From: Date: January 2 2007 4:13pm Subject: bk commit into 4.1 tree (cmiller:1.2558) BUG#25126 List-Archive: http://lists.mysql.com/commits/17527 X-Bug: 25126 Message-Id: <20070102151326.5D96F8304B@zippy> 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-01-02 10:13:23-05:00, cmiller@stripped +3 -0 Bug#25126: Reference to non-existant column in UPDATE...ORDER BY... crashes server "update existingtable set anything=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 placeholder. If the Field is NULL, don't try to use it to set values in the Item_field. mysql-test/r/order_by.result@stripped, 2007-01-02 10:13:22-05:00, cmiller@stripped +24 -0 Verify that the missing-column behavior is as expected. mysql-test/t/order_by.test@stripped, 2007-01-02 10:13:22-05:00, cmiller@stripped +29 -0 Verify that the missing-column behavior is as expected. sql/item.cc@stripped, 2007-01-02 10:13:22-05:00, cmiller@stripped +4 -1 Don't try to set_field() when the field is NULL. # 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: zippy.cornsilk.net # Root: /home/cmiller/work/mysql/bug25126/my41-bug25126 --- 1.233/sql/item.cc 2007-01-02 10:13:26 -05:00 +++ 1.234/sql/item.cc 2007-01-02 10:13:26 -05:00 @@ -1763,7 +1763,10 @@ bool Item_field::fix_fields(THD *thd, TA ¬_used); if (res != (Item **)not_found_item && (*res)->type() == Item::FIELD_ITEM) { - set_field((*((Item_field**)res))->field); + Field *field= (*((Item_field**)res))->field; + + if (field != NULL) + set_field(field); return 0; } } --- 1.47/mysql-test/r/order_by.result 2007-01-02 10:13:26 -05:00 +++ 1.48/mysql-test/r/order_by.result 2007-01-02 10:13:26 -05:00 @@ -820,3 +820,27 @@ b a 20 1 10 2 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 'field list' +UPDATE bug25126 SET MissingCol = 1 ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +DROP TABLE bug25126; --- 1.34/mysql-test/t/order_by.test 2007-01-02 10:13:26 -05:00 +++ 1.35/mysql-test/t/order_by.test 2007-01-02 10:13:26 -05:00 @@ -559,4 +559,33 @@ INSERT INTO t1 VALUES (1,30), (2,20), (1 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