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
6c9b71d7
Commit
6c9b71d7
authored
Sep 20, 2017
by
Aleksey Midenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: VTMD for OR REPLACE [fixes #270]
parent
9ba635fd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
31 deletions
+52
-31
mysql-test/suite/versioning/r/vtmd.result
mysql-test/suite/versioning/r/vtmd.result
+8
-4
mysql-test/suite/versioning/t/vtmd.test
mysql-test/suite/versioning/t/vtmd.test
+7
-3
sql/mysqld.h
sql/mysqld.h
+1
-1
sql/sql_table.cc
sql/sql_table.cc
+32
-20
sql/vtmd.cc
sql/vtmd.cc
+4
-3
No files found.
mysql-test/suite/versioning/r/vtmd.result
View file @
6c9b71d7
...
...
@@ -37,7 +37,7 @@ set @start= null;
select start from tmp_vtmd for system_time all order by start limit 1 into @start;
select @start > 0 and @start < @inf;
select
start
+ 0
= @start as A_start,
start
>
= @start as A_start,
(@start:= end) and end = @inf as B_end,
name,
substr(archive_name, 1, instr(archive_name, '_')) as C_archive_name
...
...
@@ -45,12 +45,12 @@ from tmp_vtmd for system_time all;
drop table tmp_vtmd;
end~~
set versioning_alter_history= keep;
create
or replace table t0 (x
int) with system versioning;
create
table t0 (z
int) with system versioning;
show tables;
Tables_in_test
t0
set versioning_alter_history= survive;
create or replace table t0 (
x
int) with system versioning;
create or replace table t0 (
y
int) with system versioning;
show tables;
Tables_in_test
t0
...
...
@@ -75,14 +75,18 @@ A_start B_end name C_archive_name
set versioning_alter_history= keep;
drop table t0;
set versioning_alter_history= survive;
create
or replace
table t0 (x int) with system versioning;
create table t0 (x int) with system versioning;
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;
alter table t0 add column (y int);
call check_vtmd('t0_vtmd');
@start > 0 and @start < @inf
1
A_start B_end name C_archive_name
1 0 t0 t0_
1 0 t0 t0_
1 1 t0 NULL
call drop_archives('t0_vtmd');
drop table t0_vtmd;
...
...
mysql-test/suite/versioning/t/vtmd.test
View file @
6c9b71d7
...
...
@@ -46,7 +46,7 @@ begin
select
start
from
tmp_vtmd
for
system_time
all
order
by
start
limit
1
into
@
start
;
select
@
start
>
0
and
@
start
<
@
inf
;
select
start
+
0
=
@
start
as
A_start
,
start
>
=
@
start
as
A_start
,
(
@
start
:=
end
)
and
end
=
@
inf
as
B_end
,
name
,
substr
(
archive_name
,
1
,
instr
(
archive_name
,
'_'
))
as
C_archive_name
...
...
@@ -58,10 +58,10 @@ delimiter ;~~
# create
set
versioning_alter_history
=
keep
;
create
or
replace
table
t0
(
x
int
)
with
system
versioning
;
create
table
t0
(
z
int
)
with
system
versioning
;
show
tables
;
set
versioning_alter_history
=
survive
;
create
or
replace
table
t0
(
x
int
)
with
system
versioning
;
create
or
replace
table
t0
(
y
int
)
with
system
versioning
;
show
tables
;
show
create
table
t0_vtmd
;
call
check_vtmd
(
't0_vtmd'
);
...
...
@@ -70,6 +70,10 @@ set versioning_alter_history= keep;
drop
table
t0
;
set
versioning_alter_history
=
survive
;
--
error
ER_VERS_VTMD_ERROR
create
table
t0
(
x
int
)
with
system
versioning
;
drop
table
t0_vtmd
;
create
table
t0
(
y
int
)
with
system
versioning
;
create
or
replace
table
t0
(
x
int
)
with
system
versioning
;
# alter
...
...
sql/mysqld.h
View file @
6c9b71d7
...
...
@@ -211,7 +211,7 @@ enum vers_hide_enum
enum
vers_alter_history_enum
{
VERS_ALTER_HISTORY_KEEP
,
VERS_ALTER_HISTORY_KEEP
=
0
,
VERS_ALTER_HISTORY_SURVIVE
,
VERS_ALTER_HISTORY_DROP
};
...
...
sql/sql_table.cc
View file @
6c9b71d7
...
...
@@ -2438,6 +2438,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
else
{
char
*
end
;
int
frm_delete_error
=
0
;
/*
It could happen that table's share in the table definition cache
is the only thing that keeps the engine plugin loaded
...
...
@@ -2476,7 +2477,8 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
// Remove extension for delete
*
(
end
=
path
+
path_length
-
reg_ext_length
)
=
'\0'
;
if
(
thd
->
lex
->
sql_command
==
SQLCOM_DROP_TABLE
&&
if
((
thd
->
lex
->
sql_command
==
SQLCOM_DROP_TABLE
||
thd
->
lex
->
sql_command
==
SQLCOM_CREATE_TABLE
)
&&
thd
->
variables
.
vers_alter_history
==
VERS_ALTER_HISTORY_SURVIVE
&&
table_type
&&
table_type
!=
view_pseudo_hton
)
{
...
...
@@ -2493,29 +2495,33 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
drop_table:
error
=
ha_delete_table
(
thd
,
table_type
,
path
,
db
,
table
->
table_name
,
!
dont_log_query
);
if
(
!
error
)
{
/* Delete the table definition file */
strmov
(
end
,
reg_ext
);
if
(
table_type
&&
table_type
!=
view_pseudo_hton
&&
table_type
->
discover_table
)
{
/*
Table type is using discovery and may not need a .frm file.
Delete it silently if it exists
*/
(
void
)
mysql_file_delete
(
key_file_frm
,
path
,
MYF
(
0
));
}
else
if
(
mysql_file_delete
(
key_file_frm
,
path
,
MYF
(
MY_WME
)))
{
frm_delete_error
=
my_errno
;
DBUG_ASSERT
(
frm_delete_error
);
}
}
}
if
(
!
error
)
{
int
frm_delete_error
,
trigger_drop_error
=
0
;
/* Delete the table definition file */
strmov
(
end
,
reg_ext
);
if
(
table_type
&&
table_type
!=
view_pseudo_hton
&&
table_type
->
discover_table
)
{
/*
Table type is using discovery and may not need a .frm file.
Delete it silently if it exists
*/
(
void
)
mysql_file_delete
(
key_file_frm
,
path
,
MYF
(
0
));
frm_delete_error
=
0
;
}
else
frm_delete_error
=
mysql_file_delete
(
key_file_frm
,
path
,
MYF
(
MY_WME
));
if
(
frm_delete_error
)
frm_delete_error
=
my_errno
;
else
int
trigger_drop_error
=
0
;
if
(
!
frm_delete_error
)
{
non_tmp_table_deleted
=
TRUE
;
trigger_drop_error
=
...
...
@@ -2534,7 +2540,10 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
if
(
!
error
&&
vtmd
.
exists
)
{
enum_sql_command
sql_command
=
thd
->
lex
->
sql_command
;
thd
->
lex
->
sql_command
=
SQLCOM_DROP_TABLE
;
error
=
vtmd
.
update
(
thd
);
thd
->
lex
->
sql_command
=
sql_command
;
if
(
error
)
mysql_rename_table
(
table_type
,
table
->
db
,
vtmd
.
archive_name
(),
table
->
db
,
table
->
table_name
,
NO_FK_CHECKS
);
...
...
@@ -5081,6 +5090,9 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
VTMD_table
vtmd
(
*
create_table
);
if
(
vtmd
.
update
(
thd
))
{
thd
->
variables
.
vers_alter_history
=
VERS_ALTER_HISTORY_KEEP
;
mysql_rm_table_no_locks
(
thd
,
create_table
,
0
,
0
,
0
,
0
,
1
,
1
);
thd
->
variables
.
vers_alter_history
=
VERS_ALTER_HISTORY_SURVIVE
;
result
=
1
;
goto
err
;
}
...
...
sql/vtmd.cc
View file @
6c9b71d7
...
...
@@ -237,10 +237,9 @@ VTMD_table::update(THD *thd, const char* archive_name)
{
err:
vtmd
->
file
->
print_error
(
error
,
MYF
(
0
));
goto
quit
;
}
result
=
false
;
else
result
=
local_da
.
is_error
()
;
}
quit:
...
...
@@ -436,6 +435,8 @@ VTMD_rename::try_rename(THD *thd, LString new_db, LString new_alias, const char
if
(
lock_table_names
(
thd
,
&
vtmd_tl
,
0
,
thd
->
variables
.
lock_wait_timeout
,
0
))
return
true
;
tdc_remove_table
(
thd
,
TDC_RT_REMOVE_ALL
,
about
.
db
,
vtmd_name
,
false
);
if
(
local_da
.
is_error
())
// just safety check
return
true
;
bool
rc
=
mysql_rename_table
(
hton
,
about
.
db
,
vtmd_name
,
new_db
,
vtmd_new_name
,
...
...
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