summaryrefslogtreecommitdiff
path: root/sql/item.h
diff options
context:
space:
mode:
authorVarun Gupta <varun.gupta@mariadb.com>2021-01-12 14:25:55 +0530
committerVarun Gupta <varun.gupta@mariadb.com>2021-01-12 18:47:39 +0530
commitab271ee7e22ce1250ec36b09123bfb98bc3f8107 (patch)
treedf91f14e267169e4d3b42f5f0d4c452677730d8e /sql/item.h
parent3b94309a6cec8d8149c9f312229d18227036e01d (diff)
downloadmariadb-git-ab271ee7e22ce1250ec36b09123bfb98bc3f8107.tar.gz
MDEV-23826: ORDER BY in view definition leads to wrong result with GROUP BY on query using view
Introduced val_time_packed and val_datetime_packed functions for Item_direct_ref to make sure to get the value from the item it is referring to. The issue for incorrect result was that the item was getting its value from the temporary table rather than from the view.
Diffstat (limited to 'sql/item.h')
-rw-r--r--sql/item.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/sql/item.h b/sql/item.h
index ed20074a8da..823ffd873b6 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -4671,13 +4671,16 @@ public:
return Item_ref::fix_fields(thd, it);
}
void save_val(Field *to);
+ /* Below we should have all val() methods as in Item_ref */
double val_real();
longlong val_int();
- String *val_str(String* tmp);
my_decimal *val_decimal(my_decimal *);
bool val_bool();
+ String *val_str(String* tmp);
bool is_null();
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate);
+ longlong val_datetime_packed();
+ longlong val_time_packed();
virtual Ref_Type ref_type() { return DIRECT_REF; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_direct_ref>(thd, mem_root, this); }
@@ -4992,6 +4995,20 @@ public:
}
return Item_direct_ref::get_date(ltime, fuzzydate);
}
+ longlong val_time_packed()
+ {
+ if (check_null_ref())
+ return 0;
+ else
+ return Item_direct_ref::val_time_packed();
+ }
+ longlong val_datetime_packed()
+ {
+ if (check_null_ref())
+ return 0;
+ else
+ return Item_direct_ref::val_datetime_packed();
+ }
bool send(Protocol *protocol, String *buffer);
void save_org_in_field(Field *field,
fast_field_copier data __attribute__ ((__unused__)))