mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
ae5bc05988
create table t1 (a smallint primary key auto_increment); insert into t1 values(32767); insert into t1 values(NULL); ERROR 1062 (23000): Duplicate entry '32767' for key 'PRIMARY Now on always gets error HA_ERR_AUTOINC_RANGE=167 "Out of range value for column", independent of store engine, SQL Mode or number of inserted rows. This is an unique error that is easier to test for in replication. Another bug fix is that we now get an error when trying to insert a too big auto-generated value, even in non-strict mode. Before one get insted the max column value inserted. This patch also fixes some issues with inserting negative numbers in an auto-increment column. Fixed the ER_DUP_ENTRY and HA_ERR_AUTOINC_ERANGE are compared the same between master and slave. This ensures that replication works between an old server to a new slave for auto-increment overflow errors. Added SQLSTATE errors for handler errors Smaller bug fixes: * Added warnings for duplicate key errors when using INSERT IGNORE * Fixed bug when using --skip-log-bin followed by --log-bin, which did set log-bin to "0" * Allow one to see how cmake is called by using --just-print --just-configure BUILD/FINISH.sh: --just-print --just-configure now shows how cmake would be invoked. Good for understanding parameters to cmake. cmake/configure.pl: --just-print --just-configure now shows how cmake would be invoked. Good for understanding parameters to cmake. include/CMakeLists.txt: Added handler_state.h include/handler_state.h: SQLSTATE for handler error messages. Required for HA_ERR_AUTOINC_ERANGE, but solves also some other cases. mysql-test/extra/binlog_tests/binlog.test: Fixed old wrong behaviour Added more tests mysql-test/extra/binlog_tests/binlog_insert_delayed.test: Reset binary log to only print what's necessary in show_binlog_events mysql-test/extra/rpl_tests/rpl_auto_increment.test: Update to new error codes mysql-test/extra/rpl_tests/rpl_insert_delayed.test: Ignore warnings as this depends on how the test is run mysql-test/include/strict_autoinc.inc: On now gets an error on overflow mysql-test/r/auto_increment.result: Update results after fixing error message mysql-test/r/auto_increment_ranges_innodb.result: Test new behaviour mysql-test/r/auto_increment_ranges_myisam.result: Test new behaviour mysql-test/r/commit_1innodb.result: Added warnings for duplicate key error mysql-test/r/create.result: Added warnings for duplicate key error mysql-test/r/insert.result: Added warnings for duplicate key error mysql-test/r/insert_select.result: Added warnings for duplicate key error mysql-test/r/insert_update.result: Added warnings for duplicate key error mysql-test/r/mix2_myisam.result: Added warnings for duplicate key error mysql-test/r/myisam_mrr.result: Added warnings for duplicate key error mysql-test/r/null_key.result: Added warnings for duplicate key error mysql-test/r/replace.result: Update to new error codes mysql-test/r/strict_autoinc_1myisam.result: Update to new error codes mysql-test/r/strict_autoinc_2innodb.result: Update to new error codes mysql-test/r/strict_autoinc_3heap.result: Update to new error codes mysql-test/r/trigger.result: Added warnings for duplicate key error mysql-test/r/xtradb_mrr.result: Added warnings for duplicate key error mysql-test/suite/binlog/r/binlog_innodb_row.result: Updated result mysql-test/suite/binlog/r/binlog_row_binlog.result: Out of range data for auto-increment is not inserted anymore mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result: Updated result mysql-test/suite/binlog/r/binlog_stm_binlog.result: Out of range data for auto-increment is not inserted anymore mysql-test/suite/binlog/r/binlog_unsafe.result: Updated result mysql-test/suite/innodb/r/innodb-autoinc.result: Update to new error codes mysql-test/suite/innodb/r/innodb-lock.result: Updated results mysql-test/suite/innodb/r/innodb.result: Updated results mysql-test/suite/innodb/r/innodb_bug56947.result: Updated results mysql-test/suite/innodb/r/innodb_mysql.result: Updated results mysql-test/suite/innodb/t/innodb-autoinc.test: Update to new error codes mysql-test/suite/maria/maria3.result: Updated result mysql-test/suite/maria/mrr.result: Updated result mysql-test/suite/optimizer_unfixed_bugs/r/bug43617.result: Updated result mysql-test/suite/rpl/r/rpl_auto_increment.result: Update to new error codes mysql-test/suite/rpl/r/rpl_insert_delayed,stmt.rdiff: Updated results mysql-test/suite/rpl/r/rpl_loaddatalocal.result: Updated results mysql-test/t/auto_increment.test: Update to new error codes mysql-test/t/auto_increment_ranges.inc: Test new behaviour mysql-test/t/auto_increment_ranges_innodb.test: Test new behaviour mysql-test/t/auto_increment_ranges_myisam.test: Test new behaviour mysql-test/t/replace.test: Update to new error codes mysys/my_getopt.c: Fixed bug when using --skip-log-bin followed by --log-bin, which did set log-bin to "0" sql/handler.cc: Ignore negative values for signed auto-increment columns Always give an error if we get an overflow for an auto-increment-column (instead of inserting the max value) Ensure that the row number is correct for the out-of-range-value error message. ****** Fixed wrong printing of column namn for "Out of range value" errors Fixed that INSERT_ID is correctly replicated also for out-of-range autoincrement values Fixed that print_keydup_error() can also be used to generate warnings ****** Return HA_ERR_AUTOINC_ERANGE (167) instead of ER_WARN_DATA_OUT_OF_RANGE for auto-increment overflow sql/handler.h: Allow INSERT IGNORE to continue also after out-of-range inserts. Fixed that print_keydup_error() can also be used to generate warnings sql/log_event.cc: Added DBUG_PRINT Fixed the ER_AUTOINC_READ_FAILED, ER_DUP_ENTRY and HA_ERR_AUTOINC_ERANGE are compared the same between master and slave. This ensures that replication works between an old server to a new slave for auto-increment overflow errors. sql/sql_insert.cc: Add warnings for duplicate key errors when using INSERT IGNORE sql/sql_state.c: Added handler errors sql/sql_table.cc: Update call to print_keydup_error() storage/innobase/handler/ha_innodb.cc: Fixed increment handling of auto-increment columns to be consistent with rest of MariaDB. storage/xtradb/handler/ha_innodb.cc: Fixed increment handling of auto-increment columns to be consistent with rest of MariaDB.
851 lines
26 KiB
Text
851 lines
26 KiB
Text
drop table if exists t1,t2,t3,t4;
|
|
set @save_storage_engine= @@storage_engine;
|
|
set storage_engine=InnoDB;
|
|
set @innodb_mrr_tmp=@@optimizer_switch;
|
|
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
|
|
create table t1(a int);
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`a` int(11) DEFAULT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
|
create table t2(a int);
|
|
insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C;
|
|
create table t3 (
|
|
a char(8) not null, b char(8) not null, filler char(200),
|
|
key(a)
|
|
);
|
|
insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A;
|
|
insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'),
|
|
'filler-1' from t2 A;
|
|
insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'),
|
|
'filler-2' from t2 A;
|
|
select a,filler from t3 where a >= 'c-9011=w';
|
|
a filler
|
|
select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w';
|
|
a filler
|
|
c-1011=w filler
|
|
c-1012=w filler
|
|
c-1013=w filler
|
|
c-1014=w filler
|
|
c-1015=w filler
|
|
c-1011=w filler-1
|
|
c-1012=w filler-1
|
|
c-1013=w filler-1
|
|
c-1014=w filler-1
|
|
c-1015=w filler-1
|
|
c-1011=w filler-2
|
|
c-1012=w filler-2
|
|
c-1013=w filler-2
|
|
c-1014=w filler-2
|
|
c-1015=w filler-2
|
|
select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or
|
|
(a>='c-1014=w' and a <= 'c-1015=w');
|
|
a filler
|
|
c-1011=w filler
|
|
c-1012=w filler
|
|
c-1013=w filler
|
|
c-1014=w filler
|
|
c-1015=w filler
|
|
c-1011=w filler-1
|
|
c-1012=w filler-1
|
|
c-1013=w filler-1
|
|
c-1014=w filler-1
|
|
c-1015=w filler-1
|
|
c-1011=w filler-2
|
|
c-1012=w filler-2
|
|
c-1013=w filler-2
|
|
c-1014=w filler-2
|
|
c-1015=w filler-2
|
|
insert into t3 values ('c-1013=z', 'c-1013=z', 'err');
|
|
insert into t3 values ('a-1014=w', 'a-1014=w', 'err');
|
|
select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or
|
|
(a>='c-1014=w' and a <= 'c-1015=w');
|
|
a filler
|
|
c-1011=w filler
|
|
c-1012=w filler
|
|
c-1013=w filler
|
|
c-1014=w filler
|
|
c-1015=w filler
|
|
c-1011=w filler-1
|
|
c-1012=w filler-1
|
|
c-1013=w filler-1
|
|
c-1014=w filler-1
|
|
c-1015=w filler-1
|
|
c-1011=w filler-2
|
|
c-1012=w filler-2
|
|
c-1013=w filler-2
|
|
c-1014=w filler-2
|
|
c-1015=w filler-2
|
|
delete from t3 where b in ('c-1013=z', 'a-1014=w');
|
|
select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or
|
|
a='c-1014=w' or a='c-1015=w';
|
|
a filler
|
|
c-1011=w filler
|
|
c-1012=w filler
|
|
c-1013=w filler
|
|
c-1014=w filler
|
|
c-1015=w filler
|
|
c-1011=w filler-1
|
|
c-1012=w filler-1
|
|
c-1013=w filler-1
|
|
c-1014=w filler-1
|
|
c-1015=w filler-1
|
|
c-1011=w filler-2
|
|
c-1012=w filler-2
|
|
c-1013=w filler-2
|
|
c-1014=w filler-2
|
|
c-1015=w filler-2
|
|
insert into t3 values ('c-1013=w', 'del-me', 'inserted');
|
|
select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or
|
|
a='c-1014=w' or a='c-1015=w';
|
|
a filler
|
|
c-1011=w filler
|
|
c-1012=w filler
|
|
c-1013=w filler
|
|
c-1014=w filler
|
|
c-1015=w filler
|
|
c-1011=w filler-1
|
|
c-1012=w filler-1
|
|
c-1013=w filler-1
|
|
c-1014=w filler-1
|
|
c-1015=w filler-1
|
|
c-1011=w filler-2
|
|
c-1012=w filler-2
|
|
c-1013=w filler-2
|
|
c-1014=w filler-2
|
|
c-1015=w filler-2
|
|
c-1013=w inserted
|
|
delete from t3 where b='del-me';
|
|
alter table t3 add primary key(b);
|
|
select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or
|
|
b IN ('c-1019=w', 'c-1020=w', 'c-1021=w',
|
|
'c-1022=w', 'c-1023=w', 'c-1024=w');
|
|
b filler
|
|
c-1011=w filler
|
|
c-1012=w filler
|
|
c-1013=w filler
|
|
c-1014=w filler
|
|
c-1015=w filler
|
|
c-1016=w filler
|
|
c-1017=w filler
|
|
c-1018=w filler
|
|
c-1019=w filler
|
|
c-1020=w filler
|
|
c-1021=w filler
|
|
c-1022=w filler
|
|
c-1023=w filler
|
|
c-1024=w filler
|
|
select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or
|
|
b IN ('c-1021=w', 'c-1022=w', 'c-1023=w');
|
|
b filler
|
|
c-1011=w filler
|
|
c-1012=w filler
|
|
c-1013=w filler
|
|
c-1014=w filler
|
|
c-1015=w filler
|
|
c-1016=w filler
|
|
c-1017=w filler
|
|
c-1018=w filler
|
|
c-1019=w filler
|
|
c-1020=w filler
|
|
c-1021=w filler
|
|
c-1022=w filler
|
|
c-1023=w filler
|
|
select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or
|
|
b IN ('c-1019=w', 'c-1020=w') or
|
|
(b>='c-1021=w' and b<= 'c-1023=w');
|
|
b filler
|
|
c-1011=w filler
|
|
c-1012=w filler
|
|
c-1013=w filler
|
|
c-1014=w filler
|
|
c-1015=w filler
|
|
c-1016=w filler
|
|
c-1017=w filler
|
|
c-1018=w filler
|
|
c-1019=w filler
|
|
c-1020=w filler
|
|
c-1021=w filler
|
|
c-1022=w filler
|
|
c-1023=w filler
|
|
drop table if exists t4;
|
|
create table t4 (a varchar(10), b int, c char(10), filler char(200),
|
|
key idx1 (a, b, c));
|
|
insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15;
|
|
insert into t4 (a,b,c,filler)
|
|
select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15;
|
|
insert into t4 (a,b,c,filler)
|
|
select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15;
|
|
insert into t4 (a,b,c,filler)
|
|
select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15;
|
|
insert into t4 (a,b,c,filler)
|
|
select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500;
|
|
explain
|
|
select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1'
|
|
or c='no-such-row2');
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE t4 range idx1 idx1 29 NULL 16 Using index condition; Using where; Rowid-ordered scan
|
|
select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1'
|
|
or c='no-such-row2');
|
|
a b c filler
|
|
NULL NULL NULL NULL-15
|
|
NULL NULL NULL NULL-14
|
|
NULL NULL NULL NULL-13
|
|
NULL NULL NULL NULL-12
|
|
NULL NULL NULL NULL-11
|
|
NULL NULL NULL NULL-10
|
|
NULL NULL NULL NULL-9
|
|
NULL NULL NULL NULL-8
|
|
NULL NULL NULL NULL-7
|
|
NULL NULL NULL NULL-6
|
|
NULL NULL NULL NULL-5
|
|
NULL NULL NULL NULL-4
|
|
NULL NULL NULL NULL-3
|
|
NULL NULL NULL NULL-2
|
|
NULL NULL NULL NULL-1
|
|
explain
|
|
select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2');
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE t4 range idx1 idx1 29 NULL 32 Using index condition; Using where; Rowid-ordered scan
|
|
select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2');
|
|
a b c filler
|
|
b-1 NULL c-1 NULL-15
|
|
b-1 NULL c-1 NULL-14
|
|
b-1 NULL c-1 NULL-13
|
|
b-1 NULL c-1 NULL-12
|
|
b-1 NULL c-1 NULL-11
|
|
b-1 NULL c-1 NULL-10
|
|
b-1 NULL c-1 NULL-9
|
|
b-1 NULL c-1 NULL-8
|
|
b-1 NULL c-1 NULL-7
|
|
b-1 NULL c-1 NULL-6
|
|
b-1 NULL c-1 NULL-5
|
|
b-1 NULL c-1 NULL-4
|
|
b-1 NULL c-1 NULL-3
|
|
b-1 NULL c-1 NULL-2
|
|
b-1 NULL c-1 NULL-1
|
|
bb-1 NULL cc-2 NULL-15
|
|
bb-1 NULL cc-2 NULL-14
|
|
bb-1 NULL cc-2 NULL-13
|
|
bb-1 NULL cc-2 NULL-12
|
|
bb-1 NULL cc-2 NULL-11
|
|
bb-1 NULL cc-2 NULL-10
|
|
bb-1 NULL cc-2 NULL-9
|
|
bb-1 NULL cc-2 NULL-8
|
|
bb-1 NULL cc-2 NULL-7
|
|
bb-1 NULL cc-2 NULL-6
|
|
bb-1 NULL cc-2 NULL-5
|
|
bb-1 NULL cc-2 NULL-4
|
|
bb-1 NULL cc-2 NULL-3
|
|
bb-1 NULL cc-2 NULL-2
|
|
bb-1 NULL cc-2 NULL-1
|
|
select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2');
|
|
a b c filler
|
|
b-1 NULL c-1 NULL-15
|
|
b-1 NULL c-1 NULL-14
|
|
b-1 NULL c-1 NULL-13
|
|
b-1 NULL c-1 NULL-12
|
|
b-1 NULL c-1 NULL-11
|
|
b-1 NULL c-1 NULL-10
|
|
b-1 NULL c-1 NULL-9
|
|
b-1 NULL c-1 NULL-8
|
|
b-1 NULL c-1 NULL-7
|
|
b-1 NULL c-1 NULL-6
|
|
b-1 NULL c-1 NULL-5
|
|
b-1 NULL c-1 NULL-4
|
|
b-1 NULL c-1 NULL-3
|
|
b-1 NULL c-1 NULL-2
|
|
b-1 NULL c-1 NULL-1
|
|
bb-1 NULL cc-2 NULL-15
|
|
bb-1 NULL cc-2 NULL-14
|
|
bb-1 NULL cc-2 NULL-13
|
|
bb-1 NULL cc-2 NULL-12
|
|
bb-1 NULL cc-2 NULL-11
|
|
bb-1 NULL cc-2 NULL-10
|
|
bb-1 NULL cc-2 NULL-9
|
|
bb-1 NULL cc-2 NULL-8
|
|
bb-1 NULL cc-2 NULL-7
|
|
bb-1 NULL cc-2 NULL-6
|
|
bb-1 NULL cc-2 NULL-5
|
|
bb-1 NULL cc-2 NULL-4
|
|
bb-1 NULL cc-2 NULL-3
|
|
bb-1 NULL cc-2 NULL-2
|
|
bb-1 NULL cc-2 NULL-1
|
|
drop table t1, t2, t3, t4;
|
|
create table t1 (a int, b int not null,unique key (a,b),index(b));
|
|
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
|
|
Warnings:
|
|
Warning 1062 Duplicate entry '6-6' for key 'a'
|
|
create table t2 like t1;
|
|
insert into t2 select * from t1;
|
|
alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
|
|
select * from t1 where a is null;
|
|
a b c
|
|
NULL 7 0
|
|
NULL 9 0
|
|
NULL 9 0
|
|
select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3;
|
|
a b c
|
|
NULL 9 0
|
|
NULL 9 0
|
|
select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
|
|
a b c
|
|
NULL 7 0
|
|
NULL 9 0
|
|
NULL 9 0
|
|
drop table t1, t2;
|
|
set storage_engine= @save_storage_engine;
|
|
set @mrr_buffer_size_save= @@mrr_buffer_size;
|
|
set mrr_buffer_size=64;
|
|
Warnings:
|
|
Warning 1292 Truncated incorrect mrr_buffer_size value: '64'
|
|
create table t1(a int);
|
|
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
|
create table t2(a char(8), b char(8), c char(8), filler char(100), key(a,b,c) ) engine=InnoDB;
|
|
insert into t2 select
|
|
concat('a-', 1000 + A.a, '-a'),
|
|
concat('b-', 1000 + B.a, '-b'),
|
|
concat('c-', 1000 + C.a, '-c'),
|
|
'filler'
|
|
from t1 A, t1 B, t1 C;
|
|
explain
|
|
select count(length(a) + length(filler)) from t2 where a>='a-1000-a' and a <'a-1001-a';
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE t2 range a a 9 NULL 99 Using index condition; Rowid-ordered scan
|
|
select count(length(a) + length(filler)) from t2 where a>='a-1000-a' and a <'a-1001-a';
|
|
count(length(a) + length(filler))
|
|
100
|
|
drop table t2;
|
|
create table t2 (a char(100), b char(100), c char(100), d int,
|
|
filler char(10), key(d), primary key (a,b,c)) engine= innodb;
|
|
insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B;
|
|
explain select * from t2 force index (d) where d < 10;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE t2 range d d 5 NULL # Using index condition; Rowid-ordered scan
|
|
drop table t2;
|
|
drop table t1;
|
|
set @@mrr_buffer_size= @mrr_buffer_size_save;
|
|
create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3))Engine=InnoDB;
|
|
select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4);
|
|
f1 f2 f3 f4
|
|
1 1 1 A
|
|
2 2 2 A
|
|
3 3 3 A
|
|
4 4 4 A
|
|
5 5 5 A
|
|
6 6 6 A
|
|
7 7 7 A
|
|
8 8 8 A
|
|
9 9 9 A
|
|
10 10 10 A
|
|
drop table t1;
|
|
|
|
BUG#37977: Wrong result returned on GROUP BY + OR + Innodb
|
|
|
|
CREATE TABLE t1 (
|
|
`pk` int(11) NOT NULL AUTO_INCREMENT,
|
|
`int_nokey` int(11) NOT NULL,
|
|
`int_key` int(11) NOT NULL,
|
|
`date_key` date NOT NULL,
|
|
`date_nokey` date NOT NULL,
|
|
`time_key` time NOT NULL,
|
|
`time_nokey` time NOT NULL,
|
|
`datetime_key` datetime NOT NULL,
|
|
`datetime_nokey` datetime NOT NULL,
|
|
`varchar_key` varchar(5) DEFAULT NULL,
|
|
`varchar_nokey` varchar(5) DEFAULT NULL,
|
|
PRIMARY KEY (`pk`),
|
|
KEY `int_key` (`int_key`),
|
|
KEY `date_key` (`date_key`),
|
|
KEY `time_key` (`time_key`),
|
|
KEY `datetime_key` (`datetime_key`),
|
|
KEY `varchar_key` (`varchar_key`)
|
|
) ENGINE=InnoDB;
|
|
INSERT INTO t1 VALUES
|
|
(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'),
|
|
(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'),
|
|
(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'),
|
|
(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL),
|
|
(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu');
|
|
select pk from t1 WHERE `varchar_key` > 'kr' group by pk;
|
|
pk
|
|
1
|
|
5
|
|
select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk;
|
|
pk
|
|
1
|
|
5
|
|
drop table t1;
|
|
#
|
|
# BUG#39447: Error with NOT NULL condition and LIMIT 1
|
|
#
|
|
CREATE TABLE t1 (
|
|
id int(11) NOT NULL,
|
|
parent_id int(11) DEFAULT NULL,
|
|
name varchar(10) DEFAULT NULL,
|
|
PRIMARY KEY (id),
|
|
KEY ind_parent_id (parent_id)
|
|
) ENGINE=InnoDB;
|
|
insert into t1 (id, parent_id, name) values
|
|
(10,NULL,'A'),
|
|
(20,10,'B'),
|
|
(30,10,'C'),
|
|
(40,NULL,'D'),
|
|
(50,40,'E'),
|
|
(60,40,'F'),
|
|
(70,NULL,'J');
|
|
SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1;
|
|
id
|
|
60
|
|
This must show type=index, extra=Using where
|
|
explain SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE t1 index NULL PRIMARY 4 NULL 1 Using where
|
|
SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1;
|
|
id parent_id name
|
|
60 40 F
|
|
drop table t1;
|
|
#
|
|
# BUG#628785: multi_range_read.cc:430: int DsMrr_impl::dsmrr_init(): Assertion `do_sort_keys || do_rowid_fetch' failed
|
|
#
|
|
set @save_join_cache_level= @@join_cache_level;
|
|
set @save_optimizer_switch= @@optimizer_switch;
|
|
SET SESSION join_cache_level=9;
|
|
Warnings:
|
|
Warning 1292 Truncated incorrect join_cache_level value: '9'
|
|
SET SESSION optimizer_switch='mrr_sort_keys=off';
|
|
CREATE TABLE `t1` (
|
|
`pk` int(11) NOT NULL AUTO_INCREMENT,
|
|
`col_int_nokey` int(11) DEFAULT NULL,
|
|
`col_int_key` int(11) DEFAULT NULL,
|
|
`col_varchar_key` varchar(1) DEFAULT NULL,
|
|
`col_varchar_nokey` varchar(1) DEFAULT NULL,
|
|
PRIMARY KEY (`pk`),
|
|
KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=latin1;
|
|
INSERT INTO `t1` VALUES (1,6,NULL,'r','r');
|
|
INSERT INTO `t1` VALUES (2,8,0,'c','c');
|
|
INSERT INTO `t1` VALUES (97,7,0,'z','z');
|
|
INSERT INTO `t1` VALUES (98,1,1,'j','j');
|
|
INSERT INTO `t1` VALUES (99,7,8,'c','c');
|
|
INSERT INTO `t1` VALUES (100,2,5,'f','f');
|
|
SELECT table1 .`col_varchar_key`
|
|
FROM t1 table1 STRAIGHT_JOIN ( t1 table3 JOIN t1 table4 ON table4 .`pk` = table3 .`col_int_nokey` ) ON table4 .`col_varchar_nokey` ;
|
|
col_varchar_key
|
|
Warnings:
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'r'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'r'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'r'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'r'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'r'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'r'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'c'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'c'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'c'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'c'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'c'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'c'
|
|
DROP TABLE t1;
|
|
set join_cache_level=@save_join_cache_level;
|
|
set optimizer_switch=@save_optimizer_switch;
|
|
#
|
|
# BUG#623300: Query with join_cache_level = 6 returns extra rows in maria-5.3-dsmrr-cpk
|
|
#
|
|
CREATE TABLE t1 (
|
|
pk int(11) NOT NULL AUTO_INCREMENT,
|
|
col_int_nokey int(11) DEFAULT NULL,
|
|
PRIMARY KEY (pk)
|
|
) ENGINE=InnoDB;
|
|
INSERT INTO t1 VALUES (10,7);
|
|
INSERT INTO t1 VALUES (11,1);
|
|
INSERT INTO t1 VALUES (12,5);
|
|
INSERT INTO t1 VALUES (13,3);
|
|
INSERT INTO t1 VALUES (14,6);
|
|
INSERT INTO t1 VALUES (15,92);
|
|
INSERT INTO t1 VALUES (16,7);
|
|
INSERT INTO t1 VALUES (17,NULL);
|
|
INSERT INTO t1 VALUES (18,3);
|
|
INSERT INTO t1 VALUES (19,5);
|
|
INSERT INTO t1 VALUES (20,1);
|
|
INSERT INTO t1 VALUES (21,2);
|
|
INSERT INTO t1 VALUES (22,NULL);
|
|
INSERT INTO t1 VALUES (23,1);
|
|
INSERT INTO t1 VALUES (24,0);
|
|
INSERT INTO t1 VALUES (25,210);
|
|
INSERT INTO t1 VALUES (26,8);
|
|
INSERT INTO t1 VALUES (27,7);
|
|
INSERT INTO t1 VALUES (28,5);
|
|
INSERT INTO t1 VALUES (29,NULL);
|
|
CREATE TABLE t2 (
|
|
pk int(11) NOT NULL AUTO_INCREMENT,
|
|
col_int_nokey int(11) DEFAULT NULL,
|
|
PRIMARY KEY (pk)
|
|
) ENGINE=InnoDB;
|
|
INSERT INTO t2 VALUES (1,NULL);
|
|
INSERT INTO t2 VALUES (2,7);
|
|
INSERT INTO t2 VALUES (3,9);
|
|
INSERT INTO t2 VALUES (4,7);
|
|
INSERT INTO t2 VALUES (5,4);
|
|
INSERT INTO t2 VALUES (6,2);
|
|
INSERT INTO t2 VALUES (7,6);
|
|
INSERT INTO t2 VALUES (8,8);
|
|
INSERT INTO t2 VALUES (9,NULL);
|
|
INSERT INTO t2 VALUES (10,5);
|
|
INSERT INTO t2 VALUES (11,NULL);
|
|
INSERT INTO t2 VALUES (12,6);
|
|
INSERT INTO t2 VALUES (13,188);
|
|
INSERT INTO t2 VALUES (14,2);
|
|
INSERT INTO t2 VALUES (15,1);
|
|
INSERT INTO t2 VALUES (16,1);
|
|
INSERT INTO t2 VALUES (17,0);
|
|
INSERT INTO t2 VALUES (18,9);
|
|
INSERT INTO t2 VALUES (19,NULL);
|
|
INSERT INTO t2 VALUES (20,4);
|
|
set @my_save_join_cache_level= @@join_cache_level;
|
|
SET join_cache_level = 0;
|
|
SELECT table2.col_int_nokey
|
|
FROM t1 table1 JOIN t2 table2 ON table2.pk = table1.col_int_nokey
|
|
WHERE table1.pk ;
|
|
col_int_nokey
|
|
2
|
|
4
|
|
4
|
|
4
|
|
6
|
|
6
|
|
6
|
|
7
|
|
8
|
|
9
|
|
9
|
|
NULL
|
|
NULL
|
|
NULL
|
|
SET join_cache_level = 6;
|
|
SELECT table2.col_int_nokey
|
|
FROM t1 table1 JOIN t2 table2 ON table2.pk = table1.col_int_nokey
|
|
WHERE table1.pk ;
|
|
col_int_nokey
|
|
2
|
|
4
|
|
4
|
|
4
|
|
6
|
|
6
|
|
6
|
|
7
|
|
8
|
|
9
|
|
9
|
|
NULL
|
|
NULL
|
|
NULL
|
|
set join_cache_level= @my_save_join_cache_level;
|
|
drop table t1, t2;
|
|
#
|
|
# BUG#623315: Query returns less rows when run with join_cache_level=6 on maria-5.3-dsmrr-cpk
|
|
#
|
|
CREATE TABLE t1 (
|
|
pk int(11) NOT NULL AUTO_INCREMENT,
|
|
col_int_nokey int(11) DEFAULT NULL,
|
|
col_int_key int(11) DEFAULT NULL,
|
|
col_varchar_key varchar(1) DEFAULT NULL,
|
|
PRIMARY KEY (pk),
|
|
KEY col_int_key (col_int_key),
|
|
KEY col_varchar_key (col_varchar_key,col_int_key)
|
|
) ENGINE=InnoDB;
|
|
INSERT INTO t1 VALUES (10,7,8,'v');
|
|
INSERT INTO t1 VALUES (11,1,9,'r');
|
|
INSERT INTO t1 VALUES (12,5,9,'a');
|
|
INSERT INTO t1 VALUES (13,3,186,'m');
|
|
INSERT INTO t1 VALUES (14,6,NULL,'y');
|
|
INSERT INTO t1 VALUES (15,92,2,'j');
|
|
INSERT INTO t1 VALUES (16,7,3,'d');
|
|
INSERT INTO t1 VALUES (17,NULL,0,'z');
|
|
INSERT INTO t1 VALUES (18,3,133,'e');
|
|
INSERT INTO t1 VALUES (19,5,1,'h');
|
|
INSERT INTO t1 VALUES (20,1,8,'b');
|
|
INSERT INTO t1 VALUES (21,2,5,'s');
|
|
INSERT INTO t1 VALUES (22,NULL,5,'e');
|
|
INSERT INTO t1 VALUES (23,1,8,'j');
|
|
INSERT INTO t1 VALUES (24,0,6,'e');
|
|
INSERT INTO t1 VALUES (25,210,51,'f');
|
|
INSERT INTO t1 VALUES (26,8,4,'v');
|
|
INSERT INTO t1 VALUES (27,7,7,'x');
|
|
INSERT INTO t1 VALUES (28,5,6,'m');
|
|
INSERT INTO t1 VALUES (29,NULL,4,'c');
|
|
set @my_save_join_cache_level= @@join_cache_level;
|
|
SET join_cache_level=6;
|
|
select count(*) from
|
|
(SELECT table2.pk FROM
|
|
t1 LEFT JOIN t1 table2 JOIN t1 table3 ON table3.col_varchar_key = table2.col_varchar_key
|
|
ON table3.col_int_nokey) foo;
|
|
count(*)
|
|
480
|
|
SET join_cache_level=0;
|
|
select count(*) from
|
|
(SELECT table2.pk FROM
|
|
t1 LEFT JOIN t1 table2 JOIN t1 table3 ON table3.col_varchar_key = table2.col_varchar_key
|
|
ON table3.col_int_nokey) foo;
|
|
count(*)
|
|
480
|
|
set join_cache_level= @my_save_join_cache_level;
|
|
drop table t1;
|
|
#
|
|
# BUG#671340: Diverging results in with mrr_sort_keys=ON|OFF and join_cache_level=5
|
|
#
|
|
CREATE TABLE t1 (
|
|
pk int(11) NOT NULL AUTO_INCREMENT,
|
|
col_int_key int(11) NOT NULL,
|
|
col_varchar_key varchar(1) NOT NULL,
|
|
col_varchar_nokey varchar(1) NOT NULL,
|
|
PRIMARY KEY (pk),
|
|
KEY col_int_key (col_int_key),
|
|
KEY col_varchar_key (col_varchar_key,col_int_key)
|
|
) ENGINE=InnoDB;
|
|
INSERT INTO t1 VALUES
|
|
(10,8,'v','v'),
|
|
(11,8,'f','f'),
|
|
(12,5,'v','v'),
|
|
(13,8,'s','s'),
|
|
(14,8,'a','a'),
|
|
(15,6,'p','p'),
|
|
(16,7,'z','z'),
|
|
(17,2,'a','a'),
|
|
(18,5,'h','h'),
|
|
(19,7,'h','h'),
|
|
(20,2,'v','v'),
|
|
(21,9,'v','v'),
|
|
(22,142,'b','b'),
|
|
(23,3,'y','y'),
|
|
(24,0,'v','v'),
|
|
(25,3,'m','m'),
|
|
(26,5,'z','z'),
|
|
(27,9,'n','n'),
|
|
(28,1,'d','d'),
|
|
(29,107,'a','a');
|
|
CREATE TABLE t2 (
|
|
pk int(11) NOT NULL AUTO_INCREMENT,
|
|
col_int_key int(11) NOT NULL,
|
|
col_varchar_key varchar(1) NOT NULL,
|
|
col_varchar_nokey varchar(1) NOT NULL,
|
|
PRIMARY KEY (pk),
|
|
KEY col_int_key (col_int_key),
|
|
KEY col_varchar_key (col_varchar_key,col_int_key)
|
|
) ENGINE=InnoDB;
|
|
INSERT INTO t2 VALUES
|
|
(1,9,'x','x'),
|
|
(2,5,'g','g'),
|
|
(3,1,'o','o'),
|
|
(4,0,'g','g'),
|
|
(5,1,'v','v'),
|
|
(6,190,'m','m'),
|
|
(7,6,'x','x'),
|
|
(8,3,'c','c'),
|
|
(9,4,'z','z'),
|
|
(10,3,'i','i'),
|
|
(11,186,'x','x'),
|
|
(12,1,'g','g'),
|
|
(13,8,'q','q'),
|
|
(14,226,'m','m'),
|
|
(15,133,'p','p'),
|
|
(16,6,'e','e'),
|
|
(17,3,'t','t'),
|
|
(18,8,'j','j'),
|
|
(19,5,'h','h'),
|
|
(20,7,'w','w');
|
|
SELECT count(*), sum(table1.col_int_key*table2.pk)
|
|
FROM
|
|
t2 AS table1, t1 AS table2, t2 AS table3
|
|
WHERE
|
|
table3.col_varchar_nokey = table2.col_varchar_key AND table3.pk > table2.col_varchar_nokey ;
|
|
count(*) sum(table1.col_int_key*table2.pk)
|
|
240 185955
|
|
Warnings:
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
|
set @my_save_join_cache_level= @@join_cache_level;
|
|
set @my_save_join_buffer_size= @@join_buffer_size;
|
|
set join_cache_level=6;
|
|
set join_buffer_size=1536;
|
|
SELECT count(*), sum(table1.col_int_key*table2.pk)
|
|
FROM
|
|
t2 AS table1, t1 AS table2, t2 AS table3
|
|
WHERE
|
|
table3.col_varchar_nokey = table2.col_varchar_key AND table3.pk > table2.col_varchar_nokey ;
|
|
count(*) sum(table1.col_int_key*table2.pk)
|
|
240 185955
|
|
drop table t1,t2;
|
|
set join_cache_level=@my_save_join_cache_level;
|
|
set join_buffer_size=@my_save_join_buffer_size;
|
|
#
|
|
# BUG#665669: Result differences on query re-execution
|
|
#
|
|
create table t1 (pk int primary key, b int, c int default 0, index idx(b)) engine=innodb;
|
|
insert into t1(pk,b) values (3, 30), (2, 20), (9, 90), (7, 70), (4, 40), (5, 50), (10, 100), (12, 120);
|
|
set @bug665669_tmp=@@optimizer_switch;
|
|
set optimizer_switch='mrr=off';
|
|
explain select * from t1 where b > 1000;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE t1 range idx idx 5 NULL 1 Using index condition
|
|
# The following two must produce indentical results:
|
|
select * from t1 where pk < 2 or pk between 3 and 4;
|
|
pk b c
|
|
3 30 0
|
|
4 40 0
|
|
select * from t1 where pk < 2 or pk between 3 and 4;
|
|
pk b c
|
|
3 30 0
|
|
4 40 0
|
|
drop table t1;
|
|
set optimizer_switch = @bug665669_tmp;
|
|
#
|
|
# Bug#43360 - Server crash with a simple multi-table update
|
|
#
|
|
CREATE TABLE t1 (
|
|
a CHAR(2) NOT NULL PRIMARY KEY,
|
|
b VARCHAR(20) NOT NULL,
|
|
KEY (b)
|
|
) ENGINE=InnoDB;
|
|
CREATE TABLE t2 (
|
|
a CHAR(2) NOT NULL PRIMARY KEY,
|
|
b VARCHAR(20) NOT NULL,
|
|
KEY (b)
|
|
) ENGINE=InnoDB;
|
|
INSERT INTO t1 VALUES
|
|
('AB','MySQLAB'),
|
|
('JA','Sun Microsystems'),
|
|
('MS','Microsoft'),
|
|
('IB','IBM- Inc.'),
|
|
('GO','Google Inc.');
|
|
INSERT INTO t2 VALUES
|
|
('AB','Sweden'),
|
|
('JA','USA'),
|
|
('MS','United States of America'),
|
|
('IB','North America'),
|
|
('GO','South America');
|
|
Warnings:
|
|
Warning 1265 Data truncated for column 'b' at row 3
|
|
UPDATE t1,t2 SET t1.b=UPPER(t1.b) WHERE t1.b LIKE 'United%';
|
|
SELECT * FROM t1;
|
|
a b
|
|
GO Google Inc.
|
|
IB IBM- Inc.
|
|
MS Microsoft
|
|
AB MySQLAB
|
|
JA Sun Microsystems
|
|
SELECT * FROM t2;
|
|
a b
|
|
IB North America
|
|
GO South America
|
|
AB Sweden
|
|
MS United States of Ame
|
|
JA USA
|
|
DROP TABLE t1,t2;
|
|
#
|
|
# Testcase backport: Bug#43249
|
|
# (Note: Fixed by patch for BUG#42580)
|
|
#
|
|
CREATE TABLE t1(c1 TIME NOT NULL, c2 TIME NULL, c3 DATE, PRIMARY KEY(c1), UNIQUE INDEX(c2)) engine=innodb;
|
|
INSERT INTO t1 VALUES('8:29:45',NULL,'2009-02-01');
|
|
SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2;
|
|
c1 c2 c3
|
|
08:29:45 NULL 2009-02-01
|
|
SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2;
|
|
c1 c2 c3
|
|
08:29:45 NULL 2009-02-01
|
|
drop table `t1`;
|
|
#
|
|
# BUG#707925: Wrong result with join_cache_level=6 optimizer_use_mrr =
|
|
# force (incremental, BKA join)
|
|
#
|
|
set @_save_join_cache_level= @@join_cache_level;
|
|
set join_cache_level = 6;
|
|
CREATE TABLE t1 (
|
|
f1 int(11), f2 int(11), f3 varchar(1), f4 varchar(1),
|
|
PRIMARY KEY (f1),
|
|
KEY (f3),
|
|
KEY (f2)
|
|
) ENGINE=InnoDB;
|
|
INSERT INTO t1 VALUES ('11','8','f','f'),('12','5','v','v'),('13','8','s','s'),
|
|
('14','8','a','a'),('15','6','p','p'),('16','7','z','z'),('17','2','a','a'),
|
|
('18','5','h','h'),('19','7','h','h'),('20','2','v','v'),('21','9','v','v'),
|
|
('22','142','b','b'),('23','3','y','y'),('24','0','v','v'),('25','3','m','m'),
|
|
('26','5','z','z'),('27','9','n','n'),('28','1','d','d'),('29','107','a','a');
|
|
select count(*) from (
|
|
SELECT alias1.f2
|
|
FROM
|
|
t1 AS alias1 JOIN (
|
|
t1 AS alias2 FORCE KEY (f3) JOIN
|
|
t1 AS alias3 FORCE KEY (f2) ON alias3.f2 = alias2.f2 AND alias3.f4 = alias2.f3
|
|
) ON alias3.f1 <= alias2.f1
|
|
) X;
|
|
count(*)
|
|
361
|
|
set join_cache_level=@_save_join_cache_level;
|
|
set optimizer_switch= @innodb_mrr_tmp;
|
|
drop table t1;
|