MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:igor Date:May 14 2007 11:41pm
Subject:bk commit into 4.1 tree (igor:1.2655) BUG#27937
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of igor. When igor does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-05-14 16:41:09-07:00, igor@stripped +3 -0
  Fixed bug #27937: crash for the the second execution of a prepared
  statement from a UNION query with ORDER BY an expression containing
  RAND().
  The crash happened because the global order by list in the union query
  was not re-initialized for execution.
  (Local order by lists were re-initialized though).
  

  mysql-test/r/ps.result@stripped, 2007-05-14 16:41:08-07:00, igor@stripped +22 -0
    Added a test case for bug #27937.

  mysql-test/t/ps.test@stripped, 2007-05-14 16:41:08-07:00, igor@stripped +18 -0
    Added a test case for bug #27937.

  sql/sql_union.cc@stripped, 2007-05-14 16:41:08-07:00, igor@stripped +5 -0
    Fixed bug #27937: crash for the the second execution of a prepared
    statement from a UNION query with ORDER BY an expression containing
    RAND().
    The crash happened because the global order by list in the union query
    was not re-initialized for execution.
    (Local order by lists were re-initialized though).
    Added re-initialization of the global order by list in the function
    st_select_lex_unit::init_prepare_fake_select_lex.  
    

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	igor
# Host:	olga.mysql.com
# Root:	/home/igor/dev-opt/mysql-4.1-opt-bug27937

--- 1.146/sql/sql_union.cc	2007-05-14 16:41:14 -07:00
+++ 1.147/sql/sql_union.cc	2007-05-14 16:41:14 -07:00
@@ -135,6 +135,11 @@
   fake_select_lex->table_list.link_in_list((byte *)&result_table_list,
 					   (byte **)
 					   &result_table_list.next);
+  for (ORDER *order= (ORDER *) global_parameters->order_list.first;
+       order;
+       order= order->next)
+    order->item= &order->item_ptr;
+
   return options_tmp;
 }
 

--- 1.55/mysql-test/r/ps.result	2007-05-14 16:41:14 -07:00
+++ 1.56/mysql-test/r/ps.result	2007-05-14 16:41:14 -07:00
@@ -1087,4 +1087,26 @@
 drop database mysqltest;
 deallocate prepare stmt1;
 deallocate prepare stmt2;
+CREATE TABLE t1(a int);
+INSERT INTO t1 VALUES (2), (3), (1);
+PREPARE st1 FROM
+'(SELECT a FROM t1) UNION (SELECT a+10 FROM t1) ORDER BY RAND()*0+a';
+EXECUTE st1;
+a
+1
+2
+3
+11
+12
+13
+EXECUTE st1;
+a
+1
+2
+3
+11
+12
+13
+DEALLOCATE PREPARE st1;
+DROP TABLE t1;
 End of 4.1 tests.

--- 1.58/mysql-test/t/ps.test	2007-05-14 16:41:14 -07:00
+++ 1.59/mysql-test/t/ps.test	2007-05-14 16:41:14 -07:00
@@ -1128,4 +1128,22 @@
 deallocate prepare stmt1;
 deallocate prepare stmt2;
 #
+
+#
+# Bug #27937: crash on the second execution for prepared statement 
+#             from UNION with ORDER BY an expression containing RAND()
+#
+
+CREATE TABLE t1(a int);
+INSERT INTO t1 VALUES (2), (3), (1);
+
+PREPARE st1 FROM
+  '(SELECT a FROM t1) UNION (SELECT a+10 FROM t1) ORDER BY RAND()*0+a';
+
+EXECUTE st1;
+EXECUTE st1;
+
+DEALLOCATE PREPARE st1;
+DROP TABLE t1;
+
 --echo End of 4.1 tests.
Thread
bk commit into 4.1 tree (igor:1.2655) BUG#27937igor15 May