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
cfc78964
Commit
cfc78964
authored
Jul 18, 2011
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge.
parents
fdad4063
a7287d9a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
3 deletions
+83
-3
mysql-test/r/derived_view.result
mysql-test/r/derived_view.result
+52
-2
mysql-test/t/derived_view.test
mysql-test/t/derived_view.test
+30
-1
sql/sql_select.cc
sql/sql_select.cc
+1
-0
No files found.
mysql-test/r/derived_view.result
View file @
cfc78964
...
@@ -743,7 +743,7 @@ SELECT * FROM t1, t2, v1 WHERE t2.a=t1.a AND t2.a=v1.a AND t2.a=v1.b;
...
@@ -743,7 +743,7 @@ SELECT * FROM t1, t2, v1 WHERE t2.a=t1.a AND t2.a=v1.a AND t2.a=v1.b;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
1 PRIMARY t1 system NULL NULL NULL NULL 1
1 PRIMARY t2 ref a a 4 const 1 Using index
1 PRIMARY t2 ref a a 4 const 1 Using index
1 PRIMARY <derived2> ref key1 key1 10 test.t1.a,test.t1.a 2
Using where
1 PRIMARY <derived2> ref key1 key1 10 test.t1.a,test.t1.a 2
2 DERIVED t3 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
2 DERIVED t3 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
SELECT * FROM t1, t2, v1 WHERE t2.a=t1.a AND t2.a=v1.a AND t2.a=v1.b;
SELECT * FROM t1, t2, v1 WHERE t2.a=t1.a AND t2.a=v1.a AND t2.a=v1.b;
a a a b
a a a b
...
@@ -1050,7 +1050,7 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -1050,7 +1050,7 @@ id select_type table type possible_keys key key_len ref rows Extra
DROP VIEW v1;
DROP VIEW v1;
DROP TABLE t1,t2,t3;
DROP TABLE t1,t2,t3;
#
#
# LP bug #809179
# LP bug #809179
: right join over a derived table / view
#
#
CREATE TABLE t1 (a int, b int);
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (6,5);
INSERT INTO t1 VALUES (6,5);
...
@@ -1116,3 +1116,53 @@ INSERT INTO v3(a) VALUES (1);
...
@@ -1116,3 +1116,53 @@ INSERT INTO v3(a) VALUES (1);
ERROR HY000: The target table v3 of the INSERT is not insertable-into
ERROR HY000: The target table v3 of the INSERT is not insertable-into
DROP VIEW v1,v2,v3;
DROP VIEW v1,v2,v3;
DROP TABLE t1,t2,t3;
DROP TABLE t1,t2,t3;
#
# LP bug #793448: materialized view accessed by two-component key
#
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (9,3), (2,5);
CREATE TABLE t2 (a int, b int);
INSERT INTO t2 VALUES (9,3), (3,7), (9,1), (2,5), (2,4), (3,8);
CREATE TABLE t3 (a int, b int);
INSERT INTO t3 VALUES (10,3), (9,7), (9,1), (2,4);
CREATE VIEW v1(a,b) AS SELECT a, MAX(b) FROM t2 GROUP BY a;
CREATE VIEW v2(a,b) AS SELECT a,b FROM t2 UNION SELECT a,b FROM t3;
SELECT * FROM v1;
a b
2 5
3 8
9 3
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1);
a
9
2
EXPLAIN
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 10 func,func 2 Using where
3 DERIVED t2 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
SELECT * FROM v2;
a b
9 3
3 7
9 1
2 5
2 4
3 8
10 3
9 7
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2);
a
9
2
EXPLAIN
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 10 func,func 2 Using where
3 DERIVED t2 ALL NULL NULL NULL NULL 6
4 UNION t3 ALL NULL NULL NULL NULL 4
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
DROP VIEW v1,v2;
DROP TABLE t1,t2,t3;
mysql-test/t/derived_view.test
View file @
cfc78964
...
@@ -616,7 +616,7 @@ DROP VIEW v1;
...
@@ -616,7 +616,7 @@ DROP VIEW v1;
DROP
TABLE
t1
,
t2
,
t3
;
DROP
TABLE
t1
,
t2
,
t3
;
--
echo
#
--
echo
#
--
echo
# LP bug #809179
--
echo
# LP bug #809179
: right join over a derived table / view
--
echo
#
--
echo
#
CREATE
TABLE
t1
(
a
int
,
b
int
);
CREATE
TABLE
t1
(
a
int
,
b
int
);
...
@@ -668,3 +668,32 @@ INSERT INTO v3(a) VALUES (1);
...
@@ -668,3 +668,32 @@ INSERT INTO v3(a) VALUES (1);
DROP
VIEW
v1
,
v2
,
v3
;
DROP
VIEW
v1
,
v2
,
v3
;
DROP
TABLE
t1
,
t2
,
t3
;
DROP
TABLE
t1
,
t2
,
t3
;
--
echo
#
--
echo
# LP bug #793448: materialized view accessed by two-component key
--
echo
#
CREATE
TABLE
t1
(
a
int
,
b
int
);
INSERT
INTO
t1
VALUES
(
9
,
3
),
(
2
,
5
);
CREATE
TABLE
t2
(
a
int
,
b
int
);
INSERT
INTO
t2
VALUES
(
9
,
3
),
(
3
,
7
),
(
9
,
1
),
(
2
,
5
),
(
2
,
4
),
(
3
,
8
);
CREATE
TABLE
t3
(
a
int
,
b
int
);
INSERT
INTO
t3
VALUES
(
10
,
3
),
(
9
,
7
),
(
9
,
1
),
(
2
,
4
);
CREATE
VIEW
v1
(
a
,
b
)
AS
SELECT
a
,
MAX
(
b
)
FROM
t2
GROUP
BY
a
;
CREATE
VIEW
v2
(
a
,
b
)
AS
SELECT
a
,
b
FROM
t2
UNION
SELECT
a
,
b
FROM
t3
;
SELECT
*
FROM
v1
;
SELECT
a
FROM
t1
WHERE
(
a
,
b
)
IN
(
SELECT
*
FROM
v1
);
EXPLAIN
SELECT
a
FROM
t1
WHERE
(
a
,
b
)
IN
(
SELECT
*
FROM
v1
);
SELECT
*
FROM
v2
;
SELECT
a
FROM
t1
WHERE
(
a
,
b
)
IN
(
SELECT
*
FROM
v2
);
EXPLAIN
SELECT
a
FROM
t1
WHERE
(
a
,
b
)
IN
(
SELECT
*
FROM
v2
);
DROP
VIEW
v1
,
v2
;
DROP
TABLE
t1
,
t2
,
t3
;
sql/sql_select.cc
View file @
cfc78964
...
@@ -8332,6 +8332,7 @@ uint get_next_field_for_derived_key(uchar *arg)
...
@@ -8332,6 +8332,7 @@ uint get_next_field_for_derived_key(uchar *arg)
keyuse
->
keypart
=
keypart
;
keyuse
->
keypart
=
keypart
;
if
(
keyuse
->
key
!=
key
)
if
(
keyuse
->
key
!=
key
)
keyuse
=
0
;
keyuse
=
0
;
*
((
KEYUSE
**
)
arg
)
=
keyuse
;
return
fldno
;
return
fldno
;
}
}
...
...
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