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
69027708
Commit
69027708
authored
Mar 30, 2011
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge the fix for LP BUG#613029.
parents
3273ce6a
7999f40a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
2 deletions
+118
-2
mysql-test/r/subselect4.result
mysql-test/r/subselect4.result
+52
-0
mysql-test/t/subselect4.test
mysql-test/t/subselect4.test
+57
-0
sql/sql_select.cc
sql/sql_select.cc
+7
-0
sql/sql_select.h
sql/sql_select.h
+2
-2
No files found.
mysql-test/r/subselect4.result
View file @
69027708
...
...
@@ -1133,3 +1133,55 @@ SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM
f1 f2
set @@optimizer_switch=@save_optimizer_switch;
drop table t1,t2;
#
# LP BUG#613029 Wrong result with materialization and semijoin, and
# valgrind warnings in Protocol::net_store_data with materialization
# for implicit grouping
#
CREATE TABLE t1 (
pk int(11) NOT NULL AUTO_INCREMENT,
f2 int(11) NOT NULL,
f3 varchar(1) NOT NULL,
PRIMARY KEY (pk),
KEY f2 (f2));
INSERT INTO t1 VALUES (1,9,'x');
INSERT INTO t1 VALUES (2,5,'g');
CREATE TABLE t2 (
pk int(11) NOT NULL AUTO_INCREMENT,
f2 int(11) NOT NULL,
f3 varchar(1) NOT NULL,
PRIMARY KEY (pk),
KEY f2 (f2));
INSERT INTO t2 VALUES (1,7,'p');
set @save_optimizer_switch=@@optimizer_switch;
set @@optimizer_switch='materialization=off,semijoin=off';
EXPLAIN
SELECT t1.f3, MAX(t1.f2)
FROM t1, t2
WHERE (t2.pk = t1.pk) AND t2.pk IN (SELECT f2 FROM t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 DEPENDENT SUBQUERY t1 index_subquery f2 f2 4 func 2 Using index
SELECT t1.f3, MAX(t1.f2)
FROM t1, t2
WHERE (t2.pk = t1.pk) AND t2.pk IN (SELECT f2 FROM t1);
f3 MAX(t1.f2)
NULL NULL
set @@optimizer_switch='materialization=on,semijoin=off';
EXPLAIN
SELECT t1.f3, MAX(t1.f2)
FROM t1, t2
WHERE (t2.pk = t1.pk) AND t2.pk IN (SELECT f2 FROM t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system PRIMARY NULL NULL NULL 1
1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1
2 SUBQUERY t1 index NULL f2 4 NULL 2 Using index
SELECT t1.f3, MAX(t1.f2)
FROM t1, t2
WHERE (t2.pk = t1.pk) AND t2.pk IN (SELECT f2 FROM t1);
f3 MAX(t1.f2)
NULL NULL
TODO: add a test case for semijoin when the wrong result is fixed
set @@optimizer_switch='materialization=off,semijoin=on';
set @@optimizer_switch=@save_optimizer_switch;
drop table t1, t2;
mysql-test/t/subselect4.test
View file @
69027708
...
...
@@ -906,3 +906,60 @@ SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM
set
@@
optimizer_switch
=@
save_optimizer_switch
;
drop
table
t1
,
t2
;
--
echo
#
--
echo
# LP BUG#613029 Wrong result with materialization and semijoin, and
--
echo
# valgrind warnings in Protocol::net_store_data with materialization
--
echo
# for implicit grouping
--
echo
#
CREATE
TABLE
t1
(
pk
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
f2
int
(
11
)
NOT
NULL
,
f3
varchar
(
1
)
NOT
NULL
,
PRIMARY
KEY
(
pk
),
KEY
f2
(
f2
));
INSERT
INTO
t1
VALUES
(
1
,
9
,
'x'
);
INSERT
INTO
t1
VALUES
(
2
,
5
,
'g'
);
CREATE
TABLE
t2
(
pk
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
f2
int
(
11
)
NOT
NULL
,
f3
varchar
(
1
)
NOT
NULL
,
PRIMARY
KEY
(
pk
),
KEY
f2
(
f2
));
INSERT
INTO
t2
VALUES
(
1
,
7
,
'p'
);
set
@
save_optimizer_switch
=@@
optimizer_switch
;
set
@@
optimizer_switch
=
'materialization=off,semijoin=off'
;
EXPLAIN
SELECT
t1
.
f3
,
MAX
(
t1
.
f2
)
FROM
t1
,
t2
WHERE
(
t2
.
pk
=
t1
.
pk
)
AND
t2
.
pk
IN
(
SELECT
f2
FROM
t1
);
SELECT
t1
.
f3
,
MAX
(
t1
.
f2
)
FROM
t1
,
t2
WHERE
(
t2
.
pk
=
t1
.
pk
)
AND
t2
.
pk
IN
(
SELECT
f2
FROM
t1
);
set
@@
optimizer_switch
=
'materialization=on,semijoin=off'
;
EXPLAIN
SELECT
t1
.
f3
,
MAX
(
t1
.
f2
)
FROM
t1
,
t2
WHERE
(
t2
.
pk
=
t1
.
pk
)
AND
t2
.
pk
IN
(
SELECT
f2
FROM
t1
);
SELECT
t1
.
f3
,
MAX
(
t1
.
f2
)
FROM
t1
,
t2
WHERE
(
t2
.
pk
=
t1
.
pk
)
AND
t2
.
pk
IN
(
SELECT
f2
FROM
t1
);
--
echo
TODO
:
add
a
test
case
for
semijoin
when
the
wrong
result
is
fixed
--
echo
set
@@
optimizer_switch
=
'materialization=off,semijoin=on'
;
set
@@
optimizer_switch
=@
save_optimizer_switch
;
drop
table
t1
,
t2
;
sql/sql_select.cc
View file @
69027708
...
...
@@ -13458,6 +13458,13 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
{
List
<
Item
>
*
columns_list
=
(
procedure
?
&
join
->
procedure_fields_list
:
fields
);
/*
With implicit grouping all fields of special row produced for an
empty result are NULL. See return_zero_rows() for the same behavior.
*/
for
(
TABLE_LIST
*
table
=
join
->
select_lex
->
leaf_tables
;
table
;
table
=
table
->
next_leaf
)
mark_as_null_row
(
table
->
table
);
rc
=
join
->
result
->
send_data
(
*
columns_list
);
}
}
...
...
sql/sql_select.h
View file @
69027708
...
...
@@ -964,8 +964,8 @@ class JOIN :public Sql_alloc
bool
init_save_join_tab
();
bool
send_row_on_empty_set
()
{
return
(
do_send_rows
&&
tmp_table_param
.
sum_func_count
!=
0
&&
!
group_list
&&
having_value
!=
Item
::
COND_FALSE
);
return
(
do_send_rows
&&
implicit_grouping
&&
having_value
!=
Item
::
COND_FALSE
);
}
bool
change_result
(
select_result
*
result
);
bool
is_top_level_join
()
const
...
...
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