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
751e45ad
Commit
751e45ad
authored
Oct 11, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0
into moonbone.local:/work/13327-bug-5.0-mysql
parents
58e8167e
1e13b2de
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
0 deletions
+57
-0
mysql-test/r/view.result
mysql-test/r/view.result
+22
-0
mysql-test/t/view.test
mysql-test/t/view.test
+20
-0
sql/sql_select.cc
sql/sql_select.cc
+15
-0
No files found.
mysql-test/r/view.result
View file @
751e45ad
...
@@ -2298,3 +2298,25 @@ a
...
@@ -2298,3 +2298,25 @@ a
3
3
DROP VIEW v1;
DROP VIEW v1;
DROP TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, INDEX(a,b));
CREATE TABLE t2 LIKE t1;
CREATE TABLE t3 (a INT);
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
INSERT INTO t2 VALUES (1,1),(2,2),(3,3);
INSERT INTO t3 VALUES (1),(2),(3);
CREATE VIEW v1 AS SELECT t1.* FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b;
CREATE VIEW v2 AS SELECT t3.* FROM t1,t3 WHERE t1.a=t3.a;
EXPLAIN SELECT t1.* FROM t1 JOIN t2 WHERE t1.a=t2.a AND t1.b=t2.b AND t1.a=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 5 const 1 Using where; Using index
1 SIMPLE t2 ref a a 10 const,test.t1.b 2 Using where; Using index
EXPLAIN SELECT * FROM v1 WHERE a=1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
1 PRIMARY t2 ref a a 10 const,test.t1.b 2 Using where; Using index
EXPLAIN SELECT * FROM v2 WHERE a=1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
DROP VIEW v1,v2;
DROP TABLE t1,t2,t3;
mysql-test/t/view.test
View file @
751e45ad
...
@@ -2167,3 +2167,23 @@ SELECT v_1.a FROM v1 AS v_1 GROUP BY v_1.a HAVING v_1.a IN (1,2,3);
...
@@ -2167,3 +2167,23 @@ SELECT v_1.a FROM v1 AS v_1 GROUP BY v_1.a HAVING v_1.a IN (1,2,3);
DROP
VIEW
v1
;
DROP
VIEW
v1
;
DROP
TABLE
t1
;
DROP
TABLE
t1
;
#
# Bug #13327 view wasn't using index for const condition
#
CREATE
TABLE
t1
(
a
INT
,
b
INT
,
INDEX
(
a
,
b
));
CREATE
TABLE
t2
LIKE
t1
;
CREATE
TABLE
t3
(
a
INT
);
INSERT
INTO
t1
VALUES
(
1
,
1
),(
2
,
2
),(
3
,
3
);
INSERT
INTO
t2
VALUES
(
1
,
1
),(
2
,
2
),(
3
,
3
);
INSERT
INTO
t3
VALUES
(
1
),(
2
),(
3
);
CREATE
VIEW
v1
AS
SELECT
t1
.*
FROM
t1
,
t2
WHERE
t1
.
a
=
t2
.
a
AND
t1
.
b
=
t2
.
b
;
CREATE
VIEW
v2
AS
SELECT
t3
.*
FROM
t1
,
t3
WHERE
t1
.
a
=
t3
.
a
;
EXPLAIN
SELECT
t1
.*
FROM
t1
JOIN
t2
WHERE
t1
.
a
=
t2
.
a
AND
t1
.
b
=
t2
.
b
AND
t1
.
a
=
1
;
EXPLAIN
SELECT
*
FROM
v1
WHERE
a
=
1
;
EXPLAIN
SELECT
*
FROM
v2
WHERE
a
=
1
;
DROP
VIEW
v1
,
v2
;
DROP
TABLE
t1
,
t2
,
t3
;
sql/sql_select.cc
View file @
751e45ad
...
@@ -6254,6 +6254,21 @@ static bool check_equality(Item *item, COND_EQUAL *cond_equal)
...
@@ -6254,6 +6254,21 @@ static bool check_equality(Item *item, COND_EQUAL *cond_equal)
{
{
Item
*
left_item
=
((
Item_func
*
)
item
)
->
arguments
()[
0
];
Item
*
left_item
=
((
Item_func
*
)
item
)
->
arguments
()[
0
];
Item
*
right_item
=
((
Item_func
*
)
item
)
->
arguments
()[
1
];
Item
*
right_item
=
((
Item_func
*
)
item
)
->
arguments
()[
1
];
if
(
left_item
->
type
()
==
Item
::
REF_ITEM
&&
((
Item_ref
*
)
left_item
)
->
ref_type
()
==
Item_ref
::
VIEW_REF
)
{
if
(((
Item_ref
*
)
left_item
)
->
depended_from
)
return
FALSE
;
left_item
=
left_item
->
real_item
();
}
if
(
right_item
->
type
()
==
Item
::
REF_ITEM
&&
((
Item_ref
*
)
right_item
)
->
ref_type
()
==
Item_ref
::
VIEW_REF
)
{
if
(((
Item_ref
*
)
right_item
)
->
depended_from
)
return
FALSE
;
right_item
=
right_item
->
real_item
();
}
if
(
left_item
->
type
()
==
Item
::
FIELD_ITEM
&&
if
(
left_item
->
type
()
==
Item
::
FIELD_ITEM
&&
right_item
->
type
()
==
Item
::
FIELD_ITEM
&&
right_item
->
type
()
==
Item
::
FIELD_ITEM
&&
!
((
Item_field
*
)
left_item
)
->
depended_from
&&
!
((
Item_field
*
)
left_item
)
->
depended_from
&&
...
...
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