You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-07 03:22:57 +03:00
Merge branch 'develop-1.1' into 1.1-merge-up-20180509-a2
This commit is contained in:
@@ -123,8 +123,8 @@ static int calpont_rollback(handlerton* hton, THD* thd, bool all);
|
||||
static int calpont_close_connection ( handlerton* hton, THD* thd );
|
||||
handlerton* calpont_hton;
|
||||
|
||||
static group_by_handler *
|
||||
create_calpont_group_by_handler(THD *thd, Query *query);
|
||||
static group_by_handler*
|
||||
create_calpont_group_by_handler(THD* thd, Query* query);
|
||||
|
||||
/* Variables for example share methods */
|
||||
|
||||
@@ -1142,7 +1142,7 @@ static MYSQL_SYSVAR_ULONG(
|
||||
/*@brief create_calpont_group_by_handler- Creates handler*/
|
||||
/***********************************************************
|
||||
* DESCRIPTION:
|
||||
* Creates a group_by pushdown handler.
|
||||
* Creates a group_by pushdown handler.
|
||||
* Details are in server/sql/group_by_handler.h
|
||||
* PARAMETERS:
|
||||
* thd - THD pointer.
|
||||
@@ -1151,21 +1151,21 @@ static MYSQL_SYSVAR_ULONG(
|
||||
* group_by_handler if success
|
||||
* NULL in other case
|
||||
***********************************************************/
|
||||
static group_by_handler *
|
||||
create_calpont_group_by_handler(THD *thd, Query *query)
|
||||
static group_by_handler*
|
||||
create_calpont_group_by_handler(THD* thd, Query* query)
|
||||
{
|
||||
ha_calpont_group_by_handler *handler = NULL;
|
||||
|
||||
ha_calpont_group_by_handler* handler = NULL;
|
||||
|
||||
if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE )
|
||||
{
|
||||
handler = new ha_calpont_group_by_handler(thd, query);
|
||||
|
||||
// Notify the server, that CS handles GROUP BY, ORDER BY and HAVING clauses.
|
||||
|
||||
// Notify the server, that CS handles GROUP BY, ORDER BY and HAVING clauses.
|
||||
query->group_by = NULL;
|
||||
query->order_by = NULL;
|
||||
query->having = NULL;
|
||||
}
|
||||
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
|
@@ -251,13 +251,13 @@ public:
|
||||
/*@brief group_by_handler class*/
|
||||
/***********************************************************
|
||||
* DESCRIPTION:
|
||||
* Provides server with group_by_handler API methods.
|
||||
* Provides server with group_by_handler API methods.
|
||||
* One should read comments in server/sql/group_by_handler.h
|
||||
* Attributes:
|
||||
* select - attribute contains all GROUP BY, HAVING, ORDER items and calls it
|
||||
* an extended SELECT list accordin to comments in
|
||||
* server/sql/group_handler.cc.
|
||||
* So the temporary table for
|
||||
* select - attribute contains all GROUP BY, HAVING, ORDER items and calls it
|
||||
* an extended SELECT list accordin to comments in
|
||||
* server/sql/group_handler.cc.
|
||||
* So the temporary table for
|
||||
* select count(*) from b group by a having a > 3 order by a
|
||||
* will have 4 columns not 1.
|
||||
* However server ignores all NULLs used in GROUP BY, HAVING, ORDER.
|
||||
@@ -274,29 +274,29 @@ public:
|
||||
***********************************************************/
|
||||
class ha_calpont_group_by_handler: public group_by_handler
|
||||
{
|
||||
public:
|
||||
ha_calpont_group_by_handler(THD *thd_arg, Query *query)
|
||||
: group_by_handler(thd_arg, calpont_hton),
|
||||
select(query->select),
|
||||
table_list(query->from),
|
||||
distinct(query->distinct),
|
||||
where(query->where),
|
||||
group_by(query->group_by),
|
||||
order_by(query->order_by),
|
||||
having(query->having)
|
||||
{ }
|
||||
~ha_calpont_group_by_handler() { }
|
||||
int init_scan();
|
||||
int next_row();
|
||||
int end_scan();
|
||||
public:
|
||||
ha_calpont_group_by_handler(THD* thd_arg, Query* query)
|
||||
: group_by_handler(thd_arg, calpont_hton),
|
||||
select(query->select),
|
||||
table_list(query->from),
|
||||
distinct(query->distinct),
|
||||
where(query->where),
|
||||
group_by(query->group_by),
|
||||
order_by(query->order_by),
|
||||
having(query->having)
|
||||
{ }
|
||||
~ha_calpont_group_by_handler() { }
|
||||
int init_scan();
|
||||
int next_row();
|
||||
int end_scan();
|
||||
|
||||
List<Item> *select;
|
||||
TABLE_LIST *table_list;
|
||||
bool distinct;
|
||||
Item *where;
|
||||
ORDER *group_by;
|
||||
ORDER *order_by;
|
||||
Item *having;
|
||||
List<Item>* select;
|
||||
TABLE_LIST* table_list;
|
||||
bool distinct;
|
||||
Item* where;
|
||||
ORDER* group_by;
|
||||
ORDER* order_by;
|
||||
Item* having;
|
||||
};
|
||||
#endif //HA_CALPONT_H__
|
||||
|
||||
|
@@ -174,10 +174,6 @@ uint32_t convertDataType(int dataType)
|
||||
calpontDataType = CalpontSystemCatalog::DATETIME;
|
||||
break;
|
||||
|
||||
case ddlpackage::DDL_TIME:
|
||||
calpontDataType = CalpontSystemCatalog::TIME;
|
||||
break;
|
||||
|
||||
case ddlpackage::DDL_CLOB:
|
||||
calpontDataType = CalpontSystemCatalog::CLOB;
|
||||
break;
|
||||
@@ -1872,20 +1868,16 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
|
||||
if (ddlStatement.find("AUTO_INCREMENT") != string::npos)
|
||||
{
|
||||
thd->raise_error_printf(ER_CHECK_NOT_IMPLEMENTED, "Use of the MySQL auto_increment syntax is not supported in Columnstore. If you wish to create an auto increment column in Columnstore, please consult the Columnstore SQL Syntax Guide for the correct usage.");
|
||||
}
|
||||
// MCOL-867. MariaDB RENAME TABLE statement supports WAIT|NOWAIT options since 10.3.0 but Columnstore isn't yet.
|
||||
else if (ddlStatement.find("WAIT") != string::npos || ddlStatement.find("NOWAIT") != string::npos)
|
||||
{
|
||||
thd->raise_error_printf(ER_CHECK_NOT_IMPLEMENTED, "WAIT and NOWAIT options are not supported in Columnstore. Please consult the Columnstore SQL Syntax Guide for the correct usage.");
|
||||
ci->alterTableState = cal_connection_info::NOT_ALTER;
|
||||
ci->isAlter = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//@Bug 1888,1885. update error message
|
||||
thd->raise_error_printf(ER_CHECK_NOT_IMPLEMENTED, "The syntax or the data type(s) is not supported by Columnstore. Please check the Columnstore syntax guide for supported syntax or data types.");
|
||||
ci->alterTableState = cal_connection_info::NOT_ALTER;
|
||||
ci->isAlter = false;
|
||||
}
|
||||
|
||||
ci->alterTableState = cal_connection_info::NOT_ALTER;
|
||||
ci->isAlter = false;
|
||||
}
|
||||
|
||||
return rc;
|
||||
@@ -2187,7 +2179,6 @@ int ha_calpont_impl_rename_table_(const char* from, const char* to, cal_connecti
|
||||
THD* thd = current_thd;
|
||||
string emsg;
|
||||
|
||||
ostringstream stmt1;
|
||||
pair<string, string> fromPair;
|
||||
pair<string, string> toPair;
|
||||
string stmt;
|
||||
@@ -2215,20 +2206,21 @@ int ha_calpont_impl_rename_table_(const char* from, const char* to, cal_connecti
|
||||
return -1;
|
||||
}
|
||||
|
||||
stmt1 << "alter table " << fromPair.second << " rename to " << toPair.second << ";";
|
||||
|
||||
stmt = stmt1.str();
|
||||
// This explicitely shields both db objects with quotes that the lexer strips down later.
|
||||
stmt = "alter table `" + fromPair.second + "` rename to `" + toPair.second + "`;";
|
||||
string db;
|
||||
|
||||
if ( fromPair.first.length() != 0 )
|
||||
db = fromPair.first;
|
||||
else if ( thd->db )
|
||||
if ( thd->db )
|
||||
db = thd->db;
|
||||
else if ( fromPair.first.length() != 0 )
|
||||
db = fromPair.first;
|
||||
else
|
||||
db = toPair.first;
|
||||
|
||||
int rc = ProcessDDLStatement(stmt, db, "", tid2sid(thd->thread_id), emsg);
|
||||
|
||||
if (rc != 0)
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, emsg.c_str());
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_ERROR, 9999, emsg.c_str());
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -427,7 +427,7 @@ int vbin2hex(const uint8_t* p, const unsigned l, char* o)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool handler_flag=false)
|
||||
int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool handler_flag = false)
|
||||
{
|
||||
int rc = HA_ERR_END_OF_FILE;
|
||||
int num_attr = ti.msTablePtr->s->fields;
|
||||
@@ -469,6 +469,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
||||
{
|
||||
Field** f;
|
||||
f = ti.msTablePtr->field;
|
||||
|
||||
//set all fields to null in null col bitmap
|
||||
if (!handler_flag)
|
||||
memset(buf, -1, ti.msTablePtr->s->null_bytes);
|
||||
@@ -476,6 +477,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
||||
{
|
||||
memset(ti.msTablePtr->null_flags, -1, ti.msTablePtr->s->null_bytes);
|
||||
}
|
||||
|
||||
std::vector<CalpontSystemCatalog::ColType>& colTypes = ti.tpl_scan_ctx->ctp;
|
||||
int64_t intColVal = 0;
|
||||
uint64_t uintColVal = 0;
|
||||
@@ -5074,7 +5076,7 @@ int ha_calpont_impl_rnd_pos(uchar* buf, uchar* pos)
|
||||
return ER_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
/*@brief ha_calpont_impl_group_by_init - Get data for MariaDB group_by
|
||||
/*@brief ha_calpont_impl_group_by_init - Get data for MariaDB group_by
|
||||
pushdown handler */
|
||||
/***********************************************************
|
||||
* DESCRIPTION:
|
||||
@@ -5132,8 +5134,8 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
|
||||
setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version");
|
||||
thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR;
|
||||
return ER_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
uint32_t sessionID = tid2sid(thd->thread_id);
|
||||
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
|
||||
csc->identity(CalpontSystemCatalog::FE);
|
||||
@@ -5145,9 +5147,9 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
|
||||
|
||||
idbassert(ci != 0);
|
||||
|
||||
|
||||
|
||||
// MySQL sometimes calls rnd_init multiple times, plan should only be
|
||||
// generated and sent once.
|
||||
// generated and sent once.
|
||||
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE &&
|
||||
!thd->infinidb_vtable.isNewQuery)
|
||||
return 0;
|
||||
@@ -5183,7 +5185,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
|
||||
sm::cpsm_conhdl_t* hndl;
|
||||
SCSEP csep;
|
||||
|
||||
bool localQuery = (thd->variables.infinidb_local_query > 0 ? true : false);
|
||||
bool localQuery = (thd->variables.infinidb_local_query > 0 ? true : false);
|
||||
|
||||
{
|
||||
ci->stats.reset(); // reset query stats
|
||||
@@ -5213,7 +5215,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
|
||||
sm::sm_cleanup(ci->cal_conn_hndl);
|
||||
ci->cal_conn_hndl = 0;
|
||||
}
|
||||
|
||||
|
||||
sm::sm_init(sessionID, &ci->cal_conn_hndl, localQuery);
|
||||
idbassert(ci->cal_conn_hndl != 0);
|
||||
ci->cal_conn_hndl->csc = csc;
|
||||
@@ -5256,7 +5258,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
|
||||
csep->schemaName(group_hand->table_list->db);
|
||||
|
||||
csep->traceFlags(ci->traceFlags);
|
||||
|
||||
|
||||
// MCOL-1052 Send Items lists down to the optimizer.
|
||||
gi.groupByTables = group_hand->table_list;
|
||||
gi.groupByFields = group_hand->select;
|
||||
@@ -5265,7 +5267,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
|
||||
gi.groupByOrder = group_hand->order_by;
|
||||
gi.groupByHaving = group_hand->having;
|
||||
gi.groupByDistinct = group_hand->distinct;
|
||||
|
||||
|
||||
// MCOL-1052 Send pushed conditions here, since server could omit GROUP BY
|
||||
// items in case of = or IN functions used on GROUP BY columns.
|
||||
{
|
||||
@@ -5274,15 +5276,17 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
|
||||
execplan::CalpontSelectExecutionPlan::ColumnMap::iterator condColMapIter;
|
||||
execplan::ParseTree* ptIt;
|
||||
execplan::ReturnedColumn* rcIt;
|
||||
for(TABLE_LIST* tl = gi.groupByTables; tl; tl=tl->next_local)
|
||||
|
||||
for (TABLE_LIST* tl = gi.groupByTables; tl; tl = tl->next_local)
|
||||
{
|
||||
mapiter = ci->tableMap.find(tl->table);
|
||||
if(mapiter != ci->tableMap.end() && mapiter->second.condInfo != NULL
|
||||
&& mapiter->second.condInfo->condPush)
|
||||
|
||||
if (mapiter != ci->tableMap.end() && mapiter->second.condInfo != NULL
|
||||
&& mapiter->second.condInfo->condPush)
|
||||
{
|
||||
while(!mapiter->second.condInfo->ptWorkStack.empty())
|
||||
while (!mapiter->second.condInfo->ptWorkStack.empty())
|
||||
{
|
||||
ptIt=mapiter->second.condInfo->ptWorkStack.top();
|
||||
ptIt = mapiter->second.condInfo->ptWorkStack.top();
|
||||
mapiter->second.condInfo->ptWorkStack.pop();
|
||||
gi.pushedPts.push_back(ptIt);
|
||||
}
|
||||
@@ -5316,14 +5320,14 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, msg.c_str());
|
||||
}
|
||||
|
||||
#ifdef PLAN_HEX_FILE
|
||||
#ifdef PLAN_HEX_FILE
|
||||
// plan serialization
|
||||
ifstream ifs("/tmp/li1-plan.hex");
|
||||
ByteStream bs1;
|
||||
ifs >> bs1;
|
||||
ifs.close();
|
||||
csep->unserialize(bs1);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (ci->traceFlags & 1)
|
||||
{
|
||||
@@ -5338,7 +5342,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
|
||||
IDEBUG( cout << "-------------- EXECUTION PLAN END --------------\n" << endl );
|
||||
}
|
||||
}// end of execution plan generation
|
||||
|
||||
|
||||
{
|
||||
ByteStream msg;
|
||||
ByteStream emsgBs;
|
||||
@@ -5569,10 +5573,10 @@ internal_error:
|
||||
ci->cal_conn_hndl = 0;
|
||||
}
|
||||
|
||||
return ER_INTERNAL_ERROR;
|
||||
return ER_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
/*@brief ha_calpont_impl_group_by_next - Return result set for MariaDB group_by
|
||||
/*@brief ha_calpont_impl_group_by_next - Return result set for MariaDB group_by
|
||||
pushdown handler
|
||||
*/
|
||||
/***********************************************************
|
||||
@@ -5588,7 +5592,7 @@ internal_error:
|
||||
***********************************************************/
|
||||
int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE* table)
|
||||
{
|
||||
THD* thd = current_thd;
|
||||
THD* thd = current_thd;
|
||||
|
||||
/* If this node is the slave, ignore DML to IDB tables */
|
||||
if (thd->slave_thread && (
|
||||
@@ -5697,7 +5701,7 @@ int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE
|
||||
emsg = errorcodes.errorString(rc);
|
||||
}
|
||||
|
||||
setError(thd, ER_INTERNAL_ERROR, emsg);
|
||||
setError(thd, ER_INTERNAL_ERROR, emsg);
|
||||
ci->stats.fErrorNo = rc;
|
||||
CalpontSystemCatalog::removeCalpontSystemCatalog(tid2sid(thd->thread_id));
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
@@ -5806,7 +5810,7 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE*
|
||||
cal_table_info ti = ci->tableMap[table];
|
||||
sm::cpsm_conhdl_t* hndl;
|
||||
|
||||
hndl = ci->cal_conn_hndl;
|
||||
hndl = ci->cal_conn_hndl;
|
||||
|
||||
if (ti.tpl_ctx)
|
||||
{
|
||||
|
@@ -194,14 +194,14 @@ struct cal_table_info
|
||||
|
||||
struct cal_group_info
|
||||
{
|
||||
cal_group_info() : groupByFields(0),
|
||||
cal_group_info() : groupByFields(0),
|
||||
groupByTables(0),
|
||||
groupByWhere(0),
|
||||
groupByGroup(0),
|
||||
groupByOrder(0),
|
||||
groupByHaving(0),
|
||||
groupByDistinct(false)
|
||||
{ }
|
||||
{ }
|
||||
~cal_group_info() { }
|
||||
|
||||
List<Item>* groupByFields; // MCOL-1052 SELECT
|
||||
|
@@ -512,12 +512,13 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n
|
||||
{
|
||||
Item* orderItem = *(orderCol->item);
|
||||
srcp.reset(buildReturnedColumn(orderItem, gwi, nonSupport));
|
||||
|
||||
|
||||
// MCOL-1052 GROUP BY handler has all of query's agg Items
|
||||
// as field and correlates them with its extended SELECT Items.
|
||||
// as field and correlates them with its extended SELECT Items.
|
||||
if (!srcp)
|
||||
{
|
||||
orderItem = orderCol->item_ptr;
|
||||
orderItem = orderCol->item_ptr;
|
||||
|
||||
if (orderItem)
|
||||
{
|
||||
gwi.fatalParseError = false;
|
||||
|
@@ -27,6 +27,8 @@
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include "calpontsystemcatalog.h"
|
||||
#include "dataconvert.h"
|
||||
#include "exceptclasses.h"
|
||||
using namespace logging;
|
||||
|
||||
|
||||
// Required declaration as it isn't in a MairaDB include
|
||||
@@ -70,7 +72,25 @@ static int is_columnstore_columns_fill(THD* thd, TABLE_LIST* tables, COND* cond)
|
||||
for (std::vector<std::pair<execplan::CalpontSystemCatalog::OID, execplan::CalpontSystemCatalog::TableName> >::const_iterator it = catalog_tables.begin();
|
||||
it != catalog_tables.end(); ++it)
|
||||
{
|
||||
execplan::CalpontSystemCatalog::RIDList column_rid_list = systemCatalogPtr->columnRIDs((*it).second, true);
|
||||
execplan::CalpontSystemCatalog::RIDList column_rid_list;
|
||||
|
||||
// Note a table may get dropped as you iterate over the list of tables.
|
||||
// So simply ignore the dropped table.
|
||||
try
|
||||
{
|
||||
column_rid_list = systemCatalogPtr->columnRIDs((*it).second, true);
|
||||
}
|
||||
catch (IDBExcept& ex)
|
||||
{
|
||||
if (ex.errorCode() == ERR_TABLE_NOT_IN_CATALOG)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t col_num = 0; col_num < column_rid_list.size(); col_num++)
|
||||
{
|
||||
|
@@ -145,7 +145,7 @@ status_t tpl_scan_fetch_getband(cpsm_conhdl_t* hndl, sp_cpsm_tplsch_t& ntplsch,
|
||||
if (ntplsch->bs.length() != 0)
|
||||
{
|
||||
ntplsch->deserializeTable(ntplsch->bs);
|
||||
|
||||
|
||||
if (ntplsch->rowGroup && ntplsch->rowGroup->getRGData() == NULL)
|
||||
{
|
||||
ntplsch->bs.restart();
|
||||
|
Reference in New Issue
Block a user