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
01c9d1c9
Commit
01c9d1c9
authored
Oct 18, 2016
by
Aleksey Midenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: SP idempotency fix
Fixes #52
parent
44e581eb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
19 deletions
+66
-19
mysql-test/suite/versioning/r/auto_increment.result
mysql-test/suite/versioning/r/auto_increment.result
+38
-0
mysql-test/suite/versioning/t/auto_increment.test
mysql-test/suite/versioning/t/auto_increment.test
+1
-2
sql/sql_select.cc
sql/sql_select.cc
+27
-17
No files found.
mysql-test/suite/versioning/r/auto_increment.result
View file @
01c9d1c9
...
...
@@ -93,7 +93,45 @@ A x y x y
1 5 15 5 15
1 6 16 6 16
1 7 17 7 17
call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
A x y x y
1 1 11 1 11
1 2 12 2 12
1 3 13 3 13
1 4 14 4 14
1 5 15 5 15
1 6 16 6 16
1 7 17 7 17
1 8 18 8 18
1 9 19 9 19
A x y x y
1 1 11 1 11
1 3 13 3 13
1 4 14 4 14
1 5 15 5 15
1 6 16 6 16
1 7 17 7 17
1 8 18 8 18
1 9 19 9 19
A x y x y
1 1 11 1 11
1 3 13 3 13
1 4 14 4 14
1 5 15 5 15
1 6 16 6 16
1 7 17 7 17
call verify_vtq;
No A B C D
1 1 1 1 1
2 1 1 1 1
3 1 1 1 1
4 1 1 1 1
5 1 1 1 1
6 1 1 1 1
7 1 1 1 1
8 1 1 1 1
9 1 1 1 1
10 1 1 1 1
11 1 1 1 1
drop procedure test_01;
drop procedure verify_vtq;
mysql-test/suite/versioning/t/auto_increment.test
View file @
01c9d1c9
...
...
@@ -60,8 +60,7 @@ end~~
delimiter
;
~~
call
test_01
(
'timestamp(6)'
,
'myisam'
,
'sys_end'
);
# Issue #52
# call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_end)');
call
test_01
(
'bigint unsigned'
,
'innodb'
,
'commit_ts(sys_end)'
);
call
verify_vtq
;
drop
procedure
test_01
;
...
...
sql/sql_select.cc
View file @
01c9d1c9
...
...
@@ -701,44 +701,54 @@ setup_for_system_time(THD *thd, TABLE_LIST *tables, COND **where_expr, SELECT_LE
if
(
select_lex
->
saved_where
)
{
DBUG_ASSERT
(
thd
->
stmt_arena
->
is_sp_execute
());
*
where_expr
=
select_lex
->
saved_where
;
/* 2. this copy_andor_structure() is also required by the same reason */
*
where_expr
=
select_lex
->
saved_where
->
copy_andor_structure
(
thd
);
}
else
if
(
thd
->
stmt_arena
->
is_sp_execute
())
{
if
(
thd
->
stmt_arena
->
is_stmt_execute
())
// SP executed second time (STMT_EXECUTED)
*
where_expr
=
0
;
else
if
(
*
where_expr
)
// SP executed first time (STMT_INITIALIZED_FOR_SP)
/* copy_andor_structure() is required since this andor tree
/*
1.
copy_andor_structure() is required since this andor tree
is modified later (and on shorter arena) */
select_lex
->
saved_where
=
(
*
where_expr
)
->
copy_andor_structure
(
thd
);
}
for
(
table
=
tables
;
table
;
table
=
table
->
next_local
)
/* We have to save also non-versioned on_expr since we may have
conjuction of versioned + non-versioned */
if
(
thd
->
stmt_arena
->
is_sp_execute
())
{
if
(
table
->
table
&&
table
->
table
->
versioned
()
)
for
(
table
=
tables
;
table
;
table
=
table
->
next_local
)
{
COND
**
dst_cond
=
where_expr
;
if
(
!
table
->
table
)
continue
;
if
(
table
->
saved_on_expr
)
// same logic as saved_where
{
DBUG_ASSERT
(
thd
->
stmt_arena
->
is_sp_execute
());
if
(
table
->
on_expr
)
{
table
->
on_expr
=
table
->
saved_on_expr
;
dst_cond
=
&
table
->
on_expr
;
}
table
->
on_expr
=
table
->
saved_on_expr
->
copy_andor_structure
(
thd
);
else
{
// on_expr was moved to WHERE (see below: Add ON expression to the WHERE)
*
dst_cond
=
and_items
(
thd
,
*
where_expr
=
and_items
(
thd
,
*
where_expr
,
table
->
saved_on_expr
);
table
->
saved_on_expr
->
copy_andor_structure
(
thd
));
}
else
if
(
table
->
on_expr
&&
thd
->
stmt_arena
->
state
==
Query_arena
::
STMT_INITIALIZED_FOR_SP
)
{
table
->
saved_on_expr
=
table
->
on_expr
->
copy_andor_structure
(
thd
);
}
}
}
else
if
(
table
->
on_expr
)
for
(
table
=
tables
;
table
;
table
=
table
->
next_local
)
{
if
(
table
->
table
&&
table
->
table
->
versioned
())
{
COND
**
dst_cond
=
where_expr
;
if
(
table
->
on_expr
)
{
dst_cond
=
&
table
->
on_expr
;
if
(
thd
->
stmt_arena
->
state
==
Query_arena
::
STMT_INITIALIZED_FOR_SP
)
table
->
saved_on_expr
=
table
->
on_expr
->
copy_andor_structure
(
thd
);
}
Field
*
fstart
=
table
->
table
->
vers_start_field
();
...
...
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