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
fa4525ca
Commit
fa4525ca
authored
Aug 05, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge rurik.mysql.com:/home/igor/mysql-5.0
into rurik.mysql.com:/home/igor/dev/mysql-5.0-0
parents
e71d99d9
6d5d8c92
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
0 deletions
+109
-0
mysql-test/r/join_nested.result
mysql-test/r/join_nested.result
+55
-0
mysql-test/t/join_nested.test
mysql-test/t/join_nested.test
+48
-0
sql/mysql_priv.h
sql/mysql_priv.h
+6
-0
No files found.
mysql-test/r/join_nested.result
View file @
fa4525ca
...
...
@@ -1343,3 +1343,58 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 0
1 SIMPLE t3 ALL NULL NULL NULL NULL 0
DROP TABLE t1,t2,t3;
CREATE TABLE t1 (goods int(12) NOT NULL, price varchar(128) NOT NULL);
INSERT INTO t1 VALUES (23, 2340), (26, 9900);
CREATE TABLE t2 (goods int(12), name varchar(50), shop char(2));
INSERT INTO t2 VALUES (23, 'as300', 'fr'), (26, 'as600', 'fr');
create table t3 (groupid int(12) NOT NULL, goodsid int(12) NOT NULL);
INSERT INTO t3 VALUES (3,23), (6,26);
CREATE TABLE t4 (groupid int(12));
INSERT INTO t4 VALUES (1), (2), (3), (4), (5), (6);
SELECT * FROM
(SELECT DISTINCT gl.groupid, gp.price
FROM t4 gl
LEFT JOIN
(t3 g INNER JOIN t2 p ON g.goodsid = p.goods
INNER JOIN t1 gp ON p.goods = gp.goods)
ON gl.groupid = g.groupid and p.shop = 'fr') t;
groupid price
1 NULL
2 NULL
3 2340
4 NULL
5 NULL
6 9900
CREATE VIEW v1 AS
SELECT g.groupid groupid, p.goods goods,
p.name name, p.shop shop,
gp.price price
FROM t3 g INNER JOIN t2 p ON g.goodsid = p.goods
INNER JOIN t1 gp on p.goods = gp.goods;
CREATE VIEW v2 AS
SELECT DISTINCT g.groupid, fr.price
FROM t4 g
LEFT JOIN
v1 fr on g.groupid = fr.groupid and fr.shop = 'fr';
SELECT * FROM v2;
groupid price
1 NULL
2 NULL
3 2340
4 NULL
5 NULL
6 9900
SELECT * FROM
(SELECT DISTINCT g.groupid, fr.price
FROM t4 g
LEFT JOIN
v1 fr on g.groupid = fr.groupid and fr.shop = 'fr') t;
groupid price
1 NULL
2 NULL
3 2340
4 NULL
5 NULL
6 9900
DROP VIEW v1,v2;
DROP TABLE t1,t2,t3,t4;
mysql-test/t/join_nested.test
View file @
fa4525ca
...
...
@@ -770,3 +770,51 @@ SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21;
EXPLAIN
SELECT
*
FROM
t1
LEFT
JOIN
(
t2
LEFT
JOIN
t3
ON
c21
=
c31
)
ON
c11
=
c21
;
DROP
TABLE
t1
,
t2
,
t3
;
#
# Bug #12154: creation of temp table for a query with nested outer join
#
CREATE
TABLE
t1
(
goods
int
(
12
)
NOT
NULL
,
price
varchar
(
128
)
NOT
NULL
);
INSERT
INTO
t1
VALUES
(
23
,
2340
),
(
26
,
9900
);
CREATE
TABLE
t2
(
goods
int
(
12
),
name
varchar
(
50
),
shop
char
(
2
));
INSERT
INTO
t2
VALUES
(
23
,
'as300'
,
'fr'
),
(
26
,
'as600'
,
'fr'
);
create
table
t3
(
groupid
int
(
12
)
NOT
NULL
,
goodsid
int
(
12
)
NOT
NULL
);
INSERT
INTO
t3
VALUES
(
3
,
23
),
(
6
,
26
);
CREATE
TABLE
t4
(
groupid
int
(
12
));
INSERT
INTO
t4
VALUES
(
1
),
(
2
),
(
3
),
(
4
),
(
5
),
(
6
);
SELECT
*
FROM
(
SELECT
DISTINCT
gl
.
groupid
,
gp
.
price
FROM
t4
gl
LEFT
JOIN
(
t3
g
INNER
JOIN
t2
p
ON
g
.
goodsid
=
p
.
goods
INNER
JOIN
t1
gp
ON
p
.
goods
=
gp
.
goods
)
ON
gl
.
groupid
=
g
.
groupid
and
p
.
shop
=
'fr'
)
t
;
CREATE
VIEW
v1
AS
SELECT
g
.
groupid
groupid
,
p
.
goods
goods
,
p
.
name
name
,
p
.
shop
shop
,
gp
.
price
price
FROM
t3
g
INNER
JOIN
t2
p
ON
g
.
goodsid
=
p
.
goods
INNER
JOIN
t1
gp
on
p
.
goods
=
gp
.
goods
;
CREATE
VIEW
v2
AS
SELECT
DISTINCT
g
.
groupid
,
fr
.
price
FROM
t4
g
LEFT
JOIN
v1
fr
on
g
.
groupid
=
fr
.
groupid
and
fr
.
shop
=
'fr'
;
SELECT
*
FROM
v2
;
SELECT
*
FROM
(
SELECT
DISTINCT
g
.
groupid
,
fr
.
price
FROM
t4
g
LEFT
JOIN
v1
fr
on
g
.
groupid
=
fr
.
groupid
and
fr
.
shop
=
'fr'
)
t
;
DROP
VIEW
v1
,
v2
;
DROP
TABLE
t1
,
t2
,
t3
,
t4
;
sql/mysql_priv.h
View file @
fa4525ca
...
...
@@ -1450,6 +1450,12 @@ inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr)
table
->
status
=
STATUS_NO_RECORD
;
table
->
keys_in_use_for_query
=
table
->
s
->
keys_in_use
;
table
->
maybe_null
=
table_list
->
outer_join
;
TABLE_LIST
*
embedding
=
table_list
->
embedding
;
while
(
!
table
->
maybe_null
&&
embedding
)
{
table
->
maybe_null
=
embedding
->
outer_join
;
embedding
=
embedding
->
embedding
;
}
table
->
tablenr
=
tablenr
;
table
->
map
=
(
table_map
)
1
<<
tablenr
;
table
->
force_index
=
table_list
->
force_index
;
...
...
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