summaryrefslogtreecommitdiff
path: root/sql/item.h
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2011-03-01 14:16:28 +0200
committerunknown <timour@askmonty.org>2011-03-01 14:16:28 +0200
commit7895c35874c76a88d7b1be609f06fbe6f266aab7 (patch)
treea1f57cf7c7bb129bb67d0aed5176d0bcaf4b7920 /sql/item.h
parent39616eb9ef974c69e73bcb80cd7e3c40228910fd (diff)
parent759d71eba1842bbde7b44fc42e1098590b136320 (diff)
downloadmariadb-git-7895c35874c76a88d7b1be609f06fbe6f266aab7.tar.gz
MWL#89
Merge MWL#89 with 5.3.
Diffstat (limited to 'sql/item.h')
-rw-r--r--sql/item.h64
1 files changed, 62 insertions, 2 deletions
diff --git a/sql/item.h b/sql/item.h
index 7c4b3c6e819..74f79c40bf0 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -491,6 +491,17 @@ typedef void (*Cond_traverser) (const Item *item, void *arg);
class Item {
Item(const Item &); /* Prevent use of these */
void operator=(Item &);
+ /**
+ The index in the JOIN::join_tab array of the JOIN_TAB this Item is attached
+ to. Items are attached (or 'pushed') to JOIN_TABs during optimization by the
+ make_cond_for_table procedure. During query execution, this item is
+ evaluated when the join loop reaches the corresponding JOIN_TAB.
+
+ If the value of join_tab_idx >= MAX_TABLES, this means that there is no
+ corresponding JOIN_TAB.
+ */
+ uint join_tab_idx;
+
public:
static void *operator new(size_t size) throw ()
{ return sql_alloc(size); }
@@ -507,7 +518,7 @@ public:
SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM, TYPE_HOLDER,
PARAM_ITEM, TRIGGER_FIELD_ITEM, DECIMAL_ITEM,
XPATH_NODESET, XPATH_NODESET_CMP,
- VIEW_FIXER_ITEM, EXPR_CACHE_ITEM};
+ VIEW_FIXER_ITEM, EXPR_CACHE_ITEM, UNKNOWN_ITEM};
enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };
@@ -608,7 +619,7 @@ public:
virtual Item_result cast_to_int_type() const { return result_type(); }
virtual enum_field_types string_field_type() const;
virtual enum_field_types field_type() const;
- virtual enum Type type() const =0;
+ virtual enum Type type() const { return UNKNOWN_ITEM; };
/*
Return information about function monotonicity. See comment for
@@ -957,6 +968,8 @@ public:
virtual bool register_field_in_read_map(uchar *arg) { return 0; }
virtual bool enumerate_field_refs_processor(uchar *arg) { return 0; }
virtual bool mark_as_eliminated_processor(uchar *arg) { return 0; }
+ virtual bool eliminate_subselect_processor(uchar *arg) { return 0; }
+ virtual bool set_fake_select_as_master_processor(uchar *arg) { return 0; }
/* To call bool function for all arguments */
struct bool_func_call_args
@@ -1186,6 +1199,16 @@ public:
Item* set_expr_cache(THD *thd, List<Item*> &depends_on);
virtual Item *get_cached_item() { return NULL; }
+ /**
+ Set the join tab index to the minimal (left-most) JOIN_TAB to which this
+ Item is attached.
+ */
+ virtual void set_join_tab_idx(uint join_tab_idx_arg)
+ {
+ if (join_tab_idx_arg < join_tab_idx)
+ join_tab_idx= join_tab_idx_arg;
+ }
+ virtual uint get_join_tab_idx() { return join_tab_idx; }
};
@@ -2596,6 +2619,43 @@ public:
virtual Ref_Type ref_type() { return DIRECT_REF; }
};
+
+/**
+ This class is the same as Item_direct_ref but created to wrap Item_ident
+ before fix_fields() call
+*/
+
+class Item_direct_ref_to_ident :public Item_direct_ref
+{
+ Item_ident *ident;
+public:
+ Item_direct_ref_to_ident(Item_ident *item)
+ :Item_direct_ref(item->context, (Item**)&item, item->table_name, item->field_name,
+ FALSE)
+ {
+ ident= item;
+ ref= (Item**)&ident;
+ }
+
+ bool fix_fields(THD *thd, Item **it)
+ {
+ DBUG_ASSERT(ident->type() == FIELD_ITEM || ident->type() == REF_ITEM);
+ if ((!ident->fixed && ident->fix_fields(thd, ref)) ||
+ ident->check_cols(1))
+ return TRUE;
+ set_properties();
+ return FALSE;
+ }
+
+ virtual void print(String *str, enum_query_type query_type)
+ { ident->print(str, query_type); }
+
+ virtual Item* transform(Item_transformer transformer, uchar *arg);
+ virtual Item* compile(Item_analyzer analyzer, uchar **arg_p,
+ Item_transformer transformer, uchar *arg_t);
+};
+
+
class Expression_cache;
class Item_cache;