summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorJoerg Bruehe <joerg@mysql.com>2010-02-12 18:35:27 +0100
committerJoerg Bruehe <joerg@mysql.com>2010-02-12 18:35:27 +0100
commitca6ec790b4c12ab93a11d0f8f1d6e23d13c041b5 (patch)
treebb607eb1c3e866c97f1b35b2e085f2e6e064fadb /sql/sql_select.cc
parenta835c80dec57666307f7f70b07cb0c706bdab3f2 (diff)
parent44c1a79b0e6af3f87712af7e7386aa6c516b89f9 (diff)
downloadmariadb-git-ca6ec790b4c12ab93a11d0f8f1d6e23d13c041b5.tar.gz
Automerge from central branch.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index d8ec5eff5c1..eecc2b086a3 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -521,13 +521,26 @@ JOIN::prepare(Item ***rref_pointer_array,
if (order)
{
+ bool real_order= FALSE;
ORDER *ord;
for (ord= order; ord; ord= ord->next)
{
Item *item= *ord->item;
+ /*
+ Disregard sort order if there's only "{VAR}CHAR(0) NOT NULL" fields
+ there. Such fields don't contain any data to sort.
+ */
+ if (!real_order &&
+ (item->type() != Item::FIELD_ITEM ||
+ ((Item_field *) item)->field->maybe_null() ||
+ ((Item_field *) item)->field->sort_length()))
+ real_order= TRUE;
+
if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM)
item->split_sum_func(thd, ref_pointer_array, all_fields);
}
+ if (!real_order)
+ order= NULL;
}
if (having && having->with_sum_func)