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
27d9e762
Commit
27d9e762
authored
Dec 21, 2016
by
Aleksey Midenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: prohibit write-locking of historic rows [fixes #102]
parent
46badf17
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
7 deletions
+36
-7
mysql-test/suite/versioning/r/select.result
mysql-test/suite/versioning/r/select.result
+4
-0
mysql-test/suite/versioning/t/select.test
mysql-test/suite/versioning/t/select.test
+5
-0
sql/sql_select.cc
sql/sql_select.cc
+27
-7
No files found.
mysql-test/suite/versioning/r/select.result
View file @
27d9e762
...
...
@@ -402,6 +402,10 @@ create or replace table t1 (x int);
insert into t1 values (1);
select * from t1 for system_time all;
ERROR HY000: System Versioning required: `FOR SYSTEM_TIME` query
create or replace table t1 (x int) with system versioning;
insert into t1 values (1);
select * from t1 for system_time all for update;
ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME query`: write-locking of historic rows
drop table t1;
call verify_vtq;
No A B C D
...
...
mysql-test/suite/versioning/t/select.test
View file @
27d9e762
...
...
@@ -126,6 +126,11 @@ insert into t1 values (1);
--
error
ER_VERSIONING_REQUIRED
select
*
from
t1
for
system_time
all
;
create
or
replace
table
t1
(
x
int
)
with
system
versioning
;
insert
into
t1
values
(
1
);
--
error
ER_VERS_WRONG_PARAMS
select
*
from
t1
for
system_time
all
for
update
;
drop
table
t1
;
call
verify_vtq
;
...
...
sql/sql_select.cc
View file @
27d9e762
...
...
@@ -690,9 +690,11 @@ vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LEX *s
versioned_tables
++
;
}
vers_range_type_t
query_type
=
slex
->
vers_conditions
.
type
;
if
(
versioned_tables
==
0
)
{
if
(
slex
->
vers_conditions
.
type
!=
FOR_SYSTEM_TIME_UNSPECIFIED
)
if
(
query_
type
!=
FOR_SYSTEM_TIME_UNSPECIFIED
)
{
my_error
(
ER_VERSIONING_REQUIRED
,
MYF
(
0
),
"`FOR SYSTEM_TIME` query"
);
DBUG_RETURN
(
-
1
);
...
...
@@ -700,9 +702,27 @@ vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LEX *s
DBUG_RETURN
(
0
);
}
if
(
slex
->
vers_conditions
.
type
==
FOR_SYSTEM_TIME_ALL
)
if
(
query_type
!=
FOR_SYSTEM_TIME_UNSPECIFIED
)
{
DBUG_RETURN
(
0
);
switch
(
slex
->
lock_type
)
{
case
TL_WRITE_ALLOW_WRITE
:
case
TL_WRITE_CONCURRENT_INSERT
:
case
TL_WRITE_DELAYED
:
case
TL_WRITE_DEFAULT
:
case
TL_WRITE_LOW_PRIORITY
:
case
TL_WRITE
:
case
TL_WRITE_ONLY
:
my_error
(
ER_VERS_WRONG_PARAMS
,
MYF
(
0
),
"FOR SYSTEM_TIME query"
,
"write-locking of historic rows"
);
DBUG_RETURN
(
-
1
);
default:
break
;
}
if
(
query_type
==
FOR_SYSTEM_TIME_ALL
)
{
DBUG_RETURN
(
0
);
}
}
/* For prepared statements we create items on statement arena,
...
...
@@ -784,7 +804,7 @@ vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LEX *s
}
}
else
if
(
vers_simple_select
&&
slex
->
vers_conditions
.
unit
==
UNIT_TIMESTAMP
&&
slex
->
vers_conditions
.
type
!=
FOR_SYSTEM_TIME_UNSPECIFIED
)
&&
query_
type
!=
FOR_SYSTEM_TIME_UNSPECIFIED
)
{
DBUG_ASSERT
(
table
->
table
->
s
&&
table
->
table
->
s
->
db_plugin
);
handlerton
*
hton
=
plugin_hton
(
table
->
table
->
s
->
db_plugin
);
...
...
@@ -805,7 +825,7 @@ vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LEX *s
Item
*
cond1
=
0
,
*
cond2
=
0
,
*
curr
=
0
;
if
(
table
->
table
->
versioned_by_sql
()
||
vers_simple_select
)
{
switch
(
slex
->
vers_conditions
.
type
)
switch
(
query_
type
)
{
case
FOR_SYSTEM_TIME_UNSPECIFIED
:
if
(
table
->
table
->
versioned_by_sql
())
...
...
@@ -851,7 +871,7 @@ vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LEX *s
Item
*
trx_id0
,
*
trx_id1
;
switch
(
slex
->
vers_conditions
.
type
)
switch
(
query_
type
)
{
case
FOR_SYSTEM_TIME_UNSPECIFIED
:
curr
=
newx
Item_int
(
thd
,
ULONGLONG_MAX
);
...
...
@@ -877,7 +897,7 @@ vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LEX *s
trx_id1
=
slex
->
vers_conditions
.
end
;
}
cond1
=
slex
->
vers_conditions
.
type
==
FOR_SYSTEM_TIME_FROM_TO
?
cond1
=
query_
type
==
FOR_SYSTEM_TIME_FROM_TO
?
newx
Item_func_vtq_trx_sees
(
thd
,
trx_id1
,
row_start
)
:
newx
Item_func_vtq_trx_sees_eq
(
thd
,
trx_id1
,
row_start
);
cond2
=
newx
Item_func_vtq_trx_sees_eq
(
thd
,
row_end
,
trx_id0
);
...
...
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