summaryrefslogtreecommitdiff
path: root/sql/sql_lex.h
diff options
context:
space:
mode:
authorOleg Smirnov <olernov@gmail.com>2023-02-17 19:21:30 +0700
committerOleg Smirnov <olernov@gmail.com>2023-03-20 10:56:41 +0700
commit22ebce8d684cbcbd7ff8c044f387b9cd5ca295f7 (patch)
tree39c73cedf0ee173d437da42c84d0090420e9554c /sql/sql_lex.h
parentce4a289f1c367987977f1a02bbb8d8b8e8e6bb53 (diff)
downloadmariadb-git-bb-11.0-MDEV-8320.tar.gz
MDEV-8320 Allow index usage for DATE(col) <=> const and YEAR <=> constbb-11.0-MDEV-8320
Rewrite datetime comparison conditions into sargeable. For example, YEAR(col) <= val -> col <= YEAR_END(val) YEAR(col) < val -> col < YEAR_START(val) YEAR(col) >= val -> col >= YEAR_START(val) YEAR(col) > val -> col > YEAR_END(val) YEAR(col) = val -> col BETWEEN YEAR_START(val) AND YEAR_END(val) Do the same with DATE(col), for example: DATE(col) <= val -> col <= DAY_END(val) After such a rewrite index lookup on column "col" can be employed
Diffstat (limited to 'sql/sql_lex.h')
-rw-r--r--sql/sql_lex.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 95ed308103d..7d8895f1e6c 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -2320,6 +2320,20 @@ public:
bool uses_stored_routines() const
{ return sroutines_list.elements != 0; }
+ void set_date_funcs_used_flag()
+ {
+ date_funcs_used_flag= true;
+ }
+
+ /*
+ Returns TRUE if date functions such as YEAR(), MONTH() or DATE()
+ are used in this LEX
+ */
+ bool are_date_funcs_used() const
+ {
+ return date_funcs_used_flag;
+ }
+
private:
/**
@@ -2360,6 +2374,12 @@ private:
be accessed while executing a statement.
*/
uint32 stmt_accessed_table_flag;
+
+ /*
+ Flag indicating that date functions such as YEAR(), MONTH() or DATE() are
+ used in this LEX
+ */
+ bool date_funcs_used_flag= false;
};