Files
tidb/tests/integrationtest/r/executor/autoid.result

845 lines
20 KiB
Plaintext

drop table if exists t0, t1, t2, t3, t4, t5, t6, t7, t8, t9;
create table t0 (a tinyint signed key auto_increment) ;
insert into t0 values (-128);
insert into t0 values ();
insert into t0 values (0);
insert into t0 values ();
insert into t0 values (127);
insert into t0 values ();
Error 1690 (22003): constant 128 overflows tinyint
select * from t0 order by a;
a
-128
1
2
3
127
drop table t0;
create table t1 (a tinyint unsigned key auto_increment) ;
insert into t1 values (0);
insert into t1 values ();
insert into t1 values (127);
insert into t1 values ();
insert into t1 values (255);
insert into t1 values ();
Error 1690 (22003): constant 256 overflows tinyint
select * from t1 order by a;
a
1
2
127
128
255
drop table t1;
create table t2 (a smallint signed key auto_increment) ;
insert into t2 values (-32768);
insert into t2 values ();
insert into t2 values (0);
insert into t2 values ();
insert into t2 values (32767);
insert into t2 values ();
Error 1690 (22003): constant 32768 overflows smallint
select * from t2 order by a;
a
-32768
1
2
3
32767
drop table t2;
create table t3 (a smallint unsigned key auto_increment) ;
insert into t3 values (0);
insert into t3 values ();
insert into t3 values (32767);
insert into t3 values ();
insert into t3 values (65535);
insert into t3 values ();
Error 1690 (22003): constant 65536 overflows smallint
select * from t3 order by a;
a
1
2
32767
32768
65535
drop table t3;
create table t4 (a mediumint signed key auto_increment) ;
insert into t4 values (-8388608);
insert into t4 values ();
insert into t4 values (0);
insert into t4 values ();
insert into t4 values (8388607);
insert into t4 values ();
Error 1690 (22003): constant 8388608 overflows mediumint
select * from t4 order by a;
a
-8388608
1
2
3
8388607
drop table t4;
create table t5 (a mediumint unsigned key auto_increment) ;
insert into t5 values (0);
insert into t5 values ();
insert into t5 values (8388607);
insert into t5 values ();
insert into t5 values (16777215);
insert into t5 values ();
Error 1690 (22003): constant 16777216 overflows mediumint
select * from t5 order by a;
a
1
2
8388607
8388608
16777215
drop table t5;
create table t6 (a integer signed key auto_increment) ;
insert into t6 values (-2147483648);
insert into t6 values ();
insert into t6 values (0);
insert into t6 values ();
insert into t6 values (2147483647);
insert into t6 values ();
Error 1690 (22003): constant 2147483648 overflows int
select * from t6 order by a;
a
-2147483648
1
2
3
2147483647
drop table t6;
create table t7 (a integer unsigned key auto_increment) ;
insert into t7 values (0);
insert into t7 values ();
insert into t7 values (2147483647);
insert into t7 values ();
insert into t7 values (4294967295);
insert into t7 values ();
Error 1690 (22003): constant 4294967296 overflows int
select * from t7 order by a;
a
1
2
2147483647
2147483648
4294967295
drop table t7;
create table t8 (a bigint signed key auto_increment) ;
insert into t8 values (-9223372036854775808);
insert into t8 values ();
insert into t8 values (0);
insert into t8 values ();
insert into t8 values (9223372036854775807);
insert into t8 values ();
Error 1467 (HY000): Failed to read auto-increment value from storage engine
select * from t8 order by a;
a
-9223372036854775808
1
2
3
9223372036854775807
drop table t8;
create table t9 (a bigint unsigned key auto_increment) ;
insert into t9 values (0);
insert into t9 values ();
insert into t9 values (9223372036854775807);
insert into t9 values ();
select * from t9 order by a;
a
1
2
9223372036854775807
9223372036854775808
drop table t9;
create table t0 (a tinyint signed key auto_increment) auto_id_cache 1;
insert into t0 values (-128);
insert into t0 values ();
insert into t0 values (0);
insert into t0 values ();
insert into t0 values (127);
insert into t0 values ();
Error 1690 (22003): constant 128 overflows tinyint
select * from t0 order by a;
a
-128
1
2
3
127
drop table t0;
create table t1 (a tinyint unsigned key auto_increment) auto_id_cache 1;
insert into t1 values (0);
insert into t1 values ();
insert into t1 values (127);
insert into t1 values ();
insert into t1 values (255);
insert into t1 values ();
Error 1690 (22003): constant 256 overflows tinyint
select * from t1 order by a;
a
1
2
127
128
255
drop table t1;
create table t2 (a smallint signed key auto_increment) auto_id_cache 1;
insert into t2 values (-32768);
insert into t2 values ();
insert into t2 values (0);
insert into t2 values ();
insert into t2 values (32767);
insert into t2 values ();
Error 1690 (22003): constant 32768 overflows smallint
select * from t2 order by a;
a
-32768
1
2
3
32767
drop table t2;
create table t3 (a smallint unsigned key auto_increment) auto_id_cache 1;
insert into t3 values (0);
insert into t3 values ();
insert into t3 values (32767);
insert into t3 values ();
insert into t3 values (65535);
insert into t3 values ();
Error 1690 (22003): constant 65536 overflows smallint
select * from t3 order by a;
a
1
2
32767
32768
65535
drop table t3;
create table t4 (a mediumint signed key auto_increment) auto_id_cache 1;
insert into t4 values (-8388608);
insert into t4 values ();
insert into t4 values (0);
insert into t4 values ();
insert into t4 values (8388607);
insert into t4 values ();
Error 1690 (22003): constant 8388608 overflows mediumint
select * from t4 order by a;
a
-8388608
1
2
3
8388607
drop table t4;
create table t5 (a mediumint unsigned key auto_increment) auto_id_cache 1;
insert into t5 values (0);
insert into t5 values ();
insert into t5 values (8388607);
insert into t5 values ();
insert into t5 values (16777215);
insert into t5 values ();
Error 1690 (22003): constant 16777216 overflows mediumint
select * from t5 order by a;
a
1
2
8388607
8388608
16777215
drop table t5;
create table t6 (a integer signed key auto_increment) auto_id_cache 1;
insert into t6 values (-2147483648);
insert into t6 values ();
insert into t6 values (0);
insert into t6 values ();
insert into t6 values (2147483647);
insert into t6 values ();
Error 1690 (22003): constant 2147483648 overflows int
select * from t6 order by a;
a
-2147483648
1
2
3
2147483647
drop table t6;
create table t7 (a integer unsigned key auto_increment) auto_id_cache 1;
insert into t7 values (0);
insert into t7 values ();
insert into t7 values (2147483647);
insert into t7 values ();
insert into t7 values (4294967295);
insert into t7 values ();
Error 1690 (22003): constant 4294967296 overflows int
select * from t7 order by a;
a
1
2
2147483647
2147483648
4294967295
drop table t7;
create table t8 (a bigint signed key auto_increment) auto_id_cache 1;
insert into t8 values (-9223372036854775808);
insert into t8 values ();
insert into t8 values (0);
insert into t8 values ();
insert into t8 values (9223372036854775807);
insert into t8 values ();
Error 1105 (HY000): auto increment action failed
select * from t8 order by a;
a
-9223372036854775808
1
2
3
9223372036854775807
drop table t8;
create table t9 (a bigint unsigned key auto_increment) auto_id_cache 1;
insert into t9 values (0);
insert into t9 values ();
insert into t9 values (9223372036854775807);
insert into t9 values ();
select * from t9 order by a;
a
1
2
9223372036854775807
9223372036854775808
drop table t9;
create table t0 (a tinyint signed key auto_increment) auto_id_cache 100;
insert into t0 values (-128);
insert into t0 values ();
insert into t0 values (0);
insert into t0 values ();
insert into t0 values (127);
insert into t0 values ();
Error 1690 (22003): constant 128 overflows tinyint
select * from t0 order by a;
a
-128
1
2
3
127
drop table t0;
create table t1 (a tinyint unsigned key auto_increment) auto_id_cache 100;
insert into t1 values (0);
insert into t1 values ();
insert into t1 values (127);
insert into t1 values ();
insert into t1 values (255);
insert into t1 values ();
Error 1690 (22003): constant 256 overflows tinyint
select * from t1 order by a;
a
1
2
127
128
255
drop table t1;
create table t2 (a smallint signed key auto_increment) auto_id_cache 100;
insert into t2 values (-32768);
insert into t2 values ();
insert into t2 values (0);
insert into t2 values ();
insert into t2 values (32767);
insert into t2 values ();
Error 1690 (22003): constant 32768 overflows smallint
select * from t2 order by a;
a
-32768
1
2
3
32767
drop table t2;
create table t3 (a smallint unsigned key auto_increment) auto_id_cache 100;
insert into t3 values (0);
insert into t3 values ();
insert into t3 values (32767);
insert into t3 values ();
insert into t3 values (65535);
insert into t3 values ();
Error 1690 (22003): constant 65536 overflows smallint
select * from t3 order by a;
a
1
2
32767
32768
65535
drop table t3;
create table t4 (a mediumint signed key auto_increment) auto_id_cache 100;
insert into t4 values (-8388608);
insert into t4 values ();
insert into t4 values (0);
insert into t4 values ();
insert into t4 values (8388607);
insert into t4 values ();
Error 1690 (22003): constant 8388608 overflows mediumint
select * from t4 order by a;
a
-8388608
1
2
3
8388607
drop table t4;
create table t5 (a mediumint unsigned key auto_increment) auto_id_cache 100;
insert into t5 values (0);
insert into t5 values ();
insert into t5 values (8388607);
insert into t5 values ();
insert into t5 values (16777215);
insert into t5 values ();
Error 1690 (22003): constant 16777216 overflows mediumint
select * from t5 order by a;
a
1
2
8388607
8388608
16777215
drop table t5;
create table t6 (a integer signed key auto_increment) auto_id_cache 100;
insert into t6 values (-2147483648);
insert into t6 values ();
insert into t6 values (0);
insert into t6 values ();
insert into t6 values (2147483647);
insert into t6 values ();
Error 1690 (22003): constant 2147483648 overflows int
select * from t6 order by a;
a
-2147483648
1
2
3
2147483647
drop table t6;
create table t7 (a integer unsigned key auto_increment) auto_id_cache 100;
insert into t7 values (0);
insert into t7 values ();
insert into t7 values (2147483647);
insert into t7 values ();
insert into t7 values (4294967295);
insert into t7 values ();
Error 1690 (22003): constant 4294967296 overflows int
select * from t7 order by a;
a
1
2
2147483647
2147483648
4294967295
drop table t7;
create table t8 (a bigint signed key auto_increment) auto_id_cache 100;
insert into t8 values (-9223372036854775808);
insert into t8 values ();
insert into t8 values (0);
insert into t8 values ();
insert into t8 values (9223372036854775807);
insert into t8 values ();
Error 1467 (HY000): Failed to read auto-increment value from storage engine
select * from t8 order by a;
a
-9223372036854775808
1
2
3
9223372036854775807
drop table t8;
create table t9 (a bigint unsigned key auto_increment) auto_id_cache 100;
insert into t9 values (0);
insert into t9 values ();
insert into t9 values (9223372036854775807);
insert into t9 values ();
select * from t9 order by a;
a
1
2
9223372036854775807
9223372036854775808
drop table t9;
create table t10 (a integer key auto_increment) auto_id_cache 1;
insert into t10 values (2147483648);
Error 1264 (22003): Out of range value for column 'a' at row 1
insert into t10 values (-2147483649);
Error 1264 (22003): Out of range value for column 'a' at row 1
drop table if exists t1, t2, t3, t11, t22, t33;
create table t1 (id int key auto_increment);
insert into t1 values ();
rename table t1 to t11;
insert into t11 values ();
select * from t11;
id
1
2
create table t2 (id int key auto_increment) auto_id_cache 1;
insert into t2 values ();
rename table t2 to t22;
insert into t22 values ();
select * from t22;
id
1
2
create table t3 (id int key auto_increment) auto_id_cache 100;
insert into t3 values ();
rename table t3 to t33;
insert into t33 values ();
select * from t33;
id
1
2
drop table if exists t0;
create table t0 (id int auto_increment,k int,c char(120)) ;
drop table if exists t1;
create table t1 (id int auto_increment,k int,c char(120)) engine = MyISAM;
drop table if exists t2;
create table t2 (id int auto_increment,k int,c char(120)) engine = InnoDB;
drop table if exists t3;
create table t3 (id int auto_increment,k int,c char(120)) auto_id_cache 1;
drop table if exists t4;
create table t4 (id int auto_increment,k int,c char(120)) auto_id_cache 100;
drop table if exists t5;
create table t5 (id int auto_increment,k int,c char(120),PRIMARY KEY(k, id)) ;
drop table if exists t6;
create table t6 (id int auto_increment,k int,c char(120),PRIMARY KEY(k, id)) engine = MyISAM;
drop table if exists t7;
create table t7 (id int auto_increment,k int,c char(120),PRIMARY KEY(k, id)) engine = InnoDB;
drop table if exists t8;
create table t8 (id int auto_increment,k int,c char(120),PRIMARY KEY(k, id)) auto_id_cache 1;
drop table if exists t9;
create table t9 (id int auto_increment,k int,c char(120),PRIMARY KEY(k, id)) auto_id_cache 100;
drop table if exists t10;
create table t10 (id int auto_increment,k int,c char(120),key idx_1(id)) ;
drop table if exists t11;
create table t11 (id int auto_increment,k int,c char(120),key idx_1(id)) engine = MyISAM;
drop table if exists t12;
create table t12 (id int auto_increment,k int,c char(120),key idx_1(id)) engine = InnoDB;
drop table if exists t13;
create table t13 (id int auto_increment,k int,c char(120),key idx_1(id)) auto_id_cache 1;
drop table if exists t14;
create table t14 (id int auto_increment,k int,c char(120),key idx_1(id)) auto_id_cache 100;
drop table if exists t15;
create table t15 (id int auto_increment,k int,c char(120),PRIMARY KEY(`k`, `id`), key idx_1(id)) ;
drop table if exists t16;
create table t16 (id int auto_increment,k int,c char(120),PRIMARY KEY(`k`, `id`), key idx_1(id)) engine = MyISAM;
drop table if exists t17;
create table t17 (id int auto_increment,k int,c char(120),PRIMARY KEY(`k`, `id`), key idx_1(id)) engine = InnoDB;
drop table if exists t18;
create table t18 (id int auto_increment,k int,c char(120),PRIMARY KEY(`k`, `id`), key idx_1(id)) auto_id_cache 1;
drop table if exists t19;
create table t19 (id int auto_increment,k int,c char(120),PRIMARY KEY(`k`, `id`), key idx_1(id)) auto_id_cache 100;
create table tt1 (id int);
alter table tt1 add column (c int auto_increment);
Error 8200 (HY000): unsupported add column 'c' constraint AUTO_INCREMENT when altering 'executor__autoid.tt1'
create table tt2 (id int, c int auto_increment, key c_idx(c));
alter table tt2 drop index c_idx;
drop table if exists t_473;
create table t_473 (id int key auto_increment);
insert into t_473 values ();
select * from t_473;
id
1
show table t_473 next_row_id;
DB_NAME TABLE_NAME COLUMN_NAME NEXT_GLOBAL_ROW_ID ID_TYPE
executor__autoid t_473 id 30001 _TIDB_ROWID
alter table t_473 auto_id_cache = 100;
show table t_473 next_row_id;
DB_NAME TABLE_NAME COLUMN_NAME NEXT_GLOBAL_ROW_ID ID_TYPE
executor__autoid t_473 id 30001 _TIDB_ROWID
insert into t_473 values ();
select * from t_473;
id
1
30001
show table t_473 next_row_id;
DB_NAME TABLE_NAME COLUMN_NAME NEXT_GLOBAL_ROW_ID ID_TYPE
executor__autoid t_473 id 30101 _TIDB_ROWID
alter table t_473 auto_id_cache = 1;
Error 1105 (HY000): Can't Alter AUTO_ID_CACHE between 1 and non-1, the underlying implementation is different
drop table if exists io;
set auto_increment_offset = 10;
set auto_increment_increment = 5;
create table io (a int key auto_increment);
insert into io values (null),(null),(null);
select * from io;
a
1
6
11
drop table io;
create table io (a int key auto_increment) AUTO_ID_CACHE 1;
insert into io values (null),(null),(null);
select * from io;
a
1
6
11
drop table io;
create table io (a int key auto_increment);
set auto_increment_offset = 10;
set auto_increment_increment = 2;
insert into io values (),(),();
select * from io;
a
1
3
5
delete from io;
set auto_increment_increment = 5;
insert into io values (),(),();
select * from io;
a
6
11
16
delete from io;
set auto_increment_increment = 10;
insert into io values (),(),();
select * from io;
a
20
30
40
delete from io;
set auto_increment_increment = 5;
insert into io values (),(),();
select * from io;
a
41
46
51
drop table io;
create table io (a int key auto_increment) AUTO_ID_CACHE 1;
set auto_increment_offset = 10;
set auto_increment_increment = 2;
insert into io values (),(),();
select * from io;
a
1
3
5
delete from io;
set auto_increment_increment = 5;
insert into io values (),(),();
select * from io;
a
6
11
16
delete from io;
set auto_increment_increment = 10;
insert into io values (),(),();
select * from io;
a
20
30
40
delete from io;
set auto_increment_increment = 5;
insert into io values (),(),();
select * from io;
a
41
46
51
drop table io;
set auto_increment_offset = 10;
set auto_increment_increment = 2;
create table io (a int, b int auto_increment, key(b));
insert into io(b) values (null),(null),(null);
select b from io;
b
1
3
5
select _tidb_rowid from io;
_tidb_rowid
6
7
8
delete from io;
set auto_increment_increment = 10;
insert into io(b) values (null),(null),(null);
select b from io;
b
10
20
30
select _tidb_rowid from io;
_tidb_rowid
31
32
33
drop table io;
set auto_increment_offset = 10;
set auto_increment_increment = 2;
create table io (a int, b int auto_increment, key(b)) AUTO_ID_CACHE 1;
insert into io(b) values (null),(null),(null);
select b from io;
b
1
3
5
select _tidb_rowid from io;
_tidb_rowid
1
2
3
delete from io;
set auto_increment_increment = 10;
insert into io(b) values (null),(null),(null);
select b from io;
b
10
20
30
select _tidb_rowid from io;
_tidb_rowid
4
5
6
drop table io;
set auto_increment_offset = -1;
show warnings;
Level Code Message
Warning 1292 Truncated incorrect auto_increment_offset value: '-1'
set auto_increment_increment = -2;
show warnings;
Level Code Message
Warning 1292 Truncated incorrect auto_increment_increment value: '-2'
show variables like 'auto_increment%';
Variable_name Value
auto_increment_increment 1
auto_increment_offset 1
set auto_increment_offset = 65536;
show warnings;
Level Code Message
Warning 1292 Truncated incorrect auto_increment_offset value: '65536'
set auto_increment_increment = 65536;
show warnings;
Level Code Message
Warning 1292 Truncated incorrect auto_increment_increment value: '65536'
show variables like 'auto_increment%';
Variable_name Value
auto_increment_increment 65535
auto_increment_offset 65535
set auto_increment_offset = default;
set auto_increment_increment = default;
drop table if exists issue52465;
create table issue52465 (id int primary key auto_increment, k int) AUTO_ID_CACHE=1;
insert into issue52465 (k) values (1);
insert into issue52465 values (3997, 2);
select * from issue52465 t;
id k
1 1
3997 2
insert into issue52465 (k) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
select * from issue52465;
id k
1 1
3997 2
3998 1
3999 2
4000 3
4001 4
4002 5
4003 6
4004 7
4005 8
4006 9
4007 10
insert into issue52465 (k) values (11);
select * from issue52465;
id k
1 1
3997 2
3998 1
3999 2
4000 3
4001 4
4002 5
4003 6
4004 7
4005 8
4006 9
4007 10
4008 11
drop table issue52465;
drop table if exists issue52465;
create table issue52465 (id int unsigned primary key auto_increment, k int) AUTO_ID_CACHE=1;
insert into issue52465 (k) values (1);
insert into issue52465 values (3997, 2);
select * from issue52465 t;
id k
1 1
3997 2
insert into issue52465 (k) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
select * from issue52465;
id k
1 1
3997 2
3998 1
3999 2
4000 3
4001 4
4002 5
4003 6
4004 7
4005 8
4006 9
4007 10
insert into issue52465 (k) values (11);
select * from issue52465;
id k
1 1
3997 2
3998 1
3999 2
4000 3
4001 4
4002 5
4003 6
4004 7
4005 8
4006 9
4007 10
4008 11
drop table issue52465;
drop table if exists issue58631;
set tidb_enable_clustered_index=off;
create table t(id bigint unsigned auto_increment primary key);
insert into t values(123);
select _tidb_rowid, id from t;
_tidb_rowid id
124 123
insert into t values(18446744073709551613);
select _tidb_rowid, id from t;
_tidb_rowid id
124 123
-2 18446744073709551613
insert into t values();
Error 1467 (HY000): Failed to read auto-increment value from storage engine
drop table t;
create table t(id bigint unsigned auto_increment primary key) auto_id_cache=1;
insert into t values(123);
select _tidb_rowid, id from t;
_tidb_rowid id
1 123
insert into t values(18446744073709551615);
select _tidb_rowid, id from t;
_tidb_rowid id
1 123
2 18446744073709551615
insert into t values();
Error 1105 (HY000): [autoid:1467]Failed to read auto-increment value from storage engine
set tidb_enable_clustered_index=default;