diff options
author | unknown <dlenev@brandersnatch.localdomain> | 2004-08-20 17:53:46 +0400 |
---|---|---|
committer | unknown <dlenev@brandersnatch.localdomain> | 2004-08-20 17:53:46 +0400 |
commit | 0f5fa0eb57e7aa4e24b05aaf03c5f4fff2adb789 (patch) | |
tree | 65bfed51926a7496b1598c32ff98e04e45df07a7 /sql/sql_select.cc | |
parent | 53fd4439286066cf3305ba5128bb3bbe933bed46 (diff) | |
download | mariadb-git-0f5fa0eb57e7aa4e24b05aaf03c5f4fff2adb789.tar.gz |
Fix for bug#4302 "ambiguos order by when renamed column is identical to another in result"
When in find_item_in_list() we are looking for item we should take into account unaliased
names of the fields but only if item with such aliased name is not found.
Also we should ignore aliases when looking for fully specified field.
mysql-test/r/order_by.result:
Fixed wrong (non-standard) test results
Added test case for bug #4302
Added tests for other ambiguos and potentially ambigous cases in order by clause
mysql-test/t/order_by.test:
Fixed wrong (non-standard) test results
Added test case for bug #4302
Added tests for other ambiguos and potentially ambigous cases in order by clause
sql/sql_select.cc:
We should ignore only not_found_item errors when searching for item in find_order_in_list()
to be able to catch ambiguities.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f8bc6210a2f..d4cc263ac55 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7978,13 +7978,18 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, return 0; } uint counter; - Item **item= find_item_in_list(itemptr, fields, &counter, IGNORE_ERRORS); - if (item) + Item **item= find_item_in_list(itemptr, fields, &counter, + REPORT_EXCEPT_NOT_FOUND); + if (!item) + return 1; + + if (item != not_found_item) { order->item= ref_pointer_array + counter; order->in_field_list=1; return 0; } + order->in_field_list=0; Item *it= *order->item; /* |