diff options
author | unknown <cmiller@calliope.local.cmiller/calliope.local> | 2007-02-14 11:27:37 -0500 |
---|---|---|
committer | unknown <cmiller@calliope.local.cmiller/calliope.local> | 2007-02-14 11:27:37 -0500 |
commit | 48be0a2ff17af54aab36b0b554175ae5756e3690 (patch) | |
tree | 7c9fd27030b35104266e24d59e4c21c5a445468b | |
parent | 9d66be72b0ee079cecc39e09d4f4c0f7e1849dbc (diff) | |
parent | 4c4f50623896f43873420d6c8d8e2a320653d57a (diff) | |
download | mariadb-git-48be0a2ff17af54aab36b0b554175ae5756e3690.tar.gz |
Merge calliope.local.cmiller:/Volumes/Source/src/mysql-4.1-maint--bug25126
into calliope.local.cmiller:/Volumes/Source/src/mysql-5.0-maint
sql/item.cc:
Auto merged
mysql-test/r/order_by.result:
Manual merge.
mysql-test/t/order_by.test:
Manual merge.
-rw-r--r-- | mysql-test/r/order_by.result | 24 | ||||
-rw-r--r-- | mysql-test/t/order_by.test | 31 | ||||
-rw-r--r-- | sql/item.cc | 13 |
3 files changed, 66 insertions, 2 deletions
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index e81d46c9199..0185394cdad 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -874,6 +874,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 012b38ff8b7..5533f273b0d 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -589,6 +589,36 @@ 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 # @@ -603,7 +633,6 @@ SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val > 1; DROP TABLE t1; -# End of 4.1 tests create table t1 (a int not null, b int not null, c int not null); insert t1 values (1,1,1),(1,1,2),(1,2,1); select a, b from t1 group by a, b order by sum(c); diff --git a/sql/item.cc b/sql/item.cc index b4a7820eabf..050171b8fbe 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3724,7 +3724,18 @@ bool Item_field::fix_fields(THD *thd, Item **reference) 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 |