1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-08 14:22:09 +03:00

Revert "Merge pull request #1046 from drrtuy/MCOL-3769"

This has an uninit'd var warning from the compiler.  It fixes one test
and breaks 2 others in test001.

This reverts commit cf668897ef, reversing
changes made to 25084d0020.
This commit is contained in:
Patrick LeBlanc
2020-02-14 18:23:54 -05:00
parent eb60168cba
commit ae515a36b8
3 changed files with 33 additions and 42 deletions

View File

@@ -18,7 +18,7 @@
// Search simplify_joins() function in the server's code for detail // Search simplify_joins() function in the server's code for detail
COND * COND *
simplify_joins_cs(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top, simplify_joins_(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top,
bool in_sj) bool in_sj)
{ {
TABLE_LIST *table; TABLE_LIST *table;
@@ -26,7 +26,7 @@ simplify_joins_cs(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top
TABLE_LIST *prev_table= 0; TABLE_LIST *prev_table= 0;
List_iterator<TABLE_LIST> li(*join_list); List_iterator<TABLE_LIST> li(*join_list);
bool straight_join= MY_TEST(join->select_options & SELECT_STRAIGHT_JOIN); bool straight_join= MY_TEST(join->select_options & SELECT_STRAIGHT_JOIN);
DBUG_ENTER("simplify_joins_cs"); DBUG_ENTER("simplify_joins");
/* /*
Try to simplify join operations from join_list. Try to simplify join operations from join_list.
@@ -54,7 +54,7 @@ simplify_joins_cs(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top
the outer join is converted to an inner join and the outer join is converted to an inner join and
the corresponding on expression is added to E. the corresponding on expression is added to E.
*/ */
expr= simplify_joins_cs(join, &nested_join->join_list, expr= simplify_joins_(join, &nested_join->join_list,
expr, FALSE, in_sj || table->sj_on_expr); expr, FALSE, in_sj || table->sj_on_expr);
if (!table->prep_on_expr || expr != table->on_expr) if (!table->prep_on_expr || expr != table->on_expr)
@@ -67,7 +67,7 @@ simplify_joins_cs(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top
} }
nested_join->used_tables= (table_map) 0; nested_join->used_tables= (table_map) 0;
nested_join->not_null_tables=(table_map) 0; nested_join->not_null_tables=(table_map) 0;
conds= simplify_joins_cs(join, &nested_join->join_list, conds, top, conds= simplify_joins_(join, &nested_join->join_list, conds, top,
in_sj || table->sj_on_expr); in_sj || table->sj_on_expr);
used_tables= nested_join->used_tables; used_tables= nested_join->used_tables;
not_null_tables= nested_join->not_null_tables; not_null_tables= nested_join->not_null_tables;
@@ -241,5 +241,5 @@ simplify_joins_cs(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top
li.replace(repl_list); li.replace(repl_list);
} }
} }
DBUG_RETURN(conds); DBUG_RETURN(conds);
} }

View File

@@ -20,6 +20,7 @@
#include "idb_mysql.h" #include "idb_mysql.h"
COND *simplify_joins_cs(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top, bool in_sj); COND *simplify_joins_(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top, bool in_sj);
#endif #endif

View File

@@ -21,6 +21,7 @@
void check_walk(const Item* item, void* arg); void check_walk(const Item* item, void* arg);
void disable_indices_for_CEJ(THD *thd_) void disable_indices_for_CEJ(THD *thd_)
{ {
TABLE_LIST* global_list; TABLE_LIST* global_list;
@@ -41,7 +42,7 @@ void disable_indices_for_CEJ(THD *thd_)
} }
} }
bool optimize_unflattened_subqueries_cs(SELECT_LEX *select_lex) bool optimize_unflattened_subqueries_(SELECT_LEX *select_lex)
{ {
bool result = false; bool result = false;
TABLE_LIST *tbl; TABLE_LIST *tbl;
@@ -51,7 +52,7 @@ bool optimize_unflattened_subqueries_cs(SELECT_LEX *select_lex)
if (tbl->is_view_or_derived()) if (tbl->is_view_or_derived())
{ {
SELECT_LEX *dsl = tbl->derived->first_select(); SELECT_LEX *dsl = tbl->derived->first_select();
result = optimize_unflattened_subqueries_cs(dsl); result = optimize_unflattened_subqueries_(dsl);
} }
} }
@@ -545,7 +546,7 @@ create_columnstore_derived_handler(THD* thd, TABLE_LIST *derived)
//To search for CROSS JOIN-s we use tree invariant //To search for CROSS JOIN-s we use tree invariant
//G(V,E) where [V] = [E]+1 //G(V,E) where [V] = [E]+1
List<Item> join_preds_list; List<Item> join_preds_list;
TABLE_LIST *tl; TABLE_LIST *tl;
for (tl = sl->get_table_list(); !unsupported_feature && tl; tl = tl->next_local) for (tl = sl->get_table_list(); !unsupported_feature && tl; tl = tl->next_local)
{ {
Item_cond* where_icp= 0; Item_cond* where_icp= 0;
@@ -807,6 +808,7 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
return handler; return handler;
} }
bool unsupported_feature = false;
// Select_handler use the short-cut that effectively disables // Select_handler use the short-cut that effectively disables
// INSERT..SELECT, LDI, SELECT..INTO OUTFILE // INSERT..SELECT, LDI, SELECT..INTO OUTFILE
if ((thd->lex)->sql_command == SQLCOM_INSERT_SELECT if ((thd->lex)->sql_command == SQLCOM_INSERT_SELECT
@@ -814,41 +816,28 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
|| (thd->lex)->exchange) || (thd->lex)->exchange)
{ {
return handler; unsupported_feature = true;
} }
// We apply dedicated rewrites from MDB here so the data structures
// becomes dirty and CS has to raise an error in case of any problem.
bool unsupported_feature = false;
logging::Message::Args args;
JOIN *join= select_lex->join; JOIN *join= select_lex->join;
// Next block tries to execute the query using SH very early to fallback
// if execution fails.
if (!unsupported_feature)
{ {
disable_indices_for_CEJ(thd); disable_indices_for_CEJ(thd);
if (select_lex->handle_derived(thd->lex, DT_MERGE)) if (select_lex->handle_derived(thd->lex, DT_MERGE))
{ {
// set to true b/c of an error in handle_derived // early quit b/c of the error in handle_derived
unsupported_feature = true; return handler;
args.add("in handle_derived()");
} }
COND *conds; COND *conds = simplify_joins_(join, select_lex->join_list, join->conds, TRUE, FALSE);
if (!unsupported_feature)
{
conds = simplify_joins_cs(join, select_lex->join_list,
join->conds, TRUE, FALSE);
}
// MCOL-3747 IN-TO-EXISTS rewrite inside MDB didn't add // MCOL-3747 IN-TO-EXISTS rewrite inside MDB didn't add
// an equi-JOIN condition. // an equi-JOIN condition.
if (!unsupported_feature optimize_unflattened_subqueries_(select_lex);
&& optimize_unflattened_subqueries_cs(select_lex))
{
unsupported_feature = true;
args.add("in optimize_unflattened_subqueries_cs()");
}
if (!unsupported_feature && conds) if (conds)
{ {
#ifdef DEBUG_WALK_COND #ifdef DEBUG_WALK_COND
conds->traverse_cond(cal_impl_if::debug_walk, NULL, Item::POSTFIX); conds->traverse_cond(cal_impl_if::debug_walk, NULL, Item::POSTFIX);
@@ -856,6 +845,15 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
join->conds = conds; join->conds = conds;
} }
// Impossible HAVING or WHERE
// TODO replace with function call
if (unsupported_feature
|| select_lex->having_value == Item::COND_FALSE
|| select_lex->cond_value == Item::COND_FALSE )
{
unsupported_feature = true;
restore_optimizer_flags(thd);
}
} }
// Restore back the saved group_list // Restore back the saved group_list
@@ -876,7 +874,6 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
item_check(item, &unsupported_feature); item_check(item, &unsupported_feature);
if (unsupported_feature) if (unsupported_feature)
{ {
args.add("in item_check()");
break; break;
} }
} }
@@ -893,20 +890,13 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
{ {
rc= ha_cs_impl_pushdown_init(&mhi, handler->table); rc= ha_cs_impl_pushdown_init(&mhi, handler->table);
} }
unsupported_feature = (rc) ? true : unsupported_feature;
// Return SH even if init fails b/c CS changed SELECT_LEX structures // Return SH even if init fails b/c CS changed SELECT_LEX structures
// with simplify_joins_cs and other rewrites() // with simplify_joins_()
// the handler will return error on next_row() if (rc)
unsupported_feature = true;
return handler; return handler;
} }
else
{
std::string emsg=
logging::IDBErrorInfo::instance()->errorMsg(ER_INTERNAL_ERROR, args);
thd->raise_error_printf(ER_INTERNAL_ERROR, emsg.c_str());
}
restore_optimizer_flags(thd);
return NULL; return NULL;
} }