~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/field.cc

  • Committer: Brian Aker
  • Date: 2011-01-12 06:45:23 UTC
  • mto: (2073.1.4 catalogs)
  • mto: This revision was merged to the branch mainline in revision 2080.
  • Revision ID: brian@tangent.org-20110112064523-rqhptaqbph22qmj1
Remove custom error.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
 
20
#include "config.h"
21
21
 
22
22
#include <drizzled/session.h>
23
23
#include <drizzled/table.h>
56
56
bool Item_field::collect_item_field_processor(unsigned char *arg)
57
57
{
58
58
  List<Item_field> *item_list= (List<Item_field>*) arg;
59
 
  List<Item_field>::iterator item_list_it(item_list->begin());
 
59
  List_iterator<Item_field> item_list_it(*item_list);
60
60
  Item_field *curr_item;
61
61
  while ((curr_item= item_list_it++))
62
62
  {
165
165
   have_privileges(0),
166
166
   any_privileges(0)
167
167
{
168
 
  Select_Lex *select= getSession().getLex()->current_select;
 
168
  Select_Lex *select= current_session->lex->current_select;
169
169
  collation.set(DERIVATION_IMPLICIT);
170
170
 
171
171
  if (select && select->parsing_place != IN_HAVING)
262
262
  return result_field->val_str(str,&str_value);
263
263
}
264
264
 
265
 
bool Item_field::get_date(type::Time &ltime,uint32_t fuzzydate)
 
265
bool Item_field::get_date(type::Time *ltime,uint32_t fuzzydate)
266
266
{
267
267
  if ((null_value=field->is_null()) || field->get_date(ltime,fuzzydate))
268
268
  {
269
 
    ltime.reset();
 
269
    memset(ltime, 0, sizeof(*ltime));
270
270
    return 1;
271
271
  }
272
272
  return 0;
273
273
}
274
274
 
275
 
bool Item_field::get_date_result(type::Time &ltime,uint32_t fuzzydate)
 
275
bool Item_field::get_date_result(type::Time *ltime,uint32_t fuzzydate)
276
276
{
277
277
  if ((null_value=result_field->is_null()) ||
278
278
      result_field->get_date(ltime,fuzzydate))
279
279
  {
280
 
    ltime.reset();
 
280
    memset(ltime, 0, sizeof(*ltime));
281
281
    return 1;
282
282
  }
283
283
  return 0;
284
284
}
285
285
 
286
 
bool Item_field::get_time(type::Time &ltime)
 
286
bool Item_field::get_time(type::Time *ltime)
287
287
{
288
288
  if ((null_value=field->is_null()) || field->get_time(ltime))
289
289
  {
290
 
    ltime.reset();
 
290
    memset(ltime, 0, sizeof(*ltime));
291
291
    return 1;
292
292
  }
293
293
  return 0;
319
319
bool Item_field::val_bool_result()
320
320
{
321
321
  if ((null_value= result_field->is_null()))
322
 
  {
323
322
    return false;
324
 
  }
325
 
 
326
323
  switch (result_field->result_type()) {
327
324
  case INT_RESULT:
328
325
    return result_field->val_int() != 0;
332
329
      type::Decimal decimal_value;
333
330
      type::Decimal *val= result_field->val_decimal(&decimal_value);
334
331
      if (val)
335
 
        return not val->isZero();
 
332
        return not val->is_zero();
336
333
      return 0;
337
334
    }
338
335
 
369
366
    (In cases where we would choose wrong we would have to generate a
370
367
    ER_NON_UNIQ_ERROR).
371
368
  */
372
 
  return (not my_strcasecmp(system_charset_info, item_field->name, field_name) &&
373
 
          (not item_field->table_name || not table_name ||
374
 
           (not my_strcasecmp(table_alias_charset, item_field->table_name, table_name) &&
375
 
            (not item_field->db_name || not db_name ||
376
 
             (item_field->db_name && not my_strcasecmp(system_charset_info, item_field->db_name, db_name))))));
 
369
  return (!my_strcasecmp(system_charset_info, item_field->name,
 
370
                         field_name) &&
 
371
          (!item_field->table_name || !table_name ||
 
372
           (!my_strcasecmp(table_alias_charset, item_field->table_name,
 
373
                           table_name) &&
 
374
            (!item_field->db_name || !db_name ||
 
375
             (item_field->db_name && !strcasecmp(item_field->db_name,
 
376
                                             db_name))))));
377
377
}
378
378
 
379
379
 
380
380
table_map Item_field::used_tables() const
381
381
{
382
382
  if (field->getTable()->const_table)
383
 
  {
384
383
    return 0;                                   // const item
385
 
  }
386
 
 
387
384
  return (depended_from ? OUTER_REF_TABLE_BIT : field->getTable()->map);
388
385
}
389
386
 
496
493
  */
497
494
  Name_resolution_context *last_checked_context= context;
498
495
  Item **ref= (Item **) not_found_item;
499
 
  Select_Lex *current_sel= (Select_Lex *) session->getLex()->current_select;
 
496
  Select_Lex *current_sel= (Select_Lex *) session->lex->current_select;
500
497
  Name_resolution_context *outer_context= 0;
501
498
  Select_Lex *select= 0;
502
499
  /* Currently derived tables cannot be correlated */
562
559
              return -1;
563
560
            session->change_item_tree(reference, rf);
564
561
            select->inner_refs_list.push_back(rf);
565
 
            rf->in_sum_func= session->getLex()->in_sum_func;
 
562
            rf->in_sum_func= session->lex->in_sum_func;
566
563
          }
567
564
          /*
568
565
            A reference is resolved to a nest level that's outer or the same as
569
566
            the nest level of the enclosing set function : adjust the value of
570
567
            max_arg_level for the function if it's needed.
571
568
          */
572
 
          if (session->getLex()->in_sum_func &&
573
 
              session->getLex()->in_sum_func->nest_level >= select->nest_level)
 
569
          if (session->lex->in_sum_func &&
 
570
              session->lex->in_sum_func->nest_level >= select->nest_level)
574
571
          {
575
572
            Item::Type ref_type= (*reference)->type();
576
 
            set_if_bigger(session->getLex()->in_sum_func->max_arg_level,
 
573
            set_if_bigger(session->lex->in_sum_func->max_arg_level,
577
574
                          select->nest_level);
578
575
            set_field(*from_field);
579
576
            fixed= 1;
640
637
    if (upward_lookup)
641
638
    {
642
639
      // We can't say exactly what absent table or field
643
 
      my_error(ER_BAD_FIELD_ERROR, MYF(0), full_name(), session->where());
 
640
      my_error(ER_BAD_FIELD_ERROR, MYF(0), full_name(), session->where);
644
641
    }
645
642
    else
646
643
    {
682
679
    if (place != IN_HAVING && select->group_list.elements)
683
680
    {
684
681
      outer_context->select_lex->inner_refs_list.push_back((Item_outer_ref*)rf);
685
 
      ((Item_outer_ref*)rf)->in_sum_func= session->getLex()->in_sum_func;
 
682
      ((Item_outer_ref*)rf)->in_sum_func= session->lex->in_sum_func;
686
683
    }
687
684
    session->change_item_tree(reference, rf);
688
685
    /*
788
785
                                          context->first_name_resolution_table,
789
786
                                          context->last_name_resolution_table,
790
787
                                          reference,
791
 
                                          session->getLex()->use_only_table_context ?
 
788
                                          session->lex->use_only_table_context ?
792
789
                                            REPORT_ALL_ERRORS :
793
790
                                            IGNORE_EXCEPT_NON_UNIQUE, true)) ==
794
791
        not_found_field)
795
792
    {
796
793
      int ret;
797
794
      /* Look up in current select's item_list to find aliased fields */
798
 
      if (session->getLex()->current_select->is_item_list_lookup)
 
795
      if (session->lex->current_select->is_item_list_lookup)
799
796
      {
800
797
        uint32_t counter;
801
798
        enum_resolution_type resolution;
802
799
        Item** res= find_item_in_list(session,
803
 
                                      this, session->getLex()->current_select->item_list,
 
800
                                      this, session->lex->current_select->item_list,
804
801
                                      &counter, REPORT_EXCEPT_NOT_FOUND,
805
802
                                      &resolution);
806
803
        if (!res)
824
821
            {
825
822
              /* The column to which we link isn't valid. */
826
823
              my_error(ER_BAD_FIELD_ERROR, MYF(0), (*res)->name,
827
 
                       session->where());
 
824
                       current_session->where);
828
825
              return(1);
829
826
            }
830
827
 
888
885
      return false;
889
886
 
890
887
    set_field(from_field);
891
 
    if (session->getLex()->in_sum_func &&
892
 
        session->getLex()->in_sum_func->nest_level ==
893
 
        session->getLex()->current_select->nest_level)
 
888
    if (session->lex->in_sum_func &&
 
889
        session->lex->in_sum_func->nest_level ==
 
890
        session->lex->current_select->nest_level)
894
891
    {
895
 
      set_if_bigger(session->getLex()->in_sum_func->max_arg_level,
896
 
                    session->getLex()->current_select->nest_level);
 
892
      set_if_bigger(session->lex->in_sum_func->max_arg_level,
 
893
                    session->lex->current_select->nest_level);
897
894
    }
898
895
  }
899
896
  else if (session->mark_used_columns != MARK_COLUMNS_NONE)
980
977
  Item_equal *item= 0;
981
978
  while (cond_equal)
982
979
  {
983
 
    List<Item_equal>::iterator li(cond_equal->current_level.begin());
 
980
    List_iterator_fast<Item_equal> li(cond_equal->current_level);
984
981
    while ((item= li++))
985
982
    {
986
983
      if (item->contains(field))