Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
dc4ef66f
Commit
dc4ef66f
authored
Dec 10, 2016
by
kevg
Committed by
Aleksey Midenkov
May 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: optimize FOR SYSTEM_TIME ALL queries [closes #85]
parent
1dc02136
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
13 deletions
+11
-13
sql/sql_select.cc
sql/sql_select.cc
+7
-4
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-7
sql/table.h
sql/table.h
+3
-2
No files found.
sql/sql_select.cc
View file @
dc4ef66f
...
@@ -676,11 +676,9 @@ vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LEX *s
...
@@ -676,11 +676,9 @@ vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LEX *s
TABLE_LIST
*
table
;
TABLE_LIST
*
table
;
int
versioned_tables
=
0
;
int
versioned_tables
=
0
;
Query_arena
*
arena
=
0
,
backup
;
Query_arena
*
arena
=
0
,
backup
;
bool
is_prepare
=
thd
->
stmt_arena
->
is_stmt_prepare
();
if
(
!
thd
->
stmt_arena
->
is_conventional
()
if
(
!
thd
->
stmt_arena
->
is_conventional
()
&&
&&
!
is_prepare
!
thd
->
stmt_arena
->
is_stmt_prepare
()
&&
!
thd
->
stmt_arena
->
is_sp_execute
())
&&
!
thd
->
stmt_arena
->
is_sp_execute
())
{
{
// statement is already prepared
// statement is already prepared
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
...
@@ -702,6 +700,11 @@ vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LEX *s
...
@@ -702,6 +700,11 @@ vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LEX *s
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
if
(
slex
->
vers_conditions
.
type
==
FOR_SYSTEM_TIME_ALL
)
{
DBUG_RETURN
(
0
);
}
/* For prepared statements we create items on statement arena,
/* For prepared statements we create items on statement arena,
because they must outlive execution phase for multiple executions. */
because they must outlive execution phase for multiple executions. */
arena
=
thd
->
activate_stmt_arena_if_needed
(
&
backup
);
arena
=
thd
->
activate_stmt_arena_if_needed
(
&
backup
);
...
...
sql/sql_yacc.yy
View file @
dc4ef66f
...
@@ -8749,13 +8749,7 @@ opt_for_system_time_clause:
...
@@ -8749,13 +8749,7 @@ opt_for_system_time_clause:
}
}
| FOR_SYSTEM_TIME_SYM ALL
| FOR_SYSTEM_TIME_SYM ALL
{
{
static MYSQL_TIME min= { TIMESTAMP_MIN_YEAR, 1, 1, 0, 0, 0, 0, false, MYSQL_TIMESTAMP_DATETIME };
Lex->current_select->vers_conditions.init(FOR_SYSTEM_TIME_ALL, UNIT_TIMESTAMP);
static MYSQL_TIME max= { TIMESTAMP_MAX_YEAR, 12, 31, 23, 59, 59, 0, false, MYSQL_TIMESTAMP_DATETIME };
Item *t0= new (thd->mem_root) Item_datetime_literal(thd, &min);
Item *t1= new (thd->mem_root) Item_datetime_literal(thd, &max);
if (!t0 || !t1)
MYSQL_YYABORT;
Lex->current_select->vers_conditions.init(FOR_SYSTEM_TIME_BETWEEN, UNIT_TIMESTAMP, t0, t1);
}
}
| FOR_SYSTEM_TIME_SYM
| FOR_SYSTEM_TIME_SYM
FROM
FROM
...
...
sql/table.h
View file @
dc4ef66f
...
@@ -1817,7 +1817,8 @@ enum vers_range_type_t
...
@@ -1817,7 +1817,8 @@ enum vers_range_type_t
FOR_SYSTEM_TIME_UNSPECIFIED
=
0
,
FOR_SYSTEM_TIME_UNSPECIFIED
=
0
,
FOR_SYSTEM_TIME_AS_OF
,
FOR_SYSTEM_TIME_AS_OF
,
FOR_SYSTEM_TIME_FROM_TO
,
FOR_SYSTEM_TIME_FROM_TO
,
FOR_SYSTEM_TIME_BETWEEN
FOR_SYSTEM_TIME_BETWEEN
,
FOR_SYSTEM_TIME_ALL
};
};
enum
vers_range_unit_t
enum
vers_range_unit_t
...
@@ -1843,7 +1844,7 @@ struct vers_select_conds_t
...
@@ -1843,7 +1844,7 @@ struct vers_select_conds_t
void
init
(
void
init
(
vers_range_type_t
t
,
vers_range_type_t
t
,
vers_range_unit_t
u
,
vers_range_unit_t
u
,
Item
*
s
,
Item
*
s
=
NULL
,
Item
*
e
=
NULL
)
Item
*
e
=
NULL
)
{
{
type
=
t
;
type
=
t
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment