diff options
Diffstat (limited to 'mysql-test')
28 files changed, 1398 insertions, 3 deletions
diff --git a/mysql-test/r/derived_opt.result b/mysql-test/r/derived_opt.result index 11216a32e61..22e2ab8d676 100644 --- a/mysql-test/r/derived_opt.result +++ b/mysql-test/r/derived_opt.result @@ -282,4 +282,74 @@ CREATE TABLE t1 ( i INT ); INSERT INTO t1 VALUES ( (SELECT 1 FROM ( SELECT * FROM t1 ) as a) ); drop table t1; set optimizer_switch=@save_optimizer_switch; +# +# MDEV-3801 Reproducible sub select join crash on 5.3.8 and 5.3.9 +# +CREATE TABLE t1 ( +pk int(10) unsigned NOT NULL AUTO_INCREMENT, +a char(2) DEFAULT NULL, +PRIMARY KEY (pk), +KEY a (a) +) ENGINE=MyISAM; +INSERT INTO t1 (a) +VALUES (NULL),(NULL),(NULL),('AB'),(NULL),('CD'),(NULL),(NULL); +INSERT INTO t1 SELECT NULL, a1.a FROM t1 a1, t1 a2, t1 a3, t1 a4, t1 a5; +CREATE TABLE t2 ( +pk int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +INSERT INTO t2 SELECT NULL FROM t2 a1, t2 a2, t2 a3, t2 a4, t2 a5; +CREATE TABLE t3 ( +pk int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY +) ENGINE=MyISAM; +INSERT INTO t3 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +INSERT INTO t3 SELECT NULL FROM t3 a1, t3 a2, t3 a3, t3 a4, t3 a5; +CREATE TABLE t4 ( +a char(2) NOT NULL DEFAULT '', +PRIMARY KEY (a) +) ENGINE=MyISAM; +INSERT INTO t4 VALUES ('CD'); +set @@tmp_table_size=8192; +EXPLAIN +SELECT * FROM t3 AS tx JOIN t2 AS ty ON (tx.pk = ty.pk) +WHERE +tx.pk IN +(SELECT * +FROM (SELECT DISTINCT ta.pk +FROM t3 AS ta +JOIN t2 AS tb ON (ta.pk = tb.pk) +JOIN t1 AS tc ON (tb.pk = tc.pk) +JOIN t4 AS td ON tc.a = td.a) tu) +limit 10; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL # +1 PRIMARY tx eq_ref PRIMARY PRIMARY 4 tu.pk # Using index +1 PRIMARY ty eq_ref PRIMARY PRIMARY 4 tu.pk # Using index +2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL # +3 DERIVED td system PRIMARY NULL NULL NULL # Using temporary +3 DERIVED tc ref PRIMARY,a a 3 const # +3 DERIVED ta eq_ref PRIMARY PRIMARY 4 test.tc.pk # Using index +3 DERIVED tb eq_ref PRIMARY PRIMARY 4 test.tc.pk # Using index; Distinct +SELECT * FROM t3 AS tX JOIN t2 AS tY ON (tX.pk = tY.pk) +WHERE +tX.pk IN +(SELECT * +FROM (SELECT DISTINCT tA.pk +FROM t3 AS tA +JOIN t2 AS tB ON (tA.pk = tB.pk) +JOIN t1 AS tC ON (tB.pk = tC.pk) +JOIN t4 AS tD ON tC.a = tD.a) tU) +limit 10; +pk pk +6 6 +16 16 +24 24 +32 32 +40 40 +48 48 +56 56 +64 64 +72 72 +80 80 +drop table t1, t2, t3, t4; set optimizer_switch=@exit_optimizer_switch; diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 222977e5106..9f942747594 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -2119,6 +2119,17 @@ FROM t2 GROUP BY 1; a DROP TABLE t1, t2; +FLUSH STATUS; +CREATE TABLE t1 (f1 INT, f2 decimal(20,1), f3 blob); +INSERT INTO t1 values(11,NULL,'blob'),(11,NULL,'blob'); +SELECT f3, MIN(f2) FROM t1 GROUP BY f1 LIMIT 1; +f3 MIN(f2) +blob NULL +DROP TABLE t1; +the value below *must* be 1 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 1 # End of 5.3 tests # # Bug#49771: Incorrect MIN (date) when minimum value is 0000-00-00 diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index fcb40dae4ff..9d993e723c2 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1678,6 +1678,12 @@ SELECT length(CAST(b AS CHAR)) FROM ubig; length(CAST(b AS CHAR)) 20 DROP TABLE ubig; +select 1 from information_schema.tables where table_schema=repeat('a', 2000); +1 +grant usage on *.* to mysqltest_1@localhost; +select 1 from information_schema.tables where table_schema=repeat('a', 2000); +1 +drop user mysqltest_1@localhost; End of 5.1 tests. # # Additional test for WL#3726 "DDL locking for all metadata objects" diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 40586b8d54b..86425825601 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -2394,6 +2394,12 @@ HAVING b > geomfromtext("") ); 1 DROP TABLE t1; + +MDEV-612 Valgrind error in ha_maria::check_if_incompatible_data + +CREATE TABLE t1 (a INT, b INT, KEY(a)) ENGINE=Aria PARTITION BY KEY(a) PARTITIONS 2; +ALTER TABLE t1 ADD KEY (b); +drop table t1; End of 5.1 tests # # BUG#55385: UPDATE statement throws an error, but still updates diff --git a/mysql-test/r/range_vs_index_merge.result b/mysql-test/r/range_vs_index_merge.result index faaa6d2429e..cc8a345a2ff 100644 --- a/mysql-test/r/range_vs_index_merge.result +++ b/mysql-test/r/range_vs_index_merge.result @@ -1221,6 +1221,153 @@ Lugansk UKR 469000 Seattle USA 563374 Caracas VEN 1975294 set optimizer_switch=@save_optimizer_switch; +# +# Bug mdev-585: range vs index-merge with ORDER BY ... LIMIT n +# (LP bug #637962) +# +DROP INDEX CountryPopulation ON City; +DROP INDEX CountryName ON City; +DROP INDEX CityName on City; +CREATE INDEX Name ON City(Name); +CREATE INDEX Population ON City(Population); +EXPLAIN +SELECT * FROM City +WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) +AND (Population >= 100000 AND Population < 120000); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE City index_merge Country,Name,Population Name,Country 35,3 NULL # Using sort_union(Name,Country); Using where +FLUSH STATUS; +SELECT * FROM City +WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) +AND (Population >= 100000 AND Population < 120000); +ID Name Country Population +384 Cabo Frio BRA 119503 +387 Camaragibe BRA 118968 +403 Catanduva BRA 107761 +412 Cachoeirinha BRA 103240 +508 Watford GBR 113080 +509 Ipswich GBR 114000 +510 Slough GBR 112000 +511 Exeter GBR 111000 +512 Cheltenham GBR 106000 +513 Gloucester GBR 107000 +514 Saint Helens GBR 106293 +515 Sutton Coldfield GBR 106001 +516 York GBR 104425 +517 Oldham GBR 103931 +518 Basildon GBR 100924 +519 Worthing GBR 100000 +635 Mallawi EGY 119283 +636 Bilbays EGY 113608 +637 Mit Ghamr EGY 101801 +638 al-Arish EGY 100447 +701 Tarragona ESP 113016 +702 Lleida (Lérida) ESP 112207 +703 Jaén ESP 109247 +704 Ourense (Orense) ESP 109120 +705 Mataró ESP 104095 +706 Algeciras ESP 103106 +707 Marbella ESP 101144 +759 Gonder ETH 112249 +869 Cabuyao PHL 106630 +870 Calapan PHL 105910 +873 Cauayan PHL 103952 +903 Serekunda GMB 102600 +909 Sohumi GEO 111700 +913 Tema GHA 109975 +914 Sekondi-Takoradi GHA 103653 +924 Villa Nueva GTM 101295 +1844 Cape Breton CAN 114733 +1847 Cambridge CAN 109186 +2406 Herakleion GRC 116178 +2407 Kallithea GRC 114233 +2408 Larisa GRC 113090 +2908 Cajamarca PER 108009 +3002 Besançon FRA 117733 +3003 Caen FRA 113987 +3004 Orléans FRA 113126 +3005 Mulhouse FRA 110359 +3006 Rouen FRA 106592 +3007 Boulogne-Billancourt FRA 106367 +3008 Perpignan FRA 105115 +3009 Nancy FRA 103605 +3411 Ceyhan TUR 102412 +3567 Carúpano VEN 119639 +3568 Catia La Mar VEN 117012 +3571 Calabozo VEN 107146 +3786 Cam Ranh VNM 114041 +3792 Tartu EST 101246 +4002 Carrollton USA 109576 +4027 Cape Coral USA 102286 +4032 Cambridge USA 101355 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 385 +Handler_read_prev 0 +Handler_read_rnd 377 +Handler_read_rnd_deleted 0 +Handler_read_rnd_next 0 +EXPLAIN +SELECT * FROM City +WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) +AND (Population >= 100000 AND Population < 120000) +ORDER BY Population LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE City range Country,Name,Population Population 4 NULL # Using where +FLUSH STATUS; +SELECT * FROM City +WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) +AND (Population >= 100000 AND Population < 120000) +ORDER BY Population LIMIT 5; +ID Name Country Population +519 Worthing GBR 100000 +638 al-Arish EGY 100447 +518 Basildon GBR 100924 +707 Marbella ESP 101144 +3792 Tartu EST 101246 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 59 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_deleted 0 +Handler_read_rnd_next 0 +set optimizer_switch='index_merge=off'; +EXPLAIN +SELECT * FROM City +WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) +AND (Population >= 100000 AND Population < 120000) +ORDER BY Population LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE City range Country,Name,Population Population 4 NULL # Using index condition; Using where +FLUSH STATUS; +SELECT * FROM City +WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) +AND (Population >= 100000 AND Population < 120000) +ORDER BY Population LIMIT 5; +ID Name Country Population +519 Worthing GBR 100000 +638 al-Arish EGY 100447 +518 Basildon GBR 100924 +707 Marbella ESP 101144 +3792 Tartu EST 101246 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 59 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_deleted 0 +Handler_read_rnd_next 0 +set optimizer_switch=@save_optimizer_switch; DROP DATABASE world; use test; CREATE TABLE t1 ( diff --git a/mysql-test/r/range_vs_index_merge_innodb,innodb_plugin.rdiff b/mysql-test/r/range_vs_index_merge_innodb,innodb_plugin.rdiff index 5913434caae..ecae2c809c1 100644 --- a/mysql-test/r/range_vs_index_merge_innodb,innodb_plugin.rdiff +++ b/mysql-test/r/range_vs_index_merge_innodb,innodb_plugin.rdiff @@ -1,5 +1,5 @@ ---- r/range_vs_index_merge_innodb.result 2012-03-24 17:12:02.124422000 +0100 -+++ r/range_vs_index_merge_innodb,innodb_plugin.reject 2012-03-24 18:00:13.647902620 +0100 +--- ./r/range_vs_index_merge_innodb.result 2012-11-21 19:35:14.000000000 +0100 ++++ ./r/range_vs_index_merge_innodb,innodb_plugin.reject 2012-11-21 20:56:00.000000000 +0100 @@ -50,14 +50,14 @@ WHERE (Population >= 100000 OR Name LIKE 'P%') AND Country='CAN' OR (Population < 100000 OR Name Like 'T%') AND Country='ARG'; @@ -269,3 +269,12 @@ SELECT Name, Country, Population FROM City WHERE (Name='Manila' AND Country='PHL') OR (Name='Addis Abeba' AND Country='ETH') OR +@@ -1346,7 +1346,7 @@ + AND (Population >= 100000 AND Population < 120000) + ORDER BY Population LIMIT 5; + id select_type table type possible_keys key key_len ref rows Extra +-1 SIMPLE City range Country,Name,Population Population 4 NULL # Using index condition; Using where ++1 SIMPLE City range Country,Name,Population Population 4 NULL # Using where + FLUSH STATUS; + SELECT * FROM City + WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) diff --git a/mysql-test/r/range_vs_index_merge_innodb.result b/mysql-test/r/range_vs_index_merge_innodb.result index df3a2af0753..67e341192da 100644 --- a/mysql-test/r/range_vs_index_merge_innodb.result +++ b/mysql-test/r/range_vs_index_merge_innodb.result @@ -1222,6 +1222,153 @@ Lugansk UKR 469000 Seattle USA 563374 Caracas VEN 1975294 set optimizer_switch=@save_optimizer_switch; +# +# Bug mdev-585: range vs index-merge with ORDER BY ... LIMIT n +# (LP bug #637962) +# +DROP INDEX CountryPopulation ON City; +DROP INDEX CountryName ON City; +DROP INDEX CityName on City; +CREATE INDEX Name ON City(Name); +CREATE INDEX Population ON City(Population); +EXPLAIN +SELECT * FROM City +WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) +AND (Population >= 100000 AND Population < 120000); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE City index_merge Country,Name,Population Name,Country 35,3 NULL # Using sort_union(Name,Country); Using where +FLUSH STATUS; +SELECT * FROM City +WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) +AND (Population >= 100000 AND Population < 120000); +ID Name Country Population +384 Cabo Frio BRA 119503 +387 Camaragibe BRA 118968 +403 Catanduva BRA 107761 +412 Cachoeirinha BRA 103240 +508 Watford GBR 113080 +509 Ipswich GBR 114000 +510 Slough GBR 112000 +511 Exeter GBR 111000 +512 Cheltenham GBR 106000 +513 Gloucester GBR 107000 +514 Saint Helens GBR 106293 +515 Sutton Coldfield GBR 106001 +516 York GBR 104425 +517 Oldham GBR 103931 +518 Basildon GBR 100924 +519 Worthing GBR 100000 +635 Mallawi EGY 119283 +636 Bilbays EGY 113608 +637 Mit Ghamr EGY 101801 +638 al-Arish EGY 100447 +701 Tarragona ESP 113016 +702 Lleida (Lérida) ESP 112207 +703 Jaén ESP 109247 +704 Ourense (Orense) ESP 109120 +705 Mataró ESP 104095 +706 Algeciras ESP 103106 +707 Marbella ESP 101144 +759 Gonder ETH 112249 +869 Cabuyao PHL 106630 +870 Calapan PHL 105910 +873 Cauayan PHL 103952 +903 Serekunda GMB 102600 +909 Sohumi GEO 111700 +913 Tema GHA 109975 +914 Sekondi-Takoradi GHA 103653 +924 Villa Nueva GTM 101295 +1844 Cape Breton CAN 114733 +1847 Cambridge CAN 109186 +2406 Herakleion GRC 116178 +2407 Kallithea GRC 114233 +2408 Larisa GRC 113090 +2908 Cajamarca PER 108009 +3002 Besançon FRA 117733 +3003 Caen FRA 113987 +3004 Orléans FRA 113126 +3005 Mulhouse FRA 110359 +3006 Rouen FRA 106592 +3007 Boulogne-Billancourt FRA 106367 +3008 Perpignan FRA 105115 +3009 Nancy FRA 103605 +3411 Ceyhan TUR 102412 +3567 Carúpano VEN 119639 +3568 Catia La Mar VEN 117012 +3571 Calabozo VEN 107146 +3786 Cam Ranh VNM 114041 +3792 Tartu EST 101246 +4002 Carrollton USA 109576 +4027 Cape Coral USA 102286 +4032 Cambridge USA 101355 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 385 +Handler_read_prev 0 +Handler_read_rnd 377 +Handler_read_rnd_deleted 0 +Handler_read_rnd_next 0 +EXPLAIN +SELECT * FROM City +WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) +AND (Population >= 100000 AND Population < 120000) +ORDER BY Population LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE City range Country,Name,Population Population 4 NULL # Using where +FLUSH STATUS; +SELECT * FROM City +WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) +AND (Population >= 100000 AND Population < 120000) +ORDER BY Population LIMIT 5; +ID Name Country Population +519 Worthing GBR 100000 +638 al-Arish EGY 100447 +518 Basildon GBR 100924 +707 Marbella ESP 101144 +3792 Tartu EST 101246 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 59 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_deleted 0 +Handler_read_rnd_next 0 +set optimizer_switch='index_merge=off'; +EXPLAIN +SELECT * FROM City +WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) +AND (Population >= 100000 AND Population < 120000) +ORDER BY Population LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE City range Country,Name,Population Population 4 NULL # Using index condition; Using where +FLUSH STATUS; +SELECT * FROM City +WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) +AND (Population >= 100000 AND Population < 120000) +ORDER BY Population LIMIT 5; +ID Name Country Population +519 Worthing GBR 100000 +638 al-Arish EGY 100447 +518 Basildon GBR 100924 +707 Marbella ESP 101144 +3792 Tartu EST 101246 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 59 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_deleted 0 +Handler_read_rnd_next 0 +set optimizer_switch=@save_optimizer_switch; DROP DATABASE world; use test; CREATE TABLE t1 ( diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 3134096b8c3..14347e9b899 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -6060,6 +6060,116 @@ WHERE (col_varchar_nokey, 'x') IN col_int_nokey 1 DROP TABLE ot,it1,it2; +# +# MDEV-746 +# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY +# HAS AN EMPTY RESULT +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_time_key time 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_time_key (col_time_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_time_key time 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_time_key (col_time_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b'); +SET @var2:=4, @var3:=8; + +Testcase without inner subquery +EXPLAIN SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3; +@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +SELECT @var3; +@var3 +8 +EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3 ) AS alias3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE <derived2> system NULL NULL NULL NULL 0 const row not found +2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table +SELECT * FROM ( SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3 ) AS alias3; +@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +SELECT @var3; +@var3 +8 + +Testcase with inner subquery; crashed WL#6095 +SET @var3=8; +EXPLAIN SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1 +SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)); +pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +EXPLAIN SELECT * FROM ( SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)) ) AS alias3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +3 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1 +SELECT * FROM ( SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)) ) AS alias3; +pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +DROP TABLE t1,t2; End of 5.2 tests # # BUG#779885: Crash in eliminate_item_equal with materialization=on in diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result index 43d71a08ec4..c307a68f64d 100644 --- a/mysql-test/r/subselect_no_mat.result +++ b/mysql-test/r/subselect_no_mat.result @@ -6059,6 +6059,116 @@ WHERE (col_varchar_nokey, 'x') IN col_int_nokey 1 DROP TABLE ot,it1,it2; +# +# MDEV-746 +# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY +# HAS AN EMPTY RESULT +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_time_key time 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_time_key (col_time_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_time_key time 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_time_key (col_time_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b'); +SET @var2:=4, @var3:=8; + +Testcase without inner subquery +EXPLAIN SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3; +@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +SELECT @var3; +@var3 +8 +EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3 ) AS alias3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE <derived2> system NULL NULL NULL NULL 0 const row not found +2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table +SELECT * FROM ( SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3 ) AS alias3; +@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +SELECT @var3; +@var3 +8 + +Testcase with inner subquery; crashed WL#6095 +SET @var3=8; +EXPLAIN SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1 +SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)); +pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +EXPLAIN SELECT * FROM ( SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)) ) AS alias3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +3 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1 +SELECT * FROM ( SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)) ) AS alias3; +pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +DROP TABLE t1,t2; End of 5.2 tests # # BUG#779885: Crash in eliminate_item_equal with materialization=on in diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result index 879e429d674..d1590b0df51 100644 --- a/mysql-test/r/subselect_no_opts.result +++ b/mysql-test/r/subselect_no_opts.result @@ -6055,6 +6055,116 @@ WHERE (col_varchar_nokey, 'x') IN col_int_nokey 1 DROP TABLE ot,it1,it2; +# +# MDEV-746 +# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY +# HAS AN EMPTY RESULT +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_time_key time 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_time_key (col_time_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_time_key time 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_time_key (col_time_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b'); +SET @var2:=4, @var3:=8; + +Testcase without inner subquery +EXPLAIN SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3; +@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +SELECT @var3; +@var3 +8 +EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3 ) AS alias3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE <derived2> system NULL NULL NULL NULL 0 const row not found +2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table +SELECT * FROM ( SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3 ) AS alias3; +@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +SELECT @var3; +@var3 +8 + +Testcase with inner subquery; crashed WL#6095 +SET @var3=8; +EXPLAIN SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1 +SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)); +pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +EXPLAIN SELECT * FROM ( SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)) ) AS alias3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +3 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1 +SELECT * FROM ( SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)) ) AS alias3; +pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +DROP TABLE t1,t2; End of 5.2 tests # # BUG#779885: Crash in eliminate_item_equal with materialization=on in diff --git a/mysql-test/r/subselect_no_scache.result b/mysql-test/r/subselect_no_scache.result index bf141948765..b6b5572815a 100644 --- a/mysql-test/r/subselect_no_scache.result +++ b/mysql-test/r/subselect_no_scache.result @@ -6066,6 +6066,116 @@ WHERE (col_varchar_nokey, 'x') IN col_int_nokey 1 DROP TABLE ot,it1,it2; +# +# MDEV-746 +# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY +# HAS AN EMPTY RESULT +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_time_key time 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_time_key (col_time_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_time_key time 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_time_key (col_time_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b'); +SET @var2:=4, @var3:=8; + +Testcase without inner subquery +EXPLAIN SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3; +@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +SELECT @var3; +@var3 +8 +EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3 ) AS alias3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE <derived2> system NULL NULL NULL NULL 0 const row not found +2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table +SELECT * FROM ( SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3 ) AS alias3; +@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +SELECT @var3; +@var3 +8 + +Testcase with inner subquery; crashed WL#6095 +SET @var3=8; +EXPLAIN SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1 +SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)); +pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +EXPLAIN SELECT * FROM ( SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)) ) AS alias3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +3 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1 +SELECT * FROM ( SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)) ) AS alias3; +pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +DROP TABLE t1,t2; End of 5.2 tests # # BUG#779885: Crash in eliminate_item_equal with materialization=on in diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result index 7c692e0898d..34cdb17e23e 100644 --- a/mysql-test/r/subselect_no_semijoin.result +++ b/mysql-test/r/subselect_no_semijoin.result @@ -6055,6 +6055,116 @@ WHERE (col_varchar_nokey, 'x') IN col_int_nokey 1 DROP TABLE ot,it1,it2; +# +# MDEV-746 +# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY +# HAS AN EMPTY RESULT +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_time_key time 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_time_key (col_time_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_time_key time 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_time_key (col_time_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b'); +SET @var2:=4, @var3:=8; + +Testcase without inner subquery +EXPLAIN SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3; +@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +SELECT @var3; +@var3 +8 +EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3 ) AS alias3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE <derived2> system NULL NULL NULL NULL 0 const row not found +2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table +SELECT * FROM ( SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR +sq4_alias1.col_varchar_key = @var3 ) AS alias3; +@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +SELECT @var3; +@var3 +8 + +Testcase with inner subquery; crashed WL#6095 +SET @var3=8; +EXPLAIN SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1 +SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)); +pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +EXPLAIN SELECT * FROM ( SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)) ) AS alias3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +3 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1 +SELECT * FROM ( SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) +NOT IN +(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, +c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 +FROM t2 AS c_sq1_alias1 +WHERE (c_sq1_alias1.col_int_nokey != @var2 +OR c_sq1_alias1.pk != @var3)) ) AS alias3; +pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey +DROP TABLE t1,t2; End of 5.2 tests # # BUG#779885: Crash in eliminate_item_equal with materialization=on in diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index e98dda46061..9c4fd02fcdd 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -498,4 +498,36 @@ DROP TABLE t1; # SET @bug12408412=1; SELECT GROUP_CONCAT(@bug12408412 ORDER BY 1) INTO @bug12408412; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0); +SELECT DISTINCT POW(COUNT(*), @a:=(SELECT 1 FROM t1 LEFT JOIN t1 AS t2 ON @a)) +AS b FROM t1 GROUP BY a; +b +1 +SELECT @a; +@a +1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT, f2 INT); +INSERT INTO t1 VALUES (1,2),(2,3),(3,1); +CREATE TABLE t2(a INT); +INSERT INTO t2 VALUES (1); +SET @var=NULL; +SELECT @var:=(SELECT f2 FROM t2 WHERE @var) FROM t1 GROUP BY f1 ORDER BY f2 DESC +LIMIT 1; +@var:=(SELECT f2 FROM t2 WHERE @var) +NULL +SELECT @var; +@var +NULL +DROP TABLE t1, t2; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0),(1),(3); +SELECT DISTINCT POW(COUNT(distinct a), @a:=(SELECT 1 FROM t1 LEFT JOIN t1 AS t2 ON @a limit 1)) AS b FROM t1 GROUP BY a; +b +1 +SELECT @a; +@a +1 +DROP TABLE t1; End of 5.5 tests diff --git a/mysql-test/suite/federated/federatedx.test b/mysql-test/suite/federated/federatedx.test index fd2f363ff90..15fdd47c4da 100644 --- a/mysql-test/suite/federated/federatedx.test +++ b/mysql-test/suite/federated/federatedx.test @@ -1999,4 +1999,4 @@ connection slave; SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT; connection default; -source suite/federated/include/federated_cleanup.inc; +source include/federated_cleanup.inc; diff --git a/mysql-test/suite/heap/heap_hash.result b/mysql-test/suite/heap/heap_hash.result index ac62427c81c..55d43588403 100644 --- a/mysql-test/suite/heap/heap_hash.result +++ b/mysql-test/suite/heap/heap_hash.result @@ -382,6 +382,26 @@ INSERT INTO t1 VALUES('A ', 'A '); ERROR 23000: Duplicate entry 'A -A ' for key 'key1' DROP TABLE t1; End of 5.0 tests +# +# MDEV-568 (AKA LP BUG#1007981, AKA MySQL bug#44771) +# Wrong result for a hash index look-up if the index is unique and +# the key is NULL +# +CREATE TABLE t1 ( pk INT PRIMARY KEY, val INT, UNIQUE KEY USING HASH(val)) ENGINE=MEMORY; +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, NULL); +INSERT INTO t1 VALUES (3, 1); +INSERT INTO t1 VALUES (4, NULL); +EXPLAIN SELECT * FROM t1 WHERE val IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref val val 5 const 1 Using where +SELECT * FROM t1 WHERE val IS NULL; +pk val +4 NULL +2 NULL +1 NULL +drop table t1; +End of 5.2 tests # bit index in heap tables create table t1 (a bit(63) not null) engine=heap; insert into t1 values (869751),(736494),(226312),(802616),(728912); diff --git a/mysql-test/suite/heap/heap_hash.test b/mysql-test/suite/heap/heap_hash.test index 80d6ef9c8f2..3fe95e14205 100644 --- a/mysql-test/suite/heap/heap_hash.test +++ b/mysql-test/suite/heap/heap_hash.test @@ -285,6 +285,23 @@ DROP TABLE t1; --echo End of 5.0 tests +--echo # +--echo # MDEV-568 (AKA LP BUG#1007981, AKA MySQL bug#44771) +--echo # Wrong result for a hash index look-up if the index is unique and +--echo # the key is NULL +--echo # +CREATE TABLE t1 ( pk INT PRIMARY KEY, val INT, UNIQUE KEY USING HASH(val)) ENGINE=MEMORY; + +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, NULL); +INSERT INTO t1 VALUES (3, 1); +INSERT INTO t1 VALUES (4, NULL); +EXPLAIN SELECT * FROM t1 WHERE val IS NULL; +SELECT * FROM t1 WHERE val IS NULL; +drop table t1; + +--echo End of 5.2 tests + -- echo # bit index in heap tables create table t1 (a bit(63) not null) engine=heap; diff --git a/mysql-test/suite/plugins/t/audit_null.test b/mysql-test/suite/plugins/t/audit_null.test index da86e602c6b..428fd0c276e 100644 --- a/mysql-test/suite/plugins/t/audit_null.test +++ b/mysql-test/suite/plugins/t/audit_null.test @@ -1,4 +1,6 @@ +--source include/not_embedded.inc + if (!$ADT_NULL_SO) { skip No NULL_AUDIT plugin; } diff --git a/mysql-test/suite/vcol/inc/vcol_trigger_sp.inc b/mysql-test/suite/vcol/inc/vcol_trigger_sp.inc index ddf13fef6a1..eb7e6ad32b9 100644 --- a/mysql-test/suite/vcol/inc/vcol_trigger_sp.inc +++ b/mysql-test/suite/vcol/inc/vcol_trigger_sp.inc @@ -108,3 +108,44 @@ select * from t1; drop table t1,t2; drop procedure p1; + +--echo # +--echo # Bug mdev-3845: values of virtual columns are not computed for triggers +--echo # + +CREATE TABLE t1 ( + a INTEGER UNSIGNED NULL DEFAULT NULL, + b INTEGER UNSIGNED GENERATED ALWAYS AS (a) VIRTUAL +); + +CREATE TABLE t2 (c INTEGER UNSIGNED NOT NULL); + +DELIMITER |; + +CREATE TRIGGER t1_ins_aft + AFTER INSERT + ON t1 + FOR EACH ROW +BEGIN + INSERT INTO t2 (c) VALUES (NEW.b); +END | + +CREATE TRIGGER t1_del_bef + BEFORE DELETE + ON t1 + FOR EACH ROW +BEGIN + INSERT INTO t2 (c) VALUES (OLD.b); +END | + +DELIMITER ;| + +INSERT INTO t1 (a) VALUES (1), (2), (3); +SELECT * FROM t2; +DELETE FROM t1; +SELECT * FROM t2; + +DROP TRIGGER t1_ins_aft; +DROP TRIGGER t1_del_bef; +DROP TABLE t1,t2; + diff --git a/mysql-test/suite/vcol/r/vcol_trigger_sp_innodb.result b/mysql-test/suite/vcol/r/vcol_trigger_sp_innodb.result index e903bc4eafd..1d78bbf50e4 100644 --- a/mysql-test/suite/vcol/r/vcol_trigger_sp_innodb.result +++ b/mysql-test/suite/vcol/r/vcol_trigger_sp_innodb.result @@ -85,3 +85,43 @@ a b c 300 30 30 drop table t1,t2; drop procedure p1; +# +# Bug mdev-3845: values of virtual columns are not computed for triggers +# +CREATE TABLE t1 ( +a INTEGER UNSIGNED NULL DEFAULT NULL, +b INTEGER UNSIGNED GENERATED ALWAYS AS (a) VIRTUAL +); +CREATE TABLE t2 (c INTEGER UNSIGNED NOT NULL); +CREATE TRIGGER t1_ins_aft +AFTER INSERT +ON t1 +FOR EACH ROW +BEGIN +INSERT INTO t2 (c) VALUES (NEW.b); +END | +CREATE TRIGGER t1_del_bef +BEFORE DELETE +ON t1 +FOR EACH ROW +BEGIN +INSERT INTO t2 (c) VALUES (OLD.b); +END | +INSERT INTO t1 (a) VALUES (1), (2), (3); +SELECT * FROM t2; +c +1 +2 +3 +DELETE FROM t1; +SELECT * FROM t2; +c +1 +2 +3 +1 +2 +3 +DROP TRIGGER t1_ins_aft; +DROP TRIGGER t1_del_bef; +DROP TABLE t1,t2; diff --git a/mysql-test/suite/vcol/r/vcol_trigger_sp_myisam.result b/mysql-test/suite/vcol/r/vcol_trigger_sp_myisam.result index c2a66d656b5..77efa8fe6b9 100644 --- a/mysql-test/suite/vcol/r/vcol_trigger_sp_myisam.result +++ b/mysql-test/suite/vcol/r/vcol_trigger_sp_myisam.result @@ -85,3 +85,43 @@ a b c 300 30 30 drop table t1,t2; drop procedure p1; +# +# Bug mdev-3845: values of virtual columns are not computed for triggers +# +CREATE TABLE t1 ( +a INTEGER UNSIGNED NULL DEFAULT NULL, +b INTEGER UNSIGNED GENERATED ALWAYS AS (a) VIRTUAL +); +CREATE TABLE t2 (c INTEGER UNSIGNED NOT NULL); +CREATE TRIGGER t1_ins_aft +AFTER INSERT +ON t1 +FOR EACH ROW +BEGIN +INSERT INTO t2 (c) VALUES (NEW.b); +END | +CREATE TRIGGER t1_del_bef +BEFORE DELETE +ON t1 +FOR EACH ROW +BEGIN +INSERT INTO t2 (c) VALUES (OLD.b); +END | +INSERT INTO t1 (a) VALUES (1), (2), (3); +SELECT * FROM t2; +c +1 +2 +3 +DELETE FROM t1; +SELECT * FROM t2; +c +1 +2 +3 +1 +2 +3 +DROP TRIGGER t1_ins_aft; +DROP TRIGGER t1_del_bef; +DROP TABLE t1,t2; diff --git a/mysql-test/t/derived_opt.test b/mysql-test/t/derived_opt.test index c2f831036e1..b01c479111b 100644 --- a/mysql-test/t/derived_opt.test +++ b/mysql-test/t/derived_opt.test @@ -212,5 +212,65 @@ INSERT INTO t1 VALUES ( (SELECT 1 FROM ( SELECT * FROM t1 ) as a) ); drop table t1; set optimizer_switch=@save_optimizer_switch; +--echo # +--echo # MDEV-3801 Reproducible sub select join crash on 5.3.8 and 5.3.9 +--echo # + +CREATE TABLE t1 ( + pk int(10) unsigned NOT NULL AUTO_INCREMENT, + a char(2) DEFAULT NULL, + PRIMARY KEY (pk), + KEY a (a) +) ENGINE=MyISAM; +INSERT INTO t1 (a) +VALUES (NULL),(NULL),(NULL),('AB'),(NULL),('CD'),(NULL),(NULL); +INSERT INTO t1 SELECT NULL, a1.a FROM t1 a1, t1 a2, t1 a3, t1 a4, t1 a5; + +CREATE TABLE t2 ( + pk int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +INSERT INTO t2 SELECT NULL FROM t2 a1, t2 a2, t2 a3, t2 a4, t2 a5; + +CREATE TABLE t3 ( + pk int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY +) ENGINE=MyISAM; +INSERT INTO t3 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +INSERT INTO t3 SELECT NULL FROM t3 a1, t3 a2, t3 a3, t3 a4, t3 a5; + +CREATE TABLE t4 ( + a char(2) NOT NULL DEFAULT '', + PRIMARY KEY (a) +) ENGINE=MyISAM; +INSERT INTO t4 VALUES ('CD'); + +set @@tmp_table_size=8192; + +--replace_column 9 # +EXPLAIN +SELECT * FROM t3 AS tx JOIN t2 AS ty ON (tx.pk = ty.pk) +WHERE + tx.pk IN + (SELECT * + FROM (SELECT DISTINCT ta.pk + FROM t3 AS ta + JOIN t2 AS tb ON (ta.pk = tb.pk) + JOIN t1 AS tc ON (tb.pk = tc.pk) + JOIN t4 AS td ON tc.a = td.a) tu) +limit 10; + +SELECT * FROM t3 AS tX JOIN t2 AS tY ON (tX.pk = tY.pk) +WHERE + tX.pk IN + (SELECT * + FROM (SELECT DISTINCT tA.pk + FROM t3 AS tA + JOIN t2 AS tB ON (tA.pk = tB.pk) + JOIN t1 AS tC ON (tB.pk = tC.pk) + JOIN t4 AS tD ON tC.a = tD.a) tU) +limit 10; + +drop table t1, t2, t3, t4; + # The following command must be the last one the file set optimizer_switch=@exit_optimizer_switch; diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 1226683ba03..3af531418c5 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1469,6 +1469,20 @@ WHERE a = ( GROUP BY 1; DROP TABLE t1, t2; +# +# MDEV-736 LP:1004615 - Unexpected warnings "Encountered illegal value '' when converting to DECIMAL" on a query with aggregate functions and GROUP BY +# + +FLUSH STATUS; # this test case *must* use Aria temp tables + +CREATE TABLE t1 (f1 INT, f2 decimal(20,1), f3 blob); +INSERT INTO t1 values(11,NULL,'blob'),(11,NULL,'blob'); +SELECT f3, MIN(f2) FROM t1 GROUP BY f1 LIMIT 1; +DROP TABLE t1; + +--echo the value below *must* be 1 +show status like 'Created_tmp_disk_tables'; + --echo # End of 5.3 tests --echo # diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index b0f8ddd375f..e95f41f6c8d 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1444,6 +1444,17 @@ SELECT length(CAST(b AS CHAR)) FROM ubig; DROP TABLE ubig; +# +# Bug #13889741: HANDLE_FATAL_SIGNAL IN _DB_ENTER_ | HANDLE_FATAL_SIGNAL IN STRNLEN +# +select 1 from information_schema.tables where table_schema=repeat('a', 2000); +grant usage on *.* to mysqltest_1@localhost; +connect (con1, localhost, mysqltest_1,,); +connection con1; +select 1 from information_schema.tables where table_schema=repeat('a', 2000); +connection default; +disconnect con1; +drop user mysqltest_1@localhost; --echo End of 5.1 tests. diff --git a/mysql-test/t/information_schema_all_engines.test b/mysql-test/t/information_schema_all_engines.test index a5400e8287a..553367d2b9a 100644 --- a/mysql-test/t/information_schema_all_engines.test +++ b/mysql-test/t/information_schema_all_engines.test @@ -15,6 +15,7 @@ show tables; # Bug#18925: subqueries with MIN/MAX functions on INFORMATION_SCHEMA # +--sorted_result SELECT t.table_name, c1.column_name FROM information_schema.tables t INNER JOIN @@ -29,6 +30,7 @@ SELECT t.table_name, c1.column_name c2.table_name = t.table_name AND c2.column_name LIKE '%SCHEMA%' ) order by t.table_name; +--sorted_result SELECT t.table_name, c1.column_name FROM information_schema.tables t INNER JOIN diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index ef0d3df6661..038907702d5 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -2395,6 +2395,14 @@ SELECT 1 FROM t1 WHERE b < SOME DROP TABLE t1; +--echo +--echo MDEV-612 Valgrind error in ha_maria::check_if_incompatible_data +--echo + +CREATE TABLE t1 (a INT, b INT, KEY(a)) ENGINE=Aria PARTITION BY KEY(a) PARTITIONS 2; +ALTER TABLE t1 ADD KEY (b); +drop table t1; + --echo End of 5.1 tests --echo # diff --git a/mysql-test/t/range_vs_index_merge.test b/mysql-test/t/range_vs_index_merge.test index 613a7cf5760..fb8fd778559 100755 --- a/mysql-test/t/range_vs_index_merge.test +++ b/mysql-test/t/range_vs_index_merge.test @@ -675,6 +675,64 @@ SELECT Name, Country, Population FROM City WHERE $cond; set optimizer_switch=@save_optimizer_switch; + +--echo # +--echo # Bug mdev-585: range vs index-merge with ORDER BY ... LIMIT n +--echo # (LP bug #637962) +--echo # + +DROP INDEX CountryPopulation ON City; +DROP INDEX CountryName ON City; +DROP INDEX CityName on City; + +CREATE INDEX Name ON City(Name); +CREATE INDEX Population ON City(Population); + + +--replace_column 9 # +EXPLAIN +SELECT * FROM City + WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) + AND (Population >= 100000 AND Population < 120000); +FLUSH STATUS; +SELECT * FROM City + WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) + AND (Population >= 100000 AND Population < 120000); +SHOW STATUS LIKE 'Handler_read_%'; + + +--replace_column 9 # +EXPLAIN +SELECT * FROM City + WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) + AND (Population >= 100000 AND Population < 120000) +ORDER BY Population LIMIT 5; + +FLUSH STATUS; +SELECT * FROM City + WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) + AND (Population >= 100000 AND Population < 120000) +ORDER BY Population LIMIT 5; +SHOW STATUS LIKE 'Handler_read_%'; + + +set optimizer_switch='index_merge=off'; + +--replace_column 9 # +EXPLAIN +SELECT * FROM City + WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) + AND (Population >= 100000 AND Population < 120000) +ORDER BY Population LIMIT 5; + +FLUSH STATUS; +SELECT * FROM City + WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H')) + AND (Population >= 100000 AND Population < 120000) +ORDER BY Population LIMIT 5; +SHOW STATUS LIKE 'Handler_read_%'; + +set optimizer_switch=@save_optimizer_switch; DROP DATABASE world; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 07f0084e7ab..e7cb505b19f 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -5078,6 +5078,82 @@ SELECT col_int_nokey FROM ot DROP TABLE ot,it1,it2; +--echo # +--echo # MDEV-746 +--echo # Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY +--echo # HAS AN EMPTY RESULT +--echo # + +CREATE TABLE t1 ( + pk int NOT NULL, + col_int_nokey int NOT NULL, + col_int_key int NOT NULL, + col_time_key time 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_time_key (col_time_key), + KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; + +CREATE TABLE t2 ( + pk int NOT NULL AUTO_INCREMENT, + col_int_nokey int NOT NULL, + col_int_key int NOT NULL, + col_time_key time 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_time_key (col_time_key), + KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; + +INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b'); + +SET @var2:=4, @var3:=8; + +--echo +--echo Testcase without inner subquery + +let $subq= +SELECT @var3:=12, sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR + sq4_alias1.col_varchar_key = @var3; + +eval EXPLAIN $subq; +eval $subq; +SELECT @var3; + +# Now as derived table: +eval EXPLAIN SELECT * FROM ( $subq ) AS alias3; +eval SELECT * FROM ( $subq ) AS alias3; +SELECT @var3; + +--echo +--echo Testcase with inner subquery; crashed WL#6095 +SET @var3=8; +let $subq= +SELECT sq4_alias1.* +FROM t1 AS sq4_alias1 +WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey) + NOT IN + (SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1, + c_sq1_alias1.col_varchar_nokey AS c_sq1_field2 + FROM t2 AS c_sq1_alias1 + WHERE (c_sq1_alias1.col_int_nokey != @var2 + OR c_sq1_alias1.pk != @var3)); + +eval EXPLAIN $subq; +eval $subq; +# Now as derived table: +eval EXPLAIN SELECT * FROM ( $subq ) AS alias3; +eval SELECT * FROM ( $subq ) AS alias3; + +DROP TABLE t1,t2; + --echo End of 5.2 tests --echo # diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index f509a1ad0f2..c6c4e4d9d2f 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -424,4 +424,32 @@ DROP TABLE t1; SET @bug12408412=1; SELECT GROUP_CONCAT(@bug12408412 ORDER BY 1) INTO @bug12408412; +# +# MDEV-616 LP BUG#1002126 +# Bug #11764371 57196: MORE FUN WITH ASSERTION: !TABLE->FILE || +# TABLE->FILE->INITED == HANDLER:: +# + +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0); +SELECT DISTINCT POW(COUNT(*), @a:=(SELECT 1 FROM t1 LEFT JOIN t1 AS t2 ON @a)) +AS b FROM t1 GROUP BY a; +SELECT @a; +DROP TABLE t1; +CREATE TABLE t1(f1 INT, f2 INT); +INSERT INTO t1 VALUES (1,2),(2,3),(3,1); +CREATE TABLE t2(a INT); +INSERT INTO t2 VALUES (1); +SET @var=NULL; +SELECT @var:=(SELECT f2 FROM t2 WHERE @var) FROM t1 GROUP BY f1 ORDER BY f2 DESC +LIMIT 1; +SELECT @var; +DROP TABLE t1, t2; + +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0),(1),(3); +SELECT DISTINCT POW(COUNT(distinct a), @a:=(SELECT 1 FROM t1 LEFT JOIN t1 AS t2 ON @a limit 1)) AS b FROM t1 GROUP BY a; +SELECT @a; +DROP TABLE t1; + --echo End of 5.5 tests |