diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2011-03-19 12:27:08 +0300 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2011-03-19 12:27:08 +0300 |
commit | 792c67ff618f7fa5edb39563b0ccf48b4a30db0f (patch) | |
tree | 404edda509690b2624ed968a9127b239fc218e6a | |
parent | 125bfa2ce722f909e7133c4e381b549bcdb3192c (diff) | |
download | mariadb-git-792c67ff618f7fa5edb39563b0ccf48b4a30db0f.tar.gz |
MWL#90: Address review feedback part #1
-rw-r--r-- | mysql-test/include/mix1.inc | 8 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/innodb_mysql.result | 8 | ||||
-rw-r--r-- | mysql-test/suite/innodb_plugin/r/innodb_mysql.result | 8 | ||||
-rw-r--r-- | sql/item_subselect.cc | 4 | ||||
-rw-r--r-- | sql/item_subselect.h | 5 | ||||
-rw-r--r-- | sql/sql_join_cache.h | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 10 | ||||
-rw-r--r-- | sql/sql_select.h | 4 | ||||
-rw-r--r-- | sql/sql_show.cc | 3 | ||||
-rw-r--r-- | sql/table.cc | 7 | ||||
-rw-r--r-- | sql/table.h | 6 |
11 files changed, 21 insertions, 44 deletions
diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index f12aa4b035e..5befcce2dd5 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -1532,12 +1532,6 @@ INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; ---echo # MariaDB note: ---echo # This will show 2 for table which has 5 rows. ---echo # This is because the access method employed is actually range access ---echo # which scans 2 records (yes, EXPLAIN displays it incorrectly). ---echo # our correct printing is an artifact of changing in select_describe() ---echo # from printing table->starts.records() to tab->records. EXPLAIN SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; @@ -1551,7 +1545,6 @@ INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; ---echo # See above "MariaDB note" EXPLAIN SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; @@ -1566,7 +1559,6 @@ INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; ---echo # See above "MariaDB note" EXPLAIN SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index e0b4645d621..193dff3c742 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -1735,12 +1735,6 @@ SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; 1 1 -# MariaDB note: -# This will show 2 for table which has 5 rows. -# This is because the access method employed is actually range access -# which scans 2 records (yes, EXPLAIN displays it incorrectly). -# our correct printing is an artifact of changing in select_describe() -# from printing table->starts.records() to tab->records. EXPLAIN SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; @@ -1755,7 +1749,6 @@ SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; 1 1 -# See above "MariaDB note" EXPLAIN SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; @@ -1771,7 +1764,6 @@ SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; 1 1 -# See above "MariaDB note" EXPLAIN SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; diff --git a/mysql-test/suite/innodb_plugin/r/innodb_mysql.result b/mysql-test/suite/innodb_plugin/r/innodb_mysql.result index d1e52605e5b..f75b286713a 100644 --- a/mysql-test/suite/innodb_plugin/r/innodb_mysql.result +++ b/mysql-test/suite/innodb_plugin/r/innodb_mysql.result @@ -1735,12 +1735,6 @@ SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; 1 1 -# MariaDB note: -# This will show 2 for table which has 5 rows. -# This is because the access method employed is actually range access -# which scans 2 records (yes, EXPLAIN displays it incorrectly). -# our correct printing is an artifact of changing in select_describe() -# from printing table->starts.records() to tab->records. EXPLAIN SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; @@ -1755,7 +1749,6 @@ SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; 1 1 -# See above "MariaDB note" EXPLAIN SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; @@ -1771,7 +1764,6 @@ SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; 1 1 -# See above "MariaDB note" EXPLAIN SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index c4289045b7e..324a331c32b 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1022,7 +1022,7 @@ Item_in_subselect::Item_in_subselect(Item * left_exp, st_select_lex *select_lex): Item_exists_subselect(), left_expr_cache(0), first_execution(TRUE), is_constant(FALSE), optimizer(0), pushed_cond_guards(NULL), - exec_method(NOT_TRANSFORMED), upper_item(0) + exec_method(NOT_TRANSFORMED), is_flattenable_semijoin(FALSE), upper_item(0) { DBUG_ENTER("Item_in_subselect::Item_in_subselect"); left_expr= left_exp; @@ -4080,7 +4080,7 @@ void subselect_hash_sj_engine::cleanup() int subselect_hash_sj_engine::optimize() { - int res= 0; + int res; SELECT_LEX *save_select= thd->lex->current_select; thd->lex->current_select= materialize_join->select_lex; res= materialize_join->optimize(); diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 772196a4ea3..39780708e60 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -406,11 +406,6 @@ public: */ 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; diff --git a/sql/sql_join_cache.h b/sql/sql_join_cache.h index 3b05d534064..d4628445d9c 100644 --- a/sql/sql_join_cache.h +++ b/sql/sql_join_cache.h @@ -650,8 +650,6 @@ public: buff= 0; } - // JOIN_TAB *get_next_table(JOIN_TAB *tab); - friend class JOIN_CACHE_HASHED; friend class JOIN_CACHE_BNL; friend class JOIN_CACHE_BKA; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 35988ea32d7..03b194cf744 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -242,9 +242,6 @@ static uint make_join_orderinfo(JOIN *join); Item_equal *find_item_equal(COND_EQUAL *cond_equal, Field *field, bool *inherited_fl); -JOIN_TAB *first_linear_tab(JOIN *join, bool after_const_tables); -JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, bool include_bush_roots); - /** This handles SELECT with and without UNION. */ @@ -8569,6 +8566,12 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) tab->sorted= sorted; sorted= 0; // only first must be sorted + + /* + We should not set tab->next_select for the last table in the + SMJ-nest, as setup_sj_materialization() has already set it to + end_sj_materialize. + */ if (!(tab->bush_root_tab && tab->bush_root_tab->bush_children->end == tab + 1)) { @@ -12910,7 +12913,6 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, i < field_count; i++, reg_field++, key_part_info++) { - key_part_info->null_bit=0; key_part_info->field= *reg_field; (*reg_field)->flags |= PART_KEY_FLAG; if (key_part_info == keyinfo->key_part) diff --git a/sql/sql_select.h b/sql/sql_select.h index 6c294b7af27..04048b89ca2 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -616,7 +616,6 @@ inline bool sj_is_materialize_strategy(uint strategy) return strategy >= SJ_OPT_MATERIALIZE; } - class JOIN_TAB_RANGE: public Sql_alloc { public: @@ -1050,6 +1049,9 @@ private: }; +JOIN_TAB *first_linear_tab(JOIN *join, bool after_const_tables); +JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, bool include_bush_roots); + typedef struct st_select_check { uint const_ref,reg_ref; } SELECT_CHECK; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 3f20e8afa36..1cc69ff1517 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -6584,9 +6584,6 @@ int make_schema_select(THD *thd, SELECT_LEX *sel, } -JOIN_TAB *first_linear_tab(JOIN *join, bool after_const_tables); -JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, bool include_bush_roots); - /* Fill temporary schema tables before SELECT diff --git a/sql/table.cc b/sql/table.cc index cd2cf51e2e0..94c82d4ff45 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -5335,6 +5335,13 @@ bool st_table::is_children_attached(void) } +/* + Return TRUE if the table is filled at execution phase + + (and so, the optimizer must not do anything that depends on the contents of + the table, like range analysis or constant table detection) +*/ + bool st_table::is_filled_at_execution() { return test(pos_in_table_list->jtbm_subselect); diff --git a/sql/table.h b/sql/table.h index d4dbc075bc5..a5bb37adccc 100644 --- a/sql/table.h +++ b/sql/table.h @@ -968,9 +968,9 @@ struct st_table { DBUG_VOID_RETURN; } /* - If TRUE, the table is filled at execution phase (and so, the optimizer - should not do things like range analysis or constant table detection on - it). + Returns TRUE if the table is filled at execution phase (and so, the + optimizer must not do anything that depends on the contents of the table, + like range analysis or constant table detection) */ bool is_filled_at_execution(); inline void disable_keyread() |