You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-01 06:46:55 +03:00
Part 1: As part of MCOL-3776 to address synchronization issue while accessing the fTimeZone member of the Func class, mutex locks were added to the accessor and mutator methods. However, this slows down processing of TIMESTAMP columns in PrimProc significantly as all threads across all concurrently running queries would serialize on the mutex. This is because PrimProc only has a single global object for the functor class (class derived from Func in utils/funcexp/functor.h) for a given function name. To fix this problem: (1) We remove the fTimeZone as a member of the Func derived classes (hence removing the mutexes) and instead use the fOperationType member of the FunctionColumn class to propagate the timezone values down to the individual functor processing functions such as FunctionColumn::getStrVal(), FunctionColumn::getIntVal(), etc. (2) To achieve (1), a timezone member is added to the execplan::CalpontSystemCatalog::ColType class. Part 2: Several functors in the Funcexp code call dataconvert::gmtSecToMySQLTime() and dataconvert::mySQLTimeToGmtSec() functions for conversion between seconds since unix epoch and broken-down representation. These functions in turn call the C library function localtime_r() which currently has a known bug of holding a global lock via a call to __tz_convert. This significantly reduces performance in multi-threaded applications where multiple threads concurrently call localtime_r(). More details on the bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16145 This bug in localtime_r() caused processing of the Functors in PrimProc to slowdown significantly since a query execution causes Functors code to be processed in a multi-threaded manner. As a fix, we remove the calls to localtime_r() from gmtSecToMySQLTime() and mySQLTimeToGmtSec() by performing the timezone-to-offset conversion (done in dataconvert::timeZoneToOffset()) during the execution plan creation in the plugin. Note that localtime_r() is only called when the time_zone system variable is set to "SYSTEM". This fix also required changing the timezone type from a std::string to a long across the system.
166 lines
6.6 KiB
C++
166 lines
6.6 KiB
C++
/* Copyright (C) 2014 InfiniDB, Inc.
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; version 2 of
|
|
the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
MA 02110-1301, USA. */
|
|
|
|
/***********************************************************************
|
|
* $Id: altertableprocessor.h 9303 2013-03-07 16:07:12Z chao $
|
|
*
|
|
*
|
|
***********************************************************************/
|
|
/** @file */
|
|
#ifndef ALTERTABLEPROCESSOR_H
|
|
#define ALTERTABLEPROCESSOR_H
|
|
|
|
#include "ddlpackageprocessor.h"
|
|
|
|
#if defined(_MSC_VER) && defined(DDLPKGPROC_DLLEXPORT)
|
|
#define EXPORT __declspec(dllexport)
|
|
#else
|
|
#define EXPORT
|
|
#endif
|
|
|
|
namespace ddlpackageprocessor
|
|
{
|
|
/** @brief specialization of a DDLPackageProcessor
|
|
* for interacting with the Write Engine
|
|
* to process alter table ddl statements.
|
|
*/
|
|
class AlterTableProcessor : public DDLPackageProcessor
|
|
{
|
|
public:
|
|
AlterTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm)
|
|
{
|
|
}
|
|
/** @brief process an alter table statement
|
|
*
|
|
* @param alterTableStmt the AlterTableStatement
|
|
*/
|
|
EXPORT DDLResult processPackage(ddlpackage::AlterTableStatement& alterTableStmt);
|
|
/** @brief add a physical column file
|
|
*
|
|
* @param result the result of the operation
|
|
* @param addColumn the AtaAddColumn object
|
|
* @param fTableName the QualifiedName of the table
|
|
*/
|
|
EXPORT void addColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
|
ddlpackage::ColumnDef* columnDefPtr, ddlpackage::QualifiedName& fTableName,
|
|
const uint64_t uniqueId);
|
|
|
|
/** @brief drop a column
|
|
*
|
|
* @param result the result of the operation
|
|
* @param ataDropColumn the AtaDropColumn object
|
|
* @param fTableName the QualifiedName for the table
|
|
*/
|
|
EXPORT void dropColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
|
ddlpackage::AtaDropColumn& ataDropColumn, ddlpackage::QualifiedName& fTableName,
|
|
const uint64_t uniqueId);
|
|
|
|
/** @brief drop columns
|
|
*
|
|
* @param result the result of the operation
|
|
* @param ataDropColumns the AtaDropColumn object
|
|
* @param fTableName the QualifiedName for the table
|
|
*/
|
|
EXPORT void dropColumns(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
|
ddlpackage::AtaDropColumns& ataDropColumns, ddlpackage::QualifiedName& fTableName,
|
|
const uint64_t uniqueId);
|
|
|
|
/** @brief add table constraint
|
|
*
|
|
* @param result the result of the operation
|
|
* @param ataAddTableConstraint the AtaDropColumn object
|
|
* @param fTableName the QualifiedName for the table
|
|
*/
|
|
EXPORT void addTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
|
DDLResult& result, ddlpackage::AtaAddTableConstraint& ataAddTableConstraint,
|
|
ddlpackage::QualifiedName& fTableName);
|
|
|
|
/** @brief set column default
|
|
*
|
|
* @param result the result of the operation
|
|
* @param ataSetColumnDefault the AtaSetColumnDefault object
|
|
* @param fTableName the QualifiedName for the table
|
|
*/
|
|
EXPORT void setColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
|
DDLResult& result, ddlpackage::AtaSetColumnDefault& ataSetColumnDefault,
|
|
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
|
|
|
/** @brief drop column default
|
|
*
|
|
* @param result the result of the operation
|
|
* @param ataDropColumnDefault the AtaDropColumnDefault object
|
|
* @param fTableName the QualifiedName for the table
|
|
*/
|
|
EXPORT void dropColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
|
DDLResult& result, ddlpackage::AtaDropColumnDefault& ataDropColumnDefault,
|
|
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
|
|
|
/** @brief drop table constraint
|
|
*
|
|
* @param result the result of the operation
|
|
* @param ataDropTableConstraint the AtaDropTableConstraint object
|
|
* @param fTableName the QualifiedName for the table
|
|
*/
|
|
EXPORT void dropTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
|
DDLResult& result,
|
|
ddlpackage::AtaDropTableConstraint& ataDropTableConstraint,
|
|
ddlpackage::QualifiedName& fTableName);
|
|
/** @brief rename a table
|
|
*
|
|
* @param result the result of the operation
|
|
* @param ataRenameTable the AtaRenameTable object
|
|
* @param fTableName the QualifiedName for the table
|
|
*/
|
|
EXPORT void renameTable(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
|
ddlpackage::AtaRenameTable& ataRenameTable, ddlpackage::QualifiedName& fTableName,
|
|
const uint64_t uniqueId);
|
|
|
|
/** @brief rename a column
|
|
*
|
|
* @param result the result of the operation
|
|
* @param ataRenameColumn the AtaRenameColumn object
|
|
* @param fTableName the QualifiedName for the table
|
|
*/
|
|
EXPORT void renameColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
|
ddlpackage::AtaRenameColumn& ataRenameColumn,
|
|
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
|
|
|
/** @brief change a table autoincrement via a comment
|
|
*
|
|
* @param result the result of the operation
|
|
* @param ataTableComment the AtaTableComment object
|
|
* @param fTableName the QualifiedName for the table
|
|
*/
|
|
EXPORT void tableComment(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
|
ddlpackage::AtaTableComment& ataTableComment,
|
|
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
|
|
|
long fTimeZone;
|
|
|
|
protected:
|
|
void rollBackAlter(const std::string& error, BRM::TxnID txnID, int sessionId, DDLResult& result,
|
|
uint64_t uniqueId);
|
|
|
|
private:
|
|
};
|
|
|
|
} // namespace ddlpackageprocessor
|
|
|
|
#undef EXPORT
|
|
|
|
#endif // ALTERTABLEPROCESSOR_H
|