diff --git a/dbcon/ddlpackageproc/createindexprocessor.cpp b/dbcon/ddlpackageproc/createindexprocessor.cpp index 9b06a4920..30b8eeaf7 100644 --- a/dbcon/ddlpackageproc/createindexprocessor.cpp +++ b/dbcon/ddlpackageproc/createindexprocessor.cpp @@ -194,25 +194,21 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage: while ( sysCons_iterator != sysConsColumns.end() ) { column = *sysCons_iterator; - boost::algorithm::to_lower(column.tableColName.column); isNull = false; if (CONSTRAINTNAME_COL == column.tableColName.column) { idxData = createIndexStmt.fIndexName->fName; - boost::algorithm::to_lower(idxData); colTuple.data = idxData; } else if (SCHEMA_COL == column.tableColName.column) { idxData = (createIndexStmt.fTableName)->fSchema; - boost::algorithm::to_lower(idxData); colTuple.data = idxData; } else if (TABLENAME_COL == column.tableColName.column) { idxData = (createIndexStmt.fTableName)->fName; - boost::algorithm::to_lower(idxData); colTuple.data = idxData; } else if (CONSTRAINTTYPE_COL == column.tableColName.column) @@ -235,7 +231,6 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage: else if (INDEXNAME_COL == column.tableColName.column) { idxData = createIndexStmt.fIndexName->fName; - boost::algorithm::to_lower(idxData); colTuple.data = idxData; } else @@ -315,33 +310,28 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage: while ( sysConsCol_iterator != sysConsColColumns.end() ) { column = *sysConsCol_iterator; - boost::algorithm::to_lower(column.tableColName.column); isNull = false; if (SCHEMA_COL == column.tableColName.column) { colData = (createIndexStmt.fTableName)->fSchema; - boost::algorithm::to_lower(colData); colTupleCol.data = colData; } else if (TABLENAME_COL == column.tableColName.column) { colData = (createIndexStmt.fTableName)->fName; - boost::algorithm::to_lower(colData); colTupleCol.data = colData; } else if (COLNAME_COL == column.tableColName.column) { colData = createIndexStmt.fColumnNames[0]; - boost::algorithm::to_lower(colData); colTupleCol.data = colData; } else if (CONSTRAINTNAME_COL == column.tableColName.column) { colData = createIndexStmt.fIndexName->fName; - boost::algorithm::to_lower(colData); colTupleCol.data = colData; } else diff --git a/dbcon/ddlpackageproc/createtableprocessor.cpp b/dbcon/ddlpackageproc/createtableprocessor.cpp index db1e8d088..a49dda249 100644 --- a/dbcon/ddlpackageproc/createtableprocessor.cpp +++ b/dbcon/ddlpackageproc/createtableprocessor.cpp @@ -76,7 +76,6 @@ CreateTableProcessor::DDLResult CreateTableProcessor::processPackage( DETAIL_INFO(createTableStmt); ddlpackage::TableDef& tableDef = *createTableStmt.fTableDef; //If schema = CALPONTSYS, do not create table - boost::algorithm::to_lower(tableDef.fQualifiedName->fSchema); if (tableDef.fQualifiedName->fSchema == CALPONT_SCHEMA) { diff --git a/dbcon/execplan/arithmeticoperator.cpp b/dbcon/execplan/arithmeticoperator.cpp index cf47554d9..230786800 100644 --- a/dbcon/execplan/arithmeticoperator.cpp +++ b/dbcon/execplan/arithmeticoperator.cpp @@ -28,20 +28,6 @@ using namespace std; -namespace -{ - -/**@brief util struct for converting string to lower case */ -struct to_lower -{ - char operator() (char c) const - { - return tolower(c); - } -}; - -} - namespace execplan { diff --git a/dbcon/execplan/calpontselectexecutionplan.h b/dbcon/execplan/calpontselectexecutionplan.h index 6f0faa645..c11a2c1df 100644 --- a/dbcon/execplan/calpontselectexecutionplan.h +++ b/dbcon/execplan/calpontselectexecutionplan.h @@ -37,6 +37,7 @@ #include "expressionparser.h" #include "calpontsystemcatalog.h" #include "brmtypes.h" +#include #ifndef __GNUC__ # ifndef __attribute__ @@ -293,9 +294,11 @@ public: { return fTableAlias; } - void tableAlias (const std::string& tableAlias) + void tableAlias (const std::string& tableAlias, int lower_case_table_names) { fTableAlias = tableAlias; + if (lower_case_table_names) + boost::algorithm::to_lower(fTableAlias); } /** @@ -424,18 +427,22 @@ public: { return fSchemaName; } - inline void schemaName(const std::string& schemaName) + inline void schemaName(const std::string& schemaName, int lower_case_table_names) { fSchemaName = schemaName; + if (lower_case_table_names) + boost::algorithm::to_lower(fSchemaName); } inline std::string& tableName() { return fTableName; } - inline void tableName(const std::string& tableName) + inline void tableName(const std::string& tableName, int lower_case_table_names) { fTableName = tableName; + if (lower_case_table_names) + boost::algorithm::to_lower(fTableName); } inline void traceOn(bool traceOn) __attribute__((deprecated)) @@ -539,16 +546,23 @@ public: return fSubType; } - void derivedTbAlias(const std::string derivedTbAlias) + void derivedTbAlias(const std::string derivedTbAlias, int lower_case_table_names=0) { fDerivedTbAlias = derivedTbAlias; + if (lower_case_table_names) + boost::algorithm::to_lower(fDerivedTbAlias); } const std::string derivedTbAlias() const { return fDerivedTbAlias; } - void derivedTbView(const std::string derivedTbView) { fDerivedTbView = derivedTbView; } + void derivedTbView(const std::string derivedTbView, int lower_case_table_names) + { + fDerivedTbView = derivedTbView; + if (lower_case_table_names) + boost::algorithm::to_lower(fDerivedTbView); + } const std::string derivedTbView() const { return fDerivedTbView; } diff --git a/dbcon/execplan/calpontsystemcatalog.cpp b/dbcon/execplan/calpontsystemcatalog.cpp index c2bb50c6e..7bb88253d 100644 --- a/dbcon/execplan/calpontsystemcatalog.cpp +++ b/dbcon/execplan/calpontsystemcatalog.cpp @@ -249,30 +249,36 @@ CalpontSystemCatalog::NJLSysDataList::~NJLSysDataList() delete *it; } -const CalpontSystemCatalog::TableColName make_tcn(const string& s, const string& t, const string& c) +const CalpontSystemCatalog::TableColName make_tcn(const string& s, const string& t, const string& c, int lower_case_table_names) { CalpontSystemCatalog::TableColName tcns; tcns.schema = s; tcns.table = t; tcns.column = c; - transform (tcns.schema.begin(), tcns.schema.end(), tcns.schema.begin(), to_lower()); - transform (tcns.table.begin(), tcns.table.end(), tcns.table.begin(), to_lower()); - transform (tcns.column.begin(), tcns.column.end(), tcns.column.begin(), to_lower()); + if (lower_case_table_names) + { + boost::algorithm::to_lower(tcns.schema); + boost::algorithm::to_lower(tcns.table); + } + boost::algorithm::to_lower(tcns.column); return tcns; } -const CalpontSystemCatalog::TableName make_table(const string& s, const string& t) +const CalpontSystemCatalog::TableName make_table(const string& s, const string& t, int lower_case_table_names) { CalpontSystemCatalog::TableName tn; tn.schema = s; tn.table = t; - transform (tn.schema.begin(), tn.schema.end(), tn.schema.begin(), to_lower()); - transform (tn.table.begin(), tn.table.end(), tn.table.begin(), to_lower()); + if (lower_case_table_names) + { + boost::algorithm::to_lower(tn.schema); + boost::algorithm::to_lower(tn.table); + } return tn; } -const CalpontSystemCatalog::TableAliasName make_aliastable(const string& s, const string& t, const string& a, const bool isColumnStore) +const CalpontSystemCatalog::TableAliasName make_aliastable(const string& s, const string& t, const string& a, const bool isColumnStore, int lower_case_table_names) { CalpontSystemCatalog::TableAliasName tn; tn.schema = s; @@ -280,13 +286,16 @@ const CalpontSystemCatalog::TableAliasName make_aliastable(const string& s, cons tn.alias = a; tn.view = ""; 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()); + if (lower_case_table_names) + { + boost::algorithm::to_lower(tn.schema); + boost::algorithm::to_lower(tn.table); + boost::algorithm::to_lower(tn.alias); + } return tn; } -const CalpontSystemCatalog::TableAliasName make_aliasview(const string& s, const string& t, const string& a, const string& v, const bool isColumnStore) +const CalpontSystemCatalog::TableAliasName make_aliasview(const string& s, const string& t, const string& a, const string& v, const bool isColumnStore, int lower_case_table_names) { CalpontSystemCatalog::TableAliasName tn; tn.schema = s; @@ -294,10 +303,13 @@ const CalpontSystemCatalog::TableAliasName make_aliasview(const string& s, const tn.alias = a; tn.view = v; 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()); - transform (tn.view.begin(), tn.view.end(), tn.view.begin(), to_lower()); + if (lower_case_table_names) + { + boost::algorithm::to_lower(tn.schema); + boost::algorithm::to_lower(tn.table); + boost::algorithm::to_lower(tn.alias); + boost::algorithm::to_lower(tn.view); + } return tn; } @@ -418,13 +430,16 @@ CalpontSystemCatalog::CatalogMap CalpontSystemCatalog::fCatalogMap; /*static*/ uint32_t CalpontSystemCatalog::fModuleID = numeric_limits::max(); -CalpontSystemCatalog::OID CalpontSystemCatalog::lookupTableOID(const TableName& tablename) +CalpontSystemCatalog::OID CalpontSystemCatalog::lookupTableOID(const TableName& tablename, int lower_case_table_names) { TableName aTableName; aTableName.schema = tablename.schema; aTableName.table = tablename.table; - transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); - transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); + if (lower_case_table_names) + { + boost::algorithm::to_lower(aTableName.schema); + boost::algorithm::to_lower(aTableName.table); + } if (aTableName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter tableInfo: " << tablename.schema << "|" << tablename.table << endl; @@ -511,7 +526,7 @@ CalpontSystemCatalog::OID CalpontSystemCatalog::lookupTableOID(const TableName& return (OID)0; } -CalpontSystemCatalog::OID CalpontSystemCatalog::lookupOID(const TableColName& tableColName) +CalpontSystemCatalog::OID CalpontSystemCatalog::lookupOID(const TableColName& tableColName, int lower_case_table_names) { if (tableColName.schema.length() == 0 || tableColName.table.length() == 0 || tableColName.column.length() == 0) return -1; @@ -520,9 +535,12 @@ CalpontSystemCatalog::OID CalpontSystemCatalog::lookupOID(const TableColName& ta aTableColName.schema = tableColName.schema; aTableColName.table = tableColName.table; aTableColName.column = tableColName.column; - transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); - transform( aTableColName.table.begin(), aTableColName.table.end(), aTableColName.table.begin(), to_lower() ); - transform( aTableColName.column.begin(), aTableColName.column.end(), aTableColName.column.begin(), to_lower() ); + if (lower_case_table_names) + { + boost::algorithm::to_lower(aTableColName.schema); + boost::algorithm::to_lower(aTableColName.table); + } + boost::algorithm::to_lower(aTableColName.column); if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter lookupOID: " << tableColName.schema << "|" << tableColName.table @@ -1583,16 +1601,19 @@ const CalpontSystemCatalog::TableColName CalpontSystemCatalog::dictColName(const return tableColName; } -uint64_t CalpontSystemCatalog::nextAutoIncrValue ( TableName aTableName) +uint64_t CalpontSystemCatalog::nextAutoIncrValue (TableName aTableName, int lower_case_table_names) { - transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); - transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); - TableInfo tbInfo; + if (lower_case_table_names) + { + boost::algorithm::to_lower(aTableName.schema); + boost::algorithm::to_lower(aTableName.table); + } + try { - tbInfo = tableInfo (aTableName); + tbInfo = tableInfo(aTableName); } catch (runtime_error& /*ex*/) { @@ -1691,13 +1712,16 @@ uint64_t CalpontSystemCatalog::nextAutoIncrValue ( TableName aTableName) } -int32_t CalpontSystemCatalog::autoColumOid ( TableName aTableName) +int32_t CalpontSystemCatalog::autoColumOid (TableName aTableName, int lower_case_table_names) { - transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); - transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); - TableInfo tbInfo; + if (lower_case_table_names) + { + boost::algorithm::to_lower(aTableName.schema); + boost::algorithm::to_lower(aTableName.table); + } + try { tbInfo = tableInfo (aTableName); @@ -2018,8 +2042,6 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::indexRIDs(const TableN TableColName aTableName; aTableName.schema = tableName.schema; aTableName.table = tableName.table; - transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); - transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); if (aTableName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter constraintRIDs: " << tableName.schema << "|" << tableName.table << endl; @@ -2097,8 +2119,6 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::indexColRIDs(const Tab TableName aTableColName; aTableColName.schema = tableName.schema; aTableColName.table = tableName.table; - transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); - transform( aTableColName.table.begin(), aTableColName.table.end(), aTableColName.table.begin(), to_lower() ); if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter indexColRIDs: " << tableName.schema << "|" @@ -2175,9 +2195,6 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::indexColRIDs(const Ind aIndexName.schema = indexName.schema; aIndexName.table = indexName.table; aIndexName.index = indexName.index; - transform( aIndexName.schema.begin(), aIndexName.schema.end(), aIndexName.schema.begin(), to_lower() ); - transform( aIndexName.table.begin(), aIndexName.table.end(), aIndexName.table.begin(), to_lower() ); - transform( aIndexName.index.begin(), aIndexName.index.end(), aIndexName.index.begin(), to_lower() ); if (aIndexName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter indexColRIDs: " << aIndexName.schema << "|" @@ -2249,8 +2266,6 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::constraintRIDs(const T TableColName aTableName; aTableName.schema = tableName.schema; aTableName.table = tableName.table; - transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); - transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); if (aTableName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter constraintRIDs: " << tableName.schema << "|" << tableName.table << endl; @@ -2325,9 +2340,7 @@ const CalpontSystemCatalog::IndexNameList CalpontSystemCatalog::colValueSysconst aTableColName.schema = tableColName.schema; aTableColName.table = tableColName.table; aTableColName.column = tableColName.column; - transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); - transform( aTableColName.table.begin(), aTableColName.table.end(), aTableColName.table.begin(), to_lower() ); - transform( aTableColName.column.begin(), aTableColName.column.end(), aTableColName.column.begin(), to_lower() ); + boost::algorithm::to_lower(aTableColName.column); #if BOOST_VERSION < 104000 boost::mutex::scoped_lock lk1(fColIndexListmapLock, false); @@ -2435,7 +2448,6 @@ const CalpontSystemCatalog::RID CalpontSystemCatalog::constraintRID(const std::s */ RID rid = std::numeric_limits::max(); string aConstraintName = constraintName; - transform( aConstraintName.begin(), aConstraintName.end(), aConstraintName.begin(), to_lower() ); CalpontSelectExecutionPlan csep; CalpontSelectExecutionPlan::ReturnedColumnList returnedColumnList; @@ -2489,7 +2501,7 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::constraintColRID(const */ RIDList ridlist; string aConstraintName = constraintName; - transform( aConstraintName.begin(), aConstraintName.end(), aConstraintName.begin(), to_lower() ); + boost::algorithm::to_lower(aConstraintName); CalpontSelectExecutionPlan csep; CalpontSelectExecutionPlan::ReturnedColumnList returnedColumnList; @@ -2550,9 +2562,7 @@ const std::string CalpontSystemCatalog::colValueSysconstraintCol (const TableCol aTableColName.schema = tableColName.schema; aTableColName.table = tableColName.table; aTableColName.column = tableColName.column; - transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); - transform( aTableColName.table.begin(), aTableColName.table.end(), aTableColName.table.begin(), to_lower() ); - transform( aTableColName.column.begin(), aTableColName.column.end(), aTableColName.column.begin(), to_lower() ); + boost::algorithm::to_lower(aTableColName.column); if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter colValueSysconstraintCol: " << tableColName.schema << "|" @@ -2631,8 +2641,6 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::constraintColRIDs(cons TableColName aTableColName; aTableColName.schema = tableName.schema; aTableColName.table = tableName.table; - transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); - transform( aTableColName.table.begin(), aTableColName.table.end(), aTableColName.table.begin(), to_lower() ); if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter constraintColRIDs: " << tableName.schema << "|" @@ -2709,9 +2717,7 @@ const CalpontSystemCatalog::RID CalpontSystemCatalog::constraintColRID(const Tab aTableColName.schema = tableColName.schema; aTableColName.table = tableColName.table; aTableColName.column = tableColName.column; - transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); - transform( aTableColName.table.begin(), aTableColName.table.end(), aTableColName.table.begin(), to_lower() ); - transform( aTableColName.column.begin(), aTableColName.column.end(), aTableColName.column.begin(), to_lower() ); + boost::algorithm::to_lower(aTableColName.column); if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter constraintColRID: " << tableColName.schema << "|" @@ -2783,11 +2789,14 @@ const CalpontSystemCatalog::RID CalpontSystemCatalog::constraintColRID(const Tab } #endif -const vector< pair > CalpontSystemCatalog::getTables (const std::string schema) +const vector< pair > CalpontSystemCatalog::getTables(const std::string schema, int lower_case_table_names) { string schemaname = schema; + if (lower_case_table_names) + { + boost::algorithm::to_lower(schemaname); + } vector < pair > tables; - transform( schemaname.begin(), schemaname.end(), schemaname.begin(), to_lower() ); if (schemaname == CALPONT_SCHEMA) { @@ -2936,16 +2945,19 @@ int CalpontSystemCatalog::getTableCount () } /* SQL statement: select objectid from syscolumn where schema=tableColName.schema and * tablename=tableColName.table and columnname=tableColName.column;*/ -const CalpontSystemCatalog::ROPair CalpontSystemCatalog::columnRID(const TableColName& tableColName) +const CalpontSystemCatalog::ROPair CalpontSystemCatalog::columnRID(const TableColName& tableColName, int lower_case_table_names) { ROPair rp; TableColName aTableColName; aTableColName.schema = tableColName.schema; aTableColName.table = tableColName.table; aTableColName.column = tableColName.column; - transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); - transform( aTableColName.table.begin(), aTableColName.table.end(), aTableColName.table.begin(), to_lower() ); - transform( aTableColName.column.begin(), aTableColName.column.end(), aTableColName.column.begin(), to_lower() ); + if (lower_case_table_names) + { + boost::algorithm::to_lower(aTableColName.schema); + boost::algorithm::to_lower(aTableColName.table); + } + boost::algorithm::to_lower(aTableColName.column); if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter columnRID: " << tableColName.schema << "|" << tableColName.table @@ -2972,11 +2984,15 @@ const CalpontSystemCatalog::ROPair CalpontSystemCatalog::columnRID(const TableCo } -const CalpontSystemCatalog::RIDList CalpontSystemCatalog::columnRIDs(const TableName& tableName, bool useCache) +const CalpontSystemCatalog::RIDList CalpontSystemCatalog::columnRIDs(const TableName& tableName, bool useCache, int lower_case_table_names) { TableName aTableName(tableName); - transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); - transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); + + if (lower_case_table_names) + { + boost::algorithm::to_lower(aTableName.schema); + boost::algorithm::to_lower(aTableName.table); + } if (aTableName.schema.empty() || aTableName.table.empty()) throw runtime_error("ColumnRIDs: Invalid table name"); @@ -3491,13 +3507,16 @@ const CalpontSystemCatalog::TableName CalpontSystemCatalog::tableName(const OID& } -const CalpontSystemCatalog::ROPair CalpontSystemCatalog::tableRID(const TableName& tableName) +const CalpontSystemCatalog::ROPair CalpontSystemCatalog::tableRID(const TableName& tableName, int lower_case_table_names) { TableName aTableName; aTableName.schema = tableName.schema; aTableName.table = tableName.table; - transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); - transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); + if (lower_case_table_names) + { + boost::algorithm::to_lower(aTableName.schema); + boost::algorithm::to_lower(aTableName.table); + } if (aTableName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter tableRID: " << tableName.schema << "|" << tableName.table << endl; @@ -3642,8 +3661,6 @@ const CalpontSystemCatalog::IndexNameList CalpontSystemCatalog::indexNames(const TableName aTableName; aTableName.schema = tableName.schema; aTableName.table = tableName.table; - transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); - transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); /* SQL statement: select indexname from sysindex where schema=indexName.schema and * tablename=indexName.table and indexname=indexName.index; @@ -3748,9 +3765,7 @@ const CalpontSystemCatalog::TableColNameList CalpontSystemCatalog::indexColNames aIndexName.schema = indexName.schema; aIndexName.table = indexName.table; aIndexName.index = indexName.index; - transform( aIndexName.schema.begin(), aIndexName.schema.end(), aIndexName.schema.begin(), to_lower() ); - transform( aIndexName.table.begin(), aIndexName.table.end(), aIndexName.table.begin(), to_lower() ); - transform( aIndexName.index.begin(), aIndexName.index.end(), aIndexName.index.begin(), to_lower() ); + boost::algorithm::to_lower(aIndexName.index); /* SQL statement: select columnname, columnposition from sysindexcol where schema=indexname.schema and * tablename=indexName.table and indexname=indexName.index; @@ -3858,7 +3873,7 @@ const CalpontSystemCatalog::TableColNameList CalpontSystemCatalog::constraintCol std::string aConstraintName( constraintName ); - transform( aConstraintName.begin(), aConstraintName.end(), aConstraintName.begin(), to_lower() ); + boost::algorithm::to_lower(aConstraintName); /* SQL statement: select columnname from sysconstraintcol where constraintname = aConstraintName */ @@ -3961,9 +3976,7 @@ const CalpontSystemCatalog::ROPair CalpontSystemCatalog::indexRID(const IndexNam aIndexName.schema = indexName.schema; aIndexName.table = indexName.table; aIndexName.index = indexName.index; - transform( aIndexName.schema.begin(), aIndexName.schema.end(), aIndexName.schema.begin(), to_lower() ); - transform( aIndexName.table.begin(), aIndexName.table.end(), aIndexName.table.begin(), to_lower() ); - transform( aIndexName.index.begin(), aIndexName.index.end(), aIndexName.index.begin(), to_lower() ); + boost::algorithm::to_lower(aIndexName.index); /* SQL statement: select indexname from sysindex where schema=indexName.schema and indexname=indexName.index; */ @@ -4020,11 +4033,11 @@ const CalpontSystemCatalog::ROPair CalpontSystemCatalog::indexRID(const IndexNam } #endif -int CalpontSystemCatalog::colNumbers(const TableName& tableName) +int CalpontSystemCatalog::colNumbers(const TableName& tableName, int lower_case_table_names) { DEBUG << "Enter colNumbers: " << tableName.schema << "|" << tableName.table << endl; - TableInfo ti = tableInfo(tableName); + TableInfo ti = tableInfo(tableName, lower_case_table_names); return ti.numOfCols; } @@ -4037,9 +4050,7 @@ const std::string CalpontSystemCatalog::colValueSysindex (const TableColName& ta aTableColName.schema = tableColName.schema; aTableColName.table = tableColName.table; aTableColName.column = tableColName.column; - transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); - transform( aTableColName.table.begin(), aTableColName.table.end(), aTableColName.table.begin(), to_lower() ); - transform( aTableColName.column.begin(), aTableColName.column.end(), aTableColName.column.begin(), to_lower() ); + boost::algorithm::to_lower(aTableColName.column); if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter colValueSysindex: " << tableColName.schema << "|" @@ -4131,9 +4142,7 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::indexColRID(const Inde aIndexName.schema = indexName.schema; aIndexName.table = indexName.table; aIndexName.index = indexName.index; - transform( aIndexName.schema.begin(), aIndexName.schema.end(), aIndexName.schema.begin(), to_lower() ); - transform( aIndexName.table.begin(), aIndexName.table.end(), aIndexName.table.begin(), to_lower() ); - transform( aIndexName.index.begin(), aIndexName.index.end(), aIndexName.index.begin(), to_lower() ); + boost::algorithm::to_lower(aIndexName.index); if (aIndexName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter indexColRID: " << aIndexName.schema << "|" @@ -4211,9 +4220,7 @@ const CalpontSystemCatalog::ROPair CalpontSystemCatalog::indexColRID(const Table aTableColName.schema = tableColName.schema; aTableColName.table = tableColName.table; aTableColName.column = tableColName.column; - transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); - transform( aTableColName.table.begin(), aTableColName.table.end(), aTableColName.table.begin(), to_lower() ); - transform( aTableColName.column.begin(), aTableColName.column.end(), aTableColName.column.begin(), to_lower() ); + boost::algorithm::to_lower(aTableColName.column); if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter indexColRID: " << tableColName.schema << "|" @@ -4295,9 +4302,7 @@ const CalpontSystemCatalog::IndexNameList CalpontSystemCatalog::colValueSysindex aTableColName.schema = tableColName.schema; aTableColName.table = tableColName.table; aTableColName.column = tableColName.column; - transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); - transform( aTableColName.table.begin(), aTableColName.table.end(), aTableColName.table.begin(), to_lower() ); - transform( aTableColName.column.begin(), aTableColName.column.end(), aTableColName.column.begin(), to_lower() ); + boost::algorithm::to_lower(aTableColName.column); return indexNameList; //so colxml can run when indexes are not made @@ -4382,8 +4387,7 @@ const CalpontSystemCatalog::TableName CalpontSystemCatalog::lookupTableForIndex( //select tablename from sysindex where indexname = indexName and schema = schema; std::string aIndexName( indexName ); std::string aSchema ( schema); - transform( aIndexName.begin(), aIndexName.end(), aIndexName.begin(), to_lower() ); - transform( aSchema.begin(), aSchema.end(), aSchema.begin(), to_lower() ); + boost::algorithm::to_lower(aIndexName); tablename.schema = aSchema; CalpontSelectExecutionPlan csep; @@ -4449,9 +4453,7 @@ const CalpontSystemCatalog::IndexOID CalpontSystemCatalog::lookupIndexNbr(const aIndexName.schema = indexName.schema; aIndexName.table = indexName.table; aIndexName.index = indexName.index; - transform( aIndexName.schema.begin(), aIndexName.schema.end(), aIndexName.schema.begin(), to_lower() ); - transform( aIndexName.table.begin(), aIndexName.table.end(), aIndexName.table.begin(), to_lower() ); - transform( aIndexName.index.begin(), aIndexName.index.end(), aIndexName.index.begin(), to_lower() ); + boost::algorithm::to_lower(aIndexName.index); if (aIndexName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter lookupIndexNbr: " << indexName.schema << "|" << indexName.table @@ -4562,9 +4564,7 @@ const CalpontSystemCatalog::IndexOID CalpontSystemCatalog::lookupIndexNbr(const aTableColName.schema = tableColName.schema; aTableColName.table = tableColName.table; aTableColName.column = tableColName.column; - transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); - transform( aTableColName.table.begin(), aTableColName.table.end(), aTableColName.table.begin(), to_lower() ); - transform( aTableColName.column.begin(), aTableColName.column.end(), aTableColName.column.begin(), to_lower() ); + boost::algorithm::to_lower(aTableColName.column); if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter lookupIndexNbr: " << tableColName.schema << "|" << tableColName.table @@ -4655,8 +4655,6 @@ const CalpontSystemCatalog::IndexOIDList CalpontSystemCatalog::indexOIDs( const aTableName.schema = tableName.schema; aTableName.table = tableName.table; - transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); - transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); if (aTableName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter indexOIDs: " << tableName.schema << "|" << tableName.table << endl; @@ -4756,7 +4754,7 @@ const CalpontSystemCatalog::IndexOIDList CalpontSystemCatalog::indexOIDs( const } #endif -const CalpontSystemCatalog::DictOIDList CalpontSystemCatalog::dictOIDs( const TableName& tableName ) +const CalpontSystemCatalog::DictOIDList CalpontSystemCatalog::dictOIDs(const TableName& tableName, int lower_case_table_names) { /* SQL statement: select dictobjectid, listobjectid, treeobjectid from syscolumn where * schema=tableName.schema and table=tableName.table;*/ @@ -4766,8 +4764,11 @@ const CalpontSystemCatalog::DictOIDList CalpontSystemCatalog::dictOIDs( const Ta aTableName.schema = tableName.schema; aTableName.table = tableName.table; - transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); - transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); + if (lower_case_table_names) + { + boost::algorithm::to_lower(aTableName.schema); + boost::algorithm::to_lower(aTableName.table); + } if (aTableName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter dictOIDs: " << tableName.schema << "|" << tableName.table << endl; @@ -4872,7 +4873,6 @@ const CalpontSystemCatalog::DictOIDList CalpontSystemCatalog::dictOIDs( const Ta return dictOIDList; } - #if 0 //Not implemented void CalpontSystemCatalog::storeColOID(void) { @@ -4898,13 +4898,16 @@ int CalpontSystemCatalog::colPosition (const OID& oid) return col.colPosition; } -const CalpontSystemCatalog::TableInfo CalpontSystemCatalog::tableInfo (const TableName& tb) +const CalpontSystemCatalog::TableInfo CalpontSystemCatalog::tableInfo(const TableName& tb, int lower_case_table_names) { TableName aTableName; aTableName.schema = tb.schema; aTableName.table = tb.table; - transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); - transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); + if (lower_case_table_names) + { + boost::algorithm::to_lower(aTableName.schema); + boost::algorithm::to_lower(aTableName.table); + } if (aTableName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter tableInfo: " << tb.schema << "|" << tb.table << endl; @@ -4916,7 +4919,7 @@ const CalpontSystemCatalog::TableInfo CalpontSystemCatalog::tableInfo (const Tab // select count(objectid) from syscolumn where schema=tableName.schema and tablename=tableName.table; try { - ridlist = columnRIDs(tb); + ridlist = columnRIDs(aTableName); } catch (logging::IDBExcept& noTable) { @@ -4953,9 +4956,7 @@ const CalpontSystemCatalog::ConstraintInfo CalpontSystemCatalog::constraintInfo aIndexName.schema = indexName.schema; aIndexName.table = indexName.table; aIndexName.index = indexName.index; - transform( aIndexName.schema.begin(), aIndexName.schema.end(), aIndexName.schema.begin(), to_lower() ); - transform( aIndexName.table.begin(), aIndexName.table.end(), aIndexName.table.begin(), to_lower() ); - transform( aIndexName.index.begin(), aIndexName.index.end(), aIndexName.index.begin(), to_lower() ); + boost::algorithm::to_lower(aIndexName.index); if (aIndexName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter constraintInfo: " << aIndexName.schema << "|" << aIndexName.table << aIndexName.index << endl; @@ -5109,9 +5110,7 @@ const CalpontSystemCatalog::IndexNameList CalpontSystemCatalog::referenceConstra aIndexName.schema = referencePKName.schema; aIndexName.table = referencePKName.table; aIndexName.index = referencePKName.index; - transform( aIndexName.schema.begin(), aIndexName.schema.end(), aIndexName.schema.begin(), to_lower() ); - transform( aIndexName.table.begin(), aIndexName.table.end(), aIndexName.table.begin(), to_lower() ); - transform( aIndexName.index.begin(), aIndexName.index.end(), aIndexName.index.begin(), to_lower() ); + boost::algorithm::to_lower(aIndexName.index); if (aIndexName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter referenceConstraints: " << aIndexName.schema << "|" << aIndexName.table << aIndexName.index << endl; @@ -5231,8 +5230,6 @@ const string CalpontSystemCatalog::primaryKeyName (const TableName& tableName ) TableName aTableName; aTableName.schema = tableName.schema; aTableName.table = tableName.table; - transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); - transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); if (tableName.schema.compare(CALPONT_SCHEMA) != 0) DEBUG << "Enter primaryKeyName: " << tableName.schema << "|" << tableName.table << endl; @@ -5301,11 +5298,13 @@ const string CalpontSystemCatalog::primaryKeyName (const TableName& tableName ) } #endif -void CalpontSystemCatalog::getSchemaInfo(const string& in_schema) +void CalpontSystemCatalog::getSchemaInfo(const string& in_schema, int lower_case_table_names) { string schema = in_schema; - transform( schema.begin(), schema.end(), schema.begin(), to_lower() ); - + if (lower_case_table_names) + { + boost::algorithm::to_lower(schema); + } if (schema == CALPONT_SCHEMA) return; else diff --git a/dbcon/execplan/calpontsystemcatalog.h b/dbcon/execplan/calpontsystemcatalog.h index ae2fb05d2..ae45ec888 100644 --- a/dbcon/execplan/calpontsystemcatalog.h +++ b/dbcon/execplan/calpontsystemcatalog.h @@ -550,13 +550,13 @@ public: * * For a unique table_name return the internal OID */ - OID lookupTableOID(const TableName& tableName); + OID lookupTableOID(const TableName& tableName, int lower_case_table_names=0); /** looks up a column's OID in the System Catalog * * For a unique table_name.column_name return the internal OID */ - OID lookupOID(const TableColName& tableColName); + OID lookupOID(const TableColName& tableColName, int lower_case_table_names=0); /** returns the column type attribute(s) for a column * @@ -588,19 +588,19 @@ public: * 0: Autoincrement does not exist for this table * Throws runtime_error if no such table found */ - uint64_t nextAutoIncrValue ( TableName tableName); + uint64_t nextAutoIncrValue(TableName tableName, int lower_case_table_names=0); /** returns the rid of next autoincrement value for the table oid * * return the rid of next value of autoincrement for a given table: */ - const ROPair nextAutoIncrRid ( const OID& oid); + const ROPair nextAutoIncrRid(const OID& oid); /** returns the oid of autoincrement column for the table * * return the oid of autoincrement column for a given table: */ - int32_t autoColumOid(TableName tableName); + int32_t autoColumOid(TableName tableName, int lower_case_table_names=0); /** returns the columns bitmap file object number * @@ -618,31 +618,31 @@ public: * * returns a list of the RID's of the indexes for a table */ - const RIDList indexRIDs(const TableName& tableName); + const RIDList indexRIDs(const TableName& tableName, int lower_case_table_names=0); /** return the total number of columns for a table * * returns the total number of columns for a table */ - int colNumbers(const TableName& tableName); + int colNumbers(const TableName& tableName, int lower_case_table_names=0); /** return the RID's of the colindexes for a table * * returns a list of the RID's of the colindexes for a table */ - const RIDList indexColRIDs(const TableName& tableName); + const RIDList indexColRIDs(const TableName& tableName, int lower_case_table_names=0); /** return the RID's of the index columns (SYSINDEXCOL) for a index * * returns a list of the RID's of the colindexes for a index */ - const RIDList indexColRIDs(const IndexName& indexName); + const RIDList indexColRIDs(const IndexName& indexName, int lower_case_table_names=0); /** return the RID's of the constraints for a table * * returns a list of the RID's of the constraints for a table */ - const RIDList constraintRIDs(const TableName& tableName); + const RIDList constraintRIDs(const TableName& tableName, int lower_case_table_names=0); /** return the RID of the constraint for a ConstrainName * @@ -660,19 +660,19 @@ public: * * returns a list of the RID's of the colconstraints for a table */ - const RIDList constraintColRIDs(const TableName& tableName); + const RIDList constraintColRIDs(const TableName& tableName, int lower_case_table_names=0); /** return the RID of the colconstraint for a column * * returns the RID of the colconstraints for a column */ - RID constraintColRID(const TableColName& tableColName); + RID constraintColRID(const TableColName& tableColName, int lower_case_table_names=0); /** return the value for the given RID and column name from table SYSCONSTRAINTCOL * * returns the column value for the given RID a column name fron table SYSCONSTRAINTCOL */ - const std::string colValueSysconstraintCol (const TableColName& colName); + const std::string colValueSysconstraintCol (const TableColName& colName, int lower_case_table_names=0); /** return the RID of the constraint for a ConstrainName * @@ -686,19 +686,19 @@ public: * return OID. Therefore it's duplicate to lookupOID function. This function is to be * deprecated. */ - const ROPair columnRID(const TableColName& tableColName); + const ROPair columnRID(const TableColName& tableColName, int lower_case_table_names=0); /** return the RID's of the columns for a table * * returns a list of the RID's of the columns for a table */ - const RIDList columnRIDs(const TableName& tableName, bool useCache = false); + const RIDList columnRIDs(const TableName& tableName, bool useCache = false, int lower_case_table_names=0); /** return the RID of the table * * returns the RID of the table */ - const ROPair tableRID(const TableName& tableName); + const ROPair tableRID(const TableName& tableName, int lower_case_table_names=0); /** return the RID of the index for a table * @@ -709,7 +709,7 @@ public: * * returns the index name list for a table */ - const IndexNameList indexNames(const TableName& tableName); + const IndexNameList indexNames(const TableName& tableName, int lower_case_table_names=0); /** return the column names for a index * * returns the column name list for a index @@ -726,7 +726,7 @@ public: * * returns the column value for the given RID a column name fron table SYSINDEX */ - const std::string colValueSysindex (const TableColName& colName); + const std::string colValueSysindex (const TableColName& colName, int lower_case_table_names=0); /** return the RID of the colindexe for a table * @@ -738,13 +738,13 @@ public: * * returns the RID's of the colindexe for a table */ - const ROPair indexColRID(const TableColName& tableColName); + const ROPair indexColRID(const TableColName& tableColName, int lower_case_table_names=0); /** return the value for the given RID and column name from table SYSINDEX * * returns the column value for the given RID a column name fron table SYSINDEX */ - const IndexNameList colValueSysindexCol (const TableColName& colName); + const IndexNameList colValueSysindexCol (const TableColName& colName, int lower_case_table_names=0); /** looks up a Table Name for a Index in the System Catalog * @@ -765,19 +765,19 @@ public: * for now, assume one column belongs to just one index. In the future getPlan * should give index name therefore this function will be deprecated. */ - const IndexOID lookupIndexNbr(const TableColName& tableColName); + const IndexOID lookupIndexNbr(const TableColName& tableColName, int lower_case_table_names=0); /** return the list of Index OIDs for the given table * * returns the list of Index OIDs for a table */ - const IndexOIDList indexOIDs(const TableName& tableName); + const IndexOIDList indexOIDs(const TableName& tableName, int lower_case_table_names=0); /** return the list of Dictionary OIDs for the given table * * returns the list of Dictionary OIDs for a table */ - const DictOIDList dictOIDs(const TableName& tableName); + const DictOIDList dictOIDs(const TableName& tableName, int lower_case_table_names=0); /** Update column OID. This is for testing DDL and DML only * and will go away once READ works @@ -838,16 +838,16 @@ public: */ int colPosition (const OID& oid); /** return primary key name for the given table */ - const std::string primaryKeyName (const TableName& tableName ); + const std::string primaryKeyName (const TableName& tableName, int lower_case_table_names=0); /** return the table info * * return the table info for a given TableName */ - const TableInfo tableInfo (const TableName& tb); + const TableInfo tableInfo (const TableName& tb, int lower_case_table_names=0); /** return the table name for a give table oid */ const TableName tableName (const OID& oid); /** return the list of tables for a given schema */ - const std::vector< std::pair > getTables (const std::string schema = ""); + const std::vector< std::pair > getTables(const std::string schema = "", int lower_case_table_names=0); /** return the number of tables in the whole database */ int getTableCount (); /** return the constraint info for a given constraint */ @@ -856,7 +856,7 @@ public: const IndexNameList referenceConstraints (const IndexName& referencePKName); // @bug 682 - void getSchemaInfo(const std::string& schema); + void getSchemaInfo(const std::string& schema, int lower_case_table_names=0); typedef std::map OIDNextvalMap; void updateColinfoCache(OIDNextvalMap& oidNextvalMap); @@ -951,14 +951,15 @@ private: /** convenience function to make a TableColName from 3 strings */ -const CalpontSystemCatalog::TableColName make_tcn(const std::string& s, const std::string& t, const std::string& c); +const CalpontSystemCatalog::TableColName make_tcn(const std::string& s, const std::string& t, const std::string& c, int lower_case_table_names=0); /** convenience function to make a TableName from 2 strings */ -const CalpontSystemCatalog::TableName make_table(const std::string& s, const std::string& t); +const CalpontSystemCatalog::TableName make_table(const std::string& s, const std::string& t, int lower_case_table_names=0); const CalpontSystemCatalog::TableAliasName make_aliastable(const std::string& s, const std::string& t, const std::string& a, - 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); + const bool fisColumnStore = true, int lower_case_table_names=0); +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, int lower_case_table_names=0); /** convenience function to determine if column type is a char * type diff --git a/dbcon/execplan/expressionparser.cpp b/dbcon/execplan/expressionparser.cpp index bba1de48c..4201b90e4 100644 --- a/dbcon/execplan/expressionparser.cpp +++ b/dbcon/execplan/expressionparser.cpp @@ -31,6 +31,7 @@ using namespace std; #include "constantcolumn.h" #include "operator.h" #include "treenode.h" +#include namespace execplan { @@ -98,7 +99,7 @@ int ExpressionParser::positions(Token t) return expression::close | expression::function_close; default: - transform (oper.begin(), oper.end(), oper.begin(), to_lower()); + boost::algorithm::to_lower(oper); if (oper.compare ("and") == 0 || oper.compare ("or") == 0 ) return expression::infix; @@ -143,7 +144,7 @@ int ExpressionParser::position(TreeNode* op) return expression::function_close; default: - transform (oper.begin(), oper.end(), oper.begin(), to_lower()); + boost::algorithm::to_lower(oper); if (oper.compare ("and") == 0 || oper.compare ("or") == 0 ) return expression::infix; @@ -200,7 +201,7 @@ TreeNode* ExpressionParser::as_operator(Token t, int pos) } default: - transform (oper.begin(), oper.end(), oper.begin(), to_lower()); + boost::algorithm::to_lower(oper); if (oper.compare ("and") == 0 || oper.compare ("or") == 0 ) return t.value; @@ -295,7 +296,7 @@ ParseTree* ExpressionParser::reduce(ParseTree* a, TreeNode* b, string content = value->data()->data(); ParseTree* root; - transform (functionName.begin(), functionName.end(), functionName.begin(), to_lower()); + boost::algorithm::to_lower(functionName); if (functionName.compare("sum") == 0 || functionName.compare("avg") == 0 || @@ -346,7 +347,7 @@ int ExpressionParser::precnum(TreeNode* op) return 7; default: - transform (oper.begin(), oper.end(), oper.begin(), to_lower()); + boost::algorithm::to_lower(oper); if (oper.compare("or") == 0) return 1; @@ -372,7 +373,7 @@ expression::associativity ExpressionParser::assoc(TreeNode* op) return expression::left_associative; default: - transform (oper.begin(), oper.end(), oper.begin(), to_lower()); + boost::algorithm::to_lower(oper); if (oper.compare("or") == 0 || oper.compare("and") == 0) return expression::left_associative; diff --git a/dbcon/execplan/expressionparser.h b/dbcon/execplan/expressionparser.h index 924db2e81..cc7f34f7b 100644 --- a/dbcon/execplan/expressionparser.h +++ b/dbcon/execplan/expressionparser.h @@ -46,17 +46,6 @@ namespace execplan typedef std::stack OperandStack; typedef std::stack OperatorStack; -/**@brief util struct for converting string to lower case - * - */ -struct to_lower -{ - char operator() (char c) const - { - return tolower(c); - } -}; - /**@brief a structure to respent a token accepted by the parser * * token structure diff --git a/dbcon/execplan/logicoperator.cpp b/dbcon/execplan/logicoperator.cpp index a466017da..662653195 100644 --- a/dbcon/execplan/logicoperator.cpp +++ b/dbcon/execplan/logicoperator.cpp @@ -28,20 +28,6 @@ using namespace std; -namespace -{ - -/**@brief util struct for converting string to lower case */ -struct to_lower -{ - char operator() (char c) const - { - return tolower(c); - } -}; - -} - namespace execplan { diff --git a/dbcon/execplan/predicateoperator.cpp b/dbcon/execplan/predicateoperator.cpp index 4772a8b8c..3f4aee1f2 100644 --- a/dbcon/execplan/predicateoperator.cpp +++ b/dbcon/execplan/predicateoperator.cpp @@ -36,20 +36,6 @@ using namespace oam; using namespace std; -namespace -{ - -/**@brief util struct for converting string to lower case */ -struct to_lower -{ - char operator() (char c) const - { - return tolower(c); - } -}; - -} - namespace execplan { diff --git a/dbcon/execplan/simplecolumn.cpp b/dbcon/execplan/simplecolumn.cpp index 3c98536b6..054d7ab0d 100644 --- a/dbcon/execplan/simplecolumn.cpp +++ b/dbcon/execplan/simplecolumn.cpp @@ -158,7 +158,8 @@ SimpleColumn::SimpleColumn(const string& token, const uint32_t sessionID): SimpleColumn::SimpleColumn(const string& schemaName, const string& tableName, const string& columnName, - const uint32_t sessionID): + const uint32_t sessionID, + const int lower_case_table_names) : ReturnedColumn(sessionID), fSchemaName (schemaName), fTableName (tableName), @@ -167,13 +168,20 @@ SimpleColumn::SimpleColumn(const string& schemaName, { setOID(); fDistinct = false; + if (lower_case_table_names) + { + boost::algorithm::to_lower(fSchemaName); + boost::algorithm::to_lower(fTableName); + } + boost::algorithm::to_lower(fColumnName); } SimpleColumn::SimpleColumn(const string& schemaName, const string& tableName, const string& columnName, const bool isColumnStore, - const uint32_t sessionID): + const uint32_t sessionID, + const int lower_case_table_names) : ReturnedColumn(sessionID), fSchemaName (schemaName), fTableName (tableName), @@ -182,8 +190,13 @@ SimpleColumn::SimpleColumn(const string& schemaName, { if (isColumnStore) setOID(); - fDistinct = false; + if (lower_case_table_names) + { + boost::algorithm::to_lower(fSchemaName); + boost::algorithm::to_lower(fTableName); + } + boost::algorithm::to_lower(fColumnName); } SimpleColumn::SimpleColumn (const SimpleColumn& rhs, const uint32_t sessionID): diff --git a/dbcon/execplan/simplecolumn.h b/dbcon/execplan/simplecolumn.h index 54193fba5..d6e60929b 100644 --- a/dbcon/execplan/simplecolumn.h +++ b/dbcon/execplan/simplecolumn.h @@ -33,6 +33,7 @@ #include "calpontsystemcatalog.h" #include "dataconvert.h" #include "calpontselectexecutionplan.h" +#include namespace messageqcpp { @@ -66,12 +67,14 @@ public: SimpleColumn(const std::string& schema, const std::string& table, const std::string& col, - const uint32_t sessionID = 0); + const uint32_t sessionID = 0, + const int lower_case_table_names = 0); SimpleColumn(const std::string& schema, const std::string& table, const std::string& col, const bool isColumnStore, - const uint32_t sessionID = 0); + const uint32_t sessionID = 0, + const int lower_case_table_names = 0); SimpleColumn(const SimpleColumn& rhs, const uint32_t sessionID = 0); /** @@ -87,9 +90,11 @@ public: return fSchemaName; } - inline void schemaName(const std::string& schemaName) + inline void schemaName(const std::string& schemaName, int lower_case_table_names = 0) { fSchemaName = schemaName; + if (lower_case_table_names) + boost::algorithm::to_lower(fSchemaName); } inline const std::string& tableName() const @@ -97,9 +102,11 @@ public: return fTableName; } - inline void tableName(const std::string& tableName) + inline void tableName(const std::string& tableName, int lower_case_table_names = 0) { fTableName = tableName; + if (lower_case_table_names) + boost::algorithm::to_lower(fTableName); } inline const std::string& columnName() const @@ -132,9 +139,11 @@ public: { return fTableAlias; } - inline void tableAlias(const std::string& tableAlias) + inline void tableAlias(const std::string& tableAlias, int lower_case_table_names = 0) { fTableAlias = tableAlias; + if (lower_case_table_names) + boost::algorithm::to_lower(fTableAlias); } inline const std::string& indexName() const { @@ -148,9 +157,11 @@ public: { return fViewName; } - inline void viewName(const std::string& viewName) + inline void viewName(const std::string& viewName, int lower_case_table_names = 0) { fViewName = viewName; + if (lower_case_table_names) + boost::algorithm::to_lower(fViewName); } inline const std::string& timeZone() const { diff --git a/dbcon/joblist/jlf_common.cpp b/dbcon/joblist/jlf_common.cpp index fe3195653..c40425b16 100644 --- a/dbcon/joblist/jlf_common.cpp +++ b/dbcon/joblist/jlf_common.cpp @@ -313,7 +313,7 @@ string UniqId::toString() const //------------------------------------------------------------------------------ string extractTableAlias(const SimpleColumn* sc) { - return ba::to_lower_copy(sc->tableAlias()); + return sc->tableAlias(); } @@ -322,7 +322,7 @@ string extractTableAlias(const SimpleColumn* sc) //------------------------------------------------------------------------------ string extractTableAlias(const SSC& sc) { - return ba::to_lower_copy(sc->tableAlias()); + return sc->tableAlias(); } diff --git a/dbcon/joblist/subquerytransformer.cpp b/dbcon/joblist/subquerytransformer.cpp index 6ebd00602..be54eaedd 100644 --- a/dbcon/joblist/subquerytransformer.cpp +++ b/dbcon/joblist/subquerytransformer.cpp @@ -63,7 +63,7 @@ SubQueryTransformer::SubQueryTransformer(JobInfo* jobInfo, SErrorInfo& err, const string& view) : fOutJobInfo(jobInfo), fSubJobInfo(NULL), fErrorInfo(err) { - fVtable.view(algorithm::to_lower_copy(view)); + fVtable.view(view); } @@ -72,8 +72,8 @@ SubQueryTransformer::SubQueryTransformer(JobInfo* jobInfo, SErrorInfo& err, const string& view) : fOutJobInfo(jobInfo), fSubJobInfo(NULL), fErrorInfo(err) { - fVtable.alias(algorithm::to_lower_copy(alias)); - fVtable.view(algorithm::to_lower_copy(view)); + fVtable.alias(alias); + fVtable.view(view); } diff --git a/dbcon/mysql/columnstore.cnf b/dbcon/mysql/columnstore.cnf index 682745401..19840e129 100644 --- a/dbcon/mysql/columnstore.cnf +++ b/dbcon/mysql/columnstore.cnf @@ -1,7 +1,6 @@ [mysqld] plugin-load-add=ha_columnstore.so plugin-maturity=beta -lower_case_table_names=1 # Enable compression by default on create, set to NONE to turn off #columnstore_compression_type=SNAPPY diff --git a/dbcon/mysql/ha_from_sub.cpp b/dbcon/mysql/ha_from_sub.cpp index d34bc8c2e..3322f51a2 100644 --- a/dbcon/mysql/ha_from_sub.cpp +++ b/dbcon/mysql/ha_from_sub.cpp @@ -345,7 +345,7 @@ SCSEP FromSubQuery::transform() gwi.subQuery = this; gwi.viewName = fGwip.viewName; csep->derivedTbAlias(fAlias); // always lower case - csep->derivedTbView(fGwip.viewName.alias); + csep->derivedTbView(fGwip.viewName.alias, lower_case_table_names); if (getSelectPlan(gwi, *fFromSub, csep, false) != 0) { diff --git a/dbcon/mysql/ha_mcs_client_udfs.cpp b/dbcon/mysql/ha_mcs_client_udfs.cpp index aa9d114eb..87ba12d84 100644 --- a/dbcon/mysql/ha_mcs_client_udfs.cpp +++ b/dbcon/mysql/ha_mcs_client_udfs.cpp @@ -478,7 +478,9 @@ extern "C" tableName.table = args->args[0]; if (thd->db.length) + { tableName.schema = thd->db.str; + } else { std::string msg("No schema information provided"); @@ -487,6 +489,11 @@ extern "C" return result; } } + if (lower_case_table_names) + { + boost::algorithm::to_lower(tableName.schema); + boost::algorithm::to_lower(tableName.table); + } if ( !ci->dmlProc ) { @@ -620,6 +627,11 @@ extern "C" return -1; } } + if (lower_case_table_names) + { + boost::algorithm::to_lower(tableName.schema); + boost::algorithm::to_lower(tableName.table); + } boost::shared_ptr csc = execplan::CalpontSystemCatalog::makeCalpontSystemCatalog( diff --git a/dbcon/mysql/ha_mcs_ddl.cpp b/dbcon/mysql/ha_mcs_ddl.cpp index 55c4e4fb5..82ea00a17 100644 --- a/dbcon/mysql/ha_mcs_ddl.cpp +++ b/dbcon/mysql/ha_mcs_ddl.cpp @@ -421,10 +421,14 @@ bool anyRowInTable(string& schema, string& tableName, int sessionID) boost::shared_ptr csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); csc->identity(execplan::CalpontSystemCatalog::FE); CalpontSystemCatalog::TableName aTableName; - algorithm::to_lower(schema); - algorithm::to_lower(tableName); + if (lower_case_table_names) + { + algorithm::to_lower(schema); + algorithm::to_lower(tableName); + } aTableName.schema = schema; aTableName.table = tableName; + CalpontSystemCatalog::RIDList ridList = csc->columnRIDs(aTableName, true); CalpontSystemCatalog::TableColName tableColName = csc->colName(ridList[0].objnum); @@ -558,8 +562,11 @@ bool anyTimestampColumn(string& schema, string& tableName, int sessionID) boost::shared_ptr csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); csc->identity(execplan::CalpontSystemCatalog::FE); CalpontSystemCatalog::TableName aTableName; - algorithm::to_lower(schema); - algorithm::to_lower(tableName); + if (lower_case_table_names) + { + algorithm::to_lower(schema); + algorithm::to_lower(tableName); + } // select columnname from calpontsys.syscolumn // where schema = schema and tablename = tableName @@ -729,8 +736,11 @@ bool anyNullInTheColumn (THD* thd, string& schema, string& table, string& column CalpontSelectExecutionPlan::ReturnedColumnList returnedColumnList; CalpontSelectExecutionPlan::FilterTokenList filterTokenList; CalpontSelectExecutionPlan::ColumnMap colMap; - algorithm::to_lower(schema); - algorithm::to_lower(table); + if (lower_case_table_names) + { + algorithm::to_lower(schema); + algorithm::to_lower(table); + } algorithm::to_lower(columnName); SessionManager sm; @@ -912,6 +922,11 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl if ( typeid ( stmt ) == typeid ( CreateTableStatement ) ) { CreateTableStatement* createTable = dynamic_cast ( &stmt ); + if (lower_case_table_names) + { + algorithm::to_lower(createTable->fTableDef->fQualifiedName->fSchema); + algorithm::to_lower(createTable->fTableDef->fQualifiedName->fName); + } bool matchedCol = false; bool isFirstTimestamp = true; @@ -1215,6 +1230,11 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl else if ( typeid ( stmt ) == typeid ( AlterTableStatement ) ) { AlterTableStatement* alterTable = dynamic_cast ( &stmt ); + if (lower_case_table_names) + { + algorithm::to_lower(alterTable->fTableName->fSchema); + algorithm::to_lower(alterTable->fTableName->fName); + } alterTable->fTimeZone.assign(thd->variables.time_zone->get_name()->ptr()); diff --git a/dbcon/mysql/ha_mcs_dml.cpp b/dbcon/mysql/ha_mcs_dml.cpp index 733506ac1..53c9e22f6 100644 --- a/dbcon/mysql/ha_mcs_dml.cpp +++ b/dbcon/mysql/ha_mcs_dml.cpp @@ -1877,6 +1877,11 @@ std::string ha_mcs_impl_viewtablelock( cal_impl_if::cal_connection_info& ci, ex std::string dmlStatement( "VIEWTABLELOCK" ); VendorDMLStatement cmdStmt(dmlStatement, DML_COMMAND, sessionID); pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(cmdStmt); + if (lower_case_table_names) + { + boost::algorithm::to_lower(tablename.schema); + boost::algorithm::to_lower(tablename.table); + } pDMLPackage->set_SchemaName (tablename.schema); pDMLPackage->set_TableName (tablename.table); diff --git a/dbcon/mysql/ha_mcs_execplan.cpp b/dbcon/mysql/ha_mcs_execplan.cpp index 93b763ddf..cd7b92b32 100755 --- a/dbcon/mysql/ha_mcs_execplan.cpp +++ b/dbcon/mysql/ha_mcs_execplan.cpp @@ -16,7 +16,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -//#define DEBUG_WALK_COND #include #include @@ -129,15 +128,6 @@ public: gp_walk_info* fgwip; }; -namespace -{ -string lower(string str) -{ - boost::algorithm::to_lower(str); - return str; -} -} - #include "ha_view.h" namespace cal_impl_if @@ -1249,7 +1239,7 @@ void buildNestedTableOuterJoin(gp_walk_info& gwi, TABLE_LIST* table_ptr) (table->db.length ? table->db.str : ""), (table->table_name.length ? table->table_name.str : ""), (table->alias.length ? table->alias.str : ""), - getViewName(table)); + getViewName(table), true, lower_case_table_names); gwi.innerTables.insert(ta); } @@ -1264,7 +1254,7 @@ void buildNestedTableOuterJoin(gp_walk_info& gwi, TABLE_LIST* table_ptr) (tab->db.length ? tab->db.str : ""), (tab->table_name.length ? tab->table_name.str : ""), (tab->alias.length ? tab->alias.str : ""), - getViewName(tab)); + getViewName(tab), true, lower_case_table_names); gwi.innerTables.insert(ta); } } @@ -1313,7 +1303,7 @@ uint32_t buildOuterJoin(gp_walk_info& gwi, SELECT_LEX& select_lex) (table_ptr->db.length ? table_ptr->db.str : ""), (table_ptr->table_name.length ? table_ptr->table_name.str : ""), (table_ptr->alias.length ? table_ptr->alias.str : ""), - getViewName(table_ptr)); + getViewName(table_ptr), true, lower_case_table_names); if (table_ptr->outer_join && table_ptr->on_expr) { @@ -1332,7 +1322,7 @@ uint32_t buildOuterJoin(gp_walk_info& gwi, SELECT_LEX& select_lex) (table->db.length ? table->db.str : ""), (table->table_name.length ? table->table_name.str : ""), (table->alias.length ? table->alias.str : ""), - getViewName(table)); + getViewName(table), true, lower_case_table_names); gwi_outer.innerTables.insert(ta); } } @@ -1367,7 +1357,7 @@ uint32_t buildOuterJoin(gp_walk_info& gwi, SELECT_LEX& select_lex) (table->db.length ? table->db.str : ""), (table->table_name.length ? table->table_name.str : ""), (table->alias.length ? table->alias.str : ""), - getViewName(table)); + getViewName(table), true, lower_case_table_names); gwi_outer.innerTables.insert(ta); } @@ -2387,8 +2377,8 @@ SimpleColumn* buildSimpleColFromDerivedTable(gp_walk_info& gwi, Item_field* ifp) // @bug 3003. Keep column alias if it has. sc->alias(ifp->is_autogenerated_name() ? tcn.column : ifp->name.str); - sc->tableAlias(lower(gwi.tbList[i].alias)); - sc->viewName(lower(viewName)); + sc->tableAlias(gwi.tbList[i].alias); + sc->viewName(viewName, lower_case_table_names); sc->resultType(ct); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); break; @@ -2446,17 +2436,15 @@ SimpleColumn* buildSimpleColFromDerivedTable(gp_walk_info& gwi, Item_field* ifp) sc->alias(ifp->is_autogenerated_name() ? cols[j]->alias() : ifp->name.str); sc->tableName(csep->derivedTbAlias()); sc->colPosition(j); - string tableAlias(csep->derivedTbAlias()); - sc->tableAlias(lower(tableAlias)); + sc->tableAlias(csep->derivedTbAlias()); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); if (!viewName.empty()) { - // TODO: Remove lower when MCOL-4144 fixed - sc->viewName(lower(viewName)); + sc->viewName(viewName, lower_case_table_names); } else { - sc->viewName(lower(csep->derivedTbView())); + sc->viewName(csep->derivedTbView()); } sc->resultType(cols[j]->resultType()); sc->hasAggregate(cols[j]->hasAggregate()); @@ -2570,15 +2558,14 @@ void collectAllCols(gp_walk_info& gwi, Item_field* ifp) SimpleColumn* sc = new SimpleColumn(); sc->columnName(cols[j]->alias()); sc->colPosition(j); - string tableAlias(csep->derivedTbAlias()); - sc->tableAlias(lower(tableAlias)); - sc->viewName(lower(gwi.tbList[i].view)); + sc->tableAlias(csep->derivedTbAlias()); + sc->viewName(gwi.tbList[i].view); sc->resultType(cols[j]->resultType()); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); // @bug5634 derived table optimization cols[j]->incRefCount(); - sc->derivedTable(tableAlias); + sc->derivedTable(sc->tableAlias()); sc->derivedRefCol(cols[j].get()); srcp.reset(sc); gwi.returnedCols.push_back(srcp); @@ -2590,10 +2577,23 @@ void collectAllCols(gp_walk_info& gwi, Item_field* ifp) { CalpontSystemCatalog::TableName tn(gwi.tbList[i].schema, gwi.tbList[i].table); - if (!tableName.empty() && (strcasecmp(tableName.c_str(), tn.table.c_str()) != 0 && - strcasecmp(tableName.c_str(), gwi.tbList[i].alias.c_str()) != 0 )) - continue; - + if (lower_case_table_names) + { + if (!tableName.empty() && (strcasecmp(tableName.c_str(), tn.table.c_str()) != 0 && + strcasecmp(tableName.c_str(), gwi.tbList[i].alias.c_str()) != 0 )) + continue; + } + else + { + if (!tableName.empty() && (strcmp(tableName.c_str(), tn.table.c_str()) != 0 && + strcmp(tableName.c_str(), gwi.tbList[i].alias.c_str()) != 0 )) + continue; + } + if (lower_case_table_names) + { + boost::algorithm::to_lower(tn.schema); + boost::algorithm::to_lower(tn.table); + } CalpontSystemCatalog::RIDList oidlist = gwi.csc->columnRIDs(tn, true); for (unsigned int j = 0; j < oidlist.size(); j++) @@ -2602,13 +2602,13 @@ void collectAllCols(gp_walk_info& gwi, Item_field* ifp) CalpontSystemCatalog::TableColName tcn = gwi.csc->colName(oidlist[j].objnum); CalpontSystemCatalog::ColType ct = gwi.csc->colType(oidlist[j].objnum); sc->columnName(tcn.column); - sc->tableName(tcn.table); - sc->schemaName(tcn.schema); + sc->tableName(tcn.table, lower_case_table_names); + sc->schemaName(tcn.schema, lower_case_table_names); sc->oid(oidlist[j].objnum); sc->alias(tcn.column); sc->resultType(ct); - sc->tableAlias(lower(gwi.tbList[i].alias)); - sc->viewName(lower(viewName)); + sc->tableAlias(gwi.tbList[i].alias, lower_case_table_names); + sc->viewName(viewName, lower_case_table_names); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); srcp.reset(sc); gwi.returnedCols.push_back(srcp); @@ -2887,6 +2887,15 @@ SimpleColumn* getSmallestColumn(boost::shared_ptr csc, TABLE* table, gp_walk_info& gwi) { + if (lower_case_table_names) + { + boost::algorithm::to_lower(tn.schema); + boost::algorithm::to_lower(tn.table); + boost::algorithm::to_lower(tan.schema); + boost::algorithm::to_lower(tan.table); + boost::algorithm::to_lower(tan.alias); + boost::algorithm::to_lower(tan.view); + } // derived table if (tan.schema.empty()) { @@ -2901,7 +2910,7 @@ SimpleColumn* getSmallestColumn(boost::shared_ptr csc, SimpleColumn* sc = new SimpleColumn(); sc->columnName(rc->alias()); sc->sequence(0); - sc->tableAlias(lower(tan.alias)); + sc->tableAlias(tan.alias); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); // @bug5634 derived table optimization. rc->incRefCount(); @@ -2919,9 +2928,8 @@ SimpleColumn* getSmallestColumn(boost::shared_ptr csc, { // 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.fisColumnStore, gwi.sessionid); - string alias(table->alias.ptr()); - sc->tableAlias(lower(alias)); + SimpleColumn* sc = new SimpleColumn(table->s->db.str, table->s->table_name.str, field->field_name.str, tan.fisColumnStore, gwi.sessionid, lower_case_table_names); + sc->tableAlias(table->alias.ptr(), lower_case_table_names); sc->isColumnStore(false); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); sc->resultType(fieldType_MysqlToIDB(field)); @@ -2950,8 +2958,8 @@ SimpleColumn* getSmallestColumn(boost::shared_ptr csc, tcn = csc->colName(oidlist[minWidthColOffset].objnum); SimpleColumn* sc = new SimpleColumn(tcn.schema, tcn.table, tcn.column, csc->sessionID()); - sc->tableAlias(lower(tan.alias)); - sc->viewName(lower(tan.view)); + sc->tableAlias(tan.alias); + sc->viewName(tan.view); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); sc->resultType(csc->colType(oidlist[minWidthColOffset].objnum)); sc->charsetNumber(3000); @@ -4499,15 +4507,15 @@ SimpleColumn* buildSimpleColumn(Item_field* ifp, gp_walk_info& gwi) if (isInformationSchema) { sc->schemaName("information_schema"); - sc->tableName(tbname); + sc->tableName(tbname, lower_case_table_names); } - sc->tableAlias(lower(tbname)); + sc->tableAlias(tbname, lower_case_table_names); // view name - sc->viewName(lower(getViewName(ifp->cached_table))); - + sc->viewName(getViewName(ifp->cached_table), lower_case_table_names); sc->alias(ifp->name.str); + sc->isColumnStore(columnStore); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); @@ -5231,7 +5239,7 @@ void gp_walk(const Item* item, void* arg) break; string aliasTableName(scp->tableAlias()); - scp->tableAlias(lower(aliasTableName)); + scp->tableAlias(aliasTableName); gwip->rcWorkStack.push(scp->clone()); boost::shared_ptr scsp(scp); gwip->scsp = scsp; @@ -6214,6 +6222,10 @@ int processFrom(bool &isUnion, } string viewName = getViewName(table_ptr); + if (lower_case_table_names) + { + boost::algorithm::to_lower(viewName); + } // @todo process from subquery if (table_ptr->derived) @@ -6221,7 +6233,11 @@ int processFrom(bool &isUnion, SELECT_LEX* select_cursor = table_ptr->derived->first_select(); FromSubQuery fromSub(gwi, select_cursor); string alias(table_ptr->alias.str); - fromSub.alias(lower(alias)); + if (lower_case_table_names) + { + boost::algorithm::to_lower(alias); + } + fromSub.alias(alias); CalpontSystemCatalog::TableAliasName tn = make_aliasview("", "", alias, viewName); // @bug 3852. check return execplan @@ -6244,7 +6260,7 @@ int processFrom(bool &isUnion, else if (table_ptr->view) { 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); + CalpontSystemCatalog::TableAliasName tn = make_aliastable(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str, true, lower_case_table_names); view->viewName(tn); gwi.viewList.push_back(view); view->transform(); @@ -6256,7 +6272,7 @@ int processFrom(bool &isUnion, // trigger system catalog cache if (columnStore) - gwi.csc->columnRIDs(make_table(table_ptr->db.str, table_ptr->table_name.str), true); + gwi.csc->columnRIDs(make_table(table_ptr->db.str, table_ptr->table_name.str, lower_case_table_names), true); string table_name = table_ptr->table_name.str; @@ -6264,9 +6280,9 @@ int processFrom(bool &isUnion, 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, columnStore); + CalpontSystemCatalog::TableAliasName tn = make_aliasview(table_ptr->db.str, table_name, table_ptr->alias.str, viewName, columnStore, lower_case_table_names); gwi.tbList.push_back(tn); - CalpontSystemCatalog::TableAliasName tan = make_aliastable(table_ptr->db.str, table_name, table_ptr->alias.str, columnStore); + CalpontSystemCatalog::TableAliasName tan = make_aliastable(table_ptr->db.str, table_name, table_ptr->alias.str, columnStore, lower_case_table_names); gwi.tableMap[tan] = make_pair(0, table_ptr); #ifdef DEBUG_WALK_COND cerr << tn << endl; @@ -7205,8 +7221,9 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, rc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); if (sub->get_select_lex()->get_table_list()) - rc->viewName(lower(getViewName(sub->get_select_lex()->get_table_list()))); - + { + rc->viewName(getViewName(sub->get_select_lex()->get_table_list()), lower_case_table_names); + } if (sub->name.length) rc->alias(sub->name.str); @@ -7968,7 +7985,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, sc1->columnName(sc->columnName()); sc1->tableName(sc->tableName()); sc1->tableAlias(sc->tableAlias()); - sc1->viewName(lower(sc->viewName())); + sc1->viewName(sc->viewName()); sc1->colPosition(0); sc1->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); minSc.reset(sc1); @@ -8056,7 +8073,11 @@ int cp_get_table_plan(THD* thd, SCSEP& csep, cal_table_info& ti) { SimpleColumn* sc = new SimpleColumn(table->s->db.str, table->s->table_name.str, field->field_name.str, sessionID); string alias(table->alias.c_ptr()); - sc->tableAlias(lower(alias)); + if (lower_case_table_names) + { + boost::algorithm::to_lower(alias); + } + sc->tableAlias(alias); sc->timeZone(gwi->thd->variables.time_zone->get_name()->ptr()); assert (sc); boost::shared_ptr spsc(sc); @@ -8117,7 +8138,7 @@ int cp_get_table_plan(THD* thd, SCSEP& csep, cal_table_info& ti) csep->returnedCols(gwi->returnedCols); csep->columnMap(gwi->columnMap); CalpontSelectExecutionPlan::TableList tblist; - tblist.push_back(make_aliastable(table->s->db.str, table->s->table_name.str, table->alias.c_ptr())); + tblist.push_back(make_aliastable(table->s->db.str, table->s->table_name.str, table->alias.c_ptr(), true, lower_case_table_names)); csep->tableList(tblist); // @bug 3321. Set max number of blocks in a dictionary file to be scanned for filtering @@ -8343,6 +8364,10 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro } string viewName = getViewName(table_ptr); + if (lower_case_table_names) + { + boost::algorithm::to_lower(viewName); + } // @todo process from subquery if (table_ptr->derived) @@ -8354,7 +8379,11 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // Use Pushdown handler for subquery processing FromSubQuery fromSub(gwi, select_cursor); string alias(table_ptr->alias.str); - fromSub.alias(lower(alias)); + if (lower_case_table_names) + { + boost::algorithm::to_lower(alias); + } + fromSub.alias(alias); CalpontSystemCatalog::TableAliasName tn = make_aliasview("", "", alias, viewName); // @bug 3852. check return execplan @@ -8377,7 +8406,7 @@ 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->first_select_lex(), &gwi); - CalpontSystemCatalog::TableAliasName tn = make_aliastable(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str); + CalpontSystemCatalog::TableAliasName tn = make_aliastable(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str, true, lower_case_table_names); view->viewName(tn); gwi.viewList.push_back(view); view->transform(); @@ -8389,7 +8418,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // trigger system catalog cache if (columnStore) - csc->columnRIDs(make_table(table_ptr->db.str, table_ptr->table_name.str), true); + csc->columnRIDs(make_table(table_ptr->db.str, table_ptr->table_name.str, lower_case_table_names), true); string table_name = table_ptr->table_name.str; @@ -8397,9 +8426,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, columnStore); + CalpontSystemCatalog::TableAliasName tn = make_aliasview(table_ptr->db.str, table_name, table_ptr->alias.str, viewName, columnStore, lower_case_table_names); gwi.tbList.push_back(tn); - CalpontSystemCatalog::TableAliasName tan = make_aliastable(table_ptr->db.str, table_name, table_ptr->alias.str, columnStore); + CalpontSystemCatalog::TableAliasName tan = make_aliastable(table_ptr->db.str, table_name, table_ptr->alias.str, columnStore, lower_case_table_names); gwi.tableMap[tan] = make_pair(0, table_ptr); #ifdef DEBUG_WALK_COND cerr << tn << endl; @@ -8959,8 +8988,9 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro rc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); if (sub->get_select_lex()->get_table_list()) - rc->viewName(lower(getViewName(sub->get_select_lex()->get_table_list()))); - + { + rc->viewName(getViewName(sub->get_select_lex()->get_table_list()), lower_case_table_names); + } if (sub->name.length) rc->alias(sub->name.str); @@ -9123,7 +9153,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro funcFieldVec[i]->print(&str, QT_ORDINARY); sc->alias(string(str.c_ptr())); //sc->tableAlias(funcFieldVec[i]->table_name); - sc->tableAlias(sc->tableAlias()); + sc->tableAlias(sc->alias()); SRCP srcp(sc); uint32_t j = 0; @@ -9920,7 +9950,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro sc1->columnName(sc->columnName()); sc1->tableName(sc->tableName()); sc1->tableAlias(sc->tableAlias()); - sc1->viewName(lower(sc->viewName())); + sc1->viewName(sc->viewName()); sc1->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); sc1->colPosition(0); minSc.reset(sc1); diff --git a/dbcon/mysql/ha_mcs_impl.cpp b/dbcon/mysql/ha_mcs_impl.cpp index f21694654..e3ca22a2f 100644 --- a/dbcon/mysql/ha_mcs_impl.cpp +++ b/dbcon/mysql/ha_mcs_impl.cpp @@ -965,8 +965,6 @@ vector getOnUpdateTimestampColumns(string& schema, string& tableName, in boost::shared_ptr csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); csc->identity(execplan::CalpontSystemCatalog::FE); CalpontSystemCatalog::TableName aTableName; - boost::algorithm::to_lower(schema); - boost::algorithm::to_lower(tableName); // select columnname from calpontsys.syscolumn // where schema = schema and tablename = tableName @@ -1304,11 +1302,18 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector& c else aliasName = item->table_name.str; + if (lower_case_table_names) + { + boost::algorithm::to_lower(aliasName); + boost::algorithm::to_lower(tableName); + boost::algorithm::to_lower(tmpTableName); + } + if (strcasecmp(tableName.c_str(), "") == 0) { tableName = tmpTableName; } - else if (strcasecmp(tableName.c_str(), tmpTableName.c_str()) != 0) + else if (strcmp(tableName.c_str(), tmpTableName.c_str()) != 0) { //@ Bug3326 error out for multi table update string emsg(IDBErrorInfo::instance()->errorMsg(ERR_UPDATE_NOT_SUPPORT_FEATURE)); @@ -1332,8 +1337,13 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector& c } } else + { schemaName = string(item->db_name.str); - + if (lower_case_table_names) + { + boost::algorithm::to_lower(schemaName); + } + } columnAssignmentPtr = new ColumnAssignment(item->name.str, "=", ""); if (item->field_type() == MYSQL_TYPE_TIMESTAMP || item->field_type() == MYSQL_TYPE_TIMESTAMP2) @@ -1567,6 +1577,11 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector& c aTableName.schema = first_table->table->s->db.str; aTableName.table = first_table->table->s->table_name.str; } + if (lower_case_table_names) + { + boost::algorithm::to_lower(aTableName.schema); + boost::algorithm::to_lower(aTableName.table); + } CalpontDMLPackage* pDMLPackage = 0; // dmlStmt += ";"; @@ -1604,6 +1619,12 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector& c schemaName = first_table->db.str; tableName = first_table->table_name.str; aliasName = first_table->alias.str; + if (lower_case_table_names) + { + boost::algorithm::to_lower(schemaName); + boost::algorithm::to_lower(tableName); + boost::algorithm::to_lower(aliasName); + } qualifiedTablName->fName = tableName; qualifiedTablName->fSchema = schemaName; pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(dmlStatement); @@ -1623,6 +1644,12 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector& c schemaName = first_table->table->s->db.str; tableName = first_table->table->s->table_name.str; aliasName = first_table->alias.str; + if (lower_case_table_names) + { + boost::algorithm::to_lower(schemaName); + boost::algorithm::to_lower(tableName); + boost::algorithm::to_lower(aliasName); + } qualifiedTablName->fName = tableName; qualifiedTablName->fSchema = schemaName; pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(dmlStatement); @@ -1634,6 +1661,12 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector& c schemaName = first_table->table->s->db.str; tableName = first_table->table->s->table_name.str; aliasName = first_table->alias.str; + if (lower_case_table_names) + { + boost::algorithm::to_lower(schemaName); + boost::algorithm::to_lower(tableName); + boost::algorithm::to_lower(aliasName); + } qualifiedTablName->fName = tableName; qualifiedTablName->fSchema = schemaName; pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(dmlStatement); @@ -1821,7 +1854,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector& c try { - colrids = csc->columnRIDs(deleteTableName); + colrids = csc->columnRIDs(deleteTableName, false, lower_case_table_names); } catch (IDBExcept& ie) { @@ -1916,7 +1949,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector& c CalpontSystemCatalog::ROPair roPair; try { - roPair = csc->tableRID( aTableName ); + roPair = csc->tableRID(aTableName); } catch (IDBExcept& ie) { @@ -2238,7 +2271,7 @@ int ha_mcs_impl_discover_existence(const char* schema, const char* name) try { - const CalpontSystemCatalog::OID oid = csc->lookupTableOID(make_table(schema, name)); + const CalpontSystemCatalog::OID oid = csc->lookupTableOID(make_table(schema, name, lower_case_table_names)); if (oid) return 1; @@ -2438,7 +2471,7 @@ int ha_mcs::impl_rnd_init(TABLE* table, const std::vector& condStack) ti.csep->sessionID(sessionID); if (thd->db.length) - ti.csep->schemaName(thd->db.str); + ti.csep->schemaName(thd->db.str, lower_case_table_names); ti.csep->traceFlags(ci->traceFlags); ti.msTablePtr = table; @@ -2629,7 +2662,7 @@ int ha_mcs::impl_rnd_init(TABLE* table, const std::vector& condStack) // 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); + CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str, lower_case_table_names), true); if (oidlist.size() != num_attr) { @@ -3185,7 +3218,7 @@ void ha_mcs_impl_start_bulk_insert(ha_rows rows, TABLE* table, bool is_cache_ins try { - colrids = csc->columnRIDs(tableName); + colrids = csc->columnRIDs(tableName, false, lower_case_table_names); } catch (IDBExcept& ie) { @@ -3596,7 +3629,7 @@ void ha_mcs_impl_start_bulk_insert(ha_rows rows, TABLE* table, bool is_cache_ins try { - CalpontSystemCatalog::ROPair roPair = csc->tableRID( tableName ); + CalpontSystemCatalog::ROPair roPair = csc->tableRID(tableName, lower_case_table_names); ci->tableOid = roPair.objnum; } catch (IDBExcept& ie) @@ -4336,7 +4369,7 @@ int ha_mcs_impl_group_by_init(mcs_handler_info *handler_info, TABLE* table) csep->sessionID(sessionID); if (group_hand->table_list->db.length) - csep->schemaName(group_hand->table_list->db.str); + csep->schemaName(group_hand->table_list->db.str, lower_case_table_names); csep->traceFlags(ci->traceFlags); @@ -5096,7 +5129,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) csep->sessionID(sessionID); if (thd->db.length) - csep->schemaName(thd->db.str); + csep->schemaName(thd->db.str, lower_case_table_names); csep->traceFlags(ci->traceFlags); diff --git a/dbcon/mysql/ha_mcs_partition.cpp b/dbcon/mysql/ha_mcs_partition.cpp index 1bd8b65ba..47dff51f1 100644 --- a/dbcon/mysql/ha_mcs_partition.cpp +++ b/dbcon/mysql/ha_mcs_partition.cpp @@ -450,8 +450,10 @@ void parsePartitionString(UDF_ARGS* args, string& errMsg, execplan::CalpontSystemCatalog::TableName tableName) { - //@Bug 4695 - algorithm::to_lower(tableName.schema); + if (lower_case_table_names) + { + boost::algorithm::to_lower(tableName.schema); + } if (tableName.schema == "calpontsys") { @@ -654,12 +656,17 @@ void partitionByValue_common(UDF_ARGS* args, // input column = (char*)(args->args[1]); } + if (lower_case_table_names) + { + boost::algorithm::to_lower(schema); + boost::algorithm::to_lower(table); + } + boost::algorithm::to_lower(column); + tableName.schema = schema; tableName.table = table; //@Bug 4695 - algorithm::to_lower(tableName.schema); - if (tableName.schema == "calpontsys") { errMsg = IDBErrorInfo::instance()->errorMsg(SYSTABLE_PARTITION); @@ -670,7 +677,7 @@ void partitionByValue_common(UDF_ARGS* args, // input { boost::shared_ptr csc = CalpontSystemCatalog::makeCalpontSystemCatalog(tid2sid(current_thd->thread_id)); csc->identity(execplan::CalpontSystemCatalog::FE); - CalpontSystemCatalog::TableColName tcn = make_tcn(schema, table, column); + CalpontSystemCatalog::TableColName tcn = make_tcn(schema, table, column, lower_case_table_names); csc->identity(CalpontSystemCatalog::FE); OID_t oid = csc->lookupOID(tcn); ct = csc->colType(oid); @@ -1029,10 +1036,16 @@ extern "C" table = (char*)(args->args[0]); column = (char*)(args->args[1]); } + if (lower_case_table_names) + { + boost::algorithm::to_lower(schema); + boost::algorithm::to_lower(table); + } + boost::algorithm::to_lower(column); boost::shared_ptr csc = CalpontSystemCatalog::makeCalpontSystemCatalog(tid2sid(current_thd->thread_id)); csc->identity(CalpontSystemCatalog::FE); - CalpontSystemCatalog::TableColName tcn = make_tcn(schema, table, column); + CalpontSystemCatalog::TableColName tcn = make_tcn(schema, table, column, lower_case_table_names); OID_t oid = csc->lookupOID(tcn); ct = csc->colType(oid); @@ -1735,9 +1748,16 @@ extern "C" column = (char*)(args->args[1]); } + if (lower_case_table_names) + { + boost::algorithm::to_lower(schema); + boost::algorithm::to_lower(table); + } + boost::algorithm::to_lower(column); + boost::shared_ptr csc = CalpontSystemCatalog::makeCalpontSystemCatalog(tid2sid(current_thd->thread_id)); csc->identity(CalpontSystemCatalog::FE); - CalpontSystemCatalog::TableColName tcn = make_tcn(schema, table, column); + CalpontSystemCatalog::TableColName tcn = make_tcn(schema, table, column, lower_case_table_names); OID_t oid = csc->lookupOID(tcn); ct = csc->colType(oid); diff --git a/dbcon/mysql/ha_view.cpp b/dbcon/mysql/ha_view.cpp index 2cba59b09..c804c5410 100644 --- a/dbcon/mysql/ha_view.cpp +++ b/dbcon/mysql/ha_view.cpp @@ -88,14 +88,21 @@ void View::transform() continue; string viewName = getViewName(table_ptr); + if (lower_case_table_names) + { + boost::algorithm::to_lower(viewName); + } if (table_ptr->derived) { SELECT_LEX* select_cursor = table_ptr->derived->first_select(); FromSubQuery* fromSub = new FromSubQuery(gwi, select_cursor); string alias(table_ptr->alias.str); - gwi.viewName = make_aliasview("", alias, table_ptr->belong_to_view->alias.str, ""); - algorithm::to_lower(alias); + if (lower_case_table_names) + { + boost::algorithm::to_lower(alias); + } + gwi.viewName = make_aliasview("", alias, table_ptr->belong_to_view->alias.str, "", true, lower_case_table_names); fromSub->alias(alias); gwi.derivedTbList.push_back(SCSEP(fromSub->transform())); // set alias to both table name and alias name of the derived table @@ -108,8 +115,8 @@ void View::transform() else if (table_ptr->view) { // 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); + CalpontSystemCatalog::TableAliasName tn = make_aliasview(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str, viewName, true, lower_case_table_names); + gwi.viewName = make_aliastable(table_ptr->db.str, table_ptr->table_name.str, viewName, true, lower_case_table_names); View* view = new View(*table_ptr->view->first_select_lex(), &gwi); view->viewName(gwi.viewName); gwi.viewList.push_back(view); @@ -122,9 +129,9 @@ void View::transform() // trigger system catalog cache if (columnStore) - csc->columnRIDs(make_table(table_ptr->db.str, table_ptr->table_name.str), true); + csc->columnRIDs(make_table(table_ptr->db.str, table_ptr->table_name.str, lower_case_table_names), true); - CalpontSystemCatalog::TableAliasName tn = make_aliasview(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str, viewName, columnStore); + CalpontSystemCatalog::TableAliasName tn = make_aliasview(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str, viewName, columnStore, lower_case_table_names); 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/idb_mysql.h b/dbcon/mysql/idb_mysql.h index b94cc2409..70bafeced 100644 --- a/dbcon/mysql/idb_mysql.h +++ b/dbcon/mysql/idb_mysql.h @@ -28,6 +28,9 @@ template bool isnan(T); #endif #endif +//#define INFINIDB_DEBUG +//#define DEBUG_WALK_COND + #define MYSQL_SERVER 1 //needed for definition of struct THD in mysql_priv.h #define USE_CALPONT_REGEX @@ -45,7 +48,7 @@ template bool isnan(T); #ifndef ENABLED_DEBUG_SYNC #define ENABLED_DEBUG_SYNC #endif -//#define INFINIDB_DEBUG + #define DBUG_ON 1 #undef DBUG_OFF #else @@ -73,6 +76,7 @@ template bool isnan(T); #include "derived_handler.h" #include "select_handler.h" #include "rpl_rli.h" +#include "my_dbug.h" // Now clean up the pollution as best we can... #undef min diff --git a/dbcon/mysql/is_columnstore_columns.cpp b/dbcon/mysql/is_columnstore_columns.cpp index 4bdb69b02..75a368cec 100644 --- a/dbcon/mysql/is_columnstore_columns.cpp +++ b/dbcon/mysql/is_columnstore_columns.cpp @@ -151,7 +151,7 @@ static int is_columnstore_columns_fill(THD* thd, TABLE_LIST* tables, COND* cond) // So simply ignore the dropped table. try { - column_rid_list = systemCatalogPtr->columnRIDs((*it).second, true); + column_rid_list = systemCatalogPtr->columnRIDs((*it).second, true, lower_case_table_names); } catch (IDBExcept& ex) { diff --git a/dbcon/mysql/is_columnstore_tables.cpp b/dbcon/mysql/is_columnstore_tables.cpp index 9734d7e52..4bc29837b 100644 --- a/dbcon/mysql/is_columnstore_tables.cpp +++ b/dbcon/mysql/is_columnstore_tables.cpp @@ -131,28 +131,35 @@ static int is_columnstore_tables_fill(THD* thd, TABLE_LIST* tables, COND* cond) } } - execplan::CalpontSystemCatalog::TableInfo tb_info = systemCatalogPtr->tableInfo((*it).second); - std::string create_date = dataconvert::DataConvert::dateToString((*it).second.create_date); - table->field[0]->store((*it).second.schema.c_str(), (*it).second.schema.length(), cs); - table->field[1]->store((*it).second.table.c_str(), (*it).second.table.length(), cs); - table->field[2]->store((*it).first); - table->field[3]->store(create_date.c_str(), create_date.length(), cs); - table->field[4]->store(tb_info.numOfCols); - - if (tb_info.tablewithautoincr) + try { - table->field[5]->set_notnull(); - table->field[5]->store(systemCatalogPtr->nextAutoIncrValue((*it).second)); + execplan::CalpontSystemCatalog::TableInfo tb_info = systemCatalogPtr->tableInfo((*it).second); + std::string create_date = dataconvert::DataConvert::dateToString((*it).second.create_date); + table->field[0]->store((*it).second.schema.c_str(), (*it).second.schema.length(), cs); + table->field[1]->store((*it).second.table.c_str(), (*it).second.table.length(), cs); + table->field[2]->store((*it).first); + table->field[3]->store(create_date.c_str(), create_date.length(), cs); + table->field[4]->store(tb_info.numOfCols); + + if (tb_info.tablewithautoincr) + { + table->field[5]->set_notnull(); + table->field[5]->store(systemCatalogPtr->nextAutoIncrValue((*it).second)); + } + else + { + table->field[5]->set_null(); + } + + table->field[5]->store(tb_info.tablewithautoincr); + + if (schema_table_store_record(thd, table)) + return 1; } - else + catch (std::runtime_error& e) { - table->field[5]->set_null(); + std::cerr << e.what() << std::endl; } - - table->field[5]->store(tb_info.tablewithautoincr); - - if (schema_table_store_record(thd, table)) - return 1; } return 0; diff --git a/utils/funcexp/func_greatest.cpp b/utils/funcexp/func_greatest.cpp index 2c58ec481..b8bbef60f 100644 --- a/utils/funcexp/func_greatest.cpp +++ b/utils/funcexp/func_greatest.cpp @@ -42,16 +42,6 @@ using namespace funcexp; #include "collation.h" -class to_lower -{ -public: - char operator() (char c) const // notice the return type - { - return tolower(c); - } -}; - - namespace funcexp { diff --git a/utils/funcexp/func_lcase.cpp b/utils/funcexp/func_lcase.cpp index 073c92f40..64296d156 100644 --- a/utils/funcexp/func_lcase.cpp +++ b/utils/funcexp/func_lcase.cpp @@ -37,15 +37,6 @@ using namespace joblist; #include "collation.h" -class to_lower -{ -public: - char operator() (char c) const // notice the return type - { - return tolower(c); - } -}; - namespace funcexp { diff --git a/utils/funcexp/func_least.cpp b/utils/funcexp/func_least.cpp index f8256ac60..51add0c17 100644 --- a/utils/funcexp/func_least.cpp +++ b/utils/funcexp/func_least.cpp @@ -42,17 +42,6 @@ using namespace funcexp; #include "collation.h" -class to_lower -{ -public: - char operator() (char c) const // notice the return type - { - return tolower(c); - } -}; - - - namespace funcexp { diff --git a/utils/funcexp/func_repeat.cpp b/utils/funcexp/func_repeat.cpp index 2a14bbdc8..98c3dbd3d 100644 --- a/utils/funcexp/func_repeat.cpp +++ b/utils/funcexp/func_repeat.cpp @@ -36,16 +36,6 @@ using namespace rowgroup; #include "joblisttypes.h" using namespace joblist; -class to_lower -{ -public: - char operator() (char c) const // notice the return type - { - return tolower(c); - } -}; - - namespace funcexp { diff --git a/utils/funcexp/func_strcmp.cpp b/utils/funcexp/func_strcmp.cpp index 68584f705..50d031279 100644 --- a/utils/funcexp/func_strcmp.cpp +++ b/utils/funcexp/func_strcmp.cpp @@ -45,16 +45,6 @@ using namespace funcexp; struct charset_info_st; typedef const struct charset_info_st CHARSET_INFO; -class to_lower -{ -public: - char operator() (char c) const // notice the return type - { - return tolower(c); - } -}; - - namespace funcexp { diff --git a/writeengine/server/we_ddlcommandproc.cpp b/writeengine/server/we_ddlcommandproc.cpp index 58e2ba0a3..1526bdf8e 100644 --- a/writeengine/server/we_ddlcommandproc.cpp +++ b/writeengine/server/we_ddlcommandproc.cpp @@ -182,14 +182,12 @@ uint8_t WE_DDLCommandProc::writeSystable(ByteStream& bs, std::string& err) if (TABLENAME_COL == column.tableColName.column) { std::string tablename = tableDef.fQualifiedName->fName; - boost::to_lower(tablename); colTuple.data = tablename; tmpStr = tablename; } else if (SCHEMA_COL == column.tableColName.column) { std::string schema = tableDef.fQualifiedName->fSchema; - boost::to_lower(schema); colTuple.data = schema; tmpStr = schema; } @@ -519,13 +517,11 @@ uint8_t WE_DDLCommandProc::writeCreateSyscolumn(ByteStream& bs, std::string& err if (SCHEMA_COL == column.tableColName.column) { - boost::to_lower(qualifiedName.fSchema); colTuple.data = qualifiedName.fSchema; tmpStr = qualifiedName.fSchema; } else if (TABLENAME_COL == column.tableColName.column) { - boost::to_lower(qualifiedName.fName); colTuple.data = qualifiedName.fName; tmpStr = qualifiedName.fName; } @@ -916,13 +912,11 @@ uint8_t WE_DDLCommandProc::writeSyscolumn(ByteStream& bs, std::string& err) if (SCHEMA_COL == column.tableColName.column) { - boost::to_lower(schema); colTuple.data = schema; tmpStr = schema; } else if (TABLENAME_COL == column.tableColName.column) { - boost::to_lower(tablename); colTuple.data = tablename; tmpStr = tablename; }