From 973edf5a87935b548ada654c1c29a170190c9855 Mon Sep 17 00:00:00 2001 From: David Hall Date: Wed, 6 Mar 2019 13:29:50 -0600 Subject: [PATCH 01/59] MCOL-2100 Don't print the line "redistributeData must have one of START, STOP or STATUS" if it has one. --- oamapps/mcsadmin/mcsadmin.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/oamapps/mcsadmin/mcsadmin.cpp b/oamapps/mcsadmin/mcsadmin.cpp index dd7262d1e..d88944961 100644 --- a/oamapps/mcsadmin/mcsadmin.cpp +++ b/oamapps/mcsadmin/mcsadmin.cpp @@ -801,9 +801,9 @@ int processCommand(string* arguments) SendToWES(oam, bs); } #if _MSC_VER - if (_strnicmp(arguments[1].c_str(), "stop", 4) == 0)) + else if (_strnicmp(arguments[1].c_str(), "stop", 4) == 0)) #else - if (strncasecmp(arguments[1].c_str(), "stop", 4) == 0) + else if (strncasecmp(arguments[1].c_str(), "stop", 4) == 0) #endif { ByteStream bs; @@ -815,9 +815,9 @@ int processCommand(string* arguments) SendToWES(oam, bs); } #if _MSC_VER - if (_strnicmp(arguments[1].c_str(), "status", 6) == 0)) + else if (_strnicmp(arguments[1].c_str(), "status", 6) == 0)) #else - if (strncasecmp(arguments[1].c_str(), "status", 6) == 0) + else if (strncasecmp(arguments[1].c_str(), "status", 6) == 0) #endif { ByteStream bs; From bed4eae7213515fdba22ff7f2e08be313bb28ba5 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Fri, 29 Mar 2019 15:02:16 +0000 Subject: [PATCH 02/59] Bump to version 1.1.8 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 04362fcf8..6d304eb90 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ COLUMNSTORE_VERSION_MAJOR=1 COLUMNSTORE_VERSION_MINOR=1 -COLUMNSTORE_VERSION_PATCH=7 +COLUMNSTORE_VERSION_PATCH=8 COLUMNSTORE_VERSION_RELEASE=1 From 4e72b1f2d924566daf95175744630926fc21bdc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=95=B0=E7=BB=84=E8=B6=8A=E7=95=8C?= Date: Tue, 16 Apr 2019 09:31:49 +0800 Subject: [PATCH 03/59] fix typo in postConfigure --- oamapps/postConfigure/postConfigure.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index fe7a3b337..107674507 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -4666,7 +4666,7 @@ bool storageSetup(bool amazonInstall) if ( (glusterInstalled == "y" && singleServerInstall != "1") && hadoopInstalled == "y" ) { - cout << "There are 5 options when configuring the storage: internal, external, DataRedundancy, or hdfs" << endl << endl; + cout << "There are 4 options when configuring the storage: internal, external, DataRedundancy, or hdfs" << endl << endl; prompt = "Select the type of Data Storage [1=internal, 2=external, 3=DataRedundancy, 4=hdfs] (" + storageType + ") > "; } From 83aad0c7b10bb7e0423ae5c7e845c94bc368d0f9 Mon Sep 17 00:00:00 2001 From: Sergey Sedov Date: Fri, 26 Apr 2019 11:10:29 +0300 Subject: [PATCH 04/59] MCOL-2051: CS uses 'NULL' literal as NULL when UPDATEs varchar field: proxying NULL value. Note: empty strings are still considered NULLs later on. --- dbcon/dmlpackage/dmlcolumn.cpp | 4 ---- dbcon/dmlpackage/dmlpkg.h | 5 +++-- dbcon/dmlpackage/updatedmlpackage.cpp | 3 ++- dbcon/mysql/ha_calpont_impl.cpp | 3 ++- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/dbcon/dmlpackage/dmlcolumn.cpp b/dbcon/dmlpackage/dmlcolumn.cpp index 9bd0f67a8..f2a98f7d6 100644 --- a/dbcon/dmlpackage/dmlcolumn.cpp +++ b/dbcon/dmlpackage/dmlcolumn.cpp @@ -40,10 +40,6 @@ DMLColumn::DMLColumn(std::string name, std::string value, bool isFromCol, uint32 { fName = name; fData = value; - if (( strcasecmp(value.c_str(), "NULL") == 0) || (value.length() == 0) ) - { - isNULL = true; - } fisNULL = isNULL; fIsFromCol = isFromCol; fFuncScale = funcScale; diff --git a/dbcon/dmlpackage/dmlpkg.h b/dbcon/dmlpackage/dmlpkg.h index 3bef09343..924d974fd 100644 --- a/dbcon/dmlpackage/dmlpkg.h +++ b/dbcon/dmlpackage/dmlpkg.h @@ -409,8 +409,9 @@ public: std::string fColumn; std::string fOperator; std::string fScalarExpression; - bool fFromCol; - uint32_t fFuncScale; + bool fFromCol; + uint32_t fFuncScale; + bool fIsNull = false; }; /** @brief Stores a value list or a query specification diff --git a/dbcon/dmlpackage/updatedmlpackage.cpp b/dbcon/dmlpackage/updatedmlpackage.cpp index 05ca4f117..aa3504010 100644 --- a/dbcon/dmlpackage/updatedmlpackage.cpp +++ b/dbcon/dmlpackage/updatedmlpackage.cpp @@ -245,7 +245,8 @@ void UpdateDMLPackage::buildUpdateFromMysqlBuffer(UpdateSqlStatement& updateStm while (iter != updateStmt.fColAssignmentListPtr->end()) { ColumnAssignment* colaPtr = *iter; - DMLColumn* colPtr = new DMLColumn(colaPtr->fColumn, colaPtr->fScalarExpression, colaPtr->fFromCol, colaPtr->fFuncScale); + DMLColumn* colPtr = new DMLColumn(colaPtr->fColumn, colaPtr->fScalarExpression, colaPtr->fFromCol, colaPtr->fFuncScale, + colaPtr->fIsNull); rowPtr->get_ColumnList().push_back(colPtr); ++iter; diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index c1f37c9ac..7bb6ad212 100755 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -1044,8 +1044,9 @@ uint32_t doUpdateDelete(THD *thd) else if ( value->type() == Item::NULL_ITEM ) { // dmlStmt += "NULL"; - columnAssignmentPtr->fScalarExpression = "NULL"; + columnAssignmentPtr->fScalarExpression = ""; columnAssignmentPtr->fFromCol = false; + columnAssignmentPtr->fIsNull = true; } else if ( value->type() == Item::SUBSELECT_ITEM ) { From 12d9e2ec954d24ec48ff0d948d8a2c06fb26bf11 Mon Sep 17 00:00:00 2001 From: Sergey Sedov Date: Thu, 2 May 2019 09:58:57 +0300 Subject: [PATCH 05/59] fixup! MCOL-2051: CS uses 'NULL' literal as NULL when UPDATEs varchar field Fixed to retain compatibility with CentOS 6 (no C++11 support). Moved initialization to the ColumnAssignment constructor. --- dbcon/dmlpackage/dml.y | 10 ++-------- dbcon/dmlpackage/dmlpkg.h | 10 +++++++++- dbcon/mysql/ha_calpont_impl.cpp | 5 +---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/dbcon/dmlpackage/dml.y b/dbcon/dmlpackage/dml.y index b26319c0b..73dcf26ea 100644 --- a/dbcon/dmlpackage/dml.y +++ b/dbcon/dmlpackage/dml.y @@ -566,17 +566,11 @@ assignment_commalist: assignment: column COMPARISON scalar_exp { - $$ = new ColumnAssignment(); - $$->fColumn = $1; - $$->fOperator = $2; - $$->fScalarExpression = $3; + $$ = new ColumnAssignment($1, $2, $3); } | column COMPARISON NULLX { - $$ = new ColumnAssignment(); - $$->fColumn = $1; - $$->fOperator = $2; - $$->fScalarExpression = $3; + $$ = new ColumnAssignment($1, $2, $3); } ; diff --git a/dbcon/dmlpackage/dmlpkg.h b/dbcon/dmlpackage/dmlpkg.h index 924d974fd..82c561b8e 100644 --- a/dbcon/dmlpackage/dmlpkg.h +++ b/dbcon/dmlpackage/dmlpkg.h @@ -397,6 +397,14 @@ public: class ColumnAssignment { public: + explicit ColumnAssignment( + std::string const& column, + std::string const& op = "=", + std::string const& expr = "") : + fColumn(column), fOperator(op), fScalarExpression(expr), + fFromCol(false), fFuncScale(0), fIsNull(false) + {}; + /** @brief dump to stdout */ std::ostream& put(std::ostream &os) const; @@ -411,7 +419,7 @@ public: std::string fScalarExpression; bool fFromCol; uint32_t fFuncScale; - bool fIsNull = false; + bool fIsNull; }; /** @brief Stores a value list or a query specification diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 7bb6ad212..a6cbea6a9 100755 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -928,10 +928,7 @@ uint32_t doUpdateDelete(THD *thd) else schemaName = string(item->db_name); - columnAssignmentPtr = new ColumnAssignment(); - columnAssignmentPtr->fColumn = string(item->name); - columnAssignmentPtr->fOperator = "="; - columnAssignmentPtr->fFuncScale = 0; + columnAssignmentPtr = new ColumnAssignment(item->name, "=", ""); Item *value= value_it++; if (value->type() == Item::STRING_ITEM) { From be83194c316e38a2aff28623960fe0818c403a66 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Thu, 2 May 2019 10:32:49 +0100 Subject: [PATCH 06/59] MCOL-2273 Improve disk usage reporting Use the amount of available space rather than the amount of free space. The two numbers are usually different because the free blocks may be unusable at the time. --- oamapps/serverMonitor/diskMonitor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oamapps/serverMonitor/diskMonitor.cpp b/oamapps/serverMonitor/diskMonitor.cpp index bef1df560..e6989e4f6 100644 --- a/oamapps/serverMonitor/diskMonitor.cpp +++ b/oamapps/serverMonitor/diskMonitor.cpp @@ -240,7 +240,7 @@ void diskMonitor() blksize = buf.f_bsize; blocks = buf.f_blocks; - freeblks = buf.f_bfree; + freeblks = buf.f_bavail; totalBlocks = blocks * blksize; free = freeblks * blksize; @@ -359,7 +359,7 @@ void diskMonitor() blksize = buf.f_bsize; blocks = buf.f_blocks; - freeblks = buf.f_bfree; + freeblks = buf.f_bavail; totalBlocks = blocks * blksize; free = freeblks * blksize; From 72b6e3ef54723d8f283e03d9cb3a2e5f1d0ab879 Mon Sep 17 00:00:00 2001 From: David Hall Date: Thu, 2 May 2019 13:49:21 -0500 Subject: [PATCH 07/59] MCOL-1984 add waitPeriod to config items saved during update --- tools/configMgt/autoConfigure.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/configMgt/autoConfigure.cpp b/tools/configMgt/autoConfigure.cpp index e87401127..4c21fd6c7 100755 --- a/tools/configMgt/autoConfigure.cpp +++ b/tools/configMgt/autoConfigure.cpp @@ -66,6 +66,7 @@ typedef std::vector PerformanceModuleList; int main(int argc, char *argv[]) { setenv("CALPONT_HOME", "./", 1); + std::cout << "autoConfigure : main() *************" << std::endl; Oam oam; string systemParentOAMModuleName; @@ -326,7 +327,19 @@ int main(int argc, char *argv[]) exit(-1); } - //setup System Language + // WaitPeriod + try + { + string waitPeriod = sysConfigOld->getConfig(SystemSection, "WaitPeriod"); + if (waitPeriod.length() > 0) + { + sysConfigNew->setConfig(SystemSection, "WaitPeriod", waitPeriod); + } + } + catch (...) + { } + + //setup System Language string systemLang = "C"; try { systemLang = sysConfigOld->getConfig(SystemSection, "SystemLang"); From 767dd633c21b72cca4dc86c4b3daffa471d723a1 Mon Sep 17 00:00:00 2001 From: David Hall Date: Thu, 2 May 2019 13:52:01 -0500 Subject: [PATCH 08/59] MCOL-1984 remove debug line --- tools/configMgt/autoConfigure.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/configMgt/autoConfigure.cpp b/tools/configMgt/autoConfigure.cpp index 4c21fd6c7..6cf665dad 100755 --- a/tools/configMgt/autoConfigure.cpp +++ b/tools/configMgt/autoConfigure.cpp @@ -66,7 +66,6 @@ typedef std::vector PerformanceModuleList; int main(int argc, char *argv[]) { setenv("CALPONT_HOME", "./", 1); - std::cout << "autoConfigure : main() *************" << std::endl; Oam oam; string systemParentOAMModuleName; From c444c36da7ce72f7d948c2cf7fe3827e5cfe956f Mon Sep 17 00:00:00 2001 From: Ben Thompson Date: Wed, 8 May 2019 12:00:12 -0500 Subject: [PATCH 09/59] Fix for newer version of CMake/CPack --- cpackEngineRPM.cmake | 230 +------------------------------------------ 1 file changed, 3 insertions(+), 227 deletions(-) diff --git a/cpackEngineRPM.cmake b/cpackEngineRPM.cmake index 866f39cff..b34b8207d 100644 --- a/cpackEngineRPM.cmake +++ b/cpackEngineRPM.cmake @@ -119,235 +119,11 @@ SET(ignored #%define _prefix ${CMAKE_INSTALL_PREFIX} #") -SET(CPACK_RPM_platform_USER_FILELIST -"/usr/local/mariadb/columnstore/bin/DDLProc" -"/usr/local/mariadb/columnstore/bin/ExeMgr" -"/usr/local/mariadb/columnstore/bin/ProcMgr" -"/usr/local/mariadb/columnstore/bin/ProcMon" -"/usr/local/mariadb/columnstore/bin/DMLProc" -"/usr/local/mariadb/columnstore/bin/WriteEngineServer" -"/usr/local/mariadb/columnstore/bin/cpimport" -"/usr/local/mariadb/columnstore/bin/post-install" -"/usr/local/mariadb/columnstore/bin/post-mysql-install" -"/usr/local/mariadb/columnstore/bin/post-mysqld-install" -"/usr/local/mariadb/columnstore/bin/pre-uninstall" -"/usr/local/mariadb/columnstore/bin/PrimProc" -"/usr/local/mariadb/columnstore/bin/DecomSvr" -"/usr/local/mariadb/columnstore/bin/upgrade-columnstore.sh" -"/usr/local/mariadb/columnstore/bin/run.sh" -"/usr/local/mariadb/columnstore/bin/columnstore" -"/usr/local/mariadb/columnstore/bin/columnstoreSyslog" -"/usr/local/mariadb/columnstore/bin/columnstoreSyslog7" -"/usr/local/mariadb/columnstore/bin/columnstoreSyslog-ng" -"/usr/local/mariadb/columnstore/bin/syslogSetup.sh" -"/usr/local/mariadb/columnstore/bin/cplogger" -"/usr/local/mariadb/columnstore/bin/columnstore.def" -"/usr/local/mariadb/columnstore/bin/dbbuilder" -"/usr/local/mariadb/columnstore/bin/cpimport.bin" -"/usr/local/mariadb/columnstore/bin/load_brm" -"/usr/local/mariadb/columnstore/bin/save_brm" -"/usr/local/mariadb/columnstore/bin/dbrmctl" -"/usr/local/mariadb/columnstore/bin/controllernode" -"/usr/local/mariadb/columnstore/bin/reset_locks" -"/usr/local/mariadb/columnstore/bin/workernode" -"/usr/local/mariadb/columnstore/bin/colxml" -"/usr/local/mariadb/columnstore/bin/clearShm" -"/usr/local/mariadb/columnstore/bin/viewtablelock" -"/usr/local/mariadb/columnstore/bin/cleartablelock" -"/usr/local/mariadb/columnstore/bin/mcsadmin" -"/usr/local/mariadb/columnstore/bin/remote_command.sh" -"/usr/local/mariadb/columnstore/bin/postConfigure" -"/usr/local/mariadb/columnstore/bin/columnstoreLogRotate" -"/usr/local/mariadb/columnstore/bin/transactionLog" -"/usr/local/mariadb/columnstore/bin/columnstoreDBWrite" -"/usr/local/mariadb/columnstore/bin/transactionLogArchiver.sh" -"/usr/local/mariadb/columnstore/bin/installer" -"/usr/local/mariadb/columnstore/bin/module_installer.sh" -"/usr/local/mariadb/columnstore/bin/package_installer.sh" -"/usr/local/mariadb/columnstore/bin/startupTests.sh" -"/usr/local/mariadb/columnstore/bin/os_check.sh" -"/usr/local/mariadb/columnstore/bin/remote_scp_put.sh" -"/usr/local/mariadb/columnstore/bin/remotessh.exp" -"/usr/local/mariadb/columnstore/bin/ServerMonitor" -"/usr/local/mariadb/columnstore/bin/master-rep-columnstore.sh" -"/usr/local/mariadb/columnstore/bin/slave-rep-columnstore.sh" -"/usr/local/mariadb/columnstore/bin/rsync.sh" -"/usr/local/mariadb/columnstore/bin/columnstoreSupport" -"/usr/local/mariadb/columnstore/bin/hardwareReport.sh" -"/usr/local/mariadb/columnstore/bin/softwareReport.sh" -"/usr/local/mariadb/columnstore/bin/configReport.sh" -"/usr/local/mariadb/columnstore/bin/logReport.sh" -"/usr/local/mariadb/columnstore/bin/bulklogReport.sh" -"/usr/local/mariadb/columnstore/bin/resourceReport.sh" -"/usr/local/mariadb/columnstore/bin/hadoopReport.sh" -"/usr/local/mariadb/columnstore/bin/alarmReport.sh" -"/usr/local/mariadb/columnstore/bin/remote_command_verify.sh" -"/usr/local/mariadb/columnstore/bin/disable-rep-columnstore.sh" -"/usr/local/mariadb/columnstore/bin/columnstore.service" -"/usr/local/mariadb/columnstore/etc/MessageFile.txt" -"/usr/local/mariadb/columnstore/etc/ErrorMessage.txt" -"/usr/local/mariadb/columnstore/local/module" -"/usr/local/mariadb/columnstore/releasenum" -"/usr/local/mariadb/columnstore/bin/rollback" -"/usr/local/mariadb/columnstore/bin/editem" -"/usr/local/mariadb/columnstore/bin/getConfig" -"/usr/local/mariadb/columnstore/bin/setConfig" -"/usr/local/mariadb/columnstore/bin/setenv-hdfs-12" -"/usr/local/mariadb/columnstore/bin/setenv-hdfs-20" -"/usr/local/mariadb/columnstore/bin/configxml.sh" -"/usr/local/mariadb/columnstore/bin/remote_scp_get.sh" -"/usr/local/mariadb/columnstore/bin/columnstoreAlias" -"/usr/local/mariadb/columnstore/bin/autoConfigure" -"/usr/local/mariadb/columnstore/bin/ddlcleanup" -"/usr/local/mariadb/columnstore/bin/idbmeminfo" -"/usr/local/mariadb/columnstore/bin/MCSInstanceCmds.sh" -"/usr/local/mariadb/columnstore/bin/MCSVolumeCmds.sh" -"/usr/local/mariadb/columnstore/bin/binary_installer.sh" -"/usr/local/mariadb/columnstore/bin/myCnf-include-args.text" -"/usr/local/mariadb/columnstore/bin/myCnf-exclude-args.text" -"/usr/local/mariadb/columnstore/bin/mycnfUpgrade" -"/usr/local/mariadb/columnstore/bin/getMySQLpw" -"/usr/local/mariadb/columnstore/bin/columnstore.conf" -"/usr/local/mariadb/columnstore/post/functions" -"/usr/local/mariadb/columnstore/post/test-001.sh" -"/usr/local/mariadb/columnstore/post/test-002.sh" -"/usr/local/mariadb/columnstore/post/test-003.sh" -"/usr/local/mariadb/columnstore/post/test-004.sh" -"/usr/local/mariadb/columnstore/bin/os_detect.sh" -"/usr/local/mariadb/columnstore/bin/columnstoreClusterTester.sh" -"/usr/local/mariadb/columnstore/bin/mariadb-command-line.sh" -"/usr/local/mariadb/columnstore/bin/quick_installer_single_server.sh" -"/usr/local/mariadb/columnstore/bin/quick_installer_multi_server.sh" -"/usr/local/mariadb/columnstore/bin/quick_installer_amazon.sh" -${ignored}) +SET(CPACK_RPM_platform_USER_FILELIST ${ignored}) -SET(CPACK_RPM_libs_USER_FILELIST -"/usr/local/mariadb/columnstore/lib/libconfigcpp.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libconfigcpp.so.1" -"/usr/local/mariadb/columnstore/lib/libconfigcpp.so" -"/usr/local/mariadb/columnstore/lib/libddlpackageproc.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libddlpackageproc.so.1" -"/usr/local/mariadb/columnstore/lib/libddlpackageproc.so" -"/usr/local/mariadb/columnstore/lib/libddlpackage.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libddlpackage.so.1" -"/usr/local/mariadb/columnstore/lib/libddlpackage.so" -"/usr/local/mariadb/columnstore/lib/libdmlpackageproc.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libdmlpackageproc.so.1" -"/usr/local/mariadb/columnstore/lib/libdmlpackageproc.so" -"/usr/local/mariadb/columnstore/lib/libdmlpackage.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libdmlpackage.so.1" -"/usr/local/mariadb/columnstore/lib/libdmlpackage.so" -"/usr/local/mariadb/columnstore/lib/libexecplan.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libexecplan.so.1" -"/usr/local/mariadb/columnstore/lib/libexecplan.so" -"/usr/local/mariadb/columnstore/lib/libfuncexp.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libfuncexp.so.1" -"/usr/local/mariadb/columnstore/lib/libfuncexp.so" -"/usr/local/mariadb/columnstore/lib/libudfsdk.so.1.1.0" -"/usr/local/mariadb/columnstore/lib/libudfsdk.so.1" -"/usr/local/mariadb/columnstore/lib/libudfsdk.so" -"/usr/local/mariadb/columnstore/lib/libjoblist.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libjoblist.so.1" -"/usr/local/mariadb/columnstore/lib/libjoblist.so" -"/usr/local/mariadb/columnstore/lib/libjoiner.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libjoiner.so.1" -"/usr/local/mariadb/columnstore/lib/libjoiner.so" -"/usr/local/mariadb/columnstore/lib/libloggingcpp.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libloggingcpp.so.1" -"/usr/local/mariadb/columnstore/lib/libloggingcpp.so" -"/usr/local/mariadb/columnstore/lib/libmessageqcpp.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libmessageqcpp.so.1" -"/usr/local/mariadb/columnstore/lib/libmessageqcpp.so" -"/usr/local/mariadb/columnstore/lib/liboamcpp.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/liboamcpp.so.1" -"/usr/local/mariadb/columnstore/lib/liboamcpp.so" -"/usr/local/mariadb/columnstore/lib/libalarmmanager.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libalarmmanager.so.1" -"/usr/local/mariadb/columnstore/lib/libalarmmanager.so" -"/usr/local/mariadb/columnstore/lib/libthreadpool.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libthreadpool.so.1" -"/usr/local/mariadb/columnstore/lib/libthreadpool.so" -"/usr/local/mariadb/columnstore/lib/libwindowfunction.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libwindowfunction.so.1" -"/usr/local/mariadb/columnstore/lib/libwindowfunction.so" -"/usr/local/mariadb/columnstore/lib/libwriteengine.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libwriteengine.so.1" -"/usr/local/mariadb/columnstore/lib/libwriteengine.so" -"/usr/local/mariadb/columnstore/lib/libwriteengineclient.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libwriteengineclient.so.1" -"/usr/local/mariadb/columnstore/lib/libwriteengineclient.so" -"/usr/local/mariadb/columnstore/lib/libbrm.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libbrm.so.1" -"/usr/local/mariadb/columnstore/lib/libbrm.so" -"/usr/local/mariadb/columnstore/lib/librwlock.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/librwlock.so.1" -"/usr/local/mariadb/columnstore/lib/librwlock.so" -"/usr/local/mariadb/columnstore/lib/libdataconvert.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libdataconvert.so.1" -"/usr/local/mariadb/columnstore/lib/libdataconvert.so" -"/usr/local/mariadb/columnstore/lib/librowgroup.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/librowgroup.so.1" -"/usr/local/mariadb/columnstore/lib/librowgroup.so" -"/usr/local/mariadb/columnstore/lib/libcacheutils.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libcacheutils.so.1" -"/usr/local/mariadb/columnstore/lib/libcacheutils.so" -"/usr/local/mariadb/columnstore/lib/libcommon.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libcommon.so.1" -"/usr/local/mariadb/columnstore/lib/libcommon.so" -"/usr/local/mariadb/columnstore/lib/libcompress.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libcompress.so.1" -"/usr/local/mariadb/columnstore/lib/libcompress.so" -"/usr/local/mariadb/columnstore/lib/libddlcleanuputil.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libddlcleanuputil.so.1" -"/usr/local/mariadb/columnstore/lib/libddlcleanuputil.so" -"/usr/local/mariadb/columnstore/lib/libbatchloader.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libbatchloader.so.1" -"/usr/local/mariadb/columnstore/lib/libbatchloader.so" -"/usr/local/mariadb/columnstore/lib/libquerystats.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libquerystats.so.1" -"/usr/local/mariadb/columnstore/lib/libquerystats.so" -"/usr/local/mariadb/columnstore/lib/libwriteengineredistribute.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libwriteengineredistribute.so.1" -"/usr/local/mariadb/columnstore/lib/libwriteengineredistribute.so" -"/usr/local/mariadb/columnstore/lib/libidbdatafile.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libidbdatafile.so.1" -"/usr/local/mariadb/columnstore/lib/libidbdatafile.so" -"/usr/local/mariadb/columnstore/lib/libthrift.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libthrift.so.1" -"/usr/local/mariadb/columnstore/lib/libthrift.so" -"/usr/local/mariadb/columnstore/lib/libquerytele.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libquerytele.so.1" -"/usr/local/mariadb/columnstore/lib/libquerytele.so" -${ignored}) +SET(CPACK_RPM_libs_USER_FILELIST ${ignored}) -SET(CPACK_RPM_storage-engine_USER_FILELIST -"/usr/local/mariadb/columnstore/lib/libcalmysql.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libcalmysql.so.1" -"/usr/local/mariadb/columnstore/lib/libcalmysql.so" -"/usr/local/mariadb/columnstore/lib/libudf_mysql.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libudf_mysql.so.1" -"/usr/local/mariadb/columnstore/lib/libudf_mysql.so" -"/usr/local/mariadb/columnstore/lib/is_columnstore_columns.so" -"/usr/local/mariadb/columnstore/lib/is_columnstore_columns.so.1" -"/usr/local/mariadb/columnstore/lib/is_columnstore_columns.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/is_columnstore_extents.so" -"/usr/local/mariadb/columnstore/lib/is_columnstore_extents.so.1" -"/usr/local/mariadb/columnstore/lib/is_columnstore_extents.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/is_columnstore_tables.so" -"/usr/local/mariadb/columnstore/lib/is_columnstore_tables.so.1" -"/usr/local/mariadb/columnstore/lib/is_columnstore_tables.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/is_columnstore_files.so" -"/usr/local/mariadb/columnstore/lib/is_columnstore_files.so.1" -"/usr/local/mariadb/columnstore/lib/is_columnstore_files.so.1.0.0" -"/usr/local/mariadb/columnstore/mysql/mysql-Columnstore" -"/usr/local/mariadb/columnstore/mysql/install_calpont_mysql.sh" -"/usr/local/mariadb/columnstore/mysql/syscatalog_mysql.sql" -"/usr/local/mariadb/columnstore/mysql/dumpcat_mysql.sql" -"/usr/local/mariadb/columnstore/mysql/calsetuserpriority.sql" -"/usr/local/mariadb/columnstore/mysql/calremoveuserpriority.sql" -"/usr/local/mariadb/columnstore/mysql/calshowprocesslist.sql" -"/usr/local/mariadb/columnstore/mysql/columnstore_info.sql" -${ignored}) +SET(CPACK_RPM_storage-engine_USER_FILELIST ${ignored}) INCLUDE (CPack) From f2d8a33ee5ee299fddebc78cfd4c16501bee348b Mon Sep 17 00:00:00 2001 From: David Hall Date: Thu, 9 May 2019 12:42:18 -0500 Subject: [PATCH 10/59] MCOL-3296 CTRL+C should not double remove from dequeue. --- dmlproc/dmlproc.cpp | 12 +++++++---- dmlproc/dmlprocessor.cpp | 36 +++++++------------------------ dmlproc/dmlprocessor.h | 38 +++++++++++++++++++++++++++++---- utils/threadpool/threadpool.cpp | 20 +++++++++++++++++ 4 files changed, 70 insertions(+), 36 deletions(-) diff --git a/dmlproc/dmlproc.cpp b/dmlproc/dmlproc.cpp index 106977824..990015ac8 100644 --- a/dmlproc/dmlproc.cpp +++ b/dmlproc/dmlproc.cpp @@ -86,6 +86,8 @@ using namespace joblist; namespace fs = boost::filesystem; +ThreadPool DMLServer::fDmlPackagepool(10, 0); + namespace { DistributedEngineComm *Dec; @@ -551,16 +553,16 @@ int main(int argc, char* argv[]) int temp; int serverThreads = 10; - int serverQueueSize = 50; + int serverQueueSize = 0; const string DMLProc("DMLProc"); temp = toInt(cf->getConfig(DMLProc, "ServerThreads")); if (temp > 0) serverThreads = temp; - temp = toInt(cf->getConfig(DMLProc, "ServerQueueSize")); - if (temp > 0) - serverQueueSize = temp; +// temp = toInt(cf->getConfig(DMLProc, "ServerQueueSize")); +// if (temp > 0) +// serverQueueSize = temp; bool rootUser = true; @@ -599,6 +601,8 @@ int main(int argc, char* argv[]) { JobStep::jobstepThreadPool.setDebug(true); JobStep::jobstepThreadPool.invoke(ThreadPoolMonitor(&JobStep::jobstepThreadPool)); + DMLServer::fDmlPackagepool.setDebug(true); + DMLServer::fDmlPackagepool.invoke(ThreadPoolMonitor(&DMLServer::fDmlPackagepool)); } //set ACTIVE state diff --git a/dmlproc/dmlprocessor.cpp b/dmlproc/dmlprocessor.cpp index 3b3a5cffc..ca0707989 100644 --- a/dmlproc/dmlprocessor.cpp +++ b/dmlproc/dmlprocessor.cpp @@ -413,7 +413,6 @@ int PackageHandler::releaseTableAccess() boost::lock_guard lock(tableOidMutex); if (fTableOid == 0 || (it=tableOidMap.find(fTableOid)) == tableOidMap.end()) { - // This will happen for DML_COMMAND, as we never got the tableoid or called synchTableAccess return 2; // For now, return codes are not used } PackageHandler::tableAccessQueue_t& tableOidQueue = it->second; @@ -433,7 +432,8 @@ int PackageHandler::releaseTableAccess() } else { - tableOidQueue.pop(); // Get off the waiting list. + if (!tableOidQueue.empty()) + tableOidQueue.pop(); // Get off the waiting list. if (tableOidQueue.empty()) { // remove the queue from the map. @@ -447,7 +447,7 @@ int PackageHandler::releaseTableAccess() int PackageHandler::forceReleaseTableAccess() { - // By removing the tcnid from the queue, the logic after the wait in + // By removing the txnid from the queue, the logic after the wait in // synchTableAccess() will release the thread and clean up if needed. std::map::iterator it; boost::lock_guard lock(tableOidMutex); @@ -481,7 +481,8 @@ void PackageHandler::run() std::string stmt; unsigned DMLLoggingId = 21; oam::OamCache* oamCache = oam::OamCache::makeOamCache(); - + SynchTable synchTable; + try { switch( fPackageType ) @@ -508,7 +509,7 @@ void PackageHandler::run() CalpontSystemCatalog::ROPair roPair = fcsc->tableRID(tableName); fTableOid = roPair.objnum; } - synchTableAccess(); // Blocks if another DML thread is using this fTableOid + synchTable.setPackage(this); // Blocks if another DML thread is using this fTableOid } #endif QueryTeleStats qts; @@ -870,7 +871,7 @@ void PackageHandler::run() CalpontSystemCatalog::ROPair roPair = fcsc->tableRID(tableName); fTableOid = roPair.objnum; } - synchTableAccess(); // Blocks if another DML thread is using this fTableOid + synchTable.setPackage(this); // Blocks if another DML thread is using this fTableOid } #endif updatePkg->set_TxnID(fTxnid); @@ -926,7 +927,7 @@ void PackageHandler::run() CalpontSystemCatalog::ROPair roPair = fcsc->tableRID(tableName); fTableOid = roPair.objnum; } - synchTableAccess(); // Blocks if another DML thread is using this fTableOid + synchTable.setPackage(this); // Blocks if another DML thread is using this fTableOid } #endif deletePkg->set_TxnID(fTxnid); @@ -989,13 +990,6 @@ void PackageHandler::run() } break; } -#ifdef MCOL_140 - if (fConcurrentSupport) - { - // MCOL-140 We're done. release the next waiting txn for this fTableOid - releaseTableAccess(); - } -#endif //Log errors if ( (result.result != dmlpackageprocessor::DMLPackageProcessor::NO_ERROR) && (result.result != dmlpackageprocessor::DMLPackageProcessor::IDBRANGE_WARNING) @@ -1017,13 +1011,6 @@ void PackageHandler::run() } catch(std::exception& e) { -#ifdef MCOL_140 - if (fConcurrentSupport) - { - // MCOL-140 We're done. release the next waiting txn for this fTableOid - releaseTableAccess(); - } -#endif cout << "dmlprocessor.cpp PackageHandler::run() package type(" << fPackageType << ") exception: " << e.what() << endl; logging::LoggingID lid(21); @@ -1040,13 +1027,6 @@ void PackageHandler::run() } catch(...) { -#ifdef MCOL_140 - if (fConcurrentSupport) - { - // MCOL-140 We're done. release the next waiting txn for this fTableOid - releaseTableAccess(); - } -#endif logging::LoggingID lid(21); logging::MessageLog ml(lid); logging::Message::Args args; diff --git a/dmlproc/dmlprocessor.h b/dmlproc/dmlprocessor.h index 2faf0cfb2..02f993df6 100644 --- a/dmlproc/dmlprocessor.h +++ b/dmlproc/dmlprocessor.h @@ -120,15 +120,16 @@ private: DMLServer(const DMLServer& rhs); DMLServer& operator=(const DMLServer& rhs); - /** @brief the thread pool for processing dml packages - */ - threadpool::ThreadPool fDmlPackagepool; - int fPackageMaxThreads; /** @brief max number of threads to process dml packages */ int fPackageWorkQueueSize; /** @brief max number of packages waiting in the work queue */ boost::scoped_ptr fMqServer; BRM::DBRM* fDbrm; + +public: + /** @brief the thread pool for processing dml packages + */ + static threadpool::ThreadPool fDmlPackagepool; }; /** @brief Thread to process a single dml package. @@ -184,6 +185,35 @@ private: static boost::mutex tableOidMutex; public: static int clearTableAccess(); + + // MCOL-3296 Add a class to call synchTableAccess on creation and + // releaseTableAccess on destuction for exception safeness. + class SynchTable + { + public: + SynchTable() : fphp(NULL) {}; + SynchTable(PackageHandler* php) + { + setPackage(php); + } + ~SynchTable() + { + if (fphp) + fphp->releaseTableAccess(); + } + bool setPackage(PackageHandler* php) + { + if (fphp) + fphp->releaseTableAccess(); + fphp = php; + if (fphp) + fphp->synchTableAccess(); + return true; + } + private: + PackageHandler* fphp; + }; + }; /** @brief processes dml packages as they arrive diff --git a/utils/threadpool/threadpool.cpp b/utils/threadpool/threadpool.cpp index 602f868c4..892a14ff2 100644 --- a/utils/threadpool/threadpool.cpp +++ b/utils/threadpool/threadpool.cpp @@ -392,6 +392,24 @@ void ThreadPool::beginThread() throw() --fIssued; --waitingFunctorsSize; fWaitingFunctors.erase(todo); + if (fDebug) + { + ostringstream oss; + oss << "Ending thread " << " on " << fName + << " max " << fMaxThreads + << " queue " << fQueueSize + << " threads " << fThreadCount + << " running " << fIssued + << " waiting " << (waitingFunctorsSize - fIssued) + << " total " << waitingFunctorsSize; + logging::Message::Args args; + logging::Message message(0); + args.add(oss.str()); + message.format( args ); + logging::LoggingID lid(22); + logging::MessageLog ml(lid); + ml.logWarningMessage( message ); + } } timeout = boost::get_system_time()+boost::posix_time::minutes(10); @@ -515,6 +533,8 @@ void ThreadPoolMonitor::operator()() << setw(4) << tv.tv_usec/100 << " Name " << fPool->fName << " Active " << fPool->waitingFunctorsSize + << " running " << fPool->fIssued + << " waiting " << (fPool->waitingFunctorsSize - fPool->fIssued) << " ThdCnt " << fPool->fThreadCount << " Max " << fPool->fMaxThreads << " Q " << fPool->fQueueSize From f98097673f72e7fbeae70fc1fd451167828a095a Mon Sep 17 00:00:00 2001 From: David Hall Date: Fri, 10 May 2019 10:04:57 -0500 Subject: [PATCH 11/59] MCOL-3296 Add logging when a dml is blocked because of another dml on the same table --- dmlproc/dmlprocessor.cpp | 53 ++++++++++++++++++++++++++++------------ dmlproc/dmlprocessor.h | 12 ++++----- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/dmlproc/dmlprocessor.cpp b/dmlproc/dmlprocessor.cpp index ca0707989..b2ef6e6f6 100644 --- a/dmlproc/dmlprocessor.cpp +++ b/dmlproc/dmlprocessor.cpp @@ -334,7 +334,7 @@ PackageHandler::~PackageHandler() // Rollback will most likely be next. // // A tranasaction for one fTableOid is not blocked by a txn for a different fTableOid. -int PackageHandler::synchTableAccess() +int PackageHandler::synchTableAccess(dmlpackage::CalpontDMLPackage* dmlPackage) { // MCOL-140 Wait for any other DML using this table. std::map::iterator it; @@ -374,9 +374,27 @@ int PackageHandler::synchTableAccess() // tableOidQueue here is the queue holding the waitng transactions for this fTableOid while (true) { - tableOidCond.wait(lock); + // Log something that we're waiting + LoggingID logid(21, fSessionID, fTxnid); + logging::Message::Args args1; + logging::Message msg(1); + ostringstream oss; + oss << "Txn is waiting for" << tableOidQueue.front() << " " << dmlPackage->get_SQLStatement() << "; |" << dmlPackage->get_SchemaName() <<"|"; + args1.add(oss.str()); + args1.add((uint64_t)fTableOid); + msg.format(args1); + logging::Logger logger(logid.fSubsysID); + logger.logMessage(LOG_TYPE_DEBUG, msg, logid); + + tableOidCond.wait(lock); + // In case of CTRL+C, the tableOidQueue could be invalidated + if ((tableOidMap.find(fTableOid))->second != tableOidQueue) + { + break; + } if (tableOidQueue.front() == fTxnid) { + // We're up next. Let's go do stuff. break; } if (tableOidQueue.empty()) @@ -458,6 +476,11 @@ int PackageHandler::forceReleaseTableAccess() } PackageHandler::tableAccessQueue_t& tableOidQueue = it->second; tableOidQueue.erase(fTxnid); + if (tableOidQueue.empty()) + { + // remove the queue from the map. + tableOidMap.erase(fTableOid); + } // release the condition tableOidCond.notify_all(); return 1; @@ -509,7 +532,7 @@ void PackageHandler::run() CalpontSystemCatalog::ROPair roPair = fcsc->tableRID(tableName); fTableOid = roPair.objnum; } - synchTable.setPackage(this); // Blocks if another DML thread is using this fTableOid + synchTable.setPackage(this, &insertPkg); // Blocks if another DML thread is using this fTableOid } #endif QueryTeleStats qts; @@ -871,7 +894,7 @@ void PackageHandler::run() CalpontSystemCatalog::ROPair roPair = fcsc->tableRID(tableName); fTableOid = roPair.objnum; } - synchTable.setPackage(this); // Blocks if another DML thread is using this fTableOid + synchTable.setPackage(this, updatePkg.get()); // Blocks if another DML thread is using this fTableOid } #endif updatePkg->set_TxnID(fTxnid); @@ -927,7 +950,7 @@ void PackageHandler::run() CalpontSystemCatalog::ROPair roPair = fcsc->tableRID(tableName); fTableOid = roPair.objnum; } - synchTable.setPackage(this); // Blocks if another DML thread is using this fTableOid + synchTable.setPackage(this, deletePkg.get()); // Blocks if another DML thread is using this fTableOid } #endif deletePkg->set_TxnID(fTxnid); @@ -1070,16 +1093,6 @@ void PackageHandler::run() void PackageHandler::rollbackPending() { - // Force a release of the processing from MCOL-140 -#ifdef MCOL_140 - if (fConcurrentSupport) - { - // MCOL-140 We're not necessarily the next in line. - // This forces this thread to be released anyway. - forceReleaseTableAccess(); - } -#endif - if (fProcessor.get() == NULL) { // This happens when batch insert @@ -1088,6 +1101,16 @@ void PackageHandler::rollbackPending() fProcessor->setRollbackPending(true); + // Force a release of the processing from MCOL-140 +#ifdef MCOL_140 + if (fConcurrentSupport) + { + // MCOL-140 We're not necessarily the next in line. + // This forces this thread to be released anyway. + forceReleaseTableAccess(); + } +#endif + ostringstream oss; oss << "PackageHandler::rollbackPending: Processing DMLPackage."; DMLProcessor::log(oss.str(), logging::LOG_TYPE_DEBUG); diff --git a/dmlproc/dmlprocessor.h b/dmlproc/dmlprocessor.h index 02f993df6..978fbdda8 100644 --- a/dmlproc/dmlprocessor.h +++ b/dmlproc/dmlprocessor.h @@ -171,12 +171,12 @@ private: // Used to serialize operations because the VSS can't handle inserts // or updates on the same block. // When an Insert, Update or Delete command arrives, we look here - // for the table oid. If found, wait until it is no onger here. + // for the table oid. If found, wait until it is no longer here. // If this transactionID (SCN) is < the transactionID in the table, don't delay // and hope for the best, as we're already out of order. // When the VSS is engineered to handle transactions out of order, all MCOL-140 // code is to be removed. - int synchTableAccess(); + int synchTableAccess(dmlpackage::CalpontDMLPackage* dmlPackage); int releaseTableAccess(); int forceReleaseTableAccess(); typedef iterable_queue tableAccessQueue_t; @@ -192,22 +192,22 @@ public: { public: SynchTable() : fphp(NULL) {}; - SynchTable(PackageHandler* php) + SynchTable(PackageHandler* php, dmlpackage::CalpontDMLPackage* dmlPackage) { - setPackage(php); + setPackage(php, dmlPackage); } ~SynchTable() { if (fphp) fphp->releaseTableAccess(); } - bool setPackage(PackageHandler* php) + bool setPackage(PackageHandler* php, dmlpackage::CalpontDMLPackage* dmlPackage) { if (fphp) fphp->releaseTableAccess(); fphp = php; if (fphp) - fphp->synchTableAccess(); + fphp->synchTableAccess(dmlPackage); return true; } private: From 45df72a416a05a8d07647be9c83629568357f121 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Tue, 14 May 2019 14:36:46 +0100 Subject: [PATCH 12/59] Fix issue during merge --- dbcon/mysql/ha_calpont_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index e57f332c5..146e026b1 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -1095,7 +1095,7 @@ uint32_t doUpdateDelete(THD* thd) else schemaName = string(item->db_name); - columnAssignmentPtr = new ColumnAssignment(item->name, "=", ""); + columnAssignmentPtr = new ColumnAssignment(item->name.str, "=", ""); Item* value = value_it++; if (value->type() == Item::STRING_ITEM) From 750b6ea0ffe527640e220d068e0963228323108b Mon Sep 17 00:00:00 2001 From: David Hall Date: Fri, 17 May 2019 12:43:18 -0500 Subject: [PATCH 13/59] MCOL-3314 When setting up statistics functions for the UM, use values that actually exist. --- dbcon/joblist/tupleaggregatestep.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/dbcon/joblist/tupleaggregatestep.cpp b/dbcon/joblist/tupleaggregatestep.cpp index b4aec4013..143af5de0 100644 --- a/dbcon/joblist/tupleaggregatestep.cpp +++ b/dbcon/joblist/tupleaggregatestep.cpp @@ -2622,8 +2622,8 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate( functionVec2[i]->fAuxColumnIndex = lastCol; // sum(x) - oidsAggDist.push_back(oidsAggDist[j]); - keysAggDist.push_back(keysAggDist[j]); + oidsAggDist.push_back(oidsAgg[j]); + keysAggDist.push_back(keysAgg[j]); scaleAggDist.push_back(0); precisionAggDist.push_back(0); typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE); @@ -2631,8 +2631,8 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate( ++lastCol; // sum(x**2) - oidsAggDist.push_back(oidsAggDist[j]); - keysAggDist.push_back(keysAggDist[j]); + oidsAggDist.push_back(oidsAgg[j]); + keysAggDist.push_back(keysAgg[j]); scaleAggDist.push_back(0); precisionAggDist.push_back(-1); typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE); @@ -3667,8 +3667,8 @@ void TupleAggregateStep::prep2PhasesAggregate( functionVecUm[i]->fAuxColumnIndex = lastCol; // sum(x) - oidsAggUm.push_back(oidsAggUm[j]); - keysAggUm.push_back(keysAggUm[j]); + oidsAggUm.push_back(oidsAggPm[j]); + keysAggUm.push_back(keysAggPm[j]); scaleAggUm.push_back(0); precisionAggUm.push_back(-1); typeAggUm.push_back(CalpontSystemCatalog::LONGDOUBLE); @@ -3676,8 +3676,8 @@ void TupleAggregateStep::prep2PhasesAggregate( ++lastCol; // sum(x**2) - oidsAggUm.push_back(oidsAggUm[j]); - keysAggUm.push_back(keysAggUm[j]); + oidsAggUm.push_back(oidsAggPm[j]); + keysAggUm.push_back(keysAggPm[j]); scaleAggUm.push_back(0); precisionAggUm.push_back(-1); typeAggUm.push_back(CalpontSystemCatalog::LONGDOUBLE); @@ -4704,8 +4704,8 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate( functionVecUm[i]->fAuxColumnIndex = lastCol; // sum(x) - oidsAggDist.push_back(oidsAggDist[j]); - keysAggDist.push_back(keysAggDist[j]); + oidsAggDist.push_back(oidsAggPm[j]); + keysAggDist.push_back(keysAggPm[j]); scaleAggDist.push_back(0); precisionAggDist.push_back(-1); typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE); @@ -4713,8 +4713,8 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate( ++lastCol; // sum(x**2) - oidsAggDist.push_back(oidsAggDist[j]); - keysAggDist.push_back(keysAggDist[j]); + oidsAggDist.push_back(oidsAggPm[j]); + keysAggDist.push_back(keysAggPm[j]); scaleAggDist.push_back(0); precisionAggDist.push_back(-1); typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE); From 01ff86096a4092a8a80d8a177620d1f076bb946e Mon Sep 17 00:00:00 2001 From: David Hall Date: Fri, 17 May 2019 12:45:09 -0500 Subject: [PATCH 14/59] MCOL-3314 When setting up statistics functions for the UM, use values that actually exist. --- dbcon/joblist/tupleaggregatestep.cpp | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/dbcon/joblist/tupleaggregatestep.cpp b/dbcon/joblist/tupleaggregatestep.cpp index e68bc9f18..07fb2a828 100755 --- a/dbcon/joblist/tupleaggregatestep.cpp +++ b/dbcon/joblist/tupleaggregatestep.cpp @@ -2325,8 +2325,8 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate( throw logic_error("(9)A UDAF function is called but there's no RowUDAFFunctionCol"); } functionVec2[i]->fAuxColumnIndex = lastCol++; - oidsAggDist.push_back(oidsAggDist[j]); // Dummy? - keysAggDist.push_back(keysAggDist[j]); // Dummy? + oidsAggDist.push_back(oidsAgg[j]); // Dummy? + keysAggDist.push_back(keysAgg[j]); // Dummy? scaleAggDist.push_back(0); precisionAggDist.push_back(0); typeAggDist.push_back(CalpontSystemCatalog::UBIGINT); @@ -2340,8 +2340,8 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate( functionVec2[i]->fAuxColumnIndex = lastCol; // sum(x) - oidsAggDist.push_back(oidsAggDist[j]); - keysAggDist.push_back(keysAggDist[j]); + oidsAggDist.push_back(oidsAgg[j]); + keysAggDist.push_back(keysAgg[j]); scaleAggDist.push_back(0); precisionAggDist.push_back(0); typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE); @@ -2349,8 +2349,8 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate( ++lastCol; // sum(x**2) - oidsAggDist.push_back(oidsAggDist[j]); - keysAggDist.push_back(keysAggDist[j]); + oidsAggDist.push_back(oidsAgg[j]); + keysAggDist.push_back(keysAgg[j]); scaleAggDist.push_back(0); precisionAggDist.push_back(0); typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE); @@ -3258,8 +3258,8 @@ void TupleAggregateStep::prep2PhasesAggregate( throw logic_error("(9)A UDAF function is called but there's no RowUDAFFunctionCol"); } functionVecUm[i]->fAuxColumnIndex = lastCol++; - oidsAggUm.push_back(oidsAggUm[j]); // Dummy? - keysAggUm.push_back(keysAggUm[j]); // Dummy? + oidsAggUm.push_back(oidsAggPm[j]); // Dummy? + keysAggUm.push_back(keysAggPm[j]); // Dummy? scaleAggUm.push_back(0); precisionAggUm.push_back(0); typeAggUm.push_back(CalpontSystemCatalog::UBIGINT); @@ -3273,8 +3273,8 @@ void TupleAggregateStep::prep2PhasesAggregate( functionVecUm[i]->fAuxColumnIndex = lastCol; // sum(x) - oidsAggUm.push_back(oidsAggUm[j]); - keysAggUm.push_back(keysAggUm[j]); + oidsAggUm.push_back(oidsAggPm[j]); + keysAggUm.push_back(keysAggPm[j]); scaleAggUm.push_back(0); precisionAggUm.push_back(0); typeAggUm.push_back(CalpontSystemCatalog::LONGDOUBLE); @@ -3282,8 +3282,8 @@ void TupleAggregateStep::prep2PhasesAggregate( ++lastCol; // sum(x**2) - oidsAggUm.push_back(oidsAggUm[j]); - keysAggUm.push_back(keysAggUm[j]); + oidsAggUm.push_back(oidsAggPm[j]); + keysAggUm.push_back(keysAggPm[j]); scaleAggUm.push_back(0); precisionAggUm.push_back(0); typeAggUm.push_back(CalpontSystemCatalog::LONGDOUBLE); @@ -4189,8 +4189,8 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate( throw logic_error("(9)A UDAF function is called but there's no RowUDAFFunctionCol"); } functionVecUm[i]->fAuxColumnIndex = lastCol++; - oidsAggDist.push_back(oidsAggUm[j]); // Dummy? - keysAggDist.push_back(keysAggUm[j]); // Dummy? + oidsAggDist.push_back(oidsAggPm[j]); // Dummy? + keysAggDist.push_back(keysAggPm[j]); // Dummy? scaleAggDist.push_back(0); precisionAggDist.push_back(0); typeAggDist.push_back(CalpontSystemCatalog::UBIGINT); @@ -4203,8 +4203,8 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate( functionVecUm[i]->fAuxColumnIndex = lastCol; // sum(x) - oidsAggDist.push_back(oidsAggDist[j]); - keysAggDist.push_back(keysAggDist[j]); + oidsAggDist.push_back(oidsAggPm[j]); + keysAggDist.push_back(keysAggPm[j]); scaleAggDist.push_back(0); precisionAggDist.push_back(0); typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE); @@ -4212,8 +4212,8 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate( ++lastCol; // sum(x**2) - oidsAggDist.push_back(oidsAggDist[j]); - keysAggDist.push_back(keysAggDist[j]); + oidsAggDist.push_back(oidsAggPm[j]); + keysAggDist.push_back(keysAggPm[j]); scaleAggDist.push_back(0); precisionAggDist.push_back(0); typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE); From fa0947caaaa294ffbcd3115b2c9fd7cec47b377b Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Thu, 23 May 2019 13:47:20 +0100 Subject: [PATCH 15/59] Revert "MCOL-1559 remove unused boost/trim header" This reverts commit 28e743bf38e6cc143d21e047cfcc7af105a665c5. --- dbcon/joblist/jlf_execplantojoblist.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dbcon/joblist/jlf_execplantojoblist.cpp b/dbcon/joblist/jlf_execplantojoblist.cpp index fff1b12fb..e9068b5e8 100644 --- a/dbcon/joblist/jlf_execplantojoblist.cpp +++ b/dbcon/joblist/jlf_execplantojoblist.cpp @@ -36,6 +36,7 @@ using namespace std; #include #include #include +#include namespace ba = boost::algorithm; #include "calpontexecutionplan.h" From 182e31e2829cc26aa4bf5103a64f1abe55951264 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Thu, 23 May 2019 13:47:42 +0100 Subject: [PATCH 16/59] Revert "MCOL-1559 backout trim before setting compare. Shouldn't do this in all cases." This reverts commit d78944d9ff894f677b63726d3e4f0a89763c8521. --- dbcon/joblist/jlf_execplantojoblist.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dbcon/joblist/jlf_execplantojoblist.cpp b/dbcon/joblist/jlf_execplantojoblist.cpp index e9068b5e8..2cad5870e 100644 --- a/dbcon/joblist/jlf_execplantojoblist.cpp +++ b/dbcon/joblist/jlf_execplantojoblist.cpp @@ -1674,6 +1674,8 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo) pds->cardinality(sc->cardinality()); //Add the filter + // MCOL-1559 trim before adding. + boost::trim_right_if(constval, boost::is_any_of(" ")); pds->addFilter(cop, constval); // data list for pcolstep output From 8b1c0f610164cc8ca14e1f701a5f98412d82fc71 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Thu, 23 May 2019 13:48:00 +0100 Subject: [PATCH 17/59] Revert "MCOL-1559 trim constant varchar string before adding filter" This reverts commit b6484dda4aa5703606cf74fe77e29101625cff33. --- dbcon/joblist/jlf_execplantojoblist.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbcon/joblist/jlf_execplantojoblist.cpp b/dbcon/joblist/jlf_execplantojoblist.cpp index 2cad5870e..4bd41530d 100644 --- a/dbcon/joblist/jlf_execplantojoblist.cpp +++ b/dbcon/joblist/jlf_execplantojoblist.cpp @@ -1636,6 +1636,8 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo) } string constval(cc->constval()); +// boost::trim_right_if(constval, boost::is_any_of(" ")); + CalpontSystemCatalog::OID dictOid = 0; CalpontSystemCatalog::ColType ct = sc->colType(); @@ -1674,8 +1676,6 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo) pds->cardinality(sc->cardinality()); //Add the filter - // MCOL-1559 trim before adding. - boost::trim_right_if(constval, boost::is_any_of(" ")); pds->addFilter(cop, constval); // data list for pcolstep output From 73f7307ca264d775c9b636bbadb813df5da3f998 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Thu, 23 May 2019 13:48:18 +0100 Subject: [PATCH 18/59] Revert "MCOL-1559 trailing space compare" This reverts commit e2cb6444843494e62ae8eacb0a1c3425400b7f69. --- dbcon/execplan/predicateoperator.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dbcon/execplan/predicateoperator.h b/dbcon/execplan/predicateoperator.h index 08f0c40cf..daa078948 100644 --- a/dbcon/execplan/predicateoperator.h +++ b/dbcon/execplan/predicateoperator.h @@ -456,8 +456,18 @@ inline bool PredicateOperator::getBoolVal(rowgroup::Row& row, bool& isNull, Retu isNull = false; return !ret; } +#if 0 + if (isNull) + return false; - // MCOL-1559 + const std::string& val1 = lop->getStrVal(row, isNull); + + if (isNull) + return false; + + return strCompare(val1, rop->getStrVal(row, isNull)) && !isNull; +#endif + // MCOL-1559 std::string val1 = lop->getStrVal(row, isNull); if (isNull) return false; From f3449fe2f47c3f1f15ba88d4e65ae463b8fab3ae Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Thu, 23 May 2019 13:48:31 +0100 Subject: [PATCH 19/59] Revert "MCOL-1559 trailing space compare" This reverts commit 5b581f53cbe1c0a7b27ac63fdddcffeccd866103. --- dbcon/execplan/predicateoperator.h | 12 ++---------- dbcon/joblist/jlf_execplantojoblist.cpp | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/dbcon/execplan/predicateoperator.h b/dbcon/execplan/predicateoperator.h index daa078948..70209df5b 100644 --- a/dbcon/execplan/predicateoperator.h +++ b/dbcon/execplan/predicateoperator.h @@ -456,19 +456,11 @@ inline bool PredicateOperator::getBoolVal(rowgroup::Row& row, bool& isNull, Retu isNull = false; return !ret; } -#if 0 - if (isNull) - return false; - - const std::string& val1 = lop->getStrVal(row, isNull); if (isNull) return false; - return strCompare(val1, rop->getStrVal(row, isNull)) && !isNull; -#endif - // MCOL-1559 - std::string val1 = lop->getStrVal(row, isNull); + std::string val1 = lop->getStrVal(row, isNull); if (isNull) return false; @@ -480,7 +472,7 @@ inline bool PredicateOperator::getBoolVal(rowgroup::Row& row, bool& isNull, Retu boost::trim_right_if(val2, boost::is_any_of(" ")); return strCompare(val1, val2); - } + } //FIXME: ??? case execplan::CalpontSystemCatalog::VARBINARY: diff --git a/dbcon/joblist/jlf_execplantojoblist.cpp b/dbcon/joblist/jlf_execplantojoblist.cpp index 4bd41530d..24ec7f50e 100644 --- a/dbcon/joblist/jlf_execplantojoblist.cpp +++ b/dbcon/joblist/jlf_execplantojoblist.cpp @@ -1636,7 +1636,7 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo) } string constval(cc->constval()); -// boost::trim_right_if(constval, boost::is_any_of(" ")); + boost::trim_right_if(constval, boost::is_any_of(" ")); CalpontSystemCatalog::OID dictOid = 0; From e7a331f3f86290972973f717a4dc2e235c1c9ced Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Thu, 23 May 2019 13:48:43 +0100 Subject: [PATCH 20/59] Revert "MCOL-1559 trim spaces before compare" This reverts commit 8d553ae9fbbe8ddcc984966a45f632a1896fdf81. --- dbcon/execplan/predicateoperator.h | 4 ++-- dbcon/mysql/ha_calpont_execplan.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dbcon/execplan/predicateoperator.h b/dbcon/execplan/predicateoperator.h index 70209df5b..f81f189bb 100644 --- a/dbcon/execplan/predicateoperator.h +++ b/dbcon/execplan/predicateoperator.h @@ -460,11 +460,11 @@ inline bool PredicateOperator::getBoolVal(rowgroup::Row& row, bool& isNull, Retu if (isNull) return false; - std::string val1 = lop->getStrVal(row, isNull); + const std::string& val1 = lop->getStrVal(row, isNull); if (isNull) return false; - std::string val2 = rop->getStrVal(row, isNull); + const std::string& val2 = rop->getStrVal(row, isNull); if (isNull) return false; diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index 65d0ac4a6..239ae9f0c 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -49,6 +49,7 @@ using namespace std; #include #include +#include #include #include @@ -4868,6 +4869,7 @@ void gp_walk(const Item* item, void* arg) { cval.assign(str->ptr(), str->length()); } +// boost::trim_right_if(cval, boost::is_any_of(" ")); gwip->rcWorkStack.push(new ConstantColumn(cval)); break; From 922e828d6c52a722ba9c4f74c16269de301facba Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Thu, 23 May 2019 13:48:56 +0100 Subject: [PATCH 21/59] Revert "MCOL-1559 trailing white space comparison" This reverts commit aa802f44c534a21ff447b3025ae3e07ac323e337. --- dbcon/execplan/predicateoperator.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/dbcon/execplan/predicateoperator.h b/dbcon/execplan/predicateoperator.h index f81f189bb..b83931394 100644 --- a/dbcon/execplan/predicateoperator.h +++ b/dbcon/execplan/predicateoperator.h @@ -36,7 +36,6 @@ #endif #include #include -#include #include "expressionparser.h" #include "returnedcolumn.h" @@ -461,17 +460,11 @@ inline bool PredicateOperator::getBoolVal(rowgroup::Row& row, bool& isNull, Retu return false; const std::string& val1 = lop->getStrVal(row, isNull); + if (isNull) return false; - const std::string& val2 = rop->getStrVal(row, isNull); - if (isNull) - return false; - - boost::trim_right_if(val1, boost::is_any_of(" ")); - boost::trim_right_if(val2, boost::is_any_of(" ")); - - return strCompare(val1, val2); + return strCompare(val1, rop->getStrVal(row, isNull)) && !isNull; } //FIXME: ??? From 9390ee05fb74c7edb28ff4f3e80bdb2f4b62aeaf Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Thu, 23 May 2019 13:49:08 +0100 Subject: [PATCH 22/59] Revert "MCOL-1559 Some string trailing blank stuff" This reverts commit e5d76e142be7edcbbf0817f5bea594ddffc84973. --- dbcon/joblist/jlf_execplantojoblist.cpp | 2 -- dbcon/joblist/lbidlist.cpp | 1 - dbcon/mysql/ha_calpont_execplan.cpp | 2 -- primitives/primproc/dictstep.cpp | 2 -- primitives/primproc/primitiveserver.cpp | 2 -- 5 files changed, 9 deletions(-) diff --git a/dbcon/joblist/jlf_execplantojoblist.cpp b/dbcon/joblist/jlf_execplantojoblist.cpp index 24ec7f50e..f3782c9d5 100644 --- a/dbcon/joblist/jlf_execplantojoblist.cpp +++ b/dbcon/joblist/jlf_execplantojoblist.cpp @@ -36,7 +36,6 @@ using namespace std; #include #include #include -#include namespace ba = boost::algorithm; #include "calpontexecutionplan.h" @@ -1636,7 +1635,6 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo) } string constval(cc->constval()); - boost::trim_right_if(constval, boost::is_any_of(" ")); CalpontSystemCatalog::OID dictOid = 0; diff --git a/dbcon/joblist/lbidlist.cpp b/dbcon/joblist/lbidlist.cpp index 7852562ef..c317defc9 100644 --- a/dbcon/joblist/lbidlist.cpp +++ b/dbcon/joblist/lbidlist.cpp @@ -749,7 +749,6 @@ bool LBIDList::CasualPartitionPredicate(const int64_t Min, int64_t tMax = Max; dataconvert::DataConvert::trimWhitespace(tMin); dataconvert::DataConvert::trimWhitespace(tMax); - dataconvert::DataConvert::trimWhitespace(value); scan = compareVal(order_swap(tMin), order_swap(tMax), order_swap(value), op, lcf); diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index 239ae9f0c..65d0ac4a6 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -49,7 +49,6 @@ using namespace std; #include #include -#include #include #include @@ -4869,7 +4868,6 @@ void gp_walk(const Item* item, void* arg) { cval.assign(str->ptr(), str->length()); } -// boost::trim_right_if(cval, boost::is_any_of(" ")); gwip->rcWorkStack.push(new ConstantColumn(cval)); break; diff --git a/primitives/primproc/dictstep.cpp b/primitives/primproc/dictstep.cpp index 47bfeac25..abd99ada3 100644 --- a/primitives/primproc/dictstep.cpp +++ b/primitives/primproc/dictstep.cpp @@ -30,7 +30,6 @@ #include #include -#include #include "bpp.h" #include "primitiveserver.h" @@ -94,7 +93,6 @@ void DictStep::createCommand(ByteStream& bs) for (uint32_t i = 0; i < filterCount; i++) { bs >> strTmp; - boost::trim_right_if(strTmp, boost::is_any_of(" ")); //cout << " " << strTmp << endl; eqFilter->insert(strTmp); } diff --git a/primitives/primproc/primitiveserver.cpp b/primitives/primproc/primitiveserver.cpp index 54f4b7fb6..1e497122e 100644 --- a/primitives/primproc/primitiveserver.cpp +++ b/primitives/primproc/primitiveserver.cpp @@ -28,7 +28,6 @@ #include #include #include -#include //#define NDEBUG #include #include @@ -1778,7 +1777,6 @@ private: for (i = 0; i < count; i++) { *bs >> str; - boost::trim_right_if(str, boost::is_any_of(" ")); filter->insert(str); } From 6b2f67a23747942861d347d15f5cab7c55bc70a5 Mon Sep 17 00:00:00 2001 From: David Hall Date: Thu, 23 May 2019 14:15:58 -0500 Subject: [PATCH 23/59] MCOL-3314 Use something useful for stats functions oid and key during prep1PhaseAggregate --- dbcon/joblist/tupleaggregatestep.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dbcon/joblist/tupleaggregatestep.cpp b/dbcon/joblist/tupleaggregatestep.cpp index 143af5de0..396e6a6ae 100644 --- a/dbcon/joblist/tupleaggregatestep.cpp +++ b/dbcon/joblist/tupleaggregatestep.cpp @@ -1583,8 +1583,8 @@ void TupleAggregateStep::prep1PhaseAggregate( } functionVec[i]->fAuxColumnIndex = lastCol++; - oidsAgg.push_back(oidsAgg[j]); - keysAgg.push_back(keysAgg[j]); + oidsAgg.push_back(oidsProj[j]); + keysAgg.push_back(keysProj[j]); scaleAgg.push_back(0); precisionAgg.push_back(0); precisionAgg.push_back(0); @@ -1599,8 +1599,8 @@ void TupleAggregateStep::prep1PhaseAggregate( functionVec[i]->fAuxColumnIndex = lastCol; // sum(x) - oidsAgg.push_back(oidsAgg[j]); - keysAgg.push_back(keysAgg[j]); + oidsAgg.push_back(oidsProj[j]); + keysAgg.push_back(keysProj[j]); scaleAgg.push_back(0); precisionAgg.push_back(-1); typeAgg.push_back(CalpontSystemCatalog::LONGDOUBLE); @@ -1608,8 +1608,8 @@ void TupleAggregateStep::prep1PhaseAggregate( ++lastCol; // sum(x**2) - oidsAgg.push_back(oidsAgg[j]); - keysAgg.push_back(keysAgg[j]); + oidsAgg.push_back(oidsProj[j]); + keysAgg.push_back(keysProj[j]); scaleAgg.push_back(0); precisionAgg.push_back(-1); typeAgg.push_back(CalpontSystemCatalog::LONGDOUBLE); From 42f29096f0cc9f639ddc46e0ea0854eebdcf3d6b Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Thu, 23 May 2019 22:22:55 +0300 Subject: [PATCH 24/59] MCOL-3239 CS pushes relevant filter predicates into derived tables. This change disables predicate push for function column that contains both derived table column and non-derived table column. --- dbcon/execplan/functioncolumn.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dbcon/execplan/functioncolumn.cpp b/dbcon/execplan/functioncolumn.cpp index 487d42c0b..665e4a4c3 100644 --- a/dbcon/execplan/functioncolumn.cpp +++ b/dbcon/execplan/functioncolumn.cpp @@ -420,6 +420,16 @@ void FunctionColumn::setDerivedTable() break; } } + // MCOL-3239 Block for func column with both + // derived table column and normal table column. + else if (derivedTableAlias == "") + { + if (sc->tableAlias().length()) + { + derivedTableAlias = ""; + break; + } + } } fDerivedTable = derivedTableAlias; From 23b594eb284add47f3b97a6f20dd00eb2cf3a640 Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 28 May 2019 15:56:30 -0500 Subject: [PATCH 25/59] MCOL-3304 During prepAggregate, if you set type to LONGDOUBLE, set scale to 0 --- dbcon/execplan/windowfunctioncolumn.cpp | 1 + dbcon/joblist/tupleaggregatestep.cpp | 36 ++++++++++++------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/dbcon/execplan/windowfunctioncolumn.cpp b/dbcon/execplan/windowfunctioncolumn.cpp index e01c5c010..5c3e57407 100644 --- a/dbcon/execplan/windowfunctioncolumn.cpp +++ b/dbcon/execplan/windowfunctioncolumn.cpp @@ -386,6 +386,7 @@ void WindowFunctionColumn::adjustResultType() fResultType.colDataType = CalpontSystemCatalog::LONGDOUBLE; fResultType.colWidth = sizeof(long double); fResultType.precision = -1; + fResultType.scale = 0; } } diff --git a/dbcon/joblist/tupleaggregatestep.cpp b/dbcon/joblist/tupleaggregatestep.cpp index 143af5de0..23a8e8782 100644 --- a/dbcon/joblist/tupleaggregatestep.cpp +++ b/dbcon/joblist/tupleaggregatestep.cpp @@ -1406,7 +1406,7 @@ void TupleAggregateStep::prep1PhaseAggregate( typeAgg.push_back(CalpontSystemCatalog::LONGDOUBLE); precisionAgg.push_back(-1); widthAgg.push_back(sizeof(long double)); - scaleAgg.push_back(scaleProj[colProj]); + scaleAgg.push_back(0); } break; @@ -1935,7 +1935,7 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate( typeAgg.push_back(CalpontSystemCatalog::LONGDOUBLE); precisionAgg.push_back(-1); widthAgg.push_back(sizeof(long double)); - scaleAgg.push_back(scaleProj[colProj]); + scaleAgg.push_back(0); colAgg++; // has distinct step, put the count column for avg next to the sum @@ -2255,7 +2255,7 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate( typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE); precisionAggDist.push_back(-1); widthAggDist.push_back(sizeof(long double)); - scaleAggDist.push_back(scaleProj[colAgg]); + scaleAggDist.push_back(0); } break; @@ -2327,10 +2327,10 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate( { oidsAggDist.push_back(oidsAgg[colAgg]); keysAggDist.push_back(retKey); - scaleAggDist.push_back(scaleAgg[colAgg] >> 8); - precisionAggDist.push_back(precisionAgg[colAgg]); - typeAggDist.push_back(typeAgg[colAgg]); - widthAggDist.push_back(widthAgg[colAgg]); + scaleAggDist.push_back(0); + typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE); + precisionAggDist.push_back(-1); + widthAggDist.push_back(sizeof(long double)); } else { @@ -3173,7 +3173,7 @@ void TupleAggregateStep::prep2PhasesAggregate( oidsAggPm.push_back(oidsProj[colProj]); keysAggPm.push_back(aggKey); typeAggPm.push_back(CalpontSystemCatalog::LONGDOUBLE); - scaleAggPm.push_back(scaleProj[colProj]); + scaleAggPm.push_back(0); precisionAggPm.push_back(-1); widthAggPm.push_back(sizeof(long double)); colAggPm++; @@ -3449,10 +3449,10 @@ void TupleAggregateStep::prep2PhasesAggregate( { oidsAggUm.push_back(oidsAggPm[colPm]); keysAggUm.push_back(retKey); - scaleAggUm.push_back(scaleAggPm[colPm] >> 8); - precisionAggUm.push_back(precisionAggPm[colPm]); - typeAggUm.push_back(typeAggPm[colPm]); - widthAggUm.push_back(widthAggPm[colPm]); + scaleAggUm.push_back(0); + typeAggUm.push_back(CalpontSystemCatalog::LONGDOUBLE); + precisionAggUm.push_back(-1); + widthAggUm.push_back(sizeof(long double)); } else { @@ -4027,7 +4027,7 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate( typeAggPm.push_back(CalpontSystemCatalog::LONGDOUBLE); precisionAggPm.push_back(-1); widthAggPm.push_back(sizeof(long double)); - scaleAggPm.push_back(scaleProj[colProj]); + scaleAggPm.push_back(0); colAggPm++; } @@ -4394,7 +4394,7 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate( typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE); precisionAggDist.push_back(-1); widthAggDist.push_back(sizeof(long double)); - scaleAggDist.push_back(scaleAggUm[colUm]); + scaleAggDist.push_back(0); } // PM: put the count column for avg next to the sum // let fall through to add a count column for average function @@ -4456,10 +4456,10 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate( { oidsAggDist.push_back(oidsAggUm[colUm]); keysAggDist.push_back(retKey); - scaleAggDist.push_back(scaleAggUm[colUm] >> 8); - precisionAggDist.push_back(precisionAggUm[colUm]); - typeAggDist.push_back(typeAggUm[colUm]); - widthAggDist.push_back(widthAggUm[colUm]); + scaleAggDist.push_back(0); + typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE); + precisionAggDist.push_back(-1); + widthAggDist.push_back(sizeof(long double)); } else { From fff18e0dd41f22e97b3ca78497e7cb2f20c924ea Mon Sep 17 00:00:00 2001 From: David Mott Date: Mon, 3 Jun 2019 03:36:48 -0500 Subject: [PATCH 26/59] fix to possible memory corruption --- dbcon/execplan/arithmeticcolumn.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dbcon/execplan/arithmeticcolumn.cpp b/dbcon/execplan/arithmeticcolumn.cpp index aab6c9265..2128a47ed 100644 --- a/dbcon/execplan/arithmeticcolumn.cpp +++ b/dbcon/execplan/arithmeticcolumn.cpp @@ -326,7 +326,8 @@ void ArithmeticColumn::serialize(messageqcpp::ByteStream& b) const ObjectReader::writeParseTree(fExpression, b); b << fTableAlias; b << fData; - b << static_cast(fAsc); + const ByteStream::doublebyte tmp = fAsc; + b << tmp; } void ArithmeticColumn::unserialize(messageqcpp::ByteStream& b) @@ -340,7 +341,9 @@ void ArithmeticColumn::unserialize(messageqcpp::ByteStream& b) fExpression = ObjectReader::createParseTree(b); b >> fTableAlias; b >> fData; - b >> reinterpret_cast< ByteStream::doublebyte&>(fAsc); + ByteStream::doublebyte tmp; + b >> tmp; + fAsc = (tmp); fSimpleColumnList.clear(); fExpression->walk(getSimpleCols, &fSimpleColumnList); From 0983c1becf0e66de8b06024e6504f4ffb7dc245a Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Mon, 10 Jun 2019 16:46:24 +0100 Subject: [PATCH 27/59] MCOL-2230 Fix TIMEDIFF() handling TIMEDIFF would not compare datetime with string correctly, causing a NULL saturation. --- utils/funcexp/func_timediff.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/funcexp/func_timediff.cpp b/utils/funcexp/func_timediff.cpp index 369bb80a1..c4de35a0d 100644 --- a/utils/funcexp/func_timediff.cpp +++ b/utils/funcexp/func_timediff.cpp @@ -118,7 +118,10 @@ string Func_timediff::getStrVal(rowgroup::Row& row, case execplan::CalpontSystemCatalog::TIME: case execplan::CalpontSystemCatalog::DATETIME: - if (type1 != type2) + // Diff between time and datetime returns NULL in MariaDB + if ((type2 == execplan::CalpontSystemCatalog::TIME || + type2 == execplan::CalpontSystemCatalog::DATETIME) && + type1 != type2) { isNull = true; break; From e3cd20538887c037faea1f93cdda32763f7fc7fb Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Tue, 11 Jun 2019 10:37:04 +0100 Subject: [PATCH 28/59] MCOL-1968 Fix UTF char/varchar min/max handling If the first byte of a char/varchar was > 0x80 then it will break the min/max values for an extent during cpimport. This patch makes the min/max compare unsigned and only switches to signed when storing. In addition send all the LDI / INSERT...SELECT data to cpimport, not truncated. Let cpimport figure out the truncation point. --- dbcon/mysql/ha_calpont_dml.cpp | 18 ++++++++++-------- writeengine/bulk/we_bulkloadbuffer.cpp | 11 +++++++---- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/dbcon/mysql/ha_calpont_dml.cpp b/dbcon/mysql/ha_calpont_dml.cpp index c2dc36e47..a9404c223 100755 --- a/dbcon/mysql/ha_calpont_dml.cpp +++ b/dbcon/mysql/ha_calpont_dml.cpp @@ -860,7 +860,13 @@ int ha_calpont_impl_write_batch_row_(uchar *buf, TABLE* table, cal_impl_if::cal_ } case CalpontSystemCatalog::VARCHAR: { - if (nullVal && (ci.columnTypes[colpos].constraintType != CalpontSystemCatalog::NOTNULL_CONSTRAINT)) + size_t length; + if (ci.utf8) + length = (ci.columnTypes[colpos].colWidth * 3); + else + length = ci.columnTypes[colpos].colWidth; + + if (nullVal && (ci.columnTypes[colpos].constraintType != CalpontSystemCatalog::NOTNULL_CONSTRAINT)) { fprintf(ci.filePtr, "%c", ci.delimiter); if (!ci.utf8) @@ -901,6 +907,7 @@ int ha_calpont_impl_write_batch_row_(uchar *buf, TABLE* table, cal_impl_if::cal_ dataLength = *(uint16_t*) buf; buf = buf + 2 ; } + length = dataLength; escape.assign((char*)buf, dataLength); boost::replace_all(escape, "\\", "\\\\"); fprintf(ci.filePtr, "%c%.*s%c%c", ci.enclosed_by, (int)escape.length(), escape.c_str(), ci.enclosed_by, ci.delimiter); @@ -917,8 +924,7 @@ int ha_calpont_impl_write_batch_row_(uchar *buf, TABLE* table, cal_impl_if::cal_ dataLength = *(uint16_t*) buf; buf = buf + 2 ; } - if ( dataLength > ci.columnTypes[colpos].colWidth) - dataLength = ci.columnTypes[colpos].colWidth; + length = dataLength; escape.assign((char*)buf, dataLength); boost::replace_all(escape, "\\", "\\\\"); @@ -926,11 +932,7 @@ int ha_calpont_impl_write_batch_row_(uchar *buf, TABLE* table, cal_impl_if::cal_ fprintf(ci.filePtr, "%c%.*s%c%c", ci.enclosed_by, (int)escape.length(), escape.c_str(), ci.enclosed_by, ci.delimiter); } } - //buf += ci.columnTypes[colpos].colWidth; - if (ci.utf8) - buf += (ci.columnTypes[colpos].colWidth * 3); - else - buf += ci.columnTypes[colpos].colWidth; + buf += length; break; } diff --git a/writeengine/bulk/we_bulkloadbuffer.cpp b/writeengine/bulk/we_bulkloadbuffer.cpp index b1902e98f..7326f987b 100644 --- a/writeengine/bulk/we_bulkloadbuffer.cpp +++ b/writeengine/bulk/we_bulkloadbuffer.cpp @@ -524,13 +524,16 @@ void BulkLoadBuffer::convert(char *field, int fieldLength, } // Swap byte order before comparing character string - int64_t binChar = static_cast( uint64ToStr( - *(reinterpret_cast(charTmpBuf)) ) ); + // Compare must be unsigned + uint64_t compChar = uint64ToStr( *(reinterpret_cast(charTmpBuf)) ); + int64_t binChar = static_cast( compChar ); // Update min/max range - if (binChar < bufStats.minBufferVal) + uint64_t minVal = static_cast( bufStats.minBufferVal ); + uint64_t maxVal = static_cast( bufStats.maxBufferVal ); + if (compChar < minVal) bufStats.minBufferVal = binChar; - if (binChar > bufStats.maxBufferVal) + if (compChar > maxVal) bufStats.maxBufferVal = binChar; pVal = charTmpBuf; From ea6592ea080640252f5eb2ff07c764ef3a350a31 Mon Sep 17 00:00:00 2001 From: David Hall Date: Wed, 12 Jun 2019 14:17:31 -0500 Subject: [PATCH 29/59] MCOL-3343 Try adding aggregate result to jobInfo.nonConstDelCol vector --- dbcon/joblist/joblistfactory.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dbcon/joblist/joblistfactory.cpp b/dbcon/joblist/joblistfactory.cpp index 21df156a7..0a141f03a 100644 --- a/dbcon/joblist/joblistfactory.cpp +++ b/dbcon/joblist/joblistfactory.cpp @@ -397,6 +397,7 @@ void checkHavingClause(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo) void preProcessFunctionOnAggregation(const vector& scs, const vector& aggs, + const vector& wcs, JobInfo& jobInfo) { // append the simple columns if not already projected @@ -426,10 +427,14 @@ void preProcessFunctionOnAggregation(const vector& scs, } } - // append the aggregate columns in arithmetic/function cloulmn to the projection list + // append the aggregate columns in arithmetic/function column to the projection list for (vector::const_iterator i = aggs.begin(); i != aggs.end(); i++) { addAggregateColumn(*i, -1, jobInfo.projectionCols, jobInfo); + if (wcs.size() > 0) + { + jobInfo.nonConstDelCols.push_back(SRCP((*i)->clone())); + } } } @@ -481,12 +486,12 @@ void checkReturnedColumns(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo) if (ac != NULL && ac->aggColumnList().size() > 0) { jobInfo.nonConstCols[i]->outputIndex(i); - preProcessFunctionOnAggregation(ac->simpleColumnList(), ac->aggColumnList(), jobInfo); + preProcessFunctionOnAggregation(ac->simpleColumnList(), ac->aggColumnList(), ac->windowfunctionColumnList(), jobInfo); } else if (fc != NULL && fc->aggColumnList().size() > 0) { jobInfo.nonConstCols[i]->outputIndex(i); - preProcessFunctionOnAggregation(fc->simpleColumnList(), fc->aggColumnList(), jobInfo); + preProcessFunctionOnAggregation(fc->simpleColumnList(), fc->aggColumnList(), fc->windowfunctionColumnList(), jobInfo); } } } From 7d22a5945c68456029e10c44ff402b96d8b25836 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Fri, 14 Jun 2019 15:52:30 +0100 Subject: [PATCH 30/59] MCOL-1989 Fix view in view subquery outer join A view calling a view as part of a subquery outer join was not getting the view name for the derived table columns. Which caused ColumnStore to think it was joining outside of the view and triggered a missing column error. This fix adds the view name from the subquery if one cannot be obtained from the field object. --- dbcon/execplan/calpontselectexecutionplan.h | 5 +++++ dbcon/mysql/ha_calpont_execplan.cpp | 9 ++++++++- dbcon/mysql/ha_from_sub.cpp | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dbcon/execplan/calpontselectexecutionplan.h b/dbcon/execplan/calpontselectexecutionplan.h index f77d5c0f7..cacb9d3f5 100644 --- a/dbcon/execplan/calpontselectexecutionplan.h +++ b/dbcon/execplan/calpontselectexecutionplan.h @@ -354,6 +354,10 @@ public: void derivedTbAlias(const std::string derivedTbAlias) { fDerivedTbAlias = derivedTbAlias; } const std::string derivedTbAlias() const { return fDerivedTbAlias; } + void derivedTbView(const std::string derivedTbView) { fDerivedTbView = derivedTbView; } + const std::string derivedTbView() const { return fDerivedTbView; } + + void limitStart(const uint64_t limitStart) { fLimitStart = limitStart; } const uint64_t limitStart() const { return fLimitStart; } @@ -565,6 +569,7 @@ private: // for subselect uint64_t fSubType; std::string fDerivedTbAlias; + std::string fDerivedTbView; // for limit uint64_t fLimitStart; diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index 2383f7ff7..d0e96c412 100755 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -1833,7 +1833,14 @@ SimpleColumn* buildSimpleColFromDerivedTable(gp_walk_info& gwi, Item_field* ifp) sc->colPosition(j); string tableAlias(csep->derivedTbAlias()); sc->tableAlias(lower(tableAlias)); - sc->viewName(lower(viewName)); + if (!viewName.empty()) + { + sc->viewName(viewName); + } + else + { + sc->viewName(csep->derivedTbView()); + } sc->resultType(cols[j]->resultType()); sc->hasAggregate(cols[j]->hasAggregate()); if (col) diff --git a/dbcon/mysql/ha_from_sub.cpp b/dbcon/mysql/ha_from_sub.cpp index 0dd9eeb0e..a12221fc5 100755 --- a/dbcon/mysql/ha_from_sub.cpp +++ b/dbcon/mysql/ha_from_sub.cpp @@ -317,6 +317,7 @@ SCSEP FromSubQuery::transform() gwi.subQuery = this; gwi.viewName = fGwip.viewName; csep->derivedTbAlias(fAlias); // always lower case + csep->derivedTbView(fGwip.viewName.alias); if (getSelectPlan(gwi, *fFromSub, csep) != 0) { From e3e59dd167658810218a4f6c5c4b49b69ff6afba Mon Sep 17 00:00:00 2001 From: Ben Thompson Date: Mon, 17 Jun 2019 12:33:15 -0500 Subject: [PATCH 31/59] Update Version to 1.2.5 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 91bc7ea08..f67d0ae71 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ COLUMNSTORE_VERSION_MAJOR=1 COLUMNSTORE_VERSION_MINOR=2 -COLUMNSTORE_VERSION_PATCH=4 +COLUMNSTORE_VERSION_PATCH=5 COLUMNSTORE_VERSION_RELEASE=1 From b05c4e8df4e1f3a2bdbbd14896bce658b074d0fb Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Tue, 18 Jun 2019 16:13:50 +0100 Subject: [PATCH 32/59] MCOL-2243 Only set length and dec when dec is zero Length and dec for columns only needs to be set when it is the result of a function. Otherwise it could lead to odd side-effects in MariaDB. --- dbcon/mysql/ha_calpont_impl.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index a6cbea6a9..eb3b85384 100755 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -579,7 +579,12 @@ int fetchNextRow(uchar *buf, cal_table_info& ti, cal_connection_info* ci) // bug 3485, reserve enough space for the longest float value // -3.402823466E+38 to -1.175494351E-38, 0, and // 1.175494351E-38 to 3.402823466E+38. - (*f)->field_length = 40; + if (!f2->dec) + { + (*f)->field_length = 40; + f2->dec = row.getScale(s); + } + //float float_val = *(float*)(&value); //f2->store(float_val); if (f2->decimals() < (uint32_t)row.getScale(s)) @@ -602,7 +607,12 @@ int fetchNextRow(uchar *buf, cal_table_info& ti, cal_connection_info* ci) // 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->dec) + { + (*f)->field_length = 310; + f2->dec = row.getScale(s); + } + //double double_val = *(double*)(&value); //f2->store(double_val); if (f2->decimals() < (uint32_t)row.getScale(s)) From 4cf2c37c1801de6c7cce02d14c439b976e17428e Mon Sep 17 00:00:00 2001 From: David Hall Date: Thu, 20 Jun 2019 09:24:58 -0500 Subject: [PATCH 33/59] MCOL-3343 Handle windowfunction simple column --- dbcon/execplan/windowfunctioncolumn.cpp | 1 - dbcon/joblist/jlf_common.cpp | 58 ++++++++++++++++++++----- dbcon/joblist/jlf_common.h | 7 +-- dbcon/joblist/joblistfactory.cpp | 20 +++++++-- dbcon/joblist/tupleaggregatestep.cpp | 6 ++- dbcon/joblist/windowfunctionstep.cpp | 52 ++++++++++++++++++++++ dbcon/joblist/windowfunctionstep.h | 2 + 7 files changed, 126 insertions(+), 20 deletions(-) diff --git a/dbcon/execplan/windowfunctioncolumn.cpp b/dbcon/execplan/windowfunctioncolumn.cpp index 5c3e57407..e01c5c010 100644 --- a/dbcon/execplan/windowfunctioncolumn.cpp +++ b/dbcon/execplan/windowfunctioncolumn.cpp @@ -386,7 +386,6 @@ void WindowFunctionColumn::adjustResultType() fResultType.colDataType = CalpontSystemCatalog::LONGDOUBLE; fResultType.colWidth = sizeof(long double); fResultType.precision = -1; - fResultType.scale = 0; } } diff --git a/dbcon/joblist/jlf_common.cpp b/dbcon/joblist/jlf_common.cpp index 7ce066427..33e7e9657 100644 --- a/dbcon/joblist/jlf_common.cpp +++ b/dbcon/joblist/jlf_common.cpp @@ -386,19 +386,57 @@ CalpontSystemCatalog::OID tableOid(const SimpleColumn* sc, boost::shared_ptr(sc); uint32_t pseudoType = (pc) ? pc->pseudoType() : execplan::PSEUDO_UNKNOWN; - return getTupleKey_(jobInfo, sc->oid(), sc->columnName(), extractTableAlias(sc), - sc->schemaName(), sc->viewName(), - ((sc->joinInfo() & execplan::JOIN_CORRELATED) != 0), - pseudoType, (sc->isInfiniDB() ? 0 : 1)); + if (sc == NULL) + { + return -1; + } + + if (add) + { + // setTupleInfo first if add is true, ok if already set. + if (sc->schemaName().empty()) + { + SimpleColumn tmp(*sc, jobInfo.sessionId); + tmp.oid(tableOid(sc, jobInfo.csc) + 1 + sc->colPosition()); + key = getTupleKey(jobInfo, &tmp); // sub-query should be there + } + else + { + CalpontSystemCatalog::ColType ct = sc->colType(); + string alias(extractTableAlias(sc)); + CalpontSystemCatalog::OID tblOid = tableOid(sc, jobInfo.csc); + TupleInfo ti(setTupleInfo(ct, sc->oid(), jobInfo, tblOid, sc, alias)); + key = ti.key; + + CalpontSystemCatalog::OID dictOid = isDictCol(ct); + + if (dictOid > 0) + { + ti = setTupleInfo(ct, dictOid, jobInfo, tblOid, sc, alias); + jobInfo.keyInfo->dictKeyMap[key] = ti.key; + key = ti.key; + } + } + } + else + { + // TupleInfo is expected to be set already + return getTupleKey_(jobInfo, sc->oid(), sc->columnName(), extractTableAlias(sc), + sc->schemaName(), sc->viewName(), + ((sc->joinInfo() & execplan::JOIN_CORRELATED) != 0), + pseudoType, (sc->isInfiniDB() ? 0 : 1)); + } + + return key; } - - + uint32_t getTupleKey(JobInfo& jobInfo, const SRCP& srcp, bool add) { int key = -1; @@ -608,7 +646,7 @@ uint32_t getExpTupleKey(const JobInfo& jobInfo, uint64_t eid, bool cr) } -void addAggregateColumn(AggregateColumn* agc, int idx, RetColsVector& vec, JobInfo& jobInfo) +void addAggregateColumn(ReturnedColumn* agc, int idx, RetColsVector& vec, JobInfo& jobInfo) { uint32_t eid = agc->expressionId(); setExpTupleInfo(agc->resultType(), eid, agc->alias(), jobInfo); diff --git a/dbcon/joblist/jlf_common.h b/dbcon/joblist/jlf_common.h index 18c1ea396..6cf28af8c 100644 --- a/dbcon/joblist/jlf_common.h +++ b/dbcon/joblist/jlf_common.h @@ -401,8 +401,9 @@ execplan::CalpontSystemCatalog::OID tableOid(const execplan::SimpleColumn* sc, /** @brief Returns the unique ID to be used in tupleInfo * */ -uint32_t getTupleKey(const JobInfo& jobInfo, - const execplan::SimpleColumn* sc); +uint32_t getTupleKey(JobInfo& jobInfo, + const execplan::SimpleColumn* sc, + bool add = false); uint32_t getTableKey(const JobInfo& jobInfo, execplan::CalpontSystemCatalog::OID tableOid, const std::string& alias, @@ -464,7 +465,7 @@ TupleInfo setExpTupleInfo(const execplan::ReturnedColumn* rc, JobInfo& jobInfo); /** @brief add an aggregate column info * */ -void addAggregateColumn(execplan::AggregateColumn*, int, RetColsVector&, JobInfo&); +void addAggregateColumn(execplan::ReturnedColumn*, int, RetColsVector&, JobInfo&); void makeJobSteps(execplan::CalpontSelectExecutionPlan* csep, JobInfo& jobInfo, JobStepVector& querySteps, JobStepVector& projectSteps, diff --git a/dbcon/joblist/joblistfactory.cpp b/dbcon/joblist/joblistfactory.cpp index 0a141f03a..66245a8e2 100644 --- a/dbcon/joblist/joblistfactory.cpp +++ b/dbcon/joblist/joblistfactory.cpp @@ -274,9 +274,11 @@ const JobStepVector doProject(const RetColsVector& retCols, JobInfo& jobInfo) if (retCols[i]->windowfunctionColumnList().size() > 0) jobInfo.expressionVec.push_back(key); - else if (find(jobInfo.expressionVec.begin(), jobInfo.expressionVec.end(), key) == - jobInfo.expressionVec.end()) + else if (find(jobInfo.expressionVec.begin(), jobInfo.expressionVec.end(), key) + == jobInfo.expressionVec.end()) + { jobInfo.returnedExpressions.push_back(sjstep); + } //put place hold column in projection list jobInfo.pjColList.push_back(ti); @@ -1047,16 +1049,21 @@ const JobStepVector doAggProject(const CalpontSelectExecutionPlan* csep, JobInfo const FunctionColumn* fc = NULL; const WindowFunctionColumn* wc = NULL; bool hasAggCols = false; + bool hasWndCols = false; if ((ac = dynamic_cast(srcp.get())) != NULL) { if (ac->aggColumnList().size() > 0) hasAggCols = true; + if (ac->windowfunctionColumnList().size() > 0) + hasWndCols = true; } else if ((fc = dynamic_cast(srcp.get())) != NULL) { if (fc->aggColumnList().size() > 0) hasAggCols = true; + if (fc->windowfunctionColumnList().size() > 0) + hasWndCols = true; } else if (dynamic_cast(srcp.get()) != NULL) { @@ -1081,7 +1088,7 @@ const JobStepVector doAggProject(const CalpontSelectExecutionPlan* csep, JobInfo TupleInfo ti(setExpTupleInfo(ct, eid, srcp.get()->alias(), jobInfo)); tupleKey = ti.key; - if (hasAggCols) + if (hasAggCols && !hasWndCols) jobInfo.expressionVec.push_back(tupleKey); } @@ -1195,16 +1202,21 @@ const JobStepVector doAggProject(const CalpontSelectExecutionPlan* csep, JobInfo const FunctionColumn* fc = NULL; const WindowFunctionColumn* wc = NULL; bool hasAggCols = false; + bool hasWndCols = false; if ((ac = dynamic_cast(srcp.get())) != NULL) { if (ac->aggColumnList().size() > 0) hasAggCols = true; + if (ac->windowfunctionColumnList().size() > 0) + hasWndCols = true; } else if ((fc = dynamic_cast(srcp.get())) != NULL) { if (fc->aggColumnList().size() > 0) hasAggCols = true; + if (fc->windowfunctionColumnList().size() > 0) + hasWndCols = true; } else if (dynamic_cast(srcp.get()) != NULL) { @@ -1229,7 +1241,7 @@ const JobStepVector doAggProject(const CalpontSelectExecutionPlan* csep, JobInfo TupleInfo ti(setExpTupleInfo(ct, eid, srcp.get()->alias(), jobInfo)); tupleKey = ti.key; - if (hasAggCols) + if (hasAggCols && !hasWndCols) jobInfo.expressionVec.push_back(tupleKey); } diff --git a/dbcon/joblist/tupleaggregatestep.cpp b/dbcon/joblist/tupleaggregatestep.cpp index db5a4e8d8..62f084412 100644 --- a/dbcon/joblist/tupleaggregatestep.cpp +++ b/dbcon/joblist/tupleaggregatestep.cpp @@ -5011,7 +5011,8 @@ void TupleAggregateStep::prepExpressionOnAggregate(SP_ROWAGG_UM_t& aggUM, JobInf uint64_t eid = -1; if (((ac = dynamic_cast(it->get())) != NULL) && - (ac->aggColumnList().size() > 0)) + (ac->aggColumnList().size() > 0) && + (ac->windowfunctionColumnList().size() == 0)) { const vector& scols = ac->simpleColumnList(); simpleColumns.insert(simpleColumns.end(), scols.begin(), scols.end()); @@ -5020,7 +5021,8 @@ void TupleAggregateStep::prepExpressionOnAggregate(SP_ROWAGG_UM_t& aggUM, JobInf expressionVec.push_back(*it); } else if (((fc = dynamic_cast(it->get())) != NULL) && - (fc->aggColumnList().size() > 0)) + (fc->aggColumnList().size() > 0) && + (fc->windowfunctionColumnList().size() == 0)) { const vector& sCols = fc->simpleColumnList(); simpleColumns.insert(simpleColumns.end(), sCols.begin(), sCols.end()); diff --git a/dbcon/joblist/windowfunctionstep.cpp b/dbcon/joblist/windowfunctionstep.cpp index fe43faa77..172a7a8a5 100644 --- a/dbcon/joblist/windowfunctionstep.cpp +++ b/dbcon/joblist/windowfunctionstep.cpp @@ -320,6 +320,38 @@ const string WindowFunctionStep::toString() const return oss.str(); } +void WindowFunctionStep::AddSimplColumn(const vector& scs, + JobInfo& jobInfo) +{ + // append the simple columns if not already projected + set scProjected; + + for (RetColsVector::iterator i = jobInfo.projectionCols.begin(); + i != jobInfo.projectionCols.end(); + i++) + { + SimpleColumn* sc = dynamic_cast(i->get()); + + if (sc != NULL) + { + if (sc->schemaName().empty()) + sc->oid(joblist::tableOid(sc, jobInfo.csc) + 1 + sc->colPosition()); + + scProjected.insert(UniqId(sc)); + } + } + + for (vector::const_iterator i = scs.begin(); i != scs.end(); i++) + { + if (scProjected.find(UniqId(*i)) == scProjected.end()) + { + jobInfo.windowDels.push_back(SRCP((*i)->clone())); + jobInfo.windowSet.insert(getTupleKey(jobInfo, *i, true)); + scProjected.insert(UniqId(*i)); + } + } +} + void WindowFunctionStep::checkWindowFunction(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo) { // window functions in select clause, selected or in expression @@ -404,6 +436,23 @@ void WindowFunctionStep::checkWindowFunction(CalpontSelectExecutionPlan* csep, J if (jobInfo.windowCols.empty()) return; + // Add in the non-window side of arithmetic columns and functions + for (uint64_t i = 0; i < jobInfo.windowExps.size(); i++) + { + const ArithmeticColumn* ac = + dynamic_cast(jobInfo.windowExps[i].get()); + const FunctionColumn* fc = + dynamic_cast(jobInfo.windowExps[i].get()); + + if (ac != NULL && ac->windowfunctionColumnList().size() > 0) + { + AddSimplColumn(ac->simpleColumnList(), jobInfo); + } + else if (fc != NULL && fc->windowfunctionColumnList().size() > 0) + { + AddSimplColumn(fc->simpleColumnList(), jobInfo); + } + } // reconstruct the delivered column list with auxiliary columns set colSet; jobInfo.deliveredCols.resize(0); @@ -445,7 +494,10 @@ void WindowFunctionStep::checkWindowFunction(CalpontSelectExecutionPlan* csep, J key = getTupleKey(jobInfo, *j, true); if (colSet.find(key) == colSet.end()) + { jobInfo.deliveredCols.push_back(*j); + jobInfo.windowSet.insert(getTupleKey(jobInfo, *j, true)); + } colSet.insert(key); } diff --git a/dbcon/joblist/windowfunctionstep.h b/dbcon/joblist/windowfunctionstep.h index f483c6027..f6a695a65 100644 --- a/dbcon/joblist/windowfunctionstep.h +++ b/dbcon/joblist/windowfunctionstep.h @@ -148,6 +148,8 @@ private: void formatMiniStats(); void printCalTrace(); + static void AddSimplColumn(const vector& scs, JobInfo& jobInfo); + class Runner { public: From 2255d41eaf057d5e91be26c3c483aa813f74d35f Mon Sep 17 00:00:00 2001 From: David Hall Date: Thu, 20 Jun 2019 15:54:05 -0500 Subject: [PATCH 34/59] MCOL-3343 Error when no group by for unaggregated fields in window functions. --- dbcon/joblist/windowfunctionstep.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dbcon/joblist/windowfunctionstep.cpp b/dbcon/joblist/windowfunctionstep.cpp index 172a7a8a5..1a603a98e 100644 --- a/dbcon/joblist/windowfunctionstep.cpp +++ b/dbcon/joblist/windowfunctionstep.cpp @@ -346,7 +346,10 @@ void WindowFunctionStep::AddSimplColumn(const vector& scs, if (scProjected.find(UniqId(*i)) == scProjected.end()) { jobInfo.windowDels.push_back(SRCP((*i)->clone())); - jobInfo.windowSet.insert(getTupleKey(jobInfo, *i, true)); +// MCOL-3343 Enable this if we decide to allow Window Functions to run with +// aggregates with no group by. MariaDB allows this. Nobody else in the world does. +// There will be more work to get it to function if we try this. +// jobInfo.windowSet.insert(getTupleKey(jobInfo, *i, true)); scProjected.insert(UniqId(*i)); } } @@ -496,7 +499,10 @@ void WindowFunctionStep::checkWindowFunction(CalpontSelectExecutionPlan* csep, J if (colSet.find(key) == colSet.end()) { jobInfo.deliveredCols.push_back(*j); - jobInfo.windowSet.insert(getTupleKey(jobInfo, *j, true)); +// MCOL-3343 Enable this if we decide to allow Window Functions to run with +// aggregates with no group by. MariaDB allows this. Nobody else in the world does. +// There will be more work to get it to function if we try this. +// jobInfo.windowSet.insert(getTupleKey(jobInfo, *j, true)); } colSet.insert(key); From 089ec7d4dcfe08a0014b30862bc9588a2f9439f4 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Tue, 25 Jun 2019 17:15:30 +0100 Subject: [PATCH 35/59] MCOL-3391 Fix columnstore_upgrade unicode support The columnstore_upgrade() procedure would break on utf8 table names. This patch fixes that. --- dbcon/mysql/columnstore_info.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dbcon/mysql/columnstore_info.sql b/dbcon/mysql/columnstore_info.sql index 7655b5f16..b2f5e50d1 100644 --- a/dbcon/mysql/columnstore_info.sql +++ b/dbcon/mysql/columnstore_info.sql @@ -101,7 +101,7 @@ END // create procedure columnstore_upgrade() `columnstore_upgrade`: BEGIN DECLARE done INTEGER DEFAULT 0; - DECLARE schema_table VARCHAR(100) DEFAULT ""; + DECLARE schema_table VARCHAR(100) CHARACTER SET utf8 DEFAULT ""; DECLARE table_list CURSOR FOR select concat('`', table_schema,'`.`',table_name,'`') from information_schema.tables where engine='columnstore'; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; OPEN table_list; @@ -115,6 +115,5 @@ create procedure columnstore_upgrade() DEALLOCATE PREPARE stmt; END LOOP; END // -delimiter ; DELIMITER ; From 9c4ac78105d015c0f15605c92fac1331334b0191 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Wed, 26 Jun 2019 07:50:17 +0100 Subject: [PATCH 36/59] MCOL-2225 Make cross-engine step use backticks If an InnoDB table has spaces in the column names the cross engine step would fail. This patch wraps quotes around the table and column names to support this use case. --- dbcon/execplan/simplecolumn.cpp | 4 ++-- dbcon/joblist/crossenginestep.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dbcon/execplan/simplecolumn.cpp b/dbcon/execplan/simplecolumn.cpp index 206194954..75864892e 100644 --- a/dbcon/execplan/simplecolumn.cpp +++ b/dbcon/execplan/simplecolumn.cpp @@ -211,9 +211,9 @@ const string SimpleColumn::data() const if (!fData.empty()) return fData; else if (!fTableAlias.empty()) - return string(fSchemaName + '.' + fTableAlias + '.' + fColumnName); + return string("`" + fSchemaName + "`.`" + fTableAlias + "`.`" + fColumnName + "`"); - return string(fSchemaName + '.' + fTableName + '.' + fColumnName); + return string("`" + fSchemaName + "`.`" + fTableName + "`.`" + fColumnName + "`"); } SimpleColumn& SimpleColumn::operator=(const SimpleColumn& rhs) diff --git a/dbcon/joblist/crossenginestep.cpp b/dbcon/joblist/crossenginestep.cpp index d3cef7928..e46e1fe22 100644 --- a/dbcon/joblist/crossenginestep.cpp +++ b/dbcon/joblist/crossenginestep.cpp @@ -727,17 +727,17 @@ void CrossEngineStep::setProjectBPP(JobStep* jobStep1, JobStep*) else fSelectClause += "SELECT "; - fSelectClause += jobStep1->name(); + fSelectClause += "`" + jobStep1->name() + "`"; } string CrossEngineStep::makeQuery() { ostringstream oss; - oss << fSelectClause << " FROM " << fTable; + oss << fSelectClause << " FROM `" << fTable << "`"; if (fTable.compare(fAlias) != 0) - oss << " " << fAlias; + oss << " `" << fAlias << "`"; if (!fWhereClause.empty()) oss << fWhereClause; From 6bee5f9f61956d5e54a25eecb71f3f5fc8a84dda Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Wed, 3 Jul 2019 08:46:43 +0100 Subject: [PATCH 37/59] MCOL-3395 Always clear dctnry cache on close The dictionary cache needs to be cleared every time it is closed so that on bulk insert we don't mix the cache between columns. --- writeengine/dictionary/we_dctnry.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/writeengine/dictionary/we_dctnry.cpp b/writeengine/dictionary/we_dctnry.cpp index 6200cc248..ea677b341 100644 --- a/writeengine/dictionary/we_dctnry.cpp +++ b/writeengine/dictionary/we_dctnry.cpp @@ -419,8 +419,7 @@ int Dctnry::closeDctnry(bool realClose) return rc; //cout <<"Init called! m_dctnryOID =" << m_dctnryOID << endl; - if (realClose) - freeStringCache( ); + freeStringCache( ); return NO_ERROR; } From 621948660763d05b3fe5aed0ea0695099e248555 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Wed, 10 Jul 2019 11:07:02 +0100 Subject: [PATCH 38/59] MCOL-3399 Fix VARCHAR LDI length processing Accidentally passed the wrong number of bytes when processing the row provided in LDI. Revert the buf increment code. --- dbcon/mysql/ha_calpont_dml.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/dbcon/mysql/ha_calpont_dml.cpp b/dbcon/mysql/ha_calpont_dml.cpp index 87fbad147..6d1b7626e 100644 --- a/dbcon/mysql/ha_calpont_dml.cpp +++ b/dbcon/mysql/ha_calpont_dml.cpp @@ -862,12 +862,6 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ case CalpontSystemCatalog::VARCHAR: { - size_t length; - if (ci.utf8) - length = (ci.columnTypes[colpos].colWidth * 3); - else - length = ci.columnTypes[colpos].colWidth; - if (nullVal && (ci.columnTypes[colpos].constraintType != CalpontSystemCatalog::NOTNULL_CONSTRAINT)) { fprintf(ci.filePtr, "%c", ci.delimiter); @@ -911,7 +905,6 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ dataLength = *(uint16_t*) buf; buf = buf + 2 ; } - length = dataLength; escape.assign((char*)buf, dataLength); boost::replace_all(escape, "\\", "\\\\"); fprintf(ci.filePtr, "%c%.*s%c%c", ci.enclosed_by, (int)escape.length(), escape.c_str(), ci.enclosed_by, ci.delimiter); @@ -928,7 +921,6 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ dataLength = *(uint16_t*) buf; buf = buf + 2 ; } - length = dataLength; escape.assign((char*)buf, dataLength); boost::replace_all(escape, "\\", "\\\\"); @@ -936,8 +928,10 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ fprintf(ci.filePtr, "%c%.*s%c%c", ci.enclosed_by, (int)escape.length(), escape.c_str(), ci.enclosed_by, ci.delimiter); } } - buf += length; - + if (ci.utf8) + buf += (ci.columnTypes[colpos].colWidth * 3); + else + buf += ci.columnTypes[colpos].colWidth; break; } From a62761137845e75d25766962548c8efb66848445 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Thu, 11 Jul 2019 13:32:44 +0100 Subject: [PATCH 39/59] Revert "MCOL-2243 Only set length and dec when dec is zero" This reverts commit b05c4e8df4e1f3a2bdbbd14896bce658b074d0fb. --- dbcon/mysql/ha_calpont_impl.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 97d4a80e4..d051abcd7 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -649,12 +649,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h // bug 3485, reserve enough space for the longest float value // -3.402823466E+38 to -1.175494351E-38, 0, and // 1.175494351E-38 to 3.402823466E+38. - if (!f2->dec) - { - (*f)->field_length = 40; - f2->dec = row.getScale(s); - } - + (*f)->field_length = 40; //float float_val = *(float*)(&value); //f2->store(float_val); if (f2->decimals() < (uint32_t)row.getScale(s)) @@ -683,12 +678,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h // 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. - if (!f2->dec) - { - (*f)->field_length = 310; - f2->dec = row.getScale(s); - } - + (*f)->field_length = 310; //double double_val = *(double*)(&value); //f2->store(double_val); if ((f2->decimals() == DECIMAL_NOT_SPECIFIED && row.getScale(s) > 0) From c683b6bfc061193eed8b131dd1a86d932eb6303a Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 16 Jul 2019 18:19:03 -0500 Subject: [PATCH 40/59] MCOL-3404 Revert experimental changes from MCOL-3343 --- dbcon/joblist/joblistfactory.cpp | 9 ++------- utils/rowgroup/rowgroup.h | 3 ++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/dbcon/joblist/joblistfactory.cpp b/dbcon/joblist/joblistfactory.cpp index 66245a8e2..152358bf7 100644 --- a/dbcon/joblist/joblistfactory.cpp +++ b/dbcon/joblist/joblistfactory.cpp @@ -399,7 +399,6 @@ void checkHavingClause(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo) void preProcessFunctionOnAggregation(const vector& scs, const vector& aggs, - const vector& wcs, JobInfo& jobInfo) { // append the simple columns if not already projected @@ -433,10 +432,6 @@ void preProcessFunctionOnAggregation(const vector& scs, for (vector::const_iterator i = aggs.begin(); i != aggs.end(); i++) { addAggregateColumn(*i, -1, jobInfo.projectionCols, jobInfo); - if (wcs.size() > 0) - { - jobInfo.nonConstDelCols.push_back(SRCP((*i)->clone())); - } } } @@ -488,12 +483,12 @@ void checkReturnedColumns(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo) if (ac != NULL && ac->aggColumnList().size() > 0) { jobInfo.nonConstCols[i]->outputIndex(i); - preProcessFunctionOnAggregation(ac->simpleColumnList(), ac->aggColumnList(), ac->windowfunctionColumnList(), jobInfo); + preProcessFunctionOnAggregation(ac->simpleColumnList(), ac->aggColumnList(), jobInfo); } else if (fc != NULL && fc->aggColumnList().size() > 0) { jobInfo.nonConstCols[i]->outputIndex(i); - preProcessFunctionOnAggregation(fc->simpleColumnList(), fc->aggColumnList(), fc->windowfunctionColumnList(), jobInfo); + preProcessFunctionOnAggregation(fc->simpleColumnList(), fc->aggColumnList(), jobInfo); } } } diff --git a/utils/rowgroup/rowgroup.h b/utils/rowgroup/rowgroup.h index b91e0f0ef..2334d22bc 100644 --- a/utils/rowgroup/rowgroup.h +++ b/utils/rowgroup/rowgroup.h @@ -1772,7 +1772,8 @@ inline void copyRow(const Row& in, Row* out, uint32_t colCount) { if (UNLIKELY(in.getColTypes()[i] == execplan::CalpontSystemCatalog::VARBINARY || in.getColTypes()[i] == execplan::CalpontSystemCatalog::BLOB || - in.getColTypes()[i] == execplan::CalpontSystemCatalog::TEXT)) + in.getColTypes()[i] == execplan::CalpontSystemCatalog::TEXT || + in.getColTypes()[i] == execplan::CalpontSystemCatalog::CLOB)) out->setVarBinaryField(in.getVarBinaryStringField(i), i); else if (UNLIKELY(in.isLongString(i))) //out->setStringField(in.getStringField(i), i); From 83a892422925bedcbc22f4f873747d28fc47a299 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Mon, 29 Jul 2019 13:48:28 +0100 Subject: [PATCH 41/59] Fix namespace and class changes --- dbcon/joblist/windowfunctionstep.h | 2 +- dbcon/mysql/ha_calpont_impl.cpp | 6 +----- dmlproc/dmlproc.cpp | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/dbcon/joblist/windowfunctionstep.h b/dbcon/joblist/windowfunctionstep.h index f0154ae0a..eaa020fc3 100644 --- a/dbcon/joblist/windowfunctionstep.h +++ b/dbcon/joblist/windowfunctionstep.h @@ -148,7 +148,7 @@ private: void formatMiniStats(); void printCalTrace(); - static void AddSimplColumn(const vector& scs, JobInfo& jobInfo); + static void AddSimplColumn(const std::vector& scs, JobInfo& jobInfo); class Runner { diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index fd0f0fcb8..bb08c6cb9 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -1594,11 +1594,7 @@ uint32_t doUpdateDelete(THD* thd) { if (timeStampColumnNames.find(onUpdateTimeStampColumns[i]) == timeStampColumnNames.end()) { - columnAssignmentPtr = new ColumnAssignment(); - columnAssignmentPtr->fColumn = string(onUpdateTimeStampColumns[i]); - columnAssignmentPtr->fOperator = "="; - columnAssignmentPtr->fFuncScale = 0; - columnAssignmentPtr->fFromCol = false; + columnAssignmentPtr = new ColumnAssignment(string(onUpdateTimeStampColumns[i]), "=", ""); struct timeval tv; char buf[64]; gettimeofday(&tv, 0); diff --git a/dmlproc/dmlproc.cpp b/dmlproc/dmlproc.cpp index 5adf9404d..09e5b9128 100644 --- a/dmlproc/dmlproc.cpp +++ b/dmlproc/dmlproc.cpp @@ -86,7 +86,7 @@ using namespace joblist; namespace fs = boost::filesystem; -ThreadPool DMLServer::fDmlPackagepool(10, 0); +threadpool::ThreadPool DMLServer::fDmlPackagepool(10, 0); namespace { @@ -658,7 +658,7 @@ int main(int argc, char* argv[]) JobStep::jobstepThreadPool.setDebug(true); JobStep::jobstepThreadPool.invoke(threadpool::ThreadPoolMonitor(&JobStep::jobstepThreadPool)); DMLServer::fDmlPackagepool.setDebug(true); - DMLServer::fDmlPackagepool.invoke(ThreadPoolMonitor(&DMLServer::fDmlPackagepool)); + DMLServer::fDmlPackagepool.invoke(threadpool::ThreadPoolMonitor(&DMLServer::fDmlPackagepool)); } //set ACTIVE state From 2071716ebd77f9479cbe93733db161aa9791d178 Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Wed, 30 Jan 2019 18:59:44 +0300 Subject: [PATCH 42/59] MCOL-2121 New derived_handler(MDEV-17096) infrastructure. Renamed isInfiniDB() into isMCSTable Changed getSelectPlan() to reuse it with derived and other handler types. Separate pushdown handlers methods and functions. Removed vcxproj files from the source. Added fix for MCOL-2166. Merged with MCOL-2121 --- dbcon/mysql/CMakeLists.txt | 2 + dbcon/mysql/ha_calpont.cpp | 266 +---------- dbcon/mysql/ha_calpont.h | 49 +-- dbcon/mysql/ha_calpont_execplan.cpp | 290 ++++++++++-- dbcon/mysql/ha_calpont_impl.cpp | 557 ++++++++++++++++++++++- dbcon/mysql/ha_calpont_impl.h | 6 +- dbcon/mysql/ha_calpont_impl_if.h | 6 +- dbcon/mysql/ha_mcs_pushdown.cpp | 661 ++++++++++++++++++++++++++++ dbcon/mysql/ha_mcs_pushdown.h | 142 ++++++ dbcon/mysql/ha_view.cpp | 2 +- dbcon/mysql/idb_mysql.h | 2 + 11 files changed, 1643 insertions(+), 340 deletions(-) create mode 100644 dbcon/mysql/ha_mcs_pushdown.cpp create mode 100644 dbcon/mysql/ha_mcs_pushdown.h diff --git a/dbcon/mysql/CMakeLists.txt b/dbcon/mysql/CMakeLists.txt index c74e19343..0aa6ddcc0 100644 --- a/dbcon/mysql/CMakeLists.txt +++ b/dbcon/mysql/CMakeLists.txt @@ -22,6 +22,8 @@ SET ( libcalmysql_SRCS ha_pseudocolumn.cpp) add_definitions(-DMYSQL_DYNAMIC_PLUGIN) +add_definitions(-DEBUG_WALK_COND) +add_definitions(-DINFINIDB_DEBUG) set_source_files_properties(ha_calpont.cpp PROPERTIES COMPILE_FLAGS "-fno-rtti -fno-implicit-templates") diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index 552a895d6..f1b375480 100644 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -21,6 +21,7 @@ #define NEED_CALPONT_EXTERNS #include "ha_calpont_impl.h" +#include "ha_mcs_pushdown.h" static handler* calpont_create_handler(handlerton* hton, TABLE_SHARE* table, @@ -32,9 +33,17 @@ static int calpont_rollback(handlerton* hton, THD* thd, bool all); static int calpont_close_connection ( handlerton* hton, THD* thd ); handlerton* calpont_hton; +// handlers creation function for hton. +// Look into ha_mcs_pushdown.* for more details. static group_by_handler* create_calpont_group_by_handler(THD* thd, Query* query); +static derived_handler* +create_columnstore_derived_handler(THD* thd, TABLE_LIST *derived); + +static select_handler* +create_columnstore_select_handler(THD* thd, SELECT_LEX* sel); + /* Variables for example share methods */ /* @@ -131,6 +140,8 @@ static int columnstore_init_func(void* p) calpont_hton->rollback = calpont_rollback; calpont_hton->close_connection = calpont_close_connection; calpont_hton->create_group_by = create_calpont_group_by_handler; + calpont_hton->create_derived = create_columnstore_derived_handler; + calpont_hton->create_select = create_columnstore_select_handler; DBUG_RETURN(0); } @@ -159,6 +170,10 @@ static int infinidb_init_func(void* p) calpont_hton->commit = calpont_commit; calpont_hton->rollback = calpont_rollback; calpont_hton->close_connection = calpont_close_connection; + calpont_hton->create_group_by = create_calpont_group_by_handler; + calpont_hton->create_derived = create_columnstore_derived_handler; + calpont_hton->create_select = create_columnstore_select_handler; + DBUG_RETURN(0); } @@ -929,256 +944,7 @@ struct st_mysql_storage_engine columnstore_storage_engine = struct st_mysql_storage_engine infinidb_storage_engine = { MYSQL_HANDLERTON_INTERFACE_VERSION }; -/*@brief check_walk - It traverses filter conditions*/ -/************************************************************ - * DESCRIPTION: - * It traverses filter predicates looking for unsupported - * JOIN types: non-equi JOIN, e.g t1.c1 > t2.c2; - * logical OR. - * PARAMETERS: - * thd - THD pointer. - * derived - TABLE_LIST* to work with. - * RETURN: - * derived_handler if possible - * NULL in other case - ***********************************************************/ -void check_walk(const Item* item, void* arg) -{ - bool* unsupported_feature = static_cast(arg); - if ( *unsupported_feature ) - return; - switch (item->type()) - { - case Item::FUNC_ITEM: - { - const Item_func* ifp = static_cast(item); - - if ( ifp->functype() != Item_func::EQ_FUNC ) // NON-equi JOIN - { - if ( ifp->argument_count() == 2 && - ifp->arguments()[0]->type() == Item::FIELD_ITEM && - ifp->arguments()[1]->type() == Item::FIELD_ITEM ) - { - Item_field* left= static_cast(ifp->arguments()[0]); - Item_field* right= static_cast(ifp->arguments()[1]); - - if ( left->field->table != right->field->table ) - { - *unsupported_feature = true; - return; - } - } - else // IN + correlated subquery - { - if ( ifp->functype() == Item_func::NOT_FUNC - && ifp->arguments()[0]->type() == Item::EXPR_CACHE_ITEM ) - { - check_walk(ifp->arguments()[0], arg); - } - } - } - break; - } - - case Item::EXPR_CACHE_ITEM: // IN + correlated subquery - { - const Item_cache_wrapper* icw = static_cast(item); - if ( icw->get_orig_item()->type() == Item::FUNC_ITEM ) - { - const Item_func *ifp = static_cast(icw->get_orig_item()); - if ( ifp->argument_count() == 2 && - ( ifp->arguments()[0]->type() == Item::Item::SUBSELECT_ITEM - || ifp->arguments()[1]->type() == Item::Item::SUBSELECT_ITEM )) - { - *unsupported_feature = true; - return; - } - } - break; - } - - case Item::COND_ITEM: // OR in cods is unsupported yet - { - Item_cond* icp = (Item_cond*)item; - if ( is_cond_or(icp) ) - { - *unsupported_feature = true; - } - break; - } - default: - { - break; - } - } -} - -/*@brief create_calpont_group_by_handler- Creates handler*/ -/*********************************************************** - * DESCRIPTION: - * Creates a group_by pushdown handler if there is no: - * non-equi JOIN, e.g * t1.c1 > t2.c2 - * logical OR in the filter predicates - * Impossible WHERE - * Impossible HAVING - * 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 LFM in group_by_handler.h - * RETURN: - * group_by_handler if success - * NULL in other case - ***********************************************************/ -static group_by_handler* -create_calpont_group_by_handler(THD* thd, Query* query) -{ - ha_calpont_group_by_handler* handler = NULL; - // same as thd->lex->current_select - SELECT_LEX *select_lex = query->from->select_lex; - - // Create a handler if query is valid. See comments for details. - if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE - && ( thd->variables.infinidb_vtable_mode == 0 - || thd->variables.infinidb_vtable_mode == 2 ) - && ( query->group_by || select_lex->with_sum_func ) ) - { - bool unsupported_feature = false; - // revisit SELECT_LEX for all units - for(TABLE_LIST* tl = query->from; !unsupported_feature && tl; tl = tl->next_global) - { - select_lex = tl->select_lex; - // Correlation subquery. Comming soon so fail on this yet. - unsupported_feature = select_lex->is_correlated; - - // 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 ) ) - { - unsupported_feature = true; - } - - // Unsupported JOIN conditions - if ( !unsupported_feature ) - { - JOIN *join = select_lex->join; - Item_cond *icp = 0; - - if (join != 0) - icp = reinterpret_cast(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(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 ) - { - handler = new ha_calpont_group_by_handler(thd, query); - - // 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; -} - -/*********************************************************** - * DESCRIPTION: - * GROUP BY handler constructor - * PARAMETERS: - * thd - THD pointer. - * query - Query describing structure - ***********************************************************/ -ha_calpont_group_by_handler::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) -{ -} - -/*********************************************************** - * DESCRIPTION: - * GROUP BY destructor - ***********************************************************/ -ha_calpont_group_by_handler::~ha_calpont_group_by_handler() -{ -} - -/*********************************************************** - * DESCRIPTION: - * Makes the plan and prepares the data - * RETURN: - * int rc - ***********************************************************/ -int ha_calpont_group_by_handler::init_scan() -{ - DBUG_ENTER("ha_calpont_group_by_handler::init_scan"); - - // Save vtable_state to restore the after we inited. - THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; - // MCOL-1052 Should be removed after cleaning the code up. - thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; - int rc = ha_calpont_impl_group_by_init(this, table); - thd->infinidb_vtable.vtable_state = oldState; - - DBUG_RETURN(rc); -} - -/*********************************************************** - * DESCRIPTION: - * Fetches a row and saves it to a temporary table. - * RETURN: - * int rc - ***********************************************************/ -int ha_calpont_group_by_handler::next_row() -{ - DBUG_ENTER("ha_calpont_group_by_handler::next_row"); - int rc = ha_calpont_impl_group_by_next(this, table); - - DBUG_RETURN(rc); -} - -/*********************************************************** - * DESCRIPTION: - * Shuts the scan down. - * RETURN: - * int rc - ***********************************************************/ -int ha_calpont_group_by_handler::end_scan() -{ - DBUG_ENTER("ha_calpont_group_by_handler::end_scan"); - - int rc = ha_calpont_impl_group_by_end(this, table); - - DBUG_RETURN(rc); -} +#include "ha_mcs_pushdown.cpp" mysql_declare_plugin(columnstore) { diff --git a/dbcon/mysql/ha_calpont.h b/dbcon/mysql/ha_calpont.h index bab756851..070f5380b 100644 --- a/dbcon/mysql/ha_calpont.h +++ b/dbcon/mysql/ha_calpont.h @@ -24,7 +24,7 @@ extern handlerton* calpont_hton; /** @brief - This structure will be shared among all open handlers. + INFINIDB_SHARE is a structure that will be shared among all open handlers. This example implements the minimum of what you will probably need. */ typedef struct st_calpont_share @@ -228,51 +228,4 @@ public: } }; - -/*@brief group_by_handler class*/ -/*********************************************************** - * DESCRIPTION: - * 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 according 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. - * select_list_descr - contains Item description returned by Item->print() - * that is used in lookup for corresponding columns in - * extended SELECT list. - * table_list - contains all tables involved. Must be CS tables only. - * distinct - looks like a useless thing for now. Couldn't get it set by server. - * where - where items. - * group_by - group by ORDER items. - * order_by - order by ORDER items. - * having - having Item. - * Methods: - * init_scan - get plan and send it to ExeMgr. Get the execution result. - * next_row - get a row back from sm. - * end_scan - finish and clean the things up. - ***********************************************************/ -class ha_calpont_group_by_handler: public group_by_handler -{ -public: - ha_calpont_group_by_handler(THD* thd_arg, Query* query); - ~ha_calpont_group_by_handler(); - int init_scan(); - int next_row(); - int end_scan(); - - List* select; - TABLE_LIST* table_list; - bool distinct; - Item* where; - ORDER* group_by; - ORDER* order_by; - Item* having; -}; #endif //HA_CALPONT_H__ - diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index d40584109..c8b6aa058 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -192,6 +192,150 @@ bool nonConstFunc(Item_func* ifp) return false; } +/*@brief getColNameFromItem - builds a name from an Item */ +/*********************************************************** + * DESCRIPTION: + * This f() looks for a first proper Item_ident and populate + * ostream with schema, table and column names. + * Used to build db.table.field tuple for debugging output + * in getSelectPlan(). TBD getGroupPlan must use this also. + * PARAMETERS: + * item source Item* + * ostream output stream + * RETURNS + * void + ***********************************************************/ +void getColNameFromItem(std::ostringstream& ostream, Item* item) +{ +// MCOL-2121 WIP +// Item_func doesn't have proper db.table.field values +// inherited from Item_ident. TBD what is the valid output. +// !!!dynamic_cast fails compilation + ostream << "'"; + + if (item->type() != Item::FIELD_ITEM) + { + ostream << "unknown db" << '.'; + ostream << "unknown table" << '.'; + ostream << "unknown field"; + } + else + { + Item_ident* iip = reinterpret_cast(item); + + if (iip->db_name) + ostream << iip->db_name << '.'; + else + ostream << "unknown db" << '.'; + + if (iip->table_name) + ostream << iip->table_name << '.'; + else + ostream << "unknown table" << '.'; + + if (iip->field_name.length) + ostream << iip->field_name.str; + else + ostream << "unknown field"; + } + + ostream << "'"; + return; +} + +/*@brf sortItemIsInGroupRec - seeks for an item in grouping*/ +/*********************************************************** + * DESCRIPTION: + * This f() recursively traverses grouping items and looks + * for an FUNC_ITEM, REF_ITEM or FIELD_ITEM. + * f() is used by sortItemIsInGrouping(). + * PARAMETERS: + * sort_item Item* used to build aggregation. + * group_item GROUP BY item. + * RETURNS + * bool + ***********************************************************/ +bool sortItemIsInGroupRec(Item* sort_item, Item* group_item) +{ + bool found = false; + // If ITEM_REF::ref is NULL + if (sort_item == NULL) + { + return found; + } + + Item_func* ifp_sort = reinterpret_cast(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(sort_item); + found = sortItemIsInGroupRec(*ifp_sort_ref->ref, group_item); + } + + // seeking for a group_item match + for (uint32_t i = 0; !found && i < ifp_sort->argument_count(); i++) + { + Item* ifp_sort_arg = ifp_sort->arguments()[i]; + if (ifp_sort_arg->type() == Item::FUNC_ITEM + || ifp_sort_arg->type() == Item::FIELD_ITEM) + { + Item* ifp_sort_arg = ifp_sort->arguments()[i]; + found = sortItemIsInGroupRec(ifp_sort_arg, group_item); + } + else if (ifp_sort_arg->type() == Item::REF_ITEM) + { + // dereference the Item + Item_ref* ifp_sort_ref = reinterpret_cast(ifp_sort_arg); + found = sortItemIsInGroupRec(*ifp_sort_ref->ref, group_item); + } + } + + return found; +} + +/*@brief sortItemIsInGrouping- seeks for an item in grouping*/ +/*********************************************************** + * DESCRIPTION: + * This f() traverses grouping items and looks for an item. + * only Item_fields, Item_func are considered. However there + * could be Item_ref down the tree. + * f() is used in sorting parsing by getSelectPlan(). + * PARAMETERS: + * sort_item Item* used to build aggregation. + * groupcol GROUP BY items from this unit. + * RETURNS + * bool + ***********************************************************/ +bool sortItemIsInGrouping(Item* sort_item, ORDER* groupcol) +{ + bool found = false; + + if(sort_item->type() == Item::SUM_FUNC_ITEM) + { + found = true; + } + + for (; !found && groupcol; groupcol = groupcol->next) + { + Item* group_item = *(groupcol->item); + found = (group_item->eq(sort_item, false)) ? true : false; + // Detect aggregation functions first then traverse + // if sort field is a Func and group field + // is either Field or Func + // Consider nonConstFunc() check here + if(!found && sort_item->type() == Item::FUNC_ITEM + && (group_item->type() == Item::FUNC_ITEM + || group_item->type() == Item::FIELD_ITEM)) + { + found = sortItemIsInGroupRec(sort_item, group_item); + } + } + + return found; +} + /*@brief buildAggFrmTempField- build aggr func from extSELECT list item*/ /*********************************************************** * DESCRIPTION: @@ -230,7 +374,6 @@ ReturnedColumn* buildAggFrmTempField(Item* item, gp_walk_info& gwi) std::vector::iterator iter = gwi.extSelAggColsItems.begin(); for ( ; iter != gwi.extSelAggColsItems.end(); iter++ ) { - //Item* temp_isfp = *iter; isfp = reinterpret_cast(*iter); if ( isfp->type() == Item::SUM_FUNC_ITEM && @@ -4079,10 +4222,10 @@ SimpleColumn* buildSimpleColumn(Item_field* ifp, gp_walk_info& gwi) { // check foreign engine if (ifp->cached_table && ifp->cached_table->table) - infiniDB = isInfiniDB(ifp->cached_table->table); + infiniDB = isMCSTable(ifp->cached_table->table); // @bug4509. ifp->cached_table could be null for myisam sometimes else if (ifp->field && ifp->field->table) - infiniDB = isInfiniDB(ifp->field->table); + infiniDB = isMCSTable(ifp->field->table); if (infiniDB) { @@ -5732,7 +5875,7 @@ void parse_item (Item* item, vector& field_vec, } } -bool isInfiniDB(TABLE* table_ptr) +bool isMCSTable(TABLE* table_ptr) { #if (defined(_MSC_VER) && defined(_DEBUG)) || defined(SAFE_MUTEX) @@ -5754,14 +5897,18 @@ bool isInfiniDB(TABLE* table_ptr) return false; } -int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool isUnion) +int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, + SCSEP& csep, + bool isUnion, + bool isPushdownHand) { #ifdef DEBUG_WALK_COND cerr << "getSelectPlan()" << endl; #endif // by pass the derived table resolve phase of mysql - if (!(((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || + if ( !isPushdownHand && + !(((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) ) && gwi.thd->derived_tables_processing) @@ -5913,7 +6060,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i else { // check foreign engine tables - bool infiniDB = (table_ptr->table ? isInfiniDB(table_ptr->table) : true); + bool infiniDB = (table_ptr->table ? isMCSTable(table_ptr->table) : true); // trigger system catalog cache if (infiniDB) @@ -5965,6 +6112,10 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i bool unionSel = false; + // UNION master unit check + // Existed pushdown handlers won't get in this scope + // except UNION pushdown that is to come. + // is_unit_op() give a segv for derived_handler's SELECT_LEX if (!isUnion && select_lex.master_unit()->is_unit_op()) { gwi.thd->infinidb_vtable.isUnion = true; @@ -7212,16 +7363,29 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i { if ((*(ordercol->item))->type() == Item::WINDOW_FUNC_ITEM) gwi.hasWindowFunc = true; + // MCOL-2166 Looking for this sorting item in GROUP_BY items list. + if(isPushdownHand + && !sortItemIsInGrouping(*ordercol->item, select_lex.group_list.first)) + { + std::ostringstream ostream; + std::ostringstream& osr = ostream; + getColNameFromItem(osr, *ordercol->item); + Message::Args args; + args.add(ostream.str()); + string emsg = IDBErrorInfo::instance()->errorMsg(ERR_NOT_GROUPBY_EXPRESSION, args); + gwi.parseErrorText = emsg; + setError(gwi.thd, ER_INTERNAL_ERROR, emsg, gwi); + return ERR_NOT_GROUPBY_EXPRESSION; + } } // re-visit the first of ordercol list ordercol = reinterpret_cast(order_list.first); - // for subquery, order+limit by will be supported in infinidb. build order by columns - // @todo union order by and limit support - if (gwi.hasWindowFunc - || gwi.subSelectType != CalpontSelectExecutionPlan::MAIN_SELECT - || ( isUnion && ordercol )) + // for subquery or pushdown query, order+limit by will be supported in CS + // union order by and limit are supported + if (gwi.hasWindowFunc || isPushdownHand || ( isUnion && ordercol ) + || gwi.subSelectType != CalpontSelectExecutionPlan::MAIN_SELECT ) { for (; ordercol; ordercol = ordercol->next) { @@ -7654,12 +7818,13 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i gwi.returnedCols.push_back(minSc); } - if (!isUnion && !gwi.hasWindowFunc && gwi.subSelectType == CalpontSelectExecutionPlan::MAIN_SELECT) + // ORDER BY translation part + if (!isUnion && !gwi.hasWindowFunc + && gwi.subSelectType == CalpontSelectExecutionPlan::MAIN_SELECT ) { std::ostringstream vtb; vtb << "infinidb_vtable.$vtable_" << gwi.thd->thread_id; - //vtb << "$vtable_" << gwi.thd->thread_id; // re-construct the select query and redo phase 1 if (redo) { @@ -7927,11 +8092,20 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i { gwi.thd->infinidb_vtable.has_order_by = true; csep->hasOrderBy(true); + // To activate LimitedOrderBy + if(isPushdownHand) + { + csep->specHandlerProcessed(true); + } ord_cols = " order by " + ord_cols; select_query += ord_cols; } } + // LIMIT processing part + uint64_t limitNum = std::numeric_limits::max(); + + // non-MAIN union branch if (unionSel || gwi.subSelectType != CalpontSelectExecutionPlan::MAIN_SELECT) { if (select_lex.master_unit()->global_parameters()->explicit_limit) @@ -7958,6 +8132,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i } } } + // union with explicit select at the top level else if (isUnion && select_lex.explicit_limit) { if (select_lex.braces) @@ -7969,10 +8144,10 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i csep->limitNum(((Item_int*)select_lex.select_limit)->val_int()); } } + // other types of queries that have explicit LIMIT else if (select_lex.explicit_limit) { uint32_t limitOffset = 0; - uint32_t limitNum = std::numeric_limits::max(); if (join) { @@ -8027,6 +8202,12 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i csep->limitStart(limitOffset); csep->limitNum(limitNum); } + // Pushdown queries w ORDER BY and LIMIT + else if (isPushdownHand && csep->hasOrderBy()) + { + csep->limitStart(limitOffset); + csep->limitNum(limitNum); + } else { ostringstream limit; @@ -8034,6 +8215,12 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i select_query += limit.str(); } } + // Pushdown queries with ORDER BY w/o explicit limit + else if (isPushdownHand && csep->hasOrderBy()) + { + // We must set this to activate LimitedOrderBy in ExeMgr + csep->limitNum((uint64_t) - 2); + } gwi.thd->infinidb_vtable.select_vtable_query.free(); gwi.thd->infinidb_vtable.select_vtable_query.append(select_query.c_str(), select_query.length()); @@ -8047,9 +8234,9 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i setError(gwi.thd, ER_INTERNAL_ERROR, gwi.parseErrorText, gwi); return ER_CHECK_NOT_IMPLEMENTED; } - } + } // LIMIT processing finishes here - if (/*join->select_options*/select_lex.options & SELECT_DISTINCT) + if (select_lex.options & SELECT_DISTINCT) csep->distinct(true); // add the smallest column to count(*) parm. @@ -8283,6 +8470,49 @@ int cp_get_group_plan(THD* thd, SCSEP& csep, cal_impl_if::cal_group_info& gi) return 0; } +int cs_get_derived_plan(derived_handler* handler, THD* thd, SCSEP& csep) +{ + SELECT_LEX select_lex = *handler->select; + gp_walk_info gwi; + gwi.thd = thd; + int status = getSelectPlan(gwi, select_lex, csep, false, true); + + if (status > 0) + return ER_INTERNAL_ERROR; + else if (status < 0) + return status; + +#ifdef DEBUG_WALK_COND + cerr << "---------------- cp_get_derived_plan EXECUTION PLAN ----------------" << endl; + cerr << *csep << endl ; + cerr << "-------------- EXECUTION PLAN END --------------\n" << endl; +#endif + + return 0; +} + +int cs_get_select_plan(select_handler* handler, THD* thd, SCSEP& csep) +{ + SELECT_LEX select_lex = *handler->select; + gp_walk_info gwi; + gwi.thd = thd; + int status = getSelectPlan(gwi, select_lex, csep, false, true); + + if (status > 0) + return ER_INTERNAL_ERROR; + else if (status < 0) + return status; + +#ifdef DEBUG_WALK_COND + cerr << "---------------- cp_get_select_plan EXECUTION PLAN ----------------" << endl; + cerr << *csep << endl ; + cerr << "-------------- EXECUTION PLAN END --------------\n" << endl; +#endif + + return 0; +} + + /*@brief buildConstColFromFilter- change SimpleColumn into ConstColumn*/ /*********************************************************** * DESCRIPTION: @@ -8290,6 +8520,8 @@ int cp_get_group_plan(THD* thd, SCSEP& csep, cal_impl_if::cal_group_info& gi) * filter predicate is used, e.g. * field = 'AIR', field IN ('AIR'). This utility function tries to * replace such fields with ConstantColumns using cond_pushed filters. + * TBD Take into account that originalSC SimpleColumn could be: + * SimpleColumn, ArithmeticColumn, FunctionColumn. * PARAMETERS: * originalSC SimpleColumn* removed field * gwi main strucutre @@ -8470,7 +8702,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro else { // check foreign engine tables - bool infiniDB = (table_ptr->table ? isInfiniDB(table_ptr->table) : true); + bool infiniDB = (table_ptr->table ? isMCSTable(table_ptr->table) : true); // trigger system catalog cache if (infiniDB) @@ -9652,6 +9884,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro } // GROUP processing ends here + // ORDER BY processing starts here if (gwi.thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) { ORDER* ordercol = reinterpret_cast(gi.groupByOrder); @@ -9752,26 +9985,9 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // this ORDER BY item. if ( iter == gwi.groupByCols.end() ) { - Item_ident* iip = reinterpret_cast(ord_item); std::ostringstream ostream; - ostream << "'"; - - if (iip->db_name) - ostream << iip->db_name << '.'; - else - ostream << "unknown db" << '.'; - - if (iip->table_name) - ostream << iip->table_name << '.'; - else - ostream << "unknown table" << '.'; - - if (iip->field_name.length) - ostream << iip->field_name.str; - else - ostream << "unknown field"; - - ostream << "'"; + std::ostringstream& osr = ostream; + getColNameFromItem(osr, *ordercol->item); Message::Args args; args.add(ostream.str()); string emsg = IDBErrorInfo::instance()->errorMsg(ERR_NOT_GROUPBY_EXPRESSION, args); diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 1d3c98003..3c53c518a 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -80,6 +80,7 @@ using namespace execplan; using namespace dataconvert; #include "sm.h" +#include "ha_mcs_pushdown.h" #include "bytestream.h" #include "messagequeue.h" @@ -3019,7 +3020,7 @@ int ha_calpont_impl_rnd_next(uchar* buf, TABLE* table) return rc; } -int ha_calpont_impl_rnd_end(TABLE* table) +int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) { int rc = 0; THD* thd = current_thd; @@ -3047,6 +3048,12 @@ int ha_calpont_impl_rnd_end(TABLE* table) thd->infinidb_vtable.isNewQuery = true; + // Workaround because CS doesn't reset isUnion in a normal way. + if (is_pushdown_hand) + { + thd->infinidb_vtable.isUnion = false; + } + if (get_fe_conn_info_ptr() != NULL) ci = reinterpret_cast(get_fe_conn_info_ptr()); if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ORDER_BY ) @@ -5275,4 +5282,552 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE* return rc; } + +/*@brief Initiate the query for derived_handler */ +/*********************************************************** + * DESCRIPTION: + * Execute the query and saves derived table query. + * There is an extra handler argument so I ended up with a + * new init function. The code is a copy of + * ha_calpont_impl_rnd_init() mostly. We should come up with + * a semi-universal structure that allows to save any + * extra data. + * PARAMETERS: + * void* handler either select_ or derived_handler + * TABLE* table - table where to save the results + * RETURN: + * rc as int + ***********************************************************/ +int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) +{ +#ifdef DEBUG_SETENV + string home(getenv("HOME")); + + if (!getenv("CALPONT_HOME")) + { + string calpontHome(home + "/Calpont/etc/"); + setenv("CALPONT_HOME", calpontHome.c_str(), 1); + } + + if (!getenv("CALPONT_CONFIG_FILE")) + { + string calpontConfigFile(home + "/Calpont/etc/Columnstore.xml"); + setenv("CALPONT_CONFIG_FILE", calpontConfigFile.c_str(), 1); + } + + if (!getenv("CALPONT_CSC_IDENT")) + setenv("CALPONT_CSC_IDENT", "dm", 1); + +#endif + + IDEBUG( cout << "pushdown_init for table " << endl ); + THD* thd = current_thd; + + //check whether the system is ready to process statement. +#ifndef _MSC_VER + static DBRM dbrm(true); + bool bSystemQueryReady = dbrm.getSystemQueryReady(); + + if (bSystemQueryReady == 0) + { + // Still not ready + setError(thd, ER_INTERNAL_ERROR, "The system is not yet ready to accept queries"); + thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; + return ER_INTERNAL_ERROR; + } + else if (bSystemQueryReady < 0) + { + // Still not ready + setError(thd, ER_INTERNAL_ERROR, "DBRM is not responding. Cannot accept queries"); + thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; + return ER_INTERNAL_ERROR; + } + +#endif + // prevent "create table as select" from running on slave + thd->infinidb_vtable.hasInfiniDBTable = true; + + /* If this node is the slave, ignore DML to IDB tables */ + if (thd->slave_thread && ( + thd->lex->sql_command == SQLCOM_INSERT || + thd->lex->sql_command == SQLCOM_INSERT_SELECT || + thd->lex->sql_command == SQLCOM_UPDATE || + thd->lex->sql_command == SQLCOM_UPDATE_MULTI || + thd->lex->sql_command == SQLCOM_DELETE || + thd->lex->sql_command == SQLCOM_DELETE_MULTI || + thd->lex->sql_command == SQLCOM_TRUNCATE || + thd->lex->sql_command == SQLCOM_LOAD)) + return 0; + + // return error is error status is already set + if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ERROR) + return ER_INTERNAL_ERROR; + + // @bug 2232. Basic SP support. Error out non support sp cases. + // @bug 3939. Only error out for sp with select. Let pass for alter table in sp. + if (thd->infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_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; + } + + // mysql reads table twice for order by + if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_REDO_PHASE1 || + thd->infinidb_vtable.vtable_state == THD::INFINIDB_ORDER_BY) + return 0; + + if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE ) + return 0; + + //Update and delete code + if ( ((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_DELETE) || ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) || ((thd->lex)->sql_command == SQLCOM_UPDATE_MULTI)) + return doUpdateDelete(thd); + + uint32_t sessionID = tid2sid(thd->thread_id); + boost::shared_ptr csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); + csc->identity(CalpontSystemCatalog::FE); + + if (!thd->infinidb_vtable.cal_conn_info) + thd->infinidb_vtable.cal_conn_info = (void*)(new cal_connection_info()); + + cal_connection_info* ci = reinterpret_cast(thd->infinidb_vtable.cal_conn_info); + + idbassert(ci != 0); + + // MySQL sometimes calls rnd_init multiple times, plan should only be + // generated and sent once. + if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && + !thd->infinidb_vtable.isNewQuery) + return 0; + + if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD) + { + if (ci->cal_conn_hndl) + { + // send ExeMgr a signal before closing the connection + ByteStream msg; + ByteStream::quadbyte qb = 0; + msg << qb; + + try + { + ci->cal_conn_hndl->exeMgr->write(msg); + } + catch (...) + { + // canceling query. ignore connection failure. + } + + sm::sm_cleanup(ci->cal_conn_hndl); + ci->cal_conn_hndl = 0; + } + + return 0; + } + + sm::tableid_t tableid = 0; + cal_table_info ti; + sm::cpsm_conhdl_t* hndl; + SCSEP csep; + // Declare handlers ptrs in this scope for future use. + select_handler* sh = NULL; + derived_handler* dh = NULL; + + // update traceFlags according to the autoswitch state. replication query + // on slave are in table mode (create table as...) + if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE || + (thd->slave_thread && thd->infinidb_vtable.vtable_state == THD::INFINIDB_INIT)) + { + ci->traceFlags |= CalpontSelectExecutionPlan::TRACE_TUPLE_OFF; + thd->infinidb_vtable.vtable_state = THD::INFINIDB_DISABLE_VTABLE; + } + else + { + ci->traceFlags = (ci->traceFlags | CalpontSelectExecutionPlan::TRACE_TUPLE_OFF)^ + CalpontSelectExecutionPlan::TRACE_TUPLE_OFF; + } + + bool localQuery = (thd->variables.infinidb_local_query > 0 ? true : false); + + { + //if (!ci->cal_conn_hndl || thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) + if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) + { + ci->stats.reset(); // reset query stats + ci->stats.setStartTime(); + ci->stats.fUser = thd->main_security_ctx.user; + + if (thd->main_security_ctx.host) + ci->stats.fHost = thd->main_security_ctx.host; + else if (thd->main_security_ctx.host_or_ip) + ci->stats.fHost = thd->main_security_ctx.host_or_ip; + else + ci->stats.fHost = "unknown"; + + try + { + ci->stats.userPriority(ci->stats.fHost, ci->stats.fUser); + } + catch (std::exception& e) + { + string msg = string("Columnstore User Priority - ") + e.what(); + ci->warningMsg = msg; + } + + // if the previous query has error, re-establish the connection + if (ci->queryState != 0) + { + 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; + idbassert(ci->cal_conn_hndl->exeMgr != 0); + + try + { + ci->cal_conn_hndl->connect(); + } + catch (...) + { + setError(thd, ER_INTERNAL_ERROR, IDBErrorInfo::instance()->errorMsg(ERR_LOST_CONN_EXEMGR)); + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); + goto error; + } + + hndl = ci->cal_conn_hndl; + + if (thd->infinidb_vtable.vtable_state != THD::INFINIDB_SELECT_VTABLE) + { + if (!csep) + csep.reset(new CalpontSelectExecutionPlan()); + + SessionManager sm; + BRM::TxnID txnID; + txnID = sm.getTxnID(sessionID); + + if (!txnID.valid) + { + txnID.id = 0; + txnID.valid = true; + } + + QueryContext verID; + verID = sm.verID(); + + csep->txnID(txnID.id); + csep->verID(verID); + csep->sessionID(sessionID); + + if (thd->db.length) + csep->schemaName(thd->db.str); + + csep->traceFlags(ci->traceFlags); + + if (thd->infinidb_vtable.isInsertSelect) + csep->queryType(CalpontSelectExecutionPlan::INSERT_SELECT); + + // cast the handler and get a plan. + int status = 42; + if (handler_info->hndl_type == mcs_handler_types_t::SELECT) + { + sh = reinterpret_cast(handler_info->hndl_ptr); + status = cs_get_select_plan(sh, thd, csep); + } + else if (handler_info->hndl_type == DERIVED) + { + dh = reinterpret_cast(handler_info->hndl_ptr); + status = cs_get_derived_plan(dh, thd, csep); + } + + // WIP MCOL-2121 Find a way to return an actual error + // It either ends up with 42 or other error status + if (status > 0) + goto internal_error; + else if (status < 0) + return 0; + + // @bug 2547. don't need to send the plan if it's impossible where for all unions. + if (thd->infinidb_vtable.impossibleWhereOnUnion) + return 0; + + string query; + query.assign(idb_mysql_query_str(thd)); + //query.assign(thd->infinidb_vtable.original_query.ptr(), + // thd->infinidb_vtable.original_query.length()); + csep->data(query); + + try + { + csep->priority( ci->stats.userPriority(ci->stats.fHost, ci->stats.fUser)); + } + catch (std::exception& e) + { + string msg = string("Columnstore User Priority - ") + e.what(); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, msg.c_str()); + } + +#ifdef PLAN_HEX_FILE + // plan serialization + ifstream ifs("/tmp/li1-plan.hex"); + ByteStream bs1; + ifs >> bs1; + ifs.close(); + csep->unserialize(bs1); +#endif + + if (ci->traceFlags & 1) + { + cerr << "---------------- EXECUTION PLAN ----------------" << endl; + cerr << *csep << endl ; + cerr << "-------------- EXECUTION PLAN END --------------\n" << endl; + } + else + { + IDEBUG( cout << "---------------- EXECUTION PLAN ----------------" << endl ); + IDEBUG( cerr << *csep << endl ); + IDEBUG( cout << "-------------- EXECUTION PLAN END --------------\n" << endl ); + } + } + }// end of execution plan generation + + if (thd->infinidb_vtable.vtable_state != THD::INFINIDB_SELECT_VTABLE) + { + ByteStream msg; + ByteStream emsgBs; + + while (true) + { + try + { + ByteStream::quadbyte qb = 4; + msg << qb; + hndl->exeMgr->write(msg); + msg.restart(); + csep->rmParms(rmParms); + + //send plan + csep->serialize(msg); + hndl->exeMgr->write(msg); + + //get ExeMgr status back to indicate a vtable joblist success or not + msg.restart(); + emsgBs.restart(); + msg = hndl->exeMgr->read(); + emsgBs = hndl->exeMgr->read(); + string emsg; + + if (msg.length() == 0 || emsgBs.length() == 0) + { + emsg = "Lost connection to ExeMgr. Please contact your administrator"; + setError(thd, ER_INTERNAL_ERROR, emsg); + return ER_INTERNAL_ERROR; + } + + string emsgStr; + emsgBs >> emsgStr; + bool err = false; + + if (msg.length() == 4) + { + msg >> qb; + + if (qb != 0) + { + err = true; + // for makejoblist error, stats contains only error code and insert from here + // because table fetch is not started + ci->stats.setEndTime(); + ci->stats.fQuery = csep->data(); + ci->stats.fQueryType = csep->queryType(); + ci->stats.fErrorNo = qb; + + try + { + ci->stats.insert(); + } + catch (std::exception& e) + { + string msg = string("Columnstore Query Stats - ") + e.what(); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, msg.c_str()); + } + } + } + else + { + err = true; + } + + if (err) + { + setError(thd, ER_INTERNAL_ERROR, emsgStr); + return ER_INTERNAL_ERROR; + } + + rmParms.clear(); + + if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + { + ci->tableMap[table] = ti; + } + else + { + ci->queryState = 1; + } + + break; + } + catch (...) + { + sm::sm_cleanup(hndl); + hndl = 0; + + sm::sm_init(sessionID, &hndl, localQuery); + idbassert(hndl != 0); + hndl->csc = csc; + + if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + ti.conn_hndl = hndl; + else + ci->cal_conn_hndl = hndl; + + try + { + hndl->connect(); + } + catch (...) + { + setError(thd, ER_INTERNAL_ERROR, IDBErrorInfo::instance()->errorMsg(ERR_LOST_CONN_EXEMGR)); + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); + goto error; + } + + msg.restart(); + } + } + } + + // set query state to be in_process. Sometimes mysql calls rnd_init multiple + // times, this makes sure plan only being generated and sent once. It will be + // reset when query finishes in sm::end_query + thd->infinidb_vtable.isNewQuery = false; + + // common path for both vtable select phase and table mode -- open scan handle + ti = ci->tableMap[table]; + // This is the server's temp table for the result. + if(sh) + { + ti.msTablePtr = sh->table; + } + else + { + ti.msTablePtr = dh->table; + } + + { + if (ti.tpl_ctx == 0) + { + ti.tpl_ctx = new sm::cpsm_tplh_t(); + ti.tpl_scan_ctx = sm::sp_cpsm_tplsch_t(new sm::cpsm_tplsch_t()); + } + + // make sure rowgroup is null so the new meta data can be taken. This is for some case mysql + // call rnd_init for a table more than once. + ti.tpl_scan_ctx->rowGroup = NULL; + + try + { + tableid = execplan::IDB_VTABLE_ID; + } + catch (...) + { + string emsg = "No table ID found for table " + string(table->s->table_name.str); + setError(thd, ER_INTERNAL_ERROR, emsg); + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); + goto internal_error; + } + + try + { + sm::tpl_open(tableid, ti.tpl_ctx, hndl); + sm::tpl_scan_open(tableid, ti.tpl_scan_ctx, hndl); + } + catch (std::exception& e) + { + string emsg = "table can not be opened: " + string(e.what()); + setError(thd, ER_INTERNAL_ERROR, emsg); + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); + goto internal_error; + } + catch (...) + { + string emsg = "table can not be opened"; + setError(thd, ER_INTERNAL_ERROR, emsg); + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); + goto internal_error; + } + + ti.tpl_scan_ctx->traceFlags = ci->traceFlags; + + if ((ti.tpl_scan_ctx->ctp).size() == 0) + { + uint32_t num_attr = table->s->fields; + + for (uint32_t i = 0; i < num_attr; i++) + { + CalpontSystemCatalog::ColType ctype; + ti.tpl_scan_ctx->ctp.push_back(ctype); + } + + // populate coltypes here for table mode because tableband gives treeoid for dictionary column + if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + { + CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str), true); + + if (oidlist.size() != num_attr) + { + string emsg = "Size mismatch probably caused by front end out of sync"; + setError(thd, ER_INTERNAL_ERROR, emsg); + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); + goto internal_error; + } + + for (unsigned int j = 0; j < oidlist.size(); j++) + { + CalpontSystemCatalog::ColType ctype = csc->colType(oidlist[j].objnum); + ti.tpl_scan_ctx->ctp[ctype.colPosition] = ctype; + ti.tpl_scan_ctx->ctp[ctype.colPosition].colPosition = -1; + } + } + } + } + + ci->tableMap[table] = ti; + return 0; + +error: + + if (ci->cal_conn_hndl) + { + sm::sm_cleanup(ci->cal_conn_hndl); + ci->cal_conn_hndl = 0; + } + + // do we need to close all connection handle of the table map? + return ER_INTERNAL_ERROR; + +internal_error: + + if (ci->cal_conn_hndl) + { + sm::sm_cleanup(ci->cal_conn_hndl); + ci->cal_conn_hndl = 0; + } + + return ER_INTERNAL_ERROR; +} // vim:sw=4 ts=4: diff --git a/dbcon/mysql/ha_calpont_impl.h b/dbcon/mysql/ha_calpont_impl.h index bdc0e0eef..7e8de5ce5 100644 --- a/dbcon/mysql/ha_calpont_impl.h +++ b/dbcon/mysql/ha_calpont_impl.h @@ -20,6 +20,7 @@ #define HA_CALPONT_IMPL_H__ #include "idb_mysql.h" +#include "ha_mcs_pushdown.h" #ifdef NEED_CALPONT_EXTERNS extern int ha_calpont_impl_discover_existence(const char* schema, const char* name); @@ -29,7 +30,7 @@ extern int ha_calpont_impl_open(const char* name, int mode, uint32_t test_if_loc extern int ha_calpont_impl_close(void); extern int ha_calpont_impl_rnd_init(TABLE* table); extern int ha_calpont_impl_rnd_next(uchar* buf, TABLE* table); -extern int ha_calpont_impl_rnd_end(TABLE* table); +extern int ha_calpont_impl_rnd_end(TABLE* table, bool is_derived_hand = false); extern int ha_calpont_impl_write_row(uchar* buf, TABLE* table); extern void ha_calpont_impl_start_bulk_insert(ha_rows rows, TABLE* table); extern int ha_calpont_impl_end_bulk_insert(bool abort, TABLE* table); @@ -45,6 +46,7 @@ extern int ha_calpont_impl_rnd_pos(uchar* buf, uchar* pos); extern int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE* table); extern int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE* table); extern int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE* table); +extern int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info , TABLE* table); #endif @@ -52,6 +54,7 @@ extern int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, #include "ha_calpont_impl_if.h" #include "calpontsystemcatalog.h" #include "ha_calpont.h" +#include "ha_mcs_pushdown.h" extern int ha_calpont_impl_rename_table_(const char* from, const char* to, cal_impl_if::cal_connection_info& ci); extern int ha_calpont_impl_write_row_(uchar* buf, TABLE* table, cal_impl_if::cal_connection_info& ci, ha_rows& rowsInserted); extern int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_connection_info& ci); @@ -71,6 +74,7 @@ extern std::string ha_calpont_impl_cleartablelock( cal_impl_if::cal_connection_ extern int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE* table); extern int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE* table); extern int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE* table); +extern int ha_cs_impl_derived_next(TABLE* table); #endif #endif diff --git a/dbcon/mysql/ha_calpont_impl_if.h b/dbcon/mysql/ha_calpont_impl_if.h index 6d8945ad8..820f8d430 100644 --- a/dbcon/mysql/ha_calpont_impl_if.h +++ b/dbcon/mysql/ha_calpont_impl_if.h @@ -337,14 +337,16 @@ const std::string infinidb_err_msg = "\nThe query includes syntax that is not su int cp_get_plan(THD* thd, execplan::SCSEP& csep); int cp_get_table_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_table_info& ti); int cp_get_group_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_group_info& gi); -int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, execplan::SCSEP& csep, bool isUnion = false); +int cs_get_derived_plan(derived_handler* handler, THD* thd, SCSEP& csep); +int cs_get_select_plan(select_handler* handler, THD* thd, SCSEP& csep); +int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, execplan::SCSEP& csep, bool isUnion = false, bool isPushdownHand = false); int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, execplan::SCSEP& csep, cal_group_info& gi, bool isUnion = false); void setError(THD* thd, uint32_t errcode, const std::string errmsg, gp_walk_info* gwi); void setError(THD* thd, uint32_t errcode, const std::string errmsg); void gp_walk(const Item* item, void* arg); void parse_item (Item* item, std::vector& field_vec, bool& hasNonSupportItem, uint16& parseInfo, gp_walk_info* gwip = NULL); const std::string bestTableName(const Item_field* ifp); -bool isInfiniDB(TABLE* table_ptr); +bool isMCSTable(TABLE* table_ptr); // execution plan util functions prototypes execplan::ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupport, bool pushdownHand = false); diff --git a/dbcon/mysql/ha_mcs_pushdown.cpp b/dbcon/mysql/ha_mcs_pushdown.cpp new file mode 100644 index 000000000..bc4673a11 --- /dev/null +++ b/dbcon/mysql/ha_mcs_pushdown.cpp @@ -0,0 +1,661 @@ +/* + Copyright (c) 2019 MariaDB + + 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 St, Fifth Floor, Boston, MA 02110-1301 USA */ + + +// ha_calpont.cpp includes this file. + +/*@brief check_walk - It traverses filter conditions*/ +/************************************************************ + * DESCRIPTION: + * It traverses filter predicates looking for unsupported + * JOIN types: non-equi JOIN, e.g t1.c1 > t2.c2; + * logical OR. + * PARAMETERS: + * thd - THD pointer. + * derived - TABLE_LIST* to work with. + * RETURN: + * derived_handler if possible + * NULL in other case + ***********************************************************/ +void check_walk(const Item* item, void* arg) +{ + bool* unsupported_feature = static_cast(arg); + if ( *unsupported_feature ) + return; + switch (item->type()) + { + case Item::FUNC_ITEM: + { + const Item_func* ifp = static_cast(item); + + if ( ifp->functype() != Item_func::EQ_FUNC ) // NON-equi JOIN + { + if ( ifp->argument_count() == 2 && + ifp->arguments()[0]->type() == Item::FIELD_ITEM && + ifp->arguments()[1]->type() == Item::FIELD_ITEM ) + { + Item_field* left= static_cast(ifp->arguments()[0]); + Item_field* right= static_cast(ifp->arguments()[1]); + + if ( left->field->table != right->field->table ) + { + *unsupported_feature = true; + return; + } + } + else // IN + correlated subquery + { + if ( ifp->functype() == Item_func::NOT_FUNC + && ifp->arguments()[0]->type() == Item::EXPR_CACHE_ITEM ) + { + check_walk(ifp->arguments()[0], arg); + } + } + } + break; + } + + case Item::EXPR_CACHE_ITEM: // IN + correlated subquery + { + const Item_cache_wrapper* icw = static_cast(item); + if ( icw->get_orig_item()->type() == Item::FUNC_ITEM ) + { + const Item_func *ifp = static_cast(icw->get_orig_item()); + if ( ifp->argument_count() == 2 && + ( ifp->arguments()[0]->type() == Item::Item::SUBSELECT_ITEM + || ifp->arguments()[1]->type() == Item::Item::SUBSELECT_ITEM )) + { + *unsupported_feature = true; + return; + } + } + break; + } + + case Item::COND_ITEM: // OR in JOIN conds is unsupported yet + { + Item_cond* icp = (Item_cond*)item; + if ( is_cond_or(icp) ) + { + *unsupported_feature = true; + } + break; + } + default: + { + break; + } + } +} + +/*@brief create_calpont_group_by_handler- Creates handler*/ +/*********************************************************** + * DESCRIPTION: + * Creates a group_by pushdown handler if there is no: + * non-equi JOIN, e.g * t1.c1 > t2.c2 + * logical OR in the filter predicates + * Impossible WHERE + * Impossible HAVING + * 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 LFM in group_by_handler.h + * RETURN: + * group_by_handler if success + * NULL in other case + ***********************************************************/ +static group_by_handler* +create_calpont_group_by_handler(THD* thd, Query* query) +{ + ha_calpont_group_by_handler* handler = NULL; + // same as thd->lex->current_select + SELECT_LEX *select_lex = query->from->select_lex; + + // Create a handler if query is valid. See comments for details. + if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE + && ( thd->variables.infinidb_vtable_mode == 0 + || thd->variables.infinidb_vtable_mode == 2 ) + && ( query->group_by || select_lex->with_sum_func ) ) + { + bool unsupported_feature = false; + // revisit SELECT_LEX for all units + for(TABLE_LIST* tl = query->from; !unsupported_feature && tl; tl = tl->next_global) + { + select_lex = tl->select_lex; + // Correlation subquery. Comming soon so fail on this yet. + unsupported_feature = select_lex->is_correlated; + + // 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 ) ) + { + unsupported_feature = true; + } + + // Unsupported JOIN conditions + if ( !unsupported_feature ) + { + JOIN *join = select_lex->join; + Item_cond *icp = 0; + + if (join != 0) + icp = reinterpret_cast(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(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 ) + { + handler = new ha_calpont_group_by_handler(thd, query); + + // 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; +} + +/*@brief create_columnstore_derived_handler- Creates handler*/ +/************************************************************ + * DESCRIPTION: + * Creates a derived handler if there is no non-equi JOIN, e.g + * t1.c1 > t2.c2 and logical OR in the filter predicates. + * More details in server/sql/derived_handler.h + * PARAMETERS: + * thd - THD pointer. + * derived - TABLE_LIST* to work with. + * RETURN: + * derived_handler if possible + * NULL in other case + ***********************************************************/ +static derived_handler* +create_columnstore_derived_handler(THD* thd, TABLE_LIST *derived) +{ + ha_columnstore_derived_handler* handler = NULL; + handlerton *ht= 0; + + SELECT_LEX_UNIT *unit= derived->derived; + + if ( thd->infinidb_vtable.vtable_state != THD::INFINIDB_DISABLE_VTABLE + && thd->variables.infinidb_vtable_mode != 0 ) + { + return 0; + } + + for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select()) + { + if (!(sl->join)) + return 0; + for (TABLE_LIST *tbl= sl->join->tables_list; tbl; tbl= tbl->next_local) + { + if (!tbl->table) + return 0; + // Same handlerton type check. + if (!ht) + ht= tbl->table->file->partition_ht(); + else if (ht != tbl->table->file->partition_ht()) + return 0; + } + } + + bool unsupported_feature = false; + { + SELECT_LEX select_lex = *unit->first_select(); + JOIN* join = select_lex.join; + Item_cond* icp = 0; + + if (join != 0) + icp = reinterpret_cast(join->conds); + + if (!join) + { + icp = reinterpret_cast(select_lex.where); + } + + if ( icp ) + { + icp->traverse_cond(check_walk, &unsupported_feature, Item::POSTFIX); + } + } + + if ( !unsupported_feature ) + handler= new ha_columnstore_derived_handler(thd, derived); + + return handler; +} + +/*********************************************************** + * DESCRIPTION: + * derived_handler constructor + * PARAMETERS: + * thd - THD pointer. + * tbl - tables involved. + ***********************************************************/ +ha_columnstore_derived_handler::ha_columnstore_derived_handler(THD *thd, + TABLE_LIST *dt) + : derived_handler(thd, calpont_hton) +{ + derived = dt; +} + +/*********************************************************** + * DESCRIPTION: + * derived_handler destructor + ***********************************************************/ +ha_columnstore_derived_handler::~ha_columnstore_derived_handler() +{} + +/*@brief Initiate the query for derived_handler */ +/*********************************************************** + * DESCRIPTION: + * Execute the query and saves derived table query. + * ATM this function sets vtable_state and restores it afterwards + * since it reuses existed vtable code internally. + * PARAMETERS: + * + * RETURN: + * rc as int + ***********************************************************/ +int ha_columnstore_derived_handler::init_scan() +{ + char query_buff[4096]; + + DBUG_ENTER("ha_columnstore_derived_handler::init_scan"); + + // Save query for logging + String derived_query(query_buff, sizeof(query_buff), thd->charset()); + derived_query.length(0); + derived->derived->print(&derived_query, QT_ORDINARY); + + // Save vtable_state to restore the after we inited. + THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; + thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; + + mcs_handler_info mhi = mcs_handler_info(static_cast(this), DERIVED); + // this::table is the place for the result set + int rc = ha_cs_impl_pushdown_init(&mhi, table); + + thd->infinidb_vtable.vtable_state = oldState; + + DBUG_RETURN(rc); +} + +/*@brief Fetch next row for derived_handler */ +/*********************************************************** + * DESCRIPTION: + * Fetches next row and saves it in the temp table + * ATM this function sets vtable_state and restores it + * afterwards since it reuses existed vtable code internally. + * PARAMETERS: + * + * RETURN: + * rc as int + * + ***********************************************************/ +int ha_columnstore_derived_handler::next_row() +{ + DBUG_ENTER("ha_columnstore_derived_handler::next_row"); + + // Save vtable_state to restore the after we inited. + THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; + + thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; + + int rc = ha_calpont_impl_rnd_next(table->record[0], table); + + thd->infinidb_vtable.vtable_state = oldState; + + DBUG_RETURN(rc); +} + +/*@brief Finishes the scan and clean it up */ +/*********************************************************** + * DESCRIPTION: + * Finishes the scan for derived handler + * ATM this function sets vtable_state and restores it + * afterwards since it reuses existed vtable code internally. + * PARAMETERS: + * + * RETURN: + * rc as int + * + ***********************************************************/ +int ha_columnstore_derived_handler::end_scan() +{ + DBUG_ENTER("ha_columnstore_derived_handler::end_scan"); + + THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; + thd->infinidb_vtable.vtable_state = THD::INFINIDB_SELECT_VTABLE; + + int rc = ha_calpont_impl_rnd_end(table, true); + + thd->infinidb_vtable.vtable_state = oldState; + + DBUG_RETURN(rc); +} + +void ha_columnstore_derived_handler::print_error(int, unsigned long) +{ +} + +/*********************************************************** + * DESCRIPTION: + * GROUP BY handler constructor + * PARAMETERS: + * thd - THD pointer. + * query - Query describing structure + ***********************************************************/ +ha_calpont_group_by_handler::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) +{ +} + +/*********************************************************** + * DESCRIPTION: + * GROUP BY destructor + ***********************************************************/ +ha_calpont_group_by_handler::~ha_calpont_group_by_handler() +{ +} + +/*********************************************************** + * DESCRIPTION: + * Makes the plan and prepares the data + * RETURN: + * int rc + ***********************************************************/ +int ha_calpont_group_by_handler::init_scan() +{ + DBUG_ENTER("ha_calpont_group_by_handler::init_scan"); + + // Save vtable_state to restore the after we inited. + THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; + // MCOL-1052 Should be removed after cleaning the code up. + thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; + int rc = ha_calpont_impl_group_by_init(this, table); + thd->infinidb_vtable.vtable_state = oldState; + + DBUG_RETURN(rc); +} + +/*********************************************************** + * DESCRIPTION: + * Fetches a row and saves it to a temporary table. + * RETURN: + * int rc + ***********************************************************/ +int ha_calpont_group_by_handler::next_row() +{ + DBUG_ENTER("ha_calpont_group_by_handler::next_row"); + int rc = ha_calpont_impl_group_by_next(this, table); + + DBUG_RETURN(rc); +} + +/*********************************************************** + * DESCRIPTION: + * Shuts the scan down. + * RETURN: + * int rc + ***********************************************************/ +int ha_calpont_group_by_handler::end_scan() +{ + DBUG_ENTER("ha_calpont_group_by_handler::end_scan"); + + int rc = ha_calpont_impl_group_by_end(this, table); + + DBUG_RETURN(rc); +} + +/*@brief create_columnstore_select_handler- Creates handler*/ +/************************************************************ + * DESCRIPTION: + * Creates a select handler if there is no non-equi JOIN, e.g + * t1.c1 > t2.c2 and logical OR in the filter predicates. + * More details in server/sql/select_handler.h + * PARAMETERS: + * thd - THD pointer. + * sel - SELECT_LEX* that describes the query. + * RETURN: + * select_handler if possible + * NULL in other case + ***********************************************************/ +static select_handler* +create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) +{ + ha_columnstore_select_handler* handler = NULL; + handlerton *ht= 0; + + // Return if vtable enabled. + if ( thd->infinidb_vtable.vtable_state != THD::INFINIDB_DISABLE_VTABLE + && thd->variables.infinidb_vtable_mode != 0 ) + { + return 0; + } + for (SELECT_LEX* sl = select_lex;sl; sl= sl->next_select()) + { + if (!(sl->join)) + return 0; + for (TABLE_LIST *tbl= sl->join->tables_list; tbl; tbl= tbl->next_local) + { + if (!tbl->table) + return 0; + // Same handlerton type check. + if (!ht) + ht= tbl->table->file->partition_ht(); + else if (ht != tbl->table->file->partition_ht()) + return 0; + } + } + + bool unsupported_feature = false; + // Impossible HAVING or WHERE + if ( ( select_lex->having && select_lex->having_value == Item::COND_FALSE ) + || ( select_lex->cond_count > 0 + && select_lex->cond_value == Item::COND_FALSE ) ) + { + unsupported_feature = true; + } + + // Unsupported query check. + if ( !unsupported_feature ) + { + // JOIN expression from WHERE, ON expressions + JOIN* join = select_lex->join; + Item_cond* where_icp = 0; + Item_cond* on_icp = 0; + + if (join != 0) + { + where_icp = reinterpret_cast(join->conds); + } + + if ( where_icp ) + { + where_icp->traverse_cond(check_walk, &unsupported_feature, Item::POSTFIX); + } + + // Looking for JOIN with ON expression through + // TABLE_LIST in FROM until CS meets unsupported feature + TABLE_LIST* table_ptr = select_lex->get_table_list(); + for (; !unsupported_feature && table_ptr; table_ptr = table_ptr->next_global) + { + if(table_ptr->on_expr) + { + on_icp = reinterpret_cast(table_ptr->on_expr); + on_icp->traverse_cond(check_walk, &unsupported_feature, Item::POSTFIX); + } + } + + // CROSS JOIN w/o conditions isn't supported until MCOL-301 + // is ready. + if (join && join->table_count >= 2 && ( !where_icp && !on_icp )) + { + unsupported_feature = true; + } + } + + if (!unsupported_feature) + { + handler = new ha_columnstore_select_handler(thd, select_lex); + } + + return handler; +} + +/*********************************************************** + * DESCRIPTION: + * select_handler constructor + * PARAMETERS: + * thd - THD pointer. + * select_lex - sematic tree for the query. + ***********************************************************/ +ha_columnstore_select_handler::ha_columnstore_select_handler(THD *thd, + SELECT_LEX* select_lex) + : select_handler(thd, calpont_hton) +{ + select = select_lex; +} + +/*********************************************************** + * DESCRIPTION: + * select_handler constructor + ***********************************************************/ +ha_columnstore_select_handler::~ha_columnstore_select_handler() +{} + +/*@brief Initiate the query for select_handler */ +/*********************************************************** + * DESCRIPTION: + * Execute the query and saves select table query. + * ATM this function sets vtable_state and restores it afterwards + * since it reuses existed vtable code internally. + * PARAMETERS: + * + * RETURN: + * rc as int + ***********************************************************/ +int ha_columnstore_select_handler::init_scan() +{ + char query_buff[4096]; + + DBUG_ENTER("ha_columnstore_select_handler::init_scan"); + + // Save query for logging + String select_query(query_buff, sizeof(query_buff), thd->charset()); + select_query.length(0); + select->print(thd, &select_query, QT_ORDINARY); + + // Save vtable_state to restore the after we inited. + THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; + thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; + + mcs_handler_info mhi = mcs_handler_info(static_cast(this), SELECT); + // this::table is the place for the result set + int rc = ha_cs_impl_pushdown_init(&mhi, table); + + thd->infinidb_vtable.vtable_state = oldState; + + DBUG_RETURN(rc); +} + +/*@brief Fetch next row for select_handler */ +/*********************************************************** + * DESCRIPTION: + * Fetches next row and saves it in the temp table + * ATM this function sets vtable_state and restores it + * afterwards since it reuses existed vtable code internally. + * PARAMETERS: + * + * RETURN: + * rc as int + * + ***********************************************************/ +int ha_columnstore_select_handler::next_row() +{ + DBUG_ENTER("ha_columnstore_select_handler::next_row"); + + // Save vtable_state to restore the after we inited. + THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; + + thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; + + int rc = ha_calpont_impl_rnd_next(table->record[0], table); + + thd->infinidb_vtable.vtable_state = oldState; + + DBUG_RETURN(rc); +} + +/*@brief Finishes the scan and clean it up */ +/*********************************************************** + * DESCRIPTION: + * Finishes the scan for select handler + * ATM this function sets vtable_state and restores it + * afterwards since it reuses existed vtable code internally. + * PARAMETERS: + * + * RETURN: + * rc as int + * + ***********************************************************/ +int ha_columnstore_select_handler::end_scan() +{ + DBUG_ENTER("ha_columnstore_select_handler::end_scan"); + + THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; + thd->infinidb_vtable.vtable_state = THD::INFINIDB_SELECT_VTABLE; + + int rc = ha_calpont_impl_rnd_end(table, true); + + thd->infinidb_vtable.vtable_state = oldState; + + DBUG_RETURN(rc); +} + +void ha_columnstore_select_handler::print_error(int, unsigned long) +{} diff --git a/dbcon/mysql/ha_mcs_pushdown.h b/dbcon/mysql/ha_mcs_pushdown.h new file mode 100644 index 000000000..2849cb530 --- /dev/null +++ b/dbcon/mysql/ha_mcs_pushdown.h @@ -0,0 +1,142 @@ +/* + Copyright (c) 2019 MariaDB + + 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 St, Fifth Floor, Boston, MA 02110-1301 USA */ + + +#ifndef HA_MCS_PUSH +#define HA_MCS_PUSH + +#include "idb_mysql.h" +#include "ha_calpont.h" + +enum mcs_handler_types_t +{ + SELECT, + DERIVED, + GROUP_BY, + LEGACY +}; + +struct mcs_handler_info +{ + mcs_handler_info() : hndl_ptr(NULL), hndl_type(LEGACY) { }; + mcs_handler_info(mcs_handler_types_t type) : hndl_ptr(NULL), hndl_type(type) { }; + mcs_handler_info(void* ptr, mcs_handler_types_t type) : hndl_ptr(ptr), hndl_type(type) { }; + ~mcs_handler_info() { }; + void* hndl_ptr; + mcs_handler_types_t hndl_type; +}; + +/*@brief group_by_handler class*/ +/*********************************************************** + * DESCRIPTION: + * 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 according 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. + * select_list_descr - contains Item description returned by Item->print() + * that is used in lookup for corresponding columns in + * extended SELECT list. + * table_list - contains all tables involved. Must be CS tables only. + * distinct - looks like a useless thing for now. Couldn't get it set by server. + * where - where items. + * group_by - group by ORDER items. + * order_by - order by ORDER items. + * having - having Item. + * Methods: + * init_scan - get plan and send it to ExeMgr. Get the execution result. + * next_row - get a row back from sm. + * end_scan - finish and clean the things up. + ***********************************************************/ +class ha_calpont_group_by_handler: public group_by_handler +{ +public: + ha_calpont_group_by_handler(THD* thd_arg, Query* query); + ~ha_calpont_group_by_handler(); + int init_scan(); + int next_row(); + int end_scan(); + + List* select; + TABLE_LIST* table_list; + bool distinct; + Item* where; + ORDER* group_by; + ORDER* order_by; + Item* having; +}; + +/*@brief derived_handler class*/ +/*********************************************************** + * DESCRIPTION: + * derived_handler API methods. Could be used by the server + * tp process sub-queries. + * More details in server/sql/dervied_handler.h + * INFINIDB_SHARE* hton share + * tbl in the constructor is the list of the tables involved. + * Methods: + * init_scan - get plan and send it to ExeMgr. Get the execution result. + * next_row - get a row back from sm. + * end_scan - finish and clean the things up. + ***********************************************************/ +class ha_columnstore_derived_handler: public derived_handler +{ +private: + INFINIDB_SHARE *share; + +public: + ha_columnstore_derived_handler(THD* thd_arg, TABLE_LIST *tbl); + ~ha_columnstore_derived_handler(); + int init_scan(); + int next_row(); + int end_scan(); + void print_error(int, unsigned long); +}; + +/*@brief select_handler class*/ +/*********************************************************** + * DESCRIPTION: + * select_handler API methods. Could be used by the server + * tp pushdown the whole query described by SELECT_LEX. + * More details in server/sql/select_handler.h + * INFINIDB_SHARE* hton share + * sel in the constructor is the semantic tree for the query. + * Methods: + * init_scan - get plan and send it to ExeMgr. Get the execution result. + * next_row - get a row back from sm. + * end_scan - finish and clean the things up. + ***********************************************************/ +class ha_columnstore_select_handler: public select_handler +{ +private: + INFINIDB_SHARE *share; + +public: + ha_columnstore_select_handler(THD* thd_arg, SELECT_LEX* sel); + ~ha_columnstore_select_handler(); + int init_scan(); + int next_row(); + int end_scan(); + void print_error(int, unsigned long); +}; + +#endif diff --git a/dbcon/mysql/ha_view.cpp b/dbcon/mysql/ha_view.cpp index 764c2c5c5..3bc49b2a8 100644 --- a/dbcon/mysql/ha_view.cpp +++ b/dbcon/mysql/ha_view.cpp @@ -117,7 +117,7 @@ void View::transform() else { // check foreign engine tables - bool infiniDB = (table_ptr->table ? isInfiniDB(table_ptr->table) : true); + bool infiniDB = (table_ptr->table ? isMCSTable(table_ptr->table) : true); // trigger system catalog cache if (infiniDB) diff --git a/dbcon/mysql/idb_mysql.h b/dbcon/mysql/idb_mysql.h index 25f3effcf..cb842d740 100644 --- a/dbcon/mysql/idb_mysql.h +++ b/dbcon/mysql/idb_mysql.h @@ -70,6 +70,8 @@ template bool isnan(T); #include "item_windowfunc.h" #include "sql_cte.h" #include "tztime.h" +#include "derived_handler.h" +#include "select_handler.h" // Now clean up the pollution as best we can... #undef min From 6fd5b2f22d905ffbd743aa2b623fd329953acd13 Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Tue, 19 Feb 2019 20:37:44 +0300 Subject: [PATCH 43/59] MCOL-2178 Merging with 10.4 SELECT_LEX had been moved in THD so changed all references. Avoid writing CS decimal scales into MDB decimal fields d-only dec attribute. WIP Replaced infinidb_vtable with a singleton MIGR. Merged with MCOL-2121. Added new wsrep include paths needed by UDaF code. Removed .vcxproj from Connector code. --- CMakeLists.txt | 4 +- dbcon/mysql/ha_calpont_ddl.cpp | 4 +- dbcon/mysql/ha_calpont_dml.cpp | 4 +- dbcon/mysql/ha_calpont_execplan.cpp | 87 ++++---- dbcon/mysql/ha_calpont_impl.cpp | 321 ++++++++++++++-------------- dbcon/mysql/ha_mcs_pushdown.cpp | 59 ++--- dbcon/mysql/ha_mcs_sysvars.cpp | 150 +++---------- dbcon/mysql/ha_view.cpp | 2 +- dbcon/mysql/idb_mysql.h | 63 ++++++ 9 files changed, 335 insertions(+), 359 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b931d30c0..3be90eaa4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -283,11 +283,13 @@ SET (ENGINE_WE_CONFIGCPP_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/writeengine/x SET (ENGINE_SERVER_SQL_INCLUDE "${SERVER_SOURCE_ROOT_DIR}/sql") SET (ENGINE_SERVER_INCLUDE_INCLUDE "${SERVER_SOURCE_ROOT_DIR}/include") SET (ENGINE_SERVER_PCRE_INCLUDE "${SERVER_BUILD_INCLUDE_DIR}/../pcre") +SET (ENGINE_SERVER_WSREP_INCLUDE "${SERVER_BUILD_INCLUDE_DIR}/../wsrep-lib/include") +SET (ENGINE_SERVER_WSREP_API_INCLUDE "${SERVER_BUILD_INCLUDE_DIR}/../wsrep-lib/wsrep-API/v26/") SET (ENGINE_UTILS_UDFSDK_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/udfsdk") SET (ENGINE_DEFAULT_INCLUDES ${CMAKE_BINARY_DIR} "." "../" "../../" ${SERVER_BUILD_INCLUDE_DIR}) -SET (ENGINE_COMMON_INCLUDES ${ENGINE_DEFAULT_INCLUDES} ${Boost_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} ${ENGINE_UTILS_MESSAGEQCPP_INCLUDE} ${ENGINE_WE_SHARED_INCLUDE} ${ENGINE_UTILS_IDBDATAFILE_INCLUDE} ${ENGINE_UTILS_LOGGINGCPP_INCLUDE} ${ENGINE_UTILS_CONFIGCPP_INCLUDE} ${ENGINE_UTILS_COMPRESS_INCLUDE} ${ENGINE_VERSIONING_BRM_INCLUDE} ${ENGINE_UTILS_ROWGROUP_INCLUDE} ${ENGINE_UTILS_COMMON_INCLUDE} ${ENGINE_UTILS_DATACONVERT_INCLUDE} ${ENGINE_UTILS_RWLOCK_INCLUDE} ${ENGINE_UTILS_FUNCEXP_INCLUDE} ${ENGINE_OAMAPPS_ALARMMANAGER_INCLUDE} ${ENGINE_UTILS_INCLUDE} ${ENGINE_OAM_OAMCPP_INCLUDE} ${ENGINE_DBCON_DDLPKGPROC_INCLUDE} ${ENGINE_DBCON_DDLPKG_INCLUDE} ${ENGINE_DBCON_EXECPLAN_INCLUDE} ${ENGINE_UTILS_STARTUP_INCLUDE} ${ENGINE_DBCON_JOBLIST_INCLUDE} ${ENGINE_WE_WRAPPER_INCLUDE} ${ENGINE_WE_SERVER_INCLUDE} ${ENGINE_DBCON_DMLPKG_INCLUDE} ${ENGINE_WE_CLIENT_INCLUDE} ${ENGINE_DBCON_DMLPKGPROC_INCLUDE} ${ENGINE_UTILS_CACHEUTILS_INCLUDE} ${ENGINE_UTILS_MYSQLCL_INCLUDE} ${ENGINE_UTILS_QUERYTELE_INCLUDE} ${ENGINE_UTILS_THRIFT_INCLUDE} ${ENGINE_UTILS_JOINER_INCLUDE} ${ENGINE_UTILS_THREADPOOL_INCLUDE} ${ENGINE_UTILS_BATCHLDR_INCLUDE} ${ENGINE_UTILS_DDLCLEANUP_INCLUDE} ${ENGINE_UTILS_QUERYSTATS_INCLUDE} ${ENGINE_WE_CONFIGCPP_INCLUDE} ${ENGINE_SERVER_SQL_INCLUDE} ${ENGINE_SERVER_INCLUDE_INCLUDE} ${ENGINE_SERVER_PCRE_INCLUDE} ${ENGINE_UTILS_UDFSDK_INCLUDE} ${ENGINE_UTILS_LIBMYSQL_CL_INCLUDE}) +SET (ENGINE_COMMON_INCLUDES ${ENGINE_DEFAULT_INCLUDES} ${Boost_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} ${ENGINE_UTILS_MESSAGEQCPP_INCLUDE} ${ENGINE_WE_SHARED_INCLUDE} ${ENGINE_UTILS_IDBDATAFILE_INCLUDE} ${ENGINE_UTILS_LOGGINGCPP_INCLUDE} ${ENGINE_UTILS_CONFIGCPP_INCLUDE} ${ENGINE_UTILS_COMPRESS_INCLUDE} ${ENGINE_VERSIONING_BRM_INCLUDE} ${ENGINE_UTILS_ROWGROUP_INCLUDE} ${ENGINE_UTILS_COMMON_INCLUDE} ${ENGINE_UTILS_DATACONVERT_INCLUDE} ${ENGINE_UTILS_RWLOCK_INCLUDE} ${ENGINE_UTILS_FUNCEXP_INCLUDE} ${ENGINE_OAMAPPS_ALARMMANAGER_INCLUDE} ${ENGINE_UTILS_INCLUDE} ${ENGINE_OAM_OAMCPP_INCLUDE} ${ENGINE_DBCON_DDLPKGPROC_INCLUDE} ${ENGINE_DBCON_DDLPKG_INCLUDE} ${ENGINE_DBCON_EXECPLAN_INCLUDE} ${ENGINE_UTILS_STARTUP_INCLUDE} ${ENGINE_DBCON_JOBLIST_INCLUDE} ${ENGINE_WE_WRAPPER_INCLUDE} ${ENGINE_WE_SERVER_INCLUDE} ${ENGINE_DBCON_DMLPKG_INCLUDE} ${ENGINE_WE_CLIENT_INCLUDE} ${ENGINE_DBCON_DMLPKGPROC_INCLUDE} ${ENGINE_UTILS_CACHEUTILS_INCLUDE} ${ENGINE_UTILS_MYSQLCL_INCLUDE} ${ENGINE_UTILS_QUERYTELE_INCLUDE} ${ENGINE_UTILS_THRIFT_INCLUDE} ${ENGINE_UTILS_JOINER_INCLUDE} ${ENGINE_UTILS_THREADPOOL_INCLUDE} ${ENGINE_UTILS_BATCHLDR_INCLUDE} ${ENGINE_UTILS_DDLCLEANUP_INCLUDE} ${ENGINE_UTILS_QUERYSTATS_INCLUDE} ${ENGINE_WE_CONFIGCPP_INCLUDE} ${ENGINE_SERVER_SQL_INCLUDE} ${ENGINE_SERVER_INCLUDE_INCLUDE} ${ENGINE_SERVER_PCRE_INCLUDE} ${ENGINE_SERVER_WSREP_API_INCLUDE} ${ENGINE_SERVER_WSREP_INCLUDE} ${ENGINE_UTILS_UDFSDK_INCLUDE} ${ENGINE_UTILS_LIBMYSQL_CL_INCLUDE}) ADD_SUBDIRECTORY(utils) ADD_SUBDIRECTORY(oam/oamcpp) diff --git a/dbcon/mysql/ha_calpont_ddl.cpp b/dbcon/mysql/ha_calpont_ddl.cpp index 833a0ab38..3c411e529 100644 --- a/dbcon/mysql/ha_calpont_ddl.cpp +++ b/dbcon/mysql/ha_calpont_ddl.cpp @@ -2307,7 +2307,7 @@ int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* bool isCreate = true; // relate to bug 1793. Make sure this is not for a select statement because - if (db == "calpontsys" && thd->infinidb_vtable.vtable_state == THD::INFINIDB_INIT + if (db == "calpontsys" && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT && tbl != "systable" && tbl != "syscolumn" && tbl != "sysindex" && tbl != "sysconstraint" && tbl != "sysindexcol" @@ -2337,7 +2337,7 @@ int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* return 0; } - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ALTER_VTABLE) //check if it is select + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ALTER_VTABLE) //check if it is select { return 0; } diff --git a/dbcon/mysql/ha_calpont_dml.cpp b/dbcon/mysql/ha_calpont_dml.cpp index 20462e2c8..5dcf087e5 100644 --- a/dbcon/mysql/ha_calpont_dml.cpp +++ b/dbcon/mysql/ha_calpont_dml.cpp @@ -2117,8 +2117,8 @@ int ha_calpont_impl_commit_ (handlerton* hton, THD* thd, bool all, cal_connectio { int rc = 0; - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ALTER_VTABLE || - thd->infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE ) + if (MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_ALTER_VTABLE || + MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE ) return rc; if (thd->slave_thread && !ci.replicationEnabled) diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index c8b6aa058..f7940bc17 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -1304,8 +1304,8 @@ uint32_t buildOuterJoin(gp_walk_info& gwi, SELECT_LEX& select_lex) { if (gwi.thd->derived_tables_processing) { - gwi.thd->infinidb_vtable.isUnion = false; - gwi.thd->infinidb_vtable.isUpdateWithDerive = true; + MIGR::infinidb_vtable.isUnion = false; + MIGR::infinidb_vtable.isUpdateWithDerive = true; return -1; } } @@ -2628,8 +2628,8 @@ void setError(THD* thd, uint32_t errcode, string errmsg) } thd->raise_error_printf(errcode, errmsg.c_str()); - thd->infinidb_vtable.isNewQuery = true; - thd->infinidb_vtable.override_largeside_estimate = false; + MIGR::infinidb_vtable.isNewQuery = true; + MIGR::infinidb_vtable.override_largeside_estimate = false; // reset expressionID if (get_fe_conn_info_ptr() == NULL) @@ -5556,7 +5556,7 @@ void gp_walk(const Item* item, void* arg) gwip->hasSubSelect = true; gwip->subQuery = existsSub; gwip->ptWorkStack.push(existsSub->transform()); - current_thd->infinidb_vtable.isUnion = true; // only temp. bypass the 2nd phase. + current_MIGR::infinidb_vtable.isUnion = true; // only temp. bypass the 2nd phase. // recover original gwip->subQuery = orig; gwip->lastSub = existsSub; @@ -5913,7 +5913,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) ) && gwi.thd->derived_tables_processing) { - gwi.thd->infinidb_vtable.isUnion = false; + MIGR::infinidb_vtable.isUnion = false; return -1; } @@ -5961,7 +5961,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // @bug 2123. Override large table estimate if infinidb_ordered hint was used. // @bug 2404. Always override if the infinidb_ordered_only variable is turned on. - if (gwi.thd->infinidb_vtable.override_largeside_estimate || get_ordered_only(gwi.thd)) + if (MIGR::infinidb_vtable.override_largeside_estimate || get_ordered_only(gwi.thd)) csep->overrideLargeSideEstimate(true); // @bug 5741. Set a flag when in Local PM only query mode @@ -6047,7 +6047,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, gwi.tbList.push_back(tn); CalpontSystemCatalog::TableAliasName tan = make_aliastable("", alias, alias); gwi.tableMap[tan] = make_pair(0, table_ptr); - gwi.thd->infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init + MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init } else if (table_ptr->view) { @@ -6118,7 +6118,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // is_unit_op() give a segv for derived_handler's SELECT_LEX if (!isUnion && select_lex.master_unit()->is_unit_op()) { - gwi.thd->infinidb_vtable.isUnion = true; + MIGR::infinidb_vtable.isUnion = true; CalpontSelectExecutionPlan::SelectList unionVec; SELECT_LEX* select_cursor = select_lex.master_unit()->first_select(); unionSel = true; @@ -6177,7 +6177,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, csep->distinctUnionNum(distUnionNum); if (unionVec.empty()) - gwi.thd->infinidb_vtable.impossibleWhereOnUnion = true; + MIGR::infinidb_vtable.impossibleWhereOnUnion = true; } gwi.clauseType = WHERE; @@ -6210,8 +6210,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // processing. if (gwi.thd->derived_tables_processing) { - gwi.thd->infinidb_vtable.isUnion = false; - gwi.thd->infinidb_vtable.isUpdateWithDerive = true; + MIGR::infinidb_vtable.isUnion = false; + MIGR::infinidb_vtable.isUpdateWithDerive = true; return -1; } @@ -7068,7 +7068,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SRCP minSc; // min width projected column. for count(*) use // Group by list. not valid for union main query - if (gwi.thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && !unionSel) + if (MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && !unionSel) { gwi.clauseType = GROUP_BY; Item* nonSupportItem = NULL; @@ -7345,14 +7345,14 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, } } - if (gwi.thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) { SQL_I_List order_list = select_lex.order_list; ORDER* ordercol = reinterpret_cast(order_list.first); - string create_query(gwi.thd->infinidb_vtable.create_vtable_query.c_ptr()); - string select_query(gwi.thd->infinidb_vtable.select_vtable_query.c_ptr()); - string lower_create_query(gwi.thd->infinidb_vtable.create_vtable_query.c_ptr()); - string lower_select_query(gwi.thd->infinidb_vtable.select_vtable_query.c_ptr()); + string create_query(MIGR::infinidb_vtable.create_vtable_query.c_ptr()); + string select_query(MIGR::infinidb_vtable.select_vtable_query.c_ptr()); + string lower_create_query(MIGR::infinidb_vtable.create_vtable_query.c_ptr()); + string lower_select_query(MIGR::infinidb_vtable.select_vtable_query.c_ptr()); boost::algorithm::to_lower(lower_create_query); boost::algorithm::to_lower(lower_select_query); @@ -7923,9 +7923,9 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, } - gwi.thd->infinidb_vtable.create_vtable_query.free(); - gwi.thd->infinidb_vtable.create_vtable_query.append(create_query.c_str(), create_query.length()); - gwi.thd->infinidb_vtable.vtable_state = THD::INFINIDB_REDO_PHASE1; // redo phase 1 + MIGR::infinidb_vtable.create_vtable_query.free(); + MIGR::infinidb_vtable.create_vtable_query.append(create_query.c_str(), create_query.length()); + MIGR::infinidb_vtable.vtable_state = THD::INFINIDB_REDO_PHASE1; // redo phase 1 // turn off select distinct from post process unless there're post process functions // on the select list. @@ -8090,7 +8090,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, if (ord_cols.length() > 0) // has order by { - gwi.thd->infinidb_vtable.has_order_by = true; + MIGR::infinidb_vtable.has_order_by = true; csep->hasOrderBy(true); // To activate LimitedOrderBy if(isPushdownHand) @@ -8196,7 +8196,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // do not set in csep. @bug5096. ignore session limit setting for dml if ((gwi.thd->variables.select_limit == (uint64_t) - 1 || (gwi.thd->variables.select_limit != (uint64_t) - 1 && - gwi.thd->infinidb_vtable.vtable_state != THD::INFINIDB_CREATE_VTABLE)) && + MIGR::infinidb_vtable.vtable_state != THD::INFINIDB_CREATE_VTABLE)) && !csep->hasOrderBy()) { csep->limitStart(limitOffset); @@ -8222,8 +8222,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, csep->limitNum((uint64_t) - 2); } - gwi.thd->infinidb_vtable.select_vtable_query.free(); - gwi.thd->infinidb_vtable.select_vtable_query.append(select_query.c_str(), select_query.length()); + MIGR::infinidb_vtable.select_vtable_query.free(); + MIGR::infinidb_vtable.select_vtable_query.append(select_query.c_str(), select_query.length()); // We don't currently support limit with correlated subquery if (csep->limitNum() != (uint64_t) - 1 && @@ -8319,7 +8319,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, csep->derivedTableList(gwi.derivedTbList); csep->selectSubList(selectSubList); csep->subSelectList(gwi.subselectList); - gwi.thd->infinidb_vtable.duplicate_field_name = false; + MIGR::infinidb_vtable.duplicate_field_name = false; clearStacks(gwi); return 0; } @@ -8603,7 +8603,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // @bug 2123. Override large table estimate if infinidb_ordered hint was used. // @bug 2404. Always override if the infinidb_ordered_only variable is turned on. - if (gwi.thd->infinidb_vtable.override_largeside_estimate || get_ordered_only(gwi.thd)) + if (MIGR::infinidb_vtable.override_largeside_estimate || get_ordered_only(gwi.thd)) csep->overrideLargeSideEstimate(true); // @bug 5741. Set a flag when in Local PM only query mode @@ -8689,7 +8689,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro gwi.tbList.push_back(tn); CalpontSystemCatalog::TableAliasName tan = make_aliastable("", alias, alias); gwi.tableMap[tan] = make_pair(0, table_ptr); -// gwi.thd->infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init +// MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init } else if (table_ptr->view) { @@ -8786,8 +8786,8 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // processing. if (gwi.thd->derived_tables_processing) { - gwi.thd->infinidb_vtable.isUnion = false; - gwi.thd->infinidb_vtable.isUpdateWithDerive = true; + MIGR::infinidb_vtable.isUnion = false; + MIGR::infinidb_vtable.isUpdateWithDerive = true; return -1; } @@ -9606,7 +9606,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro SRCP minSc; // min width projected column. for count(*) use // Group by list. not valid for union main query - if (gwi.thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && !unionSel) + if (MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && !unionSel) { gwi.clauseType = GROUP_BY; Item* nonSupportItem = NULL; @@ -9885,13 +9885,13 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // ORDER BY processing starts here - if (gwi.thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) { ORDER* ordercol = reinterpret_cast(gi.groupByOrder); - string create_query(gwi.thd->infinidb_vtable.create_vtable_query.c_ptr()); - string select_query(gwi.thd->infinidb_vtable.select_vtable_query.c_ptr()); - string lower_create_query(gwi.thd->infinidb_vtable.create_vtable_query.c_ptr()); - string lower_select_query(gwi.thd->infinidb_vtable.select_vtable_query.c_ptr()); + string create_query(MIGR::infinidb_vtable.create_vtable_query.c_ptr()); + string select_query(MIGR::infinidb_vtable.select_vtable_query.c_ptr()); + string lower_create_query(MIGR::infinidb_vtable.create_vtable_query.c_ptr()); + string lower_select_query(MIGR::infinidb_vtable.select_vtable_query.c_ptr()); boost::algorithm::to_lower(lower_create_query); boost::algorithm::to_lower(lower_select_query); @@ -10219,9 +10219,9 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro } - gwi.thd->infinidb_vtable.create_vtable_query.free(); - gwi.thd->infinidb_vtable.create_vtable_query.append(create_query.c_str(), create_query.length()); - gwi.thd->infinidb_vtable.vtable_state = THD::INFINIDB_REDO_PHASE1; // redo phase 1 + MIGR::infinidb_vtable.create_vtable_query.free(); + MIGR::infinidb_vtable.create_vtable_query.append(create_query.c_str(), create_query.length()); + MIGR::infinidb_vtable.vtable_state = THD::INFINIDB_REDO_PHASE1; // redo phase 1 // turn off select distinct from post process unless there're post process functions // on the select list. @@ -10391,7 +10391,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro if ( gwi.orderByCols.size() ) // has order by { - gwi.thd->infinidb_vtable.has_order_by = true; + MIGR::infinidb_vtable.has_order_by = true; csep->hasOrderBy(true); csep->specHandlerProcessed(true); } @@ -10418,8 +10418,9 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro csep->limitStart(((Item_int*)gi.groupByTables->select_lex->offset_limit)->val_int()); } - //gwi.thd->infinidb_vtable.select_vtable_query.free(); - //gwi.thd->infinidb_vtable.select_vtable_query.append(select_query.c_str(), select_query.length()); + // WIP MCOL-2178 + //MIGR::infinidb_vtable.select_vtable_query.free(); + //MIGR::infinidb_vtable.select_vtable_query.append(select_query.c_str(), select_query.length()); // We don't currently support limit with correlated subquery if (csep->limitNum() != (uint64_t) - 1 && @@ -10516,7 +10517,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro csep->derivedTableList(gwi.derivedTbList); csep->selectSubList(selectSubList); csep->subSelectList(gwi.subselectList); - gwi.thd->infinidb_vtable.duplicate_field_name = false; + MIGR::infinidb_vtable.duplicate_field_name = false; clearStacks(gwi); return 0; } diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 3c53c518a..6790664a7 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -169,8 +169,6 @@ static const string interval_names[] = const unsigned NONSUPPORTED_ERR_THRESH = 2000; -//TODO: make this session-safe (put in connMap?) -//vector rmParms; ResourceManager* rm = ResourceManager::instance(); bool useHdfs = rm->useHdfs(); @@ -273,8 +271,8 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType& // @bug4388 stick to InfiniDB's scale in case mysql gives wrong scale due // to create vtable limitation. - if (f2->dec < ct.scale) - f2->dec = ct.scale; + //if (f2->dec < ct.scale) + // f2->dec = ct.scale; char buf[256]; dataconvert::DataConvert::decimalToString(value, (unsigned)ct.scale, buf, 256, ct.colDataType); @@ -755,7 +753,8 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h //float float_val = *(float*)(&value); //f2->store(float_val); if (f2->decimals() < (uint32_t)row.getScale(s)) - f2->dec = (uint32_t)row.getScale(s); + // WIP MCOL-2178 + //f2->dec = (uint32_t)row.getScale(s); f2->store(dl); @@ -784,11 +783,15 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h //double double_val = *(double*)(&value); //f2->store(double_val); + + + // WIP MCOL-2178 + /* if ((f2->decimals() == DECIMAL_NOT_SPECIFIED && row.getScale(s) > 0) || f2->decimals() < row.getScale(s)) { f2->dec = row.getScale(s); - } + }*/ f2->store(dl); @@ -1235,7 +1238,7 @@ uint32_t doUpdateDelete(THD* thd) //@Bug 4387. Check BRM status before start statement. boost::scoped_ptr dbrmp(new DBRM()); int rc = dbrmp->isReadWrite(); - thd->infinidb_vtable.isInfiniDBDML = true; + MIGR::infinidb_vtable.isInfiniDBDML = true; if (rc != 0 ) { @@ -1335,8 +1338,8 @@ uint32_t doUpdateDelete(THD* thd) { ColumnAssignment* columnAssignmentPtr; Item_field* item; -// TABLE_LIST* table_ptr = thd->lex->select_lex.get_table_list(); - List_iterator_fast field_it(thd->lex->select_lex.item_list); +// TABLE_LIST* table_ptr = thd->lex->thd->lex->first_select_lex()->get_table_list(); + List_iterator_fast field_it(thd->lex->thd->lex->first_select_lex()->item_list); List_iterator_fast value_it(thd->lex->value_list); // dmlStmt += "update "; updateCP->queryType(CalpontSelectExecutionPlan::UPDATE); @@ -1587,7 +1590,7 @@ uint32_t doUpdateDelete(THD* thd) } colAssignmentListPtr->push_back ( columnAssignmentPtr ); -// if (cnt < thd->lex->select_lex.item_list.elements) +// if (cnt < thd->lex->thd->lex->first_select_lex()->item_list.elements) // dmlStmt += ", "; } @@ -1636,7 +1639,7 @@ uint32_t doUpdateDelete(THD* thd) } else { - first_table = (TABLE_LIST*) thd->lex->select_lex.table_list.first; + first_table = (TABLE_LIST*) thd->lex->thd->lex->first_select_lex()->table_list.first; aTableName.schema = first_table->table->s->db.str; aTableName.table = first_table->table->s->table_name.str; } @@ -1687,9 +1690,9 @@ uint32_t doUpdateDelete(THD* thd) } else if ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) //@Bug 6121 error out on multi tables delete. { - if ( (thd->lex->select_lex.join) != 0) + if ( (thd->lex->thd->lex->first_select_lex()->join) != 0) { - multi_delete* deleteTable = (multi_delete*)((thd->lex->select_lex.join)->result); + multi_delete* deleteTable = (multi_delete*)((thd->lex->thd->lex->first_select_lex()->join)->result); first_table = (TABLE_LIST*) deleteTable->get_tables(); if (deleteTable->get_num_of_tables() == 1) @@ -1712,7 +1715,7 @@ uint32_t doUpdateDelete(THD* thd) } else { - first_table = (TABLE_LIST*) thd->lex->select_lex.table_list.first; + first_table = (TABLE_LIST*) thd->lex->thd->lex->first_select_lex()->table_list.first; schemaName = first_table->table->s->db.str; tableName = first_table->table->s->table_name.str; aliasName = first_table->alias.str; @@ -1723,7 +1726,7 @@ uint32_t doUpdateDelete(THD* thd) } else { - first_table = (TABLE_LIST*) thd->lex->select_lex.table_list.first; + first_table = (TABLE_LIST*) thd->lex->thd->lex->first_select_lex()->table_list.first; schemaName = first_table->table->s->db.str; tableName = first_table->table->s->table_name.str; aliasName = first_table->alias.str; @@ -1756,16 +1759,16 @@ uint32_t doUpdateDelete(THD* thd) if (( (thd->lex)->sql_command == SQLCOM_UPDATE ) || ( (thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) ) { - items = (thd->lex->select_lex.item_list); - thd->lex->select_lex.item_list = thd->lex->value_list; + items = (thd->lex->thd->lex->first_select_lex()->item_list); + thd->lex->thd->lex->first_select_lex()->item_list = thd->lex->value_list; } - select_lex = lex->select_lex; + select_lex = *lex->first_select_lex(); //@Bug 2808 Error out on order by or limit clause //@bug5096. support dml limit. - if (/*( select_lex.explicit_limit ) || */( select_lex.order_list.elements != 0 ) ) + if (/*( thd->lex->first_select_lex()->explicit_limit ) || */( thd->lex->first_select_lex()->order_list.elements != 0 ) ) { string emsg("DML Statement with order by clause is not currently supported."); thd->raise_error_printf(ER_INTERNAL_ERROR, emsg.c_str()); @@ -1774,12 +1777,12 @@ uint32_t doUpdateDelete(THD* thd) return 0; } - //thd->infinidb_vtable.isInfiniDBDML = true; - THD::infinidb_state origState = thd->infinidb_vtable.vtable_state; + //MIGR::infinidb_vtable.isInfiniDBDML = true; + MIGR::infinidb_state origState = MIGR::infinidb_vtable.vtable_state; //if (( (thd->lex)->sql_command == SQLCOM_UPDATE ) || ( (thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) ) { gp_walk_info gwi; - thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE; gwi.thd = thd; //updateCP->subType (CalpontSelectExecutionPlan::SINGLEROW_SUBS); //set scalar updateCP->subType (CalpontSelectExecutionPlan::SELECT_SUBS); @@ -1816,13 +1819,13 @@ uint32_t doUpdateDelete(THD* thd) if (getSelectPlan(gwi, select_lex, updateCP) != 0) //@Bug 3030 Modify the error message for unsupported functions { - if (thd->infinidb_vtable.isUpdateWithDerive) + if (MIGR::infinidb_vtable.isUpdateWithDerive) { // @bug 4457. MySQL inconsistence! for some queries, some structures are only available // in the derived_tables_processing phase. So by pass the phase for DML only when the // execution plan can not be successfully generated. recover lex before returning; - thd->lex->select_lex.item_list = items; - thd->infinidb_vtable.vtable_state = origState; + thd->lex->thd->lex->first_select_lex()->item_list = items; + MIGR::infinidb_vtable.vtable_state = origState; return 0; } @@ -1972,7 +1975,7 @@ uint32_t doUpdateDelete(THD* thd) //cout<< "Plan is " << endl << *updateCP << endl; if (( (thd->lex)->sql_command == SQLCOM_UPDATE ) || ( (thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) ) - thd->lex->select_lex.item_list = items; + thd->lex->thd->lex->first_select_lex()->item_list = items; } //cout<< "Plan is " << endl << *updateCP << endl; @@ -1989,7 +1992,7 @@ uint32_t doUpdateDelete(THD* thd) updateCP->rmParms(ci->rmParms); updateCP->serialize(*plan); // recover original vtable state - thd->infinidb_vtable.vtable_state = origState; + MIGR::infinidb_vtable.vtable_state = origState; //cout << "plan has bytes " << plan->length() << endl; pDMLPackage->write(bytestream); @@ -2368,20 +2371,20 @@ int ha_calpont_impl_rnd_init(TABLE* table) { // Still not ready setError(thd, ER_INTERNAL_ERROR, "The system is not yet ready to accept queries"); - thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } else if (bSystemQueryReady < 0) { // Still not ready setError(thd, ER_INTERNAL_ERROR, "DBRM is not responding. Cannot accept queries"); - thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } #endif // prevent "create table as select" from running on slave - thd->infinidb_vtable.hasInfiniDBTable = true; + MIGR::infinidb_vtable.hasInfiniDBTable = true; cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -2398,30 +2401,30 @@ int ha_calpont_impl_rnd_init(TABLE* table) // @bug 3005. if the table is not $vtable, then this could be a UDF defined on the connector. // watch this for other complications - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE && + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE && string(table->s->table_name.str).find("$vtable") != 0) return 0; // return error is error status is already set - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ERROR) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR) return ER_INTERNAL_ERROR; // by pass the extra union trips. return 0 - if (thd->infinidb_vtable.isUnion && thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) + if (MIGR::infinidb_vtable.isUnion && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) return 0; // @bug 2232. Basic SP support. Error out non support sp cases. // @bug 3939. Only error out for sp with select. Let pass for alter table in sp. - if (thd->infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) + if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_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; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } // mysql reads table twice for order by - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_REDO_PHASE1 || - thd->infinidb_vtable.vtable_state == THD::INFINIDB_ORDER_BY) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_PHASE1 || + MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ORDER_BY) return 0; if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE ) @@ -2442,8 +2445,8 @@ int ha_calpont_impl_rnd_init(TABLE* table) // MySQL sometimes calls rnd_init multiple times, plan should only be // generated and sent once. - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && - !thd->infinidb_vtable.isNewQuery) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE && + !MIGR::infinidb_vtable.isNewQuery) return 0; if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD) @@ -2459,11 +2462,11 @@ int ha_calpont_impl_rnd_init(TABLE* table) // update traceFlags according to the autoswitch state. replication query // on slave are in table mode (create table as...) - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE || - (thd->slave_thread && thd->infinidb_vtable.vtable_state == THD::INFINIDB_INIT)) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE || + (thd->slave_thread && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT)) { ci->traceFlags |= CalpontSelectExecutionPlan::TRACE_TUPLE_OFF; - thd->infinidb_vtable.vtable_state = THD::INFINIDB_DISABLE_VTABLE; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_DISABLE_VTABLE; } else { @@ -2474,7 +2477,7 @@ int ha_calpont_impl_rnd_init(TABLE* table) bool localQuery = get_local_query(thd); // table mode - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) { ti = ci->tableMap[table]; @@ -2544,8 +2547,8 @@ int ha_calpont_impl_rnd_init(TABLE* table) // vtable mode else { - //if (!ci->cal_conn_hndl || thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) - if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) + //if (!ci->cal_conn_hndl || MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) + if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) { ci->stats.reset(); // reset query stats ci->stats.setStartTime(); @@ -2601,7 +2604,7 @@ int ha_calpont_impl_rnd_init(TABLE* table) hndl = ci->cal_conn_hndl; - if (thd->infinidb_vtable.vtable_state != THD::INFINIDB_SELECT_VTABLE) + if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_SELECT_VTABLE) { //CalpontSelectExecutionPlan csep; if (!csep) @@ -2629,7 +2632,7 @@ int ha_calpont_impl_rnd_init(TABLE* table) csep->traceFlags(ci->traceFlags); - if (thd->infinidb_vtable.isInsertSelect) + if (MIGR::infinidb_vtable.isInsertSelect) csep->queryType(CalpontSelectExecutionPlan::INSERT_SELECT); //get plan @@ -2642,12 +2645,12 @@ int ha_calpont_impl_rnd_init(TABLE* table) return 0; // @bug 2547. don't need to send the plan if it's impossible where for all unions. - if (thd->infinidb_vtable.impossibleWhereOnUnion) + if (MIGR::infinidb_vtable.impossibleWhereOnUnion) return 0; string query; - query.assign(thd->infinidb_vtable.original_query.ptr(), - thd->infinidb_vtable.original_query.length()); + query.assign(MIGR::infinidb_vtable.original_query.ptr(), + MIGR::infinidb_vtable.original_query.length()); csep->data(query); try @@ -2686,7 +2689,7 @@ int ha_calpont_impl_rnd_init(TABLE* table) } }// end of execution plan generation - if (thd->infinidb_vtable.vtable_state != THD::INFINIDB_SELECT_VTABLE) + if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_SELECT_VTABLE) { ByteStream msg; ByteStream emsgBs; @@ -2761,7 +2764,7 @@ int ha_calpont_impl_rnd_init(TABLE* table) ci->rmParms.clear(); - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) { ci->tableMap[table] = ti; } @@ -2781,7 +2784,7 @@ int ha_calpont_impl_rnd_init(TABLE* table) idbassert(hndl != 0); hndl->csc = csc; - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) ti.conn_hndl = hndl; else ci->cal_conn_hndl = hndl; @@ -2805,15 +2808,15 @@ int ha_calpont_impl_rnd_init(TABLE* table) // set query state to be in_process. Sometimes mysql calls rnd_init multiple // times, this makes sure plan only being generated and sent once. It will be // reset when query finishes in sm::end_query - thd->infinidb_vtable.isNewQuery = false; + MIGR::infinidb_vtable.isNewQuery = false; // common path for both vtable select phase and table mode -- open scan handle ti = ci->tableMap[table]; ti.msTablePtr = table; - if ((thd->infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE) || - (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) || - (thd->infinidb_vtable.vtable_state == THD::INFINIDB_REDO_QUERY)) + if ((MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE) || + (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) || + (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_QUERY)) { if (ti.tpl_ctx == 0) { @@ -2870,7 +2873,7 @@ int ha_calpont_impl_rnd_init(TABLE* table) } // populate coltypes here for table mode because tableband gives treeoid for dictionary column - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) { CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str), true); @@ -2934,11 +2937,11 @@ int ha_calpont_impl_rnd_next(uchar* buf, TABLE* table) thd->lex->sql_command == SQLCOM_LOAD)) return 0; - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ERROR) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR) return ER_INTERNAL_ERROR; // @bug 3005 - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE && + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE && string(table->s->table_name.str).find("$vtable") != 0) return HA_ERR_END_OF_FILE; @@ -2947,15 +2950,15 @@ int ha_calpont_impl_rnd_next(uchar* buf, TABLE* table) return HA_ERR_END_OF_FILE; // @bug 2547 - if (thd->infinidb_vtable.impossibleWhereOnUnion) + if (MIGR::infinidb_vtable.impossibleWhereOnUnion) return HA_ERR_END_OF_FILE; // @bug 2232. Basic SP support // @bug 3939. Only error out for sp with select. Let pass for alter table in sp. - if (thd->infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) + if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_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; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } @@ -3027,8 +3030,8 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) cal_connection_info* ci = NULL; bool replicationEnabled = false; - if (thd->infinidb_vtable.cal_conn_info) - ci = reinterpret_cast(thd->infinidb_vtable.cal_conn_info); + if (get_fe_conn_info_ptr() != NULL) + ci = reinterpret_cast(get_fe_conn_info_ptr()); if (ci && ci->replicationEnabled) { @@ -3046,23 +3049,23 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) thd->lex->sql_command == SQLCOM_LOAD)) return 0; - thd->infinidb_vtable.isNewQuery = true; + MIGR::infinidb_vtable.isNewQuery = true; // Workaround because CS doesn't reset isUnion in a normal way. if (is_pushdown_hand) { - thd->infinidb_vtable.isUnion = false; + MIGR::infinidb_vtable.isUnion = false; } if (get_fe_conn_info_ptr() != NULL) ci = reinterpret_cast(get_fe_conn_info_ptr()); - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ORDER_BY ) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ORDER_BY ) { - thd->infinidb_vtable.vtable_state = THD::INFINIDB_SELECT_VTABLE; // flip back to normal state + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_SELECT_VTABLE; // flip back to normal state return rc; } -// if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_REDO_PHASE1) +// if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_PHASE1) // return rc; if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE ) @@ -3103,7 +3106,7 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) cal_table_info ti = ci->tableMap[table]; sm::cpsm_conhdl_t* hndl; - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) hndl = ti.conn_hndl; else hndl = ci->cal_conn_hndl; @@ -3129,7 +3132,7 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) sm::tpl_close(ti.tpl_ctx, &hndl, ci->stats); // set conn hndl back. could be changed in tpl_close - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) ti.conn_hndl = hndl; else ci->cal_conn_hndl = hndl; @@ -3163,9 +3166,9 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) ti.tpl_ctx = 0; - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE && - thd->infinidb_vtable.has_order_by) - thd->infinidb_vtable.vtable_state = THD::INFINIDB_ORDER_BY; + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE && + MIGR::infinidb_vtable.has_order_by) + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ORDER_BY; ci->tableMap[table] = ti; @@ -3190,7 +3193,7 @@ int ha_calpont_impl_create(const char* name, TABLE* table_arg, HA_CREATE_INFO* c cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); // @bug1940 Do nothing for select query. Support of set default engine to IDB. - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE || + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE || string(name).find("@0024vtable") != string::npos) return 0; @@ -3250,7 +3253,7 @@ int ha_calpont_impl_delete_table(const char* name) } else { - TABLE_LIST* first_table = (TABLE_LIST*) thd->lex->select_lex.table_list.first; + TABLE_LIST* first_table = (TABLE_LIST*) thd->lex->thd->lex->first_select_lex()->table_list.first; dbName = const_cast(first_table->db.str); } @@ -3391,14 +3394,14 @@ void ha_calpont_impl_start_bulk_insert(ha_rows rows, TABLE* table) if (ci->alterTableState > 0) return; - if (thd->infinidb_vtable.vtable_state != THD::INFINIDB_ALTER_VTABLE) - thd->infinidb_vtable.isInfiniDBDML = true; + if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_ALTER_VTABLE) + MIGR::infinidb_vtable.isInfiniDBDML = true; if (thd->slave_thread && !ci->replicationEnabled) return; //@bug 5660. Error out DDL/DML on slave node, or on local query node - if (ci->isSlaveNode && thd->infinidb_vtable.vtable_state != THD::INFINIDB_ALTER_VTABLE) + if (ci->isSlaveNode && MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_ALTER_VTABLE) { string emsg = logging::IDBErrorInfo::instance()->errorMsg(ERR_DML_DDL_SLAVE); setError(current_thd, ER_CHECK_NOT_IMPLEMENTED, emsg); @@ -4166,10 +4169,10 @@ int ha_calpont_impl_end_bulk_insert(bool abort, TABLE* table) int ha_calpont_impl_commit (handlerton* hton, THD* thd, bool all) { - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE || - thd->infinidb_vtable.vtable_state == THD::INFINIDB_ALTER_VTABLE || - thd->infinidb_vtable.vtable_state == THD::INFINIDB_DROP_VTABLE || - thd->infinidb_vtable.vtable_state == THD::INFINIDB_REDO_PHASE1) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE || + MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ALTER_VTABLE || + MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DROP_VTABLE || + MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_PHASE1) return 0; if (get_fe_conn_info_ptr() == NULL) @@ -4297,7 +4300,7 @@ int ha_calpont_impl_rename_table(const char* from, const char* to) IDEBUG( cout << "ha_calpont_impl_rename_table: was in state ALTER_SECOND_RENAME, now in NOT_ALTER" << endl ); return 0; } - else if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_ALTER_VTABLE ) + else if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ALTER_VTABLE ) return 0; int rc = ha_calpont_impl_rename_table_(from, to, *ci); @@ -4314,10 +4317,10 @@ COND* ha_calpont_impl_cond_push(COND* cond, TABLE* table) { THD* thd = current_thd; - if (thd->slave_thread && thd->infinidb_vtable.vtable_state == THD::INFINIDB_INIT) - thd->infinidb_vtable.vtable_state = THD::INFINIDB_DISABLE_VTABLE; + if (thd->slave_thread && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT) + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_DISABLE_VTABLE; - if (thd->infinidb_vtable.vtable_state != THD::INFINIDB_DISABLE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_DISABLE_VTABLE) return cond; if (((thd->lex)->sql_command == SQLCOM_UPDATE) || @@ -4404,11 +4407,11 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type) string alias; alias.assign(table->alias.ptr(), table->alias.length()); IDEBUG( cout << "external_lock for " << alias << endl ); - idbassert((thd->infinidb_vtable.vtable_state >= THD::INFINIDB_INIT_CONNECT && - thd->infinidb_vtable.vtable_state <= THD::INFINIDB_REDO_QUERY) || - thd->infinidb_vtable.vtable_state == THD::INFINIDB_ERROR); + idbassert((MIGR::infinidb_vtable.vtable_state >= MIGR::INFINIDB_INIT_CONNECT && + MIGR::infinidb_vtable.vtable_state <= MIGR::INFINIDB_REDO_QUERY) || + MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR); - if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_INIT ) + if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT ) return 0; if (get_fe_conn_info_ptr() == NULL) @@ -4432,7 +4435,7 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type) #endif { // table mode - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) { if (mapiter->second.conn_hndl) { @@ -4454,7 +4457,7 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type) // only push this warning for once if (ci->tableMap.size() == 1 && - thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE && thd->infinidb_vtable.autoswitch) + MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE && MIGR::infinidb_vtable.autoswitch) { push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, infinidb_autoswitch_warning.c_str()); } @@ -4462,7 +4465,7 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type) } else // vtable mode { - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE) { if (!ci->cal_conn_hndl) return 0; @@ -4474,7 +4477,7 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type) ci->extendedStats = ci->cal_conn_hndl->extendedStats; ci->miniStats = ci->cal_conn_hndl->miniStats; ci->queryState = 0; - thd->infinidb_vtable.override_largeside_estimate = false; + MIGR::infinidb_vtable.override_largeside_estimate = false; // MCOL-3247 Use THD::ha_data as a per-plugin per-session // storage for cal_conn_hndl to use it later in close_connection thd_set_ha_data(thd, calpont_hton, get_fe_conn_info_ptr()); @@ -4523,36 +4526,36 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE { // Still not ready setError(thd, ER_INTERNAL_ERROR, "The system is not yet ready to accept queries"); - thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } else if (bSystemQueryReady < 0) { // Still not ready setError(thd, ER_INTERNAL_ERROR, "DBRM is not responding. Cannot accept queries"); - thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } #endif // prevent "create table as select" from running on slave - thd->infinidb_vtable.hasInfiniDBTable = true; + MIGR::infinidb_vtable.hasInfiniDBTable = true; // return error if error status has been already set - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ERROR) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR) return ER_INTERNAL_ERROR; // MCOL-1052 // by pass the extra union trips. return 0 - //if (thd->infinidb_vtable.isUnion && thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) + //if (MIGR::infinidb_vtable.isUnion && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) // return 0; // @bug 2232. Basic SP support. Error out non support sp cases. // @bug 3939. Only error out for sp with select. Let pass for alter table in sp. - if (thd->infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) + if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_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; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } @@ -4570,8 +4573,8 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE // MySQL sometimes calls rnd_init multiple times, plan should only be // generated and sent once. - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE && - !thd->infinidb_vtable.isNewQuery) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE && + !MIGR::infinidb_vtable.isNewQuery) return 0; if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD) @@ -4713,7 +4716,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE return 0; // @bug 2547. don't need to send the plan if it's impossible where for all unions. - if (thd->infinidb_vtable.impossibleWhereOnUnion) + if (MIGR::infinidb_vtable.impossibleWhereOnUnion) return 0; string query; @@ -4834,7 +4837,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE ci->rmParms.clear(); - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) { ci->tableMap[table] = ti; } @@ -4855,7 +4858,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE hndl->csc = csc; // The next section is useless - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) ti.conn_hndl = hndl; else { @@ -4882,18 +4885,18 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE // set query state to be in_process. Sometimes mysql calls rnd_init multiple // times, this makes sure plan only being generated and sent once. It will be // reset when query finishes in sm::end_query - thd->infinidb_vtable.isNewQuery = false; + MIGR::infinidb_vtable.isNewQuery = false; // common path for both vtable select phase and table mode -- open scan handle ti = ci->tableMap[table]; ti.msTablePtr = table; // MCOL-1052 - thd->infinidb_vtable.vtable_state = THD::INFINIDB_SELECT_VTABLE; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_SELECT_VTABLE; - if ((thd->infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE) || - (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) || - (thd->infinidb_vtable.vtable_state == THD::INFINIDB_REDO_QUERY)) + if ((MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE) || + (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) || + (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_QUERY)) { // MCOL-1601 Using stacks of ExeMgr conn hndls, table and scan contexts. ti.tpl_ctx = new sm::cpsm_tplh_t(); @@ -4950,7 +4953,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE } // populate coltypes here for table mode because tableband gives treeoid for dictionary column - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) { CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str), true); @@ -5017,7 +5020,7 @@ int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE { THD* thd = current_thd; - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ERROR) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR) return ER_INTERNAL_ERROR; if (((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_DELETE) || @@ -5025,15 +5028,15 @@ int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE return HA_ERR_END_OF_FILE; // @bug 2547 - if (thd->infinidb_vtable.impossibleWhereOnUnion) + if (MIGR::infinidb_vtable.impossibleWhereOnUnion) return HA_ERR_END_OF_FILE; // @bug 2232. Basic SP support // @bug 3939. Only error out for sp with select. Let pass for alter table in sp. - /*if (thd->infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) + /*if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_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; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } */ @@ -5118,18 +5121,6 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE* THD* thd = current_thd; cal_connection_info* ci = NULL; - thd->infinidb_vtable.isNewQuery = true; - thd->infinidb_vtable.isUnion = false; - - if (get_fe_conn_info_ptr() != NULL) - ci = reinterpret_cast(get_fe_conn_info_ptr()); - - if (!ci) - { - thd->infinidb_vtable.cal_conn_info = (void*)(new cal_connection_info()); - ci = reinterpret_cast(thd->infinidb_vtable.cal_conn_info); - } - if (thd->slave_thread && !ci->replicationEnabled && ( thd->lex->sql_command == SQLCOM_INSERT || thd->lex->sql_command == SQLCOM_INSERT_SELECT || @@ -5141,7 +5132,13 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE* thd->lex->sql_command == SQLCOM_LOAD)) return 0; - if (((thd->lex)->sql_command == SQLCOM_INSERT) || + MIGR::infinidb_vtable.isNewQuery = true; + MIGR::infinidb_vtable.isUnion = false; + + if (get_fe_conn_info_ptr() != NULL) + ci = reinterpret_cast(get_fe_conn_info_ptr()); + + if (((thd->lex)->sql_command == SQLCOM_INSERT) || ((thd->lex)->sql_command == SQLCOM_INSERT_SELECT) ) { force_close_fep_conn(thd, ci, true); // with checking prev command rc @@ -5332,20 +5329,20 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) { // Still not ready setError(thd, ER_INTERNAL_ERROR, "The system is not yet ready to accept queries"); - thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } else if (bSystemQueryReady < 0) { // Still not ready setError(thd, ER_INTERNAL_ERROR, "DBRM is not responding. Cannot accept queries"); - thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } #endif // prevent "create table as select" from running on slave - thd->infinidb_vtable.hasInfiniDBTable = true; + MIGR::infinidb_vtable.hasInfiniDBTable = true; /* If this node is the slave, ignore DML to IDB tables */ if (thd->slave_thread && ( @@ -5360,21 +5357,21 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) return 0; // return error is error status is already set - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ERROR) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR) return ER_INTERNAL_ERROR; // @bug 2232. Basic SP support. Error out non support sp cases. // @bug 3939. Only error out for sp with select. Let pass for alter table in sp. - if (thd->infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) + if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_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; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } // mysql reads table twice for order by - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_REDO_PHASE1 || - thd->infinidb_vtable.vtable_state == THD::INFINIDB_ORDER_BY) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_PHASE1 || + MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ORDER_BY) return 0; if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE ) @@ -5388,17 +5385,17 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) boost::shared_ptr csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); csc->identity(CalpontSystemCatalog::FE); - if (!thd->infinidb_vtable.cal_conn_info) - thd->infinidb_vtable.cal_conn_info = (void*)(new cal_connection_info()); + if (!get_fe_conn_info_ptr()) + set_fe_conn_info_ptr(reinterpret_cast(new cal_connection_info(), thd)); - cal_connection_info* ci = reinterpret_cast(thd->infinidb_vtable.cal_conn_info); + cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); idbassert(ci != 0); // MySQL sometimes calls rnd_init multiple times, plan should only be // generated and sent once. - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && - !thd->infinidb_vtable.isNewQuery) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE && + !MIGR::infinidb_vtable.isNewQuery) return 0; if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD) @@ -5436,11 +5433,11 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) // update traceFlags according to the autoswitch state. replication query // on slave are in table mode (create table as...) - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE || - (thd->slave_thread && thd->infinidb_vtable.vtable_state == THD::INFINIDB_INIT)) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE || + (thd->slave_thread && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT)) { ci->traceFlags |= CalpontSelectExecutionPlan::TRACE_TUPLE_OFF; - thd->infinidb_vtable.vtable_state = THD::INFINIDB_DISABLE_VTABLE; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_DISABLE_VTABLE; } else { @@ -5448,11 +5445,11 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) CalpontSelectExecutionPlan::TRACE_TUPLE_OFF; } - bool localQuery = (thd->variables.infinidb_local_query > 0 ? true : false); + bool localQuery = (get_local_query(thd) > 0 ? true : false); { - //if (!ci->cal_conn_hndl || thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) - if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) + //if (!ci->cal_conn_hndl || MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) + if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) { ci->stats.reset(); // reset query stats ci->stats.setStartTime(); @@ -5501,7 +5498,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) hndl = ci->cal_conn_hndl; - if (thd->infinidb_vtable.vtable_state != THD::INFINIDB_SELECT_VTABLE) + if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_SELECT_VTABLE) { if (!csep) csep.reset(new CalpontSelectExecutionPlan()); @@ -5528,7 +5525,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) csep->traceFlags(ci->traceFlags); - if (thd->infinidb_vtable.isInsertSelect) + if (MIGR::infinidb_vtable.isInsertSelect) csep->queryType(CalpontSelectExecutionPlan::INSERT_SELECT); // cast the handler and get a plan. @@ -5552,13 +5549,13 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) return 0; // @bug 2547. don't need to send the plan if it's impossible where for all unions. - if (thd->infinidb_vtable.impossibleWhereOnUnion) + if (MIGR::infinidb_vtable.impossibleWhereOnUnion) return 0; string query; query.assign(idb_mysql_query_str(thd)); - //query.assign(thd->infinidb_vtable.original_query.ptr(), - // thd->infinidb_vtable.original_query.length()); + //query.assign(MIGR::infinidb_vtable.original_query.ptr(), + // MIGR::infinidb_vtable.original_query.length()); csep->data(query); try @@ -5595,7 +5592,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) } }// end of execution plan generation - if (thd->infinidb_vtable.vtable_state != THD::INFINIDB_SELECT_VTABLE) + if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_SELECT_VTABLE) { ByteStream msg; ByteStream emsgBs; @@ -5608,7 +5605,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) msg << qb; hndl->exeMgr->write(msg); msg.restart(); - csep->rmParms(rmParms); + csep->rmParms(ci->rmParms); //send plan csep->serialize(msg); @@ -5668,9 +5665,9 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) return ER_INTERNAL_ERROR; } - rmParms.clear(); + ci->rmParms.clear(); - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) { ci->tableMap[table] = ti; } @@ -5690,7 +5687,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) idbassert(hndl != 0); hndl->csc = csc; - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) ti.conn_hndl = hndl; else ci->cal_conn_hndl = hndl; @@ -5714,7 +5711,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) // set query state to be in_process. Sometimes mysql calls rnd_init multiple // times, this makes sure plan only being generated and sent once. It will be // reset when query finishes in sm::end_query - thd->infinidb_vtable.isNewQuery = false; + MIGR::infinidb_vtable.isNewQuery = false; // common path for both vtable select phase and table mode -- open scan handle ti = ci->tableMap[table]; @@ -5784,7 +5781,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) } // populate coltypes here for table mode because tableband gives treeoid for dictionary column - if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) { CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str), true); diff --git a/dbcon/mysql/ha_mcs_pushdown.cpp b/dbcon/mysql/ha_mcs_pushdown.cpp index bc4673a11..6b7f0ff89 100644 --- a/dbcon/mysql/ha_mcs_pushdown.cpp +++ b/dbcon/mysql/ha_mcs_pushdown.cpp @@ -129,9 +129,10 @@ create_calpont_group_by_handler(THD* thd, Query* query) SELECT_LEX *select_lex = query->from->select_lex; // Create a handler if query is valid. See comments for details. - if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE - && ( thd->variables.infinidb_vtable_mode == 0 - || thd->variables.infinidb_vtable_mode == 2 ) + if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE + // WIP MCOL-2178 + //&& ( MIGR::infinidb_vtable_mode == 0 + // || MIGR::infinidb_vtable_mode == 2 ) && ( query->group_by || select_lex->with_sum_func ) ) { bool unsupported_feature = false; @@ -213,8 +214,9 @@ create_columnstore_derived_handler(THD* thd, TABLE_LIST *derived) SELECT_LEX_UNIT *unit= derived->derived; - if ( thd->infinidb_vtable.vtable_state != THD::INFINIDB_DISABLE_VTABLE - && thd->variables.infinidb_vtable_mode != 0 ) + if ( MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_DISABLE_VTABLE ) +// WIP MCOL-2178 +// && MIGR::infinidb_vtable_mode != 0 ) { return 0; } @@ -305,14 +307,14 @@ int ha_columnstore_derived_handler::init_scan() derived->derived->print(&derived_query, QT_ORDINARY); // Save vtable_state to restore the after we inited. - THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; - thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; + MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE; mcs_handler_info mhi = mcs_handler_info(static_cast(this), DERIVED); // this::table is the place for the result set int rc = ha_cs_impl_pushdown_init(&mhi, table); - thd->infinidb_vtable.vtable_state = oldState; + MIGR::infinidb_vtable.vtable_state = oldState; DBUG_RETURN(rc); } @@ -334,13 +336,13 @@ int ha_columnstore_derived_handler::next_row() DBUG_ENTER("ha_columnstore_derived_handler::next_row"); // Save vtable_state to restore the after we inited. - THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; + MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state; - thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE; int rc = ha_calpont_impl_rnd_next(table->record[0], table); - thd->infinidb_vtable.vtable_state = oldState; + MIGR::infinidb_vtable.vtable_state = oldState; DBUG_RETURN(rc); } @@ -361,12 +363,12 @@ int ha_columnstore_derived_handler::end_scan() { DBUG_ENTER("ha_columnstore_derived_handler::end_scan"); - THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; - thd->infinidb_vtable.vtable_state = THD::INFINIDB_SELECT_VTABLE; + MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_SELECT_VTABLE; int rc = ha_calpont_impl_rnd_end(table, true); - thd->infinidb_vtable.vtable_state = oldState; + MIGR::infinidb_vtable.vtable_state = oldState; DBUG_RETURN(rc); } @@ -413,11 +415,11 @@ int ha_calpont_group_by_handler::init_scan() DBUG_ENTER("ha_calpont_group_by_handler::init_scan"); // Save vtable_state to restore the after we inited. - THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; + MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state; // MCOL-1052 Should be removed after cleaning the code up. - thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE; int rc = ha_calpont_impl_group_by_init(this, table); - thd->infinidb_vtable.vtable_state = oldState; + MIGR::infinidb_vtable.vtable_state = oldState; DBUG_RETURN(rc); } @@ -471,8 +473,9 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) handlerton *ht= 0; // Return if vtable enabled. - if ( thd->infinidb_vtable.vtable_state != THD::INFINIDB_DISABLE_VTABLE - && thd->variables.infinidb_vtable_mode != 0 ) + if ( MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_DISABLE_VTABLE ) +// WIP MCOL-2178 +// && MIGR::infinidb_vtable_mode != 0 ) { return 0; } @@ -591,14 +594,14 @@ int ha_columnstore_select_handler::init_scan() select->print(thd, &select_query, QT_ORDINARY); // Save vtable_state to restore the after we inited. - THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; - thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; + MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE; mcs_handler_info mhi = mcs_handler_info(static_cast(this), SELECT); // this::table is the place for the result set int rc = ha_cs_impl_pushdown_init(&mhi, table); - thd->infinidb_vtable.vtable_state = oldState; + MIGR::infinidb_vtable.vtable_state = oldState; DBUG_RETURN(rc); } @@ -620,13 +623,13 @@ int ha_columnstore_select_handler::next_row() DBUG_ENTER("ha_columnstore_select_handler::next_row"); // Save vtable_state to restore the after we inited. - THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; + MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state; - thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE; int rc = ha_calpont_impl_rnd_next(table->record[0], table); - thd->infinidb_vtable.vtable_state = oldState; + MIGR::infinidb_vtable.vtable_state = oldState; DBUG_RETURN(rc); } @@ -647,12 +650,12 @@ int ha_columnstore_select_handler::end_scan() { DBUG_ENTER("ha_columnstore_select_handler::end_scan"); - THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; - thd->infinidb_vtable.vtable_state = THD::INFINIDB_SELECT_VTABLE; + MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state; + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_SELECT_VTABLE; int rc = ha_calpont_impl_rnd_end(table, true); - thd->infinidb_vtable.vtable_state = oldState; + MIGR::infinidb_vtable.vtable_state = oldState; DBUG_RETURN(rc); } diff --git a/dbcon/mysql/ha_mcs_sysvars.cpp b/dbcon/mysql/ha_mcs_sysvars.cpp index ff6943fa4..dc022b8f2 100644 --- a/dbcon/mysql/ha_mcs_sysvars.cpp +++ b/dbcon/mysql/ha_mcs_sysvars.cpp @@ -296,225 +296,135 @@ mcs_compression_type_t get_compression_type(THD* thd) { bool get_use_decimal_scale(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? false : thd->variables.infinidb_use_decimal_scale; - else - return ( thd == NULL ) ? false : THDVAR(thd, use_decimal_scale); + return ( thd == NULL ) ? false : THDVAR(thd, use_decimal_scale); } void set_use_decimal_scale(THD* thd, bool value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_use_decimal_scale = value; - else - THDVAR(thd, use_decimal_scale) = value; + THDVAR(thd, use_decimal_scale) = value; } ulong get_decimal_scale(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? 0 : thd->variables.infinidb_decimal_scale; - else - return ( thd == NULL ) ? 0 : THDVAR(thd, decimal_scale); + return ( thd == NULL ) ? 0 : THDVAR(thd, decimal_scale); } void set_decimal_scale(THD* thd, ulong value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_decimal_scale = value; - else - THDVAR(thd, decimal_scale) = value; + THDVAR(thd, decimal_scale) = value; } bool get_ordered_only(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? false : thd->variables.infinidb_ordered_only; - else - return ( thd == NULL ) ? false : THDVAR(thd, ordered_only); + return ( thd == NULL ) ? false : THDVAR(thd, ordered_only); } void set_ordered_only(THD* thd, bool value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_ordered_only = value; - else - THDVAR(thd, ordered_only) = value; + THDVAR(thd, ordered_only) = value; } ulong get_string_scan_threshold(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? 0 : thd->variables.infinidb_string_scan_threshold; - else - return ( thd == NULL ) ? 0 : THDVAR(thd, string_scan_threshold); + return ( thd == NULL ) ? 0 : THDVAR(thd, string_scan_threshold); } void set_string_scan_threshold(THD* thd, ulong value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_string_scan_threshold = value; - else - THDVAR(thd, string_scan_threshold) = value; + THDVAR(thd, string_scan_threshold) = value; } ulong get_stringtable_threshold(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? 0 : thd->variables.infinidb_stringtable_threshold; - else - return ( thd == NULL ) ? 0 : THDVAR(thd, stringtable_threshold); + return ( thd == NULL ) ? 0 : THDVAR(thd, stringtable_threshold); } void set_stringtable_threshold(THD* thd, ulong value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_stringtable_threshold = value; - else - THDVAR(thd, stringtable_threshold) = value; + THDVAR(thd, stringtable_threshold) = value; } ulong get_diskjoin_smallsidelimit(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? 0 : thd->variables.infinidb_diskjoin_smallsidelimit; - else - return ( thd == NULL ) ? 0 : THDVAR(thd, diskjoin_smallsidelimit); + return ( thd == NULL ) ? 0 : THDVAR(thd, diskjoin_smallsidelimit); } void set_diskjoin_smallsidelimit(THD* thd, ulong value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_diskjoin_smallsidelimit = value; - else - THDVAR(thd, diskjoin_smallsidelimit) = value; + THDVAR(thd, diskjoin_smallsidelimit) = value; } ulong get_diskjoin_largesidelimit(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? 0 : thd->variables.infinidb_diskjoin_largesidelimit; - else - return ( thd == NULL ) ? 0 : THDVAR(thd, diskjoin_largesidelimit); + return ( thd == NULL ) ? 0 : THDVAR(thd, diskjoin_largesidelimit); } void set_diskjoin_largesidelimit(THD* thd, ulong value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_diskjoin_largesidelimit = value; - else - THDVAR(thd, diskjoin_largesidelimit) = value; + THDVAR(thd, diskjoin_largesidelimit) = value; } ulong get_diskjoin_bucketsize(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? 0 : thd->variables.infinidb_diskjoin_bucketsize; - else - return ( thd == NULL ) ? 0 : THDVAR(thd, diskjoin_bucketsize); + return ( thd == NULL ) ? 0 : THDVAR(thd, diskjoin_bucketsize); } void set_diskjoin_bucketsize(THD* thd, ulong value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_diskjoin_bucketsize = value; - else - THDVAR(thd, diskjoin_bucketsize) = value; + THDVAR(thd, diskjoin_bucketsize) = value; } ulong get_um_mem_limit(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? 0 : thd->variables.infinidb_um_mem_limit; - else - return ( thd == NULL ) ? 0 : THDVAR(thd, um_mem_limit); + return ( thd == NULL ) ? 0 : THDVAR(thd, um_mem_limit); } void set_um_mem_limit(THD* thd, ulong value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_um_mem_limit = value; - else - THDVAR(thd, um_mem_limit) = value; + THDVAR(thd, um_mem_limit) = value; } bool get_varbin_always_hex(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? false : thd->variables.infinidb_varbin_always_hex; - else - return ( thd == NULL ) ? false : THDVAR(thd, varbin_always_hex); + return ( thd == NULL ) ? false : THDVAR(thd, varbin_always_hex); } void set_varbin_always_hex(THD* thd, bool value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_varbin_always_hex = value; - else - THDVAR(thd, varbin_always_hex) = value; + THDVAR(thd, varbin_always_hex) = value; } bool get_double_for_decimal_math(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? false : thd->variables.infinidb_double_for_decimal_math; - else - return ( thd == NULL ) ? false : THDVAR(thd, double_for_decimal_math); + return ( thd == NULL ) ? false : THDVAR(thd, double_for_decimal_math); } void set_double_for_decimal_math(THD* thd, bool value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_double_for_decimal_math = value; - else - THDVAR(thd, double_for_decimal_math) = value; + THDVAR(thd, double_for_decimal_math) = value; } ulong get_local_query(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? 0 : thd->variables.infinidb_local_query; - else - return ( thd == NULL ) ? 0 : THDVAR(thd, local_query); + return ( thd == NULL ) ? 0 : THDVAR(thd, local_query); } void set_local_query(THD* thd, ulong value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_local_query = value; - else - THDVAR(thd, local_query) = value; + THDVAR(thd, local_query) = value; } bool get_use_import_for_batchinsert(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? false : thd->variables.infinidb_use_import_for_batchinsert; - else - return ( thd == NULL ) ? false : THDVAR(thd, use_import_for_batchinsert); + return ( thd == NULL ) ? false : THDVAR(thd, use_import_for_batchinsert); } void set_use_import_for_batchinsert(THD* thd, bool value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_use_import_for_batchinsert = value; - else - THDVAR(thd, use_import_for_batchinsert) = value; + THDVAR(thd, use_import_for_batchinsert) = value; } ulong get_import_for_batchinsert_delimiter(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? 0 : thd->variables.infinidb_import_for_batchinsert_delimiter; - else - return ( thd == NULL ) ? 0 : THDVAR(thd, import_for_batchinsert_delimiter); + return ( thd == NULL ) ? 0 : THDVAR(thd, import_for_batchinsert_delimiter); } void set_import_for_batchinsert_delimiter(THD* thd, ulong value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_import_for_batchinsert_delimiter = value; - else - THDVAR(thd, import_for_batchinsert_delimiter) = value; + THDVAR(thd, import_for_batchinsert_delimiter) = value; } ulong get_import_for_batchinsert_enclosed_by(THD* thd) { - if(get_use_legacy_sysvars(thd)) - return ( thd == NULL ) ? 0 : thd->variables.infinidb_import_for_batchinsert_enclosed_by; - else - return ( thd == NULL ) ? 0 : THDVAR(thd, import_for_batchinsert_enclosed_by); + return ( thd == NULL ) ? 0 : THDVAR(thd, import_for_batchinsert_enclosed_by); } void set_import_for_batchinsert_enclosed_by(THD* thd, ulong value) { - if(get_use_legacy_sysvars(thd)) - thd->variables.infinidb_import_for_batchinsert_enclosed_by = value; - else - THDVAR(thd, import_for_batchinsert_enclosed_by) = value; + THDVAR(thd, import_for_batchinsert_enclosed_by) = value; } diff --git a/dbcon/mysql/ha_view.cpp b/dbcon/mysql/ha_view.cpp index 3bc49b2a8..761608d0e 100644 --- a/dbcon/mysql/ha_view.cpp +++ b/dbcon/mysql/ha_view.cpp @@ -102,7 +102,7 @@ void View::transform() CalpontSystemCatalog::TableAliasName tn = make_aliasview("", "", alias, viewName); gwi.tbList.push_back(tn); gwi.tableMap[tn] = make_pair(0, table_ptr); - gwi.thd->infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init + MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init } else if (table_ptr->view) { diff --git a/dbcon/mysql/idb_mysql.h b/dbcon/mysql/idb_mysql.h index cb842d740..47dd61aff 100644 --- a/dbcon/mysql/idb_mysql.h +++ b/dbcon/mysql/idb_mysql.h @@ -111,6 +111,69 @@ inline char* idb_mysql_query_str(THD* thd) } } +class MIGR +{ + public: + enum infinidb_state + { + INFINIDB_INIT_CONNECT = 0, // intend to use to drop leftover vtable when logon. not being used now. + INFINIDB_INIT, + INFINIDB_CREATE_VTABLE, + INFINIDB_ALTER_VTABLE, + INFINIDB_SELECT_VTABLE, + INFINIDB_DROP_VTABLE, + INFINIDB_DISABLE_VTABLE, + INFINIDB_REDO_PHASE1, // post process requires to re-create vtable + INFINIDB_ORDER_BY, // for InfiniDB handler to ignore the 2nd scan for order by + INFINIDB_REDO_QUERY, // redo query with the normal mysql path + INFINIDB_ERROR_REDO_PHASE1, + INFINIDB_ERROR = 32, + }; + struct INFINIDB_VTABLE + { + String original_query; + String create_vtable_query; + String alter_vtable_query; + String select_vtable_query; + String drop_vtable_query; + String insert_vtable_query; + infinidb_state vtable_state; // flag for InfiniDB MySQL virtual table structure + bool autoswitch; + bool has_order_by; + bool duplicate_field_name; // @bug 1928. duplicate field name in create_phase will be ingored. + bool call_sp; + bool override_largeside_estimate; + void* cal_conn_info; + bool isUnion; + bool impossibleWhereOnUnion; + bool isInsertSelect; + bool isUpdateWithDerive; + bool isInfiniDBDML; // default false + bool hasInfiniDBTable; // default false + bool isNewQuery; + INFINIDB_VTABLE() : cal_conn_info(NULL) {init();} + void init() + { + vtable_state = INFINIDB_INIT_CONNECT; + autoswitch = false; + has_order_by = false; + duplicate_field_name = false; + call_sp = false; + override_largeside_estimate = false; + isUnion = false; + impossibleWhereOnUnion = false; + isUpdateWithDerive = false; + isInfiniDBDML = false; + hasInfiniDBTable = false; + isNewQuery = true; + } + }; + + static INFINIDB_VTABLE infinidb_vtable; // InfiniDB custom structure + +}; + + #endif // vim:ts=4 sw=4: From cd72326c4dab1f58f630c9a1ee460151d92269ef Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Mon, 25 Feb 2019 18:42:56 +0300 Subject: [PATCH 44/59] MCOL-2178 Introduced a dummy replacement for a infinidb_table. Used Item attribute getters introduced by 10.4 Make changes to support Item::CONST_ITEM introduced by 10.4 as a replacement for INT_,REAL_,STRING_ ITEM. Replaced QT_INFINIDB_DERIVED and similar flags with correponded flags for Item->print(). Replaced or commented out infinidb_ variable names with columnstore_ where applicable. --- dbcon/mysql/ha_calpont.cpp | 3 + dbcon/mysql/ha_calpont_dml.cpp | 4 +- dbcon/mysql/ha_calpont_execplan.cpp | 832 ++++++++++++++++------------ dbcon/mysql/ha_calpont_impl.cpp | 96 ++-- dbcon/mysql/ha_mcs_pushdown.cpp | 14 +- dbcon/mysql/ha_view.cpp | 4 +- dbcon/mysql/idb_mysql.h | 3 +- dbcon/mysql/my.cnf | 18 +- 8 files changed, 542 insertions(+), 432 deletions(-) diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index f1b375480..dfbb452ef 100644 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -23,6 +23,8 @@ #include "ha_calpont_impl.h" #include "ha_mcs_pushdown.h" +MIGR::INFINIDB_VTABLE MIGR::infinidb_vtable; + static handler* calpont_create_handler(handlerton* hton, TABLE_SHARE* table, MEM_ROOT* mem_root); @@ -116,6 +118,7 @@ static int columnstore_init_func(void* p) struct tm tm; time_t t; + time(&t); localtime_r(&t, &tm); fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d ", diff --git a/dbcon/mysql/ha_calpont_dml.cpp b/dbcon/mysql/ha_calpont_dml.cpp index 5dcf087e5..9372491e2 100644 --- a/dbcon/mysql/ha_calpont_dml.cpp +++ b/dbcon/mysql/ha_calpont_dml.cpp @@ -2117,8 +2117,8 @@ int ha_calpont_impl_commit_ (handlerton* hton, THD* thd, bool all, cal_connectio { int rc = 0; - if (MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_ALTER_VTABLE || - MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE ) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ALTER_VTABLE || + MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE ) return rc; if (thd->slave_thread && !ci.replicationEnabled) diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index f7940bc17..d97c1b303 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -514,7 +514,7 @@ void debug_walk(const Item* item, void* arg) case Item_func::BETWEEN: inp = (Item_func_opt_neg*)ifp; - if (inp->negated) cerr << "not "; + if (inp->get_negated()) cerr << "not "; cerr << "between" << " (" << ifp->functype() << ")" << endl; break; @@ -1584,7 +1584,7 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip) { // Starting with MariaDB 10.2, LIKE uses a negated flag instead of FUNC_NOT // Further processing is done below as before for LIKE - if (((Item_func_like*)ifp)->negated) + if (((Item_func_like*)ifp)->get_negated()) { sop->reverseOp(); } @@ -1722,7 +1722,7 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip) String str; // @bug5811. This filter string is for cross engine to use. // Use real table name. - ifp->print(&str, QT_INFINIDB_DERIVED); + ifp->print(&str, QT_ORDINARY); IDEBUG(cerr << str.ptr() << endl); if (str.ptr()) @@ -2743,7 +2743,7 @@ uint32_t setAggOp(AggregateColumn* ac, Item_sum* isp) { Item_func_group_concat* gc = (Item_func_group_concat*)isp; ac->aggOp(AggregateColumn::GROUP_CONCAT); - ac->distinct(gc->isDistinct()); + ac->distinct(gc->get_distinct()); return rc; } @@ -3021,7 +3021,7 @@ ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupp { //if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI )) { - if ( !item->fixed) + if ( !item->is_fixed()) { item->fix_fields(gwi.thd, (Item**)&item); } @@ -3035,59 +3035,71 @@ ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupp Item_field* ifp = (Item_field*)item; return buildSimpleColumn(ifp, gwi); } - - case Item::INT_ITEM: - case Item::VARBIN_ITEM: + case Item::CONST_ITEM: { - String val, *str = item->val_str(&val); - string valStr; - valStr.assign(str->ptr(), str->length()); - - if (item->unsigned_flag) + switch (item->cmp_type()) { - //cc = new ConstantColumn(valStr, (uint64_t)item->val_uint(), ConstantColumn::NUM); - // It seems that str at this point is crap if val_uint() is > MAX_BIGINT. By using - // this constructor, ConstantColumn is built with the proper string. For whatever reason, - // ExeMgr converts the fConstval member to numeric, rather than using the existing numeric - // values available, so it's important to have fConstval correct. - rc = new ConstantColumn((uint64_t)item->val_uint(), ConstantColumn::NUM); + case INT_RESULT: + { + String val, *str = item->val_str(&val); + string valStr; + valStr.assign(str->ptr(), str->length()); + + if (item->unsigned_flag) + { + rc = new ConstantColumn((uint64_t)item->val_uint(), ConstantColumn::NUM); + } + else + { + rc = new ConstantColumn(valStr, (int64_t)item->val_int(), ConstantColumn::NUM); + } + + break; + } + case STRING_RESULT: + { + String val, *str = item->val_str(&val); + string valStr; + valStr.assign(str->ptr(), str->length()); + rc = new ConstantColumn(valStr); + break; + } + case REAL_RESULT: + { + String val, *str = item->val_str(&val); + string valStr; + valStr.assign(str->ptr(), str->length()); + rc = new ConstantColumn(valStr, item->val_real()); + break; + } + case DECIMAL_RESULT: + { + rc = buildDecimalColumn(item, gwi); + break; + } + case TIME_RESULT: + { + String val, *str = item->val_str(&val); + string valStr; + valStr.assign(str->ptr(), str->length()); + rc = new ConstantColumn(valStr); + break; + } + default: + { + gwi.fatalParseError = true; + gwi.parseErrorText = "Unknown item type"; + break; + } } - else + + if (rc && (item->cmp_type() != DECIMAL_RESULT)) { - rc = new ConstantColumn(valStr, (int64_t)item->val_int(), ConstantColumn::NUM); + (dynamic_cast(rc))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); } - (dynamic_cast(rc))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); - //return cc; break; } - - case Item::STRING_ITEM: - { - String val, *str = item->val_str(&val); - string valStr; - valStr.assign(str->ptr(), str->length()); - rc = new ConstantColumn(valStr); - (dynamic_cast(rc))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); - break; - } - - case Item::REAL_ITEM: - { - String val, *str = item->val_str(&val); - string valStr; - valStr.assign(str->ptr(), str->length()); - rc = new ConstantColumn(valStr, item->val_real()); - (dynamic_cast(rc))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); - break; - } - - case Item::DECIMAL_ITEM: - { - rc = buildDecimalColumn(item, gwi); - break; - } - case Item::FUNC_ITEM: { Item_func* ifp = (Item_func*)item; @@ -3221,16 +3233,6 @@ ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupp break; } - case Item::DATE_ITEM: - { - String val, *str = item->val_str(&val); - string valStr; - valStr.assign(str->ptr(), str->length()); - rc = new ConstantColumn(valStr); - (dynamic_cast(rc))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); - break; - } - case Item::WINDOW_FUNC_ITEM: { return buildWindowFunctionColumn(item, gwi, nonSupport); @@ -3587,11 +3589,16 @@ ReturnedColumn* buildFunctionColumn( for (uint32_t i = 1; i < ifp->argument_count(); i++) { - if (!(ifp->arguments()[i]->type() == Item::INT_ITEM || - ifp->arguments()[i]->type() == Item::STRING_ITEM || - ifp->arguments()[i]->type() == Item::REAL_ITEM || - ifp->arguments()[i]->type() == Item::DECIMAL_ITEM || - ifp->arguments()[i]->type() == Item::NULL_ITEM)) + if (!(ifp->arguments()[i]->type() == Item::NULL_ITEM || + (ifp->arguments()[i]->type() == Item::CONST_ITEM && + (ifp->arguments()[i]->cmp_type() == INT_RESULT || + ifp->arguments()[i]->cmp_type() == STRING_RESULT || + ifp->arguments()[i]->cmp_type() == REAL_RESULT || + ifp->arguments()[i]->cmp_type() == DECIMAL_RESULT + ) + ) + ) + ) { if (ifp->arguments()[i]->type() == Item::FUNC_ITEM) { @@ -4464,7 +4471,7 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi) RowColumn* rowCol = new RowColumn(); vector selCols; - uint32_t select_ctn = gc->count_field(); + uint32_t select_ctn = gc->get_count_field(); ReturnedColumn* rc = NULL; for (uint32_t i = 0; i < select_ctn; i++) @@ -4485,12 +4492,13 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi) ORDER** order_item, **end; for (order_item = gc->get_order(), - end = order_item + gc->order_field(); order_item < end; + end = order_item + gc->get_order_field(); order_item < end; order_item++) { Item* ord_col = *(*order_item)->item; - if (ord_col->type() == Item::INT_ITEM) + if (ord_col->type() == Item::CONST_ITEM + && ord_col->cmp_type() == INT_RESULT) { Item_int* id = (Item_int*)ord_col; @@ -4530,10 +4538,10 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi) parm.reset(rowCol); ac->aggParms().push_back(parm); - if (gc->str_separator()) + if (gc->get_separator()) { string separator; - separator.assign(gc->str_separator()->ptr(), gc->str_separator()->length()); + separator.assign(gc->get_separator()->ptr(), gc->get_separator()->length()); (dynamic_cast(ac))->separator(separator); } } @@ -4564,18 +4572,29 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi) break; } - case Item::INT_ITEM: - case Item::STRING_ITEM: - case Item::REAL_ITEM: - case Item::DECIMAL_ITEM: + case Item::CONST_ITEM: { - // treat as count(*) - if (ac->aggOp() == AggregateColumn::COUNT) - ac->aggOp(AggregateColumn::COUNT_ASTERISK); + switch(sfitemp->cmp_type()) + { + case INT_RESULT: + case STRING_RESULT: + case REAL_RESULT: + case DECIMAL_RESULT: + { + // treat as count(*) + if (ac->aggOp() == AggregateColumn::COUNT) + ac->aggOp(AggregateColumn::COUNT_ASTERISK); - parm.reset(buildReturnedColumn(sfitemp, gwi, gwi.fatalParseError)); - ac->constCol(parm); - bIsConst = true; + parm.reset(buildReturnedColumn(sfitemp, gwi, gwi.fatalParseError)); + ac->constCol(parm); + bIsConst = true; + break; + } + default: + { + gwi.fatalParseError = true; + } + } break; } @@ -4659,7 +4678,6 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi) default: { gwi.fatalParseError = true; - //gwi.parseErrorText = "Non-supported Item in Aggregate function"; } } @@ -4922,7 +4940,7 @@ void addIntervalArgs(THD* thd, Item_func* ifp, FunctionParm& functionParms) if (funcName == "date_add_interval") interval_type = ((Item_date_add_interval*)ifp)->int_type; else if (funcName == "timestampdiff") - interval_type = ((Item_func_timestamp_diff*)ifp)->int_type; + interval_type = ((Item_func_timestamp_diff*)ifp)->get_int_type(); else if (funcName == "extract") interval_type = ((Item_extract*)ifp)->int_type; @@ -4959,7 +4977,7 @@ void castCharArgs(THD* thd, Item_func* ifp, FunctionParm& functionParms) Item_char_typecast* idai = (Item_char_typecast*)ifp; SPTP sptp; - sptp.reset(new ParseTree(new ConstantColumn((int64_t)idai->castLength()))); + sptp.reset(new ParseTree(new ConstantColumn((int64_t)idai->get_cast_length()))); (dynamic_cast(sptp->data()))->timeZone(thd->variables.time_zone->get_name()->ptr()); functionParms.push_back(sptp); } @@ -5058,67 +5076,96 @@ void gp_walk(const Item* item, void* arg) break; } - case Item::INT_ITEM: + case Item::CONST_ITEM: { - Item_int* iip = (Item_int*)item; - gwip->rcWorkStack.push(buildReturnedColumn(iip, *gwip, gwip->fatalParseError)); - break; - } - - case Item::STRING_ITEM: - { - Item_string* isp = (Item_string*)item; - - if (isp) + switch(item->cmp_type()) { - if (isp->result_type() == STRING_RESULT) + case INT_RESULT: { - String val, *str = isp->val_str(&val); - string cval; - - if (str->ptr()) - { - cval.assign(str->ptr(), str->length()); - } - - gwip->rcWorkStack.push(new ConstantColumn(cval)); - (dynamic_cast(gwip->rcWorkStack.top()))->timeZone(gwip->thd->variables.time_zone->get_name()->ptr()); + Item_int* iip = (Item_int*)item; + gwip->rcWorkStack.push(buildReturnedColumn(iip, *gwip, gwip->fatalParseError)); break; } - gwip->rcWorkStack.push(buildReturnedColumn(isp, *gwip, gwip->fatalParseError)); + case STRING_RESULT: + { + Item_string* isp = (Item_string*)item; + + if (isp) + { + if (isp->result_type() == STRING_RESULT) + { + String val, *str = isp->val_str(&val); + string cval; + + if (str->ptr()) + { + cval.assign(str->ptr(), str->length()); + } + + gwip->rcWorkStack.push(new ConstantColumn(cval)); + (dynamic_cast(gwip->rcWorkStack.top()))->timeZone(gwip->thd->variables.time_zone->get_name()->ptr()); + break; + } + + gwip->rcWorkStack.push(buildReturnedColumn(isp, *gwip, gwip->fatalParseError)); + } + break; + } + + 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)); + break; + } + /*case Item::VARBIN_ITEM: + { + Item_hex_string* hdp = (Item_hex_string*)item; + gwip->rcWorkStack.push(buildReturnedColumn(hdp, *gwip, gwip->fatalParseError)); + break; + }*/ + default: + { + if (gwip->condPush) + { + // push noop for unhandled item + SimpleColumn* rc = new SimpleColumn("noop"); + rc->timeZone(gwip->thd->variables.time_zone->get_name()->ptr()); + gwip->rcWorkStack.push(rc); + break; + } + + ostringstream oss; + oss << "Unhandled Item type: " << item->type(); + gwip->parseErrorText = oss.str(); + gwip->fatalParseError = true; + break; + } } - break; } - - case Item::REAL_ITEM: - { - Item_float* ifp = (Item_float*)item; - gwip->rcWorkStack.push(buildReturnedColumn(ifp, *gwip, gwip->fatalParseError)); - break; - } - - case Item::DECIMAL_ITEM: - { - Item_decimal* idp = (Item_decimal*)item; - gwip->rcWorkStack.push(buildReturnedColumn(idp, *gwip, gwip->fatalParseError)); - break; - } - - case Item::VARBIN_ITEM: - { - Item_hex_string* hdp = (Item_hex_string*)item; - gwip->rcWorkStack.push(buildReturnedColumn(hdp, *gwip, gwip->fatalParseError)); - break; - } - case Item::NULL_ITEM: { if (gwip->condPush) { // push noop for unhandled item SimpleColumn* rc = new SimpleColumn("noop"); + rc->timeZone(gwip->thd->variables.time_zone->get_name()->ptr()); gwip->rcWorkStack.push(rc); break; } @@ -5356,10 +5403,13 @@ void gp_walk(const Item* item, void* arg) } if ((it->type() == Item::FIELD_ITEM - || it->type() == Item::INT_ITEM - || it->type() == Item::DECIMAL_ITEM - || it->type() == Item::STRING_ITEM - || it->type() == Item::REAL_ITEM + || ( it->type() == Item::CONST_ITEM + && ( it->cmp_type() == INT_RESULT + || it->cmp_type() == DECIMAL_RESULT + || it->cmp_type() == STRING_RESULT + || it->cmp_type() == REAL_RESULT + ) + ) || it->type() == Item::NULL_ITEM || (it->type() == Item::FUNC_ITEM && !isPredicateFunction(it, gwip))) && !gwip->rcWorkStack.empty() @@ -5556,14 +5606,14 @@ void gp_walk(const Item* item, void* arg) gwip->hasSubSelect = true; gwip->subQuery = existsSub; gwip->ptWorkStack.push(existsSub->transform()); - current_MIGR::infinidb_vtable.isUnion = true; // only temp. bypass the 2nd phase. + MIGR::infinidb_vtable.isUnion = true; // only temp. bypass the 2nd phase. // recover original gwip->subQuery = orig; gwip->lastSub = existsSub; } else if (sub->substype() == Item_subselect::IN_SUBS) { - if (!((Item_in_subselect*)sub)->getOptimizer() && gwip->thd->derived_tables_processing) + if (!((Item_in_subselect*)sub)->optimizer && gwip->thd->derived_tables_processing) { ostringstream oss; oss << "Invalid In_optimizer: " << item->type(); @@ -5602,12 +5652,6 @@ void gp_walk(const Item* item, void* arg) break; } - case Item::DATE_ITEM: - { - Item_temporal_literal* itp = (Item_temporal_literal*)item; - gwip->rcWorkStack.push(buildReturnedColumn(itp, *gwip, gwip->fatalParseError)); - break; - } case Item::WINDOW_FUNC_ITEM: { @@ -5661,6 +5705,7 @@ void gp_walk(const Item* item, void* arg) printf("********** received TRIGGER_FIELD_ITEM *********\n"); break; + /* WIP MCOL-2178 case Item::XPATH_NODESET: printf("********** received XPATH_NODESET *********\n"); break; @@ -5672,13 +5717,14 @@ void gp_walk(const Item* item, void* arg) case Item::VIEW_FIXER_ITEM: printf("********** received VIEW_FIXER_ITEM *********\n"); break; - + */ default: { if (gwip->condPush) { // push noop for unhandled item SimpleColumn* rc = new SimpleColumn("noop"); + rc->timeZone(gwip->thd->variables.time_zone->get_name()->ptr()); gwip->rcWorkStack.push(rc); break; } @@ -5771,11 +5817,16 @@ void parse_item (Item* item, vector& field_vec, // special handling for count(*). This should not be treated as constant. if (isp->argument_count() == 1 && - (sfitempp[0]->type() == Item::INT_ITEM || - sfitempp[0]->type() == Item::STRING_ITEM || - sfitempp[0]->type() == Item::REAL_ITEM || - sfitempp[0]->type() == Item::DECIMAL_ITEM)) + ( sfitempp[0]->type() == Item::CONST_ITEM && + (sfitempp[0]->cmp_type() == INT_RESULT || + sfitempp[0]->cmp_type() == STRING_RESULT || + sfitempp[0]->cmp_type() == REAL_RESULT || + sfitempp[0]->cmp_type() == DECIMAL_RESULT) + ) + ) + { field_vec.push_back((Item_field*)item); //dummy + } for (uint32_t i = 0; i < isp->argument_count(); i++) parse_item(sfitempp[i], field_vec, hasNonSupportItem, parseInfo); @@ -6025,7 +6076,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, if (table_ptr->derived) { String str; - (table_ptr->derived->first_select())->print(gwi.thd, &str, QT_INFINIDB_DERIVED); + (table_ptr->derived->first_select())->print(gwi.thd, &str, QT_ORDINARY); SELECT_LEX* select_cursor = table_ptr->derived->first_select(); FromSubQuery fromSub(gwi, select_cursor); @@ -6051,7 +6102,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, } else if (table_ptr->view) { - View* view = new View(table_ptr->view->select_lex, &gwi); + View* view = new View(*table_ptr->view->first_select_lex(), &gwi); CalpontSystemCatalog::TableAliasName tn = make_aliastable(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str); view->viewName(tn); gwi.viewList.push_back(view); @@ -6187,7 +6238,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // MariaDB bug 624 - without the fix_fields call, delete with join may error with "No query step". //#if MYSQL_VERSION_ID < 50172 //@bug 3039. fix fields for constants - if (!icp->fixed) + if (!icp->is_fixed()) { icp->fix_fields(gwi.thd, (Item**)&icp); } @@ -6423,7 +6474,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, string fullname; String str; - ifp->print(&str, QT_INFINIDB_NO_QUOTE); + ifp->print(&str, QT_ORDINARY); fullname = str.c_ptr(); //sel_cols_in_create += fullname; @@ -6485,7 +6536,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, gwi.returnedCols.push_back(spac); gwi.selectCols.push_back('`' + escapeBackTick(spac->alias().c_str()) + '`'); String str(256); - item->print(&str, QT_INFINIDB_NO_QUOTE); + item->print(&str, QT_ORDINARY); if (sel_cols_in_create.length() != 0) sel_cols_in_create += ", "; @@ -6559,7 +6610,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, { redo = true; String str; - ifp->print(&str, QT_INFINIDB_NO_QUOTE); + ifp->print(&str, QT_ORDINARY); gwi.selectCols.push_back(string(str.c_ptr()) + " " + "`" + escapeBackTick(item->name.str) + "`"); } @@ -6574,7 +6625,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, else { String str(256); - ifp->print(&str, QT_INFINIDB_NO_QUOTE); + ifp->print(&str, QT_ORDINARY); if (sel_cols_in_create.length() != 0) sel_cols_in_create += ", "; @@ -6680,7 +6731,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, redo = true; // @bug 1706 String funcStr; - ifp->print(&funcStr, QT_INFINIDB); + ifp->print(&funcStr, QT_ORDINARY); string valStr; valStr.assign(funcStr.ptr(), funcStr.length()); gwi.selectCols.push_back(valStr + " `" + escapeBackTick(ifp->name.str) + "`"); @@ -6691,96 +6742,111 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, } break; - } + } // End of FUNC_ITEM - case Item::INT_ITEM: + case Item::CONST_ITEM: { - if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) - { } - else + switch(item->cmp_type()) { - // do not push the dummy column (mysql added) to returnedCol - if (item->name.length && string(item->name.str) == "Not_used") - continue; + case INT_RESULT: + { + if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) + { } + else + { + // do not push the dummy column (mysql added) to returnedCol + if (item->name.length && string(item->name.str) == "Not_used") + continue; - // @bug3509. Constant column is sent to ExeMgr now. - SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); + // @bug3509. Constant column is sent to ExeMgr now. + SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); - if (item->name.length) - srcp->alias(item->name.str); + if (item->name.length) + srcp->alias(item->name.str); - gwi.returnedCols.push_back(srcp); + gwi.returnedCols.push_back(srcp); - Item_int* isp = reinterpret_cast(item); - ostringstream oss; - oss << isp->value << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; + Item_int* isp = reinterpret_cast(item); + ostringstream oss; + oss << isp->value << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; + if (sel_cols_in_create.length() != 0) + sel_cols_in_create += ", "; - sel_cols_in_create += oss.str(); - gwi.selectCols.push_back(oss.str()); + sel_cols_in_create += oss.str(); + gwi.selectCols.push_back(oss.str()); + } + + break; + } + + case STRING_RESULT: + { + if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) + { } + else + { + SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); + gwi.returnedCols.push_back(srcp); + + if (item->name.length) + srcp->alias(item->name.str); + + Item_string* isp = reinterpret_cast(item); + String val, *str = isp->val_str(&val); + string valStr; + valStr.assign(str->ptr(), str->length()); + string name = "'" + valStr + "'" + " " + "`" + escapeBackTick(srcp->alias().c_str()) + "`"; + + if (sel_cols_in_create.length() != 0) + sel_cols_in_create += ", "; + + sel_cols_in_create += name; + gwi.selectCols.push_back(name); + } + + break; + } + + case DECIMAL_RESULT: + { + if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) + { } + else + { + SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); + gwi.returnedCols.push_back(srcp); + + if (item->name.length) + srcp->alias(item->name.str); + + Item_decimal* isp = reinterpret_cast(item); + String val, *str = isp->val_str(&val); + string valStr; + valStr.assign(str->ptr(), str->length()); + ostringstream oss; + oss << valStr.c_str() << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; + + if (sel_cols_in_create.length() != 0) + sel_cols_in_create += ", "; + + sel_cols_in_create += oss.str(); + gwi.selectCols.push_back(oss.str()); + } + + break; + } + // WIP MCOL-2178 This switch doesn't handl + // ROW_, TIME_, REAL_RESULT and if one couldn't + // project the former two REAL is possible. + // Need to test before commit. + default: + { + //noop + } } - break; - } - - case Item::STRING_ITEM: - { - if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) - { } - else - { - SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); - gwi.returnedCols.push_back(srcp); - - if (item->name.length) - srcp->alias(item->name.str); - - Item_string* isp = reinterpret_cast(item); - String val, *str = isp->val_str(&val); - string valStr; - valStr.assign(str->ptr(), str->length()); - string name = "'" + valStr + "'" + " " + "`" + escapeBackTick(srcp->alias().c_str()) + "`"; - - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += name; - gwi.selectCols.push_back(name); - } - - break; - } - - case Item::DECIMAL_ITEM: - { - if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) - { } - else - { - SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); - gwi.returnedCols.push_back(srcp); - - if (item->name.length) - srcp->alias(item->name.str); - - Item_decimal* isp = reinterpret_cast(item); - String val, *str = isp->val_str(&val); - string valStr; - valStr.assign(str->ptr(), str->length()); - ostringstream oss; - oss << valStr.c_str() << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; - - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += oss.str(); - gwi.selectCols.push_back(oss.str()); - } - - break; - } + } // CONST_ITEM ends here case Item::NULL_ITEM: { @@ -6858,7 +6924,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, gwi.returnedCols.push_back(SRCP(rc)); String str; - sub->get_select_lex()->print(gwi.thd, &str, QT_INFINIDB_NO_QUOTE); + sub->get_select_lex()->print(gwi.thd, &str, QT_ORDINARY); sel_cols_in_create += "(" + string(str.c_ptr()) + ")"; if (sub->name.length) @@ -7027,7 +7093,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, } String str; - funcFieldVec[i]->print(&str, QT_INFINIDB_NO_QUOTE); + funcFieldVec[i]->print(&str, QT_ORDINARY); sc->alias(string(str.c_ptr())); //sc->tableAlias(funcFieldVec[i]->table_name); sc->tableAlias(sc->tableAlias()); @@ -7068,7 +7134,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SRCP minSc; // min width projected column. for count(*) use // Group by list. not valid for union main query - if (MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && !unionSel) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE && !unionSel) { gwi.clauseType = GROUP_BY; Item* nonSupportItem = NULL; @@ -7240,10 +7306,13 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // @bug5638. The group by column is constant but not counter, alias has to match a column // on the select list else if (!groupcol->counter_used && - (groupItem->type() == Item::INT_ITEM || - groupItem->type() == Item::STRING_ITEM || - groupItem->type() == Item::REAL_ITEM || - groupItem->type() == Item::DECIMAL_ITEM)) + (groupItem->type() == Item::CONST_ITEM && + (groupItem->cmp_type() == INT_RESULT || + groupItem->cmp_type() == STRING_RESULT || + groupItem->cmp_type() == REAL_RESULT || + groupItem->cmp_type() == DECIMAL_RESULT) + ) + ) { ReturnedColumn* rc = 0; @@ -7345,7 +7414,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, } } - if (MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) { SQL_I_List order_list = select_lex.order_list; ORDER* ordercol = reinterpret_cast(order_list.first); @@ -7364,8 +7433,11 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, if ((*(ordercol->item))->type() == Item::WINDOW_FUNC_ITEM) gwi.hasWindowFunc = true; // MCOL-2166 Looking for this sorting item in GROUP_BY items list. + // Shouldn't look into this if query doesn't have GROUP BY or + // aggregations if(isPushdownHand - && !sortItemIsInGrouping(*ordercol->item, select_lex.group_list.first)) + && select_lex.agg_func_used() && select_lex.group_list.first + && !sortItemIsInGrouping(*ordercol->item, select_lex.group_list.first)) { std::ostringstream ostream; std::ostringstream& osr = ostream; @@ -7404,15 +7476,28 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, Item* ord_item = *(ordercol->item); // ignore not_used column on order by. - if (ord_item->type() == Item::INT_ITEM && ord_item->full_name() && string(ord_item->full_name()) == "Not_used") - continue; - else if (ord_item->type() == Item::INT_ITEM) - rc = gwi.returnedCols[((Item_int*)ord_item)->val_int() - 1]->clone(); + if ((ord_item->type() == Item::CONST_ITEM + && ord_item->cmp_type() == INT_RESULT) + && ord_item->full_name() + && !strcmp(ord_item->full_name(), "Not_used")) + { + continue; + } + else if (ord_item->type() == Item::CONST_ITEM + && ord_item->cmp_type() == INT_RESULT) + { + // WIP MCOL-2178. We should seek smallest + // column here and not just previous. + rc = gwi.returnedCols[((Item_int*)ord_item)->val_int() - 1]->clone(); + } else if (ord_item->type() == Item::SUBSELECT_ITEM) + { gwi.fatalParseError = true; + } else + { rc = buildReturnedColumn(ord_item, gwi, gwi.fatalParseError); - + } // @bug5501 try item_ptr if item can not be fixed. For some // weird dml statement state, item can not be fixed but the // infomation is available in item_ptr. @@ -7603,7 +7688,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // @bug 3076. do not add the argument of aggregate function to the SELECT list, // instead, add the whole column String str; - ord_item->print(&str, QT_INFINIDB_NO_QUOTE); + ord_item->print(&str, QT_ORDINARY); if (sel_cols_in_create.length() != 0) sel_cols_in_create += ", "; @@ -7684,7 +7769,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, } String str; - ord_item->print(&str, QT_INFINIDB); + ord_item->print(&str, QT_ORDINARY); ord_cols += str.c_ptr(); } @@ -7708,7 +7793,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, } String str; - fieldVec[i]->print(&str, QT_INFINIDB_NO_QUOTE); + fieldVec[i]->print(&str, QT_ORDINARY); sc->alias(string(str.c_ptr())); SRCP srcp(sc); uint32_t j = 0; @@ -7863,7 +7948,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, continue; String str; - (table_ptr->derived->first_select())->print(gwi.thd, &str, QT_INFINIDB_DERIVED); + (table_ptr->derived->first_select())->print(gwi.thd, &str, QT_ORDINARY); if (!firstTb) create_query += ", "; @@ -7925,7 +8010,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, MIGR::infinidb_vtable.create_vtable_query.free(); MIGR::infinidb_vtable.create_vtable_query.append(create_query.c_str(), create_query.length()); - MIGR::infinidb_vtable.vtable_state = THD::INFINIDB_REDO_PHASE1; // redo phase 1 + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_REDO_PHASE1; // redo phase 1 // turn off select distinct from post process unless there're post process functions // on the select list. @@ -8045,7 +8130,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, else if (ord_item->name.length) { // for union order by 1 case. For unknown reason, it doesn't show in_field_list - if (ord_item->type() == Item::INT_ITEM) + if (ord_item->type() == Item::CONST_ITEM + && ord_item->cmp_type() == INT_RESULT) { ord_cols += ord_item->name.str; } @@ -8079,7 +8165,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, else { String str; - ord_item->print(&str, QT_INFINIDB_NO_QUOTE); + ord_item->print(&str, QT_ORDINARY); ord_cols += string(str.c_ptr()); } @@ -8158,9 +8244,9 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // select_lex->offset_limit if not null. if (join->select_lex && join->select_lex->offset_limit && - join->select_lex->offset_limit->fixed && + join->select_lex->offset_limit->is_fixed() && join->select_lex->select_limit && - join->select_lex->select_limit->fixed) + join->select_lex->select_limit->is_fixed()) { limitOffset = join->select_lex->offset_limit->val_int(); limitNum = join->select_lex->select_limit->val_int(); @@ -8196,7 +8282,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // do not set in csep. @bug5096. ignore session limit setting for dml if ((gwi.thd->variables.select_limit == (uint64_t) - 1 || (gwi.thd->variables.select_limit != (uint64_t) - 1 && - MIGR::infinidb_vtable.vtable_state != THD::INFINIDB_CREATE_VTABLE)) && + MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_CREATE_VTABLE)) && !csep->hasOrderBy()) { csep->limitStart(limitOffset); @@ -8329,7 +8415,8 @@ int cp_get_plan(THD* thd, SCSEP& csep) LEX* lex = thd->lex; idbassert(lex != 0); - SELECT_LEX select_lex = lex->select_lex; + // WIP MCOL-2178 A questionable replacement. + SELECT_LEX select_lex = *lex->first_select_lex(); gp_walk_info gwi; gwi.thd = thd; int status = getSelectPlan(gwi, select_lex, csep); @@ -8667,7 +8754,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro if (table_ptr->derived) { String str; - (table_ptr->derived->first_select())->print(gwi.thd, &str, QT_INFINIDB_DERIVED); + (table_ptr->derived->first_select())->print(gwi.thd, &str, QT_ORDINARY); SELECT_LEX* select_cursor = table_ptr->derived->first_select(); FromSubQuery fromSub(gwi, select_cursor); @@ -8693,7 +8780,8 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro } else if (table_ptr->view) { - View* view = new View(table_ptr->view->select_lex, &gwi); + // WIP MCOL-2178 A questionable replacement. + View* view = new View(*table_ptr->view->first_select_lex(), &gwi); CalpontSystemCatalog::TableAliasName tn = make_aliastable(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str); view->viewName(tn); gwi.viewList.push_back(view); @@ -8763,7 +8851,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // MariaDB bug 624 - without the fix_fields call, delete with join may error with "No query step". //#if MYSQL_VERSION_ID < 50172 //@bug 3039. fix fields for constants - if (!icp->fixed) + if (!icp->is_fixed()) { icp->fix_fields(gwi.thd, (Item**)&icp); } @@ -8948,7 +9036,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro string fullname; String str; - ifp->print(&str, QT_INFINIDB_NO_QUOTE); + ifp->print(&str, QT_ORDINARY); fullname = str.c_ptr(); //sel_cols_in_create += fullname; @@ -9023,7 +9111,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro gwi.selectCols.push_back('`' + escapeBackTick(spac->alias().c_str()) + '`'); String str(256); - item->print(&str, QT_INFINIDB_NO_QUOTE); + item->print(&str, QT_ORDINARY); if (sel_cols_in_create.length() != 0) sel_cols_in_create += ", "; @@ -9097,7 +9185,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro { redo = true; String str; - ifp->print(&str, QT_INFINIDB_NO_QUOTE); + ifp->print(&str, QT_ORDINARY); gwi.selectCols.push_back(string(str.c_ptr()) + " " + "`" + escapeBackTick(item->name.str) + "`"); } @@ -9112,7 +9200,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro else { String str(256); - ifp->print(&str, QT_INFINIDB_NO_QUOTE); + ifp->print(&str, QT_ORDINARY); if (sel_cols_in_create.length() != 0) sel_cols_in_create += ", "; @@ -9221,7 +9309,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro redo = true; // @bug 1706 String funcStr; - ifp->print(&funcStr, QT_INFINIDB); + ifp->print(&funcStr, QT_ORDINARY); gwi.selectCols.push_back(string(funcStr.c_ptr()) + " `" + escapeBackTick(ifp->name.str) + "`"); // clear the error set by buildFunctionColumn gwi.fatalParseError = false; @@ -9232,97 +9320,110 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro break; } - case Item::INT_ITEM: + case Item::CONST_ITEM: { - if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) - { } - else + switch(item->cmp_type()) { - // do not push the dummy column (mysql added) to returnedCol - if (item->name.length && string(item->name.str) == "Not_used") - continue; + case INT_RESULT: + { + if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) + { } + else + { + // do not push the dummy column (mysql added) to returnedCol + if (item->name.length && string(item->name.str) == "Not_used") + continue; - // @bug3509. Constant column is sent to ExeMgr now. - SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); + // @bug3509. Constant column is sent to ExeMgr now. + SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); - if (item->name.length) - srcp->alias(item->name.str); + if (item->name.length) + srcp->alias(item->name.str); - gwi.returnedCols.push_back(srcp); + gwi.returnedCols.push_back(srcp); - Item_int* isp = reinterpret_cast(item); - ostringstream oss; - oss << isp->value << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; + Item_int* isp = reinterpret_cast(item); + ostringstream oss; + oss << isp->value << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; + if (sel_cols_in_create.length() != 0) + sel_cols_in_create += ", "; - sel_cols_in_create += oss.str(); - gwi.selectCols.push_back(oss.str()); + sel_cols_in_create += oss.str(); + gwi.selectCols.push_back(oss.str()); + } + + break; + } + + case STRING_RESULT: + { + if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) + { } + else + { + SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); + gwi.returnedCols.push_back(srcp); + + if (item->name.length) + srcp->alias(item->name.str); + + Item_string* isp = reinterpret_cast(item); + String val, *str = isp->val_str(&val); + string valStr; + valStr.assign(str->ptr(), str->length()); + string name = "'" + valStr + "'" + " " + "`" + escapeBackTick(srcp->alias().c_str()) + "`"; + + if (sel_cols_in_create.length() != 0) + sel_cols_in_create += ", "; + + sel_cols_in_create += name; + gwi.selectCols.push_back(name); + } + + break; + } + + case DECIMAL_RESULT: + { + if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) + { } + else + { + SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); + gwi.returnedCols.push_back(srcp); + + if (item->name.length) + srcp->alias(item->name.str); + + Item_decimal* isp = reinterpret_cast(item); + String val, *str = isp->val_str(&val); + string valStr; + valStr.assign(str->ptr(), str->length()); + ostringstream oss; + oss << valStr.c_str() << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; + + if (sel_cols_in_create.length() != 0) + sel_cols_in_create += ", "; + + sel_cols_in_create += oss.str(); + gwi.selectCols.push_back(oss.str()); + } + + break; + } + default: + // WIP MCOL-2178 Same thing as for getSelectPlan + { + // noop + } } - break; - } - - case Item::STRING_ITEM: - { - if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) - { } - else - { - SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); - gwi.returnedCols.push_back(srcp); - - if (item->name.length) - srcp->alias(item->name.str); - - Item_string* isp = reinterpret_cast(item); - String val, *str = isp->val_str(&val); - string valStr; - valStr.assign(str->ptr(), str->length()); - string name = "'" + valStr + "'" + " " + "`" + escapeBackTick(srcp->alias().c_str()) + "`"; - - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += name; - gwi.selectCols.push_back(name); - } - - break; - } - - case Item::DECIMAL_ITEM: - { - if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) - { } - else - { - SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); - gwi.returnedCols.push_back(srcp); - - if (item->name.length) - srcp->alias(item->name.str); - - Item_decimal* isp = reinterpret_cast(item); - String val, *str = isp->val_str(&val); - string valStr; - valStr.assign(str->ptr(), str->length()); - ostringstream oss; - oss << valStr.c_str() << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; - - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += oss.str(); - gwi.selectCols.push_back(oss.str()); - } - - break; - } + } // CONST_ITEM ends here case Item::NULL_ITEM: { + // WIP MCOL-2178 Check for NULL in projection. /*if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) ) { } else @@ -9397,7 +9498,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro gwi.returnedCols.push_back(SRCP(rc)); String str; - sub->get_select_lex()->print(gwi.thd, &str, QT_INFINIDB_NO_QUOTE); + sub->get_select_lex()->print(gwi.thd, &str, QT_ORDINARY); sel_cols_in_create += "(" + string(str.c_ptr()) + ")"; if (sub->name.length) @@ -9565,7 +9666,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro } String str; - funcFieldVec[i]->print(&str, QT_INFINIDB_NO_QUOTE); + funcFieldVec[i]->print(&str, QT_ORDINARY); sc->alias(string(str.c_ptr())); //sc->tableAlias(funcFieldVec[i]->table_name); sc->tableAlias(sc->tableAlias()); @@ -9606,7 +9707,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro SRCP minSc; // min width projected column. for count(*) use // Group by list. not valid for union main query - if (MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && !unionSel) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE && !unionSel) { gwi.clauseType = GROUP_BY; Item* nonSupportItem = NULL; @@ -9778,10 +9879,14 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // @bug5638. The group by column is constant but not counter, alias has to match a column // on the select list else if (!groupcol->counter_used && - (groupItem->type() == Item::INT_ITEM || - groupItem->type() == Item::STRING_ITEM || - groupItem->type() == Item::REAL_ITEM || - groupItem->type() == Item::DECIMAL_ITEM)) + (groupItem->type() == Item::CONST_ITEM && + (groupItem->cmp_type() == INT_RESULT || + groupItem->cmp_type() == STRING_RESULT || + groupItem->cmp_type() == REAL_RESULT || + groupItem->cmp_type() == DECIMAL_RESULT) + ) + ) + { ReturnedColumn* rc = 0; @@ -9885,7 +9990,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // ORDER BY processing starts here - if (MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) + if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) { ORDER* ordercol = reinterpret_cast(gi.groupByOrder); string create_query(MIGR::infinidb_vtable.create_vtable_query.c_ptr()); @@ -9929,12 +10034,22 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro bool nonAggField = true; // ignore not_used column on order by. - if (ord_item->type() == Item::INT_ITEM && ord_item->full_name() && string(ord_item->full_name()) == "Not_used") + if ((ord_item->type() == Item::CONST_ITEM + && ord_item->cmp_type() == INT_RESULT) + && ord_item->full_name() + && !strcmp(ord_item->full_name(), "Not_used")) + { continue; - else if (ord_item->type() == Item::INT_ITEM) + } + else if (ord_item->type() == Item::CONST_ITEM + && ord_item->cmp_type() == INT_RESULT) + { rc = gwi.returnedCols[((Item_int*)ord_item)->val_int() - 1]->clone(); + } else if (ord_item->type() == Item::SUBSELECT_ITEM) + { gwi.fatalParseError = true; + } else if (ordercol->in_field_list && ord_item->type() == Item::FIELD_ITEM) { rc = buildReturnedColumn(ord_item, gwi, gwi.fatalParseError); @@ -10159,7 +10274,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro continue; String str; - (table_ptr->derived->first_select())->print(gwi.thd, &str, QT_INFINIDB_DERIVED); + (table_ptr->derived->first_select())->print(gwi.thd, &str, QT_ORDINARY); if (!firstTb) create_query += ", "; @@ -10221,7 +10336,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro MIGR::infinidb_vtable.create_vtable_query.free(); MIGR::infinidb_vtable.create_vtable_query.append(create_query.c_str(), create_query.length()); - MIGR::infinidb_vtable.vtable_state = THD::INFINIDB_REDO_PHASE1; // redo phase 1 + MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_REDO_PHASE1; // redo phase 1 // turn off select distinct from post process unless there're post process functions // on the select list. @@ -10346,7 +10461,8 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro else if (ord_item->name.length) { // for union order by 1 case. For unknown reason, it doesn't show in_field_list - if (ord_item->type() == Item::INT_ITEM) + if (ord_item->type() == Item::CONST_ITEM + && ord_item->cmp_type() == INT_RESULT) { ord_cols += ord_item->name.str; } @@ -10380,7 +10496,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro else { String str; - ord_item->print(&str, QT_INFINIDB_NO_QUOTE); + ord_item->print(&str, QT_ORDINARY); ord_cols += string(str.c_ptr()); } diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 6790664a7..9be4eaf0a 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -752,8 +752,8 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h //float float_val = *(float*)(&value); //f2->store(float_val); - if (f2->decimals() < (uint32_t)row.getScale(s)) - // WIP MCOL-2178 + // WIP MCOL-2178 + //if (f2->decimals() < (uint32_t)row.getScale(s)) //f2->dec = (uint32_t)row.getScale(s); f2->store(dl); @@ -1320,7 +1320,6 @@ uint32_t doUpdateDelete(THD* thd) } // @bug 1127. Re-construct update stmt using lex instead of using the original query. -// string dmlStmt=""; string dmlStmt = string(idb_mysql_query_str(thd)); string schemaName; string tableName(""); @@ -1338,28 +1337,16 @@ uint32_t doUpdateDelete(THD* thd) { ColumnAssignment* columnAssignmentPtr; Item_field* item; -// TABLE_LIST* table_ptr = thd->lex->thd->lex->first_select_lex()->get_table_list(); - List_iterator_fast field_it(thd->lex->thd->lex->first_select_lex()->item_list); + List_iterator_fast field_it(thd->lex->first_select_lex()->item_list); List_iterator_fast value_it(thd->lex->value_list); -// dmlStmt += "update "; updateCP->queryType(CalpontSelectExecutionPlan::UPDATE); ci->stats.fQueryType = updateCP->queryType(); uint32_t cnt = 0; tr1::unordered_set timeStampColumnNames; -// for (; table_ptr; table_ptr= table_ptr->next_local) -// { -// dmlStmt += string(table_ptr->table_name); -// if (table_ptr->next_local) -// dmlStmt += ", "; -// } - -// dmlStmt += " set "; - while ((item = (Item_field*) field_it++)) { cnt++; -// dmlStmt += string(item->name) + "="; string tmpTableName = bestTableName(item); @@ -1411,21 +1398,41 @@ uint32_t doUpdateDelete(THD* thd) columnAssignmentPtr->fFuncScale = 0; Item* value = value_it++; - if (value->type() == Item::STRING_ITEM) + if (value->type() == Item::CONST_ITEM) { - //@Bug 2587 use val_str to replace value->name to get rid of 255 limit - String val, *str; - str = value->val_str(&val); - columnAssignmentPtr->fScalarExpression.assign(str->ptr(), str->length()); - columnAssignmentPtr->fFromCol = false; + if (value->cmp_type() == STRING_RESULT) + { + //@Bug 2587 use val_str to replace value->name to get rid of 255 limit + String val, *str; + str = value->val_str(&val); + columnAssignmentPtr->fScalarExpression.assign(str->ptr(), str->length()); + columnAssignmentPtr->fFromCol = false; + } + else if (value->cmp_type() == INT_RESULT) + { + std::ostringstream oss; + + if (value->unsigned_flag) + { + oss << value->val_uint(); + } + else + { + oss << value->val_int(); + } + + columnAssignmentPtr->fScalarExpression = oss.str(); + columnAssignmentPtr->fFromCol = false; + } } - else if ( value->type() == Item::VARBIN_ITEM ) + // WIP MCOL-2178 + /*else if ( value->type() == Item::VARBIN_ITEM ) { String val, *str; str = value->val_str(&val); columnAssignmentPtr->fScalarExpression.assign(str->ptr(), str->length()); columnAssignmentPtr->fFromCol = false; - } + }*/ else if ( value->type() == Item::FUNC_ITEM ) { //Bug 2092 handle negative values @@ -1491,23 +1498,6 @@ uint32_t doUpdateDelete(THD* thd) } } } - else if ( value->type() == Item::INT_ITEM ) - { - std::ostringstream oss; - - if (value->unsigned_flag) - { - oss << value->val_uint(); - } - else - { - oss << value->val_int(); - } - -// dmlStmt += oss.str(); - columnAssignmentPtr->fScalarExpression = oss.str(); - columnAssignmentPtr->fFromCol = false; - } else if ( value->type() == Item::FIELD_ITEM) { isFromCol = true; @@ -1590,8 +1580,6 @@ uint32_t doUpdateDelete(THD* thd) } colAssignmentListPtr->push_back ( columnAssignmentPtr ); -// if (cnt < thd->lex->thd->lex->first_select_lex()->item_list.elements) -// dmlStmt += ", "; } // Support for on update current_timestamp() for timestamp fields @@ -1620,7 +1608,6 @@ uint32_t doUpdateDelete(THD* thd) } else { -// dmlStmt = string(idb_mysql_query_str(thd)); updateCP->queryType(CalpontSelectExecutionPlan::DELETE); ci->stats.fQueryType = updateCP->queryType(); } @@ -1639,7 +1626,7 @@ uint32_t doUpdateDelete(THD* thd) } else { - first_table = (TABLE_LIST*) thd->lex->thd->lex->first_select_lex()->table_list.first; + first_table = (TABLE_LIST*) thd->lex->first_select_lex()->table_list.first; aTableName.schema = first_table->table->s->db.str; aTableName.table = first_table->table->s->table_name.str; } @@ -1690,9 +1677,9 @@ uint32_t doUpdateDelete(THD* thd) } else if ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) //@Bug 6121 error out on multi tables delete. { - if ( (thd->lex->thd->lex->first_select_lex()->join) != 0) + if ( (thd->lex->first_select_lex()->join) != 0) { - multi_delete* deleteTable = (multi_delete*)((thd->lex->thd->lex->first_select_lex()->join)->result); + multi_delete* deleteTable = (multi_delete*)((thd->lex->first_select_lex()->join)->result); first_table = (TABLE_LIST*) deleteTable->get_tables(); if (deleteTable->get_num_of_tables() == 1) @@ -1715,7 +1702,7 @@ uint32_t doUpdateDelete(THD* thd) } else { - first_table = (TABLE_LIST*) thd->lex->thd->lex->first_select_lex()->table_list.first; + first_table = (TABLE_LIST*) thd->lex->first_select_lex()->table_list.first; schemaName = first_table->table->s->db.str; tableName = first_table->table->s->table_name.str; aliasName = first_table->alias.str; @@ -1726,7 +1713,7 @@ uint32_t doUpdateDelete(THD* thd) } else { - first_table = (TABLE_LIST*) thd->lex->thd->lex->first_select_lex()->table_list.first; + first_table = (TABLE_LIST*) thd->lex->first_select_lex()->table_list.first; schemaName = first_table->table->s->db.str; tableName = first_table->table->s->table_name.str; aliasName = first_table->alias.str; @@ -1759,8 +1746,8 @@ uint32_t doUpdateDelete(THD* thd) if (( (thd->lex)->sql_command == SQLCOM_UPDATE ) || ( (thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) ) { - items = (thd->lex->thd->lex->first_select_lex()->item_list); - thd->lex->thd->lex->first_select_lex()->item_list = thd->lex->value_list; + items = (thd->lex->first_select_lex()->item_list); + thd->lex->first_select_lex()->item_list = thd->lex->value_list; } select_lex = *lex->first_select_lex(); @@ -1824,7 +1811,7 @@ uint32_t doUpdateDelete(THD* thd) // @bug 4457. MySQL inconsistence! for some queries, some structures are only available // in the derived_tables_processing phase. So by pass the phase for DML only when the // execution plan can not be successfully generated. recover lex before returning; - thd->lex->thd->lex->first_select_lex()->item_list = items; + thd->lex->first_select_lex()->item_list = items; MIGR::infinidb_vtable.vtable_state = origState; return 0; } @@ -1975,7 +1962,7 @@ uint32_t doUpdateDelete(THD* thd) //cout<< "Plan is " << endl << *updateCP << endl; if (( (thd->lex)->sql_command == SQLCOM_UPDATE ) || ( (thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) ) - thd->lex->thd->lex->first_select_lex()->item_list = items; + thd->lex->first_select_lex()->item_list = items; } //cout<< "Plan is " << endl << *updateCP << endl; @@ -3253,7 +3240,7 @@ int ha_calpont_impl_delete_table(const char* name) } else { - TABLE_LIST* first_table = (TABLE_LIST*) thd->lex->thd->lex->first_select_lex()->table_list.first; + TABLE_LIST* first_table = (TABLE_LIST*) thd->lex->first_select_lex()->table_list.first; dbName = const_cast(first_table->db.str); } @@ -4280,7 +4267,6 @@ int ha_calpont_impl_close_connection (handlerton* hton, THD* thd) int ha_calpont_impl_rename_table(const char* from, const char* to) { IDEBUG( cout << "ha_calpont_impl_rename_table: " << from << " => " << to << endl ); - THD* thd = current_thd; if (get_fe_conn_info_ptr() == NULL) set_fe_conn_info_ptr((void*)new cal_connection_info()); diff --git a/dbcon/mysql/ha_mcs_pushdown.cpp b/dbcon/mysql/ha_mcs_pushdown.cpp index 6b7f0ff89..489751795 100644 --- a/dbcon/mysql/ha_mcs_pushdown.cpp +++ b/dbcon/mysql/ha_mcs_pushdown.cpp @@ -129,11 +129,11 @@ create_calpont_group_by_handler(THD* thd, Query* query) SELECT_LEX *select_lex = query->from->select_lex; // Create a handler if query is valid. See comments for details. - if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE + if //( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE // WIP MCOL-2178 //&& ( MIGR::infinidb_vtable_mode == 0 // || MIGR::infinidb_vtable_mode == 2 ) - && ( query->group_by || select_lex->with_sum_func ) ) + ( query->group_by || select_lex->with_sum_func ) //) { bool unsupported_feature = false; // revisit SELECT_LEX for all units @@ -214,12 +214,12 @@ create_columnstore_derived_handler(THD* thd, TABLE_LIST *derived) SELECT_LEX_UNIT *unit= derived->derived; - if ( MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_DISABLE_VTABLE ) + /* //if ( MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_DISABLE_VTABLE ) // WIP MCOL-2178 // && MIGR::infinidb_vtable_mode != 0 ) { return 0; - } + }*/ for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select()) { @@ -472,13 +472,15 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) ha_columnstore_select_handler* handler = NULL; handlerton *ht= 0; + /* // Return if vtable enabled. - if ( MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_DISABLE_VTABLE ) + //if ( MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_DISABLE_VTABLE ) // WIP MCOL-2178 // && MIGR::infinidb_vtable_mode != 0 ) { return 0; - } + }*/ + for (SELECT_LEX* sl = select_lex;sl; sl= sl->next_select()) { if (!(sl->join)) diff --git a/dbcon/mysql/ha_view.cpp b/dbcon/mysql/ha_view.cpp index 761608d0e..8a6df6a0f 100644 --- a/dbcon/mysql/ha_view.cpp +++ b/dbcon/mysql/ha_view.cpp @@ -109,7 +109,9 @@ void View::transform() // for nested view, the view name is vout.vin... format CalpontSystemCatalog::TableAliasName tn = make_aliasview(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str, viewName); gwi.viewName = make_aliastable(table_ptr->db.str, table_ptr->table_name.str, viewName); - View* view = new View(table_ptr->view->select_lex, &gwi); + // WIP MCOL-2178 CS could mess with the SELECT_LEX unit so better + // use a copy. + View* view = new View(*table_ptr->view->first_select_lex(), &gwi); view->viewName(gwi.viewName); gwi.viewList.push_back(view); view->transform(); diff --git a/dbcon/mysql/idb_mysql.h b/dbcon/mysql/idb_mysql.h index 47dd61aff..b16301159 100644 --- a/dbcon/mysql/idb_mysql.h +++ b/dbcon/mysql/idb_mysql.h @@ -154,7 +154,8 @@ class MIGR INFINIDB_VTABLE() : cal_conn_info(NULL) {init();} void init() { - vtable_state = INFINIDB_INIT_CONNECT; + //vtable_state = INFINIDB_INIT_CONNECT; + vtable_state = INFINIDB_DISABLE_VTABLE; autoswitch = false; has_order_by = false; duplicate_field_name = false; diff --git a/dbcon/mysql/my.cnf b/dbcon/mysql/my.cnf index fb20fd8c9..12392a664 100644 --- a/dbcon/mysql/my.cnf +++ b/dbcon/mysql/my.cnf @@ -47,21 +47,21 @@ group_concat_max_len=512 sql_mode="ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" # Enable compression by default on create, set to 0 to turn off -infinidb_compression_type=2 +#columnstore_compression_type=2 # Default for string table threshhold -infinidb_stringtable_threshold=20 +#columnstore_stringtable_threshold=20 # infinidb local query flag -infinidb_local_query=0 +#columnstore_local_query=0 -infinidb_diskjoin_smallsidelimit=0 -infinidb_diskjoin_largesidelimit=0 -infinidb_diskjoin_bucketsize=100 -infinidb_um_mem_limit=0 +#columnstore_diskjoin_smallsidelimit=0 +#columnstore_diskjoin_largesidelimit=0 +#columnstore_diskjoin_bucketsize=100 +#columnstore_um_mem_limit=0 -infinidb_use_import_for_batchinsert=1 -infinidb_import_for_batchinsert_delimiter=7 +#columnstore_use_import_for_batchinsert=1 +#columnstore_import_for_batchinsert_delimiter=7 basedir = /usr/local/mariadb/columnstore/mysql/ character-sets-dir = /usr/local/mariadb/columnstore/mysql/share/charsets/ From 5409eed6f53525e55ca2290347f5cc15a6d019d2 Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Mon, 25 Feb 2019 18:42:56 +0300 Subject: [PATCH 45/59] MCOL-2178 Introduced a dummy replacement for a infinidb_table. Used Item attribute getters introduced by 10.4 Make changes to support Item::CONST_ITEM introduced by 10.4 as a replacement for INT_,REAL_,STRING_ ITEM. Replaced QT_INFINIDB_DERIVED and similar flags with correponded flags for Item->print(). Replaced or commented out infinidb_ variable names with columnstore_ where applicable. Fixed an impossible precision typo. --- dbcon/mysql/ha_calpont_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 9be4eaf0a..4efe01b51 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -779,7 +779,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h // 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; + (*f)->field_length = 40; //double double_val = *(double*)(&value); //f2->store(double_val); From c297ceb6c1342bc489435c02bd24c0bb7705c931 Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Thu, 25 Apr 2019 11:01:57 +0300 Subject: [PATCH 46/59] MCOL-2178 Connector code now uses separate hton for columnstore engine. CS now uses hton->close_connection() method to release all FEP connections from MDB to ExeMgr. Refactor fetchNextRow() to remove decimal and double precision changes. --- dbcon/mysql/ha_calpont.cpp | 32 ++++++------ dbcon/mysql/ha_calpont.h | 1 + dbcon/mysql/ha_calpont_impl.cpp | 91 +++++++++++---------------------- 3 files changed, 46 insertions(+), 78 deletions(-) diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index dfbb452ef..bb4a6b0a8 100644 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -34,6 +34,7 @@ static int calpont_commit(handlerton* hton, THD* thd, bool all); static int calpont_rollback(handlerton* hton, THD* thd, bool all); static int calpont_close_connection ( handlerton* hton, THD* thd ); handlerton* calpont_hton; +handlerton* mcs_hton; // handlers creation function for hton. // Look into ha_mcs_pushdown.* for more details. @@ -79,6 +80,7 @@ static uchar* calpont_get_key(INFINIDB_SHARE* share, size_t* length, return (uchar*) share->table_name; } +// This one is unused int calpont_discover(handlerton* hton, THD* thd, TABLE_SHARE* share) { DBUG_ENTER("calpont_discover"); @@ -105,6 +107,7 @@ int calpont_discover(handlerton* hton, THD* thd, TABLE_SHARE* share) DBUG_RETURN(my_errno); } +// This f() is also unused int calpont_discover_existence(handlerton* hton, const char* db, const char* table_name) { @@ -127,24 +130,24 @@ static int columnstore_init_func(void* p) fprintf(stderr, "Columnstore: Started; Version: %s-%s\n", columnstore_version.c_str(), columnstore_release.c_str()); - calpont_hton = (handlerton*)p; + mcs_hton = (handlerton*)p; #ifndef _MSC_VER (void) pthread_mutex_init(&calpont_mutex, MY_MUTEX_INIT_FAST); #endif (void) my_hash_init(&calpont_open_tables, system_charset_info, 32, 0, 0, (my_hash_get_key) calpont_get_key, 0, 0); - calpont_hton->state = SHOW_OPTION_YES; - calpont_hton->create = calpont_create_handler; - calpont_hton->flags = HTON_CAN_RECREATE; -// calpont_hton->discover_table= calpont_discover; -// calpont_hton->discover_table_existence= calpont_discover_existence; - calpont_hton->commit = calpont_commit; - calpont_hton->rollback = calpont_rollback; - calpont_hton->close_connection = calpont_close_connection; - calpont_hton->create_group_by = create_calpont_group_by_handler; - calpont_hton->create_derived = create_columnstore_derived_handler; - calpont_hton->create_select = create_columnstore_select_handler; + mcs_hton->state = SHOW_OPTION_YES; + mcs_hton->create = calpont_create_handler; + mcs_hton->flags = HTON_CAN_RECREATE; +// mcs_hton->discover_table= calpont_discover; +// mcs_hton->discover_table_existence= calpont_discover_existence; + mcs_hton->commit = calpont_commit; + mcs_hton->rollback = calpont_rollback; + mcs_hton->close_connection = calpont_close_connection; + mcs_hton->create_group_by = create_calpont_group_by_handler; + mcs_hton->create_derived = create_columnstore_derived_handler; + mcs_hton->create_select = create_columnstore_select_handler; DBUG_RETURN(0); } @@ -282,10 +285,6 @@ int ha_calpont::open(const char* name, int mode, uint32_t test_if_locked) { DBUG_ENTER("ha_calpont::open"); - //if (!(share = get_share(name, table))) - // DBUG_RETURN(1); - //thr_lock_data_init(&share->lock,&lock,NULL); - int rc = ha_calpont_impl_open(name, mode, test_if_locked); DBUG_RETURN(rc); @@ -311,7 +310,6 @@ int ha_calpont::open(const char* name, int mode, uint32_t test_if_locked) int ha_calpont::close(void) { DBUG_ENTER("ha_calpont::close"); - //DBUG_RETURN(free_share(share)); int rc = ha_calpont_impl_close(); diff --git a/dbcon/mysql/ha_calpont.h b/dbcon/mysql/ha_calpont.h index 070f5380b..3d184f955 100644 --- a/dbcon/mysql/ha_calpont.h +++ b/dbcon/mysql/ha_calpont.h @@ -22,6 +22,7 @@ #include "ha_mcs_sysvars.h" extern handlerton* calpont_hton; +extern handlerton* mcs_hton; /** @brief INFINIDB_SHARE is a structure that will be shared among all open handlers. diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 4efe01b51..989d9ea6b 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -577,10 +577,6 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h * At a later date we should set this more intelligently * based on the result set. */ - /* MCOL-683: UTF-8 datetime no msecs is 57, this sometimes happens! */ -// if (((*f)->field_length > 19) && ((*f)->field_length != 57)) -// (*f)->field_length = strlen(tmp); - Field_varstring* f2 = (Field_varstring*)*f; f2->store(tmp, strlen(tmp), f2->charset()); break; @@ -742,29 +738,18 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h if (dl == std::numeric_limits::infinity()) continue; - //int64_t* icvp = (int64_t*)&dl; - //intColVal = *icvp; Field_float* f2 = (Field_float*)*f; // bug 3485, reserve enough space for the longest float value // -3.402823466E+38 to -1.175494351E-38, 0, and // 1.175494351E-38 to 3.402823466E+38. (*f)->field_length = 40; - //float float_val = *(float*)(&value); - //f2->store(float_val); - // WIP MCOL-2178 - //if (f2->decimals() < (uint32_t)row.getScale(s)) - //f2->dec = (uint32_t)row.getScale(s); - f2->store(dl); if ((*f)->null_ptr) *(*f)->null_ptr &= ~(*f)->null_bit; break; - - //storeNumericField(f, intColVal, colType); - //break; } case CalpontSystemCatalog::DOUBLE: @@ -781,30 +766,12 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h // 2.2250738585072014E-308 to 1.7976931348623157E+308. (*f)->field_length = 40; - //double double_val = *(double*)(&value); - //f2->store(double_val); - - - // WIP MCOL-2178 - /* - if ((f2->decimals() == DECIMAL_NOT_SPECIFIED && row.getScale(s) > 0) - || f2->decimals() < row.getScale(s)) - { - f2->dec = row.getScale(s); - }*/ - f2->store(dl); if ((*f)->null_ptr) *(*f)->null_ptr &= ~(*f)->null_bit; break; - - - //int64_t* icvp = (int64_t*)&dl; - //intColVal = *icvp; - //storeNumericField(f, intColVal, colType); - //break; } case CalpontSystemCatalog::LONGDOUBLE: @@ -821,12 +788,6 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h { 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) @@ -842,12 +803,6 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h // 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(dl)); if ((*f)->null_ptr) *(*f)->null_ptr &= ~(*f)->null_bit; @@ -1425,7 +1380,7 @@ uint32_t doUpdateDelete(THD* thd) columnAssignmentPtr->fFromCol = false; } } - // WIP MCOL-2178 + // WIP MCOL-2178 /*else if ( value->type() == Item::VARBIN_ITEM ) { String val, *str; @@ -2368,8 +2323,15 @@ int ha_calpont_impl_rnd_init(TABLE* table) MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } - #endif + + // Set this to close all outstanding FEP connections on + // client disconnect in handlerton::closecon_handlerton(). + if ( !thd_get_ha_data(thd, mcs_hton)) + { + thd_set_ha_data(thd, mcs_hton, reinterpret_cast(0x42)); + } + // prevent "create table as select" from running on slave MIGR::infinidb_vtable.hasInfiniDBTable = true; @@ -2533,9 +2495,10 @@ int ha_calpont_impl_rnd_init(TABLE* table) } // vtable mode else + // The whole section must be useless now. { - //if (!ci->cal_conn_hndl || MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) - if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) + if ( !ci->cal_conn_hndl || + MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) { ci->stats.reset(); // reset query stats ci->stats.setStartTime(); @@ -2886,14 +2849,14 @@ int ha_calpont_impl_rnd_init(TABLE* table) return 0; error: - + // CS doesn't need to close the actual sockets + // b/c it tries to reuse it running next query. if (ci->cal_conn_hndl) { sm::sm_cleanup(ci->cal_conn_hndl); ci->cal_conn_hndl = 0; } - // do we need to close all connection handle of the table map? return ER_INTERNAL_ERROR; internal_error: @@ -3038,6 +3001,7 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) MIGR::infinidb_vtable.isNewQuery = true; + // WIP MCOL-2178 // Workaround because CS doesn't reset isUnion in a normal way. if (is_pushdown_hand) { @@ -3046,15 +3010,13 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) if (get_fe_conn_info_ptr() != NULL) ci = reinterpret_cast(get_fe_conn_info_ptr()); + // WIP MCOL-2178. Won't see this state anymore. if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ORDER_BY ) { MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_SELECT_VTABLE; // flip back to normal state return rc; } -// if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_PHASE1) -// return rc; - if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE ) return rc; @@ -3167,6 +3129,8 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) // reset expressionId just in case ci->expressionId = 0; + thd_set_ha_data(thd, mcs_hton, reinterpret_cast(ci)); + return rc; } @@ -4465,7 +4429,7 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type) ci->queryState = 0; MIGR::infinidb_vtable.override_largeside_estimate = false; // MCOL-3247 Use THD::ha_data as a per-plugin per-session - // storage for cal_conn_hndl to use it later in close_connection + // storage for cal_conn_hndl to use it later in close_connection thd_set_ha_data(thd, calpont_hton, get_fe_conn_info_ptr()); } } @@ -5272,12 +5236,10 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE* * Execute the query and saves derived table query. * There is an extra handler argument so I ended up with a * new init function. The code is a copy of - * ha_calpont_impl_rnd_init() mostly. We should come up with - * a semi-universal structure that allows to save any - * extra data. + * ha_calpont_impl_rnd_init() mostly. * PARAMETERS: - * void* handler either select_ or derived_handler - * TABLE* table - table where to save the results + * mcs_handler_info* pnt to an envelope struct + * TABLE* table - dest table to put the results into * RETURN: * rc as int ***********************************************************/ @@ -5325,8 +5287,15 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } - #endif + + // Set this to close all outstanding FEP connections on + // client disconnect in handlerton::closecon_handlerton(). + if ( !thd_get_ha_data(thd, mcs_hton)) + { + thd_set_ha_data(thd, mcs_hton, reinterpret_cast(0x42)); + } + // prevent "create table as select" from running on slave MIGR::infinidb_vtable.hasInfiniDBTable = true; From b4d1cbc52928c8e36845b501d0174484940fe296 Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Mon, 20 May 2019 19:10:21 +0300 Subject: [PATCH 47/59] MCOL-2178 upstream merge forces to add explicit namespaces. Add a magic value check to avoid cleanup procedures only if needed. --- dbcon/mysql/ha_calpont_impl.cpp | 4 ++-- dbcon/mysql/ha_calpont_impl_if.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 989d9ea6b..8fe27ea0d 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 InfiniDB, Inc. + /* Copyright (C) 2014 InfiniDB, Inc. Copyright (C) 2019 MariaDB Corporaton This program is free software; you can redistribute it and/or @@ -4203,7 +4203,7 @@ int ha_calpont_impl_close_connection (handlerton* hton, THD* thd) // An ugly way. I will use ha_data w/o external_lock. // This in MCOL-2178 cal_connection_info* ci = NULL; - if(thd_get_ha_data(thd, hton)) + if(thd_get_ha_data(thd, hton) != (void*)0x42) // 0x42 is the magic CS sets when setup hton { ci = reinterpret_cast(thd_get_ha_data(thd, hton)); } diff --git a/dbcon/mysql/ha_calpont_impl_if.h b/dbcon/mysql/ha_calpont_impl_if.h index 820f8d430..190ed620b 100644 --- a/dbcon/mysql/ha_calpont_impl_if.h +++ b/dbcon/mysql/ha_calpont_impl_if.h @@ -286,6 +286,7 @@ struct cal_connection_info std::stack cal_conn_hndl_st; int queryState; CalTableMap tableMap; + std::set physTablesList; sm::tableid_t currentTable; uint32_t traceFlags; std::string queryStats; @@ -337,8 +338,8 @@ const std::string infinidb_err_msg = "\nThe query includes syntax that is not su int cp_get_plan(THD* thd, execplan::SCSEP& csep); int cp_get_table_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_table_info& ti); int cp_get_group_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_group_info& gi); -int cs_get_derived_plan(derived_handler* handler, THD* thd, SCSEP& csep); -int cs_get_select_plan(select_handler* handler, THD* thd, SCSEP& csep); +int cs_get_derived_plan(derived_handler* handler, THD* thd, execplan::SCSEP& csep); +int cs_get_select_plan(select_handler* handler, THD* thd, execplan::SCSEP& csep); int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, execplan::SCSEP& csep, bool isUnion = false, bool isPushdownHand = false); int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, execplan::SCSEP& csep, cal_group_info& gi, bool isUnion = false); void setError(THD* thd, uint32_t errcode, const std::string errmsg, gp_walk_info* gwi); From 3074b6c4b31e38b75e222ce0641592e1a5bc09ec Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Thu, 30 May 2019 21:14:48 +0300 Subject: [PATCH 48/59] MCOL-2178 Functions with constant args are processed by CS now. Fix crash in ha_calpont_impl_close_connection() Fix leak in ci.tableMap. Removed extra returns in pushdown_init to avoid crashes. create_select_handler now detects INSERT..SELECT. buildConstColFromFilter now uses any kind of filter to supply relevant columns. Remove strings used by vtable redo phase. Make FromSubQuery aware of Pushdown handlers. Changed debug_walk to work around changed Item framework. Temporary disabled derived handler and unsupported features checks. --- dbcon/mysql/ha_calpont.cpp | 6 +- dbcon/mysql/ha_calpont_execplan.cpp | 781 ++++------------------------ dbcon/mysql/ha_calpont_impl.cpp | 136 ++--- dbcon/mysql/ha_from_sub.cpp | 11 +- dbcon/mysql/ha_mcs_pushdown.cpp | 74 +-- dbcon/mysql/ha_subquery.h | 8 +- 6 files changed, 172 insertions(+), 844 deletions(-) diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index bb4a6b0a8..19c37fd73 100644 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -145,8 +145,8 @@ static int columnstore_init_func(void* p) mcs_hton->commit = calpont_commit; mcs_hton->rollback = calpont_rollback; mcs_hton->close_connection = calpont_close_connection; - mcs_hton->create_group_by = create_calpont_group_by_handler; - mcs_hton->create_derived = create_columnstore_derived_handler; + //mcs_hton->create_group_by = create_calpont_group_by_handler; + //mcs_hton->create_derived = create_columnstore_derived_handler; mcs_hton->create_select = create_columnstore_select_handler; DBUG_RETURN(0); } @@ -177,7 +177,7 @@ static int infinidb_init_func(void* p) calpont_hton->rollback = calpont_rollback; calpont_hton->close_connection = calpont_close_connection; calpont_hton->create_group_by = create_calpont_group_by_handler; - calpont_hton->create_derived = create_columnstore_derived_handler; + //calpont_hton->create_derived = create_columnstore_derived_handler; calpont_hton->create_select = create_columnstore_select_handler; DBUG_RETURN(0); diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index d97c1b303..243f2164c 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -19,7 +19,7 @@ /* * $Id: ha_calpont_execplan.cpp 9749 2013-08-15 04:00:39Z zzhu $ */ - + /** @file */ //#define DEBUG_WALK_COND #include @@ -429,40 +429,61 @@ void debug_walk(const Item* item, void* arg) '.' << ifp->field_name.str << endl; break; } - - case Item::INT_ITEM: + case Item::CONST_ITEM: { - Item_int* iip = (Item_int*)item; - cerr << "INT_ITEM: "; + switch (item->cmp_type()) + { + case INT_RESULT: + { + Item_int* iip = (Item_int*)item; + cerr << "INT_ITEM: "; - if (iip->name.length) cerr << iip->name.str << " (from name string)" << endl; - else cerr << iip->val_int() << endl; + if (iip->name.length) cerr << iip->name.str << " (from name string)" << endl; + else cerr << iip->val_int() << endl; + break; + } + case STRING_RESULT: + { + Item_string* isp = (Item_string*)item; + String val, *str = isp->val_str(&val); + string valStr; + valStr.assign(str->ptr(), str->length()); + cerr << "STRING_ITEM: >" << valStr << '<' << endl; + break; + } + case REAL_RESULT: + { + cerr << "REAL_ITEM" << endl; + break; + } + case DECIMAL_RESULT: + { + cerr << "DECIMAL_ITEM" << endl; + break; + } + case TIME_RESULT: + { + String val, *str = NULL; + Item_temporal_literal* itp = (Item_temporal_literal*)item; + str = itp->val_str(&val); + cerr << "DATE ITEM: "; + + if (str) + cerr << ": (" << str->ptr() << ')' << endl; + else + cerr << ": " << endl; + + break; + } + default: + { + cerr << ": Unknown cmp_type" << endl; + break; + } + } break; } - - case Item::STRING_ITEM: - { - Item_string* isp = (Item_string*)item; - String val, *str = isp->val_str(&val); - string valStr; - valStr.assign(str->ptr(), str->length()); - cerr << "STRING_ITEM: >" << valStr << '<' << endl; - break; - } - - case Item::REAL_ITEM: - { - cerr << "REAL_ITEM" << endl; - break; - } - - case Item::DECIMAL_ITEM: - { - cerr << "DECIMAL_ITEM" << endl; - break; - } - case Item::FUNC_ITEM: { Item_func* ifp = (Item_func*)item; @@ -514,7 +535,7 @@ void debug_walk(const Item* item, void* arg) case Item_func::BETWEEN: inp = (Item_func_opt_neg*)ifp; - if (inp->get_negated()) cerr << "not "; + if (inp->negated) cerr << "not "; cerr << "between" << " (" << ifp->functype() << ")" << endl; break; @@ -713,7 +734,8 @@ void debug_walk(const Item* item, void* arg) item_name = const_cast(isp->get_arg(0)->name.str); } else if (!item_name && isp->get_arg_count() - && isp->get_arg(0)->type() == Item::INT_ITEM) + && isp->get_arg(0)->type() == Item::CONST_ITEM + && isp->get_arg(0)->cmp_type() == INT_RESULT) { item_name = (char*)"INT||*"; } @@ -1104,21 +1126,6 @@ void debug_walk(const Item* item, void* arg) break; } - case Item::DATE_ITEM: - { - String val, *str = NULL; - Item_temporal_literal* itp = (Item_temporal_literal*)item; - str = itp->val_str(&val); - cerr << "DATE ITEM: "; - - if (str) - cerr << ": (" << str->ptr() << ')' << endl; - else - cerr << ": " << endl; - - break; - } - case Item::WINDOW_FUNC_ITEM: { Item_window_func* ifp = (Item_window_func*)item; @@ -6079,7 +6086,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, (table_ptr->derived->first_select())->print(gwi.thd, &str, QT_ORDINARY); SELECT_LEX* select_cursor = table_ptr->derived->first_select(); - FromSubQuery fromSub(gwi, select_cursor); + FromSubQuery fromSub(gwi, select_cursor, isPushdownHand); string alias(table_ptr->alias.str); fromSub.alias(lower(alias)); @@ -6202,7 +6209,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, union_gwi.thd = gwi.thd; uint32_t err = 0; - if ((err = getSelectPlan(union_gwi, *sl, plan, unionSel)) != 0) + if ((err = getSelectPlan(union_gwi, *sl, plan, unionSel, isPushdownHand)) != 0) return err; unionVec.push_back(SCEP(plan)); @@ -6417,7 +6424,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, List_iterator_fast it(select_lex.item_list); Item* item; vector funcFieldVec; - string sel_cols_in_create; + string sel_cols_in_select; bool redo = false; @@ -6469,18 +6476,13 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, { boost::shared_ptr spsc(sc); - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - string fullname; String str; ifp->print(&str, QT_ORDINARY); fullname = str.c_ptr(); - //sel_cols_in_create += fullname; if (ifp->is_autogenerated_name) // no alias { - sel_cols_in_create += fullname + " `" + escapeBackTick(str.c_ptr()) + "`"; sc->alias(fullname); } else // alias @@ -6488,7 +6490,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, if (!itemAlias.empty()) sc->alias(itemAlias); - sel_cols_in_create += fullname + " `" + escapeBackTick(sc->alias().c_str()) + "`"; } if (ifp->is_autogenerated_name) @@ -6538,10 +6539,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, String str(256); item->print(&str, QT_ORDINARY); - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += string(str.c_ptr()) + " `" + escapeBackTick(spac->alias().c_str()) + "`"; break; } @@ -6587,54 +6584,21 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, if (rc) { + // MCOL-2178 CS has to process determenistic functions with constant arguments. if (!hasNonSupportItem && !nonConstFunc(ifp) && !(parseInfo & AF_BIT) && tmpVec.size() == 0) { - if (isUnion || unionSel || gwi.subSelectType != CalpontSelectExecutionPlan::MAIN_SELECT || - parseInfo & SUB_BIT || select_lex.group_list.elements != 0) - { - srcp.reset(buildReturnedColumn(item, gwi, gwi.fatalParseError)); - gwi.returnedCols.push_back(srcp); + srcp.reset(buildReturnedColumn(item, gwi, gwi.fatalParseError)); + gwi.returnedCols.push_back(srcp); - if (ifp->name.length) - srcp->alias(ifp->name.str); + if (ifp->name.length) + srcp->alias(ifp->name.str); - continue; - } - - if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || - ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || - ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || - ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) ) - { } - else - { - redo = true; - String str; - ifp->print(&str, QT_ORDINARY); - gwi.selectCols.push_back(string(str.c_ptr()) + " " + "`" + escapeBackTick(item->name.str) + "`"); - } - - break; + continue; } - //SRCP srcp(rc); gwi.returnedCols.push_back(srcp); - - if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) - { } - else - { - String str(256); - ifp->print(&str, QT_ORDINARY); - - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += string(str.c_ptr()) + " `" + ifp->name.str + "`"; - gwi.selectCols.push_back("`" + escapeBackTick(ifp->name.str) + "`"); - } } - else // InfiniDB Non support functions still go through post process for now + else // This was a vtable post-process block { hasNonSupportItem = false; uint32_t before_size = funcFieldVec.size(); @@ -6642,13 +6606,14 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, uint32_t after_size = funcFieldVec.size(); // group by func and func in subquery can not be post processed + // pushdown handler projection functions // @bug3881. set_user_var can not be treated as constant function // @bug5716. Try to avoid post process function for union query. if ((gwi.subQuery || select_lex.group_list.elements != 0 || - !csep->unionVec().empty() || isUnion) && + !csep->unionVec().empty() || isUnion || isPushdownHand ) && !hasNonSupportItem && (after_size - before_size) == 0 && - !(parseInfo & AGG_BIT) && !(parseInfo & SUB_BIT) && - string(ifp->func_name()) != "set_user_var") + !(parseInfo & AGG_BIT) && !(parseInfo & SUB_BIT) + ) { String val, *str = ifp->val_str(&val); string valStr; @@ -6721,23 +6686,14 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, return -1; } } - - //@Bug 3021. Bypass postprocess for update and delete. - //if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) - //{} else { - // @bug 3881. Here is the real redo part. - redo = true; - // @bug 1706 - String funcStr; - ifp->print(&funcStr, QT_ORDINARY); - string valStr; - valStr.assign(funcStr.ptr(), funcStr.length()); - gwi.selectCols.push_back(valStr + " `" + escapeBackTick(ifp->name.str) + "`"); - // clear the error set by buildFunctionColumn - gwi.fatalParseError = false; - gwi.parseErrorText = ""; + Message::Args args; + args.add(ifp->func_name()); + gwi.parseErrorText = + IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORTED_FUNCTION, args); + setError(gwi.thd, ER_CHECK_NOT_IMPLEMENTED, gwi.parseErrorText, gwi); + return ER_CHECK_NOT_IMPLEMENTED; } } @@ -6770,10 +6726,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, ostringstream oss; oss << isp->value << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += oss.str(); gwi.selectCols.push_back(oss.str()); } @@ -6798,10 +6750,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, valStr.assign(str->ptr(), str->length()); string name = "'" + valStr + "'" + " " + "`" + escapeBackTick(srcp->alias().c_str()) + "`"; - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += name; gwi.selectCols.push_back(name); } @@ -6827,10 +6775,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, ostringstream oss; oss << valStr.c_str() << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += oss.str(); gwi.selectCols.push_back(oss.str()); } @@ -6862,10 +6806,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, string name = string("null `") + escapeBackTick(srcp->alias().c_str()) + string("`") ; - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += name; gwi.selectCols.push_back("null"); } @@ -6925,16 +6865,13 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, gwi.returnedCols.push_back(SRCP(rc)); String str; sub->get_select_lex()->print(gwi.thd, &str, QT_ORDINARY); - sel_cols_in_create += "(" + string(str.c_ptr()) + ")"; if (sub->name.length) { - sel_cols_in_create += "`" + escapeBackTick(sub->name.str) + "`"; gwi.selectCols.push_back(sub->name.str); } else { - sel_cols_in_create += "`" + escapeBackTick(str.c_ptr()) + "`"; gwi.selectCols.push_back("`" + escapeBackTick(str.c_ptr()) + "`"); } @@ -7116,21 +7053,14 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, gwi.returnedCols.push_back(srcp); gwi.columnMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(string(funcFieldVec[i]->field_name.str), srcp)); - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - string fullname; fullname = str.c_ptr(); - sel_cols_in_create += fullname + " `" + escapeBackTick(fullname.c_str()) + "`"; TABLE_LIST* tmp = (funcFieldVec[i]->cached_table ? funcFieldVec[i]->cached_table : 0); gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isInfiniDB())] = make_pair(1, tmp); } } - // post-process Order by list and expressions on select by redo phase1. only for vtable - // ignore ORDER BY clause for union select unit - string ord_cols = ""; // for normal select phase SRCP minSc; // min width projected column. for count(*) use // Group by list. not valid for union main query @@ -7418,13 +7348,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, { SQL_I_List order_list = select_lex.order_list; ORDER* ordercol = reinterpret_cast(order_list.first); - string create_query(MIGR::infinidb_vtable.create_vtable_query.c_ptr()); - string select_query(MIGR::infinidb_vtable.select_vtable_query.c_ptr()); - string lower_create_query(MIGR::infinidb_vtable.create_vtable_query.c_ptr()); - string lower_select_query(MIGR::infinidb_vtable.select_vtable_query.c_ptr()); - boost::algorithm::to_lower(lower_create_query); - boost::algorithm::to_lower(lower_select_query); - // check if window functions are in order by. InfiniDB process order by list if // window functions are involved, either in order by or projection. @@ -7531,7 +7454,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, else if (!isUnion) { vector fieldVec; - bool addToSel; // the following order by is just for redo phase if (!unionSel) @@ -7544,101 +7466,14 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, while (ord_item->type() == Item::REF_ITEM) ord_item = (*((Item_ref*)ord_item)->ref); - // @bug 1706. re-construct the order by item one by one - //Item* ord_item = *(ordercol->item); - if (ord_cols.length() != 0) - ord_cols += ", "; + //ReturnedColumn* rc = 0; + // check if this order by column is on the select list + //Item_func* ifp = (Item_func*)(*(ordercol->item)); + //rc = buildFunctionColumn(ifp, gwi, gwi.fatalParseError); - addToSel = true; - string fullname; - - if (ordercol->in_field_list && ordercol->counter_used) + if (ord_item->type() == Item::FUNC_ITEM) { - ostringstream oss; - oss << ordercol->counter; - ord_cols += oss.str(); - - if (ordercol->direction != ORDER::ORDER_ASC) - ord_cols += " desc"; - - continue; - } - - else if (ord_item->type() == Item::FUNC_ITEM) - { - // @bug 2621. order by alias - if (!ord_item->is_autogenerated_name && ord_item->name.length) - { - ord_cols += ord_item->name.str; - continue; - } - - // if there's group by clause or aggregate column, check to see - // if this item or the arguments is on the GB list. - ReturnedColumn* rc = 0; - // check if this order by column is on the select list - Item_func* ifp = (Item_func*)(*(ordercol->item)); - rc = buildFunctionColumn(ifp, gwi, gwi.fatalParseError); - - if (rc) - { - for (uint32_t i = 0; i < gwi.returnedCols.size(); i++) - { - if (rc && rc->operator==(gwi.returnedCols[i].get())) - { - ostringstream oss; - oss << i + 1; - ord_cols += oss.str(); - addToSel = false; - break; - } - } - } - - if (addToSel) - { - FunctionColumn* fc = dynamic_cast(rc); - - if (fc) - { - addToSel = false; - redo = true; - string ord_func = string(ifp->func_name()) + "("; - - for (uint32_t i = 0; i < fc->functionParms().size(); i++) - { - if (i != 0) - ord_func += ","; - - for (uint32_t j = 0; j < gwi.returnedCols.size(); j++) - { - if (fc->functionParms()[i]->data()->operator==(gwi.returnedCols[j].get())) - { - ord_func += "`" + escapeBackTick(gwi.returnedCols[j]->alias().c_str()) + "`"; - continue; - } - - AggregateColumn* ac = dynamic_cast(fc->functionParms()[i]->data()); - - if (ac) - { - gwi.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORT_ORDER_BY); - setError(gwi.thd, ER_CHECK_NOT_IMPLEMENTED, gwi.parseErrorText, gwi); - return ER_CHECK_NOT_IMPLEMENTED; - } - - addToSel = true; - //continue; - - } - } - - ord_func += ")"; - - if (!addToSel) - ord_cols += ord_func; - } - } + //FunctionColumn* fc = dynamic_cast(rc); } else if (ord_item->type() == Item::SUBSELECT_ITEM) { @@ -7646,7 +7481,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, setError(gwi.thd, ER_CHECK_NOT_IMPLEMENTED, emsg, gwi); return ER_CHECK_NOT_IMPLEMENTED; } - else if (ord_item->type() == Item::SUM_FUNC_ITEM) { ReturnedColumn* ac = 0; @@ -7670,38 +7504,12 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, if (!ret) continue; - if (ac->operator==(gwi.returnedCols[i].get())) - { - ostringstream oss; - oss << i + 1; - ord_cols += oss.str(); - addToSel = false; - break; - } } if (ac || !gwi.groupByCols.empty()) { - if (addToSel) - { - redo = true; - // @bug 3076. do not add the argument of aggregate function to the SELECT list, - // instead, add the whole column - String str; - ord_item->print(&str, QT_ORDINARY); - - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += str.c_ptr(); - //gwi.selectCols.push_back(" `" + string(str.c_ptr()) + "`"); - SRCP srcp(ac); - gwi.returnedCols.push_back(srcp); - ord_cols += " `" + escapeBackTick(str.c_ptr()) + "`"; - } - - if (ordercol->direction != ORDER::ORDER_ASC) - ord_cols += " desc"; + SRCP srcp(ac); + gwi.returnedCols.push_back(srcp); continue; } @@ -7710,13 +7518,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, { Item_field* field = reinterpret_cast(ord_item); ReturnedColumn* rc = buildSimpleColumn(field, gwi); - fullname = field->full_name(); -// if (field->db_name) -// fullname += string(field->db_name) + "."; -// if (field->table_name) -// fullname += string(field->table_name) + "."; -// if (field->field_name) -// fullname += string(field->field_name); for (uint32_t i = 0; i < gwi.returnedCols.size(); i++) { @@ -7728,26 +7529,13 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, continue; } - if (strcasecmp(fullname.c_str(), gwi.returnedCols[i]->alias().c_str()) == 0 || - strcasecmp(ord_item->name.str, gwi.returnedCols[i]->alias().c_str()) == 0) - { - ord_cols += string(" `") + escapeBackTick(gwi.returnedCols[i]->alias().c_str()) + '`'; - addToSel = false; - break; - } - if (sc && sc->sameColumn(rc)) { - ostringstream oss; - oss << i + 1; - ord_cols += oss.str(); - addToSel = false; break; } } } - if (addToSel) { // @bug 2719. Error out order by not on the distinct select list. if (select_lex.options & SELECT_DISTINCT) @@ -7768,13 +7556,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, return ER_CHECK_NOT_IMPLEMENTED; } - String str; - ord_item->print(&str, QT_ORDINARY); - ord_cols += str.c_ptr(); } - if (ordercol->direction != ORDER::ORDER_ASC) - ord_cols += " desc"; } } @@ -7811,14 +7594,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, if (j == gwi.returnedCols.size()) { - string fullname; - - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - fullname = str.c_ptr(); - sel_cols_in_create += fullname + " `" + escapeBackTick(fullname.c_str()) + "`"; - gwi.returnedCols.push_back(srcp); gwi.columnMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(string(fieldVec[i]->field_name.str), srcp)); TABLE_LIST* tmp = (fieldVec[i]->cached_table ? fieldVec[i]->cached_table : 0); @@ -7910,230 +7685,22 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, std::ostringstream vtb; vtb << "infinidb_vtable.$vtable_" << gwi.thd->thread_id; - // re-construct the select query and redo phase 1 - if (redo) - { - // select now() from region case. returnedCols should have minSc. - if (sel_cols_in_create.length() == 0) - { - SimpleColumn* sc = dynamic_cast(gwi.returnedCols[0].get()); - - if (sc) - sel_cols_in_create = dynamic_cast(gwi.returnedCols[0].get())->columnName(); - else - sel_cols_in_create = gwi.returnedCols[0]->alias(); - } - - // select * from derived table case - if (gwi.selectCols.empty()) - sel_cols_in_create = " * "; - - create_query = "create temporary table " + vtb.str() + " engine = aria as select " + sel_cols_in_create + " from "; - TABLE_LIST* table_ptr = select_lex.get_table_list(); - - bool firstTb = true; - - // put all tables, derived tables and views on the list - //TABLE_LIST* table_ptr = select_lex.get_table_list(); - set aliasSet; // to avoid duplicate table alias - - for (; table_ptr; table_ptr = table_ptr->next_global) - { - if (string(table_ptr->table_name.str).find("$vtable") != string::npos) - continue; - - if (table_ptr->derived) - { - if (aliasSet.find(table_ptr->alias.str) != aliasSet.end()) - continue; - - String str; - (table_ptr->derived->first_select())->print(gwi.thd, &str, QT_ORDINARY); - - if (!firstTb) - create_query += ", "; - - create_query += "(" + string(str.c_ptr()) + ") " + string(table_ptr->alias.str); - firstTb = false; - aliasSet.insert(table_ptr->alias.str); - } - else if (table_ptr->view) - { - if (aliasSet.find(table_ptr->alias.str) != aliasSet.end()) - continue; - - if (!firstTb) - create_query += ", "; - - create_query += string(table_ptr->db.str) + "." + string(table_ptr->table_name.str) + - string(" `") + escapeBackTick(table_ptr->alias.str) + string("`"); - aliasSet.insert(table_ptr->alias.str); - firstTb = false; - } - else - { - // table referenced by view is represented by viewAlias_tableAlias. - // consistent with item.cc field print. - if (table_ptr->referencing_view) - { - if (aliasSet.find(string(table_ptr->referencing_view->alias.str) + "_" + - string(table_ptr->alias.str)) != aliasSet.end()) - continue; - - if (!firstTb) - create_query += ", "; - - create_query += string(table_ptr->db.str) + "." + string(table_ptr->table_name.str) + string(" "); - create_query += string(" `") + - escapeBackTick(table_ptr->referencing_view->alias.str) + "_" + - escapeBackTick(table_ptr->alias.str) + string("`"); - aliasSet.insert(string(table_ptr->referencing_view->alias.str) + "_" + - string(table_ptr->alias.str)); - } - else - { - if (aliasSet.find(table_ptr->alias.str) != aliasSet.end()) - continue; - - if (!firstTb) - create_query += ", "; - - create_query += string(table_ptr->db.str) + "." + string(table_ptr->table_name.str) + string(" "); - create_query += string("`") + escapeBackTick(table_ptr->alias.str) + string("`"); - aliasSet.insert(table_ptr->alias.str); - } - - firstTb = false; - } - } - - - MIGR::infinidb_vtable.create_vtable_query.free(); - MIGR::infinidb_vtable.create_vtable_query.append(create_query.c_str(), create_query.length()); - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_REDO_PHASE1; // redo phase 1 - - // turn off select distinct from post process unless there're post process functions - // on the select list. - string sel_query = "select "; - - if (/*join->select_options*/select_lex.options & SELECT_DISTINCT && redo) - sel_query = "select distinct "; - else - sel_query = "select "; - - // select * from derived table... - if (gwi.selectCols.size() == 0) - sel_query += " * "; - - for (uint32_t i = 0; i < gwi.selectCols.size(); i++) - { - sel_query += gwi.selectCols[i]; - - if ( i + 1 != gwi.selectCols.size()) - sel_query += ", "; - } - - select_query.replace(lower_select_query.find("select *"), string("select *").length(), sel_query); - } - else - { - // remove order by clause in case this phase has been executed before. - // need a better fix later, like skip all the other non-optimized phase. - size_t pos = lower_select_query.find("order by"); - - if (pos != string::npos) - select_query.replace(pos, lower_select_query.length() - pos, ""); - - //select_query = "select * from " + vtb.str(); + { if (unionSel) order_list = select_lex.master_unit()->global_parameters()->order_list; ordercol = reinterpret_cast(order_list.first); - ord_cols = ""; for (; ordercol; ordercol = ordercol->next) { Item* ord_item = *(ordercol->item); - - // @bug 1706. re-construct the order by item one by one, because the ord_cols constucted so far - // is for REDO phase. - if (ord_cols.length() != 0) - ord_cols += ", "; - - if (ordercol->in_field_list && ordercol->counter_used) - { - ostringstream oss; - oss << ordercol->counter; - ord_cols += oss.str(); - } - else if (ord_item->type() == Item::NULL_ITEM) - { - // MCOL-793 Do nothing for an ORDER BY NULL - } - else if (ord_item->type() == Item::SUM_FUNC_ITEM) - { - Item_sum* ifp = (Item_sum*)(*(ordercol->item)); - ReturnedColumn* fc = buildAggregateColumn(ifp, gwi); - - for (uint32_t i = 0; i < gwi.returnedCols.size(); i++) - { - if (fc->operator==(gwi.returnedCols[i].get())) - { - ostringstream oss; - oss << i + 1; - ord_cols += oss.str(); - break; - } - } - - //continue; - } - // @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(ord_item); - string fullname; - - if (field->db_name) - fullname += string(field->db_name) + "."; - - if (field->table_name) - fullname += string(field->table_name) + "."; - - if (field->field_name.length) - fullname += string(field->field_name.str); - - uint32_t i = 0; - - for (i = 0; i < gwi.returnedCols.size(); i++) - { - SimpleColumn* sc = dynamic_cast(gwi.returnedCols[i].get()); - - if (sc && ((Item_field*)ord_item)->cached_table && - (strcasecmp(getViewName(((Item_field*)ord_item)->cached_table).c_str(), sc->viewName().c_str()) != 0)) - continue; - - if (strcasecmp(fullname.c_str(), gwi.returnedCols[i]->alias().c_str()) == 0 || - strcasecmp(ord_item->name.str, gwi.returnedCols[i]->alias().c_str()) == 0) - { - ostringstream oss; - oss << i + 1; - ord_cols += oss.str(); - break; - } - } - - if (i == gwi.returnedCols.size()) - ord_cols += string(" `") + escapeBackTick(ord_item->name.str) + '`'; - } - - else if (ord_item->name.length) + + if (ord_item->name.length) { // for union order by 1 case. For unknown reason, it doesn't show in_field_list if (ord_item->type() == Item::CONST_ITEM && ord_item->cmp_type() == INT_RESULT) { - ord_cols += ord_item->name.str; } else if (ord_item->type() == Item::SUBSELECT_ITEM) { @@ -8143,7 +7710,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, } else { - ord_cols += string(" `") + escapeBackTick(ord_item->name.str) + '`'; } } else if (ord_item->type() == Item::FUNC_ITEM) @@ -8157,7 +7723,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, { ostringstream oss; oss << i + 1; - ord_cols += oss.str(); break; } } @@ -8166,25 +7731,19 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, { String str; ord_item->print(&str, QT_ORDINARY); - ord_cols += string(str.c_ptr()); } - if (ordercol->direction != ORDER::ORDER_ASC) - ord_cols += " desc"; } } - if (ord_cols.length() > 0) // has order by + if ( gwi.orderByCols.size() ) // has order by { - MIGR::infinidb_vtable.has_order_by = true; csep->hasOrderBy(true); // To activate LimitedOrderBy if(isPushdownHand) { csep->specHandlerProcessed(true); } - ord_cols = " order by " + ord_cols; - select_query += ord_cols; } } @@ -8208,14 +7767,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, csep->limitNum(select->val_int()); } - if (unionSel && gwi.subSelectType == CalpontSelectExecutionPlan::MAIN_SELECT) - { - ostringstream limit; - limit << " limit "; - limit << csep->limitStart() << ", "; - limit << csep->limitNum(); - select_query += limit.str(); - } } } // union with explicit select at the top level @@ -8294,12 +7845,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, csep->limitStart(limitOffset); csep->limitNum(limitNum); } - else - { - ostringstream limit; - limit << " limit " << limitOffset << ", " << limitNum; - select_query += limit.str(); - } } // Pushdown queries with ORDER BY w/o explicit limit else if (isPushdownHand && csep->hasOrderBy()) @@ -8308,9 +7853,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, csep->limitNum((uint64_t) - 2); } - MIGR::infinidb_vtable.select_vtable_query.free(); - MIGR::infinidb_vtable.select_vtable_query.append(select_query.c_str(), select_query.length()); - // We don't currently support limit with correlated subquery if (csep->limitNum() != (uint64_t) - 1 && gwi.subQuery && !gwi.correlatedTbNameVec.empty()) @@ -8641,9 +8183,10 @@ ConstantColumn* buildConstColFromFilter(SimpleColumn* originalSC, continue; op = simpFilter->op(); + execplan::ReturnedColumn* rc = dynamic_cast(simpleCol); - if ( originalSC->sameColumn(dynamic_cast(simpleCol)) - && op.get()->op() == OP_EQ && constCol) + // The filter could have any kind of op + if ( originalSC->sameColumn(rc) ) { #ifdef DEBUG_WALK_COND cerr << "buildConstColFromFilter() replaced " << endl; @@ -8757,7 +8300,8 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro (table_ptr->derived->first_select())->print(gwi.thd, &str, QT_ORDINARY); SELECT_LEX* select_cursor = table_ptr->derived->first_select(); - FromSubQuery fromSub(gwi, select_cursor); + // Use Pushdown handler for subquery processing + FromSubQuery fromSub(gwi, select_cursor, true); string alias(table_ptr->alias.str); fromSub.alias(lower(alias)); @@ -8970,8 +8514,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro List_iterator_fast it(*gi.groupByFields); Item* item; vector funcFieldVec; - string sel_cols_in_create; - string sel_cols_in_select; bool redo = false; // empty rcWorkStack and ptWorkStack. They should all be empty by now. @@ -9031,18 +8573,13 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro boost::shared_ptr spcc(constCol); boost::shared_ptr spsc(sc); - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - string fullname; String str; ifp->print(&str, QT_ORDINARY); fullname = str.c_ptr(); - //sel_cols_in_create += fullname; if (ifp->is_autogenerated_name) // no alias { - sel_cols_in_create += fullname + " `" + escapeBackTick(str.c_ptr()) + "`"; sc->alias(fullname); } else // alias @@ -9050,7 +8587,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro if (!itemAlias.empty()) sc->alias(itemAlias); - sel_cols_in_create += fullname + " `" + escapeBackTick(sc->alias().c_str()) + "`"; } if (ifp->is_autogenerated_name) @@ -9113,10 +8649,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro String str(256); item->print(&str, QT_ORDINARY); - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += string(str.c_ptr()) + " `" + escapeBackTick(spac->alias().c_str()) + "`"; break; } @@ -9202,10 +8734,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro String str(256); ifp->print(&str, QT_ORDINARY); - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += string(str.c_ptr()) + " `" + ifp->name.str + "`"; gwi.selectCols.push_back("`" + escapeBackTick(ifp->name.str) + "`"); } } @@ -9346,10 +8874,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro ostringstream oss; oss << isp->value << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += oss.str(); gwi.selectCols.push_back(oss.str()); } @@ -9374,10 +8898,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro valStr.assign(str->ptr(), str->length()); string name = "'" + valStr + "'" + " " + "`" + escapeBackTick(srcp->alias().c_str()) + "`"; - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += name; gwi.selectCols.push_back(name); } @@ -9403,10 +8923,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro ostringstream oss; oss << valStr.c_str() << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += oss.str(); gwi.selectCols.push_back(oss.str()); } @@ -9497,19 +9013,13 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro rc->alias(sub->name.str); gwi.returnedCols.push_back(SRCP(rc)); - String str; - sub->get_select_lex()->print(gwi.thd, &str, QT_ORDINARY); - sel_cols_in_create += "(" + string(str.c_ptr()) + ")"; if (sub->name.length) { - sel_cols_in_create += "`" + escapeBackTick(sub->name.str) + "`"; gwi.selectCols.push_back(sub->name.str); } else { - sel_cols_in_create += "`" + escapeBackTick(str.c_ptr()) + "`"; - gwi.selectCols.push_back("`" + escapeBackTick(str.c_ptr()) + "`"); } break; @@ -9689,12 +9199,8 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro gwi.returnedCols.push_back(srcp); gwi.columnMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(string(funcFieldVec[i]->field_name.str), srcp)); - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - string fullname; fullname = str.c_ptr(); - sel_cols_in_create += fullname + " `" + escapeBackTick(fullname.c_str()) + "`"; TABLE_LIST* tmp = (funcFieldVec[i]->cached_table ? funcFieldVec[i]->cached_table : 0); gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isInfiniDB())] = make_pair(1, tmp); @@ -9993,12 +9499,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) { ORDER* ordercol = reinterpret_cast(gi.groupByOrder); - string create_query(MIGR::infinidb_vtable.create_vtable_query.c_ptr()); - string select_query(MIGR::infinidb_vtable.select_vtable_query.c_ptr()); - string lower_create_query(MIGR::infinidb_vtable.create_vtable_query.c_ptr()); - string lower_select_query(MIGR::infinidb_vtable.select_vtable_query.c_ptr()); - boost::algorithm::to_lower(lower_create_query); - boost::algorithm::to_lower(lower_select_query); // check if window functions are in order by. InfiniDB process order by list if @@ -10235,30 +9735,11 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro std::ostringstream vtb; vtb << "infinidb_vtable.$vtable_" << gwi.thd->thread_id; - //vtb << "$vtable_" << gwi.thd->thread_id; // re-construct the select query and redo phase 1 if (redo) { - // select now() from region case. returnedCols should have minSc. - if (sel_cols_in_create.length() == 0) - { - SimpleColumn* sc = dynamic_cast(gwi.returnedCols[0].get()); - - if (sc) - sel_cols_in_create = dynamic_cast(gwi.returnedCols[0].get())->columnName(); - else - sel_cols_in_create = gwi.returnedCols[0]->alias(); - } - - // select * from derived table case - if (gwi.selectCols.empty()) - sel_cols_in_create = " * "; - - create_query = "create temporary table " + vtb.str() + " engine = aria as select " + sel_cols_in_create + " from "; TABLE_LIST* table_ptr = gi.groupByTables; - bool firstTb = true; - // put all tables, derived tables and views on the list //TABLE_LIST* table_ptr = select_lex.get_table_list(); set aliasSet; // to avoid duplicate table alias @@ -10273,14 +9754,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro if (aliasSet.find(table_ptr->alias.str) != aliasSet.end()) continue; - String str; - (table_ptr->derived->first_select())->print(gwi.thd, &str, QT_ORDINARY); - - if (!firstTb) - create_query += ", "; - - create_query += "(" + string(str.c_ptr()) + ") " + string(table_ptr->alias.str); - firstTb = false; aliasSet.insert(table_ptr->alias.str); } else if (table_ptr->view) @@ -10288,13 +9761,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro if (aliasSet.find(table_ptr->alias.str) != aliasSet.end()) continue; - if (!firstTb) - create_query += ", "; - - create_query += string(table_ptr->db.str) + "." + string(table_ptr->table_name.str) + - string(" `") + escapeBackTick(table_ptr->alias.str) + string("`"); aliasSet.insert(table_ptr->alias.str); - firstTb = false; } else { @@ -10306,13 +9773,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro string(table_ptr->alias.str)) != aliasSet.end()) continue; - if (!firstTb) - create_query += ", "; - - create_query += string(table_ptr->db.str) + "." + string(table_ptr->table_name.str) + string(" "); - create_query += string(" `") + - escapeBackTick(table_ptr->referencing_view->alias.str) + "_" + - escapeBackTick(table_ptr->alias.str) + string("`"); aliasSet.insert(string(table_ptr->referencing_view->alias.str) + "_" + string(table_ptr->alias.str)); } @@ -10321,83 +9781,31 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro if (aliasSet.find(table_ptr->alias.str) != aliasSet.end()) continue; - if (!firstTb) - create_query += ", "; - - create_query += string(table_ptr->db.str) + "." + string(table_ptr->table_name.str) + string(" "); - create_query += string("`") + escapeBackTick(table_ptr->alias.str) + string("`"); aliasSet.insert(table_ptr->alias.str); } - firstTb = false; } } - - MIGR::infinidb_vtable.create_vtable_query.free(); - MIGR::infinidb_vtable.create_vtable_query.append(create_query.c_str(), create_query.length()); - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_REDO_PHASE1; // redo phase 1 - - // turn off select distinct from post process unless there're post process functions - // on the select list. - string sel_query = "select "; - - if (gi.groupByDistinct && redo) - sel_query = "select distinct "; - else - sel_query = "select "; - - // select * from derived table... - if (gwi.selectCols.size() == 0) - sel_query += " * "; - - for (uint32_t i = 0; i < gwi.selectCols.size(); i++) - { - sel_query += gwi.selectCols[i]; - - if ( i + 1 != gwi.selectCols.size()) - sel_query += ", "; - } - - //select_query.replace(lower_select_query.find("select *"), string("select *").length(), sel_query); } else { // remove order by clause in case this phase has been executed before. // need a better fix later, like skip all the other non-optimized phase. - size_t pos = lower_select_query.find("order by"); - if (pos != string::npos) - select_query.replace(pos, lower_select_query.length() - pos, ""); - - //select_query = "select * from " + vtb.str(); // MCOL-1052 if (unionSel) { ordercol = reinterpret_cast(gi.groupByOrder); - //order_list = gi.groupByOrder; } else ordercol = 0; - ord_cols = ""; - for (; ordercol; ordercol = ordercol->next) { Item* ord_item = *(ordercol->item); - // @bug 1706. re-construct the order by item one by one, because the ord_cols constucted so far - // is for REDO phase. - if (ord_cols.length() != 0) - ord_cols += ", "; - - if (ordercol->in_field_list && ordercol->counter_used) - { - ostringstream oss; - oss << ordercol->counter; - ord_cols += oss.str(); - } - else if (ord_item->type() == Item::NULL_ITEM) + if (ord_item->type() == Item::NULL_ITEM) { // MCOL-793 Do nothing for an ORDER BY NULL } @@ -10507,7 +9915,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro if ( gwi.orderByCols.size() ) // has order by { - MIGR::infinidb_vtable.has_order_by = true; csep->hasOrderBy(true); csep->specHandlerProcessed(true); } @@ -10534,10 +9941,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro csep->limitStart(((Item_int*)gi.groupByTables->select_lex->offset_limit)->val_int()); } - // WIP MCOL-2178 - //MIGR::infinidb_vtable.select_vtable_query.free(); - //MIGR::infinidb_vtable.select_vtable_query.append(select_query.c_str(), select_query.length()); - // We don't currently support limit with correlated subquery if (csep->limitNum() != (uint64_t) - 1 && gwi.subQuery && !gwi.correlatedTbNameVec.empty()) diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 8fe27ea0d..fb4e6bffa 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -1515,7 +1515,6 @@ uint32_t doUpdateDelete(THD* thd) setError(thd, ER_INTERNAL_ERROR, logging::IDBErrorInfo::instance()->errorMsg(ERR_WF_UPDATE)); return ER_CHECK_NOT_IMPLEMENTED; - //return 0; } else { @@ -1594,7 +1593,6 @@ uint32_t doUpdateDelete(THD* thd) } catch (IDBExcept& ie) { -// setError(thd, ER_UNKNOWN_TABLE, ie.what()); setError(thd, ER_INTERNAL_ERROR, ie.what()); return ER_INTERNAL_ERROR; } @@ -1710,7 +1708,7 @@ uint32_t doUpdateDelete(THD* thd) //@Bug 2808 Error out on order by or limit clause //@bug5096. support dml limit. - if (/*( thd->lex->first_select_lex()->explicit_limit ) || */( thd->lex->first_select_lex()->order_list.elements != 0 ) ) + if (( thd->lex->first_select_lex()->order_list.elements != 0 ) ) { string emsg("DML Statement with order by clause is not currently supported."); thd->raise_error_printf(ER_INTERNAL_ERROR, emsg.c_str()); @@ -2348,20 +2346,10 @@ int ha_calpont_impl_rnd_init(TABLE* table) thd->lex->sql_command == SQLCOM_LOAD)) return 0; - // @bug 3005. if the table is not $vtable, then this could be a UDF defined on the connector. - // watch this for other complications - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE && - string(table->s->table_name.str).find("$vtable") != 0) - return 0; - // return error is error status is already set if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR) return ER_INTERNAL_ERROR; - // by pass the extra union trips. return 0 - if (MIGR::infinidb_vtable.isUnion && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) - return 0; - // @bug 2232. Basic SP support. Error out non support sp cases. // @bug 3939. Only error out for sp with select. Let pass for alter table in sp. if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) @@ -2371,11 +2359,6 @@ int ha_calpont_impl_rnd_init(TABLE* table) return ER_INTERNAL_ERROR; } - // mysql reads table twice for order by - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_PHASE1 || - MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ORDER_BY) - return 0; - if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE ) return 0; @@ -2392,12 +2375,6 @@ int ha_calpont_impl_rnd_init(TABLE* table) idbassert(ci != 0); - // MySQL sometimes calls rnd_init multiple times, plan should only be - // generated and sent once. - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE && - !MIGR::infinidb_vtable.isNewQuery) - return 0; - if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD) { force_close_fep_conn(thd, ci); @@ -2491,7 +2468,13 @@ int ha_calpont_impl_rnd_init(TABLE* table) // for ExeMgr logging sqltext. only log once for the query although multi plans may be sent if (ci->tableMap.size() == 1) + { ti.csep->data(idb_mysql_query_str(thd)); + } + else + { + ti.csep->data(""); + } } // vtable mode else @@ -2595,6 +2578,7 @@ int ha_calpont_impl_rnd_init(TABLE* table) return 0; // @bug 2547. don't need to send the plan if it's impossible where for all unions. + // WIP MCOL-2178 This singleton attribute could be a problem if (MIGR::infinidb_vtable.impossibleWhereOnUnion) return 0; @@ -3115,10 +3099,6 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) ti.tpl_ctx = 0; - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE && - MIGR::infinidb_vtable.has_order_by) - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ORDER_BY; - ci->tableMap[table] = ti; // push warnings from CREATE phase @@ -4158,15 +4138,6 @@ int ha_calpont_impl_commit (handlerton* hton, THD* thd, bool all) int ha_calpont_impl_rollback (handlerton* hton, THD* thd, bool all) { - // @bug 1738. no need to rollback for select. This is to avoid concurrent session - // conflict because DML is not thread safe. - //comment out for bug 3874. Select should never come to rollback. If there is no active transaction, - //rollback in DMLProc is not doing anything anyway - //if (!(current_thd->variables.option_bits & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) - //{ - // return 0; - //} - if (get_fe_conn_info_ptr() == NULL) set_fe_conn_info_ptr((void*)new cal_connection_info()); @@ -4176,7 +4147,6 @@ int ha_calpont_impl_rollback (handlerton* hton, THD* thd, bool all) { ci->dmlProc = new MessageQueueClient("DMLProc"); - //cout << "rollback starts a client " << ci->dmlProc << " for session " << thd->thread_id << endl; } int rc = ha_calpont_impl_rollback_(hton, thd, all, *ci); @@ -4225,6 +4195,8 @@ int ha_calpont_impl_close_connection (handlerton* hton, THD* thd) ci->cal_conn_hndl = 0; } + thd_set_ha_data(thd, hton, NULL); + return rc; } @@ -4357,12 +4329,6 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type) string alias; alias.assign(table->alias.ptr(), table->alias.length()); IDEBUG( cout << "external_lock for " << alias << endl ); - idbassert((MIGR::infinidb_vtable.vtable_state >= MIGR::INFINIDB_INIT_CONNECT && - MIGR::infinidb_vtable.vtable_state <= MIGR::INFINIDB_REDO_QUERY) || - MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR); - - if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT ) - return 0; if (get_fe_conn_info_ptr() == NULL) set_fe_conn_info_ptr((void*)new cal_connection_info()); @@ -4371,18 +4337,15 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type) if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD) { + ci->physTablesList.clear(); + ci->tableMap.clear(); force_close_fep_conn(thd, ci); return 0; } - CalTableMap::iterator mapiter = ci->tableMap.find(table); -#ifdef _MSC_VER - //FIXME: fix this! (must be related to F_UNLCK define in winport) - if (mapiter != ci->tableMap.end() && lock_type == 0) // make sure it's the release lock (2nd) call -#else + CalTableMap::iterator mapiter = ci->tableMap.find(table); if (mapiter != ci->tableMap.end() && lock_type == 2) // make sure it's the release lock (2nd) call -#endif { // table mode if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) @@ -4411,11 +4374,26 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type) { push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, infinidb_autoswitch_warning.c_str()); } + // MCOL-2178 Check for tableMap size to set this only once. ci->queryState = 0; } - else // vtable mode + ci->tableMap.erase(table); + } + else + { + if (lock_type == 0) { - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE) + ci->physTablesList.insert(table); + } + else if (lock_type == 2) + { + std::set::iterator iter = ci->physTablesList.find(table); + if ( iter != ci->physTablesList.end() ) + { + ci->physTablesList.erase(table); + } + + if ( iter != ci->physTablesList.end() && ci->physTablesList.empty() ) { if (!ci->cal_conn_hndl) return 0; @@ -4430,11 +4408,11 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type) MIGR::infinidb_vtable.override_largeside_estimate = false; // MCOL-3247 Use THD::ha_data as a per-plugin per-session // storage for cal_conn_hndl to use it later in close_connection - thd_set_ha_data(thd, calpont_hton, get_fe_conn_info_ptr()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + ci->tableMap.clear(); } - } - ci->tableMap.erase(table); + } } return 0; @@ -4495,11 +4473,6 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR) return ER_INTERNAL_ERROR; - // MCOL-1052 - // by pass the extra union trips. return 0 - //if (MIGR::infinidb_vtable.isUnion && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) - // return 0; - // @bug 2232. Basic SP support. Error out non support sp cases. // @bug 3939. Only error out for sp with select. Let pass for alter table in sp. if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) @@ -4521,12 +4494,6 @@ 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. - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE && - !MIGR::infinidb_vtable.isNewQuery) - return 0; - if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD) { force_close_fep_conn(thd, ci); @@ -4660,6 +4627,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE // send plan whenever group_init is called int status = cp_get_group_plan(thd, csep, gi); + // WIP MCOL-2178 This could be a problem if (status > 0) goto internal_error; else if (status < 0) @@ -5271,7 +5239,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) //check whether the system is ready to process statement. #ifndef _MSC_VER static DBRM dbrm(true); - bool bSystemQueryReady = dbrm.getSystemQueryReady(); + int bSystemQueryReady = dbrm.getSystemQueryReady(); if (bSystemQueryReady == 0) { @@ -5299,18 +5267,6 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) // prevent "create table as select" from running on slave MIGR::infinidb_vtable.hasInfiniDBTable = true; - /* If this node is the slave, ignore DML to IDB tables */ - if (thd->slave_thread && ( - thd->lex->sql_command == SQLCOM_INSERT || - thd->lex->sql_command == SQLCOM_INSERT_SELECT || - thd->lex->sql_command == SQLCOM_UPDATE || - thd->lex->sql_command == SQLCOM_UPDATE_MULTI || - thd->lex->sql_command == SQLCOM_DELETE || - thd->lex->sql_command == SQLCOM_DELETE_MULTI || - thd->lex->sql_command == SQLCOM_TRUNCATE || - thd->lex->sql_command == SQLCOM_LOAD)) - return 0; - // return error is error status is already set if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR) return ER_INTERNAL_ERROR; @@ -5327,10 +5283,14 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) // mysql reads table twice for order by if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_PHASE1 || MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ORDER_BY) + { return 0; + } if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE ) + { return 0; + } //Update and delete code if ( ((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_DELETE) || ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) || ((thd->lex)->sql_command == SQLCOM_UPDATE_MULTI)) @@ -5347,12 +5307,6 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) idbassert(ci != 0); - // MySQL sometimes calls rnd_init multiple times, plan should only be - // generated and sent once. - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE && - !MIGR::infinidb_vtable.isNewQuery) - return 0; - if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD) { if (ci->cal_conn_hndl) @@ -5495,17 +5449,19 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) dh = reinterpret_cast(handler_info->hndl_ptr); status = cs_get_derived_plan(dh, thd, csep); } + + std::cout << "pushdown_init get_plan status " << status << std::endl; - // WIP MCOL-2121 Find a way to return an actual error - // It either ends up with 42 or other error status - if (status > 0) + // Return an error to avoid MDB crash later in end_statement + if (status != 0) goto internal_error; - else if (status < 0) - return 0; + std::cout << "pushdown_init impossibleWhereOnUnion " << status << std::endl; // @bug 2547. don't need to send the plan if it's impossible where for all unions. if (MIGR::infinidb_vtable.impossibleWhereOnUnion) + { return 0; + } string query; query.assign(idb_mysql_query_str(thd)); diff --git a/dbcon/mysql/ha_from_sub.cpp b/dbcon/mysql/ha_from_sub.cpp index 94f4e1d18..2c2a12ec5 100644 --- a/dbcon/mysql/ha_from_sub.cpp +++ b/dbcon/mysql/ha_from_sub.cpp @@ -322,9 +322,12 @@ ParseTree* setDerivedFilter(THD* thd, ParseTree*& n, FromSubQuery::FromSubQuery(gp_walk_info& gwip) : SubQuery(gwip) {} -FromSubQuery::FromSubQuery(gp_walk_info& gwip, SELECT_LEX* sub) : - SubQuery(gwip), - fFromSub(sub) +FromSubQuery::FromSubQuery(gp_walk_info& gwip, + SELECT_LEX* sub, + bool isPushdownHandler) : + SubQuery(gwip), + fFromSub(sub), + fPushdownHand(isPushdownHandler) {} FromSubQuery::~FromSubQuery() @@ -345,7 +348,7 @@ SCSEP FromSubQuery::transform() gwi.viewName = fGwip.viewName; csep->derivedTbAlias(fAlias); // always lower case - if (getSelectPlan(gwi, *fFromSub, csep) != 0) + if (getSelectPlan(gwi, *fFromSub, csep, fPushdownHand) != 0) { fGwip.fatalParseError = true; diff --git a/dbcon/mysql/ha_mcs_pushdown.cpp b/dbcon/mysql/ha_mcs_pushdown.cpp index 489751795..93a3fee23 100644 --- a/dbcon/mysql/ha_mcs_pushdown.cpp +++ b/dbcon/mysql/ha_mcs_pushdown.cpp @@ -210,33 +210,9 @@ static derived_handler* create_columnstore_derived_handler(THD* thd, TABLE_LIST *derived) { ha_columnstore_derived_handler* handler = NULL; - handlerton *ht= 0; SELECT_LEX_UNIT *unit= derived->derived; - /* //if ( MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_DISABLE_VTABLE ) -// WIP MCOL-2178 -// && MIGR::infinidb_vtable_mode != 0 ) - { - return 0; - }*/ - - for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select()) - { - if (!(sl->join)) - return 0; - for (TABLE_LIST *tbl= sl->join->tables_list; tbl; tbl= tbl->next_local) - { - if (!tbl->table) - return 0; - // Same handlerton type check. - if (!ht) - ht= tbl->table->file->partition_ht(); - else if (ht != tbl->table->file->partition_ht()) - return 0; - } - } - bool unsupported_feature = false; { SELECT_LEX select_lex = *unit->first_select(); @@ -253,7 +229,7 @@ create_columnstore_derived_handler(THD* thd, TABLE_LIST *derived) if ( icp ) { - icp->traverse_cond(check_walk, &unsupported_feature, Item::POSTFIX); + //icp->traverse_cond(check_walk, &unsupported_feature, Item::POSTFIX); } } @@ -470,36 +446,21 @@ static select_handler* create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) { ha_columnstore_select_handler* handler = NULL; - handlerton *ht= 0; - - /* - // Return if vtable enabled. - //if ( MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_DISABLE_VTABLE ) -// WIP MCOL-2178 -// && MIGR::infinidb_vtable_mode != 0 ) - { - return 0; - }*/ - - for (SELECT_LEX* sl = select_lex;sl; sl= sl->next_select()) - { - if (!(sl->join)) - return 0; - for (TABLE_LIST *tbl= sl->join->tables_list; tbl; tbl= tbl->next_local) - { - if (!tbl->table) - return 0; - // Same handlerton type check. - if (!ht) - ht= tbl->table->file->partition_ht(); - else if (ht != tbl->table->file->partition_ht()) - return 0; - } - } bool unsupported_feature = false; + // Select_handler use the short-cut that effectively disables + // INSERT..SELECT and LDI + if ( (thd->lex)->sql_command == SQLCOM_INSERT_SELECT + || (thd->lex)->sql_command == SQLCOM_CREATE_TABLE ) + + { + unsupported_feature = true; + } + // Impossible HAVING or WHERE - if ( ( select_lex->having && select_lex->having_value == Item::COND_FALSE ) + // WIP replace with function call + if ( unsupported_feature + || ( select_lex->having && select_lex->having_value == Item::COND_FALSE ) || ( select_lex->cond_count > 0 && select_lex->cond_value == Item::COND_FALSE ) ) { @@ -521,7 +482,7 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) if ( where_icp ) { - where_icp->traverse_cond(check_walk, &unsupported_feature, Item::POSTFIX); + //where_icp->traverse_cond(check_walk, &unsupported_feature, Item::POSTFIX); } // Looking for JOIN with ON expression through @@ -532,7 +493,7 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) if(table_ptr->on_expr) { on_icp = reinterpret_cast(table_ptr->on_expr); - on_icp->traverse_cond(check_walk, &unsupported_feature, Item::POSTFIX); + //on_icp->traverse_cond(check_walk, &unsupported_feature, Item::POSTFIX); } } @@ -543,7 +504,7 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) unsupported_feature = true; } } - + if (!unsupported_feature) { handler = new ha_columnstore_select_handler(thd, select_lex); @@ -571,7 +532,8 @@ ha_columnstore_select_handler::ha_columnstore_select_handler(THD *thd, * select_handler constructor ***********************************************************/ ha_columnstore_select_handler::~ha_columnstore_select_handler() -{} +{ +} /*@brief Initiate the query for select_handler */ /*********************************************************** diff --git a/dbcon/mysql/ha_subquery.h b/dbcon/mysql/ha_subquery.h index b008b4fcd..b201e2fe3 100644 --- a/dbcon/mysql/ha_subquery.h +++ b/dbcon/mysql/ha_subquery.h @@ -45,7 +45,10 @@ namespace cal_impl_if class SubQuery { public: - SubQuery(gp_walk_info& gwip) : fGwip(gwip), fCorrelated(false) {} + SubQuery(gp_walk_info& gwip) : + fGwip(gwip), + fCorrelated(false) + {} virtual ~SubQuery() {} virtual gp_walk_info& gwip() const { @@ -178,7 +181,7 @@ class FromSubQuery : public SubQuery { public: FromSubQuery(gp_walk_info&); - FromSubQuery(gp_walk_info&, SELECT_LEX* fromSub); + FromSubQuery(gp_walk_info&, SELECT_LEX* fromSub, bool isPushdownHand=false); ~FromSubQuery(); const SELECT_LEX* fromSub() const { @@ -200,6 +203,7 @@ public: private: SELECT_LEX* fFromSub; std::string fAlias; + bool fPushdownHand; }; class SelectSubQuery : public SubQuery From a9c72675ba703662c76e7de109491e6e580631dd Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Tue, 11 Jun 2019 00:36:16 +0300 Subject: [PATCH 49/59] MCOL-2178 Fixed MDB crash with setError() operating with empty gwi. FromSubQuery() is no pushdown aware. Actualize OUTER_JOIN_DEBUG section in ha_calpont_execplan.cpp to be used with 10.4. Enabled derivedTableOptimization() for select handler. --- dbcon/ddlpackage/CMakeLists.txt | 3 - dbcon/mysql/ha_calpont_execplan.cpp | 88 +++++++++++++++-------------- dbcon/mysql/ha_calpont_impl.cpp | 2 +- 3 files changed, 46 insertions(+), 47 deletions(-) diff --git a/dbcon/ddlpackage/CMakeLists.txt b/dbcon/ddlpackage/CMakeLists.txt index 084aeeac0..8bdc68b1e 100644 --- a/dbcon/ddlpackage/CMakeLists.txt +++ b/dbcon/ddlpackage/CMakeLists.txt @@ -11,9 +11,6 @@ ADD_CUSTOM_COMMAND( set_source_files_properties(ddl-scan.cpp PROPERTIES COMPILE_FLAGS -Wno-sign-compare) -# Parser puts extra info to stderr. -MY_CHECK_AND_SET_COMPILER_FLAG("-DYYDEBUG=1" DEBUG) - ########### next target ############### ADD_LIBRARY(ddlpackage SHARED diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index 243f2164c..3526a2175 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -5399,7 +5399,7 @@ void gp_walk(const Item* item, void* arg) { vector fieldVec; uint16_t parseInfo = 0; - parse_item(it, fieldVec, gwip->fatalParseError, parseInfo); + parse_item(it, fieldVec, gwip->fatalParseError, parseInfo, gwip); if (parseInfo & CORRELATED) { @@ -5794,7 +5794,6 @@ void parse_item (Item* item, vector& field_vec, for (uint32_t i = 0; i < isp->argument_count(); i++) parse_item(isp->arguments()[i], field_vec, hasNonSupportItem, parseInfo, gwi); -// parse_item(sfitempp[i], field_vec, hasNonSupportItem, parseInfo); break; } @@ -5805,7 +5804,7 @@ void parse_item (Item* item, vector& field_vec, Item* cond_item; while ((cond_item = it++)) - parse_item(cond_item, field_vec, hasNonSupportItem, parseInfo); + parse_item(cond_item, field_vec, hasNonSupportItem, parseInfo, gwi); break; } @@ -6086,7 +6085,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, (table_ptr->derived->first_select())->print(gwi.thd, &str, QT_ORDINARY); SELECT_LEX* select_cursor = table_ptr->derived->first_select(); - FromSubQuery fromSub(gwi, select_cursor, isPushdownHand); + FromSubQuery fromSub(gwi, select_cursor, false, isPushdownHand); string alias(table_ptr->alias.str); fromSub.alias(lower(alias)); @@ -6289,62 +6288,63 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, #ifdef OUTER_JOIN_DEBUG List* tables = &(select_lex.top_join_list); List_iterator_fast ti(*tables); - //TABLE_LIST *inner; - //TABLE_LIST **table= (TABLE_LIST **)gwi.thd->alloc(sizeof(TABLE_LIST*) * tables->elements); - //for (TABLE_LIST **t= table + (tables->elements - 1); t >= table; t--) - // *t= ti++; - //DBUG_ASSERT(tables->elements >= 1); + TABLE_LIST **table= (TABLE_LIST **)gwi.thd->alloc(sizeof(TABLE_LIST*) * tables->elements); + for (TABLE_LIST **t= table + (tables->elements - 1); t >= table; t--) + *t= ti++; - //TABLE_LIST **end= table + tables->elements; - //for (TABLE_LIST **tbl= table; tbl < end; tbl++) - TABLE_LIST* curr; + DBUG_ASSERT(tables->elements >= 1); - while ((curr = ti++)) + TABLE_LIST **end= table + tables->elements; + for (TABLE_LIST **tbl= table; tbl < end; tbl++) { - TABLE_LIST* curr = *tbl; + TABLE_LIST* curr; - if (curr->table_name) - cerr << curr->table_name << " "; - else - cerr << curr->alias << endl; - - if (curr->outer_join) - cerr << " is inner table" << endl; - else if (curr->straight) - cerr << "straight_join" << endl; - else - cerr << "join" << endl; - - if (curr->nested_join) + while ((curr = ti++)) { - List* inners = &(curr->nested_join->join_list); - List_iterator_fast li(*inners); - TABLE_LIST** inner = (TABLE_LIST**)gwi.thd->alloc(sizeof(TABLE_LIST*) * inners->elements); + TABLE_LIST* curr = *tbl; - for (TABLE_LIST** t = inner + (inners->elements - 1); t >= inner; t--) - *t = li++; + if (curr->table_name.length) + cerr << curr->table_name.str << " "; + else + cerr << curr->alias.str << endl; - TABLE_LIST** end1 = inner + inners->elements; + if (curr->outer_join) + cerr << " is inner table" << endl; + else if (curr->straight) + cerr << "straight_join" << endl; + else + cerr << "join" << endl; - for (TABLE_LIST** tb = inner; tb < end1; tb++) + if (curr->nested_join) { - TABLE_LIST* curr1 = *tb; - cerr << curr1->alias << endl; + List* inners = &(curr->nested_join->join_list); + List_iterator_fast li(*inners); + TABLE_LIST** inner = (TABLE_LIST**)gwi.thd->alloc(sizeof(TABLE_LIST*) * inners->elements); - if (curr1->sj_on_expr) + for (TABLE_LIST** t = inner + (inners->elements - 1); t >= inner; t--) + *t = li++; + + TABLE_LIST** end1 = inner + inners->elements; + + for (TABLE_LIST** tb = inner; tb < end1; tb++) { - curr1->sj_on_expr->traverse_cond(debug_walk, &gwi, Item::POSTFIX); + TABLE_LIST* curr1 = *tb; + cerr << curr1->alias.str << endl; + + if (curr1->sj_on_expr) + { + curr1->sj_on_expr->traverse_cond(debug_walk, &gwi, Item::POSTFIX); + } } } - } - if (curr->sj_on_expr) - { - curr->sj_on_expr->traverse_cond(debug_walk, &gwi, Item::POSTFIX); + if (curr->sj_on_expr) + { + curr->sj_on_expr->traverse_cond(debug_walk, &gwi, Item::POSTFIX); + } } } - #endif uint32_t failed = buildOuterJoin(gwi, select_lex); @@ -8137,6 +8137,8 @@ int cs_get_select_plan(select_handler* handler, THD* thd, SCSEP& csep) cerr << *csep << endl ; cerr << "-------------- EXECUTION PLAN END --------------\n" << endl; #endif + // Derived table projection and filter optimization. + derivedTableOptimization(csep); return 0; } diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index fb4e6bffa..c7c15ec8e 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -1757,7 +1757,7 @@ uint32_t doUpdateDelete(THD* thd) gwi.clauseType = WHERE; - if (getSelectPlan(gwi, select_lex, updateCP) != 0) //@Bug 3030 Modify the error message for unsupported functions + if (getSelectPlan(gwi, select_lex, updateCP, false, true) != 0) //@Bug 3030 Modify the error message for unsupported functions { if (MIGR::infinidb_vtable.isUpdateWithDerive) { From 7d5275e1bd70fd278d8b44553bd4a42259906c01 Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Mon, 15 Jul 2019 21:58:45 +0300 Subject: [PATCH 50/59] MCOL-2178 CS now doesn't initiate a scan when MDB explicitly set scan to false in rnd_init(). sortItemIsInGroupRec() now has a base case for Item_Field and this prevents unbound recursion. Fixes fromSub() call with incorrect number of arguments. CS now doesn't ask for statistics unless a user explicitly asks for it using calsettrace(). --- dbcon/mysql/ha_calpont.cpp | 6 ++- dbcon/mysql/ha_calpont_execplan.cpp | 6 ++- dbcon/mysql/ha_calpont_impl.cpp | 10 +++- dbcon/mysql/sm.cpp | 84 +++++++++++++++-------------- dbcon/mysql/sm.h | 2 +- 5 files changed, 62 insertions(+), 46 deletions(-) diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index 19c37fd73..50b69c297 100644 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -527,7 +527,11 @@ int ha_calpont::rnd_init(bool scan) { DBUG_ENTER("ha_calpont::rnd_init"); - int rc = ha_calpont_impl_rnd_init(table); + int rc = 0; + if(scan) + { + rc = ha_calpont_impl_rnd_init(table); + } DBUG_RETURN(rc); } diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index 3526a2175..e5c58cdcb 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -273,6 +273,10 @@ bool sortItemIsInGroupRec(Item* sort_item, Item* group_item) Item_ref* ifp_sort_ref = reinterpret_cast(sort_item); found = sortItemIsInGroupRec(*ifp_sort_ref->ref, group_item); } + else if (!found && sort_item->type() == Item::FIELD_ITEM) + { + return found; + } // seeking for a group_item match for (uint32_t i = 0; !found && i < ifp_sort->argument_count(); i++) @@ -6085,7 +6089,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, (table_ptr->derived->first_select())->print(gwi.thd, &str, QT_ORDINARY); SELECT_LEX* select_cursor = table_ptr->derived->first_select(); - FromSubQuery fromSub(gwi, select_cursor, false, isPushdownHand); + FromSubQuery fromSub(gwi, select_cursor, isPushdownHand); string alias(table_ptr->alias.str); fromSub.alias(lower(alias)); diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index c7c15ec8e..83cddcb4c 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -3062,7 +3062,10 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) try { - sm::tpl_close(ti.tpl_ctx, &hndl, ci->stats); + { + bool ask_4_stats = (ci->traceFlags) ? true : false; + sm::tpl_close(ti.tpl_ctx, &hndl, ci->stats, ask_4_stats); + } // set conn hndl back. could be changed in tpl_close if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) @@ -5124,7 +5127,10 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE* { if(hndl) { - sm::tpl_close(ti.tpl_ctx, &hndl, ci->stats, clearScanCtx); + { + bool ask_4_stats = (ci->traceFlags) ? true : false; + sm::tpl_close(ti.tpl_ctx, &hndl, ci->stats, ask_4_stats, clearScanCtx); + } // Normaly stats variables are set in external_lock method but we set it here // since they we pretend we are in vtable_disabled mode and the stats vars won't be set. // We sum the stats up here since server could run a number of diff --git a/dbcon/mysql/sm.cpp b/dbcon/mysql/sm.cpp index 5df01dda6..8dc5c0414 100644 --- a/dbcon/mysql/sm.cpp +++ b/dbcon/mysql/sm.cpp @@ -373,17 +373,16 @@ status_t tpl_close ( cpsm_tplh_t* ntplh, cpsm_conhdl_t** conn_hdl, QueryStats& stats, + bool ask_4_stats, bool clear_scan_ctx) { cpsm_conhdl_t* hndl = *conn_hdl; -#if IDB_SM_DEBUG SMDEBUGLOG << "tpl_close: hndl" << hndl << " ntplh " << ntplh; if (ntplh) SMDEBUGLOG << " tableid: " << ntplh->tableid; SMDEBUGLOG << endl; -#endif delete ntplh; // determine end of result set and end of statement execution @@ -391,57 +390,60 @@ tpl_close ( cpsm_tplh_t* ntplh, { // Get the query stats ByteStream bs; - ByteStream::quadbyte qb = 3; - bs << qb; - hndl->write(bs); - + // Ask for a stats only if a user explicitly asks + if(ask_4_stats) + { + ByteStream::quadbyte qb = 3; + bs << qb; + hndl->write(bs); + } // MCOL-1601 Dispose of unused empty RowGroup if (clear_scan_ctx) { + std::cout << "tpl_close() clear_scan_ctx read" << std::endl; bs = hndl->exeMgr->read(); } -#if IDB_SM_DEBUG SMDEBUGLOG << "tpl_close hndl->exeMgr: " << hndl->exeMgr << endl; -#endif //keep reading until we get a string - //TODO: really need to fix this! Why is ExeMgr sending other stuff? - for (int tries = 0; tries < 10; tries++) + // Ask for a stats only if a user explicitly asks + if(ask_4_stats) { - bs = hndl->exeMgr->read(); + for (int tries = 0; tries < 10; tries++) + { + bs = hndl->exeMgr->read(); - if (bs.length() == 0) break; + if (bs.length() == 0) break; - try - { - bs >> hndl->queryStats; - bs >> hndl->extendedStats; - bs >> hndl->miniStats; - stats.unserialize(bs); - stats.setEndTime(); - stats.insert(); - break; + try + { + bs >> hndl->queryStats; + bs >> hndl->extendedStats; + bs >> hndl->miniStats; + stats.unserialize(bs); + stats.setEndTime(); + stats.insert(); + break; + } + catch (IDBExcept&) + { + // @bug4732 + end_query(hndl); + throw; + } + catch (...) + { + // querystats messed up. close connection. + // no need to throw for querystats protocol error, like for tablemode. + SMDEBUGLOG << "tpl_close() exception whilst getting stats" << endl; + end_query(hndl); + sm_cleanup(hndl); + *conn_hdl = 0; + return STATUS_OK; + //throw runtime_error(string("tbl_close catch exception: ") + e.what()); + } } - catch (IDBExcept&) - { - // @bug4732 - end_query(hndl); - throw; - } - catch (...) - { - // querystats messed up. close connection. - // no need to throw for querystats protocol error, like for tablemode. -#if IDB_SM_DEBUG - SMDEBUGLOG << "tpl_close() exception whilst getting stats" << endl; -#endif - end_query(hndl); - sm_cleanup(hndl); - *conn_hdl = 0; - return STATUS_OK; - //throw runtime_error(string("tbl_close catch exception: ") + e.what()); - } - } + } //stats end_query(hndl); } diff --git a/dbcon/mysql/sm.h b/dbcon/mysql/sm.h index dafa64419..32cb1aa18 100644 --- a/dbcon/mysql/sm.h +++ b/dbcon/mysql/sm.h @@ -282,7 +282,7 @@ extern status_t tpl_open(tableid_t, cpsm_tplh_t*, cpsm_conhdl_t*); extern status_t tpl_scan_open(tableid_t, sp_cpsm_tplsch_t&, cpsm_conhdl_t*); extern status_t tpl_scan_fetch(sp_cpsm_tplsch_t&, cpsm_conhdl_t*, int* k = 0); extern status_t tpl_scan_close(sp_cpsm_tplsch_t&); -extern status_t tpl_close(cpsm_tplh_t*, cpsm_conhdl_t**, querystats::QueryStats& stats, bool clear_scan_ctx = false); +extern status_t tpl_close(cpsm_tplh_t*, cpsm_conhdl_t**, querystats::QueryStats& stats, bool ask_4_stats, bool clear_scan_ctx = false); } From d62b66ecf7676fdbde33cb9dbaa02333cdaf5057 Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Fri, 26 Jul 2019 23:39:51 +0300 Subject: [PATCH 51/59] parse_item() in execplan code now always get an actual GWI structure to avoid accedental crashes. Add check for Conversion of Big IN Predicates Into Subqueries optimization conditions. Enabled derivedTableOptimization() for group by and derived handlers. Disabled Conversion of Big IN Predicates Into Subqueries optimization. Disabled most of optimizer_flags for now. RowGroup + operator now correctly sets useStringTable flag that instructs code to check StringStore instead of plain data buffer. --- dbcon/mysql/ha_calpont.cpp | 2 +- dbcon/mysql/ha_calpont_execplan.cpp | 67 +++++++++++++++++++++-------- dbcon/mysql/ha_calpont_impl.cpp | 32 ++++++-------- dbcon/mysql/ha_mcs_pushdown.cpp | 24 +++++++++++ dbcon/mysql/ha_mcs_pushdown.h | 3 ++ dbcon/mysql/ha_mcs_sysvars.cpp | 30 +++++++++++-- dbcon/mysql/ha_mcs_sysvars.h | 4 +- utils/rowgroup/rowgroup.cpp | 1 + 8 files changed, 119 insertions(+), 44 deletions(-) diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index 50b69c297..0d73b1667 100644 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -146,7 +146,7 @@ static int columnstore_init_func(void* p) mcs_hton->rollback = calpont_rollback; mcs_hton->close_connection = calpont_close_connection; //mcs_hton->create_group_by = create_calpont_group_by_handler; - //mcs_hton->create_derived = create_columnstore_derived_handler; + mcs_hton->create_derived = create_columnstore_derived_handler; mcs_hton->create_select = create_columnstore_select_handler; DBUG_RETURN(0); } diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index e5c58cdcb..c0c777627 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -1143,6 +1143,12 @@ void debug_walk(const Item* item, void* arg) break; } + case Item::TYPE_HOLDER: + { + cerr << "TYPE_HOLDER item with cmp_type " << item->cmp_type() << endl; + break; + } + default: { cerr << "UNKNOWN_ITEM type " << item->type() << endl; @@ -3120,7 +3126,7 @@ ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupp vector tmpVec; //bool hasAggColumn = false; uint16_t parseInfo = 0; - parse_item(ifp, tmpVec, gwi.fatalParseError, parseInfo); + parse_item(ifp, tmpVec, gwi.fatalParseError, parseInfo, &gwi); if (parseInfo & SUB_BIT) { @@ -3616,7 +3622,7 @@ ReturnedColumn* buildFunctionColumn( // try to identify const F&E. fall to primitive if parms are constant F&E. vector tmpVec; uint16_t parseInfo = 0; - parse_item(ifp->arguments()[i], tmpVec, gwi.fatalParseError, parseInfo); + parse_item(ifp->arguments()[i], tmpVec, gwi.fatalParseError, parseInfo, &gwi); if (!gwi.fatalParseError && !(parseInfo & AF_BIT) && tmpVec.size() == 0) continue; @@ -4625,7 +4631,7 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi) // check count(1+1) case vector tmpVec; uint16_t parseInfo = 0; - parse_item(ifp, tmpVec, gwi.fatalParseError, parseInfo); + parse_item(ifp, tmpVec, gwi.fatalParseError, parseInfo, &gwi); if (parseInfo & SUB_BIT) { @@ -5238,7 +5244,7 @@ void gp_walk(const Item* item, void* arg) // try to evaluate const F&E vector tmpVec; uint16_t parseInfo = 0; - parse_item(ifp, tmpVec, gwip->fatalParseError, parseInfo); + parse_item(ifp, tmpVec, gwip->fatalParseError, parseInfo, gwip); // table mode takes only one table filter if (gwip->condPush) @@ -5704,10 +5710,6 @@ void gp_walk(const Item* item, void* arg) printf("********** received INSERT_VALUE_ITEM *********\n"); break; - case Item::Item::TYPE_HOLDER: - printf("********** received TYPE_HOLDER *********\n"); - break; - case Item::PARAM_ITEM: printf("********** received PARAM_ITEM *********\n"); break; @@ -5729,6 +5731,9 @@ void gp_walk(const Item* item, void* arg) printf("********** received VIEW_FIXER_ITEM *********\n"); break; */ + case Item::TYPE_HOLDER: + std::cerr << "********** received TYPE_HOLDER *********" << std::endl; + break; default: { if (gwip->condPush) @@ -5779,7 +5784,7 @@ void parse_item (Item* item, vector& field_vec, Item** sfitempp = isp->arguments(); for (uint32_t i = 0; i < isp->argument_count(); i++) - parse_item(sfitempp[i], field_vec, hasNonSupportItem, parseInfo); + parse_item(sfitempp[i], field_vec, hasNonSupportItem, parseInfo, gwi); break; } @@ -5839,7 +5844,7 @@ void parse_item (Item* item, vector& field_vec, } for (uint32_t i = 0; i < isp->argument_count(); i++) - parse_item(sfitempp[i], field_vec, hasNonSupportItem, parseInfo); + parse_item(sfitempp[i], field_vec, hasNonSupportItem, parseInfo, gwi); break; } @@ -5867,14 +5872,14 @@ void parse_item (Item* item, vector& field_vec, Item** sfitempp = isp->arguments(); for (uint32_t i = 0; i < isp->argument_count(); i++) - parse_item(sfitempp[i], field_vec, hasNonSupportItem, parseInfo); + parse_item(sfitempp[i], field_vec, hasNonSupportItem, parseInfo, gwi); break; } else if ((*(ref->ref))->type() == Item::CACHE_ITEM) { Item_cache* isp = reinterpret_cast(*(ref->ref)); - parse_item(isp->get_example(), field_vec, hasNonSupportItem, parseInfo); + parse_item(isp->get_example(), field_vec, hasNonSupportItem, parseInfo, gwi); break; } else if ((*(ref->ref))->type() == Item::REF_ITEM) @@ -5913,7 +5918,7 @@ void parse_item (Item* item, vector& field_vec, Item_row* row = (Item_row*)item; for (uint32_t i = 0; i < row->cols(); i++) - parse_item(row->element_index(i), field_vec, hasNonSupportItem, parseInfo); + parse_item(row->element_index(i), field_vec, hasNonSupportItem, parseInfo, gwi); break; } @@ -5921,7 +5926,11 @@ void parse_item (Item* item, vector& field_vec, case Item::EXPR_CACHE_ITEM: { // item is a Item_cache_wrapper. Shouldn't get here. - printf("EXPR_CACHE_ITEM in parse_item\n"); + // WIP Why + IDEBUG(std::cerr << "EXPR_CACHE_ITEM in parse_item\n" << std::endl); + gwi->fatalParseError = true; + // DRRTUY The questionable error text. I've seen + // ERR_CORRELATED_SUB_OR string parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORT_SUB_QUERY_TYPE); setError(gwi->thd, ER_CHECK_NOT_IMPLEMENTED, parseErrorText); break; @@ -6570,7 +6579,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, uint16_t parseInfo = 0; vector tmpVec; bool hasNonSupportItem = false; - parse_item(ifp, tmpVec, hasNonSupportItem, parseInfo); + parse_item(ifp, tmpVec, hasNonSupportItem, parseInfo, &gwi); if (ifp->with_subquery() || string(ifp->func_name()) == string("") || @@ -6606,7 +6615,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, { hasNonSupportItem = false; uint32_t before_size = funcFieldVec.size(); - parse_item(ifp, funcFieldVec, hasNonSupportItem, parseInfo); + parse_item(ifp, funcFieldVec, hasNonSupportItem, parseInfo, &gwi); uint32_t after_size = funcFieldVec.size(); // group by func and func in subquery can not be post processed @@ -6915,6 +6924,23 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, gwi.returnedCols.push_back(srcp); break; } + case Item::TYPE_HOLDER: + { + if(!gwi.tbList.size()) + { + gwi.parseErrorText = "subquery with VALUES"; + gwi.fatalParseError = true; + setError(gwi.thd, ER_CHECK_NOT_IMPLEMENTED, gwi.parseErrorText, gwi); + return ER_CHECK_NOT_IMPLEMENTED; + } + else + { + std::cerr << "********** received TYPE_HOLDER *********" << std::endl; + + } + break; + } + default: { @@ -7551,7 +7577,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, bool hasNonSupportItem = false; uint16_t parseInfo = 0; - parse_item(ord_item, fieldVec, hasNonSupportItem, parseInfo); + parse_item(ord_item, fieldVec, hasNonSupportItem, parseInfo, &gwi); if (hasNonSupportItem) { @@ -8099,6 +8125,8 @@ int cp_get_group_plan(THD* thd, SCSEP& csep, cal_impl_if::cal_group_info& gi) return ER_INTERNAL_ERROR; else if (status < 0) return status; + // Derived table projection and filter optimization. + derivedTableOptimization(csep); return 0; } @@ -8120,7 +8148,8 @@ int cs_get_derived_plan(derived_handler* handler, THD* thd, SCSEP& csep) cerr << *csep << endl ; cerr << "-------------- EXECUTION PLAN END --------------\n" << endl; #endif - + // Derived table projection and filter optimization. + derivedTableOptimization(csep); return 0; } @@ -8682,7 +8711,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro uint16_t parseInfo = 0; vector tmpVec; bool hasNonSupportItem = false; - parse_item(ifp, tmpVec, hasNonSupportItem, parseInfo); + parse_item(ifp, tmpVec, hasNonSupportItem, parseInfo, &gwi); if (ifp->with_subquery() || string(ifp->func_name()) == string("") || diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 83cddcb4c..b67c7cb57 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -1380,15 +1380,7 @@ uint32_t doUpdateDelete(THD* thd) columnAssignmentPtr->fFromCol = false; } } - // WIP MCOL-2178 - /*else if ( value->type() == Item::VARBIN_ITEM ) - { - String val, *str; - str = value->val_str(&val); - columnAssignmentPtr->fScalarExpression.assign(str->ptr(), str->length()); - columnAssignmentPtr->fFromCol = false; - }*/ - else if ( value->type() == Item::FUNC_ITEM ) + else if ( value->type() == Item::FUNC_ITEM ) { //Bug 2092 handle negative values Item_func* ifp = (Item_func*)value; @@ -2994,13 +2986,6 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) if (get_fe_conn_info_ptr() != NULL) ci = reinterpret_cast(get_fe_conn_info_ptr()); - // WIP MCOL-2178. Won't see this state anymore. - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ORDER_BY ) - { - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_SELECT_VTABLE; // flip back to normal state - return rc; - } - if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE ) return rc; @@ -4387,6 +4372,8 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type) if (lock_type == 0) { ci->physTablesList.insert(table); + // MCOL-2178 Disable Conversion of Big IN Predicates Into Subqueries + thd->variables.in_subquery_conversion_threshold=~0; } else if (lock_type == 2) { @@ -4413,6 +4400,9 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type) // storage for cal_conn_hndl to use it later in close_connection thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); ci->tableMap.clear(); + // MCOL-2178 Enable Conversion of Big IN Predicates Into Subqueries + thd->variables.in_subquery_conversion_threshold = IN_SUBQUERY_CONVERSION_THRESHOLD; + restore_optimizer_flags(thd); } } @@ -5286,6 +5276,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) return ER_INTERNAL_ERROR; } + // WIP MCOL-2178 Remove this. // mysql reads table twice for order by if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_PHASE1 || MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ORDER_BY) @@ -5413,6 +5404,9 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) hndl = ci->cal_conn_hndl; + // WIP MCOL-2178 + std::cout << idb_mysql_query_str(thd) << std::endl; + if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_SELECT_VTABLE) { if (!csep) @@ -5455,13 +5449,15 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) dh = reinterpret_cast(handler_info->hndl_ptr); status = cs_get_derived_plan(dh, thd, csep); } - + + // WIP MCOL-2178 Remove this std::cout << "pushdown_init get_plan status " << status << std::endl; // Return an error to avoid MDB crash later in end_statement if (status != 0) goto internal_error; + // WIP MCOL-2178 Remove this std::cout << "pushdown_init impossibleWhereOnUnion " << status << std::endl; // @bug 2547. don't need to send the plan if it's impossible where for all unions. if (MIGR::infinidb_vtable.impossibleWhereOnUnion) @@ -5731,7 +5727,7 @@ error: ci->cal_conn_hndl = 0; } - // do we need to close all connection handle of the table map? + // do we need to close all connection handle of the table map return ER_INTERNAL_ERROR; internal_error: diff --git a/dbcon/mysql/ha_mcs_pushdown.cpp b/dbcon/mysql/ha_mcs_pushdown.cpp index 93a3fee23..d6c81fc07 100644 --- a/dbcon/mysql/ha_mcs_pushdown.cpp +++ b/dbcon/mysql/ha_mcs_pushdown.cpp @@ -17,6 +17,29 @@ // ha_calpont.cpp includes this file. +void mutate_optimizer_flags(THD *thd_) +{ + // MCOL-2178 Disable all optimizer flags as it was in the fork. + // CS restores it later in SH::scan_end() and in case of an error + // in SH::scan_init() + set_original_optimizer_flags(thd_->variables.optimizer_switch, thd_); + thd_->variables.optimizer_switch = OPTIMIZER_SWITCH_IN_TO_EXISTS | + OPTIMIZER_SWITCH_EXISTS_TO_IN | + OPTIMIZER_SWITCH_COND_PUSHDOWN_FOR_DERIVED; +} + +void restore_optimizer_flags(THD *thd_) +{ + // MCOL-2178 restore original optimizer flags after SH, DH + ulonglong orig_flags = get_original_optimizer_flags(thd_); + if (orig_flags) + { + thd_->variables.optimizer_switch = orig_flags; + set_original_optimizer_flags(0, thd_); + } +} + + /*@brief check_walk - It traverses filter conditions*/ /************************************************************ * DESCRIPTION: @@ -508,6 +531,7 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) if (!unsupported_feature) { handler = new ha_columnstore_select_handler(thd, select_lex); + mutate_optimizer_flags(thd); } return handler; diff --git a/dbcon/mysql/ha_mcs_pushdown.h b/dbcon/mysql/ha_mcs_pushdown.h index 2849cb530..1012cfa8c 100644 --- a/dbcon/mysql/ha_mcs_pushdown.h +++ b/dbcon/mysql/ha_mcs_pushdown.h @@ -21,6 +21,9 @@ #include "idb_mysql.h" #include "ha_calpont.h" +void mutate_optimizer_flags(THD *thd_); +void restore_optimizer_flags(THD *thd_); + enum mcs_handler_types_t { SELECT, diff --git a/dbcon/mysql/ha_mcs_sysvars.cpp b/dbcon/mysql/ha_mcs_sysvars.cpp index dc022b8f2..01b0d6832 100644 --- a/dbcon/mysql/ha_mcs_sysvars.cpp +++ b/dbcon/mysql/ha_mcs_sysvars.cpp @@ -58,6 +58,21 @@ static MYSQL_THDVAR_ULONGLONG( 1 ); +// optimizer flags vault +static MYSQL_THDVAR_ULONGLONG( + original_optimizer_flags, + PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_NOCMDOPT, + "Vault for original optimizer flags. For internal usage.", + NULL, + NULL, + 0, + 0, + ~0U, + 1 +); + + + // legacy system variables static MYSQL_THDVAR_ULONG( decimal_scale, @@ -240,6 +255,7 @@ st_mysql_sys_var* mcs_system_variables[] = { MYSQL_SYSVAR(compression_type), MYSQL_SYSVAR(fe_conn_info_ptr), + MYSQL_SYSVAR(original_optimizer_flags), MYSQL_SYSVAR(decimal_scale), MYSQL_SYSVAR(use_decimal_scale), MYSQL_SYSVAR(ordered_only), @@ -275,14 +291,20 @@ void set_fe_conn_info_ptr(void* ptr, THD* thd) THDVAR(current_thd, fe_conn_info_ptr) = (uint64_t)(ptr); } -bool get_use_legacy_sysvars(THD* thd) +ulonglong get_original_optimizer_flags(THD* thd) { - return ( thd == NULL ) ? false : THDVAR(thd, use_legacy_sysvars); + return ( current_thd == NULL && thd == NULL ) ? NULL : + THDVAR(current_thd, original_optimizer_flags); } -void set_use_legacy_sysvars(THD* thd, bool value) +void set_original_optimizer_flags(ulonglong ptr, THD* thd) { - THDVAR(thd, use_legacy_sysvars) = value; + if ( current_thd == NULL && thd == NULL) + { + return; + } + + THDVAR(current_thd, original_optimizer_flags) = (uint64_t)(ptr); } void set_compression_type(THD* thd, ulong value) diff --git a/dbcon/mysql/ha_mcs_sysvars.h b/dbcon/mysql/ha_mcs_sysvars.h index eae31b0ea..3eea2e2ec 100644 --- a/dbcon/mysql/ha_mcs_sysvars.h +++ b/dbcon/mysql/ha_mcs_sysvars.h @@ -40,8 +40,8 @@ void set_compression_type(THD* thd, ulong value); void* get_fe_conn_info_ptr(THD* thd = NULL); void set_fe_conn_info_ptr(void* ptr, THD* thd = NULL); -bool get_use_legacy_sysvars(THD* thd); -void set_use_legacy_sysvars(THD* thd, bool value); +ulonglong get_original_optimizer_flags(THD* thd = NULL); +void set_original_optimizer_flags(ulonglong ptr, THD* thd = NULL); bool get_use_decimal_scale(THD* thd); void set_use_decimal_scale(THD* thd, bool value); diff --git a/utils/rowgroup/rowgroup.cpp b/utils/rowgroup/rowgroup.cpp index e16f12c30..27d530343 100644 --- a/utils/rowgroup/rowgroup.cpp +++ b/utils/rowgroup/rowgroup.cpp @@ -1591,6 +1591,7 @@ RowGroup& RowGroup::operator+=(const RowGroup& rhs) } hasLongStringField = rhs.hasLongStringField || hasLongStringField; + useStringTable = rhs.useStringTable || useStringTable; offsets = (useStringTable ? &stOffsets[0] : &oldOffsets[0]); return *this; From 1c460f3ba51ce7b5e81dbfdd38d5c011dd4b9b1b Mon Sep 17 00:00:00 2001 From: Gagan Goel Date: Sun, 4 Aug 2019 21:50:50 -0400 Subject: [PATCH 52/59] MCOL-2178 Cleanup of MIGR:: singleton from the plugin code. Disable SP execution by the smart handlers for now. Add session variables to Enable/Disable select/derived/group_by handlers. Defaulted to Enable. --- dbcon/mysql/ha_calpont.cpp | 2 - dbcon/mysql/ha_calpont_ddl.cpp | 16 - dbcon/mysql/ha_calpont_dml.cpp | 4 - dbcon/mysql/ha_calpont_execplan.cpp | 68 ++- dbcon/mysql/ha_calpont_impl.cpp | 691 ++++++---------------------- dbcon/mysql/ha_calpont_impl_if.h | 12 +- dbcon/mysql/ha_mcs_pushdown.cpp | 84 ++-- dbcon/mysql/ha_mcs_sysvars.cpp | 57 +++ dbcon/mysql/ha_mcs_sysvars.h | 9 + dbcon/mysql/ha_view.cpp | 3 +- dbcon/mysql/idb_mysql.h | 64 --- 11 files changed, 284 insertions(+), 726 deletions(-) diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index 0d73b1667..525ac62b7 100644 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -23,8 +23,6 @@ #include "ha_calpont_impl.h" #include "ha_mcs_pushdown.h" -MIGR::INFINIDB_VTABLE MIGR::infinidb_vtable; - static handler* calpont_create_handler(handlerton* hton, TABLE_SHARE* table, MEM_ROOT* mem_root); diff --git a/dbcon/mysql/ha_calpont_ddl.cpp b/dbcon/mysql/ha_calpont_ddl.cpp index 3c411e529..05fb71203 100644 --- a/dbcon/mysql/ha_calpont_ddl.cpp +++ b/dbcon/mysql/ha_calpont_ddl.cpp @@ -2306,17 +2306,6 @@ int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* bool schemaSyncOnly = false; bool isCreate = true; - // relate to bug 1793. Make sure this is not for a select statement because - if (db == "calpontsys" && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT - && tbl != "systable" - && tbl != "syscolumn" && tbl != "sysindex" - && tbl != "sysconstraint" && tbl != "sysindexcol" - && tbl != "sysconstraintcol" ) - { - setError(thd, ER_INTERNAL_ERROR, "Cannot create non-system Calpont tables in calpontsys database"); - return 1; - } - regex pat("[[:space:]]*SCHEMA[[:space:]]+SYNC[[:space:]]+ONLY", regex_constants::extended); if (regex_search(tablecomment, pat)) @@ -2336,11 +2325,6 @@ int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* #endif return 0; } - - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ALTER_VTABLE) //check if it is select - { - return 0; - } } else { diff --git a/dbcon/mysql/ha_calpont_dml.cpp b/dbcon/mysql/ha_calpont_dml.cpp index 9372491e2..d98322ab3 100644 --- a/dbcon/mysql/ha_calpont_dml.cpp +++ b/dbcon/mysql/ha_calpont_dml.cpp @@ -2117,10 +2117,6 @@ int ha_calpont_impl_commit_ (handlerton* hton, THD* thd, bool all, cal_connectio { int rc = 0; - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ALTER_VTABLE || - MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE ) - return rc; - if (thd->slave_thread && !ci.replicationEnabled) return 0; diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index c0c777627..3767a3a8d 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -1321,8 +1321,9 @@ uint32_t buildOuterJoin(gp_walk_info& gwi, SELECT_LEX& select_lex) { if (gwi.thd->derived_tables_processing) { - MIGR::infinidb_vtable.isUnion = false; - MIGR::infinidb_vtable.isUpdateWithDerive = true; +// TODO MCOL-2178 isUnion member only assigned, never used +// MIGR::infinidb_vtable.isUnion = false; + gwi.cs_vtable_is_update_with_derive = true; return -1; } } @@ -2645,8 +2646,6 @@ void setError(THD* thd, uint32_t errcode, string errmsg) } thd->raise_error_printf(errcode, errmsg.c_str()); - MIGR::infinidb_vtable.isNewQuery = true; - MIGR::infinidb_vtable.override_largeside_estimate = false; // reset expressionID if (get_fe_conn_info_ptr() == NULL) @@ -5623,7 +5622,8 @@ void gp_walk(const Item* item, void* arg) gwip->hasSubSelect = true; gwip->subQuery = existsSub; gwip->ptWorkStack.push(existsSub->transform()); - MIGR::infinidb_vtable.isUnion = true; // only temp. bypass the 2nd phase. +// TODO MCOL-2178 isUnion member only assigned, never used +// MIGR::infinidb_vtable.isUnion = true; // only temp. bypass the 2nd phase. // recover original gwip->subQuery = orig; gwip->lastSub = existsSub; @@ -5983,7 +5983,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) ) && gwi.thd->derived_tables_processing) { - MIGR::infinidb_vtable.isUnion = false; +// TODO MCOL-2178 isUnion member only assigned, never used +// MIGR::infinidb_vtable.isUnion = false; return -1; } @@ -6031,7 +6032,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // @bug 2123. Override large table estimate if infinidb_ordered hint was used. // @bug 2404. Always override if the infinidb_ordered_only variable is turned on. - if (MIGR::infinidb_vtable.override_largeside_estimate || get_ordered_only(gwi.thd)) + if (get_ordered_only(gwi.thd)) csep->overrideLargeSideEstimate(true); // @bug 5741. Set a flag when in Local PM only query mode @@ -6117,7 +6118,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, gwi.tbList.push_back(tn); CalpontSystemCatalog::TableAliasName tan = make_aliastable("", alias, alias); gwi.tableMap[tan] = make_pair(0, table_ptr); - MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init +// TODO MCOL-2178 isUnion member only assigned, never used +// MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init } else if (table_ptr->view) { @@ -6188,7 +6190,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // is_unit_op() give a segv for derived_handler's SELECT_LEX if (!isUnion && select_lex.master_unit()->is_unit_op()) { - MIGR::infinidb_vtable.isUnion = true; +// TODO MCOL-2178 isUnion member only assigned, never used +// MIGR::infinidb_vtable.isUnion = true; CalpontSelectExecutionPlan::SelectList unionVec; SELECT_LEX* select_cursor = select_lex.master_unit()->first_select(); unionSel = true; @@ -6247,7 +6250,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, csep->distinctUnionNum(distUnionNum); if (unionVec.empty()) - MIGR::infinidb_vtable.impossibleWhereOnUnion = true; + gwi.cs_vtable_impossible_where_on_union = true; } gwi.clauseType = WHERE; @@ -6280,8 +6283,9 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // processing. if (gwi.thd->derived_tables_processing) { - MIGR::infinidb_vtable.isUnion = false; - MIGR::infinidb_vtable.isUpdateWithDerive = true; +// TODO MCOL-2178 isUnion member only assigned, never used +// MIGR::infinidb_vtable.isUnion = false; + gwi.cs_vtable_is_update_with_derive = true; return -1; } @@ -7094,7 +7098,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SRCP minSc; // min width projected column. for count(*) use // Group by list. not valid for union main query - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE && !unionSel) + if (!unionSel) { gwi.clauseType = GROUP_BY; Item* nonSupportItem = NULL; @@ -7374,7 +7378,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, } } - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) { SQL_I_List order_list = select_lex.order_list; ORDER* ordercol = reinterpret_cast(order_list.first); @@ -7861,10 +7864,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // relate to bug4848. let mysql drive limit when limit session variable set. // do not set in csep. @bug5096. ignore session limit setting for dml - if ((gwi.thd->variables.select_limit == (uint64_t) - 1 || - (gwi.thd->variables.select_limit != (uint64_t) - 1 && - MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_CREATE_VTABLE)) && - !csep->hasOrderBy()) + if (gwi.thd->variables.select_limit == (uint64_t) - 1 && + !csep->hasOrderBy()) { csep->limitStart(limitOffset); csep->limitNum(limitNum); @@ -7977,7 +7978,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, csep->derivedTableList(gwi.derivedTbList); csep->selectSubList(selectSubList); csep->subSelectList(gwi.subselectList); - MIGR::infinidb_vtable.duplicate_field_name = false; clearStacks(gwi); return 0; } @@ -7987,10 +7987,11 @@ int cp_get_plan(THD* thd, SCSEP& csep) LEX* lex = thd->lex; idbassert(lex != 0); - // WIP MCOL-2178 A questionable replacement. - SELECT_LEX select_lex = *lex->first_select_lex(); gp_walk_info gwi; gwi.thd = thd; + + // WIP MCOL-2178 A questionable replacement. + SELECT_LEX select_lex = *lex->first_select_lex(); int status = getSelectPlan(gwi, select_lex, csep); if (status > 0) @@ -8126,16 +8127,14 @@ int cp_get_group_plan(THD* thd, SCSEP& csep, cal_impl_if::cal_group_info& gi) else if (status < 0) return status; // Derived table projection and filter optimization. - derivedTableOptimization(csep); + derivedTableOptimization(thd, csep); return 0; } -int cs_get_derived_plan(derived_handler* handler, THD* thd, SCSEP& csep) +int cs_get_derived_plan(derived_handler* handler, THD* thd, SCSEP& csep, gp_walk_info& gwi) { SELECT_LEX select_lex = *handler->select; - gp_walk_info gwi; - gwi.thd = thd; int status = getSelectPlan(gwi, select_lex, csep, false, true); if (status > 0) @@ -8149,15 +8148,13 @@ int cs_get_derived_plan(derived_handler* handler, THD* thd, SCSEP& csep) cerr << "-------------- EXECUTION PLAN END --------------\n" << endl; #endif // Derived table projection and filter optimization. - derivedTableOptimization(csep); + derivedTableOptimization(thd, csep); return 0; } -int cs_get_select_plan(select_handler* handler, THD* thd, SCSEP& csep) +int cs_get_select_plan(select_handler* handler, THD* thd, SCSEP& csep, gp_walk_info& gwi) { SELECT_LEX select_lex = *handler->select; - gp_walk_info gwi; - gwi.thd = thd; int status = getSelectPlan(gwi, select_lex, csep, false, true); if (status > 0) @@ -8171,7 +8168,7 @@ int cs_get_select_plan(select_handler* handler, THD* thd, SCSEP& csep) cerr << "-------------- EXECUTION PLAN END --------------\n" << endl; #endif // Derived table projection and filter optimization. - derivedTableOptimization(csep); + derivedTableOptimization(thd, csep); return 0; } @@ -8268,7 +8265,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // @bug 2123. Override large table estimate if infinidb_ordered hint was used. // @bug 2404. Always override if the infinidb_ordered_only variable is turned on. - if (MIGR::infinidb_vtable.override_largeside_estimate || get_ordered_only(gwi.thd)) + if (get_ordered_only(gwi.thd)) csep->overrideLargeSideEstimate(true); // @bug 5741. Set a flag when in Local PM only query mode @@ -8355,6 +8352,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro gwi.tbList.push_back(tn); CalpontSystemCatalog::TableAliasName tan = make_aliastable("", alias, alias); gwi.tableMap[tan] = make_pair(0, table_ptr); +// TODO MCOL-2178 isUnion member only assigned, never used // MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init } else if (table_ptr->view) @@ -8453,8 +8451,8 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // processing. if (gwi.thd->derived_tables_processing) { - MIGR::infinidb_vtable.isUnion = false; - MIGR::infinidb_vtable.isUpdateWithDerive = true; +// TODO MCOL-2178 isUnion member only assigned, never used +// MIGR::infinidb_vtable.isUnion = false; return -1; } @@ -9248,7 +9246,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro SRCP minSc; // min width projected column. for count(*) use // Group by list. not valid for union main query - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE && !unionSel) + if (!unionSel) { gwi.clauseType = GROUP_BY; Item* nonSupportItem = NULL; @@ -9531,7 +9529,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // ORDER BY processing starts here - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) { ORDER* ordercol = reinterpret_cast(gi.groupByOrder); @@ -10071,7 +10068,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro csep->derivedTableList(gwi.derivedTbList); csep->selectSubList(selectSubList); csep->subSelectList(gwi.subselectList); - MIGR::infinidb_vtable.duplicate_field_name = false; clearStacks(gwi); return 0; } diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index b67c7cb57..36f152578 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -1176,7 +1176,7 @@ vector getOnUpdateTimestampColumns(string& schema, string& tableName, in return returnVal; } -uint32_t doUpdateDelete(THD* thd) +uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi) { if (get_fe_conn_info_ptr() == NULL) set_fe_conn_info_ptr((void*)new cal_connection_info()); @@ -1193,7 +1193,6 @@ uint32_t doUpdateDelete(THD* thd) //@Bug 4387. Check BRM status before start statement. boost::scoped_ptr dbrmp(new DBRM()); int rc = dbrmp->isReadWrite(); - MIGR::infinidb_vtable.isInfiniDBDML = true; if (rc != 0 ) { @@ -1709,13 +1708,8 @@ uint32_t doUpdateDelete(THD* thd) return 0; } - //MIGR::infinidb_vtable.isInfiniDBDML = true; - MIGR::infinidb_state origState = MIGR::infinidb_vtable.vtable_state; //if (( (thd->lex)->sql_command == SQLCOM_UPDATE ) || ( (thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) ) { - gp_walk_info gwi; - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE; - gwi.thd = thd; //updateCP->subType (CalpontSelectExecutionPlan::SINGLEROW_SUBS); //set scalar updateCP->subType (CalpontSelectExecutionPlan::SELECT_SUBS); //@Bug 2975. @@ -1751,13 +1745,12 @@ uint32_t doUpdateDelete(THD* thd) if (getSelectPlan(gwi, select_lex, updateCP, false, true) != 0) //@Bug 3030 Modify the error message for unsupported functions { - if (MIGR::infinidb_vtable.isUpdateWithDerive) + if (gwi.cs_vtable_is_update_with_derive) { // @bug 4457. MySQL inconsistence! for some queries, some structures are only available // in the derived_tables_processing phase. So by pass the phase for DML only when the // execution plan can not be successfully generated. recover lex before returning; thd->lex->first_select_lex()->item_list = items; - MIGR::infinidb_vtable.vtable_state = origState; return 0; } @@ -1923,8 +1916,6 @@ uint32_t doUpdateDelete(THD* thd) boost::shared_ptr plan = pDMLPackage->get_ExecutionPlan(); updateCP->rmParms(ci->rmParms); updateCP->serialize(*plan); - // recover original vtable state - MIGR::infinidb_vtable.vtable_state = origState; //cout << "plan has bytes " << plan->length() << endl; pDMLPackage->write(bytestream); @@ -2294,6 +2285,9 @@ int ha_calpont_impl_rnd_init(TABLE* table) IDEBUG( cout << "rnd_init for table " << table->s->table_name.str << endl ); THD* thd = current_thd; + gp_walk_info gwi; + gwi.thd = thd; + //check whether the system is ready to process statement. #ifndef _MSC_VER static DBRM dbrm(true); @@ -2303,14 +2297,12 @@ int ha_calpont_impl_rnd_init(TABLE* table) { // Still not ready setError(thd, ER_INTERNAL_ERROR, "The system is not yet ready to accept queries"); - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } else if (bSystemQueryReady < 0) { // Still not ready setError(thd, ER_INTERNAL_ERROR, "DBRM is not responding. Cannot accept queries"); - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } #endif @@ -2322,9 +2314,6 @@ int ha_calpont_impl_rnd_init(TABLE* table) thd_set_ha_data(thd, mcs_hton, reinterpret_cast(0x42)); } - // prevent "create table as select" from running on slave - MIGR::infinidb_vtable.hasInfiniDBTable = true; - cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); if (thd->slave_thread && !ci->replicationEnabled && ( @@ -2338,25 +2327,12 @@ int ha_calpont_impl_rnd_init(TABLE* table) thd->lex->sql_command == SQLCOM_LOAD)) return 0; - // return error is error status is already set - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR) - return ER_INTERNAL_ERROR; - - // @bug 2232. Basic SP support. Error out non support sp cases. - // @bug 3939. Only error out for sp with select. Let pass for alter table in sp. - if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) - { - setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version"); - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; - return ER_INTERNAL_ERROR; - } - if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE ) return 0; //Update and delete code if ( ((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_DELETE) || ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) || ((thd->lex)->sql_command == SQLCOM_UPDATE_MULTI)) - return doUpdateDelete(thd); + return doUpdateDelete(thd, gwi); uint32_t sessionID = tid2sid(thd->thread_id); boost::shared_ptr csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); @@ -2378,24 +2354,12 @@ int ha_calpont_impl_rnd_init(TABLE* table) sm::cpsm_conhdl_t* hndl; SCSEP csep; - // update traceFlags according to the autoswitch state. replication query - // on slave are in table mode (create table as...) - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE || - (thd->slave_thread && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT)) - { - ci->traceFlags |= CalpontSelectExecutionPlan::TRACE_TUPLE_OFF; - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_DISABLE_VTABLE; - } - else - { - ci->traceFlags = (ci->traceFlags | CalpontSelectExecutionPlan::TRACE_TUPLE_OFF)^ - CalpontSelectExecutionPlan::TRACE_TUPLE_OFF; - } + // update traceFlags according to the autoswitch state. + ci->traceFlags |= CalpontSelectExecutionPlan::TRACE_TUPLE_OFF; bool localQuery = get_local_query(thd); // table mode - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) { ti = ci->tableMap[table]; @@ -2468,154 +2432,7 @@ int ha_calpont_impl_rnd_init(TABLE* table) ti.csep->data(""); } } - // vtable mode - else - // The whole section must be useless now. - { - if ( !ci->cal_conn_hndl || - MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) - { - ci->stats.reset(); // reset query stats - ci->stats.setStartTime(); - if (thd->main_security_ctx.user) - { - ci->stats.fUser = thd->main_security_ctx.user; - } - else - { - ci->stats.fUser = ""; - } - if (thd->main_security_ctx.host) - ci->stats.fHost = thd->main_security_ctx.host; - else if (thd->main_security_ctx.host_or_ip) - ci->stats.fHost = thd->main_security_ctx.host_or_ip; - else - ci->stats.fHost = "unknown"; - - try - { - ci->stats.userPriority(ci->stats.fHost, ci->stats.fUser); - } - catch (std::exception& e) - { - string msg = string("Columnstore User Priority - ") + e.what(); - ci->warningMsg = msg; - } - - // if the previous query has error, re-establish the connection - if (ci->queryState != 0) - { - 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; - idbassert(ci->cal_conn_hndl->exeMgr != 0); - - try - { - ci->cal_conn_hndl->connect(); - } - catch (...) - { - setError(thd, ER_INTERNAL_ERROR, IDBErrorInfo::instance()->errorMsg(ERR_LOST_CONN_EXEMGR)); - CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); - goto error; - } - - hndl = ci->cal_conn_hndl; - - if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_SELECT_VTABLE) - { - //CalpontSelectExecutionPlan csep; - if (!csep) - csep.reset(new CalpontSelectExecutionPlan()); - - SessionManager sm; - BRM::TxnID txnID; - txnID = sm.getTxnID(sessionID); - - if (!txnID.valid) - { - txnID.id = 0; - txnID.valid = true; - } - - QueryContext verID; - verID = sm.verID(); - - csep->txnID(txnID.id); - csep->verID(verID); - csep->sessionID(sessionID); - - if (thd->db.length) - csep->schemaName(thd->db.str); - - csep->traceFlags(ci->traceFlags); - - if (MIGR::infinidb_vtable.isInsertSelect) - csep->queryType(CalpontSelectExecutionPlan::INSERT_SELECT); - - //get plan - int status = cp_get_plan(thd, csep); - - //if (cp_get_plan(thd, csep) != 0) - if (status > 0) - goto internal_error; - else if (status < 0) - return 0; - - // @bug 2547. don't need to send the plan if it's impossible where for all unions. - // WIP MCOL-2178 This singleton attribute could be a problem - if (MIGR::infinidb_vtable.impossibleWhereOnUnion) - return 0; - - string query; - query.assign(MIGR::infinidb_vtable.original_query.ptr(), - MIGR::infinidb_vtable.original_query.length()); - csep->data(query); - - try - { - csep->priority( ci->stats.userPriority(ci->stats.fHost, ci->stats.fUser)); - } - catch (std::exception& e) - { - string msg = string("Columnstore User Priority - ") + e.what(); - push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, msg.c_str()); - } - -#ifdef PLAN_HEX_FILE - // plan serialization - string tmpDir = aTmpDir + "/li1-plan.hex"; - - ifstream ifs(tmpDir.c_str()); - ByteStream bs1; - ifs >> bs1; - ifs.close(); - csep->unserialize(bs1); -#endif - - if (ci->traceFlags & 1) - { - cerr << "---------------- EXECUTION PLAN ----------------" << endl; - cerr << *csep << endl ; - cerr << "-------------- EXECUTION PLAN END --------------\n" << endl; - } - else - { - IDEBUG( cout << "---------------- EXECUTION PLAN ----------------" << endl ); - IDEBUG( cerr << *csep << endl ); - IDEBUG( cout << "-------------- EXECUTION PLAN END --------------\n" << endl ); - } - } - }// end of execution plan generation - - if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_SELECT_VTABLE) { ByteStream msg; ByteStream emsgBs; @@ -2690,14 +2507,7 @@ int ha_calpont_impl_rnd_init(TABLE* table) ci->rmParms.clear(); - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) - { - ci->tableMap[table] = ti; - } - else - { - ci->queryState = 1; - } + ci->tableMap[table] = ti; break; } @@ -2710,10 +2520,7 @@ int ha_calpont_impl_rnd_init(TABLE* table) idbassert(hndl != 0); hndl->csc = csc; - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) - ti.conn_hndl = hndl; - else - ci->cal_conn_hndl = hndl; + ti.conn_hndl = hndl; try { @@ -2731,92 +2538,81 @@ int ha_calpont_impl_rnd_init(TABLE* table) } } - // set query state to be in_process. Sometimes mysql calls rnd_init multiple - // times, this makes sure plan only being generated and sent once. It will be - // reset when query finishes in sm::end_query - MIGR::infinidb_vtable.isNewQuery = false; - // common path for both vtable select phase and table mode -- open scan handle ti = ci->tableMap[table]; ti.msTablePtr = table; - if ((MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE) || - (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) || - (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_QUERY)) + if (ti.tpl_ctx == 0) { - if (ti.tpl_ctx == 0) + ti.tpl_ctx = new sm::cpsm_tplh_t(); + ti.tpl_scan_ctx = sm::sp_cpsm_tplsch_t(new sm::cpsm_tplsch_t()); + } + + // make sure rowgroup is null so the new meta data can be taken. This is for some case mysql + // call rnd_init for a table more than once. + ti.tpl_scan_ctx->rowGroup = NULL; + + try + { + tableid = execplan::IDB_VTABLE_ID; + } + catch (...) + { + string emsg = "No table ID found for table " + string(table->s->table_name.str); + setError(thd, ER_INTERNAL_ERROR, emsg); + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); + goto internal_error; + } + + try + { + sm::tpl_open(tableid, ti.tpl_ctx, hndl); + sm::tpl_scan_open(tableid, ti.tpl_scan_ctx, hndl); + } + catch (std::exception& e) + { + string emsg = "table can not be opened: " + string(e.what()); + setError(thd, ER_INTERNAL_ERROR, emsg); + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); + goto internal_error; + } + catch (...) + { + string emsg = "table can not be opened"; + setError(thd, ER_INTERNAL_ERROR, emsg); + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); + goto internal_error; + } + + ti.tpl_scan_ctx->traceFlags = ci->traceFlags; + + if ((ti.tpl_scan_ctx->ctp).size() == 0) + { + uint32_t num_attr = table->s->fields; + + for (uint32_t i = 0; i < num_attr; i++) { - ti.tpl_ctx = new sm::cpsm_tplh_t(); - ti.tpl_scan_ctx = sm::sp_cpsm_tplsch_t(new sm::cpsm_tplsch_t()); + CalpontSystemCatalog::ColType ctype; + ti.tpl_scan_ctx->ctp.push_back(ctype); } - // make sure rowgroup is null so the new meta data can be taken. This is for some case mysql - // call rnd_init for a table more than once. - ti.tpl_scan_ctx->rowGroup = NULL; + // populate coltypes here for table mode because tableband gives treeoid for dictionary column + { + CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str), true); - try - { - tableid = execplan::IDB_VTABLE_ID; - } - catch (...) - { - string emsg = "No table ID found for table " + string(table->s->table_name.str); - setError(thd, ER_INTERNAL_ERROR, emsg); - CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); - goto internal_error; - } - - try - { - sm::tpl_open(tableid, ti.tpl_ctx, hndl); - sm::tpl_scan_open(tableid, ti.tpl_scan_ctx, hndl); - } - catch (std::exception& e) - { - string emsg = "table can not be opened: " + string(e.what()); - setError(thd, ER_INTERNAL_ERROR, emsg); - CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); - goto internal_error; - } - catch (...) - { - string emsg = "table can not be opened"; - setError(thd, ER_INTERNAL_ERROR, emsg); - CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); - goto internal_error; - } - - ti.tpl_scan_ctx->traceFlags = ci->traceFlags; - - if ((ti.tpl_scan_ctx->ctp).size() == 0) - { - uint32_t num_attr = table->s->fields; - - for (uint32_t i = 0; i < num_attr; i++) + if (oidlist.size() != num_attr) { - CalpontSystemCatalog::ColType ctype; - ti.tpl_scan_ctx->ctp.push_back(ctype); + string emsg = "Size mismatch probably caused by front end out of sync"; + setError(thd, ER_INTERNAL_ERROR, emsg); + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); + goto internal_error; } - // populate coltypes here for table mode because tableband gives treeoid for dictionary column - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) + for (unsigned int j = 0; j < oidlist.size(); j++) { - CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str), true); - - if (oidlist.size() != num_attr) - { - string emsg = "Size mismatch probably caused by front end out of sync"; - setError(thd, ER_INTERNAL_ERROR, emsg); - CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); - goto internal_error; - } - - for (unsigned int j = 0; j < oidlist.size(); j++) - { - CalpontSystemCatalog::ColType ctype = csc->colType(oidlist[j].objnum); - ti.tpl_scan_ctx->ctp[ctype.colPosition] = ctype; - ti.tpl_scan_ctx->ctp[ctype.colPosition].colPosition = -1; - } + CalpontSystemCatalog::ColType ctype = csc->colType(oidlist[j].objnum); + ti.tpl_scan_ctx->ctp[ctype.colPosition] = ctype; + ti.tpl_scan_ctx->ctp[ctype.colPosition].colPosition = -1; } } } @@ -2863,30 +2659,14 @@ int ha_calpont_impl_rnd_next(uchar* buf, TABLE* table) thd->lex->sql_command == SQLCOM_LOAD)) return 0; - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR) - return ER_INTERNAL_ERROR; - - // @bug 3005 - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE && - string(table->s->table_name.str).find("$vtable") != 0) - return HA_ERR_END_OF_FILE; - if (((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_DELETE) || ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) || ((thd->lex)->sql_command == SQLCOM_UPDATE_MULTI)) return HA_ERR_END_OF_FILE; // @bug 2547 - if (MIGR::infinidb_vtable.impossibleWhereOnUnion) - return HA_ERR_END_OF_FILE; - - // @bug 2232. Basic SP support - // @bug 3939. Only error out for sp with select. Let pass for alter table in sp. - if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) - { - setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version"); - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; - return ER_INTERNAL_ERROR; - } +// TODO MCOL-2178 This variable can never be true in the scope of this function +// if (MIGR::infinidb_vtable.impossibleWhereOnUnion) +// return HA_ERR_END_OF_FILE; if (get_fe_conn_info_ptr() == NULL) set_fe_conn_info_ptr((void*)new cal_connection_info()); @@ -2975,14 +2755,14 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) thd->lex->sql_command == SQLCOM_LOAD)) return 0; - MIGR::infinidb_vtable.isNewQuery = true; // WIP MCOL-2178 // Workaround because CS doesn't reset isUnion in a normal way. - if (is_pushdown_hand) - { - MIGR::infinidb_vtable.isUnion = false; - } +// TODO MCOL-2178 isUnion member only assigned, never used +// if (is_pushdown_hand) +// { +// MIGR::infinidb_vtable.isUnion = false; +// } if (get_fe_conn_info_ptr() != NULL) ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -3024,7 +2804,7 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) cal_table_info ti = ci->tableMap[table]; sm::cpsm_conhdl_t* hndl; - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) + if (!is_pushdown_hand) hndl = ti.conn_hndl; else hndl = ci->cal_conn_hndl; @@ -3053,7 +2833,7 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) } // set conn hndl back. could be changed in tpl_close - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) + if (!is_pushdown_hand) ti.conn_hndl = hndl; else ci->cal_conn_hndl = hndl; @@ -3112,8 +2892,7 @@ int ha_calpont_impl_create(const char* name, TABLE* table_arg, HA_CREATE_INFO* c cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); // @bug1940 Do nothing for select query. Support of set default engine to IDB. - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE || - string(name).find("@0024vtable") != string::npos) + if (string(name).find("@0024vtable") != string::npos) return 0; //@Bug 1948. Mysql calls create table to create a new table with new signature. @@ -3313,14 +3092,11 @@ void ha_calpont_impl_start_bulk_insert(ha_rows rows, TABLE* table) if (ci->alterTableState > 0) return; - if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_ALTER_VTABLE) - MIGR::infinidb_vtable.isInfiniDBDML = true; - if (thd->slave_thread && !ci->replicationEnabled) return; //@bug 5660. Error out DDL/DML on slave node, or on local query node - if (ci->isSlaveNode && MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_ALTER_VTABLE) + if (ci->isSlaveNode) { string emsg = logging::IDBErrorInfo::instance()->errorMsg(ERR_DML_DDL_SLAVE); setError(current_thd, ER_CHECK_NOT_IMPLEMENTED, emsg); @@ -4088,12 +3864,6 @@ int ha_calpont_impl_end_bulk_insert(bool abort, TABLE* table) int ha_calpont_impl_commit (handlerton* hton, THD* thd, bool all) { - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE || - MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ALTER_VTABLE || - MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DROP_VTABLE || - MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_PHASE1) - return 0; - if (get_fe_conn_info_ptr() == NULL) set_fe_conn_info_ptr((void*)new cal_connection_info()); @@ -4210,8 +3980,6 @@ int ha_calpont_impl_rename_table(const char* from, const char* to) IDEBUG( cout << "ha_calpont_impl_rename_table: was in state ALTER_SECOND_RENAME, now in NOT_ALTER" << endl ); return 0; } - else if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ALTER_VTABLE ) - return 0; int rc = ha_calpont_impl_rename_table_(from, to, *ci); return rc; @@ -4227,12 +3995,6 @@ COND* ha_calpont_impl_cond_push(COND* cond, TABLE* table) { THD* thd = current_thd; - if (thd->slave_thread && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT) - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_DISABLE_VTABLE; - - if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_DISABLE_VTABLE) - return cond; - if (((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_UPDATE_MULTI) || ((thd->lex)->sql_command == SQLCOM_DELETE) || @@ -4336,35 +4098,26 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type) if (mapiter != ci->tableMap.end() && lock_type == 2) // make sure it's the release lock (2nd) call { // table mode - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) + if (mapiter->second.conn_hndl) { - if (mapiter->second.conn_hndl) - { - if (ci->traceFlags & 1) - push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 9999, mapiter->second.conn_hndl->queryStats.c_str()); + if (ci->traceFlags & 1) + push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 9999, mapiter->second.conn_hndl->queryStats.c_str()); - ci->queryStats = mapiter->second.conn_hndl->queryStats; - ci->extendedStats = mapiter->second.conn_hndl->extendedStats; - ci->miniStats = mapiter->second.conn_hndl->miniStats; - sm::sm_cleanup(mapiter->second.conn_hndl); - mapiter->second.conn_hndl = 0; - } - - if (mapiter->second.condInfo) - { - delete mapiter->second.condInfo; - mapiter->second.condInfo = 0; - } - - // only push this warning for once - if (ci->tableMap.size() == 1 && - MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE && MIGR::infinidb_vtable.autoswitch) - { - push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, infinidb_autoswitch_warning.c_str()); - } - // MCOL-2178 Check for tableMap size to set this only once. - ci->queryState = 0; + ci->queryStats = mapiter->second.conn_hndl->queryStats; + ci->extendedStats = mapiter->second.conn_hndl->extendedStats; + ci->miniStats = mapiter->second.conn_hndl->miniStats; + sm::sm_cleanup(mapiter->second.conn_hndl); + mapiter->second.conn_hndl = 0; } + + if (mapiter->second.condInfo) + { + delete mapiter->second.condInfo; + mapiter->second.condInfo = 0; + } + + // MCOL-2178 Check for tableMap size to set this only once. + ci->queryState = 0; ci->tableMap.erase(table); } else @@ -4395,7 +4148,6 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type) ci->extendedStats = ci->cal_conn_hndl->extendedStats; ci->miniStats = ci->cal_conn_hndl->miniStats; ci->queryState = 0; - MIGR::infinidb_vtable.override_largeside_estimate = false; // MCOL-3247 Use THD::ha_data as a per-plugin per-session // storage for cal_conn_hndl to use it later in close_connection thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); @@ -4447,33 +4199,16 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE { // Still not ready setError(thd, ER_INTERNAL_ERROR, "The system is not yet ready to accept queries"); - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } else if (bSystemQueryReady < 0) { // Still not ready setError(thd, ER_INTERNAL_ERROR, "DBRM is not responding. Cannot accept queries"); - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } #endif - // prevent "create table as select" from running on slave - MIGR::infinidb_vtable.hasInfiniDBTable = true; - - // return error if error status has been already set - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR) - return ER_INTERNAL_ERROR; - - // @bug 2232. Basic SP support. Error out non support sp cases. - // @bug 3939. Only error out for sp with select. Let pass for alter table in sp. - if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) - { - setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version"); - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; - return ER_INTERNAL_ERROR; - } uint32_t sessionID = tid2sid(thd->thread_id); boost::shared_ptr csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); @@ -4627,8 +4362,10 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE return 0; // @bug 2547. don't need to send the plan if it's impossible where for all unions. - if (MIGR::infinidb_vtable.impossibleWhereOnUnion) - return 0; +// TODO MCOL-2178 commenting the below out since cp_get_group_plan does not modify this variable +// which has a default value of false +// if (MIGR::infinidb_vtable.impossibleWhereOnUnion) +// return 0; string query; // Set the query text only once if the server executes @@ -4748,14 +4485,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE ci->rmParms.clear(); - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) - { - ci->tableMap[table] = ti; - } - else - { - ci->queryState = 1; - } + ci->queryState = 1; break; } @@ -4768,15 +4498,9 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE idbassert(hndl != 0); hndl->csc = csc; - // The next section is useless - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) - ti.conn_hndl = hndl; - else - { - ci->cal_conn_hndl = hndl; - ci->cal_conn_hndl_st.pop(); - ci->cal_conn_hndl_st.push(ci->cal_conn_hndl); - } + ci->cal_conn_hndl = hndl; + ci->cal_conn_hndl_st.pop(); + ci->cal_conn_hndl_st.push(ci->cal_conn_hndl); try { hndl->connect(); @@ -4796,18 +4520,11 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE // set query state to be in_process. Sometimes mysql calls rnd_init multiple // times, this makes sure plan only being generated and sent once. It will be // reset when query finishes in sm::end_query - MIGR::infinidb_vtable.isNewQuery = false; // common path for both vtable select phase and table mode -- open scan handle ti = ci->tableMap[table]; ti.msTablePtr = table; - // MCOL-1052 - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_SELECT_VTABLE; - - if ((MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE) || - (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) || - (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_QUERY)) { // MCOL-1601 Using stacks of ExeMgr conn hndls, table and scan contexts. ti.tpl_ctx = new sm::cpsm_tplh_t(); @@ -4862,27 +4579,6 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE CalpontSystemCatalog::ColType ctype; ti.tpl_scan_ctx->ctp.push_back(ctype); } - - // populate coltypes here for table mode because tableband gives treeoid for dictionary column - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) - { - CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str), true); - - if (oidlist.size() != num_attr) - { - string emsg = "Size mismatch probably caused by front end out of sync"; - setError(thd, ER_INTERNAL_ERROR, emsg); - CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); - goto internal_error; - } - - for (unsigned int j = 0; j < oidlist.size(); j++) - { - CalpontSystemCatalog::ColType ctype = csc->colType(oidlist[j].objnum); - ti.tpl_scan_ctx->ctp[ctype.colPosition] = ctype; - ti.tpl_scan_ctx->ctp[ctype.colPosition].colPosition = -1; - } - } } } @@ -4931,26 +4627,15 @@ int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE { THD* thd = current_thd; - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR) - return ER_INTERNAL_ERROR; - if (((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_DELETE) || ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) || ((thd->lex)->sql_command == SQLCOM_UPDATE_MULTI)) return HA_ERR_END_OF_FILE; // @bug 2547 - if (MIGR::infinidb_vtable.impossibleWhereOnUnion) - return HA_ERR_END_OF_FILE; +// TODO MCOL-2178 +// if (MIGR::infinidb_vtable.impossibleWhereOnUnion) +// return HA_ERR_END_OF_FILE; - // @bug 2232. Basic SP support - // @bug 3939. Only error out for sp with select. Let pass for alter table in sp. - /*if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) - { - setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version"); - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; - return ER_INTERNAL_ERROR; - } - */ if (get_fe_conn_info_ptr() == NULL) set_fe_conn_info_ptr((void*)new cal_connection_info()); @@ -5043,8 +4728,8 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE* thd->lex->sql_command == SQLCOM_LOAD)) return 0; - MIGR::infinidb_vtable.isNewQuery = true; - MIGR::infinidb_vtable.isUnion = false; +// TODO MCOL-2178 isUnion member only assigned, never used +// MIGR::infinidb_vtable.isUnion = false; if (get_fe_conn_info_ptr() != NULL) ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -5232,6 +4917,9 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) IDEBUG( cout << "pushdown_init for table " << endl ); THD* thd = current_thd; + gp_walk_info gwi; + gwi.thd = thd; + //check whether the system is ready to process statement. #ifndef _MSC_VER static DBRM dbrm(true); @@ -5241,14 +4929,12 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) { // Still not ready setError(thd, ER_INTERNAL_ERROR, "The system is not yet ready to accept queries"); - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } else if (bSystemQueryReady < 0) { // Still not ready setError(thd, ER_INTERNAL_ERROR, "DBRM is not responding. Cannot accept queries"); - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; return ER_INTERNAL_ERROR; } #endif @@ -5260,30 +4946,6 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) thd_set_ha_data(thd, mcs_hton, reinterpret_cast(0x42)); } - // prevent "create table as select" from running on slave - MIGR::infinidb_vtable.hasInfiniDBTable = true; - - // return error is error status is already set - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR) - return ER_INTERNAL_ERROR; - - // @bug 2232. Basic SP support. Error out non support sp cases. - // @bug 3939. Only error out for sp with select. Let pass for alter table in sp. - if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) - { - setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version"); - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR; - return ER_INTERNAL_ERROR; - } - - // WIP MCOL-2178 Remove this. - // mysql reads table twice for order by - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_PHASE1 || - MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ORDER_BY) - { - return 0; - } - if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE ) { return 0; @@ -5291,7 +4953,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) //Update and delete code if ( ((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_DELETE) || ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) || ((thd->lex)->sql_command == SQLCOM_UPDATE_MULTI)) - return doUpdateDelete(thd); + return doUpdateDelete(thd, gwi); uint32_t sessionID = tid2sid(thd->thread_id); boost::shared_ptr csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); @@ -5337,53 +4999,39 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) select_handler* sh = NULL; derived_handler* dh = NULL; - // update traceFlags according to the autoswitch state. replication query - // on slave are in table mode (create table as...) - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE || - (thd->slave_thread && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT)) - { - ci->traceFlags |= CalpontSelectExecutionPlan::TRACE_TUPLE_OFF; - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_DISABLE_VTABLE; - } - else - { - ci->traceFlags = (ci->traceFlags | CalpontSelectExecutionPlan::TRACE_TUPLE_OFF)^ - CalpontSelectExecutionPlan::TRACE_TUPLE_OFF; - } + // update traceFlags according to the autoswitch state. + ci->traceFlags = (ci->traceFlags | CalpontSelectExecutionPlan::TRACE_TUPLE_OFF)^ + CalpontSelectExecutionPlan::TRACE_TUPLE_OFF; bool localQuery = (get_local_query(thd) > 0 ? true : false); { - //if (!ci->cal_conn_hndl || MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) - if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE) + ci->stats.reset(); // reset query stats + ci->stats.setStartTime(); + ci->stats.fUser = thd->main_security_ctx.user; + + if (thd->main_security_ctx.host) + ci->stats.fHost = thd->main_security_ctx.host; + else if (thd->main_security_ctx.host_or_ip) + ci->stats.fHost = thd->main_security_ctx.host_or_ip; + else + ci->stats.fHost = "unknown"; + + try { - ci->stats.reset(); // reset query stats - ci->stats.setStartTime(); - ci->stats.fUser = thd->main_security_ctx.user; + ci->stats.userPriority(ci->stats.fHost, ci->stats.fUser); + } + catch (std::exception& e) + { + string msg = string("Columnstore User Priority - ") + e.what(); + ci->warningMsg = msg; + } - if (thd->main_security_ctx.host) - ci->stats.fHost = thd->main_security_ctx.host; - else if (thd->main_security_ctx.host_or_ip) - ci->stats.fHost = thd->main_security_ctx.host_or_ip; - else - ci->stats.fHost = "unknown"; - - try - { - ci->stats.userPriority(ci->stats.fHost, ci->stats.fUser); - } - catch (std::exception& e) - { - string msg = string("Columnstore User Priority - ") + e.what(); - ci->warningMsg = msg; - } - - // if the previous query has error, re-establish the connection - if (ci->queryState != 0) - { - sm::sm_cleanup(ci->cal_conn_hndl); - ci->cal_conn_hndl = 0; - } + // if the previous query has error, re-establish the connection + if (ci->queryState != 0) + { + sm::sm_cleanup(ci->cal_conn_hndl); + ci->cal_conn_hndl = 0; } sm::sm_init(sessionID, &ci->cal_conn_hndl, localQuery); @@ -5407,7 +5055,6 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) // WIP MCOL-2178 std::cout << idb_mysql_query_str(thd) << std::endl; - if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_SELECT_VTABLE) { if (!csep) csep.reset(new CalpontSelectExecutionPlan()); @@ -5434,20 +5081,17 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) csep->traceFlags(ci->traceFlags); - if (MIGR::infinidb_vtable.isInsertSelect) - csep->queryType(CalpontSelectExecutionPlan::INSERT_SELECT); - // cast the handler and get a plan. int status = 42; if (handler_info->hndl_type == mcs_handler_types_t::SELECT) { sh = reinterpret_cast(handler_info->hndl_ptr); - status = cs_get_select_plan(sh, thd, csep); + status = cs_get_select_plan(sh, thd, csep, gwi); } else if (handler_info->hndl_type == DERIVED) { dh = reinterpret_cast(handler_info->hndl_ptr); - status = cs_get_derived_plan(dh, thd, csep); + status = cs_get_derived_plan(dh, thd, csep, gwi); } // WIP MCOL-2178 Remove this @@ -5460,15 +5104,13 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) // WIP MCOL-2178 Remove this std::cout << "pushdown_init impossibleWhereOnUnion " << status << std::endl; // @bug 2547. don't need to send the plan if it's impossible where for all unions. - if (MIGR::infinidb_vtable.impossibleWhereOnUnion) + if (gwi.cs_vtable_impossible_where_on_union) { return 0; } string query; query.assign(idb_mysql_query_str(thd)); - //query.assign(MIGR::infinidb_vtable.original_query.ptr(), - // MIGR::infinidb_vtable.original_query.length()); csep->data(query); try @@ -5505,7 +5147,6 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) } }// end of execution plan generation - if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_SELECT_VTABLE) { ByteStream msg; ByteStream emsgBs; @@ -5580,14 +5221,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) ci->rmParms.clear(); - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) - { - ci->tableMap[table] = ti; - } - else - { - ci->queryState = 1; - } + ci->queryState = 1; break; } @@ -5600,10 +5234,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) idbassert(hndl != 0); hndl->csc = csc; - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) - ti.conn_hndl = hndl; - else - ci->cal_conn_hndl = hndl; + ci->cal_conn_hndl = hndl; try { @@ -5624,7 +5255,6 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) // set query state to be in_process. Sometimes mysql calls rnd_init multiple // times, this makes sure plan only being generated and sent once. It will be // reset when query finishes in sm::end_query - MIGR::infinidb_vtable.isNewQuery = false; // common path for both vtable select phase and table mode -- open scan handle ti = ci->tableMap[table]; @@ -5692,27 +5322,6 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) CalpontSystemCatalog::ColType ctype; ti.tpl_scan_ctx->ctp.push_back(ctype); } - - // populate coltypes here for table mode because tableband gives treeoid for dictionary column - if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) - { - CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str), true); - - if (oidlist.size() != num_attr) - { - string emsg = "Size mismatch probably caused by front end out of sync"; - setError(thd, ER_INTERNAL_ERROR, emsg); - CalpontSystemCatalog::removeCalpontSystemCatalog(sessionID); - goto internal_error; - } - - for (unsigned int j = 0; j < oidlist.size(); j++) - { - CalpontSystemCatalog::ColType ctype = csc->colType(oidlist[j].objnum); - ti.tpl_scan_ctx->ctp[ctype.colPosition] = ctype; - ti.tpl_scan_ctx->ctp[ctype.colPosition].colPosition = -1; - } - } } } diff --git a/dbcon/mysql/ha_calpont_impl_if.h b/dbcon/mysql/ha_calpont_impl_if.h index 190ed620b..791aa999b 100644 --- a/dbcon/mysql/ha_calpont_impl_if.h +++ b/dbcon/mysql/ha_calpont_impl_if.h @@ -150,6 +150,8 @@ struct gp_walk_info // Kludge for MCOL-1472 bool inCaseStmt; + bool cs_vtable_is_update_with_derive; + bool cs_vtable_impossible_where_on_union; gp_walk_info() : sessionid(0), fatalParseError(false), @@ -166,8 +168,10 @@ struct gp_walk_info lastSub(0), derivedTbCnt(0), recursionLevel(-1), - recursionHWM(0), - inCaseStmt(false) + recursionHWM(0), + inCaseStmt(false), + cs_vtable_is_update_with_derive(false), + cs_vtable_impossible_where_on_union(false) {} ~gp_walk_info() {} @@ -338,8 +342,8 @@ const std::string infinidb_err_msg = "\nThe query includes syntax that is not su int cp_get_plan(THD* thd, execplan::SCSEP& csep); int cp_get_table_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_table_info& ti); int cp_get_group_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_group_info& gi); -int cs_get_derived_plan(derived_handler* handler, THD* thd, execplan::SCSEP& csep); -int cs_get_select_plan(select_handler* handler, THD* thd, execplan::SCSEP& csep); +int cs_get_derived_plan(derived_handler* handler, THD* thd, execplan::SCSEP& csep, gp_walk_info& gwi); +int cs_get_select_plan(select_handler* handler, THD* thd, execplan::SCSEP& csep, gp_walk_info& gwi); int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, execplan::SCSEP& csep, bool isUnion = false, bool isPushdownHand = false); int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, execplan::SCSEP& csep, cal_group_info& gi, bool isUnion = false); void setError(THD* thd, uint32_t errcode, const std::string errmsg, gp_walk_info* gwi); diff --git a/dbcon/mysql/ha_mcs_pushdown.cpp b/dbcon/mysql/ha_mcs_pushdown.cpp index d6c81fc07..1b2981b84 100644 --- a/dbcon/mysql/ha_mcs_pushdown.cpp +++ b/dbcon/mysql/ha_mcs_pushdown.cpp @@ -148,15 +148,20 @@ static group_by_handler* create_calpont_group_by_handler(THD* thd, Query* query) { ha_calpont_group_by_handler* handler = NULL; + + // MCOL-2178 Disable SP support in the group_by_handler for now + // Check the session variable value to enable/disable use of + // group_by_handler + if (!get_group_by_handler(thd) || (thd->lex)->sphead) + { + return handler; + } + // same as thd->lex->current_select SELECT_LEX *select_lex = query->from->select_lex; // Create a handler if query is valid. See comments for details. - if //( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE - // WIP MCOL-2178 - //&& ( MIGR::infinidb_vtable_mode == 0 - // || MIGR::infinidb_vtable_mode == 2 ) - ( query->group_by || select_lex->with_sum_func ) //) + if ( query->group_by || select_lex->with_sum_func ) { bool unsupported_feature = false; // revisit SELECT_LEX for all units @@ -234,6 +239,14 @@ create_columnstore_derived_handler(THD* thd, TABLE_LIST *derived) { ha_columnstore_derived_handler* handler = NULL; + // MCOL-2178 Disable SP support in the derived_handler for now + // Check the session variable value to enable/disable use of + // derived_handler + if (!get_derived_handler(thd) || (thd->lex)->sphead) + { + return handler; + } + SELECT_LEX_UNIT *unit= derived->derived; bool unsupported_feature = false; @@ -287,8 +300,6 @@ ha_columnstore_derived_handler::~ha_columnstore_derived_handler() /*********************************************************** * DESCRIPTION: * Execute the query and saves derived table query. - * ATM this function sets vtable_state and restores it afterwards - * since it reuses existed vtable code internally. * PARAMETERS: * * RETURN: @@ -305,16 +316,10 @@ int ha_columnstore_derived_handler::init_scan() derived_query.length(0); derived->derived->print(&derived_query, QT_ORDINARY); - // Save vtable_state to restore the after we inited. - MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state; - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE; - mcs_handler_info mhi = mcs_handler_info(static_cast(this), DERIVED); // this::table is the place for the result set int rc = ha_cs_impl_pushdown_init(&mhi, table); - MIGR::infinidb_vtable.vtable_state = oldState; - DBUG_RETURN(rc); } @@ -322,8 +327,6 @@ int ha_columnstore_derived_handler::init_scan() /*********************************************************** * DESCRIPTION: * Fetches next row and saves it in the temp table - * ATM this function sets vtable_state and restores it - * afterwards since it reuses existed vtable code internally. * PARAMETERS: * * RETURN: @@ -334,15 +337,8 @@ int ha_columnstore_derived_handler::next_row() { DBUG_ENTER("ha_columnstore_derived_handler::next_row"); - // Save vtable_state to restore the after we inited. - MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state; - - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE; - int rc = ha_calpont_impl_rnd_next(table->record[0], table); - MIGR::infinidb_vtable.vtable_state = oldState; - DBUG_RETURN(rc); } @@ -350,8 +346,6 @@ int ha_columnstore_derived_handler::next_row() /*********************************************************** * DESCRIPTION: * Finishes the scan for derived handler - * ATM this function sets vtable_state and restores it - * afterwards since it reuses existed vtable code internally. * PARAMETERS: * * RETURN: @@ -362,13 +356,8 @@ int ha_columnstore_derived_handler::end_scan() { DBUG_ENTER("ha_columnstore_derived_handler::end_scan"); - MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state; - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_SELECT_VTABLE; - int rc = ha_calpont_impl_rnd_end(table, true); - MIGR::infinidb_vtable.vtable_state = oldState; - DBUG_RETURN(rc); } @@ -413,12 +402,7 @@ int ha_calpont_group_by_handler::init_scan() { DBUG_ENTER("ha_calpont_group_by_handler::init_scan"); - // Save vtable_state to restore the after we inited. - MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state; - // MCOL-1052 Should be removed after cleaning the code up. - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE; int rc = ha_calpont_impl_group_by_init(this, table); - MIGR::infinidb_vtable.vtable_state = oldState; DBUG_RETURN(rc); } @@ -470,6 +454,14 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) { ha_columnstore_select_handler* handler = NULL; + // MCOL-2178 Disable SP support in the select_handler for now. + // Check the session variable value to enable/disable use of + // select_handler + if (!get_select_handler(thd) || (thd->lex)->sphead) + { + return handler; + } + bool unsupported_feature = false; // Select_handler use the short-cut that effectively disables // INSERT..SELECT and LDI @@ -563,8 +555,6 @@ ha_columnstore_select_handler::~ha_columnstore_select_handler() /*********************************************************** * DESCRIPTION: * Execute the query and saves select table query. - * ATM this function sets vtable_state and restores it afterwards - * since it reuses existed vtable code internally. * PARAMETERS: * * RETURN: @@ -581,16 +571,10 @@ int ha_columnstore_select_handler::init_scan() select_query.length(0); select->print(thd, &select_query, QT_ORDINARY); - // Save vtable_state to restore the after we inited. - MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state; - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE; - mcs_handler_info mhi = mcs_handler_info(static_cast(this), SELECT); // this::table is the place for the result set int rc = ha_cs_impl_pushdown_init(&mhi, table); - MIGR::infinidb_vtable.vtable_state = oldState; - DBUG_RETURN(rc); } @@ -598,8 +582,6 @@ int ha_columnstore_select_handler::init_scan() /*********************************************************** * DESCRIPTION: * Fetches next row and saves it in the temp table - * ATM this function sets vtable_state and restores it - * afterwards since it reuses existed vtable code internally. * PARAMETERS: * * RETURN: @@ -610,15 +592,8 @@ int ha_columnstore_select_handler::next_row() { DBUG_ENTER("ha_columnstore_select_handler::next_row"); - // Save vtable_state to restore the after we inited. - MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state; - - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE; - int rc = ha_calpont_impl_rnd_next(table->record[0], table); - MIGR::infinidb_vtable.vtable_state = oldState; - DBUG_RETURN(rc); } @@ -626,8 +601,6 @@ int ha_columnstore_select_handler::next_row() /*********************************************************** * DESCRIPTION: * Finishes the scan for select handler - * ATM this function sets vtable_state and restores it - * afterwards since it reuses existed vtable code internally. * PARAMETERS: * * RETURN: @@ -638,13 +611,8 @@ int ha_columnstore_select_handler::end_scan() { DBUG_ENTER("ha_columnstore_select_handler::end_scan"); - MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state; - MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_SELECT_VTABLE; - int rc = ha_calpont_impl_rnd_end(table, true); - MIGR::infinidb_vtable.vtable_state = oldState; - DBUG_RETURN(rc); } diff --git a/dbcon/mysql/ha_mcs_sysvars.cpp b/dbcon/mysql/ha_mcs_sysvars.cpp index 01b0d6832..2dfadcb6a 100644 --- a/dbcon/mysql/ha_mcs_sysvars.cpp +++ b/dbcon/mysql/ha_mcs_sysvars.cpp @@ -71,6 +71,33 @@ static MYSQL_THDVAR_ULONGLONG( 1 ); +static MYSQL_THDVAR_BOOL( + select_handler, + PLUGIN_VAR_NOCMDARG, + "Enable/Disable the MCS select_handler", + NULL, + NULL, + 1 +); + +static MYSQL_THDVAR_BOOL( + derived_handler, + PLUGIN_VAR_NOCMDARG, + "Enable/Disable the MCS derived_handler", + NULL, + NULL, + 1 +); + +static MYSQL_THDVAR_BOOL( + group_by_handler, + PLUGIN_VAR_NOCMDARG, + "Enable/Disable the MCS group_by_handler", + NULL, + NULL, + 1 +); + // legacy system variables @@ -256,6 +283,9 @@ st_mysql_sys_var* mcs_system_variables[] = MYSQL_SYSVAR(compression_type), MYSQL_SYSVAR(fe_conn_info_ptr), MYSQL_SYSVAR(original_optimizer_flags), + MYSQL_SYSVAR(select_handler), + MYSQL_SYSVAR(derived_handler), + MYSQL_SYSVAR(group_by_handler), MYSQL_SYSVAR(decimal_scale), MYSQL_SYSVAR(use_decimal_scale), MYSQL_SYSVAR(ordered_only), @@ -307,6 +337,33 @@ void set_original_optimizer_flags(ulonglong ptr, THD* thd) THDVAR(current_thd, original_optimizer_flags) = (uint64_t)(ptr); } +bool get_select_handler(THD* thd) +{ + return ( thd == NULL ) ? false : THDVAR(thd, select_handler); +} +void set_select_handler(THD* thd, bool value) +{ + THDVAR(thd, select_handler) = value; +} + +bool get_derived_handler(THD* thd) +{ + return ( thd == NULL ) ? false : THDVAR(thd, derived_handler); +} +void set_derived_handler(THD* thd, bool value) +{ + THDVAR(thd, derived_handler) = value; +} + +bool get_group_by_handler(THD* thd) +{ + return ( thd == NULL ) ? false : THDVAR(thd, group_by_handler); +} +void set_group_by_handler(THD* thd, bool value) +{ + THDVAR(thd, group_by_handler) = value; +} + void set_compression_type(THD* thd, ulong value) { THDVAR(thd, compression_type) = value; diff --git a/dbcon/mysql/ha_mcs_sysvars.h b/dbcon/mysql/ha_mcs_sysvars.h index 3eea2e2ec..a977842bc 100644 --- a/dbcon/mysql/ha_mcs_sysvars.h +++ b/dbcon/mysql/ha_mcs_sysvars.h @@ -43,6 +43,15 @@ void set_fe_conn_info_ptr(void* ptr, THD* thd = NULL); ulonglong get_original_optimizer_flags(THD* thd = NULL); void set_original_optimizer_flags(ulonglong ptr, THD* thd = NULL); +bool get_select_handler(THD* thd); +void set_select_handler(THD* thd, bool value); + +bool get_derived_handler(THD* thd); +void set_derived_handler(THD* thd, bool value); + +bool get_group_by_handler(THD* thd); +void set_group_by_handler(THD* thd, bool value); + bool get_use_decimal_scale(THD* thd); void set_use_decimal_scale(THD* thd, bool value); diff --git a/dbcon/mysql/ha_view.cpp b/dbcon/mysql/ha_view.cpp index 8a6df6a0f..cfcfe3970 100644 --- a/dbcon/mysql/ha_view.cpp +++ b/dbcon/mysql/ha_view.cpp @@ -102,7 +102,8 @@ void View::transform() CalpontSystemCatalog::TableAliasName tn = make_aliasview("", "", alias, viewName); gwi.tbList.push_back(tn); gwi.tableMap[tn] = make_pair(0, table_ptr); - MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init + // TODO MCOL-2178 isUnion member only assigned, never used + // MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init } else if (table_ptr->view) { diff --git a/dbcon/mysql/idb_mysql.h b/dbcon/mysql/idb_mysql.h index b16301159..cb842d740 100644 --- a/dbcon/mysql/idb_mysql.h +++ b/dbcon/mysql/idb_mysql.h @@ -111,70 +111,6 @@ inline char* idb_mysql_query_str(THD* thd) } } -class MIGR -{ - public: - enum infinidb_state - { - INFINIDB_INIT_CONNECT = 0, // intend to use to drop leftover vtable when logon. not being used now. - INFINIDB_INIT, - INFINIDB_CREATE_VTABLE, - INFINIDB_ALTER_VTABLE, - INFINIDB_SELECT_VTABLE, - INFINIDB_DROP_VTABLE, - INFINIDB_DISABLE_VTABLE, - INFINIDB_REDO_PHASE1, // post process requires to re-create vtable - INFINIDB_ORDER_BY, // for InfiniDB handler to ignore the 2nd scan for order by - INFINIDB_REDO_QUERY, // redo query with the normal mysql path - INFINIDB_ERROR_REDO_PHASE1, - INFINIDB_ERROR = 32, - }; - struct INFINIDB_VTABLE - { - String original_query; - String create_vtable_query; - String alter_vtable_query; - String select_vtable_query; - String drop_vtable_query; - String insert_vtable_query; - infinidb_state vtable_state; // flag for InfiniDB MySQL virtual table structure - bool autoswitch; - bool has_order_by; - bool duplicate_field_name; // @bug 1928. duplicate field name in create_phase will be ingored. - bool call_sp; - bool override_largeside_estimate; - void* cal_conn_info; - bool isUnion; - bool impossibleWhereOnUnion; - bool isInsertSelect; - bool isUpdateWithDerive; - bool isInfiniDBDML; // default false - bool hasInfiniDBTable; // default false - bool isNewQuery; - INFINIDB_VTABLE() : cal_conn_info(NULL) {init();} - void init() - { - //vtable_state = INFINIDB_INIT_CONNECT; - vtable_state = INFINIDB_DISABLE_VTABLE; - autoswitch = false; - has_order_by = false; - duplicate_field_name = false; - call_sp = false; - override_largeside_estimate = false; - isUnion = false; - impossibleWhereOnUnion = false; - isUpdateWithDerive = false; - isInfiniDBDML = false; - hasInfiniDBTable = false; - isNewQuery = true; - } - }; - - static INFINIDB_VTABLE infinidb_vtable; // InfiniDB custom structure - -}; - - #endif // vim:ts=4 sw=4: From a09a9d5d0fe7eb05ab293a080d0d81723c73175e Mon Sep 17 00:00:00 2001 From: Patrick LeBlanc Date: Wed, 7 Aug 2019 14:43:25 -0500 Subject: [PATCH 53/59] Mass substitution 'Corporaton' -> 'Corporation' --- dbcon/ddlpackageproc/createtableprocessor.cpp | 2 +- dbcon/execplan/aggregatecolumn.cpp | 2 +- dbcon/execplan/aggregatecolumn.h | 2 +- dbcon/execplan/arithmeticcolumn.h | 2 +- dbcon/execplan/arithmeticoperator.h | 2 +- dbcon/execplan/calpontsystemcatalog.cpp | 2 +- dbcon/execplan/calpontsystemcatalog.h | 2 +- dbcon/execplan/constantcolumn.cpp | 2 +- dbcon/execplan/constantcolumn.h | 2 +- dbcon/execplan/functioncolumn.h | 2 +- dbcon/execplan/operator.h | 2 +- dbcon/execplan/parsetree.h | 2 +- dbcon/execplan/predicateoperator.cpp | 2 +- dbcon/execplan/predicateoperator.h | 2 +- dbcon/execplan/simplecolumn.cpp | 2 +- dbcon/execplan/simplecolumn.h | 2 +- dbcon/execplan/simplecolumn_decimal.h | 2 +- dbcon/execplan/simplecolumn_int.h | 2 +- dbcon/execplan/simplecolumn_uint.h | 2 +- dbcon/execplan/simplefilter.h | 2 +- dbcon/execplan/tdriver-sm.cpp | 2 +- dbcon/execplan/tdriver.cpp | 2 +- dbcon/execplan/treenode.h | 2 +- dbcon/execplan/windowfunctioncolumn.cpp | 2 +- dbcon/execplan/windowfunctioncolumn.h | 2 +- dbcon/joblist/batchprimitiveprocessor-jl.cpp | 2 +- dbcon/joblist/groupconcat.cpp | 2 +- dbcon/joblist/jlf_common.cpp | 2 +- dbcon/joblist/jlf_common.h | 2 +- dbcon/joblist/jlf_subquery.cpp | 2 +- dbcon/joblist/jlf_tuplejoblist.cpp | 2 +- dbcon/joblist/joblist.cpp | 2 +- dbcon/joblist/joblist.h | 2 +- dbcon/joblist/joblistfactory.cpp | 2 +- dbcon/joblist/joblisttypes.h | 2 +- dbcon/joblist/largehashjoin.cpp | 2 +- dbcon/joblist/primitivestep.h | 2 +- dbcon/joblist/subquerytransformer.cpp | 2 +- dbcon/joblist/tdriver-agg.cpp | 2 +- dbcon/joblist/tupleaggregatestep.cpp | 2 +- dbcon/joblist/tupleconstantstep.cpp | 2 +- dbcon/joblist/tupleunion.cpp | 2 +- dbcon/mysql/ha_calpont.cpp | 2 +- dbcon/mysql/ha_calpont.h | 2 +- dbcon/mysql/ha_calpont_ddl.cpp | 2 +- dbcon/mysql/ha_calpont_dml.cpp | 2 +- dbcon/mysql/ha_calpont_execplan.cpp | 2 +- dbcon/mysql/ha_calpont_impl.cpp | 2 +- dbcon/mysql/ha_calpont_impl.h | 2 +- dbcon/mysql/ha_calpont_impl_if.h | 2 +- dbcon/mysql/ha_calpont_partition.cpp | 2 +- dbcon/mysql/ha_calpont_udf.cpp | 2 +- dbcon/mysql/ha_exists_sub.cpp | 2 +- dbcon/mysql/ha_from_sub.cpp | 2 +- dbcon/mysql/ha_in_sub.cpp | 2 +- dbcon/mysql/ha_mcs_client_udfs.cpp | 2 +- dbcon/mysql/ha_mcs_sysvars.cpp | 2 +- dbcon/mysql/ha_mcs_sysvars.h | 2 +- dbcon/mysql/ha_scalar_sub.cpp | 2 +- dbcon/mysql/ha_select_sub.cpp | 2 +- dbcon/mysql/ha_subquery.h | 2 +- dbcon/mysql/ha_view.cpp | 2 +- dbcon/mysql/ha_window_function.cpp | 2 +- dbcon/mysql/is_columnstore_columns.cpp | 4 ++-- dbcon/mysql/is_columnstore_extents.cpp | 4 ++-- dbcon/mysql/is_columnstore_files.cpp | 4 ++-- dbcon/mysql/is_columnstore_tables.cpp | 4 ++-- exemgr/main.cpp | 2 +- oam/oamcpp/liboamcpp.cpp | 2 +- oam/oamcpp/liboamcpp.h | 2 +- oam/oamcpp/oamcache.cpp | 2 +- oam/oamcpp/oamcache.h | 2 +- oam/replaytxnlog/replaytxnlog.cpp | 2 +- oamapps/alarmmanager/alarmglobal.h | 2 +- oamapps/mcsadmin/mcsadmin.h | 2 +- oamapps/postConfigure/amazonInstaller.cpp | 2 +- oamapps/postConfigure/helpers.h | 2 +- oamapps/postConfigure/installer.cpp | 2 +- oamapps/postConfigure/mycnfUpgrade.cpp | 2 +- oamapps/postConfigure/patchInstaller.cpp | 2 +- oamapps/resourceMonitor/resourceMonitor.cpp | 2 +- oamapps/serverMonitor/cpuMonitor.cpp | 2 +- oamapps/serverMonitor/dbhealthMonitor.cpp | 2 +- oamapps/serverMonitor/diskMonitor.cpp | 2 +- oamapps/serverMonitor/memoryMonitor.cpp | 2 +- oamapps/serverMonitor/msgProcessor.cpp | 2 +- primitives/blockcache/blockrequestprocessor.cpp | 2 +- primitives/blockcache/filebuffermgr.cpp | 2 +- primitives/blockcache/iomanager.cpp | 2 +- primitives/blockcache/stats.cpp | 2 +- primitives/primproc/batchprimitiveprocessor.cpp | 2 +- primitives/primproc/bppseeder.cpp | 2 +- primitives/primproc/primitiveserver.cpp | 2 +- primitives/primproc/primitiveserver.h | 2 +- primitives/primproc/primproc.cpp | 2 +- procmgr/main.cpp | 2 +- procmgr/processmanager.cpp | 2 +- procmgr/processmanager.h | 2 +- procmon/processmonitor.cpp | 2 +- tools/configMgt/autoConfigure.cpp | 2 +- tools/configMgt/autoInstaller.cpp | 2 +- tools/configMgt/configure.cpp | 2 +- utils/common/crashtrace.cpp | 2 +- utils/common/crashtrace.h | 2 +- utils/common/nullvaluemanip.cpp | 2 +- utils/common/threadnaming.cpp | 2 +- utils/common/threadnaming.h | 2 +- utils/dataconvert/dataconvert.cpp | 2 +- utils/funcexp/func_abs.cpp | 2 +- utils/funcexp/func_between.cpp | 2 +- utils/funcexp/func_case.cpp | 2 +- utils/funcexp/func_cast.cpp | 2 +- utils/funcexp/func_ceil.cpp | 2 +- utils/funcexp/func_coalesce.cpp | 2 +- utils/funcexp/func_exp.cpp | 2 +- utils/funcexp/func_floor.cpp | 2 +- utils/funcexp/func_from_unixtime.cpp | 2 +- utils/funcexp/func_greatest.cpp | 2 +- utils/funcexp/func_hex.cpp | 2 +- utils/funcexp/func_if.cpp | 2 +- utils/funcexp/func_ifnull.cpp | 2 +- utils/funcexp/func_in.cpp | 2 +- utils/funcexp/func_isnull.cpp | 2 +- utils/funcexp/func_least.cpp | 2 +- utils/funcexp/func_math.cpp | 2 +- utils/funcexp/func_mod.cpp | 2 +- utils/funcexp/func_nullif.cpp | 2 +- utils/funcexp/func_pow.cpp | 2 +- utils/funcexp/func_round.cpp | 2 +- utils/funcexp/func_substring_index.cpp | 2 +- utils/funcexp/func_truncate.cpp | 2 +- utils/funcexp/funcexp.cpp | 2 +- utils/funcexp/funchelpers.h | 2 +- utils/funcexp/functor.cpp | 2 +- utils/funcexp/functor.h | 2 +- utils/funcexp/functor_all.h | 2 +- utils/funcexp/functor_dtm.h | 2 +- utils/funcexp/functor_export.h | 2 +- utils/funcexp/functor_int.h | 2 +- utils/funcexp/functor_real.h | 2 +- utils/funcexp/functor_str.h | 2 +- utils/joiner/joinpartition.cpp | 2 +- utils/joiner/tuplejoiner.cpp | 2 +- utils/joiner/tuplejoiner.h | 2 +- utils/loggingcpp/messagelog.cpp | 2 +- utils/loggingcpp/tdriver.cpp | 2 +- utils/messageqcpp/bytestream.cpp | 2 +- utils/messageqcpp/bytestream.h | 2 +- utils/messageqcpp/messagequeuepool.cpp | 2 +- utils/messageqcpp/messagequeuepool.h | 2 +- utils/regr/corr.cpp | 2 +- utils/regr/corr.h | 2 +- utils/regr/covar_pop.cpp | 2 +- utils/regr/covar_pop.h | 2 +- utils/regr/covar_samp.cpp | 2 +- utils/regr/covar_samp.h | 2 +- utils/regr/regr_avgx.cpp | 2 +- utils/regr/regr_avgx.h | 2 +- utils/regr/regr_avgy.cpp | 2 +- utils/regr/regr_avgy.h | 2 +- utils/regr/regr_count.cpp | 2 +- utils/regr/regr_count.h | 2 +- utils/regr/regr_intercept.cpp | 2 +- utils/regr/regr_intercept.h | 2 +- utils/regr/regr_r2.cpp | 2 +- utils/regr/regr_r2.h | 2 +- utils/regr/regr_slope.cpp | 2 +- utils/regr/regr_slope.h | 2 +- utils/regr/regr_sxx.cpp | 2 +- utils/regr/regr_sxx.h | 2 +- utils/regr/regr_sxy.cpp | 2 +- utils/regr/regr_sxy.h | 2 +- utils/regr/regr_syy.cpp | 2 +- utils/regr/regr_syy.h | 2 +- utils/startup/installdir.cpp | 2 +- utils/testbc/stats.cpp | 2 +- utils/udfsdk/allnull.cpp | 2 +- utils/udfsdk/allnull.h | 2 +- utils/udfsdk/avg_mode.cpp | 2 +- utils/udfsdk/avg_mode.h | 2 +- utils/udfsdk/avgx.cpp | 2 +- utils/udfsdk/avgx.h | 2 +- utils/udfsdk/distinct_count.cpp | 2 +- utils/udfsdk/distinct_count.h | 2 +- utils/udfsdk/mcsv1_udaf.cpp | 2 +- utils/udfsdk/mcsv1_udaf.h | 2 +- utils/udfsdk/median.cpp | 2 +- utils/udfsdk/median.h | 2 +- utils/udfsdk/ssq.cpp | 2 +- utils/udfsdk/ssq.h | 2 +- versioning/BRM/slavecomm.cpp | 2 +- versioning/BRM/tracer.cpp | 2 +- writeengine/redistribute/we_redistributecontrol.cpp | 2 +- writeengine/redistribute/we_redistributecontrolthread.cpp | 2 +- writeengine/splitter/we_cmdargs.cpp | 2 +- writeengine/wrapper/tdriver.cpp | 2 +- 196 files changed, 200 insertions(+), 200 deletions(-) diff --git a/dbcon/ddlpackageproc/createtableprocessor.cpp b/dbcon/ddlpackageproc/createtableprocessor.cpp index 1b66c9092..db1e8d088 100644 --- a/dbcon/ddlpackageproc/createtableprocessor.cpp +++ b/dbcon/ddlpackageproc/createtableprocessor.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/aggregatecolumn.cpp b/dbcon/execplan/aggregatecolumn.cpp index 8583459da..3d7825dcb 100644 --- a/dbcon/execplan/aggregatecolumn.cpp +++ b/dbcon/execplan/aggregatecolumn.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/aggregatecolumn.h b/dbcon/execplan/aggregatecolumn.h index 0825f00ff..20b049dad 100644 --- a/dbcon/execplan/aggregatecolumn.h +++ b/dbcon/execplan/aggregatecolumn.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/arithmeticcolumn.h b/dbcon/execplan/arithmeticcolumn.h index d7e895969..2dfed7349 100644 --- a/dbcon/execplan/arithmeticcolumn.h +++ b/dbcon/execplan/arithmeticcolumn.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/arithmeticoperator.h b/dbcon/execplan/arithmeticoperator.h index cc6cc70da..7277ccd65 100644 --- a/dbcon/execplan/arithmeticoperator.h +++ b/dbcon/execplan/arithmeticoperator.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/calpontsystemcatalog.cpp b/dbcon/execplan/calpontsystemcatalog.cpp index 234fb6235..786c67383 100644 --- a/dbcon/execplan/calpontsystemcatalog.cpp +++ b/dbcon/execplan/calpontsystemcatalog.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/calpontsystemcatalog.h b/dbcon/execplan/calpontsystemcatalog.h index 188dae4e6..311a6d24c 100644 --- a/dbcon/execplan/calpontsystemcatalog.h +++ b/dbcon/execplan/calpontsystemcatalog.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/constantcolumn.cpp b/dbcon/execplan/constantcolumn.cpp index aa2676816..8b7e9fc42 100644 --- a/dbcon/execplan/constantcolumn.cpp +++ b/dbcon/execplan/constantcolumn.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/constantcolumn.h b/dbcon/execplan/constantcolumn.h index 51b914be0..bdeb1e014 100644 --- a/dbcon/execplan/constantcolumn.h +++ b/dbcon/execplan/constantcolumn.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/functioncolumn.h b/dbcon/execplan/functioncolumn.h index 99e3c9be7..c8274e087 100644 --- a/dbcon/execplan/functioncolumn.h +++ b/dbcon/execplan/functioncolumn.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/operator.h b/dbcon/execplan/operator.h index b8d2ab18c..a8119fd6e 100644 --- a/dbcon/execplan/operator.h +++ b/dbcon/execplan/operator.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/parsetree.h b/dbcon/execplan/parsetree.h index 3561d9dc6..f31a2a013 100644 --- a/dbcon/execplan/parsetree.h +++ b/dbcon/execplan/parsetree.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/predicateoperator.cpp b/dbcon/execplan/predicateoperator.cpp index 501bd8a73..efd748c99 100644 --- a/dbcon/execplan/predicateoperator.cpp +++ b/dbcon/execplan/predicateoperator.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/predicateoperator.h b/dbcon/execplan/predicateoperator.h index 75cde2051..d7f650b9a 100644 --- a/dbcon/execplan/predicateoperator.h +++ b/dbcon/execplan/predicateoperator.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/simplecolumn.cpp b/dbcon/execplan/simplecolumn.cpp index 68f09ee26..169b588fb 100644 --- a/dbcon/execplan/simplecolumn.cpp +++ b/dbcon/execplan/simplecolumn.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/simplecolumn.h b/dbcon/execplan/simplecolumn.h index cb63e9683..4c5ef52a3 100644 --- a/dbcon/execplan/simplecolumn.h +++ b/dbcon/execplan/simplecolumn.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/simplecolumn_decimal.h b/dbcon/execplan/simplecolumn_decimal.h index 07d451e4b..994c89f73 100644 --- a/dbcon/execplan/simplecolumn_decimal.h +++ b/dbcon/execplan/simplecolumn_decimal.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/simplecolumn_int.h b/dbcon/execplan/simplecolumn_int.h index e39ab9953..dc790ff9a 100644 --- a/dbcon/execplan/simplecolumn_int.h +++ b/dbcon/execplan/simplecolumn_int.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/simplecolumn_uint.h b/dbcon/execplan/simplecolumn_uint.h index 7c9169f75..9cc23ded4 100644 --- a/dbcon/execplan/simplecolumn_uint.h +++ b/dbcon/execplan/simplecolumn_uint.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/simplefilter.h b/dbcon/execplan/simplefilter.h index e448aa3ed..f1711082e 100644 --- a/dbcon/execplan/simplefilter.h +++ b/dbcon/execplan/simplefilter.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/tdriver-sm.cpp b/dbcon/execplan/tdriver-sm.cpp index 860415471..853909eed 100644 --- a/dbcon/execplan/tdriver-sm.cpp +++ b/dbcon/execplan/tdriver-sm.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/tdriver.cpp b/dbcon/execplan/tdriver.cpp index 5a8675586..080c54ee7 100644 --- a/dbcon/execplan/tdriver.cpp +++ b/dbcon/execplan/tdriver.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/treenode.h b/dbcon/execplan/treenode.h index 84d2ccfac..606819dcb 100644 --- a/dbcon/execplan/treenode.h +++ b/dbcon/execplan/treenode.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/windowfunctioncolumn.cpp b/dbcon/execplan/windowfunctioncolumn.cpp index 09ba50ddc..2316cb510 100644 --- a/dbcon/execplan/windowfunctioncolumn.cpp +++ b/dbcon/execplan/windowfunctioncolumn.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/execplan/windowfunctioncolumn.h b/dbcon/execplan/windowfunctioncolumn.h index 8dee14ece..2d06b735e 100644 --- a/dbcon/execplan/windowfunctioncolumn.h +++ b/dbcon/execplan/windowfunctioncolumn.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/batchprimitiveprocessor-jl.cpp b/dbcon/joblist/batchprimitiveprocessor-jl.cpp index d8aab62b4..5481a6de9 100644 --- a/dbcon/joblist/batchprimitiveprocessor-jl.cpp +++ b/dbcon/joblist/batchprimitiveprocessor-jl.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/groupconcat.cpp b/dbcon/joblist/groupconcat.cpp index 1433bd012..3479dd015 100644 --- a/dbcon/joblist/groupconcat.cpp +++ b/dbcon/joblist/groupconcat.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/jlf_common.cpp b/dbcon/joblist/jlf_common.cpp index bdaa18252..2598b1aa7 100644 --- a/dbcon/joblist/jlf_common.cpp +++ b/dbcon/joblist/jlf_common.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/jlf_common.h b/dbcon/joblist/jlf_common.h index 76538eef9..48cdaad5b 100644 --- a/dbcon/joblist/jlf_common.h +++ b/dbcon/joblist/jlf_common.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/jlf_subquery.cpp b/dbcon/joblist/jlf_subquery.cpp index a7f99d575..d750f5e4e 100644 --- a/dbcon/joblist/jlf_subquery.cpp +++ b/dbcon/joblist/jlf_subquery.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/jlf_tuplejoblist.cpp b/dbcon/joblist/jlf_tuplejoblist.cpp index 5337215d2..b18584d6a 100644 --- a/dbcon/joblist/jlf_tuplejoblist.cpp +++ b/dbcon/joblist/jlf_tuplejoblist.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/joblist.cpp b/dbcon/joblist/joblist.cpp index bb71996c1..8a8a89065 100644 --- a/dbcon/joblist/joblist.cpp +++ b/dbcon/joblist/joblist.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/joblist.h b/dbcon/joblist/joblist.h index 3c73eff75..4940e038d 100644 --- a/dbcon/joblist/joblist.h +++ b/dbcon/joblist/joblist.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/joblistfactory.cpp b/dbcon/joblist/joblistfactory.cpp index 9f2ca5e3e..a0f575f01 100644 --- a/dbcon/joblist/joblistfactory.cpp +++ b/dbcon/joblist/joblistfactory.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/joblisttypes.h b/dbcon/joblist/joblisttypes.h index c40c949c1..6d5664c57 100644 --- a/dbcon/joblist/joblisttypes.h +++ b/dbcon/joblist/joblisttypes.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/largehashjoin.cpp b/dbcon/joblist/largehashjoin.cpp index 4cf911405..9627a50db 100644 --- a/dbcon/joblist/largehashjoin.cpp +++ b/dbcon/joblist/largehashjoin.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/primitivestep.h b/dbcon/joblist/primitivestep.h index 588dd49bb..c6e9134ff 100644 --- a/dbcon/joblist/primitivestep.h +++ b/dbcon/joblist/primitivestep.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/subquerytransformer.cpp b/dbcon/joblist/subquerytransformer.cpp index 1118e92e8..b66bcb310 100644 --- a/dbcon/joblist/subquerytransformer.cpp +++ b/dbcon/joblist/subquerytransformer.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/tdriver-agg.cpp b/dbcon/joblist/tdriver-agg.cpp index f54831ab4..636d0c86a 100644 --- a/dbcon/joblist/tdriver-agg.cpp +++ b/dbcon/joblist/tdriver-agg.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/tupleaggregatestep.cpp b/dbcon/joblist/tupleaggregatestep.cpp index 990a694b1..548eecad1 100644 --- a/dbcon/joblist/tupleaggregatestep.cpp +++ b/dbcon/joblist/tupleaggregatestep.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/tupleconstantstep.cpp b/dbcon/joblist/tupleconstantstep.cpp index 02f61eb9c..4ffb811e7 100644 --- a/dbcon/joblist/tupleconstantstep.cpp +++ b/dbcon/joblist/tupleconstantstep.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/joblist/tupleunion.cpp b/dbcon/joblist/tupleunion.cpp index 666b0d514..f3cab8ddf 100644 --- a/dbcon/joblist/tupleunion.cpp +++ b/dbcon/joblist/tupleunion.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index 525ac62b7..bb4f3ce61 100644 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_calpont.h b/dbcon/mysql/ha_calpont.h index 3d184f955..5175b25a0 100644 --- a/dbcon/mysql/ha_calpont.h +++ b/dbcon/mysql/ha_calpont.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_calpont_ddl.cpp b/dbcon/mysql/ha_calpont_ddl.cpp index 05fb71203..1fc07be6d 100644 --- a/dbcon/mysql/ha_calpont_ddl.cpp +++ b/dbcon/mysql/ha_calpont_ddl.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_calpont_dml.cpp b/dbcon/mysql/ha_calpont_dml.cpp index d98322ab3..156babf41 100644 --- a/dbcon/mysql/ha_calpont_dml.cpp +++ b/dbcon/mysql/ha_calpont_dml.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index 3767a3a8d..8846b6d6f 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 36f152578..1bcbecd98 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_calpont_impl.h b/dbcon/mysql/ha_calpont_impl.h index 7e8de5ce5..7a92f7646 100644 --- a/dbcon/mysql/ha_calpont_impl.h +++ b/dbcon/mysql/ha_calpont_impl.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_calpont_impl_if.h b/dbcon/mysql/ha_calpont_impl_if.h index 791aa999b..f6daf1b8f 100644 --- a/dbcon/mysql/ha_calpont_impl_if.h +++ b/dbcon/mysql/ha_calpont_impl_if.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_calpont_partition.cpp b/dbcon/mysql/ha_calpont_partition.cpp index 5ee2311d0..5cd957675 100644 --- a/dbcon/mysql/ha_calpont_partition.cpp +++ b/dbcon/mysql/ha_calpont_partition.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_calpont_udf.cpp b/dbcon/mysql/ha_calpont_udf.cpp index 1e6f20301..3c5b8dd41 100644 --- a/dbcon/mysql/ha_calpont_udf.cpp +++ b/dbcon/mysql/ha_calpont_udf.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_exists_sub.cpp b/dbcon/mysql/ha_exists_sub.cpp index eb6bc84b8..ee3326803 100644 --- a/dbcon/mysql/ha_exists_sub.cpp +++ b/dbcon/mysql/ha_exists_sub.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_from_sub.cpp b/dbcon/mysql/ha_from_sub.cpp index 2c2a12ec5..4d2553511 100644 --- a/dbcon/mysql/ha_from_sub.cpp +++ b/dbcon/mysql/ha_from_sub.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_in_sub.cpp b/dbcon/mysql/ha_in_sub.cpp index 3f257961a..a582ea5bf 100644 --- a/dbcon/mysql/ha_in_sub.cpp +++ b/dbcon/mysql/ha_in_sub.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_mcs_client_udfs.cpp b/dbcon/mysql/ha_mcs_client_udfs.cpp index 9113ae51b..6f6436101 100644 --- a/dbcon/mysql/ha_mcs_client_udfs.cpp +++ b/dbcon/mysql/ha_mcs_client_udfs.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_mcs_sysvars.cpp b/dbcon/mysql/ha_mcs_sysvars.cpp index 2dfadcb6a..e512527fe 100644 --- a/dbcon/mysql/ha_mcs_sysvars.cpp +++ b/dbcon/mysql/ha_mcs_sysvars.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_mcs_sysvars.h b/dbcon/mysql/ha_mcs_sysvars.h index a977842bc..38ed294cf 100644 --- a/dbcon/mysql/ha_mcs_sysvars.h +++ b/dbcon/mysql/ha_mcs_sysvars.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_scalar_sub.cpp b/dbcon/mysql/ha_scalar_sub.cpp index 8669303f9..debd777f0 100644 --- a/dbcon/mysql/ha_scalar_sub.cpp +++ b/dbcon/mysql/ha_scalar_sub.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_select_sub.cpp b/dbcon/mysql/ha_select_sub.cpp index 54124b0f9..0b003b664 100644 --- a/dbcon/mysql/ha_select_sub.cpp +++ b/dbcon/mysql/ha_select_sub.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_subquery.h b/dbcon/mysql/ha_subquery.h index b201e2fe3..d5e1df5a4 100644 --- a/dbcon/mysql/ha_subquery.h +++ b/dbcon/mysql/ha_subquery.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_view.cpp b/dbcon/mysql/ha_view.cpp index cfcfe3970..5d9c077c1 100644 --- a/dbcon/mysql/ha_view.cpp +++ b/dbcon/mysql/ha_view.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/ha_window_function.cpp b/dbcon/mysql/ha_window_function.cpp index eb02b77a3..6a8117707 100644 --- a/dbcon/mysql/ha_window_function.cpp +++ b/dbcon/mysql/ha_window_function.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dbcon/mysql/is_columnstore_columns.cpp b/dbcon/mysql/is_columnstore_columns.cpp index 278a606d4..66d97564c 100644 --- a/dbcon/mysql/is_columnstore_columns.cpp +++ b/dbcon/mysql/is_columnstore_columns.cpp @@ -2,7 +2,7 @@ * vi: set shiftwidth=4 tabstop=4 expandtab: * :indentSize=4:tabSize=4:noTabs=true: * - * Copyright (C) 2016 MariaDB Corporaton + * Copyright (C) 2016 MariaDB Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -276,7 +276,7 @@ maria_declare_plugin(is_columnstore_columns_plugin) MYSQL_INFORMATION_SCHEMA_PLUGIN, &is_columnstore_columns_plugin_version, "COLUMNSTORE_COLUMNS", - "MariaDB Corporaton", + "MariaDB Corporation", "An information schema plugin to list ColumnStore columns", PLUGIN_LICENSE_GPL, is_columnstore_columns_plugin_init, diff --git a/dbcon/mysql/is_columnstore_extents.cpp b/dbcon/mysql/is_columnstore_extents.cpp index bdde53316..99aa43eba 100644 --- a/dbcon/mysql/is_columnstore_extents.cpp +++ b/dbcon/mysql/is_columnstore_extents.cpp @@ -2,7 +2,7 @@ * vi: set shiftwidth=4 tabstop=4 expandtab: * :indentSize=4:tabSize=4:noTabs=true: * - * Copyright (C) 2016 MariaDB Corporaton + * Copyright (C) 2016 MariaDB Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -294,7 +294,7 @@ maria_declare_plugin(is_columnstore_extents_plugin) MYSQL_INFORMATION_SCHEMA_PLUGIN, &is_columnstore_extents_plugin_version, "COLUMNSTORE_EXTENTS", - "MariaDB Corporaton", + "MariaDB Corporation", "An information schema plugin to list ColumnStore extents", PLUGIN_LICENSE_GPL, is_columnstore_extents_plugin_init, diff --git a/dbcon/mysql/is_columnstore_files.cpp b/dbcon/mysql/is_columnstore_files.cpp index 9bca1de21..378985303 100644 --- a/dbcon/mysql/is_columnstore_files.cpp +++ b/dbcon/mysql/is_columnstore_files.cpp @@ -2,7 +2,7 @@ * vi: set shiftwidth=4 tabstop=4 expandtab: * :indentSize=4:tabSize=4:noTabs=true: * - * Copyright (C) 2016 MariaDB Corporaton + * Copyright (C) 2016 MariaDB Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -305,7 +305,7 @@ maria_declare_plugin(is_columnstore_files_plugin) MYSQL_INFORMATION_SCHEMA_PLUGIN, &is_columnstore_files_plugin_version, "COLUMNSTORE_FILES", - "MariaDB Corporaton", + "MariaDB Corporation", "An information schema plugin to list ColumnStore filess", PLUGIN_LICENSE_GPL, is_columnstore_files_plugin_init, diff --git a/dbcon/mysql/is_columnstore_tables.cpp b/dbcon/mysql/is_columnstore_tables.cpp index 02a5dd72e..1f66308f7 100644 --- a/dbcon/mysql/is_columnstore_tables.cpp +++ b/dbcon/mysql/is_columnstore_tables.cpp @@ -2,7 +2,7 @@ * vi: set shiftwidth=4 tabstop=4 expandtab: * :indentSize=4:tabSize=4:noTabs=true: * - * Copyright (C) 2016 MariaDB Corporaton + * Copyright (C) 2016 MariaDB Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -174,7 +174,7 @@ maria_declare_plugin(is_columnstore_tables_plugin) MYSQL_INFORMATION_SCHEMA_PLUGIN, &is_columnstore_tables_plugin_version, "COLUMNSTORE_TABLES", - "MariaDB Corporaton", + "MariaDB Corporation", "An information schema plugin to list ColumnStore tables", PLUGIN_LICENSE_GPL, is_columnstore_tables_plugin_init, diff --git a/exemgr/main.cpp b/exemgr/main.cpp index e66d7783e..4b43f71bc 100644 --- a/exemgr/main.cpp +++ b/exemgr/main.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oam/oamcpp/liboamcpp.cpp b/oam/oamcpp/liboamcpp.cpp index 927250cfc..cf43aae8e 100644 --- a/oam/oamcpp/liboamcpp.cpp +++ b/oam/oamcpp/liboamcpp.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oam/oamcpp/liboamcpp.h b/oam/oamcpp/liboamcpp.h index 5d5a09c6c..04276081d 100644 --- a/oam/oamcpp/liboamcpp.h +++ b/oam/oamcpp/liboamcpp.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oam/oamcpp/oamcache.cpp b/oam/oamcpp/oamcache.cpp index d8035bbf3..b25a72938 100644 --- a/oam/oamcpp/oamcache.cpp +++ b/oam/oamcpp/oamcache.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oam/oamcpp/oamcache.h b/oam/oamcpp/oamcache.h index 1f64fbec8..013dcf85a 100644 --- a/oam/oamcpp/oamcache.h +++ b/oam/oamcpp/oamcache.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oam/replaytxnlog/replaytxnlog.cpp b/oam/replaytxnlog/replaytxnlog.cpp index 0a1cdc9cc..78f4617d7 100644 --- a/oam/replaytxnlog/replaytxnlog.cpp +++ b/oam/replaytxnlog/replaytxnlog.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oamapps/alarmmanager/alarmglobal.h b/oamapps/alarmmanager/alarmglobal.h index 343be54a7..554f71e5e 100644 --- a/oamapps/alarmmanager/alarmglobal.h +++ b/oamapps/alarmmanager/alarmglobal.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 MariaDB Corporaton +/* Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oamapps/mcsadmin/mcsadmin.h b/oamapps/mcsadmin/mcsadmin.h index 2843090b8..66fda95c8 100644 --- a/oamapps/mcsadmin/mcsadmin.h +++ b/oamapps/mcsadmin/mcsadmin.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oamapps/postConfigure/amazonInstaller.cpp b/oamapps/postConfigure/amazonInstaller.cpp index ac46261c5..a4988b966 100644 --- a/oamapps/postConfigure/amazonInstaller.cpp +++ b/oamapps/postConfigure/amazonInstaller.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oamapps/postConfigure/helpers.h b/oamapps/postConfigure/helpers.h index 8eb23bce0..ff5c6f82e 100644 --- a/oamapps/postConfigure/helpers.h +++ b/oamapps/postConfigure/helpers.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oamapps/postConfigure/installer.cpp b/oamapps/postConfigure/installer.cpp index a0395bb57..85c8a30fa 100644 --- a/oamapps/postConfigure/installer.cpp +++ b/oamapps/postConfigure/installer.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oamapps/postConfigure/mycnfUpgrade.cpp b/oamapps/postConfigure/mycnfUpgrade.cpp index 745da6179..53cb0ce3c 100644 --- a/oamapps/postConfigure/mycnfUpgrade.cpp +++ b/oamapps/postConfigure/mycnfUpgrade.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oamapps/postConfigure/patchInstaller.cpp b/oamapps/postConfigure/patchInstaller.cpp index 9f36658c7..dd6d9ed35 100644 --- a/oamapps/postConfigure/patchInstaller.cpp +++ b/oamapps/postConfigure/patchInstaller.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oamapps/resourceMonitor/resourceMonitor.cpp b/oamapps/resourceMonitor/resourceMonitor.cpp index dcda9940d..054e86c4c 100644 --- a/oamapps/resourceMonitor/resourceMonitor.cpp +++ b/oamapps/resourceMonitor/resourceMonitor.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oamapps/serverMonitor/cpuMonitor.cpp b/oamapps/serverMonitor/cpuMonitor.cpp index 1f1d6b3b3..3d0c53a5f 100644 --- a/oamapps/serverMonitor/cpuMonitor.cpp +++ b/oamapps/serverMonitor/cpuMonitor.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oamapps/serverMonitor/dbhealthMonitor.cpp b/oamapps/serverMonitor/dbhealthMonitor.cpp index fc1899b1f..3863b4964 100644 --- a/oamapps/serverMonitor/dbhealthMonitor.cpp +++ b/oamapps/serverMonitor/dbhealthMonitor.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oamapps/serverMonitor/diskMonitor.cpp b/oamapps/serverMonitor/diskMonitor.cpp index b86a4837b..7b1e13d5d 100644 --- a/oamapps/serverMonitor/diskMonitor.cpp +++ b/oamapps/serverMonitor/diskMonitor.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oamapps/serverMonitor/memoryMonitor.cpp b/oamapps/serverMonitor/memoryMonitor.cpp index b72d17e64..d96217d56 100644 --- a/oamapps/serverMonitor/memoryMonitor.cpp +++ b/oamapps/serverMonitor/memoryMonitor.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/oamapps/serverMonitor/msgProcessor.cpp b/oamapps/serverMonitor/msgProcessor.cpp index 1c7b928ee..fe330547e 100644 --- a/oamapps/serverMonitor/msgProcessor.cpp +++ b/oamapps/serverMonitor/msgProcessor.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/primitives/blockcache/blockrequestprocessor.cpp b/primitives/blockcache/blockrequestprocessor.cpp index 063d513f4..5463005ed 100644 --- a/primitives/blockcache/blockrequestprocessor.cpp +++ b/primitives/blockcache/blockrequestprocessor.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/primitives/blockcache/filebuffermgr.cpp b/primitives/blockcache/filebuffermgr.cpp index 013ef7603..fa7071942 100644 --- a/primitives/blockcache/filebuffermgr.cpp +++ b/primitives/blockcache/filebuffermgr.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/primitives/blockcache/iomanager.cpp b/primitives/blockcache/iomanager.cpp index 2bf4526e5..716b0b69d 100644 --- a/primitives/blockcache/iomanager.cpp +++ b/primitives/blockcache/iomanager.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/primitives/blockcache/stats.cpp b/primitives/blockcache/stats.cpp index 2d31016b2..3e74f9ad4 100644 --- a/primitives/blockcache/stats.cpp +++ b/primitives/blockcache/stats.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/primitives/primproc/batchprimitiveprocessor.cpp b/primitives/primproc/batchprimitiveprocessor.cpp index bd7c7b406..8a664bd16 100644 --- a/primitives/primproc/batchprimitiveprocessor.cpp +++ b/primitives/primproc/batchprimitiveprocessor.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016, 2017 MariaDB Corporaton + Copyright (C) 2016, 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/primitives/primproc/bppseeder.cpp b/primitives/primproc/bppseeder.cpp index 4b94d0c5c..aca03af25 100644 --- a/primitives/primproc/bppseeder.cpp +++ b/primitives/primproc/bppseeder.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/primitives/primproc/primitiveserver.cpp b/primitives/primproc/primitiveserver.cpp index 54f4b7fb6..b79aabf04 100644 --- a/primitives/primproc/primitiveserver.cpp +++ b/primitives/primproc/primitiveserver.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/primitives/primproc/primitiveserver.h b/primitives/primproc/primitiveserver.h index f212fd9fd..69f0afe11 100644 --- a/primitives/primproc/primitiveserver.h +++ b/primitives/primproc/primitiveserver.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/primitives/primproc/primproc.cpp b/primitives/primproc/primproc.cpp index 79222f216..46d6cb03e 100644 --- a/primitives/primproc/primproc.cpp +++ b/primitives/primproc/primproc.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/procmgr/main.cpp b/procmgr/main.cpp index 35f544a75..2edb4c411 100644 --- a/procmgr/main.cpp +++ b/procmgr/main.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/procmgr/processmanager.cpp b/procmgr/processmanager.cpp index f05a7dcbf..25c99e88d 100644 --- a/procmgr/processmanager.cpp +++ b/procmgr/processmanager.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/procmgr/processmanager.h b/procmgr/processmanager.h index 8dc39a540..bb0766881 100644 --- a/procmgr/processmanager.h +++ b/procmgr/processmanager.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/procmon/processmonitor.cpp b/procmon/processmonitor.cpp index f22be1b87..556550a47 100644 --- a/procmon/processmonitor.cpp +++ b/procmon/processmonitor.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/tools/configMgt/autoConfigure.cpp b/tools/configMgt/autoConfigure.cpp index 10d7318ee..f6d7b51e2 100644 --- a/tools/configMgt/autoConfigure.cpp +++ b/tools/configMgt/autoConfigure.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/tools/configMgt/autoInstaller.cpp b/tools/configMgt/autoInstaller.cpp index 7dfb934e9..74f697af7 100644 --- a/tools/configMgt/autoInstaller.cpp +++ b/tools/configMgt/autoInstaller.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/tools/configMgt/configure.cpp b/tools/configMgt/configure.cpp index 22c4ea0c4..7c600c2bb 100644 --- a/tools/configMgt/configure.cpp +++ b/tools/configMgt/configure.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/common/crashtrace.cpp b/utils/common/crashtrace.cpp index 2b39ed07c..afa593d38 100644 --- a/utils/common/crashtrace.cpp +++ b/utils/common/crashtrace.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 MariaDB Corporaton +/* Copyright (C) 2018 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/common/crashtrace.h b/utils/common/crashtrace.h index 3b9cb4036..230640185 100644 --- a/utils/common/crashtrace.h +++ b/utils/common/crashtrace.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 MariaDB Corporaton +/* Copyright (C) 2018 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/common/nullvaluemanip.cpp b/utils/common/nullvaluemanip.cpp index 44ee2273a..3b4255dea 100644 --- a/utils/common/nullvaluemanip.cpp +++ b/utils/common/nullvaluemanip.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/common/threadnaming.cpp b/utils/common/threadnaming.cpp index 2f4dda91f..65498ab61 100644 --- a/utils/common/threadnaming.cpp +++ b/utils/common/threadnaming.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 MariaDB Corporaton +/* Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/common/threadnaming.h b/utils/common/threadnaming.h index 1682b7045..4cdf28d20 100644 --- a/utils/common/threadnaming.h +++ b/utils/common/threadnaming.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 MariaDB Corporaton +/* Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/dataconvert/dataconvert.cpp b/utils/dataconvert/dataconvert.cpp index b17b430fb..1d5dd4bf3 100644 --- a/utils/dataconvert/dataconvert.cpp +++ b/utils/dataconvert/dataconvert.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_abs.cpp b/utils/funcexp/func_abs.cpp index 4cef9a791..7b04408ba 100644 --- a/utils/funcexp/func_abs.cpp +++ b/utils/funcexp/func_abs.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_between.cpp b/utils/funcexp/func_between.cpp index 44908ad4b..8330c4fc0 100644 --- a/utils/funcexp/func_between.cpp +++ b/utils/funcexp/func_between.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_case.cpp b/utils/funcexp/func_case.cpp index 22705cdd0..5c429a669 100644 --- a/utils/funcexp/func_case.cpp +++ b/utils/funcexp/func_case.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_cast.cpp b/utils/funcexp/func_cast.cpp index d2db69144..cd2da831c 100644 --- a/utils/funcexp/func_cast.cpp +++ b/utils/funcexp/func_cast.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_ceil.cpp b/utils/funcexp/func_ceil.cpp index cd76df3e3..b1f886166 100644 --- a/utils/funcexp/func_ceil.cpp +++ b/utils/funcexp/func_ceil.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_coalesce.cpp b/utils/funcexp/func_coalesce.cpp index 4c3faca85..1f46a15b3 100644 --- a/utils/funcexp/func_coalesce.cpp +++ b/utils/funcexp/func_coalesce.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_exp.cpp b/utils/funcexp/func_exp.cpp index 6decbe652..217102daf 100644 --- a/utils/funcexp/func_exp.cpp +++ b/utils/funcexp/func_exp.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_floor.cpp b/utils/funcexp/func_floor.cpp index 2ec854b8c..50dd3d919 100644 --- a/utils/funcexp/func_floor.cpp +++ b/utils/funcexp/func_floor.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_from_unixtime.cpp b/utils/funcexp/func_from_unixtime.cpp index 18dba41c8..8f5f3d051 100644 --- a/utils/funcexp/func_from_unixtime.cpp +++ b/utils/funcexp/func_from_unixtime.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_greatest.cpp b/utils/funcexp/func_greatest.cpp index 388a35f20..e064eacb3 100644 --- a/utils/funcexp/func_greatest.cpp +++ b/utils/funcexp/func_greatest.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_hex.cpp b/utils/funcexp/func_hex.cpp index 7f7c7eff9..42e6b04d2 100644 --- a/utils/funcexp/func_hex.cpp +++ b/utils/funcexp/func_hex.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_if.cpp b/utils/funcexp/func_if.cpp index cc46f4a27..b17ad7317 100644 --- a/utils/funcexp/func_if.cpp +++ b/utils/funcexp/func_if.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_ifnull.cpp b/utils/funcexp/func_ifnull.cpp index 6309171fd..e479ba69c 100644 --- a/utils/funcexp/func_ifnull.cpp +++ b/utils/funcexp/func_ifnull.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_in.cpp b/utils/funcexp/func_in.cpp index 5b1aa015c..ab691ed1f 100644 --- a/utils/funcexp/func_in.cpp +++ b/utils/funcexp/func_in.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_isnull.cpp b/utils/funcexp/func_isnull.cpp index ebe1c2d88..ffda2415d 100644 --- a/utils/funcexp/func_isnull.cpp +++ b/utils/funcexp/func_isnull.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_least.cpp b/utils/funcexp/func_least.cpp index 3675e940d..5f97ee892 100644 --- a/utils/funcexp/func_least.cpp +++ b/utils/funcexp/func_least.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_math.cpp b/utils/funcexp/func_math.cpp index ff4d908da..6ef3868c2 100644 --- a/utils/funcexp/func_math.cpp +++ b/utils/funcexp/func_math.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_mod.cpp b/utils/funcexp/func_mod.cpp index 4cbdf23af..23e4df008 100644 --- a/utils/funcexp/func_mod.cpp +++ b/utils/funcexp/func_mod.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_nullif.cpp b/utils/funcexp/func_nullif.cpp index 224c2d435..a81b439dc 100644 --- a/utils/funcexp/func_nullif.cpp +++ b/utils/funcexp/func_nullif.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_pow.cpp b/utils/funcexp/func_pow.cpp index f94432b6d..4e07c8410 100644 --- a/utils/funcexp/func_pow.cpp +++ b/utils/funcexp/func_pow.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_round.cpp b/utils/funcexp/func_round.cpp index c57dda167..805f87e56 100644 --- a/utils/funcexp/func_round.cpp +++ b/utils/funcexp/func_round.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_substring_index.cpp b/utils/funcexp/func_substring_index.cpp index 04d4d9b12..a3b5c342e 100644 --- a/utils/funcexp/func_substring_index.cpp +++ b/utils/funcexp/func_substring_index.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/func_truncate.cpp b/utils/funcexp/func_truncate.cpp index a2f73753a..441047f74 100644 --- a/utils/funcexp/func_truncate.cpp +++ b/utils/funcexp/func_truncate.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/funcexp.cpp b/utils/funcexp/funcexp.cpp index c119dc549..e92bbcbcc 100644 --- a/utils/funcexp/funcexp.cpp +++ b/utils/funcexp/funcexp.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/funchelpers.h b/utils/funcexp/funchelpers.h index e1290d230..e579ebb57 100644 --- a/utils/funcexp/funchelpers.h +++ b/utils/funcexp/funchelpers.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/functor.cpp b/utils/funcexp/functor.cpp index 28fd64cbe..06999c9fd 100644 --- a/utils/funcexp/functor.cpp +++ b/utils/funcexp/functor.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/functor.h b/utils/funcexp/functor.h index 8eb494313..357d8639d 100644 --- a/utils/funcexp/functor.h +++ b/utils/funcexp/functor.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/functor_all.h b/utils/funcexp/functor_all.h index a1daa0687..155e00656 100644 --- a/utils/funcexp/functor_all.h +++ b/utils/funcexp/functor_all.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/functor_dtm.h b/utils/funcexp/functor_dtm.h index fddd0a002..f9b61ee80 100644 --- a/utils/funcexp/functor_dtm.h +++ b/utils/funcexp/functor_dtm.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/functor_export.h b/utils/funcexp/functor_export.h index af7ca6cee..3d7405cc2 100644 --- a/utils/funcexp/functor_export.h +++ b/utils/funcexp/functor_export.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/functor_int.h b/utils/funcexp/functor_int.h index e5b0093a9..78655a892 100644 --- a/utils/funcexp/functor_int.h +++ b/utils/funcexp/functor_int.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/functor_real.h b/utils/funcexp/functor_real.h index a5ae4d317..717e2208e 100644 --- a/utils/funcexp/functor_real.h +++ b/utils/funcexp/functor_real.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/funcexp/functor_str.h b/utils/funcexp/functor_str.h index 2f772974a..24337aab9 100644 --- a/utils/funcexp/functor_str.h +++ b/utils/funcexp/functor_str.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/joiner/joinpartition.cpp b/utils/joiner/joinpartition.cpp index 4982ed750..e3b763120 100644 --- a/utils/joiner/joinpartition.cpp +++ b/utils/joiner/joinpartition.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/joiner/tuplejoiner.cpp b/utils/joiner/tuplejoiner.cpp index ff64b8283..f8ac47b98 100644 --- a/utils/joiner/tuplejoiner.cpp +++ b/utils/joiner/tuplejoiner.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/joiner/tuplejoiner.h b/utils/joiner/tuplejoiner.h index 7302876e0..83d68dfca 100644 --- a/utils/joiner/tuplejoiner.h +++ b/utils/joiner/tuplejoiner.h @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/loggingcpp/messagelog.cpp b/utils/loggingcpp/messagelog.cpp index a1dd850e2..6ddda51dd 100644 --- a/utils/loggingcpp/messagelog.cpp +++ b/utils/loggingcpp/messagelog.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/loggingcpp/tdriver.cpp b/utils/loggingcpp/tdriver.cpp index 16b98c5da..3e1342afa 100644 --- a/utils/loggingcpp/tdriver.cpp +++ b/utils/loggingcpp/tdriver.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/messageqcpp/bytestream.cpp b/utils/messageqcpp/bytestream.cpp index 003c35fd4..6ecbf625d 100644 --- a/utils/messageqcpp/bytestream.cpp +++ b/utils/messageqcpp/bytestream.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/messageqcpp/bytestream.h b/utils/messageqcpp/bytestream.h index cf3eb2057..7e39abc31 100644 --- a/utils/messageqcpp/bytestream.h +++ b/utils/messageqcpp/bytestream.h @@ -1,6 +1,6 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporaton + Copyright (C) 2019 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/messageqcpp/messagequeuepool.cpp b/utils/messageqcpp/messagequeuepool.cpp index f986f734f..f3cbcb2bc 100644 --- a/utils/messageqcpp/messagequeuepool.cpp +++ b/utils/messageqcpp/messagequeuepool.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/messageqcpp/messagequeuepool.h b/utils/messageqcpp/messagequeuepool.h index db49d8e5c..553328e7b 100644 --- a/utils/messageqcpp/messagequeuepool.h +++ b/utils/messageqcpp/messagequeuepool.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/corr.cpp b/utils/regr/corr.cpp index ac69357df..ac8c090bf 100644 --- a/utils/regr/corr.cpp +++ b/utils/regr/corr.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/corr.h b/utils/regr/corr.h index 389b61195..850690da4 100644 --- a/utils/regr/corr.h +++ b/utils/regr/corr.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/covar_pop.cpp b/utils/regr/covar_pop.cpp index 672da9d75..f3794f89e 100644 --- a/utils/regr/covar_pop.cpp +++ b/utils/regr/covar_pop.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/covar_pop.h b/utils/regr/covar_pop.h index c3f6dde4a..dd675c7fa 100644 --- a/utils/regr/covar_pop.h +++ b/utils/regr/covar_pop.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/covar_samp.cpp b/utils/regr/covar_samp.cpp index 81e9fc212..98fa99fe9 100644 --- a/utils/regr/covar_samp.cpp +++ b/utils/regr/covar_samp.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/covar_samp.h b/utils/regr/covar_samp.h index fe0352fe8..f1511a364 100644 --- a/utils/regr/covar_samp.h +++ b/utils/regr/covar_samp.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_avgx.cpp b/utils/regr/regr_avgx.cpp index c27d075ad..bec098116 100644 --- a/utils/regr/regr_avgx.cpp +++ b/utils/regr/regr_avgx.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_avgx.h b/utils/regr/regr_avgx.h index e76ecf56c..58138eff3 100644 --- a/utils/regr/regr_avgx.h +++ b/utils/regr/regr_avgx.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_avgy.cpp b/utils/regr/regr_avgy.cpp index f22959354..512e3e48d 100644 --- a/utils/regr/regr_avgy.cpp +++ b/utils/regr/regr_avgy.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_avgy.h b/utils/regr/regr_avgy.h index 9e425a7bd..957becdd7 100644 --- a/utils/regr/regr_avgy.h +++ b/utils/regr/regr_avgy.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_count.cpp b/utils/regr/regr_count.cpp index 8b5993d33..7d893e16f 100644 --- a/utils/regr/regr_count.cpp +++ b/utils/regr/regr_count.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_count.h b/utils/regr/regr_count.h index 0fa140d56..b63a2d582 100644 --- a/utils/regr/regr_count.h +++ b/utils/regr/regr_count.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_intercept.cpp b/utils/regr/regr_intercept.cpp index 9b457243c..5e05eea19 100644 --- a/utils/regr/regr_intercept.cpp +++ b/utils/regr/regr_intercept.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_intercept.h b/utils/regr/regr_intercept.h index 50c7fbdd9..2ccd272f5 100644 --- a/utils/regr/regr_intercept.h +++ b/utils/regr/regr_intercept.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_r2.cpp b/utils/regr/regr_r2.cpp index 60bcad65c..2f28afe3e 100644 --- a/utils/regr/regr_r2.cpp +++ b/utils/regr/regr_r2.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_r2.h b/utils/regr/regr_r2.h index fac04eac8..26082d979 100644 --- a/utils/regr/regr_r2.h +++ b/utils/regr/regr_r2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_slope.cpp b/utils/regr/regr_slope.cpp index 17e662f2c..2a3445da4 100644 --- a/utils/regr/regr_slope.cpp +++ b/utils/regr/regr_slope.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_slope.h b/utils/regr/regr_slope.h index d32223ae9..d14639cf1 100644 --- a/utils/regr/regr_slope.h +++ b/utils/regr/regr_slope.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_sxx.cpp b/utils/regr/regr_sxx.cpp index 2338d4436..0903148dc 100644 --- a/utils/regr/regr_sxx.cpp +++ b/utils/regr/regr_sxx.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_sxx.h b/utils/regr/regr_sxx.h index 82ec7e154..2f180483c 100644 --- a/utils/regr/regr_sxx.h +++ b/utils/regr/regr_sxx.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_sxy.cpp b/utils/regr/regr_sxy.cpp index daef4333e..092d3c375 100644 --- a/utils/regr/regr_sxy.cpp +++ b/utils/regr/regr_sxy.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_sxy.h b/utils/regr/regr_sxy.h index 47e6c30e6..83517e113 100644 --- a/utils/regr/regr_sxy.h +++ b/utils/regr/regr_sxy.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_syy.cpp b/utils/regr/regr_syy.cpp index 6d803d992..0fc3102ed 100644 --- a/utils/regr/regr_syy.cpp +++ b/utils/regr/regr_syy.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/regr/regr_syy.h b/utils/regr/regr_syy.h index 26c8cc1e7..05d7e5f8f 100644 --- a/utils/regr/regr_syy.h +++ b/utils/regr/regr_syy.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/startup/installdir.cpp b/utils/startup/installdir.cpp index 5a15a651b..b49bbc743 100644 --- a/utils/startup/installdir.cpp +++ b/utils/startup/installdir.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/testbc/stats.cpp b/utils/testbc/stats.cpp index ff1886233..1dd2442e3 100644 --- a/utils/testbc/stats.cpp +++ b/utils/testbc/stats.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/udfsdk/allnull.cpp b/utils/udfsdk/allnull.cpp index ee6669789..79f978124 100644 --- a/utils/udfsdk/allnull.cpp +++ b/utils/udfsdk/allnull.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/udfsdk/allnull.h b/utils/udfsdk/allnull.h index 40e5ce709..203bfbbaf 100644 --- a/utils/udfsdk/allnull.h +++ b/utils/udfsdk/allnull.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/udfsdk/avg_mode.cpp b/utils/udfsdk/avg_mode.cpp index 317ccce93..87b2d6b2e 100644 --- a/utils/udfsdk/avg_mode.cpp +++ b/utils/udfsdk/avg_mode.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/udfsdk/avg_mode.h b/utils/udfsdk/avg_mode.h index d37c3b83b..da0962c7f 100644 --- a/utils/udfsdk/avg_mode.h +++ b/utils/udfsdk/avg_mode.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/udfsdk/avgx.cpp b/utils/udfsdk/avgx.cpp index a7ee4eb75..b0c666541 100644 --- a/utils/udfsdk/avgx.cpp +++ b/utils/udfsdk/avgx.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/udfsdk/avgx.h b/utils/udfsdk/avgx.h index 0268df021..61d3d02b6 100644 --- a/utils/udfsdk/avgx.h +++ b/utils/udfsdk/avgx.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/udfsdk/distinct_count.cpp b/utils/udfsdk/distinct_count.cpp index 11c2ce776..e622bf324 100644 --- a/utils/udfsdk/distinct_count.cpp +++ b/utils/udfsdk/distinct_count.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/udfsdk/distinct_count.h b/utils/udfsdk/distinct_count.h index 7ad43f952..5e0fa84ac 100644 --- a/utils/udfsdk/distinct_count.h +++ b/utils/udfsdk/distinct_count.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/udfsdk/mcsv1_udaf.cpp b/utils/udfsdk/mcsv1_udaf.cpp index 4dc30a3ef..b16036e05 100644 --- a/utils/udfsdk/mcsv1_udaf.cpp +++ b/utils/udfsdk/mcsv1_udaf.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/udfsdk/mcsv1_udaf.h b/utils/udfsdk/mcsv1_udaf.h index d55002c49..79d40ccf5 100644 --- a/utils/udfsdk/mcsv1_udaf.h +++ b/utils/udfsdk/mcsv1_udaf.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/udfsdk/median.cpp b/utils/udfsdk/median.cpp index 2d4750e4d..3ef7a0187 100644 --- a/utils/udfsdk/median.cpp +++ b/utils/udfsdk/median.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/udfsdk/median.h b/utils/udfsdk/median.h index ead9eede4..5ae3025dd 100644 --- a/utils/udfsdk/median.h +++ b/utils/udfsdk/median.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/udfsdk/ssq.cpp b/utils/udfsdk/ssq.cpp index 4886acdb1..9b4c411aa 100644 --- a/utils/udfsdk/ssq.cpp +++ b/utils/udfsdk/ssq.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/utils/udfsdk/ssq.h b/utils/udfsdk/ssq.h index 58d42084b..c291d7fd1 100644 --- a/utils/udfsdk/ssq.h +++ b/utils/udfsdk/ssq.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 MariaDB Corporaton +/* Copyright (C) 2017 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/versioning/BRM/slavecomm.cpp b/versioning/BRM/slavecomm.cpp index 38aa35d00..e61fe60f8 100644 --- a/versioning/BRM/slavecomm.cpp +++ b/versioning/BRM/slavecomm.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/versioning/BRM/tracer.cpp b/versioning/BRM/tracer.cpp index d2cd35ccc..869b82197 100644 --- a/versioning/BRM/tracer.cpp +++ b/versioning/BRM/tracer.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/writeengine/redistribute/we_redistributecontrol.cpp b/writeengine/redistribute/we_redistributecontrol.cpp index c28ebfef5..c0c975cb3 100644 --- a/writeengine/redistribute/we_redistributecontrol.cpp +++ b/writeengine/redistribute/we_redistributecontrol.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/writeengine/redistribute/we_redistributecontrolthread.cpp b/writeengine/redistribute/we_redistributecontrolthread.cpp index 70b5d1e2d..90f4fbaf9 100644 --- a/writeengine/redistribute/we_redistributecontrolthread.cpp +++ b/writeengine/redistribute/we_redistributecontrolthread.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/writeengine/splitter/we_cmdargs.cpp b/writeengine/splitter/we_cmdargs.cpp index 7ed626f26..8c520924d 100644 --- a/writeengine/splitter/we_cmdargs.cpp +++ b/writeengine/splitter/we_cmdargs.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/writeengine/wrapper/tdriver.cpp b/writeengine/wrapper/tdriver.cpp index ecabe1a10..f2044e3e8 100644 --- a/writeengine/wrapper/tdriver.cpp +++ b/writeengine/wrapper/tdriver.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2016 MariaDB Corporaton + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License From 7b006b6e74cb8fbafc029fcb8de7e27c01767ec5 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Fri, 9 Aug 2019 11:51:55 +0100 Subject: [PATCH 54/59] MCOL-104 Remove InfiniDB Engine Remove the InfiniDB engine which is a duplicate of the ColumnStore engine. --- dbcon/execplan/calpontsystemcatalog.cpp | 2 +- dbcon/execplan/pseudocolumn.cpp | 2 +- dbcon/execplan/simplecolumn.cpp | 2 +- dbcon/mysql/ha_calpont.cpp | 73 ------------------------- dbcon/mysql/install_calpont_mysql.sh | 1 - dbcon/mysql/syscatalog_mysql.sql | 7 ++- writeengine/bulk/cpimport.cpp | 2 +- 7 files changed, 9 insertions(+), 80 deletions(-) diff --git a/dbcon/execplan/calpontsystemcatalog.cpp b/dbcon/execplan/calpontsystemcatalog.cpp index 234fb6235..2f62ec1e5 100644 --- a/dbcon/execplan/calpontsystemcatalog.cpp +++ b/dbcon/execplan/calpontsystemcatalog.cpp @@ -5649,7 +5649,7 @@ const string CalpontSystemCatalog::TableName::toString() const ostream& operator<<(ostream& os, const CalpontSystemCatalog::TableAliasName& rhs) { os << rhs.schema << '.' << rhs.table << "(" << rhs.alias << "/" << rhs.view - << ") engineType=" << (rhs.fIsInfiniDB ? "Columnstore" : "ForeignEngine"); + << ") engineType=" << (rhs.fIsInfiniDB ? "ColumnStore" : "ForeignEngine"); return os; } diff --git a/dbcon/execplan/pseudocolumn.cpp b/dbcon/execplan/pseudocolumn.cpp index e2303fec4..e4305295f 100644 --- a/dbcon/execplan/pseudocolumn.cpp +++ b/dbcon/execplan/pseudocolumn.cpp @@ -155,7 +155,7 @@ const string PseudoColumn::toString() const << cardinality() << '/' << joinInfo() << '/' << colSource() << '/' - << (isInfiniDB() ? "InfiniDB" : "ForeignEngine") << endl; + << (isInfiniDB() ? "ColumnStore" : "ForeignEngine") << endl; output << "Pseudotype=" << fPseudoType << endl; return output.str(); diff --git a/dbcon/execplan/simplecolumn.cpp b/dbcon/execplan/simplecolumn.cpp index 68f09ee26..009ae2faf 100644 --- a/dbcon/execplan/simplecolumn.cpp +++ b/dbcon/execplan/simplecolumn.cpp @@ -264,7 +264,7 @@ const string SimpleColumn::toString() const << cardinality() << '/' << joinInfo() << '/' << colSource() << '/' - << (isInfiniDB() ? "InfiniDB" : "ForeignEngine") << '/' + << (isInfiniDB() ? "ColumnStore" : "ForeignEngine") << '/' << colPosition() << endl; return output.str(); diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index 525ac62b7..0e4ab9f58 100644 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -149,39 +149,6 @@ static int columnstore_init_func(void* p) DBUG_RETURN(0); } -static int infinidb_init_func(void* p) -{ - DBUG_ENTER("infinidb_init_func"); - - struct tm tm; - time_t t; - - time(&t); - localtime_r(&t, &tm); - fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d ", - tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); - - fprintf(stderr, "Columnstore: Started; Version: %s-%s\n", columnstore_version.c_str(), columnstore_release.c_str()); - - calpont_hton = (handlerton*)p; - - calpont_hton->state = SHOW_OPTION_YES; - calpont_hton->create = calpont_create_handler; - calpont_hton->flags = HTON_CAN_RECREATE; -// calpont_hton->discover_table= calpont_discover; -// calpont_hton->discover_table_existence= calpont_discover_existence; - calpont_hton->commit = calpont_commit; - calpont_hton->rollback = calpont_rollback; - calpont_hton->close_connection = calpont_close_connection; - calpont_hton->create_group_by = create_calpont_group_by_handler; - //calpont_hton->create_derived = create_columnstore_derived_handler; - calpont_hton->create_select = create_columnstore_select_handler; - - DBUG_RETURN(0); -} - - static int columnstore_done_func(void* p) { DBUG_ENTER("calpont_done_func"); @@ -193,13 +160,6 @@ static int columnstore_done_func(void* p) DBUG_RETURN(0); } -static int infinidb_done_func(void* p) -{ - DBUG_ENTER("calpont_done_func"); - - DBUG_RETURN(0); -} - static handler* calpont_create_handler(handlerton* hton, TABLE_SHARE* table, MEM_ROOT* mem_root) @@ -944,9 +904,6 @@ const COND* ha_calpont::cond_push(const COND* cond) struct st_mysql_storage_engine columnstore_storage_engine = { MYSQL_HANDLERTON_INTERFACE_VERSION }; -struct st_mysql_storage_engine infinidb_storage_engine = -{ MYSQL_HANDLERTON_INTERFACE_VERSION }; - #include "ha_mcs_pushdown.cpp" mysql_declare_plugin(columnstore) @@ -964,21 +921,6 @@ mysql_declare_plugin(columnstore) mcs_system_variables, /* system variables */ NULL, /* reserved */ 0 /* config flags */ -}, -{ - MYSQL_STORAGE_ENGINE_PLUGIN, - &infinidb_storage_engine, - "InfiniDB", - "MariaDB", - "Columnstore storage engine (deprecated: use columnstore)", - PLUGIN_LICENSE_GPL, - infinidb_init_func, /* Plugin Init */ - infinidb_done_func, /* Plugin Deinit */ - 0x0100 /* 1.0 */, - NULL, /* status variables */ - mcs_system_variables, /* system variables */ - NULL, /* reserved */ - 0 /* config flags */ } mysql_declare_plugin_end; maria_declare_plugin(columnstore) @@ -996,21 +938,6 @@ maria_declare_plugin(columnstore) mcs_system_variables, /* system variables */ "1.0", /* string version */ MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ -}, -{ - MYSQL_STORAGE_ENGINE_PLUGIN, - &infinidb_storage_engine, - "InfiniDB", - "MariaDB", - "Columnstore storage engine (deprecated: use columnstore)", - PLUGIN_LICENSE_GPL, - infinidb_init_func, - infinidb_done_func, - 0x0100, /* 1.0 */ - NULL, /* status variables */ - mcs_system_variables, /* system variables */ - "1.0", /* string version */ - MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ } maria_declare_plugin_end; diff --git a/dbcon/mysql/install_calpont_mysql.sh b/dbcon/mysql/install_calpont_mysql.sh index 2a7c79883..d6fc8fb4d 100755 --- a/dbcon/mysql/install_calpont_mysql.sh +++ b/dbcon/mysql/install_calpont_mysql.sh @@ -28,7 +28,6 @@ df=$installdir/mysql/my.cnf $installdir/mysql/bin/mysql --defaults-extra-file=$df --force --user=root mysql 2> ${tmpdir}/mysql_install.log <isSystemReady()) { startupError( std::string( - "System is not ready. Verify that InfiniDB is up and ready " + "System is not ready. Verify that ColumnStore is up and ready " "before running cpimport."), false ); } From 9d83b49fca51b1f5eef8ef8b95c3a43224a0eb2d Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Mon, 12 Aug 2019 09:41:28 +0100 Subject: [PATCH 55/59] MCOL-104 First pass of InfiniDB rename in code --- README | 8 +- dbcon/execplan/calpontsystemcatalog.cpp | 16 ++-- dbcon/execplan/calpontsystemcatalog.h | 14 +-- dbcon/execplan/pseudocolumn.cpp | 8 +- dbcon/execplan/pseudocolumn.h | 2 +- dbcon/execplan/simplecolumn.cpp | 26 +++--- dbcon/execplan/simplecolumn.h | 12 +-- dbcon/execplan/simplecolumn_decimal.h | 6 +- dbcon/execplan/simplecolumn_int.h | 6 +- dbcon/execplan/simplecolumn_uint.h | 6 +- dbcon/joblist/expressionstep.cpp | 4 +- dbcon/joblist/jlf_common.cpp | 8 +- dbcon/joblist/jlf_execplantojoblist.cpp | 22 ++--- dbcon/joblist/jlf_subquery.cpp | 2 +- dbcon/joblist/joblistfactory.cpp | 12 +-- dbcon/mysql/ha_calpont.cpp | 2 +- dbcon/mysql/ha_calpont.h | 6 +- dbcon/mysql/ha_calpont_execplan.cpp | 98 ++++++++++----------- dbcon/mysql/ha_mcs_pushdown.h | 8 +- dbcon/mysql/ha_mcs_sysvars.cpp | 4 +- dbcon/mysql/ha_pseudocolumn.cpp | 2 +- dbcon/mysql/ha_view.cpp | 6 +- dbcon/mysql/sm.cpp | 8 +- dbcon/mysql/sm.h | 6 +- oam/install_scripts/myCnf-include-args.text | 4 +- procmon/main.cpp | 4 +- procmon/processmonitor.cpp | 8 +- tools/clearShm/main.cpp | 4 +- tools/cleartablelock/cleartablelock.cpp | 2 +- tools/dbloadxml/colxml.cpp | 2 +- utils/dataconvert/dataconvert.cpp | 4 +- utils/funcexp/func_cast.cpp | 2 +- utils/loggingcpp/ErrorMessage.txt | 8 +- versioning/BRM/reset_locks.cpp | 2 +- writeengine/xml/we_xmljob.cpp | 8 +- 35 files changed, 170 insertions(+), 170 deletions(-) diff --git a/README b/README index bc8efde2c..5163c1d34 100644 --- a/README +++ b/README @@ -1,9 +1,9 @@ -This is MariaDB ColumnStore 1.2 -MariaDB ColumnStore 1.2 is the GA version of MariaDB ColumnStore. -It is built by porting InfiniDB 4.6.7 on MariaDB 10.2 and adding entirely +This is MariaDB ColumnStore 1.4 +MariaDB ColumnStore 1.4 is the GA version of MariaDB ColumnStore. +It is built by porting InfiniDB 4.6.7 on MariaDB and adding entirely new features not found anywhere else. -MariaDB ColumnStore 1.2 is a GA. +MariaDB ColumnStore 1.4 is a Alpha. Additional features will be pushed in future releases. A few things to notice: diff --git a/dbcon/execplan/calpontsystemcatalog.cpp b/dbcon/execplan/calpontsystemcatalog.cpp index 2f62ec1e5..27d9724fb 100644 --- a/dbcon/execplan/calpontsystemcatalog.cpp +++ b/dbcon/execplan/calpontsystemcatalog.cpp @@ -269,28 +269,28 @@ const CalpontSystemCatalog::TableName make_table(const string& s, const string& return tn; } -const CalpontSystemCatalog::TableAliasName make_aliastable(const string& s, const string& t, const string& a, const bool isInfiniDB) +const CalpontSystemCatalog::TableAliasName make_aliastable(const string& s, const string& t, const string& a, const bool isColumnStore) { CalpontSystemCatalog::TableAliasName tn; tn.schema = s; tn.table = t; tn.alias = a; tn.view = ""; - tn.fIsInfiniDB = isInfiniDB; + tn.fisColumnStore = isColumnStore; transform (tn.schema.begin(), tn.schema.end(), tn.schema.begin(), to_lower()); transform (tn.table.begin(), tn.table.end(), tn.table.begin(), to_lower()); transform (tn.alias.begin(), tn.alias.end(), tn.alias.begin(), to_lower()); return tn; } -const CalpontSystemCatalog::TableAliasName make_aliasview(const string& s, const string& t, const string& a, const string& v, const bool isInfiniDB) +const CalpontSystemCatalog::TableAliasName make_aliasview(const string& s, const string& t, const string& a, const string& v, const bool isColumnStore) { CalpontSystemCatalog::TableAliasName tn; tn.schema = s; tn.table = t; tn.alias = a; tn.view = v; - tn.fIsInfiniDB = isInfiniDB; + tn.fisColumnStore = isColumnStore; transform (tn.schema.begin(), tn.schema.end(), tn.schema.begin(), to_lower()); transform (tn.table.begin(), tn.table.end(), tn.table.begin(), to_lower()); transform (tn.alias.begin(), tn.alias.end(), tn.alias.begin(), to_lower()); @@ -380,7 +380,7 @@ bool CalpontSystemCatalog::TableAliasName::operator<(const TableAliasName& rhs) } else if (view == rhs.view) { - if (fIsInfiniDB < rhs.fIsInfiniDB) + if (fisColumnStore < rhs.fisColumnStore) return true; } } @@ -396,7 +396,7 @@ void CalpontSystemCatalog::TableAliasName::serialize(messageqcpp::ByteStream& b) b << table; b << alias; b << view; - b << static_cast(fIsInfiniDB); + b << static_cast(fisColumnStore); } void CalpontSystemCatalog::TableAliasName::unserialize(messageqcpp::ByteStream& b) @@ -405,7 +405,7 @@ void CalpontSystemCatalog::TableAliasName::unserialize(messageqcpp::ByteStream& b >> table; b >> alias; b >> view; - b >> reinterpret_cast< ByteStream::doublebyte&>(fIsInfiniDB); + b >> reinterpret_cast< ByteStream::doublebyte&>(fisColumnStore); } /*static*/ @@ -5649,7 +5649,7 @@ const string CalpontSystemCatalog::TableName::toString() const ostream& operator<<(ostream& os, const CalpontSystemCatalog::TableAliasName& rhs) { os << rhs.schema << '.' << rhs.table << "(" << rhs.alias << "/" << rhs.view - << ") engineType=" << (rhs.fIsInfiniDB ? "ColumnStore" : "ForeignEngine"); + << ") engineType=" << (rhs.fisColumnStore ? "ColumnStore" : "ForeignEngine"); return os; } diff --git a/dbcon/execplan/calpontsystemcatalog.h b/dbcon/execplan/calpontsystemcatalog.h index 188dae4e6..383896fef 100644 --- a/dbcon/execplan/calpontsystemcatalog.h +++ b/dbcon/execplan/calpontsystemcatalog.h @@ -429,16 +429,16 @@ public: */ struct TableAliasName { - TableAliasName (): fIsInfiniDB (true) {} + TableAliasName (): fisColumnStore (true) {} TableAliasName (std::string sch, std::string tb, std::string al) : - schema (sch), table (tb), alias (al), fIsInfiniDB(true) {} + schema (sch), table (tb), alias (al), fisColumnStore(true) {} TableAliasName (std::string sch, std::string tb, std::string al, std::string v) : - schema (sch), table (tb), alias (al), view(v), fIsInfiniDB(true) {} + schema (sch), table (tb), alias (al), view(v), fisColumnStore(true) {} std::string schema; std::string table; std::string alias; std::string view; - bool fIsInfiniDB; + bool fisColumnStore; void clear(); bool operator<(const TableAliasName& rhs) const; bool operator>=(const TableAliasName& rhs) const @@ -451,7 +451,7 @@ public: table == rhs.table && alias == rhs.alias && view == rhs.view && - fIsInfiniDB == rhs.fIsInfiniDB); + fisColumnStore == rhs.fisColumnStore); } bool operator!=(const TableAliasName& rhs) const { @@ -962,8 +962,8 @@ const CalpontSystemCatalog::TableColName make_tcn(const std::string& s, const st */ const CalpontSystemCatalog::TableName make_table(const std::string& s, const std::string& t); const CalpontSystemCatalog::TableAliasName make_aliastable(const std::string& s, const std::string& t, const std::string& a, - const bool fIsInfiniDB = true); -const CalpontSystemCatalog::TableAliasName make_aliasview(const std::string& s, const std::string& t, const std::string& a, const std::string& v, const bool fIsInfiniDB = true); + const bool fisColumnStore = true); +const CalpontSystemCatalog::TableAliasName make_aliasview(const std::string& s, const std::string& t, const std::string& a, const std::string& v, const bool fisColumnStore = true); /** convenience function to determine if column type is a char * type diff --git a/dbcon/execplan/pseudocolumn.cpp b/dbcon/execplan/pseudocolumn.cpp index e4305295f..dcf35596b 100644 --- a/dbcon/execplan/pseudocolumn.cpp +++ b/dbcon/execplan/pseudocolumn.cpp @@ -72,10 +72,10 @@ PseudoColumn::PseudoColumn(const string& schemaName, PseudoColumn::PseudoColumn(const string& schemaName, const string& tableName, const string& columnName, - const bool isInfiniDB, + const bool isColumnStore, const uint32_t pseudoType, const uint32_t sessionID): - SimpleColumn(schemaName, tableName, columnName, isInfiniDB, sessionID), + SimpleColumn(schemaName, tableName, columnName, isColumnStore, sessionID), fPseudoType(pseudoType) { adjustResultType(); @@ -122,7 +122,7 @@ PseudoColumn& PseudoColumn::operator=(const PseudoColumn& rhs) fData = rhs.data(); fSequence = rhs.sequence(); fDistinct = rhs.distinct(); - fIsInfiniDB = rhs.isInfiniDB(); + fisColumnStore = rhs.isColumnStore(); fPseudoType = rhs.pseudoType(); } @@ -155,7 +155,7 @@ const string PseudoColumn::toString() const << cardinality() << '/' << joinInfo() << '/' << colSource() << '/' - << (isInfiniDB() ? "ColumnStore" : "ForeignEngine") << endl; + << (isColumnStore() ? "ColumnStore" : "ForeignEngine") << endl; output << "Pseudotype=" << fPseudoType << endl; return output.str(); diff --git a/dbcon/execplan/pseudocolumn.h b/dbcon/execplan/pseudocolumn.h index 6a48a65d4..55419e8cc 100644 --- a/dbcon/execplan/pseudocolumn.h +++ b/dbcon/execplan/pseudocolumn.h @@ -78,7 +78,7 @@ public: PseudoColumn(const std::string& schema, const std::string& table, const std::string& col, - const bool isInfiniDB, + const bool isColumnStore, const uint32_t pseudoType, const uint32_t sessionID = 0); PseudoColumn(const SimpleColumn& rhs, const uint32_t pseudoType, const uint32_t sessionID = 0); diff --git a/dbcon/execplan/simplecolumn.cpp b/dbcon/execplan/simplecolumn.cpp index 009ae2faf..0e43390bf 100644 --- a/dbcon/execplan/simplecolumn.cpp +++ b/dbcon/execplan/simplecolumn.cpp @@ -139,7 +139,7 @@ ParseTree* replaceRefCol(ParseTree*& n, CalpontSelectExecutionPlan::ReturnedColu SimpleColumn::SimpleColumn(): ReturnedColumn(), fOid (0), - fIsInfiniDB (true) + fisColumnStore (true) { fDistinct = false; } @@ -148,7 +148,7 @@ SimpleColumn::SimpleColumn(const string& token, const uint32_t sessionID): ReturnedColumn(sessionID), fOid (0), fData(token), - fIsInfiniDB (true) + fisColumnStore (true) { parse (token); setOID(); @@ -163,7 +163,7 @@ SimpleColumn::SimpleColumn(const string& schemaName, fSchemaName (schemaName), fTableName (tableName), fColumnName (columnName), - fIsInfiniDB (true) + fisColumnStore (true) { setOID(); fDistinct = false; @@ -172,15 +172,15 @@ SimpleColumn::SimpleColumn(const string& schemaName, SimpleColumn::SimpleColumn(const string& schemaName, const string& tableName, const string& columnName, - const bool isInfiniDB, + const bool isColumnStore, const uint32_t sessionID): ReturnedColumn(sessionID), fSchemaName (schemaName), fTableName (tableName), fColumnName (columnName), - fIsInfiniDB (isInfiniDB) + fisColumnStore (isColumnStore) { - if (isInfiniDB) + if (isColumnStore) setOID(); fDistinct = false; @@ -197,7 +197,7 @@ SimpleColumn::SimpleColumn (const SimpleColumn& rhs, const uint32_t sessionID): fIndexName (rhs.indexName()), fViewName (rhs.viewName()), fTimeZone (rhs.timeZone()), - fIsInfiniDB (rhs.isInfiniDB()) + fisColumnStore (rhs.isColumnStore()) { } @@ -234,7 +234,7 @@ SimpleColumn& SimpleColumn::operator=(const SimpleColumn& rhs) fData = rhs.data(); fSequence = rhs.sequence(); fDistinct = rhs.distinct(); - fIsInfiniDB = rhs.isInfiniDB(); + fisColumnStore = rhs.isColumnStore(); } return *this; @@ -264,7 +264,7 @@ const string SimpleColumn::toString() const << cardinality() << '/' << joinInfo() << '/' << colSource() << '/' - << (isInfiniDB() ? "ColumnStore" : "ForeignEngine") << '/' + << (isColumnStore() ? "ColumnStore" : "ForeignEngine") << '/' << colPosition() << endl; return output.str(); @@ -352,7 +352,7 @@ void SimpleColumn::serialize(messageqcpp::ByteStream& b) const b << fData; b << fTableAlias; b << (uint32_t) fSequence; - b << static_cast(fIsInfiniDB); + b << static_cast(fisColumnStore); } void SimpleColumn::unserialize(messageqcpp::ByteStream& b) @@ -369,7 +369,7 @@ void SimpleColumn::unserialize(messageqcpp::ByteStream& b) b >> fData; b >> fTableAlias; b >> (uint32_t&) fSequence; - b >> reinterpret_cast< ByteStream::doublebyte&>(fIsInfiniDB); + b >> reinterpret_cast< ByteStream::doublebyte&>(fisColumnStore); } bool SimpleColumn::operator==(const SimpleColumn& t) const @@ -412,7 +412,7 @@ bool SimpleColumn::operator==(const SimpleColumn& t) const if (fReturnAll != t.fReturnAll) return false; - if (fIsInfiniDB != t.fIsInfiniDB) + if (fisColumnStore != t.fisColumnStore) return false; return true; @@ -452,7 +452,7 @@ bool SimpleColumn::sameColumn(const ReturnedColumn* rc) const fColumnName.compare(sc->columnName()) == 0 && fTableAlias.compare(sc->tableAlias()) == 0 && fViewName.compare(sc->viewName()) == 0 && - fIsInfiniDB == sc->isInfiniDB()); + fisColumnStore == sc->isColumnStore()); } void SimpleColumn::setDerivedTable() diff --git a/dbcon/execplan/simplecolumn.h b/dbcon/execplan/simplecolumn.h index cb63e9683..45332f695 100644 --- a/dbcon/execplan/simplecolumn.h +++ b/dbcon/execplan/simplecolumn.h @@ -70,7 +70,7 @@ public: SimpleColumn(const std::string& schema, const std::string& table, const std::string& col, - const bool isInfiniDB, + const bool isColumnStore, const uint32_t sessionID = 0); SimpleColumn(const SimpleColumn& rhs, const uint32_t sessionID = 0); @@ -160,13 +160,13 @@ public: { fTimeZone = timeZone; } - inline const bool isInfiniDB() const + inline const bool isColumnStore() const { - return fIsInfiniDB; + return fisColumnStore; } - inline void isInfiniDB(const bool isInfiniDB) + inline void isColumnStore(const bool isColumnStore) { - fIsInfiniDB = isInfiniDB; + fisColumnStore = isColumnStore; } /** return a copy of this pointer @@ -261,7 +261,7 @@ protected: // if belong to view, view name is non-empty std::string fViewName; std::string fTimeZone; - bool fIsInfiniDB; + bool fisColumnStore; /** @brief parse SimpleColumn text * diff --git a/dbcon/execplan/simplecolumn_decimal.h b/dbcon/execplan/simplecolumn_decimal.h index 07d451e4b..ce973134a 100644 --- a/dbcon/execplan/simplecolumn_decimal.h +++ b/dbcon/execplan/simplecolumn_decimal.h @@ -60,7 +60,7 @@ public: SimpleColumn_Decimal(const std::string& schema, const std::string& table, const std::string& col, - const bool isInfiniDB, + const bool isColumnStore, const uint32_t sessionID = 0); SimpleColumn_Decimal(const SimpleColumn& rhs, const uint32_t sessionID = 0); @@ -107,9 +107,9 @@ template SimpleColumn_Decimal::SimpleColumn_Decimal(const std::string& schema, const std::string& table, const std::string& col, - const bool isInfiniDB, + const bool isColumnStore, const uint32_t sessionID) : - SimpleColumn(schema, table, col, isInfiniDB, sessionID) + SimpleColumn(schema, table, col, isColumnStore, sessionID) { setNullVal(); } diff --git a/dbcon/execplan/simplecolumn_int.h b/dbcon/execplan/simplecolumn_int.h index e39ab9953..4481e0fea 100644 --- a/dbcon/execplan/simplecolumn_int.h +++ b/dbcon/execplan/simplecolumn_int.h @@ -58,7 +58,7 @@ public: SimpleColumn_INT(const std::string& schema, const std::string& table, const std::string& col, - const bool isInfiniDB, + const bool isColumnStore, const uint32_t sessionID = 0); SimpleColumn_INT(const SimpleColumn& rhs, const uint32_t sessionID = 0); @@ -106,9 +106,9 @@ template SimpleColumn_INT::SimpleColumn_INT(const std::string& schema, const std::string& table, const std::string& col, - const bool isInfiniDB, + const bool isColumnStore, const uint32_t sessionID) : - SimpleColumn(schema, table, col, isInfiniDB, sessionID) + SimpleColumn(schema, table, col, isColumnStore, sessionID) { setNullVal(); } diff --git a/dbcon/execplan/simplecolumn_uint.h b/dbcon/execplan/simplecolumn_uint.h index 7c9169f75..c893c1a30 100644 --- a/dbcon/execplan/simplecolumn_uint.h +++ b/dbcon/execplan/simplecolumn_uint.h @@ -58,7 +58,7 @@ public: SimpleColumn_UINT(const std::string& schema, const std::string& table, const std::string& col, - const bool isInfiniDB, + const bool isColumnStore, const uint32_t sessionID = 0); SimpleColumn_UINT(const SimpleColumn& rhs, const uint32_t sessionID = 0); @@ -106,9 +106,9 @@ template SimpleColumn_UINT::SimpleColumn_UINT(const std::string& schema, const std::string& table, const std::string& col, - const bool isInfiniDB, + const bool isColumnStore, const uint32_t sessionID) : - SimpleColumn(schema, table, col, isInfiniDB, sessionID) + SimpleColumn(schema, table, col, isColumnStore, sessionID) { setNullVal(); } diff --git a/dbcon/joblist/expressionstep.cpp b/dbcon/joblist/expressionstep.cpp index 17dc3d68a..f8020a6c9 100644 --- a/dbcon/joblist/expressionstep.cpp +++ b/dbcon/joblist/expressionstep.cpp @@ -387,7 +387,7 @@ void ExpressionStep::populateColumnInfo(SimpleColumn* sc, JobInfo& jobInfo) sc->oid(tblOid + 1 + sc->colPosition()); ct = sc->resultType(); } - else if (sc->isInfiniDB() == false) + else if (sc->isColumnStore() == false) { ct = sc->colType(); } @@ -515,7 +515,7 @@ void ExpressionStep::updateInputIndex(map& indexMap, const J { ct = sc->resultType(); } - else if (sc->isInfiniDB() == false) + else if (sc->isColumnStore() == false) { ct = sc->colType(); } diff --git a/dbcon/joblist/jlf_common.cpp b/dbcon/joblist/jlf_common.cpp index bdaa18252..cd690bb12 100644 --- a/dbcon/joblist/jlf_common.cpp +++ b/dbcon/joblist/jlf_common.cpp @@ -378,7 +378,7 @@ CalpontSystemCatalog::OID tableOid(const SimpleColumn* sc, boost::shared_ptrschemaName().empty()) return execplan::CNX_VTABLE_ID; - if (sc->isInfiniDB() == false) + if (sc->isColumnStore() == false) return 0; CalpontSystemCatalog::ROPair p = cat->tableRID(make_table(sc->schemaName(), @@ -395,7 +395,7 @@ uint32_t getTupleKey(const JobInfo& jobInfo, return getTupleKey_(jobInfo, sc->oid(), sc->columnName(), extractTableAlias(sc), sc->schemaName(), sc->viewName(), ((sc->joinInfo() & execplan::JOIN_CORRELATED) != 0), - pseudoType, (sc->isInfiniDB() ? 0 : 1)); + pseudoType, (sc->isColumnStore() ? 0 : 1)); } @@ -503,7 +503,7 @@ uint32_t makeTableKey(JobInfo& jobInfo, const execplan::SimpleColumn* sc) { CalpontSystemCatalog::OID o = tableOid(sc, jobInfo.csc); return uniqTupleKey(jobInfo, o, o, "", "", sc->tableName(), extractTableAlias(sc), - sc->schemaName(), sc->viewName(), 0, (sc->isInfiniDB() ? 0 : 1), + sc->schemaName(), sc->viewName(), 0, (sc->isColumnStore() ? 0 : 1), ((sc->joinInfo() & execplan::JOIN_CORRELATED) != 0)); } @@ -561,7 +561,7 @@ TupleInfo setTupleInfo(const execplan::CalpontSystemCatalog::ColType& ct, return setTupleInfo_(ct, col_oid, jobInfo, tbl_oid, sc->columnName(), sc->alias(), sc->schemaName(), sc->tableName(), alias, sc->viewName(), ((sc->joinInfo() & execplan::JOIN_CORRELATED) != 0), - pseudoType, (sc->isInfiniDB() ? 0 : 1)); + pseudoType, (sc->isColumnStore() ? 0 : 1)); } diff --git a/dbcon/joblist/jlf_execplantojoblist.cpp b/dbcon/joblist/jlf_execplantojoblist.cpp index 54cfaf726..82e33564e 100644 --- a/dbcon/joblist/jlf_execplantojoblist.cpp +++ b/dbcon/joblist/jlf_execplantojoblist.cpp @@ -649,10 +649,10 @@ const JobStepVector doColFilter(const SimpleColumn* sc1, const SimpleColumn* sc2 //XXX use this before connector sets colType in sc correctly. // type of pseudo column is set by connector - if (!sc1->schemaName().empty() && sc1->isInfiniDB() && !pc1) + if (!sc1->schemaName().empty() && sc1->isColumnStore() && !pc1) ct1 = jobInfo.csc->colType(sc1->oid()); - if (!sc2->schemaName().empty() && sc2->isInfiniDB() && !pc2) + if (!sc2->schemaName().empty() && sc2->isColumnStore() && !pc2) ct2 = jobInfo.csc->colType(sc2->oid()); //X @@ -1074,10 +1074,10 @@ const JobStepVector doJoin( //XXX use this before connector sets colType in sc correctly. // type of pseudo column is set by connector - if (!sc1->schemaName().empty() && sc1->isInfiniDB() && !pc1) + if (!sc1->schemaName().empty() && sc1->isColumnStore() && !pc1) ct1 = jobInfo.csc->colType(sc1->oid()); - if (!sc2->schemaName().empty() && sc2->isInfiniDB() && !pc2) + if (!sc2->schemaName().empty() && sc2->isColumnStore() && !pc2) ct2 = jobInfo.csc->colType(sc2->oid()); //X @@ -1341,7 +1341,7 @@ const JobStepVector doSemiJoin(const SimpleColumn* sc, const ReturnedColumn* rc, //XXX use this before connector sets colType in sc correctly. // type of pseudo column is set by connector - if (!sc->schemaName().empty() && sc->isInfiniDB() && !pc1) + if (!sc->schemaName().empty() && sc->isColumnStore() && !pc1) ct1 = jobInfo.csc->colType(sc->oid()); //X @@ -1650,7 +1650,7 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo) //XXX use this before connector sets colType in sc correctly. // type of pseudo column is set by connector - if (!sc->schemaName().empty() && sc->isInfiniDB() && !pc) + if (!sc->schemaName().empty() && sc->isColumnStore() && !pc) ct = jobInfo.csc->colType(sc->oid()); //X @@ -1902,7 +1902,7 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo) else pcs = new PseudoColStep(sc->oid(), tbl_oid, pc->pseudoType(), ct, jobInfo); - if (sc->isInfiniDB()) + if (sc->isColumnStore()) pcs->addFilter(cop, value, rf); pcs->alias(alias); @@ -2339,7 +2339,7 @@ const JobStepVector doOuterJoinOnFilter(OuterJoinOnFilter* oj, JobInfo& jobInfo) // MCOL-1182 if we are doing a join between a cross engine // step and a constant then keep the filter for the cross // engine step instead of deleting it further down. - if (!sc->isInfiniDB()) + if (!sc->isColumnStore()) { keepFilters = true; } @@ -2724,7 +2724,7 @@ const JobStepVector doConstantFilter(const ConstantFilter* cf, JobInfo& jobInfo) //XXX use this before connector sets colType in sc correctly. // type of pseudo column is set by connector - if (!sc->schemaName().empty() && sc->isInfiniDB() && !pc) + if (!sc->schemaName().empty() && sc->isColumnStore() && !pc) ct = jobInfo.csc->colType(sc->oid()); //X @@ -2950,7 +2950,7 @@ const JobStepVector doConstantFilter(const ConstantFilter* cf, JobInfo& jobInfo) pcs->name(sc->columnName()); pcs->schema(sc->schemaName()); - if (sc->isInfiniDB()) + if (sc->isColumnStore()) { if (op) pcs->setBOP(bop2num(op)); @@ -3001,7 +3001,7 @@ const JobStepVector doConstantFilter(const ConstantFilter* cf, JobInfo& jobInfo) //XXX use this before connector sets colType in sc correctly. CalpontSystemCatalog::ColType ct = sc->colType(); - if (!sc->schemaName().empty() && sc->isInfiniDB() && !pc) + if (!sc->schemaName().empty() && sc->isColumnStore() && !pc) ct = jobInfo.csc->colType(sc->oid()); TupleInfo ti(setTupleInfo(ct, sc->oid(), jobInfo, tblOid, sc.get(), alias)); diff --git a/dbcon/joblist/jlf_subquery.cpp b/dbcon/joblist/jlf_subquery.cpp index a7f99d575..0d57c1277 100644 --- a/dbcon/joblist/jlf_subquery.cpp +++ b/dbcon/joblist/jlf_subquery.cpp @@ -802,7 +802,7 @@ void addOrderByAndLimit(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo) //XXX use this before connector sets colType in sc correctly. // type of pseudo column is set by connector - if (sc->isInfiniDB() && !(dynamic_cast(sc))) + if (sc->isColumnStore() && !(dynamic_cast(sc))) ct = jobInfo.csc->colType(sc->oid()); //X diff --git a/dbcon/joblist/joblistfactory.cpp b/dbcon/joblist/joblistfactory.cpp index 9f2ca5e3e..2c00d390f 100644 --- a/dbcon/joblist/joblistfactory.cpp +++ b/dbcon/joblist/joblistfactory.cpp @@ -127,7 +127,7 @@ void projectSimpleColumn(const SimpleColumn* sc, JobStepVector& jsv, JobInfo& jo //XXX use this before connector sets colType in sc correctly. // type of pseudo column is set by connector - if (sc->isInfiniDB() && !pc) + if (sc->isColumnStore() && !pc) ct = jobInfo.csc->colType(sc->oid()); //X @@ -708,7 +708,7 @@ const JobStepVector doAggProject(const CalpontSelectExecutionPlan* csep, JobInfo ct = sc->colType(); //XXX use this before connector sets colType in sc correctly. - if (sc->isInfiniDB() && dynamic_cast(sc) == NULL) + if (sc->isColumnStore() && dynamic_cast(sc) == NULL) ct = jobInfo.csc->colType(sc->oid()); //X @@ -994,7 +994,7 @@ const JobStepVector doAggProject(const CalpontSelectExecutionPlan* csep, JobInfo ct = sc->colType(); //XXX use this before connector sets colType in sc correctly. - if (sc->isInfiniDB() && dynamic_cast(sc) == NULL) + if (sc->isColumnStore() && dynamic_cast(sc) == NULL) ct = jobInfo.csc->colType(sc->oid()); //X @@ -1142,7 +1142,7 @@ const JobStepVector doAggProject(const CalpontSelectExecutionPlan* csep, JobInfo ct = sc->colType(); //XXX use this before connector sets colType in sc correctly. - if (sc->isInfiniDB() && dynamic_cast(sc) == NULL) + if (sc->isColumnStore() && dynamic_cast(sc) == NULL) ct = jobInfo.csc->colType(sc->oid()); //X @@ -1623,7 +1623,7 @@ void parseExecutionPlan(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo, CalpontSystemCatalog::ColType ct = sc->colType(); //XXX use this before connector sets colType in sc correctly. - if (sc->isInfiniDB() && dynamic_cast(sc) == NULL) + if (sc->isColumnStore() && dynamic_cast(sc) == NULL) ct = jobInfo.csc->colType(sc->oid()); //X @@ -1759,7 +1759,7 @@ void makeJobSteps(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo, if (it->schema.empty()) oid = doFromSubquery(fromSubquery[i++].get(), it->alias, it->view, jobInfo); - else if (it->fIsInfiniDB) + else if (it->fisColumnStore) oid = jobInfo.csc->tableRID(*it).objnum; else oid = 0; diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index 0e4ab9f58..419e2f853 100644 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -71,7 +71,7 @@ pthread_mutex_t calpont_mutex; Function we use in the creation of our hash to get key. */ -static uchar* calpont_get_key(INFINIDB_SHARE* share, size_t* length, +static uchar* calpont_get_key(COLUMNSTORE_SHARE* share, size_t* length, my_bool not_used __attribute__((unused))) { *length = share->table_name_length; diff --git a/dbcon/mysql/ha_calpont.h b/dbcon/mysql/ha_calpont.h index 3d184f955..5b9dcab56 100644 --- a/dbcon/mysql/ha_calpont.h +++ b/dbcon/mysql/ha_calpont.h @@ -25,7 +25,7 @@ extern handlerton* calpont_hton; extern handlerton* mcs_hton; /** @brief - INFINIDB_SHARE is a structure that will be shared among all open handlers. + COLUMNSTORE_SHARE is a structure that will be shared among all open handlers. This example implements the minimum of what you will probably need. */ typedef struct st_calpont_share @@ -34,7 +34,7 @@ typedef struct st_calpont_share uint32_t table_name_length, use_count; pthread_mutex_t mutex; THR_LOCK lock; -} INFINIDB_SHARE; +} COLUMNSTORE_SHARE; /** @brief Class definition for the storage engine @@ -42,7 +42,7 @@ typedef struct st_calpont_share class ha_calpont: public handler { THR_LOCK_DATA lock; ///< MySQL lock - INFINIDB_SHARE* share; ///< Shared lock info + COLUMNSTORE_SHARE* share; ///< Shared lock info ulonglong int_table_flags; public: diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index 3767a3a8d..74eb18415 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -2370,7 +2370,7 @@ SimpleColumn* buildSimpleColFromDerivedTable(gp_walk_info& gwi, Item_field* ifp) sc->hasAggregate(cols[j]->hasAggregate()); if (col) - sc->isInfiniDB(col->isInfiniDB()); + sc->isColumnStore(col->isColumnStore()); // @bug5634, @bug5635. mark used derived col on derived table. // outer join inner table filter can not be moved in @@ -2823,14 +2823,14 @@ SimpleColumn* getSmallestColumn(boost::shared_ptr csc, } // check engine type - if (!tan.fIsInfiniDB) + if (!tan.fisColumnStore) { // get the first column to project. @todo optimization to get the smallest one for foreign engine. Field* field = *(table->field); - SimpleColumn* sc = new SimpleColumn(table->s->db.str, table->s->table_name.str, field->field_name.str, tan.fIsInfiniDB, gwi.sessionid); + SimpleColumn* sc = new SimpleColumn(table->s->db.str, table->s->table_name.str, field->field_name.str, tan.fisColumnStore, gwi.sessionid); string alias(table->alias.ptr()); sc->tableAlias(lower(alias)); - sc->isInfiniDB(false); + sc->isColumnStore(false); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); sc->resultType(fieldType_MysqlToIDB(field)); sc->oid(field->field_index + 1); @@ -4182,16 +4182,16 @@ FunctionColumn* buildCaseFunction(Item_func* item, gp_walk_info& gwi, bool& nonS ConstantColumn* buildDecimalColumn(Item* item, gp_walk_info& gwi) { Item_decimal* idp = (Item_decimal*)item; - IDB_Decimal infinidb_decimal; + IDB_Decimal columnstore_decimal; String val, *str = item->val_str(&val); string valStr; valStr.assign(str->ptr(), str->length()); - ostringstream infinidb_decimal_val; + ostringstream columnstore_decimal_val; uint32_t i = 0; if (str->ptr()[0] == '+' || str->ptr()[0] == '-') { - infinidb_decimal_val << str->ptr()[0]; + columnstore_decimal_val << str->ptr()[0]; i = 1; } @@ -4200,22 +4200,22 @@ ConstantColumn* buildDecimalColumn(Item* item, gp_walk_info& gwi) if (str->ptr()[i] == '.') continue; - infinidb_decimal_val << str->ptr()[i]; + columnstore_decimal_val << str->ptr()[i]; } - infinidb_decimal.value = strtoll(infinidb_decimal_val.str().c_str(), 0, 10); + columnstore_decimal.value = strtoll(columnstore_decimal_val.str().c_str(), 0, 10); if (gwi.internalDecimalScale >= 0 && idp->decimals > (uint)gwi.internalDecimalScale) { - infinidb_decimal.scale = gwi.internalDecimalScale; - double val = (double)(infinidb_decimal.value / pow((double)10, idp->decimals - gwi.internalDecimalScale)); - infinidb_decimal.value = (int64_t)(val > 0 ? val + 0.5 : val - 0.5); + columnstore_decimal.scale = gwi.internalDecimalScale; + double val = (double)(columnstore_decimal.value / pow((double)10, idp->decimals - gwi.internalDecimalScale)); + columnstore_decimal.value = (int64_t)(val > 0 ? val + 0.5 : val - 0.5); } else - infinidb_decimal.scale = idp->decimals; + columnstore_decimal.scale = idp->decimals; - infinidb_decimal.precision = idp->max_length - idp->decimals; - ConstantColumn* cc = new ConstantColumn(valStr, infinidb_decimal); + columnstore_decimal.precision = idp->max_length - idp->decimals; + ConstantColumn* cc = new ConstantColumn(valStr, columnstore_decimal); cc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); return cc; } @@ -4239,18 +4239,18 @@ SimpleColumn* buildSimpleColumn(Item_field* ifp, gp_walk_info& gwi) return buildSimpleColFromDerivedTable(gwi, ifp); CalpontSystemCatalog::ColType ct; - bool infiniDB = true; + bool columnStore = true; try { // check foreign engine if (ifp->cached_table && ifp->cached_table->table) - infiniDB = isMCSTable(ifp->cached_table->table); + columnStore = isMCSTable(ifp->cached_table->table); // @bug4509. ifp->cached_table could be null for myisam sometimes else if (ifp->field && ifp->field->table) - infiniDB = isMCSTable(ifp->field->table); + columnStore = isMCSTable(ifp->field->table); - if (infiniDB) + if (columnStore) { ct = gwi.csc->colType( gwi.csc->lookupOID(make_tcn(ifp->db_name, bestTableName(ifp), ifp->field_name.str))); @@ -4273,10 +4273,10 @@ SimpleColumn* buildSimpleColumn(Item_field* ifp, gp_walk_info& gwi) { case CalpontSystemCatalog::TINYINT: if (ct.scale == 0) - sc = new SimpleColumn_INT<1>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, infiniDB, gwi.sessionid); + sc = new SimpleColumn_INT<1>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, columnStore, gwi.sessionid); else { - sc = new SimpleColumn_Decimal<1>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, infiniDB, gwi.sessionid); + sc = new SimpleColumn_Decimal<1>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, columnStore, gwi.sessionid); ct.colDataType = CalpontSystemCatalog::DECIMAL; } @@ -4284,10 +4284,10 @@ SimpleColumn* buildSimpleColumn(Item_field* ifp, gp_walk_info& gwi) case CalpontSystemCatalog::SMALLINT: if (ct.scale == 0) - sc = new SimpleColumn_INT<2>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, infiniDB, gwi.sessionid); + sc = new SimpleColumn_INT<2>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, columnStore, gwi.sessionid); else { - sc = new SimpleColumn_Decimal<2>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, infiniDB, gwi.sessionid); + sc = new SimpleColumn_Decimal<2>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, columnStore, gwi.sessionid); ct.colDataType = CalpontSystemCatalog::DECIMAL; } @@ -4296,10 +4296,10 @@ SimpleColumn* buildSimpleColumn(Item_field* ifp, gp_walk_info& gwi) case CalpontSystemCatalog::INT: case CalpontSystemCatalog::MEDINT: if (ct.scale == 0) - sc = new SimpleColumn_INT<4>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, infiniDB, gwi.sessionid); + sc = new SimpleColumn_INT<4>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, columnStore, gwi.sessionid); else { - sc = new SimpleColumn_Decimal<4>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, infiniDB, gwi.sessionid); + sc = new SimpleColumn_Decimal<4>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, columnStore, gwi.sessionid); ct.colDataType = CalpontSystemCatalog::DECIMAL; } @@ -4307,34 +4307,34 @@ SimpleColumn* buildSimpleColumn(Item_field* ifp, gp_walk_info& gwi) case CalpontSystemCatalog::BIGINT: if (ct.scale == 0) - sc = new SimpleColumn_INT<8>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, infiniDB, gwi.sessionid); + sc = new SimpleColumn_INT<8>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, columnStore, gwi.sessionid); else { - sc = new SimpleColumn_Decimal<8>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, infiniDB, gwi.sessionid); + sc = new SimpleColumn_Decimal<8>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, columnStore, gwi.sessionid); ct.colDataType = CalpontSystemCatalog::DECIMAL; } break; case CalpontSystemCatalog::UTINYINT: - sc = new SimpleColumn_UINT<1>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, infiniDB, gwi.sessionid); + sc = new SimpleColumn_UINT<1>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, columnStore, gwi.sessionid); break; case CalpontSystemCatalog::USMALLINT: - sc = new SimpleColumn_UINT<2>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, infiniDB, gwi.sessionid); + sc = new SimpleColumn_UINT<2>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, columnStore, gwi.sessionid); break; case CalpontSystemCatalog::UINT: case CalpontSystemCatalog::UMEDINT: - sc = new SimpleColumn_UINT<4>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, infiniDB, gwi.sessionid); + sc = new SimpleColumn_UINT<4>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, columnStore, gwi.sessionid); break; case CalpontSystemCatalog::UBIGINT: - sc = new SimpleColumn_UINT<8>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, infiniDB, gwi.sessionid); + sc = new SimpleColumn_UINT<8>(ifp->db_name, bestTableName(ifp), ifp->field_name.str, columnStore, gwi.sessionid); break; default: - sc = new SimpleColumn(ifp->db_name, bestTableName(ifp), ifp->field_name.str, infiniDB, gwi.sessionid); + sc = new SimpleColumn(ifp->db_name, bestTableName(ifp), ifp->field_name.str, columnStore, gwi.sessionid); } sc->resultType(ct); @@ -4352,10 +4352,10 @@ SimpleColumn* buildSimpleColumn(Item_field* ifp, gp_walk_info& gwi) sc->viewName(lower(getViewName(ifp->cached_table))); sc->alias(ifp->name.str); - sc->isInfiniDB(infiniDB); + sc->isColumnStore(columnStore); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); - if (!infiniDB && ifp->field) + if (!columnStore && ifp->field) sc->oid(ifp->field->field_index + 1); // ExeMgr requires offset started from 1 if (ifp->depended_from) @@ -4584,7 +4584,7 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi) parm.reset(sc); gwi.columnMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(string(ifp->field_name.str), parm)); TABLE_LIST* tmp = (ifp->cached_table ? ifp->cached_table : 0); - gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isInfiniDB())] = make_pair(1, tmp); + gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isColumnStore())] = make_pair(1, tmp); break; } @@ -5084,7 +5084,7 @@ void gp_walk(const Item* item, void* arg) if (!((scp->joinInfo() & JOIN_CORRELATED) || scp->colType().colDataType == CalpontSystemCatalog::VARBINARY)) { TABLE_LIST* tmp = (ifp->cached_table ? ifp->cached_table : 0); - gwip->tableMap[make_aliastable(scp->schemaName(), scp->tableName(), scp->tableAlias(), scp->isInfiniDB())] = + gwip->tableMap[make_aliastable(scp->schemaName(), scp->tableName(), scp->tableAlias(), scp->isColumnStore())] = make_pair(1, tmp); } } @@ -6132,10 +6132,10 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, else { // check foreign engine tables - bool infiniDB = (table_ptr->table ? isMCSTable(table_ptr->table) : true); + bool columnStore = (table_ptr->table ? isMCSTable(table_ptr->table) : true); // trigger system catalog cache - if (infiniDB) + if (columnStore) csc->columnRIDs(make_table(table_ptr->db.str, table_ptr->table_name.str), true); string table_name = table_ptr->table_name.str; @@ -6144,9 +6144,9 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, if (table_ptr->db.length && strcmp(table_ptr->db.str, "information_schema") == 0) table_name = (table_ptr->schema_table_name.length ? table_ptr->schema_table_name.str : table_ptr->alias.str); - CalpontSystemCatalog::TableAliasName tn = make_aliasview(table_ptr->db.str, table_name, table_ptr->alias.str, viewName, infiniDB); + CalpontSystemCatalog::TableAliasName tn = make_aliasview(table_ptr->db.str, table_name, table_ptr->alias.str, viewName, columnStore); gwi.tbList.push_back(tn); - CalpontSystemCatalog::TableAliasName tan = make_aliastable(table_ptr->db.str, table_name, table_ptr->alias.str, infiniDB); + CalpontSystemCatalog::TableAliasName tan = make_aliastable(table_ptr->db.str, table_name, table_ptr->alias.str, columnStore); gwi.tableMap[tan] = make_pair(0, table_ptr); #ifdef DEBUG_WALK_COND cerr << tn << endl; @@ -6523,7 +6523,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, if (ifp->cached_table) tmp = ifp->cached_table; - gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isInfiniDB())] = + gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isColumnStore())] = make_pair(1, tmp); } else @@ -7090,7 +7090,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, string fullname; fullname = str.c_ptr(); TABLE_LIST* tmp = (funcFieldVec[i]->cached_table ? funcFieldVec[i]->cached_table : 0); - gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isInfiniDB())] = + gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isColumnStore())] = make_pair(1, tmp); } } @@ -7630,7 +7630,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, gwi.returnedCols.push_back(srcp); gwi.columnMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(string(fieldVec[i]->field_name.str), srcp)); TABLE_LIST* tmp = (fieldVec[i]->cached_table ? fieldVec[i]->cached_table : 0); - gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isInfiniDB())] = + gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isColumnStore())] = make_pair(1, tmp); } } @@ -8367,10 +8367,10 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro else { // check foreign engine tables - bool infiniDB = (table_ptr->table ? isMCSTable(table_ptr->table) : true); + bool columnStore = (table_ptr->table ? isMCSTable(table_ptr->table) : true); // trigger system catalog cache - if (infiniDB) + if (columnStore) csc->columnRIDs(make_table(table_ptr->db.str, table_ptr->table_name.str), true); string table_name = table_ptr->table_name.str; @@ -8379,9 +8379,9 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro if (table_ptr->db.length && strcmp(table_ptr->db.str, "information_schema") == 0) table_name = (table_ptr->schema_table_name.length ? table_ptr->schema_table_name.str : table_ptr->alias.str); - CalpontSystemCatalog::TableAliasName tn = make_aliasview(table_ptr->db.str, table_name, table_ptr->alias.str, viewName, infiniDB); + CalpontSystemCatalog::TableAliasName tn = make_aliasview(table_ptr->db.str, table_name, table_ptr->alias.str, viewName, columnStore); gwi.tbList.push_back(tn); - CalpontSystemCatalog::TableAliasName tan = make_aliastable(table_ptr->db.str, table_name, table_ptr->alias.str, infiniDB); + CalpontSystemCatalog::TableAliasName tan = make_aliastable(table_ptr->db.str, table_name, table_ptr->alias.str, columnStore); gwi.tableMap[tan] = make_pair(0, table_ptr); #ifdef DEBUG_WALK_COND cerr << tn << endl; @@ -8646,7 +8646,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro if (ifp->cached_table) tmp = ifp->cached_table; - gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isInfiniDB())] = + gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isColumnStore())] = make_pair(1, tmp); } else @@ -9235,7 +9235,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro string fullname; fullname = str.c_ptr(); TABLE_LIST* tmp = (funcFieldVec[i]->cached_table ? funcFieldVec[i]->cached_table : 0); - gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isInfiniDB())] = + gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isColumnStore())] = make_pair(1, tmp); } } diff --git a/dbcon/mysql/ha_mcs_pushdown.h b/dbcon/mysql/ha_mcs_pushdown.h index 1012cfa8c..2ca4d5826 100644 --- a/dbcon/mysql/ha_mcs_pushdown.h +++ b/dbcon/mysql/ha_mcs_pushdown.h @@ -94,7 +94,7 @@ public: * derived_handler API methods. Could be used by the server * tp process sub-queries. * More details in server/sql/dervied_handler.h - * INFINIDB_SHARE* hton share + * COLUMNSTORE_SHARE* hton share * tbl in the constructor is the list of the tables involved. * Methods: * init_scan - get plan and send it to ExeMgr. Get the execution result. @@ -104,7 +104,7 @@ public: class ha_columnstore_derived_handler: public derived_handler { private: - INFINIDB_SHARE *share; + COLUMNSTORE_SHARE *share; public: ha_columnstore_derived_handler(THD* thd_arg, TABLE_LIST *tbl); @@ -121,7 +121,7 @@ public: * select_handler API methods. Could be used by the server * tp pushdown the whole query described by SELECT_LEX. * More details in server/sql/select_handler.h - * INFINIDB_SHARE* hton share + * COLUMNSTORE_SHARE* hton share * sel in the constructor is the semantic tree for the query. * Methods: * init_scan - get plan and send it to ExeMgr. Get the execution result. @@ -131,7 +131,7 @@ public: class ha_columnstore_select_handler: public select_handler { private: - INFINIDB_SHARE *share; + COLUMNSTORE_SHARE *share; public: ha_columnstore_select_handler(THD* thd_arg, SELECT_LEX* sel); diff --git a/dbcon/mysql/ha_mcs_sysvars.cpp b/dbcon/mysql/ha_mcs_sysvars.cpp index 2dfadcb6a..438075eb5 100644 --- a/dbcon/mysql/ha_mcs_sysvars.cpp +++ b/dbcon/mysql/ha_mcs_sysvars.cpp @@ -134,7 +134,7 @@ static MYSQL_THDVAR_BOOL( static MYSQL_THDVAR_BOOL( double_for_decimal_math, PLUGIN_VAR_NOCMDARG, - "Enable/disable the InfiniDB to replace DECIMAL with DOUBLE in arithmetic operation.", + "Enable/disable for ColumnStore to replace DECIMAL with DOUBLE in arithmetic operation.", NULL, NULL, 0 @@ -227,7 +227,7 @@ static MYSQL_THDVAR_ULONG( static MYSQL_THDVAR_ULONG( local_query, PLUGIN_VAR_RQCMDARG, - "Enable/disable the Infinidb local PM query only feature.", + "Enable/disable the ColumnStore local PM query only feature.", NULL, NULL, 0, diff --git a/dbcon/mysql/ha_pseudocolumn.cpp b/dbcon/mysql/ha_pseudocolumn.cpp index 57683b9bf..943d492ae 100644 --- a/dbcon/mysql/ha_pseudocolumn.cpp +++ b/dbcon/mysql/ha_pseudocolumn.cpp @@ -540,7 +540,7 @@ execplan::ReturnedColumn* buildPseudoColumn(Item* item, { SRCP srcp(sc); gwi.columnMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(sc->columnName(), srcp)); - gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isInfiniDB())] = + gwi.tableMap[make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias(), sc->isColumnStore())] = make_pair(1, field->cached_table); } else if (!gwi.rcWorkStack.empty()) diff --git a/dbcon/mysql/ha_view.cpp b/dbcon/mysql/ha_view.cpp index cfcfe3970..6553a0e44 100644 --- a/dbcon/mysql/ha_view.cpp +++ b/dbcon/mysql/ha_view.cpp @@ -120,13 +120,13 @@ void View::transform() else { // check foreign engine tables - bool infiniDB = (table_ptr->table ? isMCSTable(table_ptr->table) : true); + bool columnStore = (table_ptr->table ? isMCSTable(table_ptr->table) : true); // trigger system catalog cache - if (infiniDB) + if (columnStore) csc->columnRIDs(make_table(table_ptr->db.str, table_ptr->table_name.str), true); - CalpontSystemCatalog::TableAliasName tn = make_aliasview(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str, viewName, infiniDB); + CalpontSystemCatalog::TableAliasName tn = make_aliasview(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str, viewName, columnStore); gwi.tbList.push_back(tn); gwi.tableMap[tn] = make_pair(0, table_ptr); fParentGwip->tableMap[tn] = make_pair(0, table_ptr); diff --git a/dbcon/mysql/sm.cpp b/dbcon/mysql/sm.cpp index 8dc5c0414..e3dca6a56 100644 --- a/dbcon/mysql/sm.cpp +++ b/dbcon/mysql/sm.cpp @@ -454,7 +454,7 @@ tpl_close ( cpsm_tplh_t* ntplh, status_t sm_init ( uint32_t sid, cpsm_conhdl_t** conn_hdl, - uint32_t infinidb_local_query) + uint32_t columnstore_local_query) { // clear file content #if IDB_SM_DEBUG @@ -465,7 +465,7 @@ sm_init ( uint32_t sid, // @bug5660 Connection changes related to the local pm setting /** - * when local PM is detected, or infinidb_local_query is set: + * when local PM is detected, or columnstore_local_query is set: * 1. SELECT query connect to local ExeMgr 127.0.0.1:8601; * 2. DML/DDL is disallowed. * once local connection is determined, no need to check @@ -474,14 +474,14 @@ sm_init ( uint32_t sid, if (*conn_hdl) { // existing connection is local, ok. - if ((*conn_hdl)->exeMgr->localQuery() || ! infinidb_local_query) + if ((*conn_hdl)->exeMgr->localQuery() || ! columnstore_local_query) return STATUS_OK; // if session variable changes to local, re-establish the connection to loopback. else sm_cleanup(*conn_hdl); } - cpsm_conhdl_t* hndl = new cpsm_conhdl_t(time(0), sid, infinidb_local_query); + cpsm_conhdl_t* hndl = new cpsm_conhdl_t(time(0), sid, columnstore_local_query); *conn_hdl = hndl; hndl->sessionID = sid; diff --git a/dbcon/mysql/sm.h b/dbcon/mysql/sm.h index 32cb1aa18..43da05ee1 100644 --- a/dbcon/mysql/sm.h +++ b/dbcon/mysql/sm.h @@ -198,9 +198,9 @@ typedef boost::shared_ptr sp_cpsm_tplsch_t; class cpsm_conhdl_t { public: - cpsm_conhdl_t(time_t v, const uint32_t sid, bool infinidb_local_query) : + cpsm_conhdl_t(time_t v, const uint32_t sid, bool columnstore_local_query) : value(v), sessionID(sid), queryState (NO_QUERY), - exeMgr( new execplan::ClientRotator(sid, "ExeMgr", infinidb_local_query)), + exeMgr( new execplan::ClientRotator(sid, "ExeMgr", columnstore_local_query)), tblinfo_idx(0), idxinfo_idx(0), curFetchTb (0) { } @@ -275,7 +275,7 @@ struct cpsm_tid_t int value; }; -extern status_t sm_init(uint32_t, cpsm_conhdl_t**, uint32_t infinidb_local_query = false); +extern status_t sm_init(uint32_t, cpsm_conhdl_t**, uint32_t columnstore_local_query = false); extern status_t sm_cleanup(cpsm_conhdl_t*); extern status_t tpl_open(tableid_t, cpsm_tplh_t*, cpsm_conhdl_t*); diff --git a/oam/install_scripts/myCnf-include-args.text b/oam/install_scripts/myCnf-include-args.text index 40545c7ed..e6d2cd768 100644 --- a/oam/install_scripts/myCnf-include-args.text +++ b/oam/install_scripts/myCnf-include-args.text @@ -1,6 +1,6 @@ # List of my.cnf arguments that should be checked and saved during upgrade install # -infinidb_local_query +columnstore_local_query log-bin server-id max_length_for_sort_data @@ -15,4 +15,4 @@ collation-server init-connect binlog_format secure-auth -port \ No newline at end of file +port diff --git a/procmon/main.cpp b/procmon/main.cpp index 41cbebefd..9e01c5f14 100644 --- a/procmon/main.cpp +++ b/procmon/main.cpp @@ -394,12 +394,12 @@ int main(int argc, char** argv) // check if standby never replied, if so, shutdown if ( count >= 120 ) { - log.writeLog(__LINE__, "Standby PM not responding, infinidb shutting down", LOG_TYPE_CRITICAL); + log.writeLog(__LINE__, "Standby PM not responding, ColumnStore shutting down", LOG_TYPE_CRITICAL); //Set the alarm // aMonitor.sendAlarm(config.moduleName().c_str(), STARTUP_DIAGNOTICS_FAILURE, SET); // sleep (1); - string cmd = startup::StartUp::installDir() + "/bin/infinidb stop > /dev/null 2>&1"; + string cmd = startup::StartUp::installDir() + "/bin/columnstore stop > /dev/null 2>&1"; system(cmd.c_str()); } diff --git a/procmon/processmonitor.cpp b/procmon/processmonitor.cpp index f22be1b87..48fe00e6b 100644 --- a/procmon/processmonitor.cpp +++ b/procmon/processmonitor.cpp @@ -5109,11 +5109,11 @@ int ProcessMonitor::changeMyCnf(std::string type) // set local query flag if on pm if ( (PMwithUM == "y") && config.moduleType() == "pm" ) { - pos = buf.find("infinidb_local_query", 0); + pos = buf.find("columnstore_local_query", 0); if ( pos != string::npos ) { - buf = "infinidb_local_query=1"; + buf = "columnstore_local_query=1"; string command = "SET GLOBAL " + buf + ";"; @@ -5129,11 +5129,11 @@ int ProcessMonitor::changeMyCnf(std::string type) else { // disable, if needed - pos = buf.find("infinidb_local_query", 0); + pos = buf.find("columnstore_local_query", 0); if ( pos != string::npos ) { - buf = "infinidb_local_query=0"; + buf = "columnstore_local_query=0"; string command = "SET GLOBAL " + buf + ";"; int ret = runMariaDBCommandLine(command); diff --git a/tools/clearShm/main.cpp b/tools/clearShm/main.cpp index 4ab97c2d6..cf3a7e92b 100644 --- a/tools/clearShm/main.cpp +++ b/tools/clearShm/main.cpp @@ -123,9 +123,9 @@ void semDoit(key_t sem_key, const string& label) void usage() { cout << "usage: clearShm [-cvnh]" << endl; - cout << " delete all InfiniDB shared memory data" << endl; + cout << " delete all ColumnStore shared memory data" << endl; cout << " -h display this help" << endl; - cout << " -c only clear InfiniDB Engine data, leave OAM intact" << endl; + cout << " -c only clear ColumnStore Engine data, leave OAM intact" << endl; cout << " -v verbose output" << endl; cout << " -n don't actually delete anything (implies -v)" << endl; } diff --git a/tools/cleartablelock/cleartablelock.cpp b/tools/cleartablelock/cleartablelock.cpp index df660ec5d..3a332be22 100644 --- a/tools/cleartablelock/cleartablelock.cpp +++ b/tools/cleartablelock/cleartablelock.cpp @@ -509,7 +509,7 @@ int main(int argc, char** argv) if (brm.getSystemReady() < 1) { - std::cout << "System is not ready. Verify that InfiniDB " + std::cout << "System is not ready. Verify that ColumnStore " "is up and ready before running this program" << std::endl; return 1; } diff --git a/tools/dbloadxml/colxml.cpp b/tools/dbloadxml/colxml.cpp index 1ac41d7bf..778d095e7 100644 --- a/tools/dbloadxml/colxml.cpp +++ b/tools/dbloadxml/colxml.cpp @@ -146,7 +146,7 @@ int main(int argc, char** argv) if (dbrm.getSystemReady() < 1) { std::string errMsg( - "System is not ready. Verify that InfiniDB is up and ready " + "System is not ready. Verify that ColumnStore is up and ready " "before running colxml."); if (bUseLogFile) diff --git a/utils/dataconvert/dataconvert.cpp b/utils/dataconvert/dataconvert.cpp index b17b430fb..ff40952a0 100644 --- a/utils/dataconvert/dataconvert.cpp +++ b/utils/dataconvert/dataconvert.cpp @@ -53,7 +53,7 @@ using namespace logging; namespace { -const int64_t infinidb_precision[19] = +const int64_t columnstore_precision[19] = { 0, 9, @@ -415,7 +415,7 @@ int64_t number_int_value(const string& data, (ct.colDataType == CalpontSystemCatalog::UDECIMAL) || (ct.scale > 0)) { - int64_t rangeUp = infinidb_precision[ct.precision]; + int64_t rangeUp = columnstore_precision[ct.precision]; int64_t rangeLow = -rangeUp; if (intVal > rangeUp) diff --git a/utils/funcexp/func_cast.cpp b/utils/funcexp/func_cast.cpp index d2db69144..27284d392 100644 --- a/utils/funcexp/func_cast.cpp +++ b/utils/funcexp/func_cast.cpp @@ -1168,7 +1168,7 @@ IDB_Decimal Func_cast_decimal::getDecimalVal(Row& row, int32_t decimals = parm[1]->data()->getIntVal(row, isNull); int64_t max_length = parm[2]->data()->getIntVal(row, isNull); - // As of 2.0, max length infiniDB can support is 18 + // As of 2.0, max length columnStore can support is 18 // decimal(0,0) is valid, and no limit on integer number if (max_length > 18 || max_length <= 0) max_length = 18; diff --git a/utils/loggingcpp/ErrorMessage.txt b/utils/loggingcpp/ErrorMessage.txt index a6dd3b6e0..814a51310 100755 --- a/utils/loggingcpp/ErrorMessage.txt +++ b/utils/loggingcpp/ErrorMessage.txt @@ -86,13 +86,13 @@ 2045 ERR_PRIMPROC_DOWN At least one PrimProc closed the connection unexpectedly. 2046 ERR_READ_INPUT_DATALIST Input datalist read error. -2047 ERR_LOCAL_QUERY_UM Query attempted on UM (no PM) with infinidb_local_query set. +2047 ERR_LOCAL_QUERY_UM Query attempted on UM (no PM) with columnstore_local_query set. # disk-based join runtime errors from supported queries 2048 ERR_DBJ_FILE_IO_ERROR There was an IO error doing a disk-based join. 2049 ERR_DBJ_UNKNOWN_ERROR An unknown error error occured doing a disk-based join. Check the error log & contact support. -2050 ERR_DBJ_DISK_USAGE_LIMIT This query exceeded the temp disk usage limit. Raise infinidb_diskjoin_smallsidelimit if possible and try again. -2051 ERR_DBJ_DATA_DISTRIBUTION The data distribution in this query overflowed a disk-based join bucket. If possible, raise infinidb_diskjoin_bucketsize and try again. +2050 ERR_DBJ_DISK_USAGE_LIMIT This query exceeded the temp disk usage limit. Raise columnstore_diskjoin_smallsidelimit if possible and try again. +2051 ERR_DBJ_DATA_DISTRIBUTION The data distribution in this query overflowed a disk-based join bucket. If possible, raise columnstore_diskjoin_bucketsize and try again. 2052 INFO_SWITCHING_TO_DJS Out of UM memory, switching to disk-based join. 2053 ERR_FUNC_OUT_OF_RANGE_RESULT The result is out of range for function %1% using value(s): %2% %3% @@ -141,7 +141,7 @@ 4014 ERR_CONSTRAINTS Constraints are currently not supported in Columnstore. 4015 ERR_NOT_NULL_CONSTRAINTS Column '%1%' cannot be null. 4016 ERR_DML_DDL_SLAVE DML and DDL statements for Columnstore tables can only be run from the replication master. -4017 ERR_DML_DDL_LOCAL DML and DDL statements are not allowed when infinidb_local_query is greater than 0. +4017 ERR_DML_DDL_LOCAL DML and DDL statements are not allowed when columnstore_local_query is greater than 0. 4018 ERR_NON_SUPPORT_SYNTAX The statement is not supported in Columnstore. # UDF diff --git a/versioning/BRM/reset_locks.cpp b/versioning/BRM/reset_locks.cpp index 390942ca3..293e512b1 100644 --- a/versioning/BRM/reset_locks.cpp +++ b/versioning/BRM/reset_locks.cpp @@ -53,7 +53,7 @@ bool sFlg; void usage() { cout << "usage: reset_locks [-vnh]" << endl; - cout << " reset all InfiniDB shared memory locks" << endl; + cout << " reset all ColumnStore shared memory locks" << endl; cout << " -h display this help" << endl; cout << " -v verbose output" << endl; cout << " -s skip session mgr resets" << endl; diff --git a/writeengine/xml/we_xmljob.cpp b/writeengine/xml/we_xmljob.cpp index 4cc4c90eb..863e5cbef 100644 --- a/writeengine/xml/we_xmljob.cpp +++ b/writeengine/xml/we_xmljob.cpp @@ -48,7 +48,7 @@ using namespace execplan; namespace WriteEngine { // Maximum saturation value for DECIMAL types based on precision -const long long infinidb_precision[19] = +const long long columnstore_precision[19] = { 0, 9, @@ -759,14 +759,14 @@ void XMLJob::initSatLimits( JobColumn& curColumn ) const else if ( curColumn.typeName == ColDataTypeStr[CalpontSystemCatalog::DECIMAL] ) { - curColumn.fMinIntSat = -infinidb_precision[curColumn.precision]; - curColumn.fMaxIntSat = infinidb_precision[curColumn.precision]; + curColumn.fMinIntSat = -columnstore_precision[curColumn.precision]; + curColumn.fMaxIntSat = columnstore_precision[curColumn.precision]; } else if ( curColumn.typeName == ColDataTypeStr[CalpontSystemCatalog::UDECIMAL] ) { curColumn.fMinIntSat = 0; - curColumn.fMaxIntSat = infinidb_precision[curColumn.precision]; + curColumn.fMaxIntSat = columnstore_precision[curColumn.precision]; } else if ( curColumn.typeName == ColDataTypeStr[CalpontSystemCatalog::FLOAT] ) From f0c83a4a1fdf15bd1aa31f6c29655d3fb3548390 Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Mon, 12 Aug 2019 21:02:32 +0300 Subject: [PATCH 56/59] MCOL-2178 Enable GBH by default. We preserve union related condition blocks until UNION-capable smart handler. Removed a number of commented code blocks. Add projection list REAL and TIME constants, e.g SELECT TIME'10:20:30', TIMESTAMP'2001-01-01 10:20:30', DATE'2001-01-01' FROM cs1; Marked potentially useless block in ORDER BY processing for future removal. Removed string variables used for reconstructed query in the pre-1.4 fork. Removed cp_get_plan(). GBH doesn't step in if SH processes the query. All smart handlers now correctly processes impossible WHERE and HAVING. --- dbcon/mysql/CMakeLists.txt | 2 - dbcon/mysql/ha_calpont.cpp | 2 +- dbcon/mysql/ha_calpont_execplan.cpp | 343 ++++------------------------ dbcon/mysql/ha_calpont_impl.cpp | 118 ++-------- dbcon/mysql/ha_calpont_impl_if.h | 1 + dbcon/mysql/ha_mcs_pushdown.cpp | 19 +- 6 files changed, 82 insertions(+), 403 deletions(-) diff --git a/dbcon/mysql/CMakeLists.txt b/dbcon/mysql/CMakeLists.txt index 0aa6ddcc0..c74e19343 100644 --- a/dbcon/mysql/CMakeLists.txt +++ b/dbcon/mysql/CMakeLists.txt @@ -22,8 +22,6 @@ SET ( libcalmysql_SRCS ha_pseudocolumn.cpp) add_definitions(-DMYSQL_DYNAMIC_PLUGIN) -add_definitions(-DEBUG_WALK_COND) -add_definitions(-DINFINIDB_DEBUG) set_source_files_properties(ha_calpont.cpp PROPERTIES COMPILE_FLAGS "-fno-rtti -fno-implicit-templates") diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index 525ac62b7..9de10a361 100644 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -143,7 +143,7 @@ static int columnstore_init_func(void* p) mcs_hton->commit = calpont_commit; mcs_hton->rollback = calpont_rollback; mcs_hton->close_connection = calpont_close_connection; - //mcs_hton->create_group_by = create_calpont_group_by_handler; + mcs_hton->create_group_by = create_calpont_group_by_handler; mcs_hton->create_derived = create_columnstore_derived_handler; mcs_hton->create_select = create_columnstore_select_handler; DBUG_RETURN(0); diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index 3767a3a8d..1995b3beb 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -207,7 +207,6 @@ bool nonConstFunc(Item_func* ifp) ***********************************************************/ void getColNameFromItem(std::ostringstream& ostream, Item* item) { -// MCOL-2121 WIP // Item_func doesn't have proper db.table.field values // inherited from Item_ident. TBD what is the valid output. // !!!dynamic_cast fails compilation @@ -1321,8 +1320,8 @@ uint32_t buildOuterJoin(gp_walk_info& gwi, SELECT_LEX& select_lex) { if (gwi.thd->derived_tables_processing) { -// TODO MCOL-2178 isUnion member only assigned, never used -// MIGR::infinidb_vtable.isUnion = false; + // MCOL-2178 isUnion member only assigned, never used + //MIGR::infinidb_vtable.isUnion = false; gwi.cs_vtable_is_update_with_derive = true; return -1; } @@ -5149,12 +5148,6 @@ void gp_walk(const Item* item, void* arg) gwip->rcWorkStack.push(buildReturnedColumn(itp, *gwip, gwip->fatalParseError)); break; } - /*case Item::VARBIN_ITEM: - { - Item_hex_string* hdp = (Item_hex_string*)item; - gwip->rcWorkStack.push(buildReturnedColumn(hdp, *gwip, gwip->fatalParseError)); - break; - }*/ default: { if (gwip->condPush) @@ -5622,8 +5615,8 @@ void gp_walk(const Item* item, void* arg) gwip->hasSubSelect = true; gwip->subQuery = existsSub; gwip->ptWorkStack.push(existsSub->transform()); -// TODO MCOL-2178 isUnion member only assigned, never used -// MIGR::infinidb_vtable.isUnion = true; // only temp. bypass the 2nd phase. + // MCOL-2178 isUnion member only assigned, never used + //MIGR::infinidb_vtable.isUnion = true; // only temp. bypass the 2nd phase. // recover original gwip->subQuery = orig; gwip->lastSub = existsSub; @@ -5718,20 +5711,7 @@ void gp_walk(const Item* item, void* arg) printf("********** received TRIGGER_FIELD_ITEM *********\n"); break; - /* WIP MCOL-2178 - case Item::XPATH_NODESET: - printf("********** received XPATH_NODESET *********\n"); - break; - - case Item::XPATH_NODESET_CMP: - printf("********** received XPATH_NODESET_CMP *********\n"); - break; - - case Item::VIEW_FIXER_ITEM: - printf("********** received VIEW_FIXER_ITEM *********\n"); - break; - */ - case Item::TYPE_HOLDER: + case Item::TYPE_HOLDER: std::cerr << "********** received TYPE_HOLDER *********" << std::endl; break; default: @@ -5983,8 +5963,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) ) && gwi.thd->derived_tables_processing) { -// TODO MCOL-2178 isUnion member only assigned, never used -// MIGR::infinidb_vtable.isUnion = false; + // MCOL-2178 isUnion member only assigned, never used + //MIGR::infinidb_vtable.isUnion = false; return -1; } @@ -6118,8 +6098,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, gwi.tbList.push_back(tn); CalpontSystemCatalog::TableAliasName tan = make_aliastable("", alias, alias); gwi.tableMap[tan] = make_pair(0, table_ptr); -// TODO MCOL-2178 isUnion member only assigned, never used -// MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init + // MCOL-2178 isUnion member only assigned, never used + //MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init } else if (table_ptr->view) { @@ -6190,8 +6170,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // is_unit_op() give a segv for derived_handler's SELECT_LEX if (!isUnion && select_lex.master_unit()->is_unit_op()) { -// TODO MCOL-2178 isUnion member only assigned, never used -// MIGR::infinidb_vtable.isUnion = true; + // MCOL-2178 isUnion member only assigned, never used + //MIGR::infinidb_vtable.isUnion = true; CalpontSelectExecutionPlan::SelectList unionVec; SELECT_LEX* select_cursor = select_lex.master_unit()->first_select(); unionSel = true; @@ -6283,8 +6263,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // processing. if (gwi.thd->derived_tables_processing) { -// TODO MCOL-2178 isUnion member only assigned, never used -// MIGR::infinidb_vtable.isUnion = false; + // MCOL-2178 isUnion member only assigned, never used + //MIGR::infinidb_vtable.isUnion = false; gwi.cs_vtable_is_update_with_derive = true; return -1; } @@ -6442,9 +6422,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, Item* item; vector funcFieldVec; - string sel_cols_in_select; - bool redo = false; - // empty rcWorkStack and ptWorkStack. They should all be empty by now. clearStacks(gwi); @@ -6509,12 +6486,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, } - if (ifp->is_autogenerated_name) - gwi.selectCols.push_back("`" + escapeBackTick(fullname.c_str()) + "`" + " `" + - escapeBackTick(itemAlias.empty() ? ifp->name.str : itemAlias.c_str()) + "`"); - else - gwi.selectCols.push_back("`" + escapeBackTick((itemAlias.empty() ? ifp->name.str : itemAlias.c_str())) + "`"); - gwi.returnedCols.push_back(spsc); gwi.columnMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(string(ifp->field_name.str), spsc)); @@ -6552,10 +6523,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, // add this agg col to returnedColumnList boost::shared_ptr spac(ac); gwi.returnedCols.push_back(spac); - gwi.selectCols.push_back('`' + escapeBackTick(spac->alias().c_str()) + '`'); - String str(256); - item->print(&str, QT_ORDINARY); - break; } @@ -6717,11 +6684,17 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, break; } // End of FUNC_ITEM + // DRRTUY Replace the whole section with typeid() checks or use + // reinterpret_cast here case Item::CONST_ITEM: { switch(item->cmp_type()) { case INT_RESULT: + case STRING_RESULT: + case DECIMAL_RESULT: + case REAL_RESULT: + case TIME_RESULT: { if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) { } @@ -6738,71 +6711,15 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, srcp->alias(item->name.str); gwi.returnedCols.push_back(srcp); - - Item_int* isp = reinterpret_cast(item); - ostringstream oss; - oss << isp->value << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; - - gwi.selectCols.push_back(oss.str()); } break; } - - case STRING_RESULT: - { - if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) - { } - else - { - SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); - gwi.returnedCols.push_back(srcp); - - if (item->name.length) - srcp->alias(item->name.str); - - Item_string* isp = reinterpret_cast(item); - String val, *str = isp->val_str(&val); - string valStr; - valStr.assign(str->ptr(), str->length()); - string name = "'" + valStr + "'" + " " + "`" + escapeBackTick(srcp->alias().c_str()) + "`"; - - gwi.selectCols.push_back(name); - } - - break; - } - - case DECIMAL_RESULT: - { - if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) - { } - else - { - SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); - gwi.returnedCols.push_back(srcp); - - if (item->name.length) - srcp->alias(item->name.str); - - Item_decimal* isp = reinterpret_cast(item); - String val, *str = isp->val_str(&val); - string valStr; - valStr.assign(str->ptr(), str->length()); - ostringstream oss; - oss << valStr.c_str() << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; - - gwi.selectCols.push_back(oss.str()); - } - - break; - } - // WIP MCOL-2178 This switch doesn't handl - // ROW_, TIME_, REAL_RESULT and if one couldn't - // project the former two REAL is possible. - // Need to test before commit. + // MCOL-2178 This switch doesn't handl + // ROW_ default: { + IDEBUG(cerr << "Warning unsupported cmp_type() in projection" << endl); //noop } } @@ -6820,10 +6737,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, if (item->name.length) srcp->alias(item->name.str); - - string name = string("null `") + escapeBackTick(srcp->alias().c_str()) + string("`") ; - - gwi.selectCols.push_back("null"); } break; @@ -6880,17 +6793,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, rc->alias(sub->name.str); gwi.returnedCols.push_back(SRCP(rc)); - String str; - sub->get_select_lex()->print(gwi.thd, &str, QT_ORDINARY); - - if (sub->name.length) - { - gwi.selectCols.push_back(sub->name.str); - } - else - { - gwi.selectCols.push_back("`" + escapeBackTick(str.c_ptr()) + "`"); - } break; } @@ -7437,14 +7339,14 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, && ord_item->full_name() && !strcmp(ord_item->full_name(), "Not_used")) { - continue; + continue; } else if (ord_item->type() == Item::CONST_ITEM && ord_item->cmp_type() == INT_RESULT) { - // WIP MCOL-2178. We should seek smallest - // column here and not just previous. - rc = gwi.returnedCols[((Item_int*)ord_item)->val_int() - 1]->clone(); + // DRRTUY This section looks useless b/c there is no + // way to put constant INT into an ORDER BY list + rc = gwi.returnedCols[((Item_int*)ord_item)->val_int() - 1]->clone(); } else if (ord_item->type() == Item::SUBSELECT_ITEM) { @@ -7484,6 +7386,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, gwi.orderByCols.push_back(SRCP(rc)); } } + // DRRTUY The whole block is marked for removal in 1.4.1 +#if 0 else if (!isUnion) { vector fieldVec; @@ -7590,12 +7494,9 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, } } - } } - redo = (redo || fieldVec.size() != 0); - // populate string to be added to the select list for order by for (uint32_t i = 0; i < fieldVec.size(); i++) { @@ -7635,6 +7536,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, } } } +#endif // make sure columnmap, returnedcols and count(*) arg_list are not empty TableMap::iterator tb_iter = gwi.tableMap.begin(); @@ -7715,9 +7617,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, if (!isUnion && !gwi.hasWindowFunc && gwi.subSelectType == CalpontSelectExecutionPlan::MAIN_SELECT ) { - std::ostringstream vtb; - vtb << "infinidb_vtable.$vtable_" << gwi.thd->thread_id; - { if (unionSel) order_list = select_lex.master_unit()->global_parameters()->order_list; @@ -7760,12 +7659,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, } } } - else - { - String str; - ord_item->print(&str, QT_ORDINARY); - } - } } @@ -7982,35 +7875,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, return 0; } -int cp_get_plan(THD* thd, SCSEP& csep) -{ - LEX* lex = thd->lex; - idbassert(lex != 0); - - gp_walk_info gwi; - gwi.thd = thd; - - // WIP MCOL-2178 A questionable replacement. - SELECT_LEX select_lex = *lex->first_select_lex(); - int status = getSelectPlan(gwi, select_lex, csep); - - if (status > 0) - return ER_INTERNAL_ERROR; - else if (status < 0) - return status; - -#ifdef DEBUG_WALK_COND - cerr << "---------------- cp_get_plan EXECUTION PLAN ----------------" << endl; - cerr << *csep << endl ; - cerr << "-------------- EXECUTION PLAN END --------------\n" << endl; -#endif - - // Derived table projection and filter optimization. - derivedTableOptimization(thd, csep); - - return 0; -} - int cp_get_table_plan(THD* thd, SCSEP& csep, cal_table_info& ti) { gp_walk_info* gwi = ti.condInfo; @@ -8143,7 +8007,7 @@ int cs_get_derived_plan(derived_handler* handler, THD* thd, SCSEP& csep, gp_walk return status; #ifdef DEBUG_WALK_COND - cerr << "---------------- cp_get_derived_plan EXECUTION PLAN ----------------" << endl; + cerr << "---------------- cs_get_derived_plan EXECUTION PLAN ----------------" << endl; cerr << *csep << endl ; cerr << "-------------- EXECUTION PLAN END --------------\n" << endl; #endif @@ -8163,7 +8027,7 @@ int cs_get_select_plan(select_handler* handler, THD* thd, SCSEP& csep, gp_walk_i return status; #ifdef DEBUG_WALK_COND - cerr << "---------------- cp_get_select_plan EXECUTION PLAN ----------------" << endl; + cerr << "---------------- cs_get_select_plan EXECUTION PLAN ----------------" << endl; cerr << *csep << endl ; cerr << "-------------- EXECUTION PLAN END --------------\n" << endl; #endif @@ -8352,12 +8216,11 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro gwi.tbList.push_back(tn); CalpontSystemCatalog::TableAliasName tan = make_aliastable("", alias, alias); gwi.tableMap[tan] = make_pair(0, table_ptr); -// TODO MCOL-2178 isUnion member only assigned, never used -// MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init + // MCOL-2178 isUnion member only assigned, never used + //MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init } else if (table_ptr->view) { - // WIP MCOL-2178 A questionable replacement. View* view = new View(*table_ptr->view->first_select_lex(), &gwi); CalpontSystemCatalog::TableAliasName tn = make_aliastable(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str); view->viewName(tn); @@ -8451,8 +8314,8 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // processing. if (gwi.thd->derived_tables_processing) { -// TODO MCOL-2178 isUnion member only assigned, never used -// MIGR::infinidb_vtable.isUnion = false; + // MCOL-2178 isUnion member only assigned, never used + //MIGR::infinidb_vtable.isUnion = false; return -1; } @@ -8622,12 +8485,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro } - if (ifp->is_autogenerated_name) - gwi.selectCols.push_back("`" + escapeBackTick(fullname.c_str()) + "`" + " `" + - escapeBackTick(itemAlias.empty() ? ifp->name.str : itemAlias.c_str()) + "`"); - else - gwi.selectCols.push_back("`" + escapeBackTick((itemAlias.empty() ? ifp->name.str : itemAlias.c_str())) + "`"); - // MCOL-1052 Replace SimpleColumn with ConstantColumn, // since it must have a single value only. if (constCol) @@ -8678,10 +8535,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // This item could be used in projection or HAVING later. gwi.extSelAggColsItems.push_back(item); - gwi.selectCols.push_back('`' + escapeBackTick(spac->alias().c_str()) + '`'); - String str(256); - item->print(&str, QT_ORDINARY); - break; } @@ -8741,34 +8594,11 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro continue; } - if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || - ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || - ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || - ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) ) - { } - else - { - redo = true; - String str; - ifp->print(&str, QT_ORDINARY); - gwi.selectCols.push_back(string(str.c_ptr()) + " " + "`" + escapeBackTick(item->name.str) + "`"); - } - break; } - //SRCP srcp(rc); gwi.returnedCols.push_back(srcp); - if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) - { } - else - { - String str(256); - ifp->print(&str, QT_ORDINARY); - - gwi.selectCols.push_back("`" + escapeBackTick(ifp->name.str) + "`"); - } } else // InfiniDB Non support functions still go through post process for now { @@ -8860,18 +8690,8 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro return -1; } } - - //@Bug 3021. Bypass postprocess for update and delete. - //if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) - //{} else { - // @bug 3881. Here is the real redo part. - redo = true; - // @bug 1706 - String funcStr; - ifp->print(&funcStr, QT_ORDINARY); - gwi.selectCols.push_back(string(funcStr.c_ptr()) + " `" + escapeBackTick(ifp->name.str) + "`"); // clear the error set by buildFunctionColumn gwi.fatalParseError = false; gwi.parseErrorText = ""; @@ -8881,11 +8701,17 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro break; } + // DRRTUY Replace the whole section with typeid() checks or use + // reinterpret_cast here case Item::CONST_ITEM: { switch(item->cmp_type()) { case INT_RESULT: + case STRING_RESULT: + case DECIMAL_RESULT: + case REAL_RESULT: + case TIME_RESULT: { if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) { } @@ -8902,69 +8728,16 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro srcp->alias(item->name.str); gwi.returnedCols.push_back(srcp); - - Item_int* isp = reinterpret_cast(item); - ostringstream oss; - oss << isp->value << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; - - gwi.selectCols.push_back(oss.str()); } break; } - case STRING_RESULT: - { - if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) - { } - else - { - SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); - gwi.returnedCols.push_back(srcp); - - if (item->name.length) - srcp->alias(item->name.str); - - Item_string* isp = reinterpret_cast(item); - String val, *str = isp->val_str(&val); - string valStr; - valStr.assign(str->ptr(), str->length()); - string name = "'" + valStr + "'" + " " + "`" + escapeBackTick(srcp->alias().c_str()) + "`"; - - gwi.selectCols.push_back(name); - } - - break; - } - - case DECIMAL_RESULT: - { - if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )) - { } - else - { - SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); - gwi.returnedCols.push_back(srcp); - - if (item->name.length) - srcp->alias(item->name.str); - - Item_decimal* isp = reinterpret_cast(item); - String val, *str = isp->val_str(&val); - string valStr; - valStr.assign(str->ptr(), str->length()); - ostringstream oss; - oss << valStr.c_str() << " `" << escapeBackTick(srcp->alias().c_str()) << "`"; - - gwi.selectCols.push_back(oss.str()); - } - - break; - } + // MCOL-2178 This switch doesn't handl + // ROW_ default: - // WIP MCOL-2178 Same thing as for getSelectPlan { - // noop + IDEBUG(cerr << "Warning unsupported cmp_type() in projection" << endl); } } break; @@ -8972,25 +8745,16 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro case Item::NULL_ITEM: { - // WIP MCOL-2178 Check for NULL in projection. - /*if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) ) + if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) ) { } else { SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError)); gwi.returnedCols.push_back(srcp); - if (item->name) - srcp->alias(item->name); - - string name = string("null `") + escapeBackTick(srcp->alias().c_str()) + string("`") ; - - if (sel_cols_in_create.length() != 0) - sel_cols_in_create += ", "; - - sel_cols_in_create += name; - gwi.selectCols.push_back("null"); - }*/ + if (item->name.length) + srcp->alias(item->name.str); + } break; } @@ -9047,14 +8811,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro gwi.returnedCols.push_back(SRCP(rc)); - if (sub->name.length) - { - gwi.selectCols.push_back(sub->name.str); - } - else - { - } - break; } @@ -9764,9 +9520,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro if (!isUnion && !gwi.hasWindowFunc && gwi.subSelectType == CalpontSelectExecutionPlan::MAIN_SELECT) { - std::ostringstream vtb; - vtb << "infinidb_vtable.$vtable_" << gwi.thd->thread_id; - // re-construct the select query and redo phase 1 if (redo) { diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 36f152578..50d05517d 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -764,7 +764,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h // 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 = 40; + (*f)->field_length = 310; f2->store(dl); @@ -2262,26 +2262,6 @@ int ha_calpont_impl_discover_existence(const char* schema, const char* name) int ha_calpont_impl_rnd_init(TABLE* table) { -#ifdef DEBUG_SETENV - string home(getenv("HOME")); - - if (!getenv("COLUMNSTORE_HOME")) - { - string calpontHome(home + "/Calpont/etc/"); - setenv("COLUMNSTORE_HOME", calpontHome.c_str(), 1); - } - - if (!getenv("COLUMNSTORE_CONFIG_FILE")) - { - string calpontConfigFile(home + "/mariadb/columnstore/etc/Columnstore.xml"); - setenv("COLUMNSTORE_CONFIG_FILE", calpontConfigFile.c_str(), 1); - } - - if (!getenv("CALPONT_CSC_IDENT")) - setenv("CALPONT_CSC_IDENT", "dm", 1); - -#endif - IDEBUG( cout << "rnd_init for table " << table->s->table_name.str << endl ); THD* thd = current_thd; @@ -2664,9 +2644,9 @@ int ha_calpont_impl_rnd_next(uchar* buf, TABLE* table) return HA_ERR_END_OF_FILE; // @bug 2547 -// TODO MCOL-2178 This variable can never be true in the scope of this function -// if (MIGR::infinidb_vtable.impossibleWhereOnUnion) -// return HA_ERR_END_OF_FILE; + // MCOL-2178 This variable can never be true in the scope of this function + // if (MIGR::infinidb_vtable.impossibleWhereOnUnion) + // return HA_ERR_END_OF_FILE; if (get_fe_conn_info_ptr() == NULL) set_fe_conn_info_ptr((void*)new cal_connection_info()); @@ -2756,13 +2736,11 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand) return 0; - // WIP MCOL-2178 - // Workaround because CS doesn't reset isUnion in a normal way. -// TODO MCOL-2178 isUnion member only assigned, never used -// if (is_pushdown_hand) -// { -// MIGR::infinidb_vtable.isUnion = false; -// } + // MCOL-2178 isUnion member only assigned, never used + // if (is_pushdown_hand) + // { + // MIGR::infinidb_vtable.isUnion = false; + // } if (get_fe_conn_info_ptr() != NULL) ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -2891,10 +2869,6 @@ int ha_calpont_impl_create(const char* name, TABLE* table_arg, HA_CREATE_INFO* c cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); - // @bug1940 Do nothing for select query. Support of set default engine to IDB. - if (string(name).find("@0024vtable") != string::npos) - return 0; - //@Bug 1948. Mysql calls create table to create a new table with new signature. if (ci->alterTableState > 0) return 0; @@ -2930,10 +2904,6 @@ int ha_calpont_impl_delete_table(const char* name) //if this is an InfiniDB tmp table ('#sql*.frm') just leave... if (!memcmp((uchar*)name, tmp_file_prefix, tmp_file_prefix_length)) return 0; - // @bug1940 Do nothing for select query. Support of set default engine to IDB. - if (string(name).find("@0024vtable") != string::npos) - return 0; - if (get_fe_conn_info_ptr() == NULL) set_fe_conn_info_ptr((void*)new cal_connection_info()); @@ -2970,22 +2940,6 @@ int ha_calpont_impl_delete_table(const char* name) return 0; } - // @bug 1793. make vtable droppable in calpontsys. "$vtable" ==> "@0024vtable" passed in as name. - if (strcmp(dbName, "calpontsys") == 0 && string(name).find("@0024vtable") == string::npos) - { - std::string stmt(idb_mysql_query_str(thd)); - boost::algorithm::to_upper(stmt); - - //@Bug 2432. systables can be dropped with restrict - if (stmt.find(" RESTRICT") != string::npos) - { - return 0; - } - - setError(thd, ER_INTERNAL_ERROR, "Calpont system tables can only be dropped with restrict."); - return 1; - } - int rc = ha_calpont_impl_delete_table_(dbName, name, *ci); return rc; } @@ -4355,17 +4309,16 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE // send plan whenever group_init is called int status = cp_get_group_plan(thd, csep, gi); - // WIP MCOL-2178 This could be a problem - if (status > 0) + // Never proceed if status != 0 to avoid empty DA + // crashes on later stages + if (status != 0) goto internal_error; - else if (status < 0) - return 0; // @bug 2547. don't need to send the plan if it's impossible where for all unions. -// TODO MCOL-2178 commenting the below out since cp_get_group_plan does not modify this variable -// which has a default value of false -// if (MIGR::infinidb_vtable.impossibleWhereOnUnion) -// return 0; + // MCOL-2178 commenting the below out since cp_get_group_plan does not modify this variable + // which has a default value of false + //if (MIGR::infinidb_vtable.impossibleWhereOnUnion) + // return 0; string query; // Set the query text only once if the server executes @@ -4632,9 +4585,9 @@ int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE return HA_ERR_END_OF_FILE; // @bug 2547 -// TODO MCOL-2178 -// if (MIGR::infinidb_vtable.impossibleWhereOnUnion) -// return HA_ERR_END_OF_FILE; + // MCOL-2178 + // if (MIGR::infinidb_vtable.impossibleWhereOnUnion) + // return HA_ERR_END_OF_FILE; if (get_fe_conn_info_ptr() == NULL) set_fe_conn_info_ptr((void*)new cal_connection_info()); @@ -4728,8 +4681,8 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE* thd->lex->sql_command == SQLCOM_LOAD)) return 0; -// TODO MCOL-2178 isUnion member only assigned, never used -// MIGR::infinidb_vtable.isUnion = false; + // MCOL-2178 isUnion member only assigned, never used + // MIGR::infinidb_vtable.isUnion = false; if (get_fe_conn_info_ptr() != NULL) ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -4894,26 +4847,6 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE* ***********************************************************/ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) { -#ifdef DEBUG_SETENV - string home(getenv("HOME")); - - if (!getenv("CALPONT_HOME")) - { - string calpontHome(home + "/Calpont/etc/"); - setenv("CALPONT_HOME", calpontHome.c_str(), 1); - } - - if (!getenv("CALPONT_CONFIG_FILE")) - { - string calpontConfigFile(home + "/Calpont/etc/Columnstore.xml"); - setenv("CALPONT_CONFIG_FILE", calpontConfigFile.c_str(), 1); - } - - if (!getenv("CALPONT_CSC_IDENT")) - setenv("CALPONT_CSC_IDENT", "dm", 1); - -#endif - IDEBUG( cout << "pushdown_init for table " << endl ); THD* thd = current_thd; @@ -5052,8 +4985,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) hndl = ci->cal_conn_hndl; - // WIP MCOL-2178 - std::cout << idb_mysql_query_str(thd) << std::endl; + IDEBUG( std::cout << idb_mysql_query_str(thd) << std::endl ); { if (!csep) @@ -5094,15 +5026,10 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) status = cs_get_derived_plan(dh, thd, csep, gwi); } - // WIP MCOL-2178 Remove this - std::cout << "pushdown_init get_plan status " << status << std::endl; - // Return an error to avoid MDB crash later in end_statement if (status != 0) goto internal_error; - // WIP MCOL-2178 Remove this - std::cout << "pushdown_init impossibleWhereOnUnion " << status << std::endl; // @bug 2547. don't need to send the plan if it's impossible where for all unions. if (gwi.cs_vtable_impossible_where_on_union) { @@ -5123,6 +5050,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, msg.c_str()); } +// DRRTUY Make this runtime configureable #ifdef PLAN_HEX_FILE // plan serialization ifstream ifs("/tmp/li1-plan.hex"); diff --git a/dbcon/mysql/ha_calpont_impl_if.h b/dbcon/mysql/ha_calpont_impl_if.h index 791aa999b..1331a5a2e 100644 --- a/dbcon/mysql/ha_calpont_impl_if.h +++ b/dbcon/mysql/ha_calpont_impl_if.h @@ -94,6 +94,7 @@ typedef std::map selectCols; execplan::CalpontSelectExecutionPlan::ReturnedColumnList returnedCols; execplan::CalpontSelectExecutionPlan::ReturnedColumnList groupByCols; diff --git a/dbcon/mysql/ha_mcs_pushdown.cpp b/dbcon/mysql/ha_mcs_pushdown.cpp index 1b2981b84..ab8966290 100644 --- a/dbcon/mysql/ha_mcs_pushdown.cpp +++ b/dbcon/mysql/ha_mcs_pushdown.cpp @@ -149,17 +149,17 @@ create_calpont_group_by_handler(THD* thd, Query* query) { ha_calpont_group_by_handler* handler = NULL; + // same as thd->lex->current_select + SELECT_LEX *select_lex = query->from->select_lex; + // MCOL-2178 Disable SP support in the group_by_handler for now // Check the session variable value to enable/disable use of - // group_by_handler - if (!get_group_by_handler(thd) || (thd->lex)->sphead) + // 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) { return handler; } - // same as thd->lex->current_select - SELECT_LEX *select_lex = query->from->select_lex; - // Create a handler if query is valid. See comments for details. if ( query->group_by || select_lex->with_sum_func ) { @@ -172,7 +172,7 @@ create_calpont_group_by_handler(THD* thd, Query* query) unsupported_feature = select_lex->is_correlated; // Impossible HAVING or WHERE - if ( ( !unsupported_feature && query->having && select_lex->having_value == Item::COND_FALSE ) + if ( ( !unsupported_feature && select_lex->having_value == Item::COND_FALSE ) || ( select_lex->cond_count > 0 && select_lex->cond_value == Item::COND_FALSE ) ) { @@ -473,11 +473,10 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) } // Impossible HAVING or WHERE - // WIP replace with function call + // TODO replace with function call if ( unsupported_feature - || ( select_lex->having && select_lex->having_value == Item::COND_FALSE ) - || ( select_lex->cond_count > 0 - && select_lex->cond_value == Item::COND_FALSE ) ) + || select_lex->having_value == Item::COND_FALSE + || select_lex->cond_value == Item::COND_FALSE ) { unsupported_feature = true; } From fd5233f070040c584ec73c4b078ead17da0cbc67 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Tue, 13 Aug 2019 14:18:59 +0100 Subject: [PATCH 57/59] MCOL-3424 Fix handler API breakage for write_row() The MariaDB handler API changed for write_row(). The 'buf' parameter is now a 'const'. This meant that our implementation didn't match the virtual call so ours was no longer called. This implemented the 'const'. --- dbcon/mysql/ha_calpont.cpp | 2 +- dbcon/mysql/ha_calpont.h | 2 +- dbcon/mysql/ha_calpont_dml.cpp | 26 ++++++++++++++------------ dbcon/mysql/ha_calpont_impl.cpp | 2 +- dbcon/mysql/ha_calpont_impl.h | 6 +++--- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index 4b1a0365c..4af394f57 100644 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -305,7 +305,7 @@ int ha_calpont::close(void) sql_insert.cc, sql_select.cc, sql_table.cc, sql_udf.cc and sql_update.cc */ -int ha_calpont::write_row(uchar* buf) +int ha_calpont::write_row(const uchar* buf) { DBUG_ENTER("ha_calpont::write_row"); int rc = ha_calpont_impl_write_row(buf, table); diff --git a/dbcon/mysql/ha_calpont.h b/dbcon/mysql/ha_calpont.h index 8e0c90407..295c780d6 100644 --- a/dbcon/mysql/ha_calpont.h +++ b/dbcon/mysql/ha_calpont.h @@ -136,7 +136,7 @@ public: We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int write_row(uchar* buf); + int write_row(const uchar* buf); /** @brief We implement this in ha_example.cc. It's not an obligatory method; diff --git a/dbcon/mysql/ha_calpont_dml.cpp b/dbcon/mysql/ha_calpont_dml.cpp index cb1f3853e..7f4bd6493 100644 --- a/dbcon/mysql/ha_calpont_dml.cpp +++ b/dbcon/mysql/ha_calpont_dml.cpp @@ -653,7 +653,7 @@ int ha_calpont_impl_write_last_batch(TABLE* table, cal_connection_info& ci, bool } -int ha_calpont_impl_write_row_(uchar* buf, TABLE* table, cal_connection_info& ci, ha_rows& rowsInserted) +int ha_calpont_impl_write_row_(const uchar* buf, TABLE* table, cal_connection_info& ci, ha_rows& rowsInserted) { int rc = 0; //timer.start( "buildValueList"); @@ -743,13 +743,13 @@ int ha_calpont_impl_write_row_(uchar* buf, TABLE* table, cal_connection_info& ci } } -int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_connection_info& ci) +int ha_calpont_impl_write_batch_row_(const uchar* buf, TABLE* table, cal_impl_if::cal_connection_info& ci) { ByteStream rowData; int rc = 0; //std::ostringstream data; bool nullVal = false; - uchar* bufHdr = buf; // bit flag indicating a field is null. Only those fields that are nullable are represented. + const uchar* bufHdr = buf; // bit flag indicating a field is null. Only those fields that are nullable are represented. int32_t headerByte = 0; // Current byte in the bufHdr int32_t headerBit = 0; // current bit in the bufHdr current byte. uint16_t colpos = 0; @@ -815,7 +815,7 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ } else { - uchar* tmp1 = buf; + const uchar* tmp1 = buf; uint32_t tmp = (tmp1[2] << 16) + (tmp1[1] << 8) + tmp1[0]; int day = tmp & 0x0000001fl; @@ -1491,11 +1491,12 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ if (ci.columnTypes[colpos].scale == 0) { - uchar* tmpBuf = buf; + const uchar* tmpBuf = buf; //test flag bit for sign bool posNum = tmpBuf[0] & (0x80); - tmpBuf[0] ^= 0x80; //flip the bit - int32_t tmp1 = tmpBuf[0]; + uchar tmpChr = tmpBuf[0]; + tmpChr ^= 0x80; //flip the bit + int32_t tmp1 = tmpChr; if (totalBytes > 4) { @@ -1589,11 +1590,12 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ } else { - uchar* tmpBuf = buf; + const uchar* tmpBuf = buf; //test flag bit for sign bool posNum = tmpBuf[0] & (0x80); - tmpBuf[0] ^= 0x80; //flip the bit - int32_t tmp1 = tmpBuf[0]; + uchar tmpChr = tmpBuf[0]; + tmpChr ^= 0x80; //flip the bit + int32_t tmp1 = tmpChr; //fetch the digits before decimal point if (bytesBefore == 0) @@ -1805,7 +1807,7 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ buf = buf + 2 ; } - uchar* tmpBuf = buf; + const uchar* tmpBuf = buf; for (int32_t i = 0; i < dataLength; i++) { @@ -1831,7 +1833,7 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ if ( dataLength > ci.columnTypes[colpos].colWidth) dataLength = ci.columnTypes[colpos].colWidth; - uchar* tmpBuf = buf; + const uchar* tmpBuf = buf; for (int32_t i = 0; i < dataLength; i++) { diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 14aa1d61d..7892f7c73 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -2937,7 +2937,7 @@ int ha_calpont_impl_delete_table(const char* name) int rc = ha_calpont_impl_delete_table_(dbName, name, *ci); return rc; } -int ha_calpont_impl_write_row(uchar* buf, TABLE* table) +int ha_calpont_impl_write_row(const uchar* buf, TABLE* table) { THD* thd = current_thd; //sleep(100); diff --git a/dbcon/mysql/ha_calpont_impl.h b/dbcon/mysql/ha_calpont_impl.h index 7a92f7646..ee96876db 100644 --- a/dbcon/mysql/ha_calpont_impl.h +++ b/dbcon/mysql/ha_calpont_impl.h @@ -31,7 +31,7 @@ extern int ha_calpont_impl_close(void); extern int ha_calpont_impl_rnd_init(TABLE* table); extern int ha_calpont_impl_rnd_next(uchar* buf, TABLE* table); extern int ha_calpont_impl_rnd_end(TABLE* table, bool is_derived_hand = false); -extern int ha_calpont_impl_write_row(uchar* buf, TABLE* table); +extern int ha_calpont_impl_write_row(const uchar* buf, TABLE* table); extern void ha_calpont_impl_start_bulk_insert(ha_rows rows, TABLE* table); extern int ha_calpont_impl_end_bulk_insert(bool abort, TABLE* table); extern int ha_calpont_impl_rename_table(const char* from, const char* to); @@ -56,8 +56,8 @@ extern int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info , TABLE* tabl #include "ha_calpont.h" #include "ha_mcs_pushdown.h" extern int ha_calpont_impl_rename_table_(const char* from, const char* to, cal_impl_if::cal_connection_info& ci); -extern int ha_calpont_impl_write_row_(uchar* buf, TABLE* table, cal_impl_if::cal_connection_info& ci, ha_rows& rowsInserted); -extern int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_connection_info& ci); +extern int ha_calpont_impl_write_row_(const uchar* buf, TABLE* table, cal_impl_if::cal_connection_info& ci, ha_rows& rowsInserted); +extern int ha_calpont_impl_write_batch_row_(const uchar* buf, TABLE* table, cal_impl_if::cal_connection_info& ci); extern int ha_calpont_impl_write_last_batch(TABLE* table, cal_impl_if::cal_connection_info& ci, bool abort); extern int ha_calpont_impl_commit_ (handlerton* hton, THD* thd, bool all, cal_impl_if::cal_connection_info& ci); extern int ha_calpont_impl_rollback_ (handlerton* hton, THD* thd, bool all, cal_impl_if::cal_connection_info& ci); From ad355dc771d355fff05776b5be5e4cf5c0fa39be Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Wed, 14 Aug 2019 14:03:23 +0100 Subject: [PATCH 58/59] Fix hton usage --- dbcon/mysql/ha_calpont.cpp | 3 +-- dbcon/mysql/ha_calpont.h | 1 - dbcon/mysql/ha_mcs_pushdown.cpp | 6 +++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index 419e2f853..4609a6b32 100644 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -31,7 +31,6 @@ static int calpont_commit(handlerton* hton, THD* thd, bool all); static int calpont_rollback(handlerton* hton, THD* thd, bool all); static int calpont_close_connection ( handlerton* hton, THD* thd ); -handlerton* calpont_hton; handlerton* mcs_hton; // handlers creation function for hton. @@ -733,7 +732,7 @@ int ha_calpont::external_lock(THD* thd, int lock_type) //@Bug 2526 Only register the transaction when autocommit is off if ((thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) - trans_register_ha( thd, true, calpont_hton); + trans_register_ha( thd, true, mcs_hton); int rc = ha_calpont_impl_external_lock(thd, table, lock_type); DBUG_RETURN(rc); diff --git a/dbcon/mysql/ha_calpont.h b/dbcon/mysql/ha_calpont.h index 5b9dcab56..0d6b335fe 100644 --- a/dbcon/mysql/ha_calpont.h +++ b/dbcon/mysql/ha_calpont.h @@ -21,7 +21,6 @@ #include "idb_mysql.h" #include "ha_mcs_sysvars.h" -extern handlerton* calpont_hton; extern handlerton* mcs_hton; /** @brief diff --git a/dbcon/mysql/ha_mcs_pushdown.cpp b/dbcon/mysql/ha_mcs_pushdown.cpp index 1b2981b84..58e948411 100644 --- a/dbcon/mysql/ha_mcs_pushdown.cpp +++ b/dbcon/mysql/ha_mcs_pushdown.cpp @@ -284,7 +284,7 @@ create_columnstore_derived_handler(THD* thd, TABLE_LIST *derived) ***********************************************************/ ha_columnstore_derived_handler::ha_columnstore_derived_handler(THD *thd, TABLE_LIST *dt) - : derived_handler(thd, calpont_hton) + : derived_handler(thd, mcs_hton) { derived = dt; } @@ -373,7 +373,7 @@ void ha_columnstore_derived_handler::print_error(int, unsigned long) * query - Query describing structure ***********************************************************/ ha_calpont_group_by_handler::ha_calpont_group_by_handler(THD* thd_arg, Query* query) - : group_by_handler(thd_arg, calpont_hton), + : group_by_handler(thd_arg, mcs_hton), select(query->select), table_list(query->from), distinct(query->distinct), @@ -538,7 +538,7 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) ***********************************************************/ ha_columnstore_select_handler::ha_columnstore_select_handler(THD *thd, SELECT_LEX* select_lex) - : select_handler(thd, calpont_hton) + : select_handler(thd, mcs_hton) { select = select_lex; } From 08b1c69905c50cde4a68b22b60fc554b1de4c146 Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Wed, 14 Aug 2019 16:59:06 +0300 Subject: [PATCH 59/59] MCOL-3416 Revived MULT_EQUAL_FUNC support in conditions. Removed unused symbol from DML code of the plugin. --- dbcon/execplan/simplefilter.cpp | 21 +++++ dbcon/execplan/simplefilter.h | 16 +++- dbcon/mysql/ha_calpont_dml.cpp | 103 ---------------------- dbcon/mysql/ha_calpont_execplan.cpp | 130 +++++++++++++++++++++------- dbcon/mysql/ha_calpont_impl_if.h | 3 + 5 files changed, 137 insertions(+), 136 deletions(-) diff --git a/dbcon/execplan/simplefilter.cpp b/dbcon/execplan/simplefilter.cpp index 5a4fd996d..4916a129c 100644 --- a/dbcon/execplan/simplefilter.cpp +++ b/dbcon/execplan/simplefilter.cpp @@ -470,6 +470,27 @@ bool SimpleFilter::operator==(const SimpleFilter& t) const return true; } +bool SimpleFilter::semanticEq(const SimpleFilter& t) const +{ + if (fOp != NULL) + { + if (*fOp != *t.fOp) + return false; + } + if (fLhs != NULL) + { + if (*fLhs != t.fLhs && *fLhs != *t.fRhs) + return false; + } + if (fRhs != NULL) + { + if (*fRhs != t.fRhs && *fRhs != *t.fLhs) + return false; + } + + return true; +} + bool SimpleFilter::operator==(const TreeNode* t) const { const SimpleFilter* o; diff --git a/dbcon/execplan/simplefilter.h b/dbcon/execplan/simplefilter.h index f1711082e..f29d505e3 100644 --- a/dbcon/execplan/simplefilter.h +++ b/dbcon/execplan/simplefilter.h @@ -138,28 +138,36 @@ public: /** @brief Do a deep, strict (as opposed to semantic) equivalence test * * Do a deep, strict (as opposed to semantic) equivalence test. - * @return true iff every member of t is a duplicate copy of every member of this; false otherwise + * @return true if every member of t is a duplicate copy of every member of this; false otherwise */ virtual bool operator==(const TreeNode* t) const; /** @brief Do a deep, strict (as opposed to semantic) equivalence test * * Do a deep, strict (as opposed to semantic) equivalence test. - * @return true iff every member of t is a duplicate copy of every member of this; false otherwise + * @return true if every member of t is a duplicate copy of every member of this; false otherwise */ bool operator==(const SimpleFilter& t) const; + /** @brief Do a semantic equivalence test + * + * Do a semantic equivalence test. + * @return true if filter operation are the same and + * the sets of arguments are the same; false otherwise + */ + bool semanticEq(const SimpleFilter& t) const; + /** @brief Do a deep, strict (as opposed to semantic) equivalence test * * Do a deep, strict (as opposed to semantic) equivalence test. - * @return false iff every member of t is a duplicate copy of every member of this; true otherwise + * @return false if every member of t is a duplicate copy of every member of this; true otherwise */ virtual bool operator!=(const TreeNode* t) const; /** @brief Do a deep, strict (as opposed to semantic) equivalence test * * Do a deep, strict (as opposed to semantic) equivalence test. - * @return false iff every member of t is a duplicate copy of every member of this; true otherwise + * @return false if every member of t is a duplicate copy of every member of this; true otherwise */ bool operator!=(const SimpleFilter& t) const; diff --git a/dbcon/mysql/ha_calpont_dml.cpp b/dbcon/mysql/ha_calpont_dml.cpp index cb1f3853e..e3c23274b 100644 --- a/dbcon/mysql/ha_calpont_dml.cpp +++ b/dbcon/mysql/ha_calpont_dml.cpp @@ -88,109 +88,6 @@ inline uint32_t tid2sid(const uint32_t tid) } //StopWatch timer; -int buildBuffer(uchar* buf, string& buffer, int& columns, TABLE* table) -{ - char attribute_buffer[1024]; - String attribute(attribute_buffer, sizeof(attribute_buffer), - &my_charset_bin); - - std::string cols = " ("; - std::string vals = " values ("; - columns = 0; - - for (Field** field = table->field; *field; field++) - { - const char* ptr; - const char* end_ptr; - - if ((*field)->is_null()) - ptr = end_ptr = 0; - else - { - bitmap_set_bit(table->read_set, (*field)->field_index); - (*field)->val_str(&attribute, &attribute); - ptr = attribute.ptr(); - end_ptr = attribute.length() + ptr; - } - - if (columns > 0) - { - cols.append(","); - vals.append(","); - } - - columns++; - - cols.append((*field)->field_name.str); - - if (ptr == end_ptr) - { - vals.append ("NULL"); - } - else - { - - if ( (*field)->type() == MYSQL_TYPE_VARCHAR || - /*FIXME: (*field)->type() == MYSQL_TYPE_VARBINARY || */ - (*field)->type() == MYSQL_TYPE_VAR_STRING || - (*field)->type() == MYSQL_TYPE_STRING || - (*field)->type() == MYSQL_TYPE_DATE || - (*field)->type() == MYSQL_TYPE_DATETIME || - (*field)->type() == MYSQL_TYPE_DATETIME2 || - (*field)->type() == MYSQL_TYPE_TIMESTAMP || - (*field)->type() == MYSQL_TYPE_TIMESTAMP2 || - (*field)->type() == MYSQL_TYPE_TIME ) - vals.append("'"); - - while (ptr < end_ptr) - { - - if (*ptr == '\r') - { - ptr++; - } - else if (*ptr == '\n') - { - ptr++; - } - else if (*ptr == '\'' ) - { - //@Bug 1820. Replace apostrophe with strange character to pass parser. - vals += '\252'; - ptr++; - } - else - vals += *ptr++; - } - - if ( (*field)->type() == MYSQL_TYPE_VARCHAR || - /*FIXME: (*field)->type() == MYSQL_TYPE_VARBINARY || */ - (*field)->type() == MYSQL_TYPE_VAR_STRING || - (*field)->type() == MYSQL_TYPE_STRING || - (*field)->type() == MYSQL_TYPE_DATE || - (*field)->type() == MYSQL_TYPE_DATETIME || - (*field)->type() == MYSQL_TYPE_DATETIME2 || - (*field)->type() == MYSQL_TYPE_TIMESTAMP || - (*field)->type() == MYSQL_TYPE_TIMESTAMP2 || - (*field)->type() == MYSQL_TYPE_TIME ) - vals.append("'"); - } - } - - if (columns) - { - cols.append(") "); - vals.append(") "); - buffer = "INSERT INTO "; - buffer.append(table->s->table_name.str); - buffer.append(cols); - buffer.append(vals); - } - - return columns; -} - - uint32_t buildValueList (TABLE* table, cal_connection_info& ci ) { char attribute_buffer[1024]; diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index f9bd19d4e..c536a5950 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -395,6 +395,40 @@ ReturnedColumn* buildAggFrmTempField(Item* item, gp_walk_info& gwi) return result; } +/*@brief isDuplicateSF - search for a duplicate SimpleFilter*/ +/*********************************************************** + * DESCRIPTION: + * As of 1.4 CS potentially has duplicate filter predicates + * in both join->conds and join->cond_equal. This utility f() + * searches for semantically equal SF in the list of already + * applied equi predicates. + * TODO + * We must move find_select_handler to either future or + * later execution phase. + * PARAMETERS: + * gwi main structure + * sf SimpleFilter * to find + * RETURNS + * true if sf has been found in the applied SF list + * false otherwise + * USED + * buildPredicateItem() + ***********************************************************/ +bool isDuplicateSF(gp_walk_info *gwip, execplan::SimpleFilter *sfp) +{ + List_iterator it(gwip->equiCondSFList); + execplan::SimpleFilter *isfp; + while((isfp = it++)) + { + if (sfp->semanticEq(*isfp)) + { + return true; + } + } + + return false; +} + string getViewName(TABLE_LIST* table_ptr) { string viewName = ""; @@ -1941,34 +1975,35 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip) } else if (ifp->functype() == Item_func::MULT_EQUAL_FUNC) { -#if 0 // MYSQL_5.6 - Item_equal* item_eq = (Item_equal*)ifp; - // This code is for mysql 5.6. Need to convert to MariaDB 10.1 - List_iterator_fast it(item_eq->fields); - idbassert(item_eq->fields.elements == 2); - - // @todo handle more than 2 equal fields - Item* item_field = it++; - ReturnedColumn* lhs = buildReturnedColumn(item_field, *gwip, gwip->fatalParseError); - item_field = it++; - ReturnedColumn* rhs = buildReturnedColumn(item_field, *gwip, gwip->fatalParseError); - - if (!rhs || !lhs) + Item_equal *cur_item_eq = (Item_equal*)ifp; + Item *lhs_item, *rhs_item; + // There must be at least two items + Item_equal_fields_iterator lhs_it(*cur_item_eq); + Item_equal_fields_iterator rhs_it(*cur_item_eq); rhs_it++; + while ((lhs_item = lhs_it++) && (rhs_item = rhs_it++)) { - gwip->fatalParseError = true; - gwip->parseErrorText = "Unsupport elements in MULT_EQUAL item"; - delete rhs; - delete lhs; - return false; + ReturnedColumn* lhs = buildReturnedColumn(lhs_item, *gwip, gwip->fatalParseError); + ReturnedColumn* rhs = buildReturnedColumn(rhs_item, *gwip, gwip->fatalParseError); + if (!rhs || !lhs) + { + gwip->fatalParseError = true; + gwip->parseErrorText = "Unsupport elements in MULT_EQUAL item"; + delete rhs; + delete lhs; + return false; + } + PredicateOperator* po = new PredicateOperator("="); + boost::shared_ptr sop(po); + sop->setOpType(lhs->resultType(), rhs->resultType()); + SimpleFilter* sf = new SimpleFilter(sop, lhs, rhs); + // Search in ptWorkStack for duplicates of the SF + // before we push the SF + if (!isDuplicateSF(gwip, sf)) + { + ParseTree* pt = new ParseTree(sf); + gwip->ptWorkStack.push(pt); + } } - - PredicateOperator* po = new PredicateOperator("="); - boost::shared_ptr sop(po); - sop->setOpType(lhs->resultType(), rhs->resultType()); - SimpleFilter* sf = new SimpleFilter(sop, lhs, rhs); - ParseTree* pt = new ParseTree(sf); - gwip->ptWorkStack.push(pt); -#endif } else if (ifp->functype() == Item_func::EQUAL_FUNC) { @@ -2189,6 +2224,11 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip) } } + if (ifp->functype() == Item_func::EQ_FUNC) + { + gwip->equiCondSFList.push_back(sf); + } + ParseTree* ptp = new ParseTree(sf); gwip->ptWorkStack.push(ptp); } @@ -3570,7 +3610,7 @@ ReturnedColumn* buildFunctionColumn( return rc; } - // TODO MariaDB 10.1: Until we figure out what to do with this + // Item_equal is supported by buildPredicateItem() if (funcName == "multiple equal") return NULL; @@ -5077,9 +5117,7 @@ void gp_walk(const Item* item, void* arg) string aliasTableName(scp->tableAlias()); scp->tableAlias(lower(aliasTableName)); gwip->rcWorkStack.push(scp->clone()); - //gwip->rcWorkStack.push(scp); boost::shared_ptr scsp(scp); - //boost::shared_ptr scsp(scp->clone()); gwip->scsp = scsp; gwip->funcName.clear(); @@ -6257,6 +6295,27 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, #ifdef DEBUG_WALK_COND cerr << "------------------ WHERE -----------------------" << endl; icp->traverse_cond(debug_walk, &gwi, Item::POSTFIX); + if (join && join->cond_equal) + { + List_iterator li(join->cond_equal->current_level); + Item_equal *cur_item_eq; + while ((cur_item_eq= li++)) + { + // WIP replace the block with + //cur_item_eq->traverse_cond(debug_walk, gwip, Item::POSTFIX); + std::cerr << "item_equal("; + Item *item; + Item_equal_fields_iterator it(*cur_item_eq); + while ((item= it++)) + { + std::ostringstream ostream; + std::ostringstream& osr = ostream; + getColNameFromItem(osr, item); + std::cerr << osr.str() << ","; + } + std::cerr << ")" << std::endl; + } + } cerr << "------------------------------------------------\n" << endl; #endif @@ -6279,6 +6338,19 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, setError(gwi.thd, ER_INTERNAL_ERROR, gwi.parseErrorText, gwi); return ER_INTERNAL_ERROR; } + + // MCOL-3416 support for EQUAL_COND in MDB >= 10.1 + if (join && join->cond_equal) + { + // TODO MCOL-3416 This must traverse all levels not current_level only + List_iterator li(join->cond_equal->current_level); + Item_equal *cur_item_eq; + while ((cur_item_eq= li++)) + { + cur_item_eq->traverse_cond(gp_walk, &gwi, Item::POSTFIX); + } + } + } else if (join && join->zero_result_cause) { diff --git a/dbcon/mysql/ha_calpont_impl_if.h b/dbcon/mysql/ha_calpont_impl_if.h index ed467527b..967299aaf 100644 --- a/dbcon/mysql/ha_calpont_impl_if.h +++ b/dbcon/mysql/ha_calpont_impl_if.h @@ -143,6 +143,9 @@ struct gp_walk_info std::map derivedTbFilterMap; uint32_t derivedTbCnt; std::vector subselectList; + // Workaround for duplicate equi-JOIN predicates + // See isDuplicateSF() for more info. + List equiCondSFList; // Kludge for Bug 750 int32_t recursionLevel;