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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
0aad592f
Commit
0aad592f
authored
Dec 05, 2012
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-3914 fix.
Fixed algorithm of detecting of first real table in view/subquery-in-the-FROM-clase.
parent
b01fbb8e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
11 deletions
+75
-11
mysql-test/r/view.result
mysql-test/r/view.result
+24
-0
mysql-test/t/view.test
mysql-test/t/view.test
+26
-0
sql/table.cc
sql/table.cc
+25
-11
No files found.
mysql-test/r/view.result
View file @
0aad592f
...
...
@@ -4568,6 +4568,30 @@ id id bbb iddqd val1
drop view v2;
drop table t1,t2;
#
# MDEV-3914: Wrong result (NULLs instead of real values)
# with INNER and RIGHT JOIN in a FROM subquery, derived_merge=on
# (fix of above MDEV-486 fix)
#
SET @save_optimizer_switch_MDEV_3914=@@optimizer_switch;
SET optimizer_switch = 'derived_merge=on';
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3),(4);
CREATE TABLE t3 (c INT) ENGINE=MyISAM;
INSERT INTO t3 VALUES (5),(6);
SELECT * FROM ( SELECT c FROM ( t1 INNER JOIN t2 ) RIGHT JOIN t3 ON a = c ) AS alias;
c
5
6
SET optimizer_switch = 'derived_merge=off';
SELECT * FROM ( SELECT c FROM ( t1 INNER JOIN t2 ) RIGHT JOIN t3 ON a = c ) AS alias;
c
5
6
SET optimizer_switch=@save_optimizer_switch_MDEV_3914;
drop table t1,t2,t3;
#
# MDEV-589 (LP BUG#1007647) :
# Assertion `vcol_table == 0 || vcol_table == table' failed in
# fill_record(THD*, List<Item>&, List<Item>&, bool)
...
...
mysql-test/t/view.test
View file @
0aad592f
...
...
@@ -4504,6 +4504,32 @@ select t1.*, v2.* from t1 left join v2 on t1.id = v2.id;
drop
view
v2
;
drop
table
t1
,
t2
;
--
echo
#
--
echo
# MDEV-3914: Wrong result (NULLs instead of real values)
--
echo
# with INNER and RIGHT JOIN in a FROM subquery, derived_merge=on
--
echo
# (fix of above MDEV-486 fix)
--
echo
#
SET
@
save_optimizer_switch_MDEV_3914
=@@
optimizer_switch
;
SET
optimizer_switch
=
'derived_merge=on'
;
CREATE
TABLE
t1
(
a
INT
)
ENGINE
=
MyISAM
;
INSERT
INTO
t1
VALUES
(
1
),(
2
);
CREATE
TABLE
t2
(
b
INT
)
ENGINE
=
MyISAM
;
INSERT
INTO
t2
VALUES
(
3
),(
4
);
CREATE
TABLE
t3
(
c
INT
)
ENGINE
=
MyISAM
;
INSERT
INTO
t3
VALUES
(
5
),(
6
);
SELECT
*
FROM
(
SELECT
c
FROM
(
t1
INNER
JOIN
t2
)
RIGHT
JOIN
t3
ON
a
=
c
)
AS
alias
;
SET
optimizer_switch
=
'derived_merge=off'
;
SELECT
*
FROM
(
SELECT
c
FROM
(
t1
INNER
JOIN
t2
)
RIGHT
JOIN
t3
ON
a
=
c
)
AS
alias
;
SET
optimizer_switch
=@
save_optimizer_switch_MDEV_3914
;
drop
table
t1
,
t2
,
t3
;
--
echo
#
--
echo
# MDEV-589 (LP BUG#1007647) :
--
echo
# Assertion `vcol_table == 0 || vcol_table == table' failed in
...
...
sql/table.cc
View file @
0aad592f
...
...
@@ -4457,19 +4457,33 @@ TABLE *TABLE_LIST::get_real_join_table()
DBUG_ASSERT
(
tbl
->
derived
==
NULL
||
tbl
->
derived
->
first_select
()
->
next_select
()
==
NULL
);
if
(
tbl
->
table
)
table
=
tbl
->
table
;
tbl
=
(
tbl
->
view
!=
NULL
?
tbl
->
view
->
select_lex
.
get_table_list
()
:
tbl
->
derived
->
first_select
()
->
get_table_list
());
/* find left table in outer join on this level */
while
(
tbl
->
outer_join
&
JOIN_TYPE_RIGHT
)
{
DBUG_ASSERT
(
tbl
->
next_local
);
tbl
=
tbl
->
next_local
;
List_iterator_fast
<
TABLE_LIST
>
ti
;
{
List_iterator_fast
<
TABLE_LIST
>
ti
(
tbl
->
view
!=
NULL
?
tbl
->
view
->
select_lex
.
top_join_list
:
tbl
->
derived
->
first_select
()
->
top_join_list
);
for
(;;)
{
tbl
=
NULL
;
/*
Find left table in outer join on this level
(the list is reverted).
*/
for
(
TABLE_LIST
*
t
=
ti
++
;
t
;
t
=
ti
++
)
tbl
=
t
;
/*
It is impossible that the list is empty
so tbl can't be NULL after above loop.
*/
if
(
!
tbl
->
nested_join
)
break
;
/* go deeper if we've found nested join */
ti
=
tbl
->
nested_join
->
join_list
;
}
}
}
}
return
tbl
->
table
;
...
...
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