~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/cmpfunc.cc

Fixed -Wmissing-declarations

Show diffs side-by-side

added added

removed removed

Lines of Context:
836
836
}
837
837
 
838
838
 
839
 
/*
840
 
  Retrieves correct TIME value from the given item.
841
 
 
842
 
  SYNOPSIS
843
 
    get_time_value()
844
 
    session                 thread handle
845
 
    item_arg   [in/out] item to retrieve TIME value from
846
 
    cache_arg  [in/out] pointer to place to store the cache item to
847
 
    warn_item  [in]     unused
848
 
    is_null    [out]    true <=> the item_arg is null
849
 
 
850
 
  DESCRIPTION
851
 
    Retrieves the correct TIME value from given item for comparison by the
852
 
    compare_datetime() function.
853
 
    If item's result can be compared as int64_t then its int value is used
854
 
    and a value returned by get_time function is used otherwise.
855
 
    If an item is a constant one then its value is cached and it isn't
856
 
    get parsed again. An Item_cache_int object is used for for cached values.
857
 
    It seamlessly substitutes the original item.  The cache item is marked as
858
 
    non-constant to prevent re-caching it again.
859
 
 
860
 
  RETURN
861
 
    obtained value
862
 
*/
863
 
 
864
 
uint64_t
865
 
get_time_value(Session *,
866
 
               Item ***item_arg, Item **cache_arg,
867
 
               Item *, bool *is_null)
868
 
{
869
 
  uint64_t value;
870
 
  Item *item= **item_arg;
871
 
  DRIZZLE_TIME ltime;
872
 
 
873
 
  if (item->result_as_int64_t())
874
 
  {
875
 
    value= item->val_int();
876
 
    *is_null= item->null_value;
877
 
  }
878
 
  else
879
 
  {
880
 
    *is_null= item->get_time(&ltime);
881
 
    value= !*is_null ? TIME_to_uint64_t_datetime(&ltime) : 0;
882
 
  }
883
 
  /*
884
 
    Do not cache GET_USER_VAR() function as its const_item() may return true
885
 
    for the current thread but it still may change during the execution.
886
 
  */
887
 
  if (item->const_item() && cache_arg && (item->type() != Item::FUNC_ITEM ||
888
 
      ((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC))
889
 
  {
890
 
    Item_cache_int *cache= new Item_cache_int();
891
 
    /* Mark the cache as non-const to prevent re-caching. */
892
 
    cache->set_used_tables(1);
893
 
    cache->store(item, value);
894
 
    *cache_arg= cache;
895
 
    *item_arg= cache_arg;
896
 
  }
897
 
  return value;
898
 
}
899
 
 
900
 
 
901
839
int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg,
902
840
                                        Item **a1, Item **a2,
903
841
                                        Item_result type)