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

Merge branch 'develop-1.2' into develop-merge-up-20190328

This commit is contained in:
Andrew Hutchings
2019-03-28 15:09:21 +00:00
136 changed files with 3636 additions and 1242 deletions

View File

@@ -1061,7 +1061,7 @@ void check_walk(const Item* item, void* arg)
break;
}
case Item::EXPR_CACHE_ITEM: // IN + correlated subquery
case Item::EXPR_CACHE_ITEM: // IN + correlated subquery
{
const Item_cache_wrapper* icw = static_cast<const Item_cache_wrapper*>(item);
if ( icw->get_orig_item()->type() == Item::FUNC_ITEM )
@@ -1102,11 +1102,14 @@ void check_walk(const Item* item, void* arg)
* logical OR in the filter predicates
* Impossible WHERE
* Impossible HAVING
* Valid queries with the last two crashes the server if processed.
* and there is either GROUP BY or aggregation function
* exists at the top level.
* Valid queries with the last two crashes the server if
* processed.
* Details are in server/sql/group_by_handler.h
* PARAMETERS:
* thd - THD pointer.
* query - Query structure, that describes the pushdowned query.
* thd - THD pointer
* query - Query structure LFM in group_by_handler.h
* RETURN:
* group_by_handler if success
* NULL in other case
@@ -1125,29 +1128,48 @@ create_calpont_group_by_handler(THD* thd, Query* query)
&& ( query->group_by || select_lex->with_sum_func ) )
{
bool unsupported_feature = false;
// Impossible HAVING or WHERE
if ( ( query->having && select_lex->having_value == Item::COND_FALSE )
|| ( select_lex->cond_count > 0
&& select_lex->cond_value == Item::COND_FALSE ) )
// revisit SELECT_LEX for all units
for(TABLE_LIST* tl = query->from; !unsupported_feature && tl; tl = tl->next_global)
{
unsupported_feature = true;
}
select_lex = tl->select_lex;
// Correlation subquery. Comming soon so fail on this yet.
unsupported_feature = select_lex->is_correlated;
// Unsupported conditions check.
if ( !unsupported_feature )
{
JOIN *join = select_lex->join;
Item_cond *icp = 0;
if (join != 0)
icp = reinterpret_cast<Item_cond*>(join->conds);
if ( unsupported_feature == false
&& icp )
// Impossible HAVING or WHERE
if ( ( !unsupported_feature && query->having && select_lex->having_value == Item::COND_FALSE )
|| ( select_lex->cond_count > 0
&& select_lex->cond_value == Item::COND_FALSE ) )
{
icp->traverse_cond(check_walk, &unsupported_feature, Item::POSTFIX);
unsupported_feature = true;
}
}
// Unsupported JOIN conditions
if ( !unsupported_feature )
{
JOIN *join = select_lex->join;
Item_cond *icp = 0;
if (join != 0)
icp = reinterpret_cast<Item_cond*>(join->conds);
if ( unsupported_feature == false
&& icp )
{
icp->traverse_cond(check_walk, &unsupported_feature, Item::POSTFIX);
}
// Optimizer could move some join conditions into where
if (select_lex->where != 0)
icp = reinterpret_cast<Item_cond*>(select_lex->where);
if ( unsupported_feature == false
&& icp )
{
icp->traverse_cond(check_walk, &unsupported_feature, Item::POSTFIX);
}
}
} // unsupported features check ends here
if ( !unsupported_feature )
{

View File

@@ -39,7 +39,6 @@
#include <tr1/unordered_set>
#endif
#include <utility>
//#define NDEBUG
#include <cassert>
using namespace std;
@@ -671,7 +670,7 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
{
SqlParser parser;
THD* thd = current_thd;
#ifdef INFINIDB_DEBUG
#ifdef MCS_DEBUG
cout << "ProcessDDLStatement: " << schema << "." << table << ":" << ddlStatement << endl;
#endif
@@ -1616,7 +1615,6 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
}
else if (ddlpackage::AtaRenameColumn* renameColumnsPtr = dynamic_cast<AtaRenameColumn*>(actionList[i]))
{
//cout << "Rename a column" << endl;
uint64_t startValue = 1;
bool autoIncre = false;
//@Bug 3746 Handle compression type
@@ -1815,7 +1813,6 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
stmt.fSql = ddlStatement;
stmt.fOwner = schema;
stmt.fTableWithAutoi = isAnyAutoincreCol;
//cout << "Sending to DDLProc" << endl;
ByteStream bytestream;
bytestream << stmt.fSessionID;
stmt.serialize(bytestream);
@@ -1904,30 +1901,6 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
return rc;
}
// Fails with `/` sign in table name
pair<string, string> parseTableName(const string& tn)
{
string db;
string tb;
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
#ifdef _MSC_VER
boost::char_separator<char> sep("\\");
#else
boost::char_separator<char> sep("/");
#endif
tokenizer tokens(tn, sep);
tokenizer::iterator tok_iter = tokens.begin();
++tok_iter;
idbassert(tok_iter != tokens.end());
db = *tok_iter;
++tok_iter;
idbassert(tok_iter != tokens.end());
tb = *tok_iter;
++tok_iter;
idbassert(tok_iter == tokens.end());
return make_pair(db, tb);
}
}
//
@@ -2005,7 +1978,7 @@ static bool get_field_default_value(THD *thd, Field *field, String *def_value,
int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* create_info, cal_connection_info& ci)
{
#ifdef INFINIDB_DEBUG
#ifdef MCS_DEBUG
cout << "ha_calpont_impl_create_: " << name << endl;
#endif
THD* thd = current_thd;
@@ -2077,7 +2050,7 @@ int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO*
if (isCreate)
{
#ifdef INFINIDB_DEBUG
#ifdef MCS_DEBUG
cout << "ha_calpont_impl_create_: SCHEMA SYNC ONLY found, returning" << endl;
#endif
return 0;
@@ -2108,7 +2081,7 @@ int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO*
{
ci.isAlter = true;
ci.alterTableState = cal_connection_info::ALTER_FIRST_RENAME;
#ifdef INFINIDB_DEBUG
#ifdef MCS_DEBUG
cout << "ha_calpont_impl_create_: now in state ALTER_FIRST_RENAME" << endl;
#endif
}
@@ -2286,7 +2259,7 @@ int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO*
//Bug 1705 reset the flag if error occurs
ci.alterTableState = cal_connection_info::NOT_ALTER;
ci.isAlter = false;
#ifdef INFINIDB_DEBUG
#ifdef MCS_DEBUG
cout << "ha_calpont_impl_create_: ProcessDDL error, now in state NOT_ALTER" << endl;
#endif
}
@@ -2296,7 +2269,7 @@ int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO*
int ha_calpont_impl_delete_table_(const char* db, const char* name, cal_connection_info& ci)
{
#ifdef INFINIDB_DEBUG
#ifdef MCS_DEBUG
cout << "ha_calpont_impl_delete_table: " << db << name << endl;
#endif
THD* thd = current_thd;
@@ -2312,7 +2285,6 @@ int ha_calpont_impl_delete_table_(const char* db, const char* name, cal_connecti
std::string stmt(query);
algorithm::to_upper(stmt);
// cout << "ha_calpont_impl_delete_table: " << schema.c_str() << "." << tbl.c_str() << " " << stmt.c_str() << endl;
// @bug 4158 allow table name with 'restrict' in it (but not by itself)
std::string::size_type fpos;
fpos = stmt.rfind(" RESTRICT");
@@ -2351,7 +2323,6 @@ int ha_calpont_impl_delete_table_(const char* db, const char* name, cal_connecti
stmt += ";";
int rc = ProcessDDLStatement(stmt, schema, tbl, tid2sid(thd->thread_id), emsg);
// cout << "ProcessDDLStatement rc=" << rc << endl;
if (rc != 0)
{
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, emsg.c_str());
@@ -2360,6 +2331,7 @@ int ha_calpont_impl_delete_table_(const char* db, const char* name, cal_connecti
return rc;
}
/**
@brief
Find and return a pointer to the last slash in the name.
@@ -2412,16 +2384,57 @@ void decode_table_name(char *buf, const char *path, size_t pathLen)
}
}
/**
@brief
Parses the path to extract both database and table names.
@details
Parses the path to extract both database
and table names. This f() assumes the path format
./test/d$
and f() produces a pair of strings 'test' and 'd$'.
This f() looks for a '/' symbols only twice to allow '/'
symbol in table names. The f() supports international
glyphs in db or table names.
Called from ha_calpont_ddl.cpp by ha_calpont_impl_rename_table_().
*/
pair<string, string> parseTableName(const char *path)
{
const char *db_pnt = NULL, *tbl_pnt = NULL, *path_cursor = path;
string db, tb;
while (*path_cursor != '/')
{
path_cursor++;
}
path_cursor++;
db_pnt = path_cursor;
while (*path_cursor != '/')
{
path_cursor++;
}
path_cursor++;
tbl_pnt = path_cursor;
db.assign(db_pnt, tbl_pnt - 1 - db_pnt);
tb.assign(tbl_pnt, path + strlen(path) - tbl_pnt);
return make_pair(db, tb);
}
int ha_calpont_impl_rename_table_(const char* from, const char* to, cal_connection_info& ci)
{
THD* thd = current_thd;
string emsg;
// to and from are rewritten after decode_table_name()
// so use a copy of pntrs
const char* from_cpy = from;
const char* to_cpy = to;
pair<string, string> fromPair;
pair<string, string> toPair;
string stmt;
//this is replcated DDL, treat it just like SSO
//this is replicated DDL, treat it just like SSO
if (thd->slave_thread)
return 0;
@@ -2435,16 +2448,18 @@ int ha_calpont_impl_rename_table_(const char* from, const char* to, cal_connecti
}
// MCOL-1855 Decode the table name if it contains encoded symbols.
// This approach fails when `/` is used in the paths.
size_t pathLen = strlen(from);
char pathCopy[pathLen];
decode_table_name(pathCopy, from, pathLen);
size_t pathLen = strlen(from_cpy);
char pathCopy[FN_REFLEN];
decode_table_name(pathCopy, from_cpy, pathLen);
fromPair = parseTableName(const_cast<const char*>(pathCopy));
pathLen = strlen(to);
decode_table_name(pathCopy, to, pathLen);
pathLen = strlen(to_cpy);
decode_table_name(pathCopy, to_cpy, pathLen);
toPair = parseTableName(const_cast<const char*>(pathCopy));
// TBD The next two blocks must be removed to allow different dbnames
// in RENAME statement.
if (fromPair.first != toPair.first)
{
thd->get_stmt_da()->set_overwrite_status(true);

View File

@@ -1,5 +1,5 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporaton
Copyright (C) 2019 MariaDB Corporaton
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -1175,6 +1175,20 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_
break;
}
case CalpontSystemCatalog::LONGDOUBLE:
{
if (nullVal && (ci.columnTypes[colpos].constraintType != CalpontSystemCatalog::NOTNULL_CONSTRAINT))
fprintf(ci.filePtr, "%c", ci.delimiter);
else
{
fprintf(ci.filePtr, "%.15Lg%c", *((long double*)buf), ci.delimiter);
//printf("%.15g|", *((double*)buf));
}
buf += 8;
break;
}
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{

View File

@@ -1,5 +1,5 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporaton
Copyright (C) 2019 MariaDB Corporaton
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -3373,7 +3373,6 @@ ReturnedColumn* buildFunctionColumn(
return ac;
}
// comment out for now until case function is fully tested.
else if (funcName == "case")
{
fc = buildCaseFunction(ifp, gwi, nonSupport);
@@ -4500,41 +4499,10 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi)
isp->sum_func() == Item_sum::AVG_DISTINCT_FUNC)
{
CalpontSystemCatalog::ColType ct = parm->resultType();
switch (ct.colDataType)
{
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
case CalpontSystemCatalog::UTINYINT:
case CalpontSystemCatalog::USMALLINT:
case CalpontSystemCatalog::UMEDINT:
case CalpontSystemCatalog::UINT:
case CalpontSystemCatalog::UBIGINT:
ct.colDataType = CalpontSystemCatalog::DECIMAL;
ct.colWidth = 8;
ct.scale += 4;
break;
#if PROMOTE_FLOAT_TO_DOUBLE_ON_SUM
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::UFLOAT:
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::UDOUBLE:
ct.colDataType = CalpontSystemCatalog::DOUBLE;
ct.colWidth = 8;
break;
#endif
default:
break;
}
ct.colDataType = CalpontSystemCatalog::LONGDOUBLE;
ct.colWidth = sizeof(long double);
ct.scale += 4;
ct.precision = -1;
ac->resultType(ct);
}
else if (isp->sum_func() == Item_sum::COUNT_FUNC ||
@@ -4550,47 +4518,9 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi)
isp->sum_func() == Item_sum::SUM_DISTINCT_FUNC)
{
CalpontSystemCatalog::ColType ct = parm->resultType();
switch (ct.colDataType)
{
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::BIGINT:
ct.colDataType = CalpontSystemCatalog::BIGINT;
// no break, let fall through
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
ct.colWidth = 8;
break;
case CalpontSystemCatalog::UTINYINT:
case CalpontSystemCatalog::USMALLINT:
case CalpontSystemCatalog::UMEDINT:
case CalpontSystemCatalog::UINT:
case CalpontSystemCatalog::UBIGINT:
ct.colDataType = CalpontSystemCatalog::UBIGINT;
ct.colWidth = 8;
break;
#if PROMOTE_FLOAT_TO_DOUBLE_ON_SUM
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::UFLOAT:
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::UDOUBLE:
ct.colDataType = CalpontSystemCatalog::DOUBLE;
ct.colWidth = 8;
break;
#endif
default:
break;
}
ct.colDataType = CalpontSystemCatalog::LONGDOUBLE;
ct.colWidth = sizeof(long double);
ct.precision = -1;
ac->resultType(ct);
}
else if (isp->sum_func() == Item_sum::STD_FUNC ||

View File

@@ -1,5 +1,5 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporaton
Copyright (C) 2019 MariaDB Corporaton
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -714,6 +714,61 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
//break;
}
case CalpontSystemCatalog::LONGDOUBLE:
{
long double dl = row.getLongDoubleField(s);
if (dl == std::numeric_limits<long double>::infinity())
{
continue;
}
switch((*f)->type())
{
case MYSQL_TYPE_NEWDECIMAL:
{
char buf[310];
Field_new_decimal* f2 = (Field_new_decimal*)*f;
if ((f2->decimals() == DECIMAL_NOT_SPECIFIED && row.getScale(s) > 0)
|| f2->decimals() < row.getScale(s))
{
f2->dec = row.getScale(s);
}
// dl /= pow(10.0, (double)f2->dec);
snprintf(buf, 310, "%.20Lg", dl);
f2->store(buf, strlen(buf), f2->charset());
if ((*f)->null_ptr)
*(*f)->null_ptr &= ~(*f)->null_bit;
}
break;
case MYSQL_TYPE_DOUBLE:
{
Field_double* f2 = (Field_double*)*f;
// bug 3483, reserve enough space for the longest double value
// -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and
// 2.2250738585072014E-308 to 1.7976931348623157E+308.
(*f)->field_length = 310;
if ((f2->decimals() == DECIMAL_NOT_SPECIFIED && row.getScale(s) > 0)
|| f2->decimals() < row.getScale(s))
{
f2->dec = row.getScale(s);
}
f2->store(static_cast<double>(dl));
if ((*f)->null_ptr)
*(*f)->null_ptr &= ~(*f)->null_bit;
}
break;
default:
{
continue; // Shouldn't happen. Functions should not return long double to other than double or decimal return type.
}
}
break;
}
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{

View File

@@ -1,5 +1,5 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporaton
Copyright (C) 2019 MariaDB Corporaton
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -190,6 +190,9 @@ string name(CalpontSystemCatalog::ColType& ct)
case CalpontSystemCatalog::UDOUBLE:
return "UDOUBLE";
case CalpontSystemCatalog::LONGDOUBLE:
return "LONGDOUBLE";
default:
return "Unknown Type";
}

View File

@@ -1,5 +1,5 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporaton
Copyright (C) 2019 MariaDB Corporaton
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -898,7 +898,13 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n
setError(gwi.thd, ER_CHECK_NOT_IMPLEMENTED, gwi.parseErrorText);
return NULL;
}
#if 0
if (item_sum->sum_func() != Item_sum::UDF_SUM_FUNC &&
item_sum->sum_func() != Item_sum::SUM_FUNC &&
item_sum->sum_func() != Item_sum::SUM_DISTINCT_FUNC &&
item_sum->sum_func() != Item_sum::AVG_FUNC &&
item_sum->sum_func() != Item_sum::AVG_DISTINCT_FUNC)
#endif
if (item_sum->sum_func() != Item_sum::UDF_SUM_FUNC)
{
ac->resultType(colType_MysqlToIDB(item_sum));