~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_cmpfunc.cc

  • Committer: Brian Aker
  • Date: 2008-10-20 03:40:03 UTC
  • mto: (492.3.21 drizzle-clean-code)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: brian@tangent.org-20081020034003-t2dcnl0ayr2ymm8k
THD -> Session rename

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <drizzled/server_includes.h>
25
25
#include <drizzled/sql_select.h>
26
26
 
27
 
static bool convert_constant_item(THD *, Item_field *, Item **);
 
27
static bool convert_constant_item(Session *, Item_field *, Item **);
28
28
 
29
29
static Item_result item_store_type(Item_result a, Item *item,
30
30
                                   bool unsigned_flag)
378
378
    1  Item was replaced with an integer version of the item
379
379
*/
380
380
 
381
 
static bool convert_constant_item(THD *thd, Item_field *field_item,
 
381
static bool convert_constant_item(Session *thd, Item_field *field_item,
382
382
                                  Item **item)
383
383
{
384
384
  Field *field= field_item->field;
426
426
void Item_bool_func2::fix_length_and_dec()
427
427
{
428
428
  max_length= 1;                                     // Function returns 0 or 1
429
 
  THD *thd;
 
429
  Session *thd;
430
430
 
431
431
  /*
432
432
    As some compare functions are generated after sql_yacc,
628
628
*/
629
629
 
630
630
static uint64_t
631
 
get_date_from_str(THD *thd, String *str, enum enum_drizzle_timestamp_type warn_type,
 
631
get_date_from_str(Session *thd, String *str, enum enum_drizzle_timestamp_type warn_type,
632
632
                  char *warn_name, bool *error_arg)
633
633
{
634
634
  uint64_t value= 0;
734
734
        (str_arg->type() != Item::FUNC_ITEM ||
735
735
        ((Item_func*)str_arg)->functype() != Item_func::GUSERVAR_FUNC))
736
736
    {
737
 
      THD *thd= current_thd;
 
737
      Session *thd= current_thd;
738
738
      uint64_t value;
739
739
      bool error;
740
740
      String tmp, *str_val= 0;
781
781
*/
782
782
 
783
783
uint64_t
784
 
get_time_value(THD *thd __attribute__((unused)),
 
784
get_time_value(Session *thd __attribute__((unused)),
785
785
               Item ***item_arg, Item **cache_arg,
786
786
               Item *warn_item __attribute__((unused)),
787
787
               bool *is_null)
924
924
*/
925
925
 
926
926
uint64_t
927
 
get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
 
927
get_datetime_value(Session *thd, Item ***item_arg, Item **cache_arg,
928
928
                   Item *warn_item, bool *is_null)
929
929
{
930
930
  uint64_t value= 0;
1443
1443
}
1444
1444
 
1445
1445
 
1446
 
bool Item_in_optimizer::fix_left(THD *thd, Item **ref __attribute__((unused)))
 
1446
bool Item_in_optimizer::fix_left(Session *thd, Item **ref __attribute__((unused)))
1447
1447
{
1448
1448
  if ((!args[0]->fixed && args[0]->fix_fields(thd, args)) ||
1449
1449
      (!cache && !(cache= Item_cache::get_cache(args[0]))))
1477
1477
}
1478
1478
 
1479
1479
 
1480
 
bool Item_in_optimizer::fix_fields(THD *thd, Item **ref)
 
1480
bool Item_in_optimizer::fix_fields(Session *thd, Item **ref)
1481
1481
{
1482
1482
  assert(fixed == 0);
1483
1483
  if (fix_left(thd, ref))
1632
1632
  if (!new_item)
1633
1633
    return 0;
1634
1634
  /*
1635
 
    THD::change_item_tree() should be called only if the tree was
 
1635
    Session::change_item_tree() should be called only if the tree was
1636
1636
    really transformed, i.e. when a new item has been created.
1637
1637
    Otherwise we'll be allocating a lot of unnecessary memory for
1638
1638
    change records at each execution.
1946
1946
    1   got error
1947
1947
*/
1948
1948
 
1949
 
bool Item_func_between::fix_fields(THD *thd, Item **ref)
 
1949
bool Item_func_between::fix_fields(Session *thd, Item **ref)
1950
1950
{
1951
1951
  if (Item_func_opt_neg::fix_fields(thd, ref))
1952
1952
    return 1;
1973
1973
  bool datetime_found= false;
1974
1974
  int time_items_found= 0;
1975
1975
  compare_as_dates= true;
1976
 
  THD *thd= current_thd;
 
1976
  Session *thd= current_thd;
1977
1977
 
1978
1978
  /*
1979
1979
    As some compare functions are generated after sql_yacc,
2312
2312
*/
2313
2313
 
2314
2314
bool
2315
 
Item_func_if::fix_fields(THD *thd, Item **ref)
 
2315
Item_func_if::fix_fields(Session *thd, Item **ref)
2316
2316
{
2317
2317
  assert(fixed == 0);
2318
2318
  args[0]->top_level_item();
2665
2665
}
2666
2666
 
2667
2667
 
2668
 
bool Item_func_case::fix_fields(THD *thd, Item **ref)
 
2668
bool Item_func_case::fix_fields(Session *thd, Item **ref)
2669
2669
{
2670
2670
  /*
2671
2671
    buff should match stack usage from
3485
3485
*/
3486
3486
 
3487
3487
bool
3488
 
Item_func_in::fix_fields(THD *thd, Item **ref)
 
3488
Item_func_in::fix_fields(Session *thd, Item **ref)
3489
3489
{
3490
3490
  Item **arg, **arg_end;
3491
3491
 
3517
3517
{
3518
3518
  Item **arg, **arg_end;
3519
3519
  bool const_itm= 1;
3520
 
  THD *thd= current_thd;
 
3520
  Session *thd= current_thd;
3521
3521
  bool datetime_found= false;
3522
3522
  /* true <=> arguments values will be compared as DATETIMEs. */
3523
3523
  bool compare_as_datetime= false;
3850
3850
  return (int64_t) (arg1 & arg2);
3851
3851
}
3852
3852
 
3853
 
Item_cond::Item_cond(THD *thd, Item_cond *item)
 
3853
Item_cond::Item_cond(Session *thd, Item_cond *item)
3854
3854
  :Item_bool_func(thd, item),
3855
3855
   abort_on_null(item->abort_on_null),
3856
3856
   and_tables_cache(item->and_tables_cache)
3861
3861
}
3862
3862
 
3863
3863
 
3864
 
void Item_cond::copy_andor_arguments(THD *thd, Item_cond *item)
 
3864
void Item_cond::copy_andor_arguments(Session *thd, Item_cond *item)
3865
3865
{
3866
3866
  List_iterator_fast<Item> li(item->list);
3867
3867
  while (Item *it= li++)
3870
3870
 
3871
3871
 
3872
3872
bool
3873
 
Item_cond::fix_fields(THD *thd, Item **ref __attribute__((unused)))
 
3873
Item_cond::fix_fields(Session *thd, Item **ref __attribute__((unused)))
3874
3874
{
3875
3875
  assert(fixed == 0);
3876
3876
  List_iterator<Item> li(list);
4019
4019
      return 0;
4020
4020
 
4021
4021
    /*
4022
 
      THD::change_item_tree() should be called only if the tree was
 
4022
      Session::change_item_tree() should be called only if the tree was
4023
4023
      really transformed, i.e. when a new item has been created.
4024
4024
      Otherwise we'll be allocating a lot of unnecessary memory for
4025
4025
      change records at each execution.
4118
4118
    that have or refer (HAVING) to a SUM expression.
4119
4119
*/
4120
4120
 
4121
 
void Item_cond::split_sum_func(THD *thd, Item **ref_pointer_array,
 
4121
void Item_cond::split_sum_func(Session *thd, Item **ref_pointer_array,
4122
4122
                               List<Item> &fields)
4123
4123
{
4124
4124
  List_iterator<Item> li(list);
4169
4169
}
4170
4170
 
4171
4171
 
4172
 
void Item_cond::neg_arguments(THD *thd)
 
4172
void Item_cond::neg_arguments(Session *thd)
4173
4173
{
4174
4174
  List_iterator<Item> li(list);
4175
4175
  Item *item;
4399
4399
}
4400
4400
 
4401
4401
 
4402
 
bool Item_func_like::fix_fields(THD *thd, Item **ref)
 
4402
bool Item_func_like::fix_fields(Session *thd, Item **ref)
4403
4403
{
4404
4404
  assert(fixed == 0);
4405
4405
  if (Item_bool_func2::fix_fields(thd, ref) ||
4790
4790
    NULL if we cannot apply NOT transformation (see Item::neg_transformer()).
4791
4791
*/
4792
4792
 
4793
 
Item *Item_func_not::neg_transformer(THD *thd __attribute__((unused)))  /* NOT(x)  ->  x */
 
4793
Item *Item_func_not::neg_transformer(Session *thd __attribute__((unused)))      /* NOT(x)  ->  x */
4794
4794
{
4795
4795
  return args[0];
4796
4796
}
4797
4797
 
4798
4798
 
4799
 
Item *Item_bool_rowready_func2::neg_transformer(THD *thd __attribute__((unused)))
 
4799
Item *Item_bool_rowready_func2::neg_transformer(Session *thd __attribute__((unused)))
4800
4800
{
4801
4801
  Item *item= negated_item();
4802
4802
  return item;
4806
4806
/**
4807
4807
  a IS NULL  ->  a IS NOT NULL.
4808
4808
*/
4809
 
Item *Item_func_isnull::neg_transformer(THD *thd __attribute__((unused)))
 
4809
Item *Item_func_isnull::neg_transformer(Session *thd __attribute__((unused)))
4810
4810
{
4811
4811
  Item *item= new Item_func_isnotnull(args[0]);
4812
4812
  return item;
4816
4816
/**
4817
4817
  a IS NOT NULL  ->  a IS NULL.
4818
4818
*/
4819
 
Item *Item_func_isnotnull::neg_transformer(THD *thd __attribute__((unused)))
 
4819
Item *Item_func_isnotnull::neg_transformer(Session *thd __attribute__((unused)))
4820
4820
{
4821
4821
  Item *item= new Item_func_isnull(args[0]);
4822
4822
  return item;
4823
4823
}
4824
4824
 
4825
4825
 
4826
 
Item *Item_cond_and::neg_transformer(THD *thd)  /* NOT(a AND b AND ...)  -> */
 
4826
Item *Item_cond_and::neg_transformer(Session *thd)      /* NOT(a AND b AND ...)  -> */
4827
4827
                                        /* NOT a OR NOT b OR ... */
4828
4828
{
4829
4829
  neg_arguments(thd);
4832
4832
}
4833
4833
 
4834
4834
 
4835
 
Item *Item_cond_or::neg_transformer(THD *thd)   /* NOT(a OR b OR ...)  -> */
 
4835
Item *Item_cond_or::neg_transformer(Session *thd)       /* NOT(a OR b OR ...)  -> */
4836
4836
                                        /* NOT a AND NOT b AND ... */
4837
4837
{
4838
4838
  neg_arguments(thd);
4841
4841
}
4842
4842
 
4843
4843
 
4844
 
Item *Item_func_nop_all::neg_transformer(THD *thd __attribute__((unused)))
 
4844
Item *Item_func_nop_all::neg_transformer(Session *thd __attribute__((unused)))
4845
4845
{
4846
4846
  /* "NOT (e $cmp$ ANY (SELECT ...)) -> e $rev_cmp$" ALL (SELECT ...) */
4847
4847
  Item_func_not_all *new_item= new Item_func_not_all(args[0]);
4852
4852
  return new_item;
4853
4853
}
4854
4854
 
4855
 
Item *Item_func_not_all::neg_transformer(THD *thd __attribute__((unused)))
 
4855
Item *Item_func_not_all::neg_transformer(Session *thd __attribute__((unused)))
4856
4856
{
4857
4857
  /* "NOT (e $cmp$ ALL (SELECT ...)) -> e $rev_cmp$" ANY (SELECT ...) */
4858
4858
  Item_func_nop_all *new_item= new Item_func_nop_all(args[0]);
5092
5092
  }
5093
5093
}
5094
5094
 
5095
 
bool Item_equal::fix_fields(THD *thd __attribute__((unused)), Item **ref __attribute__((unused)))
 
5095
bool Item_equal::fix_fields(Session *thd __attribute__((unused)), Item **ref __attribute__((unused)))
5096
5096
{
5097
5097
  List_iterator_fast<Item_field> li(fields);
5098
5098
  Item *item;
5179
5179
      return 0;
5180
5180
 
5181
5181
    /*
5182
 
      THD::change_item_tree() should be called only if the tree was
 
5182
      Session::change_item_tree() should be called only if the tree was
5183
5183
      really transformed, i.e. when a new item has been created.
5184
5184
      Otherwise we'll be allocating a lot of unnecessary memory for
5185
5185
      change records at each execution.