Skip to content

Commit d3cb00b

Browse files
committed
Bug#15831502 Assert failed in Item_outer_ref::fix_after_pullout on subquery
Preparatory patch: Remove an unused argument to Item::fix_after_pullout() The "ref" argument to this function is unused, and I see no reason that we should ever have to use it again.
1 parent 5afc584 commit d3cb00b

File tree

11 files changed

+39
-58
lines changed

11 files changed

+39
-58
lines changed

sql/item.cc

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,8 +2874,7 @@ table_map Item_field::resolved_used_tables() const
28742874
}
28752875

28762876
void Item_ident::fix_after_pullout(st_select_lex *parent_select,
2877-
st_select_lex *removed_select,
2878-
Item **ref)
2877+
st_select_lex *removed_select)
28792878
{
28802879
/*
28812880
Some field items may be created for use in execution only, without
@@ -7886,25 +7885,23 @@ bool Item_outer_ref::fix_fields(THD *thd, Item **reference)
78867885
}
78877886

78887887
void Item_outer_ref::fix_after_pullout(st_select_lex *parent_select,
7889-
st_select_lex *removed_select,
7890-
Item **ref_arg)
7888+
st_select_lex *removed_select)
78917889
{
78927890
if (depended_from == parent_select)
78937891
{
7894-
*ref_arg= outer_ref;
7895-
outer_ref->fix_after_pullout(parent_select, removed_select, ref_arg);
7892+
//*ref_arg= outer_ref;
7893+
outer_ref->fix_after_pullout(parent_select, removed_select);
78967894
}
78977895
// @todo: Find an actual test case for this funcion.
78987896
DBUG_ASSERT(false);
78997897
}
79007898

79017899
void Item_ref::fix_after_pullout(st_select_lex *parent_select,
7902-
st_select_lex *removed_select,
7903-
Item **ref_arg)
7900+
st_select_lex *removed_select)
79047901
{
7905-
(*ref)->fix_after_pullout(parent_select, removed_select, ref);
7902+
(*ref)->fix_after_pullout(parent_select, removed_select);
79067903

7907-
Item_ident::fix_after_pullout(parent_select, removed_select, ref_arg);
7904+
Item_ident::fix_after_pullout(parent_select, removed_select);
79087905
}
79097906

79107907

sql/item.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -775,12 +775,10 @@ class Item
775775
@param parent_select select_lex that tables are moved to.
776776
@param removed_select select_lex that tables are moved away from,
777777
child of parent_select.
778-
@param ref updated with new ref whenever the function substitutes
779-
this item with another.
780778
*/
781779
virtual void fix_after_pullout(st_select_lex *parent_select,
782-
st_select_lex *removed_select,
783-
Item **ref) {};
780+
st_select_lex *removed_select)
781+
{};
784782
/*
785783
should be used in case where we are sure that we do not need
786784
complete fix_fields() procedure.
@@ -2076,7 +2074,7 @@ class Item_ident :public Item
20762074
virtual table_map resolved_used_tables() const= 0;
20772075
const char *full_name() const;
20782076
virtual void fix_after_pullout(st_select_lex *parent_select,
2079-
st_select_lex *removed_select, Item **ref);
2077+
st_select_lex *removed_select);
20802078
void cleanup();
20812079
bool remove_dependence_processor(uchar * arg);
20822080
virtual void print(String *str, enum_query_type query_type);
@@ -3159,7 +3157,7 @@ class Item_ref :public Item_ident
31593157
void make_field(Send_field *field);
31603158
bool fix_fields(THD *, Item **);
31613159
void fix_after_pullout(st_select_lex *parent_select,
3162-
st_select_lex *removed_select, Item **ref);
3160+
st_select_lex *removed_select);
31633161
type_conversion_status save_in_field(Field *field, bool no_conversions);
31643162
void save_org_in_field(Field *field);
31653163
enum Item_result result_type () const { return (*ref)->result_type(); }
@@ -3405,7 +3403,7 @@ class Item_outer_ref :public Item_direct_ref
34053403
}
34063404
bool fix_fields(THD *, Item **);
34073405
void fix_after_pullout(st_select_lex *parent_select,
3408-
st_select_lex *removed_select, Item **ref);
3406+
st_select_lex *removed_select);
34093407
table_map used_tables() const
34103408
{
34113409
return (*ref)->const_item() ? 0 : OUTER_REF_TABLE_BIT;

sql/item_cmpfunc.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,8 +1917,7 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref)
19171917

19181918

19191919
void Item_in_optimizer::fix_after_pullout(st_select_lex *parent_select,
1920-
st_select_lex *removed_select,
1921-
Item **ref)
1920+
st_select_lex *removed_select)
19221921
{
19231922
used_tables_cache= get_initial_pseudo_tables();
19241923
not_null_tables_cache= 0;
@@ -1930,7 +1929,7 @@ void Item_in_optimizer::fix_after_pullout(st_select_lex *parent_select,
19301929
So, just forward the call to the Item_in_subselect object.
19311930
*/
19321931

1933-
args[1]->fix_after_pullout(parent_select, removed_select, &args[1]);
1932+
args[1]->fix_after_pullout(parent_select, removed_select);
19341933

19351934
used_tables_cache|= args[1]->used_tables();
19361935
not_null_tables_cache|= args[1]->not_null_tables();
@@ -4816,8 +4815,7 @@ Item_cond::fix_fields(THD *thd, Item **ref)
48164815

48174816

48184817
void Item_cond::fix_after_pullout(st_select_lex *parent_select,
4819-
st_select_lex *removed_select,
4820-
Item **ref)
4818+
st_select_lex *removed_select)
48214819
{
48224820
List_iterator<Item> li(list);
48234821
Item *item;
@@ -4832,8 +4830,7 @@ void Item_cond::fix_after_pullout(st_select_lex *parent_select,
48324830

48334831
while ((item=li++))
48344832
{
4835-
item->fix_after_pullout(parent_select, removed_select, li.ref());
4836-
item= *li.ref();
4833+
item->fix_after_pullout(parent_select, removed_select);
48374834
used_tables_cache|= item->used_tables();
48384835
const_item_cache&= item->const_item();
48394836
if (functype() == COND_AND_FUNC && abort_on_null)

sql/item_cmpfunc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ class Item_in_optimizer: public Item_bool_func
283283
bool fix_fields(THD *, Item **);
284284
bool fix_left(THD *thd, Item **ref);
285285
void fix_after_pullout(st_select_lex *parent_select,
286-
st_select_lex *removed_select, Item **ref);
286+
st_select_lex *removed_select);
287287
bool is_null();
288288
longlong val_int();
289289
void cleanup();
@@ -1665,7 +1665,7 @@ class Item_cond :public Item_bool_func
16651665
}
16661666
bool fix_fields(THD *, Item **ref);
16671667
void fix_after_pullout(st_select_lex *parent_select,
1668-
st_select_lex *removed_select, Item **ref);
1668+
st_select_lex *removed_select);
16691669

16701670
enum Type type() const { return COND_ITEM; }
16711671
List<Item>* argument_list() { return &list; }

sql/item_func.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ Item_func::fix_fields(THD *thd, Item **ref)
237237

238238

239239
void Item_func::fix_after_pullout(st_select_lex *parent_select,
240-
st_select_lex *removed_select,
241-
Item **ref)
240+
st_select_lex *removed_select)
242241
{
243242
Item **arg,**arg_end;
244243

@@ -250,8 +249,8 @@ void Item_func::fix_after_pullout(st_select_lex *parent_select,
250249
{
251250
for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++)
252251
{
253-
(*arg)->fix_after_pullout(parent_select, removed_select, arg);
254-
Item *item= *arg;
252+
Item *const item= *arg;
253+
item->fix_after_pullout(parent_select, removed_select);
255254

256255
used_tables_cache|= item->used_tables();
257256
not_null_tables_cache|= item->not_null_tables();

sql/item_func.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class Item_func :public Item_result_field
122122
Item_func(THD *thd, Item_func *item);
123123
bool fix_fields(THD *, Item **ref);
124124
void fix_after_pullout(st_select_lex *parent_select,
125-
st_select_lex *removed_select, Item **ref);
125+
st_select_lex *removed_select);
126126
table_map used_tables() const;
127127
/**
128128
Returns the pseudo tables depended upon in order to evaluate this

sql/item_row.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,13 @@ void Item_row::update_used_tables()
140140
}
141141

142142
void Item_row::fix_after_pullout(st_select_lex *parent_select,
143-
st_select_lex *removed_select,
144-
Item **ref)
143+
st_select_lex *removed_select)
145144
{
146145
used_tables_cache= 0;
147146
const_item_cache= 1;
148147
for (uint i= 0; i < arg_count; i++)
149148
{
150-
items[i]->fix_after_pullout(parent_select, removed_select, &items[i]);
149+
items[i]->fix_after_pullout(parent_select, removed_select);
151150
used_tables_cache|= items[i]->used_tables();
152151
const_item_cache&= items[i]->const_item();
153152
}

sql/item_row.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Item_row: public Item
7575

7676
bool fix_fields(THD *thd, Item **ref);
7777
void fix_after_pullout(st_select_lex *parent_select,
78-
st_select_lex *removed_select, Item **ref);
78+
st_select_lex *removed_select);
7979
void cleanup();
8080
void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
8181
List<Item> &fields);

sql/item_subselect.cc

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,7 @@ bool Item_subselect::exec()
627627
*/
628628

629629
void Item_subselect::fix_after_pullout(st_select_lex *parent_select,
630-
st_select_lex *removed_select,
631-
Item **ref)
630+
st_select_lex *removed_select)
632631

633632
{
634633
/* Clear usage information for this subquery predicate object */
@@ -641,17 +640,15 @@ void Item_subselect::fix_after_pullout(st_select_lex *parent_select,
641640
for (SELECT_LEX *sel= unit->first_select(); sel; sel= sel->next_select())
642641
{
643642
if (sel->where)
644-
sel->where->fix_after_pullout(parent_select, removed_select,
645-
&sel->where);
643+
sel->where->fix_after_pullout(parent_select, removed_select);
646644

647645
if (sel->having)
648-
sel->having->fix_after_pullout(parent_select, removed_select,
649-
&sel->having);
646+
sel->having->fix_after_pullout(parent_select, removed_select);
650647

651648
List_iterator<Item> li(sel->item_list);
652649
Item *item;
653650
while ((item=li++))
654-
item->fix_after_pullout(parent_select, removed_select, li.ref());
651+
item->fix_after_pullout(parent_select, removed_select);
655652

656653
/*
657654
No need to call fix_after_pullout() for outer-join conditions, as these
@@ -663,14 +660,12 @@ void Item_subselect::fix_after_pullout(st_select_lex *parent_select,
663660
for (ORDER *order= (ORDER*) sel->order_list.first;
664661
order;
665662
order= order->next)
666-
(*order->item)->fix_after_pullout(parent_select, removed_select,
667-
order->item);
663+
(*order->item)->fix_after_pullout(parent_select, removed_select);
668664

669665
for (ORDER *group= (ORDER*) sel->group_list.first;
670666
group;
671667
group= group->next)
672-
(*group->item)->fix_after_pullout(parent_select, removed_select,
673-
group->item);
668+
(*group->item)->fix_after_pullout(parent_select, removed_select);
674669
}
675670
}
676671

@@ -2327,12 +2322,11 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
23272322

23282323

23292324
void Item_in_subselect::fix_after_pullout(st_select_lex *parent_select,
2330-
st_select_lex *removed_select,
2331-
Item **ref)
2325+
st_select_lex *removed_select)
23322326
{
2333-
Item_subselect::fix_after_pullout(parent_select, removed_select, ref);
2327+
Item_subselect::fix_after_pullout(parent_select, removed_select);
23342328

2335-
left_expr->fix_after_pullout(parent_select, removed_select, &left_expr);
2329+
left_expr->fix_after_pullout(parent_select, removed_select);
23362330

23372331
used_tables_cache|= left_expr->used_tables();
23382332
}

sql/item_subselect.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class Item_subselect :public Item_result_field
130130
}
131131
bool fix_fields(THD *thd, Item **ref);
132132
void fix_after_pullout(st_select_lex *parent_select,
133-
st_select_lex *removed_select, Item **ref);
133+
st_select_lex *removed_select);
134134
virtual bool exec();
135135
virtual void fix_length_and_dec();
136136
table_map used_tables() const;
@@ -176,8 +176,7 @@ class Item_subselect :public Item_result_field
176176
friend int Item_field::fix_outer_field(THD *, Field **, Item **);
177177
friend bool Item_ref::fix_fields(THD *, Item **);
178178
friend void Item_ident::fix_after_pullout(st_select_lex *parent_select,
179-
st_select_lex *removed_select,
180-
Item **ref);
179+
st_select_lex *removed_selec);
181180
friend void mark_select_range_as_dependent(THD*,
182181
st_select_lex*, st_select_lex*,
183182
Field*, Item*, Item_ident*);
@@ -469,7 +468,7 @@ class Item_in_subselect :public Item_exists_subselect
469468
virtual void print(String *str, enum_query_type query_type);
470469
bool fix_fields(THD *thd, Item **ref);
471470
void fix_after_pullout(st_select_lex *parent_select,
472-
st_select_lex *removed_select, Item **ref);
471+
st_select_lex *removed_select);
473472
bool init_left_expr_cache();
474473

475474
/**

0 commit comments

Comments
 (0)