mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
MDEV-22830: SQL_CALC_FOUND_ROWS not working properly for single SELECT for DUAL
In case of SELECT without tables which returns either 0 or 1 rows, JOIN::exec_inner() did not check if the flag representing SQL_CALC_FOUND_ROWS is set or not and send_records was direclty assigned 0. So SELECT FOUND_ROWS() was giving 0 in the output. Now it checks if the flag is set, if it is set send_record=1 else 0. 1 is the number of rows that could have been sent to the client if the SELECT query had SQL_CALC_FOUND_ROWS. It is 0 when no rows were sent because the SELECT query did not have SQL_CALC_FOUND_ROWS.
This commit is contained in:
parent
e1045a768b
commit
443391236d
3 changed files with 13 additions and 1 deletions
|
@ -362,4 +362,9 @@ c1
|
|||
select found_rows();
|
||||
found_rows()
|
||||
5
|
||||
SELECT SQL_CALC_FOUND_ROWS 1 FROM DUAL WHERE 0;
|
||||
1
|
||||
SELECT FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
1
|
||||
drop table t1;
|
||||
|
|
|
@ -286,4 +286,11 @@ select * from t1 order by c1 limit 2,1;
|
|||
select found_rows();
|
||||
select sql_calc_found_rows * from t1 order by c1 limit 2,1;
|
||||
select found_rows();
|
||||
|
||||
#
|
||||
# MDEV-22830 SQL_CALC_FOUND_ROWS not working properly for single SELECT for DUAL
|
||||
#
|
||||
SELECT SQL_CALC_FOUND_ROWS 1 FROM DUAL WHERE 0;
|
||||
SELECT FOUND_ROWS();
|
||||
|
||||
drop table t1;
|
||||
|
|
|
@ -2647,7 +2647,7 @@ void JOIN::exec_inner()
|
|||
thd->get_sent_row_count());
|
||||
}
|
||||
else
|
||||
send_records= 0;
|
||||
send_records= (select_options & OPTION_FOUND_ROWS) ? 1 : 0;
|
||||
if (!error)
|
||||
{
|
||||
join_free(); // Unlock all cursors
|
||||
|
|
Loading…
Reference in a new issue