summaryrefslogtreecommitdiff
path: root/sql/item_subselect.h
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2011-02-15 20:29:57 +0300
committerSergey Petrunya <psergey@askmonty.org>2011-02-15 20:29:57 +0300
commite4325ff60b234c9bc5e79cebead7376b59b3dcc5 (patch)
tree226c56878600a348a2bdd8c6b576c6e15627291d /sql/item_subselect.h
parent6c9076256fd2e1a07457add0e20207a6c64480bd (diff)
parent7b9bcaa5ecdc6a2d784f092fd4b56eb84bac7f60 (diff)
downloadmariadb-git-e4325ff60b234c9bc5e79cebead7376b59b3dcc5.tar.gz
MWL#90: Subqueries: Inside-out execution for materialized non-sj subqueries
- Merge with 5.3 (3)
Diffstat (limited to 'sql/item_subselect.h')
-rw-r--r--sql/item_subselect.h32
1 files changed, 26 insertions, 6 deletions
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 8d590bc4273..a0db43fe9fe 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -46,16 +46,17 @@ protected:
< child_join->prepare
< engine->prepare
*ref= substitution;
+ substitution= NULL;
< Item_subselect::fix_fields
*/
- Item *substitution;
public:
+ Item *substitution;
/* unit of subquery */
st_select_lex_unit *unit;
-protected:
Item *expr_cache;
/* engine that perform execution of subselect (single select or union) */
subselect_engine *engine;
+protected:
/* old engine if engine was changed */
subselect_engine *old_engine;
/* cache of used external tables */
@@ -148,6 +149,7 @@ public:
bool mark_as_dependent(THD *thd, st_select_lex *select, Item *item);
void fix_after_pullout(st_select_lex *new_parent, Item **ref);
void recalc_used_tables(st_select_lex *new_parent, bool after_pullout);
+ virtual int optimize();
virtual bool exec();
virtual void fix_length_and_dec();
table_map used_tables() const;
@@ -351,7 +353,9 @@ protected:
all JOIN in UNION
*/
Item *expr;
+public:
Item_in_optimizer *optimizer;
+protected:
bool was_null;
bool abort_on_null;
public:
@@ -397,6 +401,16 @@ public:
};
enum_exec_method exec_method;
+ /*
+ TRUE<=>this is a flattenable semi-join, false overwise.
+ */
+ bool is_flattenable_semijoin;
+
+ /*
+ Cost to populate the temporary table (set on if-needed basis).
+ */
+ //double startup_cost;
+
bool *get_cond_guard(int i)
{
return pushed_cond_guards ? pushed_cond_guards + i : NULL;
@@ -446,7 +460,7 @@ public:
bool fix_fields(THD *thd, Item **ref);
void fix_after_pullout(st_select_lex *new_parent, Item **ref);
void update_used_tables();
- bool setup_engine();
+ bool setup_engine(bool dont_switch_arena);
bool init_left_expr_cache();
/* Inform 'this' that it was computed, and contains a valid result. */
void set_first_execution() { if (first_execution) first_execution= FALSE; }
@@ -522,6 +536,7 @@ public:
THD * get_thd() { return thd; }
virtual int prepare()= 0;
virtual void fix_length_and_dec(Item_cache** row)= 0;
+ virtual int optimize() { DBUG_ASSERT(0); return 0; }
/*
Execute the engine
@@ -752,7 +767,7 @@ inline bool Item_subselect::is_uncacheable() const
class subselect_hash_sj_engine : public subselect_engine
{
-protected:
+public:
/* The table into which the subquery is materialized. */
TABLE *tmp_table;
/* TRUE if the subquery was materialized into a temp table. */
@@ -764,14 +779,16 @@ protected:
of subselect_single_select_engine::[prepare | cols].
*/
subselect_single_select_engine *materialize_engine;
+protected:
/* The engine used to compute the IN predicate. */
subselect_engine *lookup_engine;
/*
QEP to execute the subquery and materialize its result into a
temporary table. Created during the first call to exec().
*/
+public:
JOIN *materialize_join;
-
+protected:
/* Keyparts of the only non-NULL composite index in a rowid merge. */
MY_BITMAP non_null_key_parts;
/* Keyparts of the single column indexes with NULL, one keypart per index. */
@@ -784,7 +801,9 @@ protected:
IN results because index lookups sometimes match values that are actually
not equal to the search key in SQL terms.
*/
+public:
Item_cond_and *semi_join_conds;
+protected:
/* Possible execution strategies that can be used to compute hash semi-join.*/
enum exec_strategy {
UNDEFINED,
@@ -818,10 +837,11 @@ public:
{}
~subselect_hash_sj_engine();
- bool init_permanent(List<Item> *tmp_columns);
+ bool init_permanent(List<Item> *tmp_columns, uint subquery_id);
bool init_runtime();
void cleanup();
int prepare() { return 0; } /* Override virtual function in base class. */
+ int optimize();
int exec();
virtual void print(String *str, enum_query_type query_type);
uint cols()