~james-page/ubuntu/precise/mysql-5.5/misc-fixes

« back to all changes in this revision

Viewing changes to sql/sql_class.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-06-11 07:34:33 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120611073433-l9za2ni4ipp848y3
Tags: 5.5.24-0ubuntu0.12.04.1
* SECURITY UPDATE: Update to 5.5.24 to fix security issues (LP: #1011371)
  - http://dev.mysql.com/doc/refman/5.5/en/news-5-5-24.html

Show diffs side-by-side

added added

removed removed

Lines of Context:
2855
2855
int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
2856
2856
{
2857
2857
  unit= u;
 
2858
  List_iterator_fast<my_var> var_li(var_list);
 
2859
  List_iterator_fast<Item> it(list);
 
2860
  Item *item;
 
2861
  my_var *mv;
 
2862
  Item_func_set_user_var **suv;
2858
2863
  
2859
2864
  if (var_list.elements != list.elements)
2860
2865
  {
2861
2866
    my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT,
2862
2867
               ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT), MYF(0));
2863
2868
    return 1;
2864
 
  }               
 
2869
  }
 
2870
 
 
2871
  /*
 
2872
    Iterate over the destination variables and mark them as being
 
2873
    updated in this query.
 
2874
    We need to do this at JOIN::prepare time to ensure proper
 
2875
    const detection of Item_func_get_user_var that is determined
 
2876
    by the presence of Item_func_set_user_vars
 
2877
  */
 
2878
 
 
2879
  suv= set_var_items= (Item_func_set_user_var **) 
 
2880
    sql_alloc(sizeof(Item_func_set_user_var *) * list.elements);
 
2881
 
 
2882
  while ((mv= var_li++) && (item= it++))
 
2883
  {
 
2884
    if (!mv->local)
 
2885
    {
 
2886
      *suv= new Item_func_set_user_var(mv->s, item);
 
2887
      (*suv)->fix_fields(thd, 0);
 
2888
    }
 
2889
    else
 
2890
      *suv= NULL;
 
2891
    suv++;
 
2892
  }
 
2893
 
2865
2894
  return 0;
2866
2895
}
2867
2896
 
3178
3207
  List_iterator<Item> it(items);
3179
3208
  Item *item;
3180
3209
  my_var *mv;
 
3210
  Item_func_set_user_var **suv;
3181
3211
  DBUG_ENTER("select_dumpvar::send_data");
3182
3212
 
3183
3213
  if (unit->offset_limit_cnt)
3190
3220
    my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0));
3191
3221
    DBUG_RETURN(1);
3192
3222
  }
3193
 
  while ((mv= var_li++) && (item= it++))
 
3223
  for (suv= set_var_items; ((mv= var_li++) && (item= it++)); suv++)
3194
3224
  {
3195
3225
    if (mv->local)
3196
3226
    {
 
3227
      DBUG_ASSERT(!*suv);
3197
3228
      if (thd->spcont->set_variable(thd, mv->offset, &item))
3198
3229
            DBUG_RETURN(1);
3199
3230
    }
3200
3231
    else
3201
3232
    {
3202
 
      Item_func_set_user_var *suv= new Item_func_set_user_var(mv->s, item);
3203
 
      if (suv->fix_fields(thd, 0))
3204
 
        DBUG_RETURN (1);
3205
 
      suv->save_item_result(item);
3206
 
      if (suv->update())
 
3233
      DBUG_ASSERT(*suv);
 
3234
      (*suv)->save_item_result(item);
 
3235
      if ((*suv)->update())
3207
3236
        DBUG_RETURN (1);
3208
3237
    }
3209
3238
  }