Commit 97dc3ccf authored by unknown's avatar unknown

Fix for the bug #3118: Subquery and order by

parent f580b954
......@@ -1624,3 +1624,11 @@ select 2 in (select * from t1);
1
SET SQL_SELECT_LIMIT=default;
drop table t1;
CREATE TABLE t1 (a int, b int, INDEX (a));
INSERT INTO t1 VALUES (1, 1), (1, 2), (1, 3);
SELECT * FROM t1 WHERE a = (SELECT MAX(a) FROM t1 WHERE a = 1) ORDER BY b;
a b
1 1
1 2
1 3
DROP TABLE t1;
......@@ -1066,3 +1066,11 @@ select 2 in (select * from t1);
SET SQL_SELECT_LIMIT=default;
drop table t1;
#
# Bug #3118: subselect + order by
#
CREATE TABLE t1 (a int, b int, INDEX (a));
INSERT INTO t1 VALUES (1, 1), (1, 2), (1, 3);
SELECT * FROM t1 WHERE a = (SELECT MAX(a) FROM t1 WHERE a = 1) ORDER BY b;
DROP TABLE t1;
......@@ -428,8 +428,10 @@ class Item_uint :public Item_int
{
public:
Item_uint(const char *str_arg, uint length) :
Item_int(str_arg, (longlong) strtoull(str_arg,(char**) 0,10), length) {}
Item_uint(uint32 i) :Item_int((longlong) i, 10) {}
Item_int(str_arg, (longlong) strtoull(str_arg,(char**) 0,10), length)
{ fixed= 0; }
Item_uint(uint32 i) :Item_int((longlong) i, 10)
{ fixed= 0; }
double val() { return ulonglong2double((ulonglong)value); }
String *val_str(String*);
Item *new_item() { return new Item_uint(name,max_length); }
......
......@@ -205,7 +205,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{
Item *item;
/* We can't yet set item to *arg as fix_fields may change *arg */
if ((*arg)->fix_fields(thd, tables, arg) ||
if ((!(*arg)->fixed && (*arg)->fix_fields(thd, tables, arg)) ||
(*arg)->check_cols(allowed_arg_cols))
return 1; /* purecov: inspected */
item= *arg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment