68
68
static Item* part_of_refkey(Table *form,Field *field);
69
69
static bool cmp_buffer_with_ref(JOIN_TAB *tab);
70
70
static void change_cond_ref_to_const(Session *session,
71
I_List<COND_CMP> *save_list,
71
vector<COND_CMP>& save_list,
3735
3735
static void change_cond_ref_to_const(Session *session,
3736
I_List<COND_CMP> *save_list,
3736
vector<COND_CMP>& save_list,
3737
3737
Item *and_father,
3742
3742
if (cond->type() == Item::COND_ITEM)
3744
bool and_level= ((Item_cond*) cond)->functype() ==
3745
Item_func::COND_AND_FUNC;
3744
bool and_level= ((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC;
3746
3745
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
3748
3747
while ((item=li++))
3749
change_cond_ref_to_const(session, save_list,and_level ? cond : item, item, field, value);
3748
change_cond_ref_to_const(session, save_list, and_level ? cond : item, item, field, value);
3752
3751
if (cond->eq_cmp_result() == Item::COND_OK)
3776
3775
! left_item->const_item())
3778
3777
cond->marker=1;
3780
if ((tmp2=new COND_CMP(and_father,func)))
3781
save_list->push_back(tmp2);
3778
save_list.push_back( COND_CMP(and_father, func) );
3783
3780
func->set_cmp_func();
3804
3801
args[0]= args[1]; // For easy check
3805
3802
session->change_item_tree(args + 1, value);
3806
3803
cond->marker=1;
3808
if ((tmp2=new COND_CMP(and_father,func)))
3809
save_list->push_back(tmp2);
3804
save_list.push_back( COND_CMP(and_father, func) );
3811
3806
func->set_cmp_func();
3847
3842
static void propagate_cond_constants(Session *session,
3848
I_List<COND_CMP> *save_list,
3843
vector<COND_CMP>& save_list,
3849
3844
COND *and_father,
3852
3847
if (cond->type() == Item::COND_ITEM)
3854
bool and_level= ((Item_cond*) cond)->functype() ==
3855
Item_func::COND_AND_FUNC;
3849
bool and_level= ((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC;
3856
3850
List_iterator_fast<Item> li(*((Item_cond*) cond)->argument_list());
3858
I_List<COND_CMP> save;
3852
vector<COND_CMP> save;
3859
3853
while ((item=li++))
3861
propagate_cond_constants(session, &save,and_level ? cond : item, item);
3855
propagate_cond_constants(session, save, and_level ? cond : item, item);
3864
{ // Handle other found items
3865
I_List_iterator<COND_CMP> cond_itr(save);
3867
while ((cond_cmp=cond_itr++))
3859
// Handle other found items
3860
for (vector<COND_CMP>::iterator iter= save.begin(); iter != save.end(); ++iter)
3869
Item **args= cond_cmp->cmp_func->arguments();
3862
Item **args= iter->cmp_func->arguments();
3870
3863
if (!args[0]->const_item())
3871
change_cond_ref_to_const(session, &save,cond_cmp->and_level,
3872
cond_cmp->and_level, args[0], args[1]);
3865
change_cond_ref_to_const( session, save, iter->and_level,
3866
iter->and_level, args[0], args[1] );
4090
4085
&join->cond_equal);
4092
4087
/* change field = field to field = const for each found field = const */
4093
propagate_cond_constants(session, (I_List<COND_CMP> *) 0, conds, conds);
4088
vector<COND_CMP> temp;
4089
propagate_cond_constants(session, temp, conds, conds);
4095
4091
Remove all instances of item == item
4096
4092
Remove all and-levels where CONST item != CONST item