diff options
author | cmiller@calliope.local.cmiller/calliope.local <> | 2007-02-14 12:24:11 -0500 |
---|---|---|
committer | cmiller@calliope.local.cmiller/calliope.local <> | 2007-02-14 12:24:11 -0500 |
commit | 80a35bfd39e8bf7eec217a157d75584e60473b08 (patch) | |
tree | cca848df4237003d6d9051d3f0fa5a173b3b636b | |
parent | cf9aca84b3d53d9d24a93b9716b74301e4e0f083 (diff) | |
parent | 0733ea7462dc16b2ec39b7fb4c73d5828fdd1444 (diff) | |
download | mariadb-git-80a35bfd39e8bf7eec217a157d75584e60473b08.tar.gz |
Merge calliope.local.cmiller:/Volumes/Source/src/mysql-4.1-maint--bug25126
into calliope.local.cmiller:/Volumes/Source/src/mysql-4.1-maint
-rw-r--r-- | mysql-test/r/order_by.result | 24 | ||||
-rw-r--r-- | mysql-test/t/order_by.test | 29 | ||||
-rw-r--r-- | sql/item.cc | 13 |
3 files changed, 65 insertions, 1 deletions
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index ec6032be882..f5601ba0e43 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -847,6 +847,30 @@ num (select num + 2 FROM t1 LIMIT 1) 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; CREATE TABLE t1 (a int); SELECT p.a AS val, q.a AS val1 FROM t1 p, t1 q ORDER BY val > 1; val val1 diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 3c23ea76d99..d781bd6c6ba 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -576,6 +576,35 @@ 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; + +# # Bug #25427: crash when order by expression contains a name # that cannot be resolved unambiguously # diff --git a/sql/item.cc b/sql/item.cc index a3de5a44e2b..bf96fdf3f43 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1774,7 +1774,18 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) 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 |