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
5e42511c
Commit
5e42511c
authored
Sep 28, 2017
by
Aleksey Midenkov
Committed by
GitHub
Sep 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: SELECT from archive table [closes #127]
parent
c5801dd6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
8 deletions
+56
-8
mysql-test/suite/versioning/r/vtmd.result
mysql-test/suite/versioning/r/vtmd.result
+8
-0
mysql-test/suite/versioning/t/vtmd.test
mysql-test/suite/versioning/t/vtmd.test
+4
-0
sql/sql_parse.cc
sql/sql_parse.cc
+16
-0
sql/sql_show.cc
sql/sql_show.cc
+8
-5
sql/vtmd.cc
sql/vtmd.cc
+19
-2
sql/vtmd.h
sql/vtmd.h
+1
-1
No files found.
mysql-test/suite/versioning/r/vtmd.result
View file @
5e42511c
...
...
@@ -86,7 +86,15 @@ ERROR HY000: VTMD error: `test.t0_vtmd` exists and not empty!
drop table t0_vtmd;
create table t0 (y int) with system versioning;
create or replace table t0 (x int) with system versioning;
insert into t0 values (1);
set @t0= now(6);
alter table t0 add column (y int);
select * from t0 for system_time as of @t0;
x
1
select * from t0;
x y
1 NULL
call check_vtmd('t0_vtmd');
@start > 0 and @start < @inf
1
...
...
mysql-test/suite/versioning/t/vtmd.test
View file @
5e42511c
...
...
@@ -86,7 +86,11 @@ create table t0 (y int) with system versioning;
create
or
replace
table
t0
(
x
int
)
with
system
versioning
;
# alter
insert
into
t0
values
(
1
);
set
@
t0
=
now
(
6
);
alter
table
t0
add
column
(
y
int
);
select
*
from
t0
for
system_time
as
of
@
t0
;
select
*
from
t0
;
call
check_vtmd
(
't0_vtmd'
);
call
drop_archives
(
't0_vtmd'
);
...
...
sql/sql_parse.cc
View file @
5e42511c
...
...
@@ -113,6 +113,7 @@
#include "wsrep_mysqld.h"
#include "wsrep_thd.h"
#include "vtmd.h"
static
void
wsrep_mysql_parse
(
THD
*
thd
,
char
*
rawbuf
,
uint
length
,
Parser_state
*
parser_state
,
...
...
@@ -6373,6 +6374,21 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
if
(
check_dependencies_in_with_clauses
(
lex
->
with_clauses_list
))
return
1
;
if
(
thd
->
variables
.
vers_alter_history
==
VERS_ALTER_HISTORY_SURVIVE
)
{
for
(
TABLE_LIST
*
table
=
all_tables
;
table
;
table
=
table
->
next_local
)
{
if
(
table
->
vers_conditions
)
{
VTMD_exists
vtmd
(
*
table
);
if
(
vtmd
.
check_exists
(
thd
))
return
1
;
if
(
vtmd
.
exists
&&
vtmd
.
setup_select
(
thd
))
return
1
;
}
}
}
if
(
!
(
res
=
open_and_lock_tables
(
thd
,
all_tables
,
TRUE
,
0
)))
{
if
(
lex
->
describe
)
...
...
sql/sql_show.cc
View file @
5e42511c
...
...
@@ -1280,12 +1280,15 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
if
(
vtmd
.
find_archive_name
(
thd
,
archive_name
))
goto
exit
;
archive
.
init_one_table
(
table_list
->
db
,
table_list
->
db_length
,
archive_name
.
ptr
(),
archive_name
.
length
(),
archive_name
.
ptr
(),
TL_READ
);
if
(
archive_name
.
length
()
>
0
)
{
archive
.
init_one_table
(
table_list
->
db
,
table_list
->
db_length
,
archive_name
.
ptr
(),
archive_name
.
length
(),
archive_name
.
ptr
(),
TL_READ
);
archive
.
alias
=
table_list
->
table_name
;
archive
.
vers_force_alias
=
true
;
table_list
=
&
archive
;
archive
.
alias
=
table_list
->
table_name
;
archive
.
vers_force_alias
=
true
;
table_list
=
&
archive
;
}
}
if
(
mysqld_show_create_get_fields
(
thd
,
table_list
,
&
field_list
,
&
buffer
))
...
...
sql/vtmd.cc
View file @
5e42511c
...
...
@@ -7,6 +7,8 @@
#include "table_cache.h" // tdc_remove_table()
#include "key.h"
#include "sql_show.h"
#include "sql_parse.h"
#include "sql_lex.h"
LString
VERS_VTMD_TEMPLATE
(
C_STRING_WITH_LEN
(
"vtmd_template"
));
...
...
@@ -546,8 +548,6 @@ VTMD_table::find_archive_name(THD *thd, String &out)
if
(
select
->
skip_record
(
thd
)
>
0
)
{
vtmd
.
table
->
field
[
FLD_ARCHIVE_NAME
]
->
val_str
(
&
out
);
if
(
out
.
length
()
==
0
)
// Handle AS OF NOW or RENAME TABLE case
out
.
set
(
about
.
table_name
,
about
.
table_name_length
,
system_charset_info
);
break
;
}
}
...
...
@@ -644,3 +644,20 @@ VTMD_table::get_archive_tables(THD *thd, const char *db, size_t db_length,
return
false
;
}
bool
VTMD_table
::
setup_select
(
THD
*
thd
)
{
SString
archive_name
;
if
(
find_archive_name
(
thd
,
archive_name
))
return
true
;
if
(
archive_name
.
length
()
==
0
)
return
false
;
about
.
table_name
=
(
char
*
)
thd
->
memdup
(
archive_name
.
c_ptr_safe
(),
archive_name
.
length
()
+
1
);
about
.
table_name_length
=
archive_name
.
length
();
DBUG_ASSERT
(
!
about
.
mdl_request
.
ticket
);
about
.
mdl_request
.
init
(
MDL_key
::
TABLE
,
about
.
db
,
about
.
table_name
,
about
.
mdl_request
.
type
,
about
.
mdl_request
.
duration
);
return
false
;
}
sql/vtmd.h
View file @
5e42511c
...
...
@@ -52,7 +52,7 @@ class VTMD_table
protected:
TABLE_LIST
vtmd
;
const
TABLE_LIST
&
about
;
TABLE_LIST
&
about
;
SString_t
vtmd_name
;
private:
...
...
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