summaryrefslogtreecommitdiff
path: root/sql/item_subselect.h
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2011-12-14 04:39:29 +0400
committerSergey Petrunya <psergey@askmonty.org>2011-12-14 04:39:29 +0400
commit05e0127478c39437be53668f0db1d674071e2485 (patch)
tree9a4688036e314f9c4de1c18dfbcd01dee433e9b0 /sql/item_subselect.h
parentfc9d34cabf06038f930db356d53ed76dab5fdf0d (diff)
downloadmariadb-git-05e0127478c39437be53668f0db1d674071e2485.tar.gz
BUG#901506: Crash in TABLE_LIST::print on EXPLAIN EXTENDED
- Let JTBM optimization code handle the case where the subquery is degenerate and doesn't have a join query plan. Regular materialization would fall back to IN->EXISTS for such cases. Semi-Join materialization does not have such option, instead we introduce and use "constant JTBM join tabs".
Diffstat (limited to 'sql/item_subselect.h')
-rw-r--r--sql/item_subselect.h40
1 files changed, 38 insertions, 2 deletions
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 880b505a8d1..fad951dd80f 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -446,11 +446,44 @@ public:
Same as above, but they also allow to scan the materialized table.
*/
bool sjm_scan_allowed;
+
+ /*
+ JoinTaB Materialization (JTBM) members
+ */
+
+ /*
+ TRUE <=> This subselect has been converted into non-mergeable semi-join
+ table.
+ */
+ bool is_jtbm_merged;
+
+ /* (Applicable if is_jtbm_merged==TRUE) Time required to run the materialized join */
double jtbm_read_time;
+
+ /* (Applicable if is_jtbm_merged==TRUE) Number of output rows in materialized join */
double jtbm_record_count;
- bool is_jtbm_merged;
- bool is_jtbm_const_tab;
+
+ /*
+ (Applicable if is_jtbm_merged==TRUE) TRUE <=> The materialized subselect is
+ a degenerate subselect which produces 0 or 1 rows, which we know at
+ optimization phase.
+ Examples:
+ 1. subquery has "Impossible WHERE":
+
+ SELECT * FROM ot WHERE ot.column IN (SELECT it.col FROM it WHERE 2 > 3)
+
+ 2. Subquery produces one row which opt_sum.cc is able to get with one lookup:
+ SELECT * FROM ot WHERE ot.column IN (SELECT MAX(it.key_col) FROM it)
+ */
+ bool is_jtbm_const_tab;
+
+ /*
+ (Applicable if is_jtbm_const_tab==TRUE) Whether the subquery has produced
+ the row (or not)
+ */
+ bool jtbm_const_row_found;
+
/*
TRUE<=>this is a flattenable semi-join, false overwise.
*/
@@ -741,6 +774,9 @@ public:
friend class subselect_hash_sj_engine;
friend class Item_in_subselect;
+ friend bool setup_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list,
+ Item **join_where);
+
};