Skip to content

Commit a79c9b3

Browse files
committed
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.
1 parent cd97cae commit a79c9b3

File tree

7 files changed

+45
-22
lines changed

7 files changed

+45
-22
lines changed

mysql-test/main/type_bool.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# MDEV-35135: Assertion `!is_cond()' failed in Item_bool_func::val_int /
3+
# do_select
4+
#
5+
CREATE TABLE t (a INT) ENGINE=MyISAM;
6+
INSERT INTO t VALUES (1);
7+
SELECT VARIANCE(a) AS f1, VARIANCE(a) AS f2 FROM t WHERE ROWNUM() = 2 HAVING f1 > 1;
8+
f1 f2
9+
DROP TABLE t;
10+
# End of 10.6 tests

mysql-test/main/type_bool.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--echo #
2+
--echo # MDEV-35135: Assertion `!is_cond()' failed in Item_bool_func::val_int /
3+
--echo # do_select
4+
--echo #
5+
6+
CREATE TABLE t (a INT) ENGINE=MyISAM;
7+
INSERT INTO t VALUES (1);
8+
SELECT VARIANCE(a) AS f1, VARIANCE(a) AS f2 FROM t WHERE ROWNUM() = 2 HAVING f1 > 1;
9+
10+
# Cleanup
11+
DROP TABLE t;
12+
13+
--echo # End of 10.6 tests

sql/opt_subselect.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5984,7 +5984,7 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond,
59845984
List_iterator_fast<Item_equal> ei(*cond_equalities);
59855985
while ((mult_eq= ei++))
59865986
{
5987-
if (mult_eq->const_item() && !mult_eq->val_int())
5987+
if (mult_eq->const_item() && !mult_eq->val_bool())
59885988
is_simplified_cond= true;
59895989
else
59905990
{
@@ -6074,7 +6074,7 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond,
60746074
List_iterator_fast<Item_equal> ei(new_cond_equal.current_level);
60756075
while ((mult_eq=ei++))
60766076
{
6077-
if (mult_eq->const_item() && !mult_eq->val_int())
6077+
if (mult_eq->const_item() && !mult_eq->val_bool())
60786078
is_simplified_cond= true;
60796079
else
60806080
{

sql/opt_sum.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
809809

810810
if (org_key_part_used != *key_part_used ||
811811
(is_field_part &&
812-
(between || eq_type || max_fl == less_fl) && !cond->val_int()))
812+
(between || eq_type || max_fl == less_fl) && !cond->val_bool()))
813813
{
814814
/*
815815
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,
859859
}
860860
else if (eq_type)
861861
{
862-
if ((!is_null && !cond->val_int()) ||
862+
if ((!is_null && !cond->val_bool()) ||
863863
(is_null && !MY_TEST(part->field->is_null())))
864864
DBUG_RETURN(FALSE); // Impossible test
865865
}

sql/sql_help.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ int search_topics(THD *thd, TABLE *topics, struct st_find_field *find_fields,
203203

204204
while (!read_record_info.read_record())
205205
{
206-
if (!select->cond->val_int()) // Doesn't match like
206+
if (!select->cond->val_bool()) // Doesn't match like
207207
continue;
208208
memorize_variant_topic(thd,topics,count,find_fields,
209209
names,name,description,example);
@@ -247,7 +247,7 @@ int search_keyword(THD *thd, TABLE *keywords,
247247

248248
while (!read_record_info.read_record() && count<2)
249249
{
250-
if (!select->cond->val_int()) // Dosn't match like
250+
if (!select->cond->val_bool()) // Dosn't match like
251251
continue;
252252

253253
*key_id= (int)find_fields[help_keyword_help_keyword_id].field->val_int();
@@ -381,7 +381,7 @@ int search_categories(THD *thd, TABLE *categories,
381381
DBUG_RETURN(0);
382382
while (!read_record_info.read_record())
383383
{
384-
if (select && !select->cond->val_int())
384+
if (select && !select->cond->val_bool())
385385
continue;
386386
String *lname= new (thd->mem_root) String;
387387
get_field(thd->mem_root,pfname,lname);
@@ -419,7 +419,7 @@ void get_all_items_for_category(THD *thd, TABLE *items, Field *pfname,
419419

420420
while (!read_record_info.read_record())
421421
{
422-
if (!select->cond->val_int())
422+
if (!select->cond->val_bool())
423423
continue;
424424
String *name= new (thd->mem_root) String();
425425
get_field(thd->mem_root,pfname,name);

sql/sql_join_cache.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4828,7 +4828,7 @@ bool JOIN_CACHE_BKAH::skip_index_tuple(range_id_t range_info)
48284828
next_rec_ref_ptr= get_next_rec_ref(next_rec_ref_ptr);
48294829
uchar *rec_ptr= next_rec_ref_ptr + rec_fields_offset;
48304830
get_record_by_pos(rec_ptr);
4831-
if (join_tab->cache_idx_cond->val_int())
4831+
if (join_tab->cache_idx_cond->val_bool())
48324832
DBUG_RETURN(FALSE);
48334833
} while(next_rec_ref_ptr != last_rec_ref_ptr);
48344834
DBUG_RETURN(TRUE);

sql/sql_select.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17219,7 +17219,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels,
1721917219
{
1722017220
List<Item> eq_list;
1722117221
Item_func_eq *eq_item= 0;
17222-
if (((Item *) item_equal)->const_item() && !item_equal->val_int())
17222+
if (((Item *) item_equal)->const_item() && !item_equal->val_bool())
1722317223
return (Item*) &Item_false;
1722417224
Item *item_const= item_equal->get_const();
1722517225
Item_equal_fields_iterator it(*item_equal);
@@ -17288,7 +17288,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels,
1728817288
Item_func_eq *func= new (thd->mem_root) Item_func_eq(thd, item_const, upper_const);
1728917289
func->set_cmp_func(thd);
1729017290
func->quick_fix_field();
17291-
if (func->val_int())
17291+
if (func->val_bool())
1729217292
item= 0;
1729317293
}
1729417294
else
@@ -18745,7 +18745,7 @@ void propagate_new_equalities(THD *thd, Item *cond,
1874518745
List_iterator<Item_equal> ei(*cond_equalities);
1874618746
while ((equal_item= ei++))
1874718747
{
18748-
if (equal_item->const_item() && !equal_item->val_int())
18748+
if (equal_item->const_item() && !equal_item->val_bool())
1874918749
{
1875018750
*is_simplifiable_cond= true;
1875118751
return;
@@ -18776,7 +18776,7 @@ void propagate_new_equalities(THD *thd, Item *cond,
1877618776
{
1877718777
equality->merge_with_check(thd, equal_item, true);
1877818778
}
18779-
if (equality->const_item() && !equality->val_int())
18779+
if (equality->const_item() && !equality->val_bool())
1878018780
*is_simplifiable_cond= true;
1878118781
}
1878218782
else
@@ -18941,7 +18941,7 @@ Item_cond::remove_eq_conds(THD *thd, Item::cond_result *cond_value,
1894118941
Item_equal *eq_item;
1894218942
while ((eq_item= it++))
1894318943
{
18944-
if (eq_item->const_item() && eq_item->val_int())
18944+
if (eq_item->const_item() && eq_item->val_bool())
1894518945
it.remove();
1894618946
}
1894718947
cond_arg_list->append((List<Item> *) cond_equalities);
@@ -19088,7 +19088,7 @@ Item_cond::remove_eq_conds(THD *thd, Item::cond_result *cond_value,
1908819088
List_iterator_fast<Item_equal> ei(*cond_equalities);
1908919089
while ((equality= ei++))
1909019090
{
19091-
if (equality->const_item() && !equality->val_int())
19091+
if (equality->const_item() && !equality->val_bool())
1909219092
{
1909319093
*cond_value= Item::COND_FALSE;
1909419094
return (COND*) 0;
@@ -21810,7 +21810,7 @@ do_select(JOIN *join, Procedure *procedure)
2181021810
*/
2181121811
clear_tables(join, &cleared_tables);
2181221812
}
21813-
if (!join->having || join->having->val_int())
21813+
if (!join->having || join->having->val_bool())
2181421814
{
2181521815
List<Item> *columns_list= (procedure ? &join->procedure_fields_list :
2181621816
join->fields);
@@ -22302,7 +22302,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
2230222302

2230322303
/* Set first_unmatched for the last inner table of this group */
2230422304
join_tab->last_inner->first_unmatched= join_tab;
22305-
if (join_tab->on_precond && !join_tab->on_precond->val_int())
22305+
if (join_tab->on_precond && !join_tab->on_precond->val_bool())
2230622306
rc= NESTED_LOOP_NO_MORE_ROWS;
2230722307
}
2230822308
join->thd->get_stmt_da()->reset_current_row_for_warning();
@@ -22481,7 +22481,7 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab,
2248122481
*/
2248222482
if (tab->select_cond)
2248322483
{
22484-
const longlong res= tab->select_cond->val_int();
22484+
const longlong res= tab->select_cond->val_bool();
2248522485
if (join->thd->is_error())
2248622486
DBUG_RETURN(NESTED_LOOP_ERROR);
2248722487

@@ -22620,7 +22620,7 @@ evaluate_null_complemented_join_record(JOIN *join, JOIN_TAB *join_tab)
2262022620
mark_as_null_row(join_tab->table); // For group by without error
2262122621
select_cond= join_tab->select_cond;
2262222622
/* Check all attached conditions for inner table rows. */
22623-
if (select_cond && !select_cond->val_int())
22623+
if (select_cond && !select_cond->val_bool())
2262422624
return NESTED_LOOP_OK;
2262522625
}
2262622626
join_tab--;
@@ -22642,7 +22642,7 @@ evaluate_null_complemented_join_record(JOIN *join, JOIN_TAB *join_tab)
2264222642
first_unmatched->found= 1;
2264322643
for (JOIN_TAB *tab= first_unmatched; tab <= join_tab; tab++)
2264422644
{
22645-
if (tab->select_cond && !tab->select_cond->val_int())
22645+
if (tab->select_cond && !tab->select_cond->val_bool())
2264622646
{
2264722647
join->return_tab= tab;
2264822648
return NESTED_LOOP_OK;
@@ -23738,7 +23738,7 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab, bool end_of_records)
2373823738
int error=0;
2373923739
if (join->procedure)
2374023740
{
23741-
if (join->having && join->having->val_int() == 0)
23741+
if (join->having && !join->having->val_bool())
2374223742
error= -1; // Didn't satisfy having
2374323743
else
2374423744
{
@@ -28446,7 +28446,7 @@ int JOIN::rollup_write_data(uint idx, TMP_TABLE_PARAM *tmp_table_param_arg,
2844628446
{
2844728447
/* Get reference pointers to sum functions in place */
2844828448
copy_ref_ptr_array(ref_ptrs, rollup.ref_pointer_arrays[i]);
28449-
if ((!having || having->val_int()))
28449+
if ((!having || having->val_bool()))
2845028450
{
2845128451
int write_error;
2845228452
Item *item;

0 commit comments

Comments
 (0)