Fixes for OPTION_FOUND_ROWS in UNION's
This commit is contained in:
parent
0088e1c657
commit
a26847c275
@ -1046,6 +1046,8 @@ t1 CREATE TABLE `t1` (
|
|||||||
) TYPE=MyISAM CHARSET=latin1
|
) TYPE=MyISAM CHARSET=latin1
|
||||||
drop table t1;
|
drop table t1;
|
||||||
CREATE TABLE t1 SELECT (SELECT 1 as a UNION SELECT 1+1 limit 1,1) as a;
|
CREATE TABLE t1 SELECT (SELECT 1 as a UNION SELECT 1+1 limit 1,1) as a;
|
||||||
|
Warnings:
|
||||||
|
Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 1
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
|
@ -409,7 +409,7 @@ found_rows()
|
|||||||
SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 2,2;
|
SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 2,2;
|
||||||
a
|
a
|
||||||
3
|
3
|
||||||
4
|
5
|
||||||
select found_rows();
|
select found_rows();
|
||||||
found_rows()
|
found_rows()
|
||||||
6
|
6
|
||||||
@ -423,7 +423,7 @@ found_rows()
|
|||||||
5
|
5
|
||||||
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1;
|
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1;
|
||||||
a
|
a
|
||||||
5
|
3
|
||||||
(SELECT * FROM t1 ORDER by a) UNION ALL (SELECT * FROM t2 ORDER BY a) ORDER BY A desc LIMIT 4;
|
(SELECT * FROM t1 ORDER by a) UNION ALL (SELECT * FROM t2 ORDER BY a) ORDER BY A desc LIMIT 4;
|
||||||
a
|
a
|
||||||
5
|
5
|
||||||
|
@ -1729,7 +1729,7 @@ mysql_execute_command(THD *thd)
|
|||||||
if (unit->select_limit_cnt <
|
if (unit->select_limit_cnt <
|
||||||
(ha_rows) unit->global_parameters->select_limit)
|
(ha_rows) unit->global_parameters->select_limit)
|
||||||
unit->select_limit_cnt= HA_POS_ERROR; // no limit
|
unit->select_limit_cnt= HA_POS_ERROR; // no limit
|
||||||
if (unit->select_limit_cnt == HA_POS_ERROR)
|
if (unit->select_limit_cnt == HA_POS_ERROR && !select_lex->next_select())
|
||||||
select_lex->options&= ~OPTION_FOUND_ROWS;
|
select_lex->options&= ~OPTION_FOUND_ROWS;
|
||||||
|
|
||||||
if (!(res=open_and_lock_tables(thd,tables)))
|
if (!(res=open_and_lock_tables(thd,tables)))
|
||||||
|
@ -281,7 +281,7 @@ int st_select_lex_unit::exec()
|
|||||||
*/
|
*/
|
||||||
sl->options|= found_rows_for_union;
|
sl->options|= found_rows_for_union;
|
||||||
}
|
}
|
||||||
|
sl->join->select_options=sl->options;
|
||||||
/*
|
/*
|
||||||
As far as union share table space we should reassign table map,
|
As far as union share table space we should reassign table map,
|
||||||
which can be spoiled by 'prepare' of JOIN of other UNION parts
|
which can be spoiled by 'prepare' of JOIN of other UNION parts
|
||||||
@ -311,6 +311,7 @@ int st_select_lex_unit::exec()
|
|||||||
records_at_start= table->file->records;
|
records_at_start= table->file->records;
|
||||||
sl->join->exec();
|
sl->join->exec();
|
||||||
res= sl->join->error;
|
res= sl->join->error;
|
||||||
|
offset_limit_cnt= sl->offset_limit;
|
||||||
if (!res && union_result->flush())
|
if (!res && union_result->flush())
|
||||||
{
|
{
|
||||||
thd->lex.current_select= lex_select_save;
|
thd->lex.current_select= lex_select_save;
|
||||||
@ -332,7 +333,7 @@ int st_select_lex_unit::exec()
|
|||||||
We get this from the difference of between total number of possible
|
We get this from the difference of between total number of possible
|
||||||
rows and actual rows added to the temporary table.
|
rows and actual rows added to the temporary table.
|
||||||
*/
|
*/
|
||||||
add_rows+= (ha_rows) (thd->limit_found_rows - (ulonglong)
|
add_rows+= (ulonglong) (thd->limit_found_rows - (ulonglong)
|
||||||
((table->file->records - records_at_start)));
|
((table->file->records - records_at_start)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user