~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.cc

move functions from item.cc/item.h to item directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
965
965
  }
966
966
}
967
967
 
968
 
/****************************************************************************
969
 
  Item_copy_string
970
 
****************************************************************************/
971
 
 
972
 
void Item_copy_string::copy()
973
 
{
974
 
  String *res=item->val_str(&str_value);
975
 
  if (res && res != &str_value)
976
 
    str_value.copy(*res);
977
 
  null_value=item->null_value;
978
 
}
979
 
 
980
 
/* ARGSUSED */
981
 
String *Item_copy_string::val_str(String *)
982
 
{
983
 
  // Item_copy_string is used without fix_fields call
984
 
  if (null_value)
985
 
    return (String*) 0;
986
 
  return &str_value;
987
 
}
988
 
 
989
 
 
990
 
my_decimal *Item_copy_string::val_decimal(my_decimal *decimal_value)
991
 
{
992
 
  // Item_copy_string is used without fix_fields call
993
 
  if (null_value)
994
 
    return 0;
995
 
  string2my_decimal(E_DEC_FATAL_ERROR, &str_value, decimal_value);
996
 
  return (decimal_value);
997
 
}
998
 
 
999
 
 
1000
968
/*
1001
969
  Functions to convert item to field (for send_fields)
1002
970
*/
1011
979
  return false;
1012
980
}
1013
981
 
1014
 
double Item_ref_null_helper::val_real()
1015
 
{
1016
 
  assert(fixed == 1);
1017
 
  double tmp= (*ref)->val_result();
1018
 
  owner->was_null|= null_value= (*ref)->null_value;
1019
 
  return tmp;
1020
 
}
1021
 
 
1022
 
 
1023
 
int64_t Item_ref_null_helper::val_int()
1024
 
{
1025
 
  assert(fixed == 1);
1026
 
  int64_t tmp= (*ref)->val_int_result();
1027
 
  owner->was_null|= null_value= (*ref)->null_value;
1028
 
  return tmp;
1029
 
}
1030
 
 
1031
 
 
1032
 
my_decimal *Item_ref_null_helper::val_decimal(my_decimal *decimal_value)
1033
 
{
1034
 
  assert(fixed == 1);
1035
 
  my_decimal *val= (*ref)->val_decimal_result(decimal_value);
1036
 
  owner->was_null|= null_value= (*ref)->null_value;
1037
 
  return val;
1038
 
}
1039
 
 
1040
 
 
1041
 
bool Item_ref_null_helper::val_bool()
1042
 
{
1043
 
  assert(fixed == 1);
1044
 
  bool val= (*ref)->val_bool_result();
1045
 
  owner->was_null|= null_value= (*ref)->null_value;
1046
 
  return val;
1047
 
}
1048
 
 
1049
 
 
1050
 
String* Item_ref_null_helper::val_str(String* s)
1051
 
{
1052
 
  assert(fixed == 1);
1053
 
  String* tmp= (*ref)->str_result(s);
1054
 
  owner->was_null|= null_value= (*ref)->null_value;
1055
 
  return tmp;
1056
 
}
1057
 
 
1058
 
 
1059
 
bool Item_ref_null_helper::get_date(DRIZZLE_TIME *ltime, uint32_t fuzzydate)
1060
 
{
1061
 
  return (owner->was_null|= null_value= (*ref)->get_date(ltime, fuzzydate));
1062
 
}
1063
 
 
1064
982
 
1065
983
/**
1066
984
  Mark item and SELECT_LEXs as dependent if item was resolved in
1674
1592
}
1675
1593
 
1676
1594
 
1677
 
Item *Item_int_with_ref::clone_item()
1678
 
{
1679
 
  assert(ref->const_item());
1680
 
  /*
1681
 
    We need to evaluate the constant to make sure it works with
1682
 
    parameter markers.
1683
 
  */
1684
 
  return (ref->unsigned_flag ?
1685
 
          new Item_uint(ref->name, ref->val_int(), ref->max_length) :
1686
 
          new Item_int(ref->name, ref->val_int(), ref->max_length));
1687
 
}
1688
 
 
1689
 
 
1690
1595
/**
1691
1596
  This is only called from items that is not of type item_field.
1692
1597
*/
1761
1666
}
1762
1667
 
1763
1668
 
1764
 
void Item_ref_null_helper::print(String *str, enum_query_type query_type)
1765
 
{
1766
 
  str->append(STRING_WITH_LEN("<ref_null_helper>("));
1767
 
  if (ref)
1768
 
    (*ref)->print(str, query_type);
1769
 
  else
1770
 
    str->append('?');
1771
 
  str->append(')');
1772
 
}
1773
 
 
1774
 
 
1775
 
double Item_direct_ref::val_real()
1776
 
{
1777
 
  double tmp=(*ref)->val_real();
1778
 
  null_value=(*ref)->null_value;
1779
 
  return tmp;
1780
 
}
1781
 
 
1782
 
 
1783
 
int64_t Item_direct_ref::val_int()
1784
 
{
1785
 
  int64_t tmp=(*ref)->val_int();
1786
 
  null_value=(*ref)->null_value;
1787
 
  return tmp;
1788
 
}
1789
 
 
1790
 
 
1791
 
String *Item_direct_ref::val_str(String* tmp)
1792
 
{
1793
 
  tmp=(*ref)->val_str(tmp);
1794
 
  null_value=(*ref)->null_value;
1795
 
  return tmp;
1796
 
}
1797
 
 
1798
 
 
1799
 
my_decimal *Item_direct_ref::val_decimal(my_decimal *decimal_value)
1800
 
{
1801
 
  my_decimal *tmp= (*ref)->val_decimal(decimal_value);
1802
 
  null_value=(*ref)->null_value;
1803
 
  return tmp;
1804
 
}
1805
 
 
1806
 
 
1807
 
bool Item_direct_ref::val_bool()
1808
 
{
1809
 
  bool tmp= (*ref)->val_bool();
1810
 
  null_value=(*ref)->null_value;
1811
 
  return tmp;
1812
 
}
1813
 
 
1814
 
 
1815
 
bool Item_direct_ref::is_null()
1816
 
{
1817
 
  return (*ref)->is_null();
1818
 
}
1819
 
 
1820
 
 
1821
 
bool Item_direct_ref::get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
1822
 
{
1823
 
  return (null_value=(*ref)->get_date(ltime,fuzzydate));
1824
 
}
1825
 
 
1826
 
/*
1827
 
  Prepare referenced outer field then call usual Item_direct_ref::fix_fields
1828
 
 
1829
 
  SYNOPSIS
1830
 
    Item_outer_ref::fix_fields()
1831
 
    session         thread handler
1832
 
    reference   reference on reference where this item stored
1833
 
 
1834
 
  RETURN
1835
 
    false   OK
1836
 
    true    Error
1837
 
*/
1838
 
 
1839
 
bool Item_outer_ref::fix_fields(Session *session, Item **reference)
1840
 
{
1841
 
  bool err;
1842
 
  /* outer_ref->check_cols() will be made in Item_direct_ref::fix_fields */
1843
 
  if ((*ref) && !(*ref)->fixed && ((*ref)->fix_fields(session, reference)))
1844
 
    return true;
1845
 
  err= Item_direct_ref::fix_fields(session, reference);
1846
 
  if (!outer_ref)
1847
 
    outer_ref= *ref;
1848
 
  if ((*ref)->type() == Item::FIELD_ITEM)
1849
 
    table_name= ((Item_field*)outer_ref)->table_name;
1850
 
  return err;
1851
 
}
1852
 
 
1853
 
void Item_outer_ref::fix_after_pullout(st_select_lex *new_parent, Item **ref)
1854
 
{
1855
 
  if (depended_from == new_parent)
1856
 
  {
1857
 
    *ref= outer_ref;
1858
 
    outer_ref->fix_after_pullout(new_parent, ref);
1859
 
  }
1860
 
}
1861
 
 
1862
 
 
1863
1669
bool Item_default_value::eq(const Item *item, bool binary_cmp) const
1864
1670
{
1865
1671
  return item->type() == DEFAULT_VALUE_ITEM &&