Skip to content

Commit bd0dc40

Browse files
committed
When replacing WHERE f with WHERE f IS TRUE mark it AT_TOP_LEVEL
fixes innodb_fts.fulltext_misc failures after MDEV-37653 also remove redundant `if ($3)` - it can never be NULL and fix a function comment.
1 parent 76d257e commit bd0dc40

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

sql/sql_parse.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8921,8 +8921,8 @@ push_new_name_resolution_context(THD *thd,
89218921

89228922

89238923
/**
8924-
Fix condition which contains only field (f turns to f <> 0 )
8925-
or only contains the function NOT field (not f turns to f == 0)
8924+
Fix condition which contains only field (f turns to f IS TRUE )
8925+
or only contains the function NOT field (not f turns to f IS FALSE)
89268926
89278927
@param cond The condition to fix
89288928
@@ -8936,7 +8936,8 @@ Item *normalize_cond(THD *thd, Item *cond)
89368936
Item::Type type= cond->type();
89378937
if (type == Item::FIELD_ITEM || type == Item::REF_ITEM)
89388938
{
8939-
item_base_t is_cond_flag= cond->base_flags & item_base_t::IS_COND;
8939+
item_base_t is_cond_flag= cond->base_flags &
8940+
(item_base_t::IS_COND | item_base_t::AT_TOP_LEVEL);
89408941
cond->base_flags&= ~item_base_t::IS_COND;
89418942
cond= new (thd->mem_root) Item_func_istrue(thd, cond);
89428943
if (cond)

sql/sql_yacc.yy

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12457,11 +12457,9 @@ opt_where_clause:
1245712457
}
1245812458
search_condition
1245912459
{
12460-
SELECT_LEX *select= Select;
12461-
select->where= normalize_cond(thd, $3);
12462-
select->parsing_place= NO_MATTER;
12463-
if ($3)
12464-
$3->top_level_item();
12460+
$3->top_level_item();
12461+
Select->where= normalize_cond(thd, $3);
12462+
Select->parsing_place= NO_MATTER;
1246512463
}
1246612464
;
1246712465

0 commit comments

Comments
 (0)