MDEV-35135 Assertion `!is_cond()' failed in Item_bool_func::val_int / do_select

Change val_int with val_bool when it is a condition.
This commit is contained in:
Oleksandr Byelkin 2024-10-14 09:36:17 +02:00
parent cd97caef84
commit a79c9b3812
7 changed files with 45 additions and 22 deletions

View file

@ -0,0 +1,10 @@
#
# MDEV-35135: Assertion `!is_cond()' failed in Item_bool_func::val_int /
# do_select
#
CREATE TABLE t (a INT) ENGINE=MyISAM;
INSERT INTO t VALUES (1);
SELECT VARIANCE(a) AS f1, VARIANCE(a) AS f2 FROM t WHERE ROWNUM() = 2 HAVING f1 > 1;
f1 f2
DROP TABLE t;
# End of 10.6 tests

View file

@ -0,0 +1,13 @@
--echo #
--echo # MDEV-35135: Assertion `!is_cond()' failed in Item_bool_func::val_int /
--echo # do_select
--echo #
CREATE TABLE t (a INT) ENGINE=MyISAM;
INSERT INTO t VALUES (1);
SELECT VARIANCE(a) AS f1, VARIANCE(a) AS f2 FROM t WHERE ROWNUM() = 2 HAVING f1 > 1;
# Cleanup
DROP TABLE t;
--echo # End of 10.6 tests

View file

@ -5984,7 +5984,7 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond,
List_iterator_fast<Item_equal> ei(*cond_equalities);
while ((mult_eq= ei++))
{
if (mult_eq->const_item() && !mult_eq->val_int())
if (mult_eq->const_item() && !mult_eq->val_bool())
is_simplified_cond= true;
else
{
@ -6074,7 +6074,7 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond,
List_iterator_fast<Item_equal> ei(new_cond_equal.current_level);
while ((mult_eq=ei++))
{
if (mult_eq->const_item() && !mult_eq->val_int())
if (mult_eq->const_item() && !mult_eq->val_bool())
is_simplified_cond= true;
else
{

View file

@ -809,7 +809,7 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
if (org_key_part_used != *key_part_used ||
(is_field_part &&
(between || eq_type || max_fl == less_fl) && !cond->val_int()))
(between || eq_type || max_fl == less_fl) && !cond->val_bool()))
{
/*
It's the first predicate for this part or a predicate of the
@ -859,7 +859,7 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
}
else if (eq_type)
{
if ((!is_null && !cond->val_int()) ||
if ((!is_null && !cond->val_bool()) ||
(is_null && !MY_TEST(part->field->is_null())))
DBUG_RETURN(FALSE); // Impossible test
}

View file

@ -203,7 +203,7 @@ int search_topics(THD *thd, TABLE *topics, struct st_find_field *find_fields,
while (!read_record_info.read_record())
{
if (!select->cond->val_int()) // Doesn't match like
if (!select->cond->val_bool()) // Doesn't match like
continue;
memorize_variant_topic(thd,topics,count,find_fields,
names,name,description,example);
@ -247,7 +247,7 @@ int search_keyword(THD *thd, TABLE *keywords,
while (!read_record_info.read_record() && count<2)
{
if (!select->cond->val_int()) // Dosn't match like
if (!select->cond->val_bool()) // Dosn't match like
continue;
*key_id= (int)find_fields[help_keyword_help_keyword_id].field->val_int();
@ -381,7 +381,7 @@ int search_categories(THD *thd, TABLE *categories,
DBUG_RETURN(0);
while (!read_record_info.read_record())
{
if (select && !select->cond->val_int())
if (select && !select->cond->val_bool())
continue;
String *lname= new (thd->mem_root) String;
get_field(thd->mem_root,pfname,lname);
@ -419,7 +419,7 @@ void get_all_items_for_category(THD *thd, TABLE *items, Field *pfname,
while (!read_record_info.read_record())
{
if (!select->cond->val_int())
if (!select->cond->val_bool())
continue;
String *name= new (thd->mem_root) String();
get_field(thd->mem_root,pfname,name);

View file

@ -4828,7 +4828,7 @@ bool JOIN_CACHE_BKAH::skip_index_tuple(range_id_t range_info)
next_rec_ref_ptr= get_next_rec_ref(next_rec_ref_ptr);
uchar *rec_ptr= next_rec_ref_ptr + rec_fields_offset;
get_record_by_pos(rec_ptr);
if (join_tab->cache_idx_cond->val_int())
if (join_tab->cache_idx_cond->val_bool())
DBUG_RETURN(FALSE);
} while(next_rec_ref_ptr != last_rec_ref_ptr);
DBUG_RETURN(TRUE);

View file

@ -17219,7 +17219,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels,
{
List<Item> eq_list;
Item_func_eq *eq_item= 0;
if (((Item *) item_equal)->const_item() && !item_equal->val_int())
if (((Item *) item_equal)->const_item() && !item_equal->val_bool())
return (Item*) &Item_false;
Item *item_const= item_equal->get_const();
Item_equal_fields_iterator it(*item_equal);
@ -17288,7 +17288,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels,
Item_func_eq *func= new (thd->mem_root) Item_func_eq(thd, item_const, upper_const);
func->set_cmp_func(thd);
func->quick_fix_field();
if (func->val_int())
if (func->val_bool())
item= 0;
}
else
@ -18745,7 +18745,7 @@ void propagate_new_equalities(THD *thd, Item *cond,
List_iterator<Item_equal> ei(*cond_equalities);
while ((equal_item= ei++))
{
if (equal_item->const_item() && !equal_item->val_int())
if (equal_item->const_item() && !equal_item->val_bool())
{
*is_simplifiable_cond= true;
return;
@ -18776,7 +18776,7 @@ void propagate_new_equalities(THD *thd, Item *cond,
{
equality->merge_with_check(thd, equal_item, true);
}
if (equality->const_item() && !equality->val_int())
if (equality->const_item() && !equality->val_bool())
*is_simplifiable_cond= true;
}
else
@ -18941,7 +18941,7 @@ Item_cond::remove_eq_conds(THD *thd, Item::cond_result *cond_value,
Item_equal *eq_item;
while ((eq_item= it++))
{
if (eq_item->const_item() && eq_item->val_int())
if (eq_item->const_item() && eq_item->val_bool())
it.remove();
}
cond_arg_list->append((List<Item> *) cond_equalities);
@ -19088,7 +19088,7 @@ Item_cond::remove_eq_conds(THD *thd, Item::cond_result *cond_value,
List_iterator_fast<Item_equal> ei(*cond_equalities);
while ((equality= ei++))
{
if (equality->const_item() && !equality->val_int())
if (equality->const_item() && !equality->val_bool())
{
*cond_value= Item::COND_FALSE;
return (COND*) 0;
@ -21810,7 +21810,7 @@ do_select(JOIN *join, Procedure *procedure)
*/
clear_tables(join, &cleared_tables);
}
if (!join->having || join->having->val_int())
if (!join->having || join->having->val_bool())
{
List<Item> *columns_list= (procedure ? &join->procedure_fields_list :
join->fields);
@ -22302,7 +22302,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
/* Set first_unmatched for the last inner table of this group */
join_tab->last_inner->first_unmatched= join_tab;
if (join_tab->on_precond && !join_tab->on_precond->val_int())
if (join_tab->on_precond && !join_tab->on_precond->val_bool())
rc= NESTED_LOOP_NO_MORE_ROWS;
}
join->thd->get_stmt_da()->reset_current_row_for_warning();
@ -22481,7 +22481,7 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab,
*/
if (tab->select_cond)
{
const longlong res= tab->select_cond->val_int();
const longlong res= tab->select_cond->val_bool();
if (join->thd->is_error())
DBUG_RETURN(NESTED_LOOP_ERROR);
@ -22620,7 +22620,7 @@ evaluate_null_complemented_join_record(JOIN *join, JOIN_TAB *join_tab)
mark_as_null_row(join_tab->table); // For group by without error
select_cond= join_tab->select_cond;
/* Check all attached conditions for inner table rows. */
if (select_cond && !select_cond->val_int())
if (select_cond && !select_cond->val_bool())
return NESTED_LOOP_OK;
}
join_tab--;
@ -22642,7 +22642,7 @@ evaluate_null_complemented_join_record(JOIN *join, JOIN_TAB *join_tab)
first_unmatched->found= 1;
for (JOIN_TAB *tab= first_unmatched; tab <= join_tab; tab++)
{
if (tab->select_cond && !tab->select_cond->val_int())
if (tab->select_cond && !tab->select_cond->val_bool())
{
join->return_tab= tab;
return NESTED_LOOP_OK;
@ -23738,7 +23738,7 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab, bool end_of_records)
int error=0;
if (join->procedure)
{
if (join->having && join->having->val_int() == 0)
if (join->having && !join->having->val_bool())
error= -1; // Didn't satisfy having
else
{
@ -28446,7 +28446,7 @@ int JOIN::rollup_write_data(uint idx, TMP_TABLE_PARAM *tmp_table_param_arg,
{
/* Get reference pointers to sum functions in place */
copy_ref_ptr_array(ref_ptrs, rollup.ref_pointer_arrays[i]);
if ((!having || having->val_int()))
if ((!having || having->val_bool()))
{
int write_error;
Item *item;