Skip to content

Commit c450f7d

Browse files
committed
Merge remote-tracking branch 'origin/5.5' into 10.0
2 parents 3661d98 + 15b9291 commit c450f7d

File tree

10 files changed

+253
-37
lines changed

10 files changed

+253
-37
lines changed

mysql-test/r/having.result

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,23 @@ a ct
713713
set sql_mode=@save_sql_mode;
714714
drop table t1;
715715
#
716+
# mdev-16235: impossible HAVING in query without aggregation
717+
#
718+
explain extended
719+
select * from mysql.help_topic where example = 'foo' having description is null;
720+
id select_type table type possible_keys key key_len ref rows filtered Extra
721+
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
722+
Warnings:
723+
Note 1003 select `mysql`.`help_topic`.`help_topic_id` AS `help_topic_id`,`mysql`.`help_topic`.`name` AS `name`,`mysql`.`help_topic`.`help_category_id` AS `help_category_id`,`mysql`.`help_topic`.`description` AS `description`,`mysql`.`help_topic`.`example` AS `example`,`mysql`.`help_topic`.`url` AS `url` from `mysql`.`help_topic` where (`mysql`.`help_topic`.`example` = 'foo') having 0
724+
select * from mysql.help_topic where example = 'foo' having description is null;
725+
help_topic_id name help_category_id description example url
726+
#
727+
# End of 5. tests
728+
#
729+
#
730+
# Start of 10.0 tests
731+
#
732+
#
716733
# Bug mdev-5160: two-way join with HAVING over the second table
717734
#
718735
CREATE TABLE t1 (c1 varchar(6)) ENGINE=MyISAM;

mysql-test/r/subselect4.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ EXPLAIN
10431043
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
10441044
id select_type table type possible_keys key key_len ref rows Extra
10451045
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
1046-
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULLImpossible WHERE noticed after reading const tables
1046+
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULLNo matching min/max row
10471047
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
10481048
f1 f2
10491049
SET @@optimizer_switch = 'materialization=off,in_to_exists=on,semijoin=off';
@@ -1134,7 +1134,7 @@ EXPLAIN
11341134
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
11351135
id select_type table type possible_keys key key_len ref rows Extra
11361136
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
1137-
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULLImpossible WHERE noticed after reading const tables
1137+
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULLNo matching min/max row
11381138
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
11391139
f1 f2
11401140
set @@optimizer_switch=@save_optimizer_switch;

mysql-test/std_data/frm/t1.frm

8.38 KB
Binary file not shown.

mysql-test/suite/vcol/r/vcol_misc.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,5 +354,15 @@ a b c
354354
DROP TABLE t1;
355355
SET sql_mode=DEFAULT;
356356
#
357+
# MDEV-15834 The code in TABLE_SHARE::init_from_binary_frm_image() is not safe
358+
#
359+
SHOW TABLES;
360+
Tables_in_test
361+
t1
362+
SHOW CREATE TABLE t1;
363+
ERROR HY000: Incorrect information in file: './test/t1.frm'
364+
ALTER TABLE t1;
365+
ERROR HY000: Incorrect information in file: './test/t1.frm'
366+
#
357367
# End of 5.5 tests
358368
#

mysql-test/suite/vcol/t/vcol_misc.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--source include/have_ucs2.inc
22

3+
let $MYSQLD_DATADIR= `select @@datadir`;
4+
35
--disable_warnings
46
drop table if exists t1,t2;
57
--enable_warnings
@@ -318,6 +320,20 @@ SELECT * FROM t1;
318320
DROP TABLE t1;
319321
SET sql_mode=DEFAULT;
320322

323+
324+
--echo #
325+
--echo # MDEV-15834 The code in TABLE_SHARE::init_from_binary_frm_image() is not safe
326+
--echo #
327+
328+
--copy_file std_data/frm/t1.frm $MYSQLD_DATADIR/test/t1.frm
329+
SHOW TABLES;
330+
--error ER_NOT_FORM_FILE
331+
SHOW CREATE TABLE t1;
332+
--error ER_NOT_FORM_FILE
333+
ALTER TABLE t1;
334+
--remove_file $MYSQLD_DATADIR/test/t1.frm
335+
336+
321337
--echo #
322338
--echo # End of 5.5 tests
323339
--echo #

mysql-test/t/having.test

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,23 @@ set sql_mode=@save_sql_mode;
745745

746746
drop table t1;
747747

748+
--echo #
749+
--echo # mdev-16235: impossible HAVING in query without aggregation
750+
--echo #
751+
752+
explain extended
753+
select * from mysql.help_topic where example = 'foo' having description is null;
754+
755+
select * from mysql.help_topic where example = 'foo' having description is null;
756+
757+
--echo #
758+
--echo # End of 5. tests
759+
--echo #
760+
761+
--echo #
762+
--echo # Start of 10.0 tests
763+
--echo #
764+
748765
--echo #
749766
--echo # Bug mdev-5160: two-way join with HAVING over the second table
750767
--echo #

sql/opt_subselect.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5937,6 +5937,7 @@ bool JOIN::choose_tableless_subquery_plan()
59375937
functions produce empty subquery result. There is no need to further
59385938
rewrite the subquery because it will not be executed at all.
59395939
*/
5940+
exec_const_cond= 0;
59405941
return FALSE;
59415942
}
59425943

@@ -5968,6 +5969,6 @@ bool JOIN::choose_tableless_subquery_plan()
59685969
tmp_having= having;
59695970
}
59705971
}
5971-
exec_const_cond= conds;
5972+
exec_const_cond= zero_result_cause ? 0 : conds;
59725973
return FALSE;
59735974
}

sql/sql_select.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,6 @@ TODO: make view to decide if it is possible to write to WHERE directly or make S
12561256
{
12571257
DBUG_PRINT("info", ("Zero limit"));
12581258
zero_result_cause= "Zero limit";
1259-
conds= 0;
12601259
}
12611260
table_count= top_join_tab_count= 0;
12621261
error= 0;

sql/table.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
14991499

15001500
if ((uchar)field_type == (uchar)MYSQL_TYPE_VIRTUAL)
15011501
{
1502-
DBUG_ASSERT(interval_nr); // Expect non-null expression
1502+
if (!interval_nr) // Expect non-null expression
1503+
goto err;
15031504
/*
15041505
The interval_id byte in the .frm file stores the length of the
15051506
expression statement for a virtual column.

0 commit comments

Comments
 (0)