[Commits] Rev 4162: MDEV-6129: Server crashes during UNION with ORDER BY field IS NULL in lp:maria/5.5

Michael Widenius michael.widenius at gmail.com
Thu Apr 24 18:20:57 EEST 2014


At lp:maria/5.5

------------------------------------------------------------
revno: 4162
revision-id: monty at askmonty.org-20140424152057-d7kc187y5xou1g5s
parent: bar at mnogosearch.org-20140423134320-8qo3gdrwmzf7vgto
committer: Michael Widenius <monty at askmonty.org>
branch nick: maria-5.5
timestamp: Thu 2014-04-24 18:20:57 +0300
message:
  MDEV-6129: Server crashes during UNION with ORDER BY field IS NULL
  
  Fixed crashing bug for union queries where there was no real tables.
-------------- next part --------------
=== modified file '.bzrignore'
--- a/.bzrignore	2014-02-19 20:39:16 +0000
+++ b/.bzrignore	2014-04-24 15:20:57 +0000
@@ -1433,3 +1433,4 @@ storage/tokudb/ft-index/utils/tokudb_dum
 storage/tokudb/ft-index/utils/tokudb_gen
 storage/tokudb/ft-index/utils/tokudb_load
 libmysql/libmysql_versions.ld
+scripts/mysql_config.pl

=== modified file 'mysql-test/r/group_by.result'
--- a/mysql-test/r/group_by.result	2014-01-26 20:49:11 +0000
+++ b/mysql-test/r/group_by.result	2014-04-24 15:20:57 +0000
@@ -2473,3 +2473,12 @@ c	1c
 v       2v,2v
 NULL    1c,2v,2v
 DROP TABLE t1,t2;
+#
+# MDEV-6129: Server crashes during UNION with ORDER BY field IS NULL
+#
+SET sql_mode='ONLY_FULL_GROUP_BY';
+SELECT 1 AS test UNION SELECT 2 AS test ORDER BY test IS NULL ASC;
+test
+1
+2
+SET sql_mode='';

=== modified file 'mysql-test/t/group_by.test'
--- a/mysql-test/t/group_by.test	2014-01-26 20:49:11 +0000
+++ b/mysql-test/t/group_by.test	2014-04-24 15:20:57 +0000
@@ -1643,3 +1643,14 @@ FROM t1 JOIN t2 ON c = b GROUP BY b WITH
 
 DROP TABLE t1,t2;
 
+--echo #
+--echo # MDEV-6129: Server crashes during UNION with ORDER BY field IS NULL
+--echo #
+
+SET sql_mode='ONLY_FULL_GROUP_BY';
+SELECT 1 AS test UNION SELECT 2 AS test ORDER BY test IS NULL ASC;
+SET sql_mode='';
+
+#
+# End of MariaDB 5.5 tests
+#

=== removed file 'sql/db.opt'
--- a/sql/db.opt	2013-02-25 09:42:40 +0000
+++ b/sql/db.opt	1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
-default-character-set=latin1
-default-collation=latin1_swedish_ci

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2014-03-17 12:04:28 +0000
+++ b/sql/item.cc	2014-04-24 15:20:57 +0000
@@ -5273,15 +5273,23 @@ bool Item_field::fix_fields(THD *thd, It
     /*
       Mark selects according to presence of non aggregated fields.
       Fields from outer selects added to the aggregate function
-      outer_fields list as its unknown at the moment whether it's
+      outer_fields list as it's unknown at the moment whether it's
       aggregated or not.
-      We're using either the select lex of the cached table (if present)
-      or the field's resolution context. context->select_lex is 
-      safe for use because it's either the SELECT we want to use 
-      (the current level) or a stub added by non-SELECT queries.
+      We're using the select lex of the cached table (if present).
     */
-    SELECT_LEX *select_lex= cached_table ? 
-      cached_table->select_lex : field->table->pos_in_table_list->select_lex;
+    SELECT_LEX *select_lex;
+    if (cached_table)
+      select_lex= cached_table->select_lex;
+    else if (!(select_lex= field->table->pos_in_table_list->select_lex))
+    {
+      /*
+        This can only happen when there is no real table in the query.
+        We are using the field's resolution context. context->select_lex is eee
+        safe for use because it's either the SELECT we want to use 
+        (the current level) or a stub added by non-SELECT queries.
+      */
+      select_lex= context->select_lex;
+    }
     if (!thd->lex->in_sum_func)
       select_lex->set_non_agg_field_used(true);
     else



More information about the commits mailing list