summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 76cad16de28..0d47aee9882 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -14543,15 +14543,18 @@ static int compare_fields_by_table_order(Item *field1,
{
int cmp= 0;
bool outer_ref= 0;
- Item_field *f1= (Item_field *) (field1->real_item());
- Item_field *f2= (Item_field *) (field2->real_item());
- if (field1->const_item() || f1->const_item())
+ Item *field1_real= field1->real_item();
+ Item *field2_real= field2->real_item();
+
+ if (field1->const_item() || field1_real->const_item())
return -1;
- if (field2->const_item() || f2->const_item())
+ if (field2->const_item() || field2_real->const_item())
return 1;
+ Item_field *f1= (Item_field *) field1_real;
+ Item_field *f2= (Item_field *) field2_real;
if (f1->used_tables() & OUTER_REF_TABLE_BIT)
{
- outer_ref= 1;
+ outer_ref= -1;
cmp= -1;
}
if (f2->used_tables() & OUTER_REF_TABLE_BIT)