1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-30333 Wrong result with not_null_range_scan and LEFT JOIN with empty table

There was a bug in JOIN::make_notnull_conds_for_range_scans() when
clearing TABLE->tmp_set, which was used to mark fields that could not be
null.

This function was only used if 'not_null_range_scan=on' is set.

The effect was that tmp_set contained a 'random value' and this caused
the optimizer to think that some fields could not be null.
FLUSH TABLES clears tmp_set and because of this things worked temporarily.

Fixed by clearing tmp_set properly.
This commit is contained in:
Monty
2023-02-15 13:56:33 +02:00
parent 690fcfbd29
commit 192427e37d
3 changed files with 95 additions and 5 deletions

View File

@ -29683,7 +29683,6 @@ void JOIN::make_notnull_conds_for_range_scans()
{
DBUG_ENTER("JOIN::make_notnull_conds_for_range_scans");
if (impossible_where ||
!optimizer_flag(thd, OPTIMIZER_SWITCH_NOT_NULL_RANGE_SCAN))
{
@ -29769,7 +29768,6 @@ bool build_notnull_conds_for_range_scans(JOIN *join, Item *cond,
table_map allowed)
{
THD *thd= join->thd;
DBUG_ENTER("build_notnull_conds_for_range_scans");
for (JOIN_TAB *s= join->join_tab;
@ -29777,13 +29775,13 @@ bool build_notnull_conds_for_range_scans(JOIN *join, Item *cond,
{
/* Clear all needed bitmaps to mark found fields */
if ((allowed & s->table->map) &&
!(s->table->map && join->const_table_map))
!(s->table->map & join->const_table_map))
bitmap_clear_all(&s->table->tmp_set);
}
/*
Find all null-rejected fields assuming that cond is null-rejected and
only formulas over tables from 'allowed' are to be taken into account
only formulas over tables from 'allowed' are to be taken into account
*/
if (cond->find_not_null_fields(allowed))
DBUG_RETURN(true);