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
ee67d30b
Commit
ee67d30b
authored
Jan 19, 2007
by
igor@olga.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug25580
parents
f346abb5
3c814f22
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
3 deletions
+81
-3
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+33
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+34
-0
sql/mysql_priv.h
sql/mysql_priv.h
+4
-1
sql/sql_lex.cc
sql/sql_lex.cc
+10
-2
No files found.
mysql-test/r/subselect.result
View file @
ee67d30b
...
@@ -3605,3 +3605,36 @@ FROM t1) t;
...
@@ -3605,3 +3605,36 @@ FROM t1) t;
COUNT(*)
COUNT(*)
3000
3000
DROP TABLE t1,t2;
DROP TABLE t1,t2;
CREATE TABLE t1 (id char(4) PRIMARY KEY, c int);
CREATE TABLE t2 (c int);
INSERT INTO t1 VALUES ('aa', 1);
INSERT INTO t2 VALUES (1);
SELECT * FROM t1
WHERE EXISTS (SELECT c FROM t2 WHERE c=1
UNION
SELECT c from t2 WHERE c=t1.c);
id c
aa 1
INSERT INTO t1 VALUES ('bb', 2), ('cc', 3), ('dd',1);
SELECT * FROM t1
WHERE EXISTS (SELECT c FROM t2 WHERE c=1
UNION
SELECT c from t2 WHERE c=t1.c);
id c
aa 1
bb 2
cc 3
dd 1
INSERT INTO t2 VALUES (2);
CREATE TABLE t3 (c int);
INSERT INTO t3 VALUES (1);
SELECT * FROM t1
WHERE EXISTS (SELECT t2.c FROM t2 JOIN t3 ON t2.c=t3.c WHERE t2.c=1
UNION
SELECT c from t2 WHERE c=t1.c);
id c
aa 1
bb 2
cc 3
dd 1
DROP TABLE t1,t2,t3;
mysql-test/t/subselect.test
View file @
ee67d30b
...
@@ -2508,3 +2508,37 @@ SELECT SQL_NO_CACHE COUNT(*)
...
@@ -2508,3 +2508,37 @@ SELECT SQL_NO_CACHE COUNT(*)
FROM
t1
)
t
;
FROM
t1
)
t
;
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
#
# Bug #25219: EXIST subquery with UNION over a mix of
# correlated and uncorrelated selects
#
CREATE
TABLE
t1
(
id
char
(
4
)
PRIMARY
KEY
,
c
int
);
CREATE
TABLE
t2
(
c
int
);
INSERT
INTO
t1
VALUES
(
'aa'
,
1
);
INSERT
INTO
t2
VALUES
(
1
);
SELECT
*
FROM
t1
WHERE
EXISTS
(
SELECT
c
FROM
t2
WHERE
c
=
1
UNION
SELECT
c
from
t2
WHERE
c
=
t1
.
c
);
INSERT
INTO
t1
VALUES
(
'bb'
,
2
),
(
'cc'
,
3
),
(
'dd'
,
1
);
SELECT
*
FROM
t1
WHERE
EXISTS
(
SELECT
c
FROM
t2
WHERE
c
=
1
UNION
SELECT
c
from
t2
WHERE
c
=
t1
.
c
);
INSERT
INTO
t2
VALUES
(
2
);
CREATE
TABLE
t3
(
c
int
);
INSERT
INTO
t3
VALUES
(
1
);
SELECT
*
FROM
t1
WHERE
EXISTS
(
SELECT
t2
.
c
FROM
t2
JOIN
t3
ON
t2
.
c
=
t3
.
c
WHERE
t2
.
c
=
1
UNION
SELECT
c
from
t2
WHERE
c
=
t1
.
c
);
DROP
TABLE
t1
,
t2
,
t3
;
sql/mysql_priv.h
View file @
ee67d30b
...
@@ -410,7 +410,10 @@ MY_LOCALE *my_locale_by_name(const char *name);
...
@@ -410,7 +410,10 @@ MY_LOCALE *my_locale_by_name(const char *name);
#define UNCACHEABLE_EXPLAIN 8
#define UNCACHEABLE_EXPLAIN 8
/* Don't evaluate subqueries in prepare even if they're not correlated */
/* Don't evaluate subqueries in prepare even if they're not correlated */
#define UNCACHEABLE_PREPARE 16
#define UNCACHEABLE_PREPARE 16
/* Used to chack GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
#define UNCACHEABLE_UNITED 32
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
#define UNDEF_POS (-1)
#define UNDEF_POS (-1)
#ifdef EXTRA_DEBUG
#ifdef EXTRA_DEBUG
/*
/*
...
...
sql/sql_lex.cc
View file @
ee67d30b
...
@@ -1371,9 +1371,17 @@ void st_select_lex::mark_as_dependent(SELECT_LEX *last)
...
@@ -1371,9 +1371,17 @@ void st_select_lex::mark_as_dependent(SELECT_LEX *last)
if
(
!
(
s
->
uncacheable
&
UNCACHEABLE_DEPENDENT
))
if
(
!
(
s
->
uncacheable
&
UNCACHEABLE_DEPENDENT
))
{
{
// Select is dependent of outer select
// Select is dependent of outer select
s
->
uncacheable
|=
UNCACHEABLE_DEPENDENT
;
s
->
uncacheable
=
(
s
->
uncacheable
&
~
UNCACHEABLE_UNITED
)
|
UNCACHEABLE_DEPENDENT
;
SELECT_LEX_UNIT
*
munit
=
s
->
master_unit
();
SELECT_LEX_UNIT
*
munit
=
s
->
master_unit
();
munit
->
uncacheable
|=
UNCACHEABLE_DEPENDENT
;
munit
->
uncacheable
=
(
munit
->
uncacheable
&
~
UNCACHEABLE_UNITED
)
|
UNCACHEABLE_DEPENDENT
;
for
(
SELECT_LEX
*
sl
=
munit
->
first_select
();
sl
;
sl
=
sl
->
next_select
())
{
if
(
sl
!=
s
&&
!
(
sl
->
uncacheable
&
(
UNCACHEABLE_DEPENDENT
|
UNCACHEABLE_UNITED
)))
sl
->
uncacheable
|=
UNCACHEABLE_UNITED
;
}
}
}
is_correlated
=
TRUE
;
is_correlated
=
TRUE
;
this
->
master_unit
()
->
item
->
is_correlated
=
TRUE
;
this
->
master_unit
()
->
item
->
is_correlated
=
TRUE
;
...
...
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