1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

Refactored MDB relation names decoding in DDL code.

SH now takes all or nothing thus we need to change if conditions that rules our GBH.

Small warning fixes for GCC8.2

Disabled GBH.
This commit is contained in:
Roman Nozdrin
2019-12-12 21:46:21 -06:00
parent 914fa570fa
commit 7acfddddb7
5 changed files with 63 additions and 129 deletions

View File

@ -198,8 +198,11 @@ ELSE ()
# fix our libraries anyway # fix our libraries anyway
STRING(REPLACE "-fvisibility=hidden" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) STRING(REPLACE "-fvisibility=hidden" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
# TODO: Re-enable these and fix the warnings they generate # TODO: Re-enable these and fix the warnings they generate
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-ignored-qualifiers -Wno-overloaded-virtual -Wno-vla -Wno-non-virtual-dtor -Wno-extra" DEBUG) MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-ignored-qualifiers -Wno-overloaded-virtual -Wno-vla -Wno-non-virtual-dtor -Wno-extra -D_DEBUG" DEBUG)
ENDIF() ENDIF()
SET (ENGINE_LDFLAGS "-Wl,--no-as-needed -Wl,--add-needed") SET (ENGINE_LDFLAGS "-Wl,--no-as-needed -Wl,--add-needed")
SET (ENGINE_COMMON_LIBS messageqcpp loggingcpp configcpp idbboot ${Boost_LIBRARIES} xml2 pthread rt libmysql_client) SET (ENGINE_COMMON_LIBS messageqcpp loggingcpp configcpp idbboot ${Boost_LIBRARIES} xml2 pthread rt libmysql_client)
SET (ENGINE_OAM_LIBS oamcpp alarmmanager) SET (ENGINE_OAM_LIBS oamcpp alarmmanager)

View File

@ -390,6 +390,32 @@ bool validateNextValue( int type, int64_t value )
return validValue; return validValue;
} }
static void decode_objectname(char *buf, const char *path, size_t buf_size)
{
size_t new_path_len = filename_to_tablename(path, buf, buf_size);
buf[new_path_len] = '\0';
}
static void decode_file_path(const char *path, char *decoded_dbname,
char *decoded_tbname)
{
// The format cont ains './' in the beginning of a path.
char *dbname_start = (char*) path + 2;
char *dbname_end = dbname_start;
while (*dbname_end != '/')
dbname_end++;
int cnt = dbname_end - dbname_start;
char *dbname = (char *)my_alloca(cnt + 1);
memcpy(dbname, dbname_start, cnt);
dbname[cnt] = '\0';
decode_objectname(decoded_dbname, dbname, FN_REFLEN);
my_afree(dbname);
char *tbname_start = dbname_end + 1;
decode_objectname(decoded_tbname, tbname_start, FN_REFLEN);
}
bool anyRowInTable(string& schema, string& tableName, int sessionID) bool anyRowInTable(string& schema, string& tableName, int sessionID)
{ {
//find a column in the table //find a column in the table
@ -1203,7 +1229,7 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
{ {
AlterTableStatement* alterTable = dynamic_cast <AlterTableStatement*> ( &stmt ); AlterTableStatement* alterTable = dynamic_cast <AlterTableStatement*> ( &stmt );
alterTable->fTimeZone = thd->variables.time_zone->get_name()->ptr(); alterTable->fTimeZone.assign(thd->variables.time_zone->get_name()->ptr());
if ( schema.length() == 0 ) if ( schema.length() == 0 )
{ {
@ -2275,9 +2301,11 @@ int ha_mcs_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* crea
string stmt(query); string stmt(query);
stmt += ";"; stmt += ";";
algorithm::to_upper(stmt); algorithm::to_upper(stmt);
string db, tbl;
db = table_arg->s->db.str;
tbl = table_arg->s->table_name.str;
string db = table_arg->s->db.str;
string tbl = table_arg->s->table_name.str;
string tablecomment; string tablecomment;
bool isAnyAutoincreCol = false; bool isAnyAutoincreCol = false;
std::string columnName(""); std::string columnName("");
@ -2594,109 +2622,21 @@ int ha_mcs_impl_delete_table_(const char* db, const char* name, cal_connection_i
return rc; return rc;
} }
/**
@brief
Find and return a pointer to the last slash in the name.
@details
This f() finds and returns position of the last slash sign found in
the path or NULL.
Called from ha_mcs_ddl.cpp by decode_table_name().
*/
const char* last_slash_pos(const char *name, size_t name_len)
{
#ifdef MCS_DEBUG
cout << "Entering last_slash_pos()" << endl;
#endif
const char *slash_pos = name + name_len - 1;
while ( *slash_pos != '/' && slash_pos != name )
slash_pos--;
return ( slash_pos != name ) ? slash_pos : NULL;
}
/**
@brief
Decodes the table name.
@details
Replaces the encoded table name in the path with a decoded variant,
e.g if path contains ./test/d@0024. This f() makes it ./test/d$
Called from ha_mcs_ddl.cpp by ha_mcs_impl_rename_table_().
*/
void decode_table_name(char *buf, const char *path, size_t pathLen)
{
#ifdef MCS_DEBUG
cout << "Entering decode_table_name()" << endl;
#endif
strncpy(buf, path, pathLen);
const char *lastSlashPos = last_slash_pos(path, pathLen);
if ( lastSlashPos )
{
size_t prefixLen = ( lastSlashPos - path ) / sizeof(*path);
size_t tableLen = strlen(lastSlashPos + 1);
char tblBuf[FN_REFLEN];
(void) filename_to_tablename(lastSlashPos + 1, tblBuf, sizeof(tblBuf));
strncpy(buf + ( pathLen - tableLen ), tblBuf, tableLen);
buf[prefixLen + tableLen + 1] = '\0';
}
}
/**
@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_mcs_ddl.cpp by ha_mcs_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_mcs_impl_rename_table_(const char* from, const char* to, cal_connection_info& ci) int ha_mcs_impl_rename_table_(const char* from, const char* to, cal_connection_info& ci)
{ {
THD* thd = current_thd; THD* thd = current_thd;
string emsg; string emsg;
// to and from are rewritten after decode_table_name() string dbFrom, tblFrom, dbTo, tblTo;
// so use a copy of pntrs char decodedDbFrom[FN_REFLEN];
const char* from_cpy = from; char decodedTblFrom[FN_REFLEN];
const char* to_cpy = to; char decodedDbTo[FN_REFLEN];
char decodedTblTo[FN_REFLEN];
pair<string, string> fromPair; decode_file_path(from, decodedDbFrom, decodedTblFrom);
pair<string, string> toPair; decode_file_path(to, decodedDbTo, decodedTblTo);
string stmt; string stmt;
if (thd->slave_thread && !get_replication_slave(thd)) if (thd->slave_thread && !get_replication_slave(thd))
return 0; return 0;
@ -2709,36 +2649,24 @@ int ha_mcs_impl_rename_table_(const char* from, const char* to, cal_connection_i
return 1; return 1;
} }
// MCOL-1855 Decode the table name if it contains encoded symbols. // User moves tables b/w namespaces.
size_t pathLen = strlen(from_cpy); size_t tblFromLength= strlen(decodedTblFrom);
char pathCopy[FN_REFLEN]; if (!memcmp(decodedTblFrom, decodedTblTo, tblFromLength))
decode_table_name(pathCopy, from_cpy, pathLen);
fromPair = parseTableName(const_cast<const char*>(pathCopy));
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); return 0;
thd->raise_error_printf(ER_CHECK_NOT_IMPLEMENTED, "Both tables must be in the same database to use RENAME TABLE");
return -1;
} }
// This explicitely shields both db objects with quotes that the lexer strips down later. stmt.assign("alter table `");
stmt = "alter table `" + fromPair.second + "` rename to `" + toPair.second + "`;"; stmt.append(decodedTblFrom);
string db; stmt.append("` rename to `");
stmt.append(decodedTblTo);
stmt.append("`;");
if ( thd->db.length ) string db;
db = thd->db.str; if (thd->db.length)
else if ( fromPair.first.length() != 0 ) db = thd->db.str;
db = fromPair.first; else
else db.assign(decodedDbFrom);
db = toPair.first;
int rc = ProcessDDLStatement(stmt, db, "", tid2sid(thd->thread_id), emsg); int rc = ProcessDDLStatement(stmt, db, "", tid2sid(thd->thread_id), emsg);

View File

@ -396,6 +396,8 @@ group_by_handler*
create_columnstore_group_by_handler(THD* thd, Query* query) create_columnstore_group_by_handler(THD* thd, Query* query)
{ {
ha_mcs_group_by_handler* handler = NULL; ha_mcs_group_by_handler* handler = NULL;
// Disable GBH.
return handler;
// same as thd->lex->current_select // same as thd->lex->current_select
SELECT_LEX *select_lex = query->from->select_lex; SELECT_LEX *select_lex = query->from->select_lex;
@ -403,7 +405,7 @@ create_columnstore_group_by_handler(THD* thd, Query* query)
// MCOL-2178 Disable SP support in the group_by_handler for now // MCOL-2178 Disable SP support in the group_by_handler for now
// Check the session variable value to enable/disable use of // Check the session variable value to enable/disable use of
// group_by_handler. There is no GBH if SH works for the query. // group_by_handler. There is no GBH if SH works for the query.
if (select_lex->select_h || !get_group_by_handler(thd) || (thd->lex)->sphead) if (get_select_handler(thd) || !get_group_by_handler(thd) || (thd->lex)->sphead)
{ {
return handler; return handler;
} }

View File

@ -68,7 +68,7 @@ SocketPool::SocketPool()
SocketPool::~SocketPool() SocketPool::~SocketPool()
{ {
boost::mutex::scoped_lock(mutex); boost::mutex::scoped_lock lock(mutex);
for (uint i = 0; i < allSockets.size(); i++) for (uint i = 0; i < allSockets.size(); i++)
::close(allSockets[i]); ::close(allSockets[i]);

View File

@ -2353,7 +2353,8 @@ bool DataConvert::isColumnTimeValid( int64_t time )
bool DataConvert::isColumnTimeStampValid( int64_t timeStamp ) bool DataConvert::isColumnTimeStampValid( int64_t timeStamp )
{ {
TimeStamp dt; TimeStamp dt;
memcpy(&dt, &timeStamp, sizeof(uint64_t)); void* dtp = static_cast<void*>(&dt);
memcpy(dtp, &timeStamp, sizeof(uint64_t));
return isTimestampValid(dt.second, dt.msecond); return isTimestampValid(dt.second, dt.msecond);
} }