606
612
st_select_lex *select);
608
class Item_int :public Item_num
612
Item_int(int32_t i,uint32_t length= MY_INT32_NUM_DECIMAL_DIGITS)
614
{ max_length=length; fixed= 1; }
615
Item_int(int64_t i,uint32_t length= MY_INT64_NUM_DECIMAL_DIGITS)
617
{ max_length=length; fixed= 1; }
618
Item_int(uint64_t i, uint32_t length= MY_INT64_NUM_DECIMAL_DIGITS)
620
{ max_length=length; fixed= 1; unsigned_flag= 1; }
621
Item_int(const char *str_arg,int64_t i,uint32_t length) :value(i)
622
{ max_length=length; name=(char*) str_arg; fixed= 1; }
623
Item_int(const char *str_arg, uint32_t length=64);
624
enum Type type() const { return INT_ITEM; }
625
enum Item_result result_type () const { return INT_RESULT; }
626
enum_field_types field_type() const { return DRIZZLE_TYPE_LONGLONG; }
627
int64_t val_int() { assert(fixed == 1); return value; }
628
double val_real() { assert(fixed == 1); return (double) value; }
629
my_decimal *val_decimal(my_decimal *);
630
String *val_str(String*);
631
int save_in_field(Field *field, bool no_conversions);
632
bool basic_const_item() const { return 1; }
633
Item *clone_item() { return new Item_int(name,value,max_length); }
634
virtual void print(String *str, enum_query_type query_type);
635
Item_num *neg() { value= -value; return this; }
636
uint32_t decimal_precision() const
637
{ return (uint)(max_length - test(value < 0)); }
638
bool eq(const Item *, bool binary_cmp) const;
639
bool check_vcol_func_processor(unsigned char *)
644
class Item_uint :public Item_int
647
Item_uint(const char *str_arg, uint32_t length);
648
Item_uint(uint64_t i) :Item_int((uint64_t) i, 10) {}
649
Item_uint(const char *str_arg, int64_t i, uint32_t length);
651
{ assert(fixed == 1); return uint64_t2double((uint64_t)value); }
652
String *val_str(String*);
653
Item *clone_item() { return new Item_uint(name, value, max_length); }
654
int save_in_field(Field *field, bool no_conversions);
655
virtual void print(String *str, enum_query_type query_type);
657
uint32_t decimal_precision() const { return max_length; }
658
bool check_vcol_func_processor(unsigned char *)
663
/* decimal (fixed point) constant */
664
class Item_decimal :public Item_num
667
my_decimal decimal_value;
669
Item_decimal(const char *str_arg, uint32_t length, const CHARSET_INFO * const charset);
670
Item_decimal(const char *str, const my_decimal *val_arg,
671
uint32_t decimal_par, uint32_t length);
672
Item_decimal(my_decimal *value_par);
673
Item_decimal(int64_t val, bool unsig);
674
Item_decimal(double val, int precision, int scale);
675
Item_decimal(const unsigned char *bin, int precision, int scale);
677
enum Type type() const { return DECIMAL_ITEM; }
678
enum Item_result result_type () const { return DECIMAL_RESULT; }
679
enum_field_types field_type() const { return DRIZZLE_TYPE_NEWDECIMAL; }
682
String *val_str(String*);
683
my_decimal *val_decimal(my_decimal *)
684
{ return &decimal_value; }
685
int save_in_field(Field *field, bool no_conversions);
686
bool basic_const_item() const { return 1; }
689
return new Item_decimal(name, &decimal_value, decimals, max_length);
691
virtual void print(String *str, enum_query_type query_type);
694
my_decimal_neg(&decimal_value);
695
unsigned_flag= !decimal_value.sign();
698
uint32_t decimal_precision() const { return decimal_value.precision(); }
699
bool eq(const Item *, bool binary_cmp) const;
700
void set_decimal_value(my_decimal *value_par);
701
bool check_vcol_func_processor(unsigned char *)
706
class Item_float :public Item_num
711
// Item_real() :value(0) {}
712
Item_float(const char *str_arg, uint32_t length);
713
Item_float(const char *str,double val_arg,uint32_t decimal_par,uint32_t length)
716
presentation= name=(char*) str;
717
decimals=(uint8_t) decimal_par;
721
Item_float(double value_par, uint32_t decimal_par) :presentation(0), value(value_par)
723
decimals= (uint8_t) decimal_par;
726
int save_in_field(Field *field, bool no_conversions);
727
enum Type type() const { return REAL_ITEM; }
728
enum_field_types field_type() const { return DRIZZLE_TYPE_DOUBLE; }
729
double val_real() { assert(fixed == 1); return value; }
731
String *val_str(String*);
732
my_decimal *val_decimal(my_decimal *);
733
bool basic_const_item() const { return 1; }
735
{ return new Item_float(name, value, decimals, max_length); }
736
Item_num *neg() { value= -value; return this; }
737
virtual void print(String *str, enum_query_type query_type);
738
bool eq(const Item *, bool binary_cmp) const;
742
class Item_static_float_func :public Item_float
744
const char *func_name;
746
Item_static_float_func(const char *str, double val_arg, uint32_t decimal_par,
748
:Item_float(NULL, val_arg, decimal_par, length), func_name(str)
751
virtual inline void print(String *str, enum_query_type)
753
str->append(func_name);
756
Item *safe_charset_converter(const CHARSET_INFO * const tocs);
757
bool check_vcol_func_processor(unsigned char *)
762
class Item_string :public Item_basic_constant
765
Item_string(const char *str,uint32_t length,
766
const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE,
767
uint32_t repertoire= MY_REPERTOIRE_UNICODE30)
768
: m_cs_specified(false)
770
str_value.set_or_copy_aligned(str, length, cs);
771
collation.set(cs, dv, repertoire);
773
We have to have a different max_length than 'length' here to
774
ensure that we get the right length if we do use the item
775
to create a new table. In this case max_length must be the maximum
776
number of chars for a string of this type because we in Create_field::
777
divide the max_length with mbmaxlen).
779
max_length= str_value.numchars()*cs->mbmaxlen;
780
set_name(str, length, cs);
781
decimals=NOT_FIXED_DEC;
782
// it is constant => can be used without fix_fields (and frequently used)
785
/* Just create an item and do not fill string representation */
786
Item_string(const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE)
787
: m_cs_specified(false)
789
collation.set(cs, dv);
791
set_name(NULL, 0, cs);
792
decimals= NOT_FIXED_DEC;
795
Item_string(const char *name_par, const char *str, uint32_t length,
796
const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE,
797
uint32_t repertoire= MY_REPERTOIRE_UNICODE30)
798
: m_cs_specified(false)
800
str_value.set_or_copy_aligned(str, length, cs);
801
collation.set(cs, dv, repertoire);
802
max_length= str_value.numchars()*cs->mbmaxlen;
803
set_name(name_par, 0, cs);
804
decimals=NOT_FIXED_DEC;
805
// it is constant => can be used without fix_fields (and frequently used)
808
void set_repertoire_from_value()
810
collation.repertoire= my_string_repertoire(str_value.charset(),
814
enum Type type() const { return STRING_ITEM; }
817
String *val_str(String*)
820
return (String*) &str_value;
822
my_decimal *val_decimal(my_decimal *);
823
int save_in_field(Field *field, bool no_conversions);
824
enum Item_result result_type () const { return STRING_RESULT; }
825
enum_field_types field_type() const { return DRIZZLE_TYPE_VARCHAR; }
826
bool basic_const_item() const { return 1; }
827
bool eq(const Item *item, bool binary_cmp) const;
830
return new Item_string(name, str_value.ptr(),
831
str_value.length(), collation.collation);
833
Item *safe_charset_converter(const CHARSET_INFO * const tocs);
834
inline void append(char *str, uint32_t length)
836
str_value.append(str, length);
837
max_length= str_value.numchars() * collation.collation->mbmaxlen;
839
virtual void print(String *str, enum_query_type query_type);
842
Return true if character-set-introducer was explicitly specified in the
843
original query for this item (text literal).
845
This operation is to be called from Item_string::print(). The idea is
846
that when a query is generated (re-constructed) from the Item-tree,
847
character-set-introducers should appear only for those literals, where
848
they were explicitly specified by the user. Otherwise, that may lead to
849
loss collation information (character set introducers implies default
850
collation for the literal).
852
Basically, that makes sense only for views and hopefully will be gone
853
one day when we start using original query as a view definition.
855
@return This operation returns the value of m_cs_specified attribute.
856
@retval true if character set introducer was explicitly specified in
858
@retval false otherwise.
860
inline bool is_cs_specified() const
862
return m_cs_specified;
866
Set the value of m_cs_specified attribute.
868
m_cs_specified attribute shows whether character-set-introducer was
869
explicitly specified in the original query for this text literal or
870
not. The attribute makes sense (is used) only for views.
872
This operation is to be called from the parser during parsing an input
875
inline void set_cs_specified(bool cs_specified)
877
m_cs_specified= cs_specified;
879
bool check_vcol_func_processor(unsigned char *)
887
class Item_static_string_func :public Item_string
889
const char *func_name;
891
Item_static_string_func(const char *name_par, const char *str, uint32_t length,
892
const CHARSET_INFO * const cs,
893
Derivation dv= DERIVATION_COERCIBLE)
894
:Item_string(NULL, str, length, cs, dv), func_name(name_par)
896
Item *safe_charset_converter(const CHARSET_INFO * const tocs);
898
virtual inline void print(String *str, enum_query_type)
900
str->append(func_name);
902
bool check_vcol_func_processor(unsigned char *)
907
/* for show tables */
908
class Item_return_date_time :public Item_string
910
enum_field_types date_time_field_type;
912
Item_return_date_time(const char *name_arg, enum_field_types field_type_arg)
913
:Item_string(name_arg, 0, &my_charset_bin),
914
date_time_field_type(field_type_arg)
916
enum_field_types field_type() const { return date_time_field_type; }
920
615
class Item_blob :public Item_string