~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

  • Committer: Mark Atwood
  • Date: 2011-06-27 19:01:37 UTC
  • mfrom: (2318.6.90 refactor16)
  • Revision ID: me@mark.atwood.name-20110627190137-iflt3vku0kw77l8a
mergeĀ lp:~olafvdspek/drizzle/refactor17

Show diffs side-by-side

added added

removed removed

Lines of Context:
258
258
                          ref->field_name, ref->alias_name_used) :
259
259
              new Item_ref(ref->context, item_ref, ref->table_name,
260
260
                          ref->field_name, ref->alias_name_used);
261
 
    if (!new_ref)
262
 
      return true;
263
261
    ref->outer_ref= new_ref;
264
262
    ref->ref= &ref->outer_ref;
265
263
 
404
402
  }
405
403
  else
406
404
  {
407
 
    if (!(join= new Join(session, fields, select_options, result)))
408
 
      return true;
 
405
    join= new Join(session, fields, select_options, result);
409
406
    session->set_proc_info("init");
410
407
    session->used_tables=0;                         // Updated by setup_fields
411
 
    if ((err= join->prepare(rref_pointer_array, tables, wild_num,
412
 
                           conds, og_num, order, group, having,
413
 
                           select_lex, unit)) == true)
414
 
    {
 
408
    if ((err= join->prepare(rref_pointer_array, tables, wild_num, conds, og_num, order, group, having, select_lex, unit)))
415
409
      goto err;
416
 
    }
417
410
  }
418
411
 
419
412
  err= join->optimize();
936
929
{
937
930
  if (*e1)
938
931
  {
939
 
    Item *res;
940
 
    if ((res= new Item_cond_and(*e1, e2)))
941
 
    {
942
 
      *e1= res;
943
 
      res->quick_fix_field();
944
 
    }
 
932
    Item* res= new Item_cond_and(*e1, e2);
 
933
    *e1= res;
 
934
    res->quick_fix_field();
945
935
  }
946
936
  else
947
937
    *e1= e2;
1146
1136
          */
1147
1137
          if (!referred_tab || referred_tab->join != join)
1148
1138
            continue;
1149
 
          if (!(notnull= new Item_func_isnotnull(not_null_item)))
1150
 
            return;
 
1139
          notnull= new Item_func_isnotnull(not_null_item);
1151
1140
          /*
1152
1141
            We need to do full fix_fields() call here in order to have correct
1153
1142
            notnull->const_item(). This is needed e.g. by test_quick_select
1553
1542
        if (!item)
1554
1543
        {
1555
1544
          Item_func_eq *eq_item;
1556
 
          if ((eq_item= new Item_func_eq(left_item, right_item)))
1557
 
            return false;
 
1545
          eq_item= new Item_func_eq(left_item, right_item);
1558
1546
          eq_item->set_cmp_func();
1559
1547
          eq_item->quick_fix_field();
1560
1548
          item= eq_item;
1647
1635
    if (!is_converted)
1648
1636
    {
1649
1637
      Item_func_eq *eq_item;
1650
 
      if (!(eq_item= new Item_func_eq(left_item, right_item)))
1651
 
        return false;
 
1638
      eq_item= new Item_func_eq(left_item, right_item);
1652
1639
      eq_item->set_cmp_func();
1653
1640
      eq_item->quick_fix_field();
1654
1641
      eq_list->push_back(eq_item);
2778
2765
            )
2779
2766
          )
2780
2767
      {
2781
 
        COND *new_cond;
2782
 
        if ((new_cond= new Item_func_eq(args[0], new Item_int("last_insert_id()",
2783
 
                                                          session->read_first_successful_insert_id_in_prev_stmt(),
2784
 
                                                          MY_INT64_NUM_DECIMAL_DIGITS))))
2785
 
        {
2786
 
          cond= new_cond;
2787
 
          /*
2788
 
            Item_func_eq can't be fixed after creation so we do not check
2789
 
            cond->fixed, also it do not need tables so we use 0 as second
2790
 
            argument.
2791
 
          */
2792
 
          cond->fix_fields(session, &cond);
2793
 
        }
 
2768
        COND *new_cond= new Item_func_eq(args[0], new Item_int("last_insert_id()", 
 
2769
          session->read_first_successful_insert_id_in_prev_stmt(), MY_INT64_NUM_DECIMAL_DIGITS));
 
2770
        cond= new_cond;
 
2771
        /*
 
2772
        Item_func_eq can't be fixed after creation so we do not check
 
2773
        cond->fixed, also it do not need tables so we use 0 as second
 
2774
        argument.
 
2775
        */
 
2776
        cond->fix_fields(session, &cond);
2794
2777
        /*
2795
2778
          IS NULL should be mapped to LAST_INSERT_ID only for first row, so
2796
2779
          clear for next row
2804
2787
          && (field->flags & NOT_NULL_FLAG)
2805
2788
          && ! field->table->maybe_null)
2806
2789
      {
2807
 
        COND *new_cond;
2808
 
        if ((new_cond= new Item_func_eq(args[0],new Item_int("0", 0, 2))))
2809
 
        {
2810
 
          cond= new_cond;
2811
 
          /*
2812
 
            Item_func_eq can't be fixed after creation so we do not check
2813
 
            cond->fixed, also it do not need tables so we use 0 as second
2814
 
            argument.
2815
 
          */
2816
 
          cond->fix_fields(session, &cond);
2817
 
        }
 
2790
        COND* new_cond= new Item_func_eq(args[0],new Item_int("0", 0, 2));
 
2791
        cond= new_cond;
 
2792
        /*
 
2793
        Item_func_eq can't be fixed after creation so we do not check
 
2794
        cond->fixed, also it do not need tables so we use 0 as second
 
2795
        argument.
 
2796
        */
 
2797
        cond->fix_fields(session, &cond);
2818
2798
      }
2819
2799
#endif /* NOTDEFINED */
2820
2800
    }
5764
5744
    Item *real_pos= pos->real_item();
5765
5745
    if (real_pos->type() == Item::FIELD_ITEM)
5766
5746
    {
5767
 
      Item_field *item;
5768
 
      if (!(item= new Item_field(session, ((Item_field*) real_pos))))
5769
 
        goto err;
 
5747
      Item_field* item= new Item_field(session, ((Item_field*) real_pos));
5770
5748
      if (pos->type() == Item::REF_ITEM)
5771
5749
      {
5772
5750
        /* preserve the names of the ref when dereferncing */
5778
5756
      pos= item;
5779
5757
      if (item->field->flags & BLOB_FLAG)
5780
5758
      {
5781
 
        if (!(pos= new Item_copy_string(pos)))
5782
 
          goto err;
 
5759
        pos= new Item_copy_string(pos);
5783
5760
            /*
5784
5761
              Item_copy_string::copy for function can call
5785
5762
              Item_copy_string::val_int for blob via Item_ref.
6172
6149
        {
6173
6150
          if (item->eq(*group_tmp->item,0))
6174
6151
          {
6175
 
            Item *new_item;
6176
 
            if (!(new_item= new Item_ref(context, group_tmp->item, 0,
6177
 
                                        item->name)))
6178
 
              return 1;                                 // fatal_error is set
 
6152
            Item* new_item= new Item_ref(context, group_tmp->item, 0, item->name);
6179
6153
            *arg= new_item;
6180
6154
            arg_changed= true;
6181
6155
          }