Files
tidb/tests/integrationtest/t/session/session.test

144 lines
4.9 KiB
Plaintext

# TestTruncateAlloc
# It tests that the auto_increment ID does not reuse the old table's allocator.
drop table if exists truncate_id;
create table truncate_id (a int primary key auto_increment);
insert truncate_id values (), (), (), (), (), (), (), (), (), ();
truncate table truncate_id;
insert truncate_id values (), (), (), (), (), (), (), (), (), ();
select a from truncate_id where a > 11;
# TestIssue19127
drop table if exists issue19127;
create table issue19127 (c_int int, c_str varchar(40), primary key (c_int, c_str) ) partition by hash (c_int) partitions 4;
insert into issue19127 values (9, 'angry williams'), (10, 'thirsty hugle');
update issue19127 set c_int = c_int + 10, c_str = 'adoring stonebraker' where c_int in (10, 9);
--sorted_result
select * from issue19127;
# TestLoadClientInteractive
select @@wait_timeout;
# TestHostLengthMax
drop user if exists 'abcddfjakldfjaldddds'@'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
CREATE USER 'abcddfjakldfjaldddds'@'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
-- error 1470
CREATE USER 'abcddfjakldfjaldddds'@'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
# TestDeletePanic
drop table if exists t;
create table t (c int);
insert into t values (1), (2), (3);
delete from `t` where `c` = 1;
delete from `t` where `c` = 2;
select * from t;
# TestSpecifyIndexPrefixLength
drop table if exists t;
-- error 1089
create table t (c1 char, index(c1(3)));
-- error 1089
create table t (c1 int, index(c1(3)));
-- error 1089
create table t (c1 bit(10), index(c1(3)));
create table t (c1 char, c2 int, c3 bit(10));
-- error 1089
create index idx_c1 on t (c1(3));
-- error 1089
create index idx_c1 on t (c2(3));
-- error 1089
create index idx_c1 on t (c3(3));
drop table if exists t;
-- error 1170
create table t (c1 int, c2 blob, c3 varchar(64), index(c2));
create table t (c1 int, c2 blob, c3 varchar(64));
-- error 1170
create index idx_c1 on t (c2);
-- error 1071
create index idx_c1 on t (c2(555555));
-- error 1089
create index idx_c1 on t (c1(5));
create index idx_c1 on t (c1);
create index idx_c2 on t (c2(3));
create unique index idx_c3 on t (c3(5));
insert into t values (3, 'abc', 'def');
select c2 from t where c2 = 'abc';
insert into t values (4, 'abcd', 'xxx');
insert into t values (4, 'abcf', 'yyy');
select c2 from t where c2 = 'abcf';
select c2 from t where c2 = 'abcd';
insert into t values (4, 'ignore', 'abcdeXXX');
-- error 1062
insert into t values (5, 'ignore', 'abcdeYYY');
select c3 from t where c3 = 'abcde';
delete from t where c3 = 'abcdeXXX';
delete from t where c2 = 'abc';
select c2 from t where c2 > 'abcd';
select c2 from t where c2 < 'abcf';
select c2 from t where c2 >= 'abcd';
select c2 from t where c2 <= 'abcf';
select c2 from t where c2 != 'abc';
select c2 from t where c2 != 'abcd';
drop table if exists t1;
create table t1 (a int, b char(255), key(a, b(20)));
insert into t1 values (0, '1');
update t1 set b = b + 1 where a = 0;
select b from t1 where a = 0;
drop table if exists t;
create table t (a text, b text, c int, index (a(3), b(3), c));
insert into t values ('abc', 'abcd', 1);
insert into t values ('abcx', 'abcf', 2);
insert into t values ('abcy', 'abcf', 3);
insert into t values ('bbc', 'abcd', 4);
insert into t values ('bbcz', 'abcd', 5);
insert into t values ('cbck', 'abd', 6);
select c from t where a = 'abc' and b <= 'abc';
select c from t where a = 'abc' and b <= 'abd';
select c from t where a < 'cbc' and b > 'abcd';
select c from t where a <= 'abd' and b > 'abc';
select c from t where a < 'bbcc' and b = 'abcd';
select c from t where a > 'bbcf';
# TestLastInsertID
drop table if exists t;
create table t (c1 int not null auto_increment, c2 int, PRIMARY KEY (c1));
insert into t set c2 = 11;
select last_insert_id();
insert into t (c2) values (22), (33), (44);
select last_insert_id();
insert into t (c1, c2) values (10, 55);
select last_insert_id();
replace t (c2) values(66);
select * from t;
select last_insert_id();
update t set c1=last_insert_id(c1 + 100);
select * from t;
select last_insert_id();
insert into t (c2) values (77);
select last_insert_id();
drop table t;
select last_insert_id();
create table t (c2 int, c3 int, c1 int not null auto_increment, PRIMARY KEY (c1));
insert into t set c2 = 30;
prepare stmt1 from 'insert into t (c2) values (?)';
set @v1=10;
set @v2=20;
execute stmt1 using @v1;
execute stmt1 using @v2;
deallocate prepare stmt1;
select c1 from t where c2 = 20;
# https://github.com/pingcap/tidb/issues/58201
select last_insert_id(1);
select last_insert_id(0);
select last_insert_id();
# TestIssue59132
-- error 1064
VALUES ( ('foo'), ROW('bar') );
show warnings;
-- error 1064
VALUES ( ('foo'), ROW('bar') );
show warnings;
-- error 1064
VALUES ( ('foo'), ROW('bar') );
show warnings;