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
816940f6
Commit
816940f6
authored
Dec 10, 2010
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge the fix for LP BUG#682683.
parents
bcc5d8f2
c8413dba
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
7 deletions
+111
-7
mysql-test/r/subselect4.result
mysql-test/r/subselect4.result
+40
-0
mysql-test/t/subselect4.test
mysql-test/t/subselect4.test
+30
-0
sql/sql_select.cc
sql/sql_select.cc
+32
-6
sql/sql_select.h
sql/sql_select.h
+9
-1
No files found.
mysql-test/r/subselect4.result
View file @
816940f6
...
...
@@ -605,6 +605,46 @@ COUNT(t2.f3) f9
0 NULL
drop table t1,t2;
#
# LP BUG#682683 Crash in create_tmp_table called from
# JOIN::init_execution
#
CREATE TABLE t2 (f1 int) ;
INSERT INTO t2 VALUES (1),(2);
CREATE TABLE t1 (f1 int) ;
EXPLAIN
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
2 SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
field1
NULL
EXPLAIN
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
2 SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
field1
NULL
NULL
INSERT INTO t1 VALUES (1),(2);
EXPLAIN
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
ERROR 21000: Subquery returns more than 1 row
EXPLAIN
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
ERROR 21000: Subquery returns more than 1 row
drop table t1,t2;
#
# LP BUG#680943 Assertion `!table || (!table->read_set ||
# bitmap_is_set(table->read_set, field_index))' failed with subquery
#
...
...
mysql-test/t/subselect4.test
View file @
816940f6
...
...
@@ -558,6 +558,36 @@ ORDER BY f9;
drop
table
t1
,
t2
;
--
echo
#
--
echo
# LP BUG#682683 Crash in create_tmp_table called from
--
echo
# JOIN::init_execution
--
echo
#
CREATE
TABLE
t2
(
f1
int
)
;
INSERT
INTO
t2
VALUES
(
1
),(
2
);
CREATE
TABLE
t1
(
f1
int
)
;
EXPLAIN
SELECT
(
SELECT
f1
FROM
t1
)
AS
field1
FROM
t2
GROUP
BY
field1
;
SELECT
(
SELECT
f1
FROM
t1
)
AS
field1
FROM
t2
GROUP
BY
field1
;
EXPLAIN
SELECT
(
SELECT
f1
FROM
t1
)
AS
field1
FROM
t2
ORDER
BY
field1
;
SELECT
(
SELECT
f1
FROM
t1
)
AS
field1
FROM
t2
ORDER
BY
field1
;
INSERT
INTO
t1
VALUES
(
1
),(
2
);
EXPLAIN
SELECT
(
SELECT
f1
FROM
t1
)
AS
field1
FROM
t2
GROUP
BY
field1
;
--
error
ER_SUBQUERY_NO_1_ROW
SELECT
(
SELECT
f1
FROM
t1
)
AS
field1
FROM
t2
GROUP
BY
field1
;
EXPLAIN
SELECT
(
SELECT
f1
FROM
t1
)
AS
field1
FROM
t2
ORDER
BY
field1
;
--
error
ER_SUBQUERY_NO_1_ROW
SELECT
(
SELECT
f1
FROM
t1
)
AS
field1
FROM
t2
ORDER
BY
field1
;
drop
table
t1
,
t2
;
--
echo
#
--
echo
# LP BUG#680943 Assertion `!table || (!table->read_set ||
--
echo
# bitmap_is_set(table->read_set, field_index))' failed with subquery
...
...
sql/sql_select.cc
View file @
816940f6
...
...
@@ -1402,6 +1402,7 @@ JOIN::optimize()
/**
Create and initialize objects neeed for the execution of a query plan.
Evaluate constant expressions not evaluated during optimization.
*/
int
JOIN
::
init_execution
()
...
...
@@ -1409,6 +1410,7 @@ int JOIN::init_execution()
DBUG_ENTER
(
"JOIN::init_execution"
);
DBUG_ASSERT
(
optimized
);
DBUG_ASSERT
(
!
(
select_options
&
SELECT_DESCRIBE
));
initialized
=
true
;
/* Create a tmp table if distinct or if the sort is too complicated */
...
...
@@ -1839,6 +1841,27 @@ JOIN::exec()
DBUG_VOID_RETURN
;
}
/*
Evaluate all constant expressions with subqueries in the ORDER/GROUP clauses
to make sure that all subqueries return a single row. The evaluation itself
will trigger an error if that is not the case.
*/
if
(
exec_const_order_group_cond
.
elements
&&
!
(
select_options
&
SELECT_DESCRIBE
))
{
List_iterator_fast
<
Item
>
const_item_it
(
exec_const_order_group_cond
);
Item
*
cur_const_item
;
while
((
cur_const_item
=
const_item_it
++
))
{
cur_const_item
->
val_str
(
&
cur_const_item
->
str_value
);
if
(
thd
->
is_error
())
{
error
=
thd
->
is_error
();
DBUG_VOID_RETURN
;
}
}
}
if
((
this
->
select_lex
->
options
&
OPTION_SCHEMA_TABLE
)
&&
get_schema_tables_result
(
this
,
PROCESSED_BY_JOIN_EXEC
))
DBUG_VOID_RETURN
;
...
...
@@ -8295,13 +8318,16 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
(
join
->
tables
>
1
&&
join
->
rollup
.
state
==
ROLLUP
::
STATE_INITED
&&
join
->
outer_join
))
*
simple_order
=
0
;
// Must do a temp table to sort
else
if
(
!
(
order_tables
&
not_const_tables
)
&&
!
order
->
item
[
0
]
->
with_subselect
)
else
if
(
!
(
order_tables
&
not_const_tables
))
{
if
(
order
->
item
[
0
]
->
with_subselect
)
{
/*
Skip constant expressions in the ORDER/GROUP clause, except when there
is a subquery in the expression
.
Delay the evaluation of constant ORDER and/or GROUP expressions that
contain subqueries until the execution phase
.
*/
join
->
exec_const_order_group_cond
.
push_back
(
order
->
item
[
0
]);
}
DBUG_PRINT
(
"info"
,(
"removing: %s"
,
order
->
item
[
0
]
->
full_name
()));
continue
;
}
...
...
sql/sql_select.h
View file @
816940f6
...
...
@@ -1599,6 +1599,13 @@ class JOIN :public Sql_alloc
evaluated at optimization time.
*/
Item
*
exec_const_cond
;
/*
Constant ORDER and/or GROUP expressions that contain subqueries. Such
expressions need to evaluated to verify that the subquery indeed
returns a single row. The evaluation of such expressions is delayed
until query execution.
*/
List
<
Item
>
exec_const_order_group_cond
;
SQL_SELECT
*
select
;
///<created in optimisation phase
JOIN_TAB
*
return_tab
;
///<used only for outer joins
Item
**
ref_pointer_array
;
///<used pointer reference for this select
...
...
@@ -1762,7 +1769,8 @@ class JOIN :public Sql_alloc
bool
send_row_on_empty_set
()
{
return
(
do_send_rows
&&
tmp_table_param
.
sum_func_count
!=
0
&&
!
group_list
&&
having_value
!=
Item
::
COND_FALSE
);
!
(
group_list
||
group_optimized_away
)
&&
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