List:Commits« Previous MessageNext Message »
From:Chad MILLER Date:February 9 2007 10:05am
Subject:bk commit into 4.1 tree (cmiller:1.2597) BUG#25126
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of cmiller. When cmiller 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-02-09 11:05:36+01:00, cmiller@stripped +3 -0
  Bug#25126: Reference to non-existant column in UPDATE...ORDER BY... crashes server
  
  "update existingtable set anycolumn=nonexisting order by nonexisting" would crash
  the server.
  
  Though we would find the reference to a field, that doesn't mean we can then use
  it to set some values.  It could be a reference to another field.  If it is NULL, 
  don't try to use it to set values in the Item_field and instead return an error.
  
  Over the previous patch, this signals an error at the location of the error, rather
  than letting the subsequent deref signal it.

  mysql-test/r/order_by.result@stripped, 2007-02-09 11:05:29+01:00, cmiller@stripped +24 -0
    Verify that all permutations work.

  mysql-test/t/order_by.test@stripped, 2007-02-09 11:05:30+01:00, cmiller@stripped +30 -0
    Verify that all permutations work.

  sql/item.cc@stripped, 2007-02-09 11:05:30+01:00, cmiller@stripped +12 -1
    When the field is NULL, don't dereference it when we set_field().  
    Instead, raise an error.

# 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:	cmiller
# Host:	calliope.local
# Root:	/Volumes/Source/src/mysql-4.1-maint--bug25126

--- 1.234/sql/item.cc	2006-11-03 17:48:11 +01:00
+++ 1.235/sql/item.cc	2007-02-09 11:05:30 +01:00
@@ -1771,7 +1771,18 @@
              use the field from the Item_field in the select list and leave
              the Item_field instance in place.
             */
-            set_field((*((Item_field**)res))->field);
+
+            Field *field= (*((Item_field**)res))->field;
+
+            if (field == NULL)
+            {
+              /* The column to which we link isn't valid. */
+              my_error(ER_BAD_FIELD_ERROR, MYF(0), (*res)->name, 
+                       current_thd->where);
+              return(1);
+            }
+
+            set_field(field);
             return 0;
           }
           else

--- 1.48/mysql-test/r/order_by.result	2006-11-03 17:48:10 +01:00
+++ 1.49/mysql-test/r/order_by.result	2007-02-09 11:05:29 +01:00
@@ -847,3 +847,27 @@
 SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a;
 ERROR 42S22: Unknown column 'num' in 'on clause'
 DROP TABLE t1;
+CREATE TABLE bug25126 (
+val int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY
+);
+UPDATE bug25126 SET MissingCol = MissingCol;
+ERROR 42S22: Unknown column 'MissingCol' in 'field list'
+UPDATE bug25126 SET val = val ORDER BY MissingCol;
+ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
+UPDATE bug25126 SET val = val ORDER BY val;
+UPDATE bug25126 SET val = 1 ORDER BY val;
+UPDATE bug25126 SET val = 1 ORDER BY MissingCol;
+ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
+UPDATE bug25126 SET val = 1 ORDER BY val, MissingCol;
+ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
+UPDATE bug25126 SET val = MissingCol ORDER BY MissingCol;
+ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
+UPDATE bug25126 SET MissingCol = 1 ORDER BY val, MissingCol;
+ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
+UPDATE bug25126 SET MissingCol = 1 ORDER BY MissingCol;
+ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
+UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol;
+ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
+UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol;
+ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
+DROP TABLE bug25126;

--- 1.35/mysql-test/t/order_by.test	2006-11-03 17:48:10 +01:00
+++ 1.36/mysql-test/t/order_by.test	2007-02-09 11:05:30 +01:00
@@ -575,4 +575,34 @@
 SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a;
 DROP TABLE t1;
 
+#
+# Bug#25126: Reference to non-existant column in UPDATE...ORDER BY... 
+#       crashes server
+#
+CREATE TABLE bug25126 (
+  val int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY
+);
+--error 1054
+UPDATE bug25126 SET MissingCol = MissingCol;
+--error 1054
+UPDATE bug25126 SET val = val ORDER BY MissingCol;
+UPDATE bug25126 SET val = val ORDER BY val;
+UPDATE bug25126 SET val = 1 ORDER BY val;
+--error 1054
+UPDATE bug25126 SET val = 1 ORDER BY MissingCol;
+--error 1054
+UPDATE bug25126 SET val = 1 ORDER BY val, MissingCol;
+--error 1054
+UPDATE bug25126 SET val = MissingCol ORDER BY MissingCol;
+--error 1054
+UPDATE bug25126 SET MissingCol = 1 ORDER BY val, MissingCol;
+--error 1054
+UPDATE bug25126 SET MissingCol = 1 ORDER BY MissingCol;
+--error 1054
+UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol;
+--error 1054
+UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol;
+DROP TABLE bug25126;
+
+
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (cmiller:1.2597) BUG#25126Chad MILLER12 Feb