MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:pem Date:March 10 2006 1:04pm
Subject:bk commit into 5.0 tree (pem:1.2074) BUG#16474
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of pem. When pem 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
  1.2074 06/03/10 14:04:56 pem@stripped +3 -0
  Fixed BUG#16474: SP crashed MySQL
    fix_fields() was not called for "order by" variables if the type was a
    "constant integer", and thus interpreted as a column index.
    However, a local variable is an expression and should not be interpreted
    as a column index. Instead it behaves just like when using a user variable
    for instance (i.e. it will not affect the ordering).
  

  sql/sql_select.cc
    1.396 06/03/10 14:04:51 pem@stripped +5 -1
    When processing order list, 

  mysql-test/t/sp.test
    1.179 06/03/10 14:04:51 pem@stripped +31 -0
    New test case for BUG#16474.

  mysql-test/r/sp.result
    1.191 06/03/10 14:04:51 pem@stripped +29 -0
    Updated results for new test case (BUG#16474).

# 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:	pem
# Host:	pem.mysql.com
# Root:	/extern/mysql/5.0/bug16474/mysql-5.0-runtime

--- 1.395/sql/sql_select.cc	2006-02-20 02:25:59 +01:00
+++ 1.396/sql/sql_select.cc	2006-03-10 14:04:51 +01:00
@@ -12325,7 +12325,11 @@
   Item **select_item; /* The corresponding item from the SELECT clause. */
   Field *from_field;  /* The corresponding field from the FROM clause. */
 
-  if (order_item->type() == Item::INT_ITEM)
+  /*
+    Local SP variables may be int but are expressions, not positions.
+    (And they must be fixed.)
+  */
+  if (order_item->type() == Item::INT_ITEM && !order_item->is_splocal())
   {						/* Order by position */
     uint count= (uint) order_item->val_int();
     if (!count || count > fields.elements)

--- 1.190/mysql-test/r/sp.result	2006-03-07 12:24:18 +01:00
+++ 1.191/mysql-test/r/sp.result	2006-03-10 14:04:51 +01:00
@@ -4857,4 +4857,33 @@
 0
 drop table t3|
 drop procedure bug16887|
+drop procedure if exists bug16474_1|
+drop procedure if exists bug16474_2|
+delete from t1|
+insert into t1 values ('c', 2), ('b', 3), ('a', 1)|
+create procedure bug16474_1()
+begin
+declare x int;
+select id from t1 order by x;
+end|
+create procedure bug16474_2(x int)
+select id from t1 order by x|
+call bug16474_1()|
+id
+c
+b
+a
+call bug16474_2(1)|
+id
+c
+b
+a
+call bug16474_2(2)|
+id
+c
+b
+a
+drop procedure bug16474_1|
+drop procedure bug16474_2|
+delete from t1|
 drop table t1,t2;

--- 1.178/mysql-test/t/sp.test	2006-03-06 16:49:28 +01:00
+++ 1.179/mysql-test/t/sp.test	2006-03-10 14:04:51 +01:00
@@ -5718,6 +5718,37 @@
 
 
 #
+# BUG#16474: SP crashed MySQL
+# (when using "order by localvar", where 'localvar' is just that.
+#
+--disable_warnings
+drop procedure if exists bug16474_1|
+drop procedure if exists bug16474_2|
+--enable_warnings
+
+delete from t1|
+insert into t1 values ('c', 2), ('b', 3), ('a', 1)|
+
+create procedure bug16474_1()
+begin
+  declare x int;
+
+  select id from t1 order by x;
+end|
+
+# This does NOT order by column index; variable is an expression.
+create procedure bug16474_2(x int)
+  select id from t1 order by x|
+
+call bug16474_1()|
+call bug16474_2(1)|
+call bug16474_2(2)|
+drop procedure bug16474_1|
+drop procedure bug16474_2|
+delete from t1|
+
+
+#
 # BUG#NNNN: New bug synopsis
 #
 #--disable_warnings
Thread
bk commit into 5.0 tree (pem:1.2074) BUG#16474pem10 Mar