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
412dd1e1
Commit
412dd1e1
authored
Dec 20, 2016
by
Aleksey Midenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: FOR SYSTEM_TIME support in VIEW expression [fixes #99]
parent
2157c6bf
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
43 deletions
+56
-43
mysql-test/suite/versioning/r/view.result
mysql-test/suite/versioning/r/view.result
+25
-0
mysql-test/suite/versioning/t/view.test
mysql-test/suite/versioning/t/view.test
+25
-0
sql/sql_select.cc
sql/sql_select.cc
+6
-37
sql/table.h
sql/table.h
+0
-6
No files found.
mysql-test/suite/versioning/r/view.result
0 → 100644
View file @
412dd1e1
create table t1 (x int) with system versioning engine innodb;
insert into t1 values (1);
select now(6) into @t1;
update t1 set x= 2;
select now(6) into @t2;
delete from t1;
set @vt1= concat("create view vt1 as select * from t1 for system_time as of timestamp '", @t1, "'");
prepare stmt from @vt1;
execute stmt;
drop prepare stmt;
set @vt2= concat("create view vt2 as select * from t1 for system_time as of timestamp '", @t2, "'");
prepare stmt from @vt2;
execute stmt;
drop prepare stmt;
select * from vt1;
x
1
select * from vt2;
x
2
select * from t1;
x
drop view vt1;
drop view vt2;
drop table t1;
mysql-test/suite/versioning/t/view.test
0 → 100644
View file @
412dd1e1
--
source
include
/
have_innodb
.
inc
create
table
t1
(
x
int
)
with
system
versioning
engine
innodb
;
insert
into
t1
values
(
1
);
select
now
(
6
)
into
@
t1
;
update
t1
set
x
=
2
;
select
now
(
6
)
into
@
t2
;
delete
from
t1
;
set
@
vt1
=
concat
(
"create view vt1 as select * from t1 for system_time as of timestamp '"
,
@
t1
,
"'"
);
prepare
stmt
from
@
vt1
;
execute
stmt
;
drop
prepare
stmt
;
set
@
vt2
=
concat
(
"create view vt2 as select * from t1 for system_time as of timestamp '"
,
@
t2
,
"'"
);
prepare
stmt
from
@
vt2
;
execute
stmt
;
drop
prepare
stmt
;
select
*
from
vt1
;
select
*
from
vt2
;
select
*
from
t1
;
drop
view
vt1
;
drop
view
vt2
;
drop
table
t1
;
sql/sql_select.cc
View file @
412dd1e1
...
...
@@ -899,8 +899,6 @@ vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LEX *s
*
dst_cond
=
cond1
;
else
thd
->
change_item_tree
(
dst_cond
,
cond1
);
table
->
vers_moved_to_where
=
true
;
}
}
// if (... table->table->versioned())
}
// for (table= tables; ...)
...
...
@@ -25036,39 +25034,6 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result)
DBUG_RETURN
(
res
||
thd
->
is_error
());
}
void
TABLE_LIST
::
print_system_versioning
(
THD
*
thd
,
table_map
eliminated_tables
,
String
*
str
,
enum_query_type
query_type
)
{
if
(
vers_moved_to_where
)
return
;
DBUG_ASSERT
(
select_lex
);
// system versioning
if
(
select_lex
->
vers_conditions
.
type
!=
FOR_SYSTEM_TIME_UNSPECIFIED
)
{
switch
(
select_lex
->
vers_conditions
.
type
)
{
case
FOR_SYSTEM_TIME_AS_OF
:
str
->
append
(
STRING_WITH_LEN
(
" for system_time as of "
));
select_lex
->
vers_conditions
.
start
->
print
(
str
,
query_type
);
break
;
case
FOR_SYSTEM_TIME_FROM_TO
:
str
->
append
(
STRING_WITH_LEN
(
" for system_time from timestamp "
));
select_lex
->
vers_conditions
.
start
->
print
(
str
,
query_type
);
str
->
append
(
STRING_WITH_LEN
(
" to "
));
select_lex
->
vers_conditions
.
end
->
print
(
str
,
query_type
);
break
;
case
FOR_SYSTEM_TIME_BETWEEN
:
str
->
append
(
STRING_WITH_LEN
(
" for system_time between timestamp "
));
select_lex
->
vers_conditions
.
start
->
print
(
str
,
query_type
);
str
->
append
(
STRING_WITH_LEN
(
" and "
));
select_lex
->
vers_conditions
.
end
->
print
(
str
,
query_type
);
break
;
default:
DBUG_ASSERT
(
0
);
}
}
}
static
void
print_table_array
(
THD
*
thd
,
table_map
eliminated_tables
,
...
...
@@ -25404,8 +25369,6 @@ void TABLE_LIST::print(THD *thd, table_map eliminated_tables, String *str,
append_identifier
(
thd
,
str
,
t_alias
,
strlen
(
t_alias
));
}
print_system_versioning
(
thd
,
eliminated_tables
,
str
,
query_type
);
if
(
index_hints
)
{
List_iterator
<
Index_hint
>
it
(
*
index_hints
);
...
...
@@ -25565,6 +25528,12 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type)
str
->
append
(
having_value
!=
Item
::
COND_FALSE
?
"1"
:
"0"
);
}
if
(
vers_conditions
.
type
!=
FOR_SYSTEM_TIME_UNSPECIFIED
)
{
// versioning conditions must be already unwrapped to WHERE clause
str
->
append
(
STRING_WITH_LEN
(
" for system_time all "
));
}
if
(
order_list
.
elements
)
{
str
->
append
(
STRING_WITH_LEN
(
" order by "
));
...
...
sql/table.h
View file @
412dd1e1
...
...
@@ -2334,9 +2334,6 @@ struct TABLE_LIST
TABLE_LIST
*
first_leaf_for_name_resolution
();
TABLE_LIST
*
last_leaf_for_name_resolution
();
/* System Versioning */
bool
vers_moved_to_where
;
/**
@brief
Find the bottom in the chain of embedded table VIEWs.
...
...
@@ -2535,9 +2532,6 @@ struct TABLE_LIST
void
check_pushable_cond_for_table
(
Item
*
cond
);
Item
*
build_pushable_cond_for_table
(
THD
*
thd
,
Item
*
cond
);
void
print_system_versioning
(
THD
*
thd
,
table_map
eliminated_tables
,
String
*
str
,
enum_query_type
query_type
);
private:
bool
prep_check_option
(
THD
*
thd
,
uint8
check_opt_type
);
bool
prep_where
(
THD
*
thd
,
Item
**
conds
,
bool
no_where_clause
);
...
...
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