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
82239b3e
Commit
82239b3e
authored
May 12, 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/mysql-5.1-opt
parents
5fbb3c15
11d5f7ee
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
2 deletions
+67
-2
mysql-test/r/subselect3.result
mysql-test/r/subselect3.result
+31
-0
mysql-test/t/subselect3.test
mysql-test/t/subselect3.test
+25
-0
sql/item_subselect.cc
sql/item_subselect.cc
+4
-2
sql/sql_select.h
sql/sql_select.h
+7
-0
No files found.
mysql-test/r/subselect3.result
View file @
82239b3e
...
@@ -711,3 +711,34 @@ a
...
@@ -711,3 +711,34 @@ a
1
1
4
4
DROP TABLE t1,t2;
DROP TABLE t1,t2;
CREATE TABLE t1 (id int);
CREATE TABLE t2 (id int PRIMARY KEY);
CREATE TABLE t3 (id int PRIMARY KEY, name varchar(10));
INSERT INTO t1 VALUES (2), (NULL), (3), (1);
INSERT INTO t2 VALUES (234), (345), (457);
INSERT INTO t3 VALUES (222,'bbb'), (333,'ccc'), (111,'aaa');
EXPLAIN
SELECT * FROM t1
WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3
WHERE t3.name='xxx' AND t2.id=t3.id);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
2 DEPENDENT SUBQUERY t2 eq_ref PRIMARY PRIMARY 4 func 1 Using where; Using index; Full scan on NULL key
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 func 1 Using where; Full scan on NULL key
SELECT * FROM t1
WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3
WHERE t3.name='xxx' AND t2.id=t3.id);
id
2
NULL
3
1
SELECT (t1.id IN (SELECT t2.id FROM t2,t3
WHERE t3.name='xxx' AND t2.id=t3.id)) AS x
FROM t1;
x
0
0
0
0
DROP TABLE t1,t2,t3;
mysql-test/t/subselect3.test
View file @
82239b3e
...
@@ -546,3 +546,28 @@ SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1));
...
@@ -546,3 +546,28 @@ SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1));
SELECT
a
FROM
t1
,
t2
WHERE
a
=
b
AND
(
b
NOT
IN
(
SELECT
a
FROM
t1
WHERE
a
>
4
));
SELECT
a
FROM
t1
,
t2
WHERE
a
=
b
AND
(
b
NOT
IN
(
SELECT
a
FROM
t1
WHERE
a
>
4
));
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
#
# Bug #28375: crash for NOT IN subquery predicate when left operand becomes NULL
#
CREATE
TABLE
t1
(
id
int
);
CREATE
TABLE
t2
(
id
int
PRIMARY
KEY
);
CREATE
TABLE
t3
(
id
int
PRIMARY
KEY
,
name
varchar
(
10
));
INSERT
INTO
t1
VALUES
(
2
),
(
NULL
),
(
3
),
(
1
);
INSERT
INTO
t2
VALUES
(
234
),
(
345
),
(
457
);
INSERT
INTO
t3
VALUES
(
222
,
'bbb'
),
(
333
,
'ccc'
),
(
111
,
'aaa'
);
EXPLAIN
SELECT
*
FROM
t1
WHERE
t1
.
id
NOT
IN
(
SELECT
t2
.
id
FROM
t2
,
t3
WHERE
t3
.
name
=
'xxx'
AND
t2
.
id
=
t3
.
id
);
SELECT
*
FROM
t1
WHERE
t1
.
id
NOT
IN
(
SELECT
t2
.
id
FROM
t2
,
t3
WHERE
t3
.
name
=
'xxx'
AND
t2
.
id
=
t3
.
id
);
SELECT
(
t1
.
id
IN
(
SELECT
t2
.
id
FROM
t2
,
t3
WHERE
t3
.
name
=
'xxx'
AND
t2
.
id
=
t3
.
id
))
AS
x
FROM
t1
;
DROP
TABLE
t1
,
t2
,
t3
;
sql/item_subselect.cc
View file @
82239b3e
...
@@ -1872,6 +1872,8 @@ int subselect_single_select_engine::exec()
...
@@ -1872,6 +1872,8 @@ int subselect_single_select_engine::exec()
if
(
cond_guard
&&
!*
cond_guard
)
if
(
cond_guard
&&
!*
cond_guard
)
{
{
/* Change the access method to full table scan */
/* Change the access method to full table scan */
tab
->
save_read_first_record
=
tab
->
read_first_record
;
tab
->
save_read_record
=
tab
->
read_record
.
read_record
;
tab
->
read_first_record
=
init_read_record_seq
;
tab
->
read_first_record
=
init_read_record_seq
;
tab
->
read_record
.
record
=
tab
->
table
->
record
[
0
];
tab
->
read_record
.
record
=
tab
->
table
->
record
[
0
];
tab
->
read_record
.
thd
=
join
->
thd
;
tab
->
read_record
.
thd
=
join
->
thd
;
...
@@ -1892,8 +1894,8 @@ int subselect_single_select_engine::exec()
...
@@ -1892,8 +1894,8 @@ int subselect_single_select_engine::exec()
JOIN_TAB
*
tab
=
*
ptab
;
JOIN_TAB
*
tab
=
*
ptab
;
tab
->
read_record
.
record
=
0
;
tab
->
read_record
.
record
=
0
;
tab
->
read_record
.
ref_length
=
0
;
tab
->
read_record
.
ref_length
=
0
;
tab
->
read_first_record
=
join_read_always_key_or_null
;
tab
->
read_first_record
=
tab
->
save_read_first_record
;
tab
->
read_record
.
read_record
=
join_read_next_same_or_null
;
tab
->
read_record
.
read_record
=
tab
->
save_read_record
;
}
}
executed
=
1
;
executed
=
1
;
thd
->
where
=
save_where
;
thd
->
where
=
save_where
;
...
...
sql/sql_select.h
View file @
82239b3e
...
@@ -160,6 +160,13 @@ typedef struct st_join_table {
...
@@ -160,6 +160,13 @@ typedef struct st_join_table {
Read_record_func
read_first_record
;
Read_record_func
read_first_record
;
Next_select_func
next_select
;
Next_select_func
next_select
;
READ_RECORD
read_record
;
READ_RECORD
read_record
;
/*
Currently the following two fields are used only for a [NOT] IN subquery
if it is executed by an alternative full table scan when the left operand of
the subquery predicate is evaluated to NULL.
*/
Read_record_func
save_read_first_record
;
/* to save read_first_record */
int
(
*
save_read_record
)
(
READ_RECORD
*
);
/* to save read_record.read_record */
double
worst_seeks
;
double
worst_seeks
;
key_map
const_keys
;
/* Keys with constant part */
key_map
const_keys
;
/* Keys with constant part */
key_map
checked_keys
;
/* Keys checked in find_best */
key_map
checked_keys
;
/* Keys checked in find_best */
...
...
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