1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-5493: First portion of UBSan fixes (#2842)

Multiple UB fixes
This commit is contained in:
Leonid Fedorov
2023-06-02 17:02:09 +03:00
committed by GitHub
parent 0a2e9760ee
commit 8f93fc3623
31 changed files with 274 additions and 916 deletions

View File

@ -343,7 +343,7 @@ void getColNameFromItem(std::ostringstream& ostream, Item* item)
}
else
{
Item_ident* iip = reinterpret_cast<Item_ident*>(item);
Item_ident* iip = static_cast<Item_ident*>(item);
if (iip->db_name.str)
ostream << iip->db_name.str << '.';
@ -386,13 +386,11 @@ bool sortItemIsInGroupRec(Item* sort_item, Item* group_item)
return found;
}
Item_func* ifp_sort = reinterpret_cast<Item_func*>(sort_item);
// base cases for Item_field and Item_ref. The second arg is binary cmp switch
found = group_item->eq(sort_item, false);
if (!found && sort_item->type() == Item::REF_ITEM)
{
Item_ref* ifp_sort_ref = reinterpret_cast<Item_ref*>(sort_item);
Item_ref* ifp_sort_ref = static_cast<Item_ref*>(sort_item);
found = sortItemIsInGroupRec(*ifp_sort_ref->ref, group_item);
}
else if (!found && sort_item->type() == Item::FIELD_ITEM)
@ -400,6 +398,8 @@ bool sortItemIsInGroupRec(Item* sort_item, Item* group_item)
return found;
}
Item_func* ifp_sort = static_cast<Item_func*>(sort_item);
// seeking for a group_item match
for (uint32_t i = 0; !found && i < ifp_sort->argument_count(); i++)
{
@ -412,7 +412,7 @@ bool sortItemIsInGroupRec(Item* sort_item, Item* group_item)
else if (ifp_sort_arg->type() == Item::REF_ITEM)
{
// dereference the Item
Item_ref* ifp_sort_ref = reinterpret_cast<Item_ref*>(ifp_sort_arg);
Item_ref* ifp_sort_ref = static_cast<Item_ref*>(ifp_sort_arg);
found = sortItemIsInGroupRec(*ifp_sort_ref->ref, group_item);
}
}
@ -432,14 +432,14 @@ bool sortItemIsInGroupRec(Item* sort_item, Item* group_item)
*********************************************************/
void check_sum_func_item(const Item* item, void* arg)
{
bool* found = reinterpret_cast<bool*>(arg);
bool* found = static_cast<bool*>(arg);
if (*found)
return;
if (item->type() == Item::REF_ITEM)
{
const Item_ref* ref_item = reinterpret_cast<const Item_ref*>(item);
const Item_ref* ref_item = static_cast<const Item_ref*>(item);
Item* ref_item_item = (Item*)*ref_item->ref;
if (ref_item_item->type() == Item::SUM_FUNC_ITEM)
{
@ -479,7 +479,7 @@ bool sortItemIsInGrouping(Item* sort_item, ORDER* groupcol)
// e.g. select a, if (sum(b) > 1, 2, 1) from t1 group by 1 order by 2;
if (sort_item->type() == Item::FUNC_ITEM)
{
Item_func* ifp = reinterpret_cast<Item_func*>(sort_item);
Item_func* ifp = static_cast<Item_func*>(sort_item);
ifp->traverse_cond(check_sum_func_item, &found, Item::POSTFIX);
}
else if (sort_item->type() == Item::CONST_ITEM || sort_item->type() == Item::WINDOW_FUNC_ITEM)
@ -528,11 +528,11 @@ ReturnedColumn* buildAggFrmTempField(Item* item, gp_walk_info& gwi)
switch (item->type())
{
case Item::FIELD_ITEM: ifip = reinterpret_cast<Item_field*>(item); break;
case Item::FIELD_ITEM: ifip = static_cast<Item_field*>(item); break;
default:
irip = reinterpret_cast<Item_ref*>(item);
irip = static_cast<Item_ref*>(item);
if (irip)
ifip = reinterpret_cast<Item_field*>(irip->ref[0]);
ifip = static_cast<Item_field*>(irip->ref[0]);
break;
}
@ -541,7 +541,7 @@ ReturnedColumn* buildAggFrmTempField(Item* item, gp_walk_info& gwi)
std::vector<Item*>::iterator iter = gwi.extSelAggColsItems.begin();
for (; iter != gwi.extSelAggColsItems.end(); iter++)
{
isfp = reinterpret_cast<Item_func_or_sum*>(*iter);
isfp = static_cast<Item_func_or_sum*>(*iter);
if (isfp->type() == Item::SUM_FUNC_ITEM && isfp->result_field == ifip->field)
{
@ -1044,7 +1044,7 @@ void debug_walk(const Item* item, void* arg)
if (join)
{
Item_cond* cond = reinterpret_cast<Item_cond*>(join->conds);
Item_cond* cond = static_cast<Item_cond*>(join->conds);
if (cond)
cond->traverse_cond(debug_walk, arg, Item::POSTFIX);
@ -1724,7 +1724,7 @@ bool buildEqualityPredicate(execplan::ReturnedColumn* lhs, execplan::ReturnedCol
boost::shared_ptr<Operator>& sop, const Item_func::Functype& funcType,
const vector<Item*>& itemList, bool isInSubs)
{
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
cal_connection_info* ci = static_cast<cal_connection_info*>(get_fe_conn_info_ptr());
// push the column that is associated with the correlated column to the returned
// column list, so the materialized view have the complete projection list.
@ -2048,7 +2048,7 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip)
else if (ifp->functype() == Item_func::GUSERVAR_FUNC)
{
Item_func_get_user_var* udf = reinterpret_cast<Item_func_get_user_var*>(ifp);
Item_func_get_user_var* udf = static_cast<Item_func_get_user_var*>(ifp);
String buf;
if (udf->result_type() == INT_RESULT)
@ -2801,7 +2801,7 @@ void setError(THD* thd, uint32_t errcode, string errmsg)
thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr());
}
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
cal_connection_info* ci = static_cast<cal_connection_info*>(get_fe_conn_info_ptr());
ci->expressionId = 0;
}
@ -3195,12 +3195,11 @@ CalpontSystemCatalog::ColType colType_MysqlToIDB(const Item* item)
*/
case DECIMAL_RESULT:
{
Item_decimal* idp = (Item_decimal*)item;
// decimal result do not shows us Item is Item_decimal
ct.colDataType = CalpontSystemCatalog::DECIMAL;
unsigned int precision = idp->decimal_precision();
unsigned int scale = idp->decimal_scale();
unsigned int precision = item->decimal_precision();
unsigned int scale = item->decimal_scale();
ct.setDecimalScalePrecision(precision, scale);
@ -3612,7 +3611,7 @@ ArithmeticColumn* buildArithmeticColumn(Item_func* item, gp_walk_info& gwi, bool
thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr());
}
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
cal_connection_info* ci = static_cast<cal_connection_info*>(get_fe_conn_info_ptr());
ArithmeticColumn* ac = new ArithmeticColumn();
Item** sfitempp = item->arguments();
@ -3638,8 +3637,7 @@ ArithmeticColumn* buildArithmeticColumn(Item_func* item, gp_walk_info& gwi, bool
if (!lhs->data() && (sfitempp[0]->type() == Item::FUNC_ITEM))
{
delete lhs;
Item_func* ifp = (Item_func*)sfitempp[0];
lhs = buildParseTree(ifp, gwi, nonSupport);
lhs = buildParseTree(sfitempp[0], gwi, nonSupport);
}
else if (!lhs->data() && (sfitempp[0]->type() == Item::REF_ITEM))
{
@ -3657,8 +3655,7 @@ ArithmeticColumn* buildArithmeticColumn(Item_func* item, gp_walk_info& gwi, bool
if (!rhs->data() && (sfitempp[1]->type() == Item::FUNC_ITEM))
{
delete rhs;
Item_func* ifp = (Item_func*)sfitempp[1];
rhs = buildParseTree(ifp, gwi, nonSupport);
rhs = buildParseTree(sfitempp[1], gwi, nonSupport);
}
else if (!rhs->data() && (sfitempp[1]->type() == Item::REF_ITEM))
{
@ -3875,7 +3872,7 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr());
}
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
cal_connection_info* ci = static_cast<cal_connection_info*>(get_fe_conn_info_ptr());
string funcName = ifp->func_name();
FuncExp* funcExp = FuncExp::instance();
@ -3923,7 +3920,7 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
else if ((funcName == "charset" || funcName == "collation") && ifp->argument_count() == 1 &&
ifp->arguments()[0]->type() == Item::FIELD_ITEM)
{
Item_field* item = reinterpret_cast<Item_field*>(ifp->arguments()[0]);
Item_field* item = static_cast<Item_field*>(ifp->arguments()[0]);
CHARSET_INFO* info = item->charset_for_protocol();
ReturnedColumn* rc;
string val;
@ -4047,9 +4044,10 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
// @todo. merge this logic to buildParseTree().
if ((funcName == "if" && i == 0) || funcName == "xor")
{
// make sure the rcWorkStack is cleaned.
gwi.clauseType = WHERE;
sptp.reset(buildParseTree((Item_func*)(ifp->arguments()[i]), gwi, nonSupport));
sptp.reset(buildParseTree(ifp->arguments()[i], gwi, nonSupport));
gwi.clauseType = clauseType;
if (!sptp)
@ -4155,50 +4153,6 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
addIntervalArgs(&gwi, ifp, funcParms);
}
// check for unsupported arguments add the keyword unit argument for extract functions
if (funcName == "extract")
{
Item_date_add_interval* idai = (Item_date_add_interval*)ifp;
switch (idai->int_type)
{
case INTERVAL_DAY_MICROSECOND:
{
nonSupport = true;
gwi.fatalParseError = true;
Message::Args args;
string info = funcName + " with DAY_MICROSECOND parameter";
args.add(info);
gwi.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORTED_FUNCTION, args);
return NULL;
}
case INTERVAL_HOUR_MICROSECOND:
{
nonSupport = true;
gwi.fatalParseError = true;
Message::Args args;
string info = funcName + " with HOUR_MICROSECOND parameter";
args.add(info);
gwi.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORTED_FUNCTION, args);
return NULL;
}
case INTERVAL_MINUTE_MICROSECOND:
{
nonSupport = true;
gwi.fatalParseError = true;
Message::Args args;
string info = funcName + " with MINUTE_MICROSECOND parameter";
args.add(info);
gwi.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORTED_FUNCTION, args);
return NULL;
}
default: break;
}
}
// add the keyword unit argument and char length for cast functions
if (funcName == "cast_as_char")
{
@ -4496,7 +4450,7 @@ FunctionColumn* buildCaseFunction(Item_func* item, gp_walk_info& gwi, bool& nonS
thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr());
}
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
cal_connection_info* ci = static_cast<cal_connection_info*>(get_fe_conn_info_ptr());
FunctionColumn* fc = new FunctionColumn();
FunctionParm funcParms;
@ -4555,7 +4509,7 @@ FunctionColumn* buildCaseFunction(Item_func* item, gp_walk_info& gwi, bool& nonS
// to pull off of rcWorkStack, so we set this inCaseStmt flag to tell it
// not to.
gwi.inCaseStmt = true;
sptp.reset(buildParseTree((Item_func*)(item->arguments()[i]), gwi, nonSupport));
sptp.reset(buildParseTree(item->arguments()[i], gwi, nonSupport));
gwi.inCaseStmt = false;
if (!gwi.ptWorkStack.empty() && *gwi.ptWorkStack.top() == *sptp.get())
{
@ -4591,7 +4545,7 @@ FunctionColumn* buildCaseFunction(Item_func* item, gp_walk_info& gwi, bool& nonS
}
else
{
sptp.reset(buildParseTree((Item_func*)(item->arguments()[i]), gwi, nonSupport));
sptp.reset(buildParseTree(item->arguments()[i], gwi, nonSupport));
// We need to pop whichever stack is holding it, if any.
if ((!gwi.ptWorkStack.empty()) && *gwi.ptWorkStack.top()->data() == sptp->data())
@ -4800,19 +4754,18 @@ SimpleColumn* buildSimpleColumn(Item_field* ifp, gp_walk_info& gwi)
return sc;
}
ParseTree* buildParseTree(Item_func* item, gp_walk_info& gwi, bool& nonSupport)
ParseTree* buildParseTree(Item* item, gp_walk_info& gwi, bool& nonSupport)
{
ParseTree* pt = 0;
Item_cond* icp = (Item_cond*)item;
#ifdef DEBUG_WALK_COND
// debug
cerr << "Build Parsetree: " << endl;
icp->traverse_cond(debug_walk, &gwi, Item::POSTFIX);
item->traverse_cond(debug_walk, &gwi, Item::POSTFIX);
#endif
//@bug5044. PPSTFIX walking should always be treated as WHERE clause filter
ClauseType clauseType = gwi.clauseType;
gwi.clauseType = WHERE;
icp->traverse_cond(gp_walk, &gwi, Item::POSTFIX);
item->traverse_cond(gp_walk, &gwi, Item::POSTFIX);
gwi.clauseType = clauseType;
if (gwi.fatalParseError)
@ -4924,9 +4877,9 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi)
thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr());
}
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
cal_connection_info* ci = static_cast<cal_connection_info*>(get_fe_conn_info_ptr());
Item_sum* isp = reinterpret_cast<Item_sum*>(item);
Item_sum* isp = static_cast<Item_sum*>(item);
Item** sfitempp = isp->get_orig_args();
SRCP parm;
@ -5156,7 +5109,7 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi)
{
case Item::FIELD_ITEM:
{
Item_field* ifp = reinterpret_cast<Item_field*>(sfitemp);
Item_field* ifp = static_cast<Item_field*>(sfitemp);
SimpleColumn* sc = buildSimpleColumn(ifp, gwi);
if (!sc)
@ -5580,6 +5533,8 @@ because it has multiple arguments.";
return ac;
}
void addIntervalArgs(gp_walk_info* gwip, Item_func* ifp, FunctionParm& functionParms)
{
string funcName = ifp->func_name();
@ -5678,7 +5633,7 @@ bool isNotFuncAndConstScalarSubSelect(Item_func* ifp, const std::string& funcNam
void gp_walk(const Item* item, void* arg)
{
gp_walk_info* gwip = reinterpret_cast<gp_walk_info*>(arg);
gp_walk_info* gwip = static_cast<gp_walk_info*>(arg);
idbassert(gwip);
// Bailout...
@ -5745,8 +5700,8 @@ void gp_walk(const Item* item, void* arg)
{
case INT_RESULT:
{
Item_int* iip = (Item_int*)item;
gwip->rcWorkStack.push(buildReturnedColumn(iip, *gwip, gwip->fatalParseError));
Item* non_const_item = const_cast<Item*>(item);
gwip->rcWorkStack.push(buildReturnedColumn(non_const_item, *gwip, gwip->fatalParseError));
break;
}
@ -5755,39 +5710,36 @@ void gp_walk(const Item* item, void* arg)
// Special handling for 0xHHHH literals
if (item->type_handler() == &type_handler_hex_hybrid)
{
Item_hex_hybrid* hip = reinterpret_cast<Item_hex_hybrid*>(const_cast<Item*>(item));
Item_hex_hybrid* hip = static_cast<Item_hex_hybrid*>(const_cast<Item*>(item));
gwip->rcWorkStack.push(new ConstantColumn((int64_t)hip->val_int(), ConstantColumn::NUM));
ConstantColumn* cc = dynamic_cast<ConstantColumn*>(gwip->rcWorkStack.top());
cc->timeZone(gwip->timeZone);
break;
}
Item_string* isp = (Item_string*)item;
if (isp)
if (item->result_type() == STRING_RESULT)
{
if (isp->result_type() == STRING_RESULT)
// dangerous cast here
Item* isp = const_cast<Item*>(item);
String val, *str = isp->val_str(&val);
if (str)
{
String val, *str = isp->val_str(&val);
if (str)
{
string cval;
string cval;
if (str->ptr())
{
cval.assign(str->ptr(), str->length());
}
gwip->rcWorkStack.push(new ConstantColumn(cval));
(dynamic_cast<ConstantColumn*>(gwip->rcWorkStack.top()))->timeZone(gwip->timeZone);
break;
}
else
if (str->ptr())
{
gwip->rcWorkStack.push(new ConstantColumn("", ConstantColumn::NULLDATA));
(dynamic_cast<ConstantColumn*>(gwip->rcWorkStack.top()))->timeZone(gwip->timeZone);
break;
cval.assign(str->ptr(), str->length());
}
gwip->rcWorkStack.push(new ConstantColumn(cval));
(dynamic_cast<ConstantColumn*>(gwip->rcWorkStack.top()))->timeZone(gwip->timeZone);
break;
}
else
{
gwip->rcWorkStack.push(new ConstantColumn("", ConstantColumn::NULLDATA));
(dynamic_cast<ConstantColumn*>(gwip->rcWorkStack.top()))->timeZone(gwip->timeZone);
break;
}
gwip->rcWorkStack.push(buildReturnedColumn(isp, *gwip, gwip->fatalParseError));
@ -5796,25 +5748,14 @@ void gp_walk(const Item* item, void* arg)
}
case REAL_RESULT:
{
Item_float* ifp = (Item_float*)item;
gwip->rcWorkStack.push(buildReturnedColumn(ifp, *gwip, gwip->fatalParseError));
break;
}
case DECIMAL_RESULT:
{
Item_decimal* idp = (Item_decimal*)item;
gwip->rcWorkStack.push(buildReturnedColumn(idp, *gwip, gwip->fatalParseError));
break;
}
case TIME_RESULT:
{
Item_temporal_literal* itp = (Item_temporal_literal*)item;
gwip->rcWorkStack.push(buildReturnedColumn(itp, *gwip, gwip->fatalParseError));
Item* nonConstItem = const_cast<Item*>(item);
gwip->rcWorkStack.push(buildReturnedColumn(nonConstItem, *gwip, gwip->fatalParseError));
break;
}
default:
{
if (gwip->condPush)
@ -5853,14 +5794,16 @@ void gp_walk(const Item* item, void* arg)
case Item::FUNC_ITEM:
{
Item_func* ifp = (Item_func*)item;
Item* ncitem = const_cast<Item*>(item);
Item_func* ifp = static_cast<Item_func*>(ncitem);
string funcName = ifp->func_name();
if (!gwip->condPush)
{
if (!ifp->fixed())
{
ifp->fix_fields(gwip->thd, reinterpret_cast<Item**>(&ifp));
ifp->fix_fields(gwip->thd, &ncitem);
}
// Special handling for queries of the form:
@ -6176,9 +6119,13 @@ void gp_walk(const Item* item, void* arg)
if (col->type() == Item::FIELD_ITEM)
{
const auto& field_name = string(((Item_field*)item)->field_name.str);
auto colMap = CalpontSelectExecutionPlan::ColumnMap::value_type(field_name, scsp);
gwip->columnMap.insert(colMap);
const Item_ident* ident_field = dynamic_cast<const Item_ident*>(item);
if (ident_field)
{
const auto& field_name = string(ident_field->field_name.str);
auto colMap = CalpontSelectExecutionPlan::ColumnMap::value_type(field_name, scsp);
gwip->columnMap.insert(colMap);
}
}
}
@ -6252,8 +6199,7 @@ void gp_walk(const Item* item, void* arg)
}
else if (col->type() == Item::COND_ITEM)
{
Item_func* ifp = (Item_func*)col;
gwip->ptWorkStack.push(buildParseTree(ifp, *gwip, gwip->fatalParseError));
gwip->ptWorkStack.push(buildParseTree(col, *gwip, gwip->fatalParseError));
}
else if (col->type() == Item::FIELD_ITEM && gwip->clauseType == HAVING)
{
@ -6404,7 +6350,7 @@ void parse_item(Item* item, vector<Item_field*>& field_vec, bool& hasNonSupportI
{
case Item::FIELD_ITEM:
{
Item_field* ifp = reinterpret_cast<Item_field*>(item);
Item_field* ifp = static_cast<Item_field*>(item);
field_vec.push_back(ifp);
return;
}
@ -6413,7 +6359,7 @@ void parse_item(Item* item, vector<Item_field*>& field_vec, bool& hasNonSupportI
{
// hasAggColumn = true;
parseInfo |= AGG_BIT;
Item_sum* isp = reinterpret_cast<Item_sum*>(item);
Item_sum* isp = static_cast<Item_sum*>(item);
Item** sfitempp = isp->arguments();
for (uint32_t i = 0; i < isp->argument_count(); i++)
@ -6424,7 +6370,7 @@ void parse_item(Item* item, vector<Item_field*>& field_vec, bool& hasNonSupportI
case Item::FUNC_ITEM:
{
Item_func* isp = reinterpret_cast<Item_func*>(item);
Item_func* isp = static_cast<Item_func*>(item);
if (string(isp->func_name()) == "<in_optimizer>")
{
@ -6441,7 +6387,7 @@ void parse_item(Item* item, vector<Item_field*>& field_vec, bool& hasNonSupportI
case Item::COND_ITEM:
{
Item_cond* icp = reinterpret_cast<Item_cond*>(item);
Item_cond* icp = static_cast<Item_cond*>(item);
List_iterator_fast<Item> it(*(icp->argument_list()));
Item* cond_item;
@ -6465,13 +6411,13 @@ void parse_item(Item* item, vector<Item_field*>& field_vec, bool& hasNonSupportI
if ((*(ref->ref))->type() == Item::SUM_FUNC_ITEM)
{
parseInfo |= AGG_BIT;
Item_sum* isp = reinterpret_cast<Item_sum*>(*(ref->ref));
Item_sum* isp = static_cast<Item_sum*>(*(ref->ref));
Item** sfitempp = isp->arguments();
// special handling for count(*). This should not be treated as constant.
if (isSupportedAggregateWithOneConstArg(isp, sfitempp))
{
field_vec.push_back((Item_field*)item); // dummy
field_vec.push_back(nullptr); // dummy
}
for (uint32_t i = 0; i < isp->argument_count(); i++)
@ -6490,14 +6436,14 @@ void parse_item(Item* item, vector<Item_field*>& field_vec, bool& hasNonSupportI
if (!rc)
{
Item_field* ifp = reinterpret_cast<Item_field*>(*(ref->ref));
Item_field* ifp = static_cast<Item_field*>(*(ref->ref));
field_vec.push_back(ifp);
}
break;
}
else if ((*(ref->ref))->type() == Item::FUNC_ITEM)
{
Item_func* isp = reinterpret_cast<Item_func*>(*(ref->ref));
Item_func* isp = static_cast<Item_func*>(*(ref->ref));
Item** sfitempp = isp->arguments();
for (uint32_t i = 0; i < isp->argument_count(); i++)
@ -6507,7 +6453,7 @@ void parse_item(Item* item, vector<Item_field*>& field_vec, bool& hasNonSupportI
}
else if ((*(ref->ref))->type() == Item::CACHE_ITEM)
{
Item_cache* isp = reinterpret_cast<Item_cache*>(*(ref->ref));
Item_cache* isp = static_cast<Item_cache*>(*(ref->ref));
parse_item(isp->get_example(), field_vec, hasNonSupportItem, parseInfo, gwi);
break;
}
@ -7580,7 +7526,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
case Item::FUNC_ITEM:
{
Item_func* ifp = reinterpret_cast<Item_func*>(item);
Item_func* ifp = static_cast<Item_func*>(item);
// @bug4383. error out non-support stored function
if (ifp->functype() == Item_func::FUNC_SP)
@ -7714,7 +7660,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
} // End of FUNC_ITEM
// DRRTUY Replace the whole section with typeid() checks or use
// reinterpret_cast here
// static_cast here
case Item::CONST_ITEM:
{
switch (item->cmp_type())
@ -7792,7 +7738,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
if (join)
{
Item_cond* cond = reinterpret_cast<Item_cond*>(join->conds);
Item_cond* cond = static_cast<Item_cond*>(join->conds);
if (cond)
cond->traverse_cond(debug_walk, &gwi, Item::POSTFIX);
@ -7928,13 +7874,12 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
if (select_lex.having != 0)
{
Item_cond* having = reinterpret_cast<Item_cond*>(select_lex.having);
#ifdef DEBUG_WALK_COND
cerr << "------------------- HAVING ---------------------" << endl;
having->traverse_cond(debug_walk, &gwi, Item::POSTFIX);
select_lex.having->traverse_cond(debug_walk, &gwi, Item::POSTFIX);
cerr << "------------------------------------------------\n" << endl;
#endif
having->traverse_cond(gp_walk, &gwi, Item::POSTFIX);
select_lex.having->traverse_cond(gp_walk, &gwi, Item::POSTFIX);
if (gwi.fatalParseError)
{
@ -8090,7 +8035,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
{
gwi.clauseType = GROUP_BY;
Item* nonSupportItem = NULL;
ORDER* groupcol = reinterpret_cast<ORDER*>(select_lex.group_list.first);
ORDER* groupcol = static_cast<ORDER*>(select_lex.group_list.first);
// check if window functions are in order by. InfiniDB process order by list if
// window functions are involved, either in order by or projection.
@ -8112,7 +8057,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
}
gwi.hasWindowFunc = hasWindowFunc;
groupcol = reinterpret_cast<ORDER*>(select_lex.group_list.first);
groupcol = static_cast<ORDER*>(select_lex.group_list.first);
for (; groupcol; groupcol = groupcol->next)
{
@ -8366,7 +8311,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
// ORDER BY processing
{
SQL_I_List<ORDER> order_list = select_lex.order_list;
ORDER* ordercol = reinterpret_cast<ORDER*>(order_list.first);
ORDER* ordercol = static_cast<ORDER*>(order_list.first);
// check if window functions are in order by. InfiniDB process order by list if
// window functions are involved, either in order by or projection.
@ -8393,7 +8338,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
}
// re-visit the first of ordercol list
ordercol = reinterpret_cast<ORDER*>(order_list.first);
ordercol = static_cast<ORDER*>(order_list.first);
{
for (; ordercol; ordercol = ordercol->next)
@ -8551,7 +8496,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
if (unionSel)
order_list = select_lex.master_unit()->global_parameters()->order_list;
ordercol = reinterpret_cast<ORDER*>(order_list.first);
ordercol = static_cast<ORDER*>(order_list.first);
for (; ordercol; ordercol = ordercol->next)
{
@ -8956,7 +8901,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
Item_cond* icp = 0;
if (gi.groupByWhere)
icp = reinterpret_cast<Item_cond*>(gi.groupByWhere);
icp = static_cast<Item_cond*>(gi.groupByWhere);
uint32_t sessionID = csep->sessionID();
gwi.sessionid = sessionID;
@ -9432,7 +9377,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
case Item::FUNC_ITEM:
{
Item_func* ifp = reinterpret_cast<Item_func*>(item);
Item_func* ifp = static_cast<Item_func*>(item);
// @bug4383. error out non-support stored function
if (ifp->functype() == Item_func::FUNC_SP)
@ -9563,7 +9508,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
}
// DRRTUY Replace the whole section with typeid() checks or use
// reinterpret_cast here
// static_cast here
case Item::CONST_ITEM:
{
switch (item->cmp_type())
@ -9640,7 +9585,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
if (join)
{
Item_cond* cond = reinterpret_cast<Item_cond*>(join->conds);
Item_cond* cond = static_cast<Item_cond*>(join->conds);
if (cond)
cond->traverse_cond(debug_walk, &gwi, Item::POSTFIX);
@ -9761,7 +9706,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
if (gi.groupByHaving != 0)
{
Item_cond* having = reinterpret_cast<Item_cond*>(gi.groupByHaving);
Item_cond* having = static_cast<Item_cond*>(gi.groupByHaving);
#ifdef DEBUG_WALK_COND
cerr << "------------------- HAVING ---------------------" << endl;
having->traverse_cond(debug_walk, &gwi, Item::POSTFIX);
@ -9881,7 +9826,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
{
gwi.clauseType = GROUP_BY;
Item* nonSupportItem = NULL;
ORDER* groupcol = reinterpret_cast<ORDER*>(gi.groupByGroup);
ORDER* groupcol = static_cast<ORDER*>(gi.groupByGroup);
// check if window functions are in order by. InfiniDB process order by list if
// window functions are involved, either in order by or projection.
@ -9903,7 +9848,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
}
gwi.hasWindowFunc = hasWindowFunc;
groupcol = reinterpret_cast<ORDER*>(gi.groupByGroup);
groupcol = static_cast<ORDER*>(gi.groupByGroup);
for (; groupcol; groupcol = groupcol->next)
{
@ -10156,7 +10101,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
// ORDER BY processing starts here
{
ORDER* ordercol = reinterpret_cast<ORDER*>(gi.groupByOrder);
ORDER* ordercol = static_cast<ORDER*>(gi.groupByOrder);
// check if window functions are in order by. InfiniDB process order by list if
// window functions are involved, either in order by or projection.
@ -10167,7 +10112,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
}
// re-visit the first of ordercol list
ordercol = reinterpret_cast<ORDER*>(gi.groupByOrder);
ordercol = static_cast<ORDER*>(gi.groupByOrder);
// for subquery, order+limit by will be supported in infinidb. build order by columns
// @todo union order by and limit support
@ -10444,7 +10389,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
// MCOL-1052
if (unionSel)
{
ordercol = reinterpret_cast<ORDER*>(gi.groupByOrder);
ordercol = static_cast<ORDER*>(gi.groupByOrder);
}
else
ordercol = 0;
@ -10478,7 +10423,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
// @bug 3518. if order by clause = selected column, use position.
else if (ord_item->name.length && ord_item->type() == Item::FIELD_ITEM)
{
Item_field* field = reinterpret_cast<Item_field*>(ord_item);
Item_field* field = static_cast<Item_field*>(ord_item);
string fullname;
if (field->db_name.str)