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
7e0ff13d
Commit
7e0ff13d
authored
Apr 30, 2017
by
Aleksey Midenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: derived fixes [related to #185]
parent
8a11f9b2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
9 deletions
+21
-9
mysql-test/suite/versioning/r/cte_recursive.result
mysql-test/suite/versioning/r/cte_recursive.result
+2
-2
mysql-test/suite/versioning/r/view.result
mysql-test/suite/versioning/r/view.result
+4
-0
mysql-test/suite/versioning/t/cte_recursive.test
mysql-test/suite/versioning/t/cte_recursive.test
+2
-2
sql/sql_derived.cc
sql/sql_derived.cc
+5
-1
sql/sql_select.cc
sql/sql_select.cc
+8
-4
No files found.
mysql-test/suite/versioning/r/cte_recursive.result
View file @
7e0ff13d
...
...
@@ -41,7 +41,7 @@ from emp as e for system_time as of timestamp @ts_1,
ancestors as a
where e.mgr = a.emp_id
)
select * from ancestors;
select * from ancestors
for system_time as of now
;
emp_id name mgr salary
1 bill NULL 1000
30 jane 1 750
...
...
@@ -59,7 +59,7 @@ from emp as e for system_time as of timestamp @ts_2,
ancestors as a
where e.mgr = a.emp_id
)
select * from ancestors
for system_time as of timestamp @ts_2
;
select * from ancestors;
emp_id name mgr salary
1 bill NULL 1000
30 jane 1 750
...
...
mysql-test/suite/versioning/r/view.result
View file @
7e0ff13d
...
...
@@ -39,9 +39,13 @@ x
drop prepare stmt;
select * from vt1;
x
2
1
prepare stmt from 'select * from vt1';
execute stmt;
x
2
1
drop prepare stmt;
select * from t1 for system_time as of timestamp @t1;
x
...
...
mysql-test/suite/versioning/t/cte_recursive.test
View file @
7e0ff13d
...
...
@@ -47,7 +47,7 @@ as
ancestors
as
a
where
e
.
mgr
=
a
.
emp_id
)
select
*
from
ancestors
;
select
*
from
ancestors
for
system_time
as
of
now
;
/* Expected 3 rows */
with
recursive
...
...
@@ -63,7 +63,7 @@ as
ancestors
as
a
where
e
.
mgr
=
a
.
emp_id
)
select
*
from
ancestors
for
system_time
as
of
timestamp
@
ts_2
;
select
*
from
ancestors
;
drop
table
emp
;
drop
table
dept
;
sql/sql_derived.cc
View file @
7e0ff13d
...
...
@@ -824,8 +824,12 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
if
(
!
expli_end
&&
(
res
=
sl
->
vers_push_field
(
thd
,
impli_table
,
impli_end
)))
goto
exit
;
if
(
impli_table
->
vers_conditions
&&
!
derived
->
is_view
())
if
(
impli_table
->
vers_conditions
)
{
sl
->
vers_derived_conds
=
impli_table
->
vers_conditions
;
if
(
derived
->
is_view
()
&&
!
sl
->
vers_conditions
)
sl
->
vers_conditions
.
import_outer
=
true
;
}
else
if
(
sl
->
vers_conditions
)
sl
->
vers_derived_conds
=
sl
->
vers_conditions
;
else
...
...
sql/sql_select.cc
View file @
7e0ff13d
...
...
@@ -771,6 +771,7 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
}
SELECT_LEX
*
outer_slex
=
slex
->
next_select_in_list
();
bool
use_slex_conds
=
false
;
if
(
outer_slex
)
{
if
(
slex
->
vers_derived_conds
)
...
...
@@ -778,11 +779,12 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
// Propagate derived conditions to outer SELECT_LEX:
if
(
!
outer_slex
->
vers_conditions
)
{
(
outer_slex
->
vers_conditions
=
slex
->
vers_derived_conds
).
from_inner
=
true
;
outer_slex
->
vers_conditions
=
slex
->
vers_derived_conds
;
outer_slex
->
vers_conditions
.
from_inner
=
true
;
outer_slex
->
vers_conditions
.
used
=
true
;
}
}
else
if
(
slex
->
vers_conditions
.
import_outer
)
if
(
slex
->
vers_conditions
.
import_outer
)
{
// Propagate query conditions from nearest outer SELECT_LEX:
while
(
outer_slex
&&
(
!
outer_slex
->
vers_conditions
||
outer_slex
->
vers_conditions
.
from_inner
))
...
...
@@ -791,6 +793,8 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
{
slex
->
vers_conditions
=
outer_slex
->
vers_conditions
;
outer_slex
->
vers_conditions
.
used
=
true
;
DBUG_ASSERT
(
slex
->
master_unit
()
->
derived
);
use_slex_conds
=
slex
->
master_unit
()
->
derived
->
is_view
();
}
}
}
...
...
@@ -799,7 +803,7 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
{
if
(
table
->
table
&&
table
->
table
->
versioned
())
{
vers_select_conds_t
&
vers_conditions
=
!
table
->
vers_conditions
?
vers_select_conds_t
&
vers_conditions
=
use_slex_conds
||
!
table
->
vers_conditions
?
(
slex
->
vers_conditions
.
used
=
true
,
slex
->
vers_conditions
)
:
table
->
vers_conditions
;
...
...
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