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
ac5eb977
Commit
ac5eb977
authored
Jun 17, 2017
by
Eugene Kosov
Committed by
Aleksey Midenkov
Jun 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: Versioned SHOW CREATE TABLE [closes #125]
parent
448374a2
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
449 additions
and
5 deletions
+449
-5
mysql-test/suite/versioning/r/ddl.result
mysql-test/suite/versioning/r/ddl.result
+1
-0
mysql-test/suite/versioning/r/vtmd_show.result
mysql-test/suite/versioning/r/vtmd_show.result
+231
-0
mysql-test/suite/versioning/t/ddl.test
mysql-test/suite/versioning/t/ddl.test
+1
-0
mysql-test/suite/versioning/t/vtmd_show.opt
mysql-test/suite/versioning/t/vtmd_show.opt
+1
-0
mysql-test/suite/versioning/t/vtmd_show.test
mysql-test/suite/versioning/t/vtmd_show.test
+92
-0
sql/sql_show.cc
sql/sql_show.cc
+31
-2
sql/sql_yacc.yy
sql/sql_yacc.yy
+10
-2
sql/table.h
sql/table.h
+2
-1
sql/vtmd.cc
sql/vtmd.cc
+79
-0
sql/vtmd.h
sql/vtmd.h
+1
-0
No files found.
mysql-test/suite/versioning/r/ddl.result
View file @
ac5eb977
...
@@ -202,6 +202,7 @@ No A B C D
...
@@ -202,6 +202,7 @@ No A B C D
11 1 1 1 1
11 1 1 1 1
12 1 1 1 1
12 1 1 1 1
drop table t;
drop table t;
drop table t_vtmd;
drop procedure verify_vtq;
drop procedure verify_vtq;
drop procedure innodb_verify_vtq;
drop procedure innodb_verify_vtq;
drop function default_engine;
drop function default_engine;
...
...
mysql-test/suite/versioning/r/vtmd_show.result
0 → 100644
View file @
ac5eb977
create or replace procedure drop_archives (in vtmd_name varchar(64))
begin
declare archive_name varchar(64);
declare cur_done bool default false;
declare cur cursor for
select cur_tmp.archive_name from cur_tmp;
declare continue handler for not found set cur_done = true;
set @tmp= concat('
create or replace temporary table
cur_tmp as
select vtmd.archive_name from ', vtmd_name, ' as vtmd
for system_time all
where vtmd.archive_name is not null
group by vtmd.archive_name');
prepare stmt from @tmp; execute stmt; drop prepare stmt;
open cur;
fetch_loop: loop
fetch cur into archive_name;
if cur_done then
leave fetch_loop;
end if;
set @tmp= concat('drop table ', archive_name);
prepare stmt from @tmp; execute stmt; drop prepare stmt;
end loop;
drop table cur_tmp;
end~~
create procedure test_01(in engine varchar(64))
begin
set @tmp = concat('create table t (a int) with system versioning engine ', engine);
prepare stmt from @tmp; execute stmt; drop prepare stmt;
set @tm1 = now(6);
alter table t add column b int;
set @tm2 = now(6);
alter table t add column c int;
show create table t for system_time as of timestamp @tm1;
show create table t for system_time as of timestamp @tm2;
show create table t for system_time as of now;
show create table t for system_time as of timestamp now(6);
show create table t;
set @tm3 = now(6);
rename table t to tt;
show create table tt for system_time as of timestamp @tm3;
set @tm4 = now(6);
alter table tt add column d int;
show create table tt for system_time as of timestamp @tm3;
show create table tt for system_time as of timestamp @tm4;
show create table tt;
drop table tt;
call drop_archives('tt_vtmd');
drop table tt_vtmd;
end~~
create table t (a int) with system versioning;
show create table t for system_time as of now;
ERROR 42S02: Table 'test.t_vtmd' doesn't exist
set versioning_ddl_survival=on;
create or replace table t (a int) with system versioning;
show create table t for system_time between timestamp @tm1 and timestamp @tm1;
ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME`: only AS OF allowed here
show create table t for system_time from timestamp @tm1 to timestamp @tm1;
ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME`: only AS OF allowed here
show create table t for system_time before timestamp @tm1;
ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME`: only AS OF allowed here
show create table t for system_time as of timestamp '01-01-1990';
ERROR HY000: VTMD error: failed to query VTMD table
show create table t for system_time as of timestamp '01-01-2020';
ERROR HY000: VTMD error: failed to query VTMD table
drop table t;
call drop_archives('t_vtmd');
drop table t_vtmd;
call test_01('myisam');
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
tt CREATE TABLE `tt` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
tt CREATE TABLE `tt` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
tt CREATE TABLE `tt` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
tt CREATE TABLE `tt` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`d` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
call test_01('innodb');
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
tt CREATE TABLE `tt` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
tt CREATE TABLE `tt` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
tt CREATE TABLE `tt` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
Table Create Table
tt CREATE TABLE `tt` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`d` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
drop procedure test_01;
drop procedure drop_archives;
mysql-test/suite/versioning/t/ddl.test
View file @
ac5eb977
...
@@ -118,5 +118,6 @@ show create table mysql.vtmd_template;
...
@@ -118,5 +118,6 @@ show create table mysql.vtmd_template;
call
verify_vtq
;
call
verify_vtq
;
drop
table
t
;
drop
table
t
;
drop
table
t_vtmd
;
--
source
suite
/
versioning
/
common_finish
.
inc
--
source
suite
/
versioning
/
common_finish
.
inc
mysql-test/suite/versioning/t/vtmd_show.opt
0 → 100644
View file @
ac5eb977
--innodb
mysql-test/suite/versioning/t/vtmd_show.test
0 → 100644
View file @
ac5eb977
delimiter
~~
;
create
or
replace
procedure
drop_archives
(
in
vtmd_name
varchar
(
64
))
begin
declare
archive_name
varchar
(
64
);
declare
cur_done
bool
default
false
;
declare
cur
cursor
for
select
cur_tmp
.
archive_name
from
cur_tmp
;
declare
continue
handler
for
not
found
set
cur_done
=
true
;
set
@
tmp
=
concat
(
'
create or replace temporary table
cur_tmp as
select vtmd.archive_name from '
,
vtmd_name
,
' as vtmd
for system_time all
where vtmd.archive_name is not null
group by vtmd.archive_name'
);
prepare
stmt
from
@
tmp
;
execute
stmt
;
drop
prepare
stmt
;
open
cur
;
fetch_loop
:
loop
fetch
cur
into
archive_name
;
if
cur_done
then
leave
fetch_loop
;
end
if
;
set
@
tmp
=
concat
(
'drop table '
,
archive_name
);
prepare
stmt
from
@
tmp
;
execute
stmt
;
drop
prepare
stmt
;
end
loop
;
drop
table
cur_tmp
;
end
~~
delimiter
;
~~
delimiter
~~
;
create
procedure
test_01
(
in
engine
varchar
(
64
))
begin
set
@
tmp
=
concat
(
'create table t (a int) with system versioning engine '
,
engine
);
prepare
stmt
from
@
tmp
;
execute
stmt
;
drop
prepare
stmt
;
set
@
tm1
=
now
(
6
);
alter
table
t
add
column
b
int
;
set
@
tm2
=
now
(
6
);
alter
table
t
add
column
c
int
;
show
create
table
t
for
system_time
as
of
timestamp
@
tm1
;
show
create
table
t
for
system_time
as
of
timestamp
@
tm2
;
show
create
table
t
for
system_time
as
of
now
;
show
create
table
t
for
system_time
as
of
timestamp
now
(
6
);
show
create
table
t
;
set
@
tm3
=
now
(
6
);
rename
table
t
to
tt
;
show
create
table
tt
for
system_time
as
of
timestamp
@
tm3
;
set
@
tm4
=
now
(
6
);
alter
table
tt
add
column
d
int
;
show
create
table
tt
for
system_time
as
of
timestamp
@
tm3
;
show
create
table
tt
for
system_time
as
of
timestamp
@
tm4
;
show
create
table
tt
;
drop
table
tt
;
call
drop_archives
(
'tt_vtmd'
);
drop
table
tt_vtmd
;
end
~~
delimiter
;
~~
create
table
t
(
a
int
)
with
system
versioning
;
--
error
ER_NO_SUCH_TABLE
show
create
table
t
for
system_time
as
of
now
;
set
versioning_ddl_survival
=
on
;
create
or
replace
table
t
(
a
int
)
with
system
versioning
;
--
error
ER_VERS_WRONG_PARAMS
show
create
table
t
for
system_time
between
timestamp
@
tm1
and
timestamp
@
tm1
;
--
error
ER_VERS_WRONG_PARAMS
show
create
table
t
for
system_time
from
timestamp
@
tm1
to
timestamp
@
tm1
;
--
error
ER_VERS_WRONG_PARAMS
show
create
table
t
for
system_time
before
timestamp
@
tm1
;
--
error
ER_VERS_VTMD_ERROR
show
create
table
t
for
system_time
as
of
timestamp
'01-01-1990'
;
--
error
ER_VERS_VTMD_ERROR
show
create
table
t
for
system_time
as
of
timestamp
'01-01-2020'
;
drop
table
t
;
call
drop_archives
(
't_vtmd'
);
drop
table
t_vtmd
;
call
test_01
(
'myisam'
);
call
test_01
(
'innodb'
);
drop
procedure
test_01
;
drop
procedure
drop_archives
;
sql/sql_show.cc
View file @
ac5eb977
...
@@ -62,6 +62,8 @@
...
@@ -62,6 +62,8 @@
#ifdef WITH_PARTITION_STORAGE_ENGINE
#ifdef WITH_PARTITION_STORAGE_ENGINE
#include "ha_partition.h"
#include "ha_partition.h"
#endif
#endif
#include "vtmd.h"
#include "transaction.h"
enum
enum_i_s_events_fields
enum
enum_i_s_events_fields
{
{
...
@@ -1267,6 +1269,24 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
...
@@ -1267,6 +1269,24 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
*/
*/
MDL_savepoint
mdl_savepoint
=
thd
->
mdl_context
.
mdl_savepoint
();
MDL_savepoint
mdl_savepoint
=
thd
->
mdl_context
.
mdl_savepoint
();
TABLE_LIST
tl
;
bool
versioned_query
=
table_list
->
vers_conditions
.
type
!=
FOR_SYSTEM_TIME_UNSPECIFIED
;
String
archive_name
;
if
(
versioned_query
)
{
DBUG_ASSERT
(
table_list
->
vers_conditions
.
type
==
FOR_SYSTEM_TIME_AS_OF
);
VTMD_table
vtmd
(
*
table_list
);
if
(
vtmd
.
find_archive_name
(
thd
,
archive_name
))
goto
exit
;
tl
.
init_one_table
(
table_list
->
db
,
table_list
->
db_length
,
archive_name
.
ptr
(),
archive_name
.
length
(),
archive_name
.
ptr
(),
TL_READ
);
tl
.
alias
=
table_list
->
table_name
;
tl
.
vers_force_alias
=
true
;
table_list
=
&
tl
;
}
if
(
mysqld_show_create_get_fields
(
thd
,
table_list
,
&
field_list
,
&
buffer
))
if
(
mysqld_show_create_get_fields
(
thd
,
table_list
,
&
field_list
,
&
buffer
))
goto
exit
;
goto
exit
;
...
@@ -1281,7 +1301,9 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
...
@@ -1281,7 +1301,9 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
protocol
->
store
(
table_list
->
view_name
.
str
,
system_charset_info
);
protocol
->
store
(
table_list
->
view_name
.
str
,
system_charset_info
);
else
else
{
{
if
(
table_list
->
schema_table
)
if
(
versioned_query
)
protocol
->
store
(
tl
.
alias
,
system_charset_info
);
else
if
(
table_list
->
schema_table
)
protocol
->
store
(
table_list
->
schema_table
->
table_name
,
protocol
->
store
(
table_list
->
schema_table
->
table_name
,
system_charset_info
);
system_charset_info
);
else
else
...
@@ -1309,6 +1331,13 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
...
@@ -1309,6 +1331,13 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
my_eof
(
thd
);
my_eof
(
thd
);
exit:
exit:
if
(
versioned_query
)
{
/* If commit fails, we should be able to reset the OK status. */
thd
->
get_stmt_da
()
->
set_overwrite_status
(
true
);
trans_commit_stmt
(
thd
);
thd
->
get_stmt_da
()
->
set_overwrite_status
(
false
);
}
close_thread_tables
(
thd
);
close_thread_tables
(
thd
);
/* Release any metadata locks taken during SHOW CREATE. */
/* Release any metadata locks taken during SHOW CREATE. */
thd
->
mdl_context
.
rollback_to_savepoint
(
mdl_savepoint
);
thd
->
mdl_context
.
rollback_to_savepoint
(
mdl_savepoint
);
...
@@ -2026,7 +2055,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
...
@@ -2026,7 +2055,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
alias
=
table_list
->
schema_table
->
table_name
;
alias
=
table_list
->
schema_table
->
table_name
;
else
else
{
{
if
(
lower_case_table_names
==
2
)
if
(
lower_case_table_names
==
2
||
table_list
->
vers_force_alias
)
alias
=
table
->
alias
.
c_ptr
();
alias
=
table
->
alias
.
c_ptr
();
else
else
{
{
...
...
sql/sql_yacc.yy
View file @
ac5eb977
...
@@ -1905,7 +1905,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
...
@@ -1905,7 +1905,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
parse_vcol_expr vcol_opt_specifier vcol_opt_attribute
parse_vcol_expr vcol_opt_specifier vcol_opt_attribute
vcol_opt_attribute_list vcol_attribute
vcol_opt_attribute_list vcol_attribute
opt_serial_attribute opt_serial_attribute_list serial_attribute
opt_serial_attribute opt_serial_attribute_list serial_attribute
explainable_command opt_lock_wait_timeout
explainable_command opt_lock_wait_timeout
asrow_attribute
END_OF_INPUT
END_OF_INPUT
%type <NONE> call sp_proc_stmts sp_proc_stmts1 sp_proc_stmt
%type <NONE> call sp_proc_stmts sp_proc_stmts1 sp_proc_stmt
...
@@ -13330,13 +13330,21 @@ show_param:
...
@@ -13330,13 +13330,21 @@ show_param:
Lex->set_command(SQLCOM_SHOW_CREATE_DB, $3);
Lex->set_command(SQLCOM_SHOW_CREATE_DB, $3);
Lex->name= $4;
Lex->name= $4;
}
}
| CREATE TABLE_SYM table_ident
| CREATE TABLE_SYM table_ident
opt_for_system_time_clause
{
{
LEX *lex= Lex;
LEX *lex= Lex;
lex->sql_command = SQLCOM_SHOW_CREATE;
lex->sql_command = SQLCOM_SHOW_CREATE;
if (!lex->select_lex.add_table_to_list(thd, $3, NULL,0))
if (!lex->select_lex.add_table_to_list(thd, $3, NULL,0))
MYSQL_YYABORT;
MYSQL_YYABORT;
lex->create_info.storage_media= HA_SM_DEFAULT;
lex->create_info.storage_media= HA_SM_DEFAULT;
if (lex->vers_conditions.type != FOR_SYSTEM_TIME_UNSPECIFIED &&
lex->vers_conditions.type != FOR_SYSTEM_TIME_AS_OF) {
my_yyabort_error((ER_VERS_WRONG_PARAMS, MYF(0), "FOR SYSTEM_TIME",
"only AS OF allowed here"));
}
if ($4)
Lex->last_table()->vers_conditions= Lex->vers_conditions;
}
}
| CREATE VIEW_SYM table_ident
| CREATE VIEW_SYM table_ident
{
{
...
...
sql/table.h
View file @
ac5eb977
...
@@ -1890,7 +1890,7 @@ struct vers_select_conds_t
...
@@ -1890,7 +1890,7 @@ struct vers_select_conds_t
{
{
return
type
!=
b
;
return
type
!=
b
;
}
}
operator
bool
()
operator
bool
()
const
{
{
return
type
!=
FOR_SYSTEM_TIME_UNSPECIFIED
;
return
type
!=
FOR_SYSTEM_TIME_UNSPECIFIED
;
}
}
...
@@ -2356,6 +2356,7 @@ struct TABLE_LIST
...
@@ -2356,6 +2356,7 @@ struct TABLE_LIST
/* System Versioning */
/* System Versioning */
vers_select_conds_t
vers_conditions
;
vers_select_conds_t
vers_conditions
;
bool
vers_vtmd_name
(
String
&
out
)
const
;
bool
vers_vtmd_name
(
String
&
out
)
const
;
bool
vers_force_alias
;
/**
/**
@brief
@brief
...
...
sql/vtmd.cc
View file @
ac5eb977
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include "sql_class.h"
#include "sql_class.h"
#include "sql_handler.h" // mysql_ha_rm_tables()
#include "sql_handler.h" // mysql_ha_rm_tables()
#include "sql_table.h"
#include "sql_table.h"
#include "sql_select.h"
#include "table_cache.h" // tdc_remove_table()
#include "table_cache.h" // tdc_remove_table()
#include "key.h"
#include "key.h"
...
@@ -493,3 +494,81 @@ void VTMD_table::archive_name(
...
@@ -493,3 +494,81 @@ void VTMD_table::archive_name(
table_name
,
now
.
year
,
now
.
month
,
now
.
day
,
now
.
hour
,
now
.
minute
,
table_name
,
now
.
year
,
now
.
month
,
now
.
day
,
now
.
hour
,
now
.
minute
,
now
.
second
,
now
.
second_part
);
now
.
second
,
now
.
second_part
);
}
}
bool
VTMD_table
::
find_archive_name
(
THD
*
thd
,
String
&
out
)
{
String
vtmd_name
;
if
(
about
.
vers_vtmd_name
(
vtmd_name
))
return
true
;
READ_RECORD
info
;
int
error
=
0
;
SQL_SELECT
*
select
=
NULL
;
COND
*
conds
=
NULL
;
List
<
TABLE_LIST
>
dummy
;
SELECT_LEX
&
select_lex
=
thd
->
lex
->
select_lex
;
TABLE_LIST
tl
;
tl
.
init_one_table
(
about
.
db
,
about
.
db_length
,
vtmd_name
.
ptr
(),
vtmd_name
.
length
(),
vtmd_name
.
ptr
(),
TL_READ
);
Open_tables_backup
open_tables_backup
;
if
(
!
(
vtmd
=
open_log_table
(
thd
,
&
tl
,
&
open_tables_backup
)))
{
my_error
(
ER_VERS_VTMD_ERROR
,
MYF
(
0
),
"failed to open VTMD table"
);
return
true
;
}
Name_resolution_context
&
ctx
=
thd
->
lex
->
select_lex
.
context
;
TABLE_LIST
*
table_list
=
ctx
.
table_list
;
TABLE_LIST
*
first_name_resolution_table
=
ctx
.
first_name_resolution_table
;
table_map
map
=
tl
.
table
->
map
;
ctx
.
table_list
=
&
tl
;
ctx
.
first_name_resolution_table
=
&
tl
;
tl
.
table
->
map
=
1
;
tl
.
vers_conditions
=
about
.
vers_conditions
;
if
((
error
=
vers_setup_select
(
thd
,
&
tl
,
&
conds
,
&
select_lex
))
||
(
error
=
setup_conds
(
thd
,
&
tl
,
dummy
,
&
conds
)))
{
my_error
(
ER_VERS_VTMD_ERROR
,
MYF
(
0
),
"failed to setup conditions for querying VTMD table"
);
goto
err
;
}
select
=
make_select
(
tl
.
table
,
0
,
0
,
conds
,
NULL
,
0
,
&
error
);
if
(
error
)
goto
loc_err
;
if
((
error
=
init_read_record
(
&
info
,
thd
,
tl
.
table
,
select
,
NULL
,
1
,
1
,
false
)))
goto
loc_err
;
while
(
!
(
error
=
info
.
read_record
(
&
info
))
&&
!
thd
->
killed
&&
!
thd
->
is_error
())
{
if
(
select
->
skip_record
(
thd
)
>
0
)
{
tl
.
table
->
field
[
FLD_ARCHIVE_NAME
]
->
val_str
(
&
out
);
if
(
out
.
length
()
==
0
)
{
// Handle AS OF NOW or just RENAMEd case
out
.
set
(
about
.
table_name
,
about
.
table_name_length
,
system_charset_info
);
}
break
;
}
}
loc_err:
if
(
error
)
my_error
(
ER_VERS_VTMD_ERROR
,
MYF
(
0
),
"failed to query VTMD table"
);
end_read_record
(
&
info
);
err:
delete
select
;
ctx
.
table_list
=
table_list
;
ctx
.
first_name_resolution_table
=
first_name_resolution_table
;
tl
.
table
->
map
=
map
;
close_log_table
(
thd
,
&
open_tables_backup
);
return
error
?
true
:
false
;
}
sql/vtmd.h
View file @
ac5eb977
...
@@ -86,6 +86,7 @@ class VTMD_table
...
@@ -86,6 +86,7 @@ class VTMD_table
archive_name
(
thd
,
about
.
table_name
,
new_name
,
new_name_size
);
archive_name
(
thd
,
about
.
table_name
,
new_name
,
new_name_size
);
}
}
bool
find_archive_name
(
THD
*
thd
,
String
&
out
);
};
};
class
VTMD_exists
:
public
VTMD_table
class
VTMD_exists
:
public
VTMD_table
...
...
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