618
623
st_select_lex *select);
622
The same as Item_ref, but get value from val_* family of method to get
623
value of item on which it referred instead of result* family.
625
class Item_direct_ref :public Item_ref
628
Item_direct_ref(Name_resolution_context *context_arg, Item **item,
629
const char *table_name_arg,
630
const char *field_name_arg,
631
bool alias_name_used_arg= false)
632
:Item_ref(context_arg, item, table_name_arg,
633
field_name_arg, alias_name_used_arg)
635
/* Constructor need to process subselect with temporary tables (see Item) */
636
Item_direct_ref(Session *session, Item_direct_ref *item) : Item_ref(session, item) {}
640
String *val_str(String* tmp);
641
my_decimal *val_decimal(my_decimal *);
644
bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
645
virtual Ref_Type ref_type() { return DIRECT_REF; }
649
Class for outer fields.
650
An object of this class is created when the select where the outer field was
651
resolved is a grouping one. After it has been fixed the ref field will point
652
to either an Item_ref or an Item_direct_ref object which will be used to
654
See also comments for the fix_inner_refs() and the
655
Item_field::fix_outer_field() functions.
658
class Item_outer_ref :public Item_direct_ref
662
/* The aggregate function under which this outer ref is used, if any. */
663
Item_sum *in_sum_func;
665
true <=> that the outer_ref is already present in the select list
668
bool found_in_select_list;
669
Item_outer_ref(Name_resolution_context *context_arg,
670
Item_field *outer_field_arg)
671
:Item_direct_ref(context_arg, 0, outer_field_arg->table_name,
672
outer_field_arg->field_name),
673
outer_ref(outer_field_arg), in_sum_func(0),
674
found_in_select_list(0)
680
Item_outer_ref(Name_resolution_context *context_arg, Item **item,
681
const char *table_name_arg, const char *field_name_arg,
682
bool alias_name_used_arg)
683
:Item_direct_ref(context_arg, item, table_name_arg, field_name_arg,
684
alias_name_used_arg),
685
outer_ref(0), in_sum_func(0), found_in_select_list(1)
687
void save_in_result_field(bool)
689
outer_ref->save_org_in_field(result_field);
691
bool fix_fields(Session *, Item **);
692
void fix_after_pullout(st_select_lex *new_parent, Item **ref);
693
table_map used_tables() const
695
return (*ref)->const_item() ? 0 : OUTER_REF_TABLE_BIT;
697
virtual Ref_Type ref_type() { return OUTER_REF; }
703
An object of this class:
704
- Converts val_XXX() calls to ref->val_XXX_result() calls, like Item_ref.
705
- Sets owner->was_null=true if it has returned a NULL value from any
706
val_XXX() function. This allows to inject an Item_ref_null_helper
707
object into subquery and then check if the subquery has produced a row
711
class Item_ref_null_helper: public Item_ref
714
Item_in_subselect* owner;
716
Item_ref_null_helper(Name_resolution_context *context_arg,
717
Item_in_subselect* master, Item **item,
718
const char *table_name_arg, const char *field_name_arg)
719
:Item_ref(context_arg, item, table_name_arg, field_name_arg),
723
String* val_str(String* s);
724
my_decimal *val_decimal(my_decimal *);
726
bool get_date(DRIZZLE_TIME *ltime, uint32_t fuzzydate);
727
virtual void print(String *str, enum_query_type query_type);
729
we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
731
table_map used_tables() const
733
return (depended_from ?
734
OUTER_REF_TABLE_BIT :
735
(*ref)->used_tables() | RAND_TABLE_BIT);
740
The following class is used to optimize comparing of date and bigint columns
741
We need to save the original item ('ref') to be able to call
742
ref->save_in_field(). This is used to create index search keys.
744
An instance of Item_int_with_ref may have signed or unsigned integer value.
748
class Item_int_with_ref :public Item_int
752
Item_int_with_ref(int64_t i, Item *ref_arg, bool unsigned_arg) :
753
Item_int(i), ref(ref_arg)
755
unsigned_flag= unsigned_arg;
757
int save_in_field(Field *field, bool no_conversions)
759
return ref->save_in_field(field, no_conversions);
762
virtual Item *real_item() { return ref; }
766
class Item_copy_string :public Item
768
enum enum_field_types cached_field_type;
771
Item_copy_string(Item *i) :item(i)
773
null_value= maybe_null= item->maybe_null;
774
decimals=item->decimals;
775
max_length=item->max_length;
777
cached_field_type= item->field_type();
779
enum Type type() const { return COPY_STR_ITEM; }
780
enum Item_result result_type () const { return STRING_RESULT; }
781
enum_field_types field_type() const { return cached_field_type; }
786
return (null_value ? 0.0 :
787
my_strntod(str_value.charset(), (char*) str_value.ptr(),
788
str_value.length(), &end_not_used, &err_not_used));
793
return null_value ? 0 : my_strntoll(str_value.charset(),str_value.ptr(),
794
str_value.length(),10, (char**) 0,
797
String *val_str(String*);
798
my_decimal *val_decimal(my_decimal *);
799
void make_field(Send_field *field) { item->make_field(field); }
801
int save_in_field(Field *field, bool)
803
return save_str_value_in_field(field, &str_value);
805
table_map used_tables() const { return (table_map) 1L; }
806
bool const_item() const { return 0; }
807
bool is_null() { return null_value; }
809
class Item_default_value : public Item_field
813
Item_default_value(Name_resolution_context *context_arg)
814
:Item_field(context_arg, (const char *)NULL, (const char *)NULL,
817
Item_default_value(Name_resolution_context *context_arg, Item *a)
818
:Item_field(context_arg, (const char *)NULL, (const char *)NULL,
821
enum Type type() const { return DEFAULT_VALUE_ITEM; }
822
bool eq(const Item *item, bool binary_cmp) const;
823
bool fix_fields(Session *, Item **);
824
virtual void print(String *str, enum_query_type query_type);
825
int save_in_field(Field *field_arg, bool no_conversions);
826
table_map used_tables() const { return (table_map)0L; }
828
bool walk(Item_processor processor, bool walk_subquery, unsigned char *args)
830
return arg->walk(processor, walk_subquery, args) ||
831
(this->*processor)(args);
834
Item *transform(Item_transformer transformer, unsigned char *args);
838
628
Item_insert_value -- an implementation of VALUES() function.