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

Merge pull request #1459 from dhall-MariaDB/MCOL-4144-dev

MCOL-4144-dev Enable lower_case_table_names
This commit is contained in:
Gagan Goel
2020-09-24 19:10:22 -04:00
committed by GitHub
32 changed files with 468 additions and 412 deletions

View File

@ -194,25 +194,21 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
while ( sysCons_iterator != sysConsColumns.end() ) while ( sysCons_iterator != sysConsColumns.end() )
{ {
column = *sysCons_iterator; column = *sysCons_iterator;
boost::algorithm::to_lower(column.tableColName.column);
isNull = false; isNull = false;
if (CONSTRAINTNAME_COL == column.tableColName.column) if (CONSTRAINTNAME_COL == column.tableColName.column)
{ {
idxData = createIndexStmt.fIndexName->fName; idxData = createIndexStmt.fIndexName->fName;
boost::algorithm::to_lower(idxData);
colTuple.data = idxData; colTuple.data = idxData;
} }
else if (SCHEMA_COL == column.tableColName.column) else if (SCHEMA_COL == column.tableColName.column)
{ {
idxData = (createIndexStmt.fTableName)->fSchema; idxData = (createIndexStmt.fTableName)->fSchema;
boost::algorithm::to_lower(idxData);
colTuple.data = idxData; colTuple.data = idxData;
} }
else if (TABLENAME_COL == column.tableColName.column) else if (TABLENAME_COL == column.tableColName.column)
{ {
idxData = (createIndexStmt.fTableName)->fName; idxData = (createIndexStmt.fTableName)->fName;
boost::algorithm::to_lower(idxData);
colTuple.data = idxData; colTuple.data = idxData;
} }
else if (CONSTRAINTTYPE_COL == column.tableColName.column) else if (CONSTRAINTTYPE_COL == column.tableColName.column)
@ -235,7 +231,6 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
else if (INDEXNAME_COL == column.tableColName.column) else if (INDEXNAME_COL == column.tableColName.column)
{ {
idxData = createIndexStmt.fIndexName->fName; idxData = createIndexStmt.fIndexName->fName;
boost::algorithm::to_lower(idxData);
colTuple.data = idxData; colTuple.data = idxData;
} }
else else
@ -315,33 +310,28 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
while ( sysConsCol_iterator != sysConsColColumns.end() ) while ( sysConsCol_iterator != sysConsColColumns.end() )
{ {
column = *sysConsCol_iterator; column = *sysConsCol_iterator;
boost::algorithm::to_lower(column.tableColName.column);
isNull = false; isNull = false;
if (SCHEMA_COL == column.tableColName.column) if (SCHEMA_COL == column.tableColName.column)
{ {
colData = (createIndexStmt.fTableName)->fSchema; colData = (createIndexStmt.fTableName)->fSchema;
boost::algorithm::to_lower(colData);
colTupleCol.data = colData; colTupleCol.data = colData;
} }
else if (TABLENAME_COL == column.tableColName.column) else if (TABLENAME_COL == column.tableColName.column)
{ {
colData = (createIndexStmt.fTableName)->fName; colData = (createIndexStmt.fTableName)->fName;
boost::algorithm::to_lower(colData);
colTupleCol.data = colData; colTupleCol.data = colData;
} }
else if (COLNAME_COL == column.tableColName.column) else if (COLNAME_COL == column.tableColName.column)
{ {
colData = createIndexStmt.fColumnNames[0]; colData = createIndexStmt.fColumnNames[0];
boost::algorithm::to_lower(colData);
colTupleCol.data = colData; colTupleCol.data = colData;
} }
else if (CONSTRAINTNAME_COL == column.tableColName.column) else if (CONSTRAINTNAME_COL == column.tableColName.column)
{ {
colData = createIndexStmt.fIndexName->fName; colData = createIndexStmt.fIndexName->fName;
boost::algorithm::to_lower(colData);
colTupleCol.data = colData; colTupleCol.data = colData;
} }
else else

View File

@ -76,7 +76,6 @@ CreateTableProcessor::DDLResult CreateTableProcessor::processPackage(
DETAIL_INFO(createTableStmt); DETAIL_INFO(createTableStmt);
ddlpackage::TableDef& tableDef = *createTableStmt.fTableDef; ddlpackage::TableDef& tableDef = *createTableStmt.fTableDef;
//If schema = CALPONTSYS, do not create table //If schema = CALPONTSYS, do not create table
boost::algorithm::to_lower(tableDef.fQualifiedName->fSchema);
if (tableDef.fQualifiedName->fSchema == CALPONT_SCHEMA) if (tableDef.fQualifiedName->fSchema == CALPONT_SCHEMA)
{ {

View File

@ -28,20 +28,6 @@
using namespace std; 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 namespace execplan
{ {

View File

@ -37,6 +37,7 @@
#include "expressionparser.h" #include "expressionparser.h"
#include "calpontsystemcatalog.h" #include "calpontsystemcatalog.h"
#include "brmtypes.h" #include "brmtypes.h"
#include <boost/algorithm/string/case_conv.hpp>
#ifndef __GNUC__ #ifndef __GNUC__
# ifndef __attribute__ # ifndef __attribute__
@ -293,9 +294,11 @@ public:
{ {
return fTableAlias; return fTableAlias;
} }
void tableAlias (const std::string& tableAlias) void tableAlias (const std::string& tableAlias, int lower_case_table_names)
{ {
fTableAlias = tableAlias; fTableAlias = tableAlias;
if (lower_case_table_names)
boost::algorithm::to_lower(fTableAlias);
} }
/** /**
@ -424,18 +427,22 @@ public:
{ {
return fSchemaName; return fSchemaName;
} }
inline void schemaName(const std::string& schemaName) inline void schemaName(const std::string& schemaName, int lower_case_table_names)
{ {
fSchemaName = schemaName; fSchemaName = schemaName;
if (lower_case_table_names)
boost::algorithm::to_lower(fSchemaName);
} }
inline std::string& tableName() inline std::string& tableName()
{ {
return fTableName; return fTableName;
} }
inline void tableName(const std::string& tableName) inline void tableName(const std::string& tableName, int lower_case_table_names)
{ {
fTableName = tableName; fTableName = tableName;
if (lower_case_table_names)
boost::algorithm::to_lower(fTableName);
} }
inline void traceOn(bool traceOn) __attribute__((deprecated)) inline void traceOn(bool traceOn) __attribute__((deprecated))
@ -539,16 +546,23 @@ public:
return fSubType; return fSubType;
} }
void derivedTbAlias(const std::string derivedTbAlias) void derivedTbAlias(const std::string derivedTbAlias, int lower_case_table_names=0)
{ {
fDerivedTbAlias = derivedTbAlias; fDerivedTbAlias = derivedTbAlias;
if (lower_case_table_names)
boost::algorithm::to_lower(fDerivedTbAlias);
} }
const std::string derivedTbAlias() const const std::string derivedTbAlias() const
{ {
return fDerivedTbAlias; 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; } const std::string derivedTbView() const { return fDerivedTbView; }

View File

@ -249,30 +249,36 @@ CalpontSystemCatalog::NJLSysDataList::~NJLSysDataList()
delete *it; 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; CalpontSystemCatalog::TableColName tcns;
tcns.schema = s; tcns.schema = s;
tcns.table = t; tcns.table = t;
tcns.column = c; tcns.column = c;
transform (tcns.schema.begin(), tcns.schema.end(), tcns.schema.begin(), to_lower()); if (lower_case_table_names)
transform (tcns.table.begin(), tcns.table.end(), tcns.table.begin(), to_lower()); {
transform (tcns.column.begin(), tcns.column.end(), tcns.column.begin(), to_lower()); boost::algorithm::to_lower(tcns.schema);
boost::algorithm::to_lower(tcns.table);
}
boost::algorithm::to_lower(tcns.column);
return tcns; 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; CalpontSystemCatalog::TableName tn;
tn.schema = s; tn.schema = s;
tn.table = t; tn.table = t;
transform (tn.schema.begin(), tn.schema.end(), tn.schema.begin(), to_lower()); if (lower_case_table_names)
transform (tn.table.begin(), tn.table.end(), tn.table.begin(), to_lower()); {
boost::algorithm::to_lower(tn.schema);
boost::algorithm::to_lower(tn.table);
}
return tn; 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; CalpontSystemCatalog::TableAliasName tn;
tn.schema = s; tn.schema = s;
@ -280,13 +286,16 @@ const CalpontSystemCatalog::TableAliasName make_aliastable(const string& s, cons
tn.alias = a; tn.alias = a;
tn.view = ""; tn.view = "";
tn.fisColumnStore = isColumnStore; tn.fisColumnStore = isColumnStore;
transform (tn.schema.begin(), tn.schema.end(), tn.schema.begin(), to_lower()); if (lower_case_table_names)
transform (tn.table.begin(), tn.table.end(), tn.table.begin(), to_lower()); {
transform (tn.alias.begin(), tn.alias.end(), tn.alias.begin(), to_lower()); boost::algorithm::to_lower(tn.schema);
boost::algorithm::to_lower(tn.table);
boost::algorithm::to_lower(tn.alias);
}
return tn; 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; CalpontSystemCatalog::TableAliasName tn;
tn.schema = s; tn.schema = s;
@ -294,10 +303,13 @@ const CalpontSystemCatalog::TableAliasName make_aliasview(const string& s, const
tn.alias = a; tn.alias = a;
tn.view = v; tn.view = v;
tn.fisColumnStore = isColumnStore; tn.fisColumnStore = isColumnStore;
transform (tn.schema.begin(), tn.schema.end(), tn.schema.begin(), to_lower()); if (lower_case_table_names)
transform (tn.table.begin(), tn.table.end(), tn.table.begin(), to_lower()); {
transform (tn.alias.begin(), tn.alias.end(), tn.alias.begin(), to_lower()); boost::algorithm::to_lower(tn.schema);
transform (tn.view.begin(), tn.view.end(), tn.view.begin(), to_lower()); boost::algorithm::to_lower(tn.table);
boost::algorithm::to_lower(tn.alias);
boost::algorithm::to_lower(tn.view);
}
return tn; return tn;
} }
@ -418,13 +430,16 @@ CalpontSystemCatalog::CatalogMap CalpontSystemCatalog::fCatalogMap;
/*static*/ /*static*/
uint32_t CalpontSystemCatalog::fModuleID = numeric_limits<uint32_t>::max(); uint32_t CalpontSystemCatalog::fModuleID = numeric_limits<uint32_t>::max();
CalpontSystemCatalog::OID CalpontSystemCatalog::lookupTableOID(const TableName& tablename) CalpontSystemCatalog::OID CalpontSystemCatalog::lookupTableOID(const TableName& tablename, int lower_case_table_names)
{ {
TableName aTableName; TableName aTableName;
aTableName.schema = tablename.schema; aTableName.schema = tablename.schema;
aTableName.table = tablename.table; aTableName.table = tablename.table;
transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); if (lower_case_table_names)
transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); {
boost::algorithm::to_lower(aTableName.schema);
boost::algorithm::to_lower(aTableName.table);
}
if (aTableName.schema.compare(CALPONT_SCHEMA) != 0) if (aTableName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter tableInfo: " << tablename.schema << "|" << tablename.table << endl; DEBUG << "Enter tableInfo: " << tablename.schema << "|" << tablename.table << endl;
@ -511,7 +526,7 @@ CalpontSystemCatalog::OID CalpontSystemCatalog::lookupTableOID(const TableName&
return (OID)0; 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) if (tableColName.schema.length() == 0 || tableColName.table.length() == 0 || tableColName.column.length() == 0)
return -1; return -1;
@ -520,9 +535,12 @@ CalpontSystemCatalog::OID CalpontSystemCatalog::lookupOID(const TableColName& ta
aTableColName.schema = tableColName.schema; aTableColName.schema = tableColName.schema;
aTableColName.table = tableColName.table; aTableColName.table = tableColName.table;
aTableColName.column = tableColName.column; aTableColName.column = tableColName.column;
transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); if (lower_case_table_names)
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.schema);
boost::algorithm::to_lower(aTableColName.table);
}
boost::algorithm::to_lower(aTableColName.column);
if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter lookupOID: " << tableColName.schema << "|" << tableColName.table DEBUG << "Enter lookupOID: " << tableColName.schema << "|" << tableColName.table
@ -1583,16 +1601,19 @@ const CalpontSystemCatalog::TableColName CalpontSystemCatalog::dictColName(const
return tableColName; 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; TableInfo tbInfo;
if (lower_case_table_names)
{
boost::algorithm::to_lower(aTableName.schema);
boost::algorithm::to_lower(aTableName.table);
}
try try
{ {
tbInfo = tableInfo (aTableName); tbInfo = tableInfo(aTableName);
} }
catch (runtime_error& /*ex*/) 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; TableInfo tbInfo;
if (lower_case_table_names)
{
boost::algorithm::to_lower(aTableName.schema);
boost::algorithm::to_lower(aTableName.table);
}
try try
{ {
tbInfo = tableInfo (aTableName); tbInfo = tableInfo (aTableName);
@ -2018,8 +2042,6 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::indexRIDs(const TableN
TableColName aTableName; TableColName aTableName;
aTableName.schema = tableName.schema; aTableName.schema = tableName.schema;
aTableName.table = tableName.table; 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) if (aTableName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter constraintRIDs: " << tableName.schema << "|" << tableName.table << endl; DEBUG << "Enter constraintRIDs: " << tableName.schema << "|" << tableName.table << endl;
@ -2097,8 +2119,6 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::indexColRIDs(const Tab
TableName aTableColName; TableName aTableColName;
aTableColName.schema = tableName.schema; aTableColName.schema = tableName.schema;
aTableColName.table = tableName.table; 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) if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter indexColRIDs: " << tableName.schema << "|" DEBUG << "Enter indexColRIDs: " << tableName.schema << "|"
@ -2175,9 +2195,6 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::indexColRIDs(const Ind
aIndexName.schema = indexName.schema; aIndexName.schema = indexName.schema;
aIndexName.table = indexName.table; aIndexName.table = indexName.table;
aIndexName.index = indexName.index; 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) if (aIndexName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter indexColRIDs: " << aIndexName.schema << "|" DEBUG << "Enter indexColRIDs: " << aIndexName.schema << "|"
@ -2249,8 +2266,6 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::constraintRIDs(const T
TableColName aTableName; TableColName aTableName;
aTableName.schema = tableName.schema; aTableName.schema = tableName.schema;
aTableName.table = tableName.table; 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) if (aTableName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter constraintRIDs: " << tableName.schema << "|" << tableName.table << endl; DEBUG << "Enter constraintRIDs: " << tableName.schema << "|" << tableName.table << endl;
@ -2325,9 +2340,7 @@ const CalpontSystemCatalog::IndexNameList CalpontSystemCatalog::colValueSysconst
aTableColName.schema = tableColName.schema; aTableColName.schema = tableColName.schema;
aTableColName.table = tableColName.table; aTableColName.table = tableColName.table;
aTableColName.column = tableColName.column; aTableColName.column = tableColName.column;
transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); boost::algorithm::to_lower(aTableColName.column);
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 BOOST_VERSION < 104000 #if BOOST_VERSION < 104000
boost::mutex::scoped_lock lk1(fColIndexListmapLock, false); boost::mutex::scoped_lock lk1(fColIndexListmapLock, false);
@ -2435,7 +2448,6 @@ const CalpontSystemCatalog::RID CalpontSystemCatalog::constraintRID(const std::s
*/ */
RID rid = std::numeric_limits<RID>::max(); RID rid = std::numeric_limits<RID>::max();
string aConstraintName = constraintName; string aConstraintName = constraintName;
transform( aConstraintName.begin(), aConstraintName.end(), aConstraintName.begin(), to_lower() );
CalpontSelectExecutionPlan csep; CalpontSelectExecutionPlan csep;
CalpontSelectExecutionPlan::ReturnedColumnList returnedColumnList; CalpontSelectExecutionPlan::ReturnedColumnList returnedColumnList;
@ -2489,7 +2501,7 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::constraintColRID(const
*/ */
RIDList ridlist; RIDList ridlist;
string aConstraintName = constraintName; string aConstraintName = constraintName;
transform( aConstraintName.begin(), aConstraintName.end(), aConstraintName.begin(), to_lower() ); boost::algorithm::to_lower(aConstraintName);
CalpontSelectExecutionPlan csep; CalpontSelectExecutionPlan csep;
CalpontSelectExecutionPlan::ReturnedColumnList returnedColumnList; CalpontSelectExecutionPlan::ReturnedColumnList returnedColumnList;
@ -2550,9 +2562,7 @@ const std::string CalpontSystemCatalog::colValueSysconstraintCol (const TableCol
aTableColName.schema = tableColName.schema; aTableColName.schema = tableColName.schema;
aTableColName.table = tableColName.table; aTableColName.table = tableColName.table;
aTableColName.column = tableColName.column; aTableColName.column = tableColName.column;
transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); boost::algorithm::to_lower(aTableColName.column);
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 (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter colValueSysconstraintCol: " << tableColName.schema << "|" DEBUG << "Enter colValueSysconstraintCol: " << tableColName.schema << "|"
@ -2631,8 +2641,6 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::constraintColRIDs(cons
TableColName aTableColName; TableColName aTableColName;
aTableColName.schema = tableName.schema; aTableColName.schema = tableName.schema;
aTableColName.table = tableName.table; 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) if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter constraintColRIDs: " << tableName.schema << "|" DEBUG << "Enter constraintColRIDs: " << tableName.schema << "|"
@ -2709,9 +2717,7 @@ const CalpontSystemCatalog::RID CalpontSystemCatalog::constraintColRID(const Tab
aTableColName.schema = tableColName.schema; aTableColName.schema = tableColName.schema;
aTableColName.table = tableColName.table; aTableColName.table = tableColName.table;
aTableColName.column = tableColName.column; aTableColName.column = tableColName.column;
transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); boost::algorithm::to_lower(aTableColName.column);
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 (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter constraintColRID: " << tableColName.schema << "|" DEBUG << "Enter constraintColRID: " << tableColName.schema << "|"
@ -2783,11 +2789,14 @@ const CalpontSystemCatalog::RID CalpontSystemCatalog::constraintColRID(const Tab
} }
#endif #endif
const vector< pair<CalpontSystemCatalog::OID, CalpontSystemCatalog::TableName> > CalpontSystemCatalog::getTables (const std::string schema) const vector< pair<CalpontSystemCatalog::OID, CalpontSystemCatalog::TableName> > CalpontSystemCatalog::getTables(const std::string schema, int lower_case_table_names)
{ {
string schemaname = schema; string schemaname = schema;
if (lower_case_table_names)
{
boost::algorithm::to_lower(schemaname);
}
vector < pair<OID, TableName> > tables; vector < pair<OID, TableName> > tables;
transform( schemaname.begin(), schemaname.end(), schemaname.begin(), to_lower() );
if (schemaname == CALPONT_SCHEMA) if (schemaname == CALPONT_SCHEMA)
{ {
@ -2936,16 +2945,19 @@ int CalpontSystemCatalog::getTableCount ()
} }
/* SQL statement: select objectid from syscolumn where schema=tableColName.schema and /* SQL statement: select objectid from syscolumn where schema=tableColName.schema and
* tablename=tableColName.table and columnname=tableColName.column;*/ * 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; ROPair rp;
TableColName aTableColName; TableColName aTableColName;
aTableColName.schema = tableColName.schema; aTableColName.schema = tableColName.schema;
aTableColName.table = tableColName.table; aTableColName.table = tableColName.table;
aTableColName.column = tableColName.column; aTableColName.column = tableColName.column;
transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); if (lower_case_table_names)
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.schema);
boost::algorithm::to_lower(aTableColName.table);
}
boost::algorithm::to_lower(aTableColName.column);
if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter columnRID: " << tableColName.schema << "|" << tableColName.table 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); 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()) if (aTableName.schema.empty() || aTableName.table.empty())
throw runtime_error("ColumnRIDs: Invalid table name"); 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; TableName aTableName;
aTableName.schema = tableName.schema; aTableName.schema = tableName.schema;
aTableName.table = tableName.table; aTableName.table = tableName.table;
transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); if (lower_case_table_names)
transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); {
boost::algorithm::to_lower(aTableName.schema);
boost::algorithm::to_lower(aTableName.table);
}
if (aTableName.schema.compare(CALPONT_SCHEMA) != 0) if (aTableName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter tableRID: " << tableName.schema << "|" << tableName.table << endl; DEBUG << "Enter tableRID: " << tableName.schema << "|" << tableName.table << endl;
@ -3642,8 +3661,6 @@ const CalpontSystemCatalog::IndexNameList CalpontSystemCatalog::indexNames(const
TableName aTableName; TableName aTableName;
aTableName.schema = tableName.schema; aTableName.schema = tableName.schema;
aTableName.table = tableName.table; 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 /* SQL statement: select indexname from sysindex where schema=indexName.schema and
* tablename=indexName.table and indexname=indexName.index; * tablename=indexName.table and indexname=indexName.index;
@ -3748,9 +3765,7 @@ const CalpontSystemCatalog::TableColNameList CalpontSystemCatalog::indexColNames
aIndexName.schema = indexName.schema; aIndexName.schema = indexName.schema;
aIndexName.table = indexName.table; aIndexName.table = indexName.table;
aIndexName.index = indexName.index; aIndexName.index = indexName.index;
transform( aIndexName.schema.begin(), aIndexName.schema.end(), aIndexName.schema.begin(), to_lower() ); boost::algorithm::to_lower(aIndexName.index);
transform( aIndexName.table.begin(), aIndexName.table.end(), aIndexName.table.begin(), to_lower() );
transform( aIndexName.index.begin(), aIndexName.index.end(), aIndexName.index.begin(), to_lower() );
/* SQL statement: select columnname, columnposition from sysindexcol where schema=indexname.schema and /* SQL statement: select columnname, columnposition from sysindexcol where schema=indexname.schema and
* tablename=indexName.table and indexname=indexName.index; * tablename=indexName.table and indexname=indexName.index;
@ -3858,7 +3873,7 @@ const CalpontSystemCatalog::TableColNameList CalpontSystemCatalog::constraintCol
std::string aConstraintName( constraintName ); 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 /* 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.schema = indexName.schema;
aIndexName.table = indexName.table; aIndexName.table = indexName.table;
aIndexName.index = indexName.index; aIndexName.index = indexName.index;
transform( aIndexName.schema.begin(), aIndexName.schema.end(), aIndexName.schema.begin(), to_lower() ); boost::algorithm::to_lower(aIndexName.index);
transform( aIndexName.table.begin(), aIndexName.table.end(), aIndexName.table.begin(), to_lower() );
transform( aIndexName.index.begin(), aIndexName.index.end(), aIndexName.index.begin(), to_lower() );
/* SQL statement: select indexname from sysindex where schema=indexName.schema and indexname=indexName.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 #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; DEBUG << "Enter colNumbers: " << tableName.schema << "|" << tableName.table << endl;
TableInfo ti = tableInfo(tableName); TableInfo ti = tableInfo(tableName, lower_case_table_names);
return ti.numOfCols; return ti.numOfCols;
} }
@ -4037,9 +4050,7 @@ const std::string CalpontSystemCatalog::colValueSysindex (const TableColName& ta
aTableColName.schema = tableColName.schema; aTableColName.schema = tableColName.schema;
aTableColName.table = tableColName.table; aTableColName.table = tableColName.table;
aTableColName.column = tableColName.column; aTableColName.column = tableColName.column;
transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); boost::algorithm::to_lower(aTableColName.column);
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 (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter colValueSysindex: " << tableColName.schema << "|" DEBUG << "Enter colValueSysindex: " << tableColName.schema << "|"
@ -4131,9 +4142,7 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::indexColRID(const Inde
aIndexName.schema = indexName.schema; aIndexName.schema = indexName.schema;
aIndexName.table = indexName.table; aIndexName.table = indexName.table;
aIndexName.index = indexName.index; aIndexName.index = indexName.index;
transform( aIndexName.schema.begin(), aIndexName.schema.end(), aIndexName.schema.begin(), to_lower() ); boost::algorithm::to_lower(aIndexName.index);
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) if (aIndexName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter indexColRID: " << aIndexName.schema << "|" DEBUG << "Enter indexColRID: " << aIndexName.schema << "|"
@ -4211,9 +4220,7 @@ const CalpontSystemCatalog::ROPair CalpontSystemCatalog::indexColRID(const Table
aTableColName.schema = tableColName.schema; aTableColName.schema = tableColName.schema;
aTableColName.table = tableColName.table; aTableColName.table = tableColName.table;
aTableColName.column = tableColName.column; aTableColName.column = tableColName.column;
transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); boost::algorithm::to_lower(aTableColName.column);
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 (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter indexColRID: " << tableColName.schema << "|" DEBUG << "Enter indexColRID: " << tableColName.schema << "|"
@ -4295,9 +4302,7 @@ const CalpontSystemCatalog::IndexNameList CalpontSystemCatalog::colValueSysindex
aTableColName.schema = tableColName.schema; aTableColName.schema = tableColName.schema;
aTableColName.table = tableColName.table; aTableColName.table = tableColName.table;
aTableColName.column = tableColName.column; aTableColName.column = tableColName.column;
transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); boost::algorithm::to_lower(aTableColName.column);
transform( aTableColName.table.begin(), aTableColName.table.end(), aTableColName.table.begin(), to_lower() );
transform( aTableColName.column.begin(), aTableColName.column.end(), aTableColName.column.begin(), to_lower() );
return indexNameList; //so colxml can run when indexes are not made 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; //select tablename from sysindex where indexname = indexName and schema = schema;
std::string aIndexName( indexName ); std::string aIndexName( indexName );
std::string aSchema ( schema); std::string aSchema ( schema);
transform( aIndexName.begin(), aIndexName.end(), aIndexName.begin(), to_lower() ); boost::algorithm::to_lower(aIndexName);
transform( aSchema.begin(), aSchema.end(), aSchema.begin(), to_lower() );
tablename.schema = aSchema; tablename.schema = aSchema;
CalpontSelectExecutionPlan csep; CalpontSelectExecutionPlan csep;
@ -4449,9 +4453,7 @@ const CalpontSystemCatalog::IndexOID CalpontSystemCatalog::lookupIndexNbr(const
aIndexName.schema = indexName.schema; aIndexName.schema = indexName.schema;
aIndexName.table = indexName.table; aIndexName.table = indexName.table;
aIndexName.index = indexName.index; aIndexName.index = indexName.index;
transform( aIndexName.schema.begin(), aIndexName.schema.end(), aIndexName.schema.begin(), to_lower() ); boost::algorithm::to_lower(aIndexName.index);
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) if (aIndexName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter lookupIndexNbr: " << indexName.schema << "|" << indexName.table DEBUG << "Enter lookupIndexNbr: " << indexName.schema << "|" << indexName.table
@ -4562,9 +4564,7 @@ const CalpontSystemCatalog::IndexOID CalpontSystemCatalog::lookupIndexNbr(const
aTableColName.schema = tableColName.schema; aTableColName.schema = tableColName.schema;
aTableColName.table = tableColName.table; aTableColName.table = tableColName.table;
aTableColName.column = tableColName.column; aTableColName.column = tableColName.column;
transform( aTableColName.schema.begin(), aTableColName.schema.end(), aTableColName.schema.begin(), to_lower() ); boost::algorithm::to_lower(aTableColName.column);
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 (aTableColName.schema.compare(CALPONT_SCHEMA) != 0) if (aTableColName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter lookupIndexNbr: " << tableColName.schema << "|" << tableColName.table DEBUG << "Enter lookupIndexNbr: " << tableColName.schema << "|" << tableColName.table
@ -4655,8 +4655,6 @@ const CalpontSystemCatalog::IndexOIDList CalpontSystemCatalog::indexOIDs( const
aTableName.schema = tableName.schema; aTableName.schema = tableName.schema;
aTableName.table = tableName.table; 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) if (aTableName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter indexOIDs: " << tableName.schema << "|" << tableName.table << endl; DEBUG << "Enter indexOIDs: " << tableName.schema << "|" << tableName.table << endl;
@ -4756,7 +4754,7 @@ const CalpontSystemCatalog::IndexOIDList CalpontSystemCatalog::indexOIDs( const
} }
#endif #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 /* SQL statement: select dictobjectid, listobjectid, treeobjectid from syscolumn where
* schema=tableName.schema and table=tableName.table;*/ * schema=tableName.schema and table=tableName.table;*/
@ -4766,8 +4764,11 @@ const CalpontSystemCatalog::DictOIDList CalpontSystemCatalog::dictOIDs( const Ta
aTableName.schema = tableName.schema; aTableName.schema = tableName.schema;
aTableName.table = tableName.table; aTableName.table = tableName.table;
transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); if (lower_case_table_names)
transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); {
boost::algorithm::to_lower(aTableName.schema);
boost::algorithm::to_lower(aTableName.table);
}
if (aTableName.schema.compare(CALPONT_SCHEMA) != 0) if (aTableName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter dictOIDs: " << tableName.schema << "|" << tableName.table << endl; DEBUG << "Enter dictOIDs: " << tableName.schema << "|" << tableName.table << endl;
@ -4872,7 +4873,6 @@ const CalpontSystemCatalog::DictOIDList CalpontSystemCatalog::dictOIDs( const Ta
return dictOIDList; return dictOIDList;
} }
#if 0 //Not implemented #if 0 //Not implemented
void CalpontSystemCatalog::storeColOID(void) void CalpontSystemCatalog::storeColOID(void)
{ {
@ -4898,13 +4898,16 @@ int CalpontSystemCatalog::colPosition (const OID& oid)
return col.colPosition; 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; TableName aTableName;
aTableName.schema = tb.schema; aTableName.schema = tb.schema;
aTableName.table = tb.table; aTableName.table = tb.table;
transform( aTableName.schema.begin(), aTableName.schema.end(), aTableName.schema.begin(), to_lower() ); if (lower_case_table_names)
transform( aTableName.table.begin(), aTableName.table.end(), aTableName.table.begin(), to_lower() ); {
boost::algorithm::to_lower(aTableName.schema);
boost::algorithm::to_lower(aTableName.table);
}
if (aTableName.schema.compare(CALPONT_SCHEMA) != 0) if (aTableName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter tableInfo: " << tb.schema << "|" << tb.table << endl; 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; // select count(objectid) from syscolumn where schema=tableName.schema and tablename=tableName.table;
try try
{ {
ridlist = columnRIDs(tb); ridlist = columnRIDs(aTableName);
} }
catch (logging::IDBExcept& noTable) catch (logging::IDBExcept& noTable)
{ {
@ -4953,9 +4956,7 @@ const CalpontSystemCatalog::ConstraintInfo CalpontSystemCatalog::constraintInfo
aIndexName.schema = indexName.schema; aIndexName.schema = indexName.schema;
aIndexName.table = indexName.table; aIndexName.table = indexName.table;
aIndexName.index = indexName.index; aIndexName.index = indexName.index;
transform( aIndexName.schema.begin(), aIndexName.schema.end(), aIndexName.schema.begin(), to_lower() ); boost::algorithm::to_lower(aIndexName.index);
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) if (aIndexName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter constraintInfo: " << aIndexName.schema << "|" << aIndexName.table << aIndexName.index << endl; DEBUG << "Enter constraintInfo: " << aIndexName.schema << "|" << aIndexName.table << aIndexName.index << endl;
@ -5109,9 +5110,7 @@ const CalpontSystemCatalog::IndexNameList CalpontSystemCatalog::referenceConstra
aIndexName.schema = referencePKName.schema; aIndexName.schema = referencePKName.schema;
aIndexName.table = referencePKName.table; aIndexName.table = referencePKName.table;
aIndexName.index = referencePKName.index; aIndexName.index = referencePKName.index;
transform( aIndexName.schema.begin(), aIndexName.schema.end(), aIndexName.schema.begin(), to_lower() ); boost::algorithm::to_lower(aIndexName.index);
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) if (aIndexName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter referenceConstraints: " << aIndexName.schema << "|" << aIndexName.table << aIndexName.index << endl; DEBUG << "Enter referenceConstraints: " << aIndexName.schema << "|" << aIndexName.table << aIndexName.index << endl;
@ -5231,8 +5230,6 @@ const string CalpontSystemCatalog::primaryKeyName (const TableName& tableName )
TableName aTableName; TableName aTableName;
aTableName.schema = tableName.schema; aTableName.schema = tableName.schema;
aTableName.table = tableName.table; 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) if (tableName.schema.compare(CALPONT_SCHEMA) != 0)
DEBUG << "Enter primaryKeyName: " << tableName.schema << "|" << tableName.table << endl; DEBUG << "Enter primaryKeyName: " << tableName.schema << "|" << tableName.table << endl;
@ -5301,11 +5298,13 @@ const string CalpontSystemCatalog::primaryKeyName (const TableName& tableName )
} }
#endif #endif
void CalpontSystemCatalog::getSchemaInfo(const string& in_schema) void CalpontSystemCatalog::getSchemaInfo(const string& in_schema, int lower_case_table_names)
{ {
string schema = in_schema; 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) if (schema == CALPONT_SCHEMA)
return; return;
else else

View File

@ -550,13 +550,13 @@ public:
* *
* For a unique table_name return the internal OID * 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 /** looks up a column's OID in the System Catalog
* *
* For a unique table_name.column_name return the internal OID * 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 /** returns the column type attribute(s) for a column
* *
@ -588,19 +588,19 @@ public:
* 0: Autoincrement does not exist for this table * 0: Autoincrement does not exist for this table
* Throws runtime_error if no such table found * 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 /** returns the rid of next autoincrement value for the table oid
* *
* return the rid of next value of autoincrement for a given table: * 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 /** returns the oid of autoincrement column for the table
* *
* return the oid of autoincrement column for a given 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 /** 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 * 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 /** return the total number of columns for a table
* *
* returns 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 /** return the RID's of the colindexes for a table
* *
* returns a list of 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 /** 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 * 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 /** return the RID's of the constraints for a table
* *
* returns a list of 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 /** 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 * 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 /** return the RID of the colconstraint for a column
* *
* returns the RID of the colconstraints 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 /** 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 * 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 /** 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 * return OID. Therefore it's duplicate to lookupOID function. This function is to be
* deprecated. * 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 /** return the RID's of the columns for a table
* *
* returns a list of 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 /** return the RID of the table
* *
* returns 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 /** return the RID of the index for a table
* *
@ -709,7 +709,7 @@ public:
* *
* returns the index name list for a table * 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 /** return the column names for a index
* *
* returns the column name list 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 * 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 /** return the RID of the colindexe for a table
* *
@ -738,13 +738,13 @@ public:
* *
* returns the RID's of the colindexe for a table * 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 /** 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 * 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 /** 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 * for now, assume one column belongs to just one index. In the future getPlan
* should give index name therefore this function will be deprecated. * 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 /** return the list of Index OIDs for the given table
* *
* returns the list of Index OIDs for a 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 /** return the list of Dictionary OIDs for the given table
* *
* returns the list of Dictionary OIDs for a 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 /** Update column OID. This is for testing DDL and DML only
* and will go away once READ works * and will go away once READ works
@ -838,16 +838,16 @@ public:
*/ */
int colPosition (const OID& oid); int colPosition (const OID& oid);
/** return primary key name for the given table */ /** 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
* *
* return the table info for a given TableName * 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 */ /** return the table name for a give table oid */
const TableName tableName (const OID& oid); const TableName tableName (const OID& oid);
/** return the list of tables for a given schema */ /** return the list of tables for a given schema */
const std::vector< std::pair<OID, TableName> > getTables (const std::string schema = ""); const std::vector< std::pair<OID, TableName> > getTables(const std::string schema = "", int lower_case_table_names=0);
/** return the number of tables in the whole database */ /** return the number of tables in the whole database */
int getTableCount (); int getTableCount ();
/** return the constraint info for a given constraint */ /** return the constraint info for a given constraint */
@ -856,7 +856,7 @@ public:
const IndexNameList referenceConstraints (const IndexName& referencePKName); const IndexNameList referenceConstraints (const IndexName& referencePKName);
// @bug 682 // @bug 682
void getSchemaInfo(const std::string& schema); void getSchemaInfo(const std::string& schema, int lower_case_table_names=0);
typedef std::map<uint32_t, long long> OIDNextvalMap; typedef std::map<uint32_t, long long> OIDNextvalMap;
void updateColinfoCache(OIDNextvalMap& oidNextvalMap); void updateColinfoCache(OIDNextvalMap& oidNextvalMap);
@ -951,14 +951,15 @@ private:
/** convenience function to make a TableColName from 3 strings /** 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 /** 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 CalpontSystemCatalog::TableAliasName make_aliastable(const std::string& s, const std::string& t, const std::string& a,
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); 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 /** convenience function to determine if column type is a char
* type * type

View File

@ -31,6 +31,7 @@ using namespace std;
#include "constantcolumn.h" #include "constantcolumn.h"
#include "operator.h" #include "operator.h"
#include "treenode.h" #include "treenode.h"
#include <boost/algorithm/string/case_conv.hpp>
namespace execplan namespace execplan
{ {
@ -98,7 +99,7 @@ int ExpressionParser::positions(Token t)
return expression::close | expression::function_close; return expression::close | expression::function_close;
default: default:
transform (oper.begin(), oper.end(), oper.begin(), to_lower()); boost::algorithm::to_lower(oper);
if (oper.compare ("and") == 0 || oper.compare ("or") == 0 ) if (oper.compare ("and") == 0 || oper.compare ("or") == 0 )
return expression::infix; return expression::infix;
@ -143,7 +144,7 @@ int ExpressionParser::position(TreeNode* op)
return expression::function_close; return expression::function_close;
default: default:
transform (oper.begin(), oper.end(), oper.begin(), to_lower()); boost::algorithm::to_lower(oper);
if (oper.compare ("and") == 0 || oper.compare ("or") == 0 ) if (oper.compare ("and") == 0 || oper.compare ("or") == 0 )
return expression::infix; return expression::infix;
@ -200,7 +201,7 @@ TreeNode* ExpressionParser::as_operator(Token t, int pos)
} }
default: default:
transform (oper.begin(), oper.end(), oper.begin(), to_lower()); boost::algorithm::to_lower(oper);
if (oper.compare ("and") == 0 || oper.compare ("or") == 0 ) if (oper.compare ("and") == 0 || oper.compare ("or") == 0 )
return t.value; return t.value;
@ -295,7 +296,7 @@ ParseTree* ExpressionParser::reduce(ParseTree* a, TreeNode* b,
string content = value->data()->data(); string content = value->data()->data();
ParseTree* root; ParseTree* root;
transform (functionName.begin(), functionName.end(), functionName.begin(), to_lower()); boost::algorithm::to_lower(functionName);
if (functionName.compare("sum") == 0 || if (functionName.compare("sum") == 0 ||
functionName.compare("avg") == 0 || functionName.compare("avg") == 0 ||
@ -346,7 +347,7 @@ int ExpressionParser::precnum(TreeNode* op)
return 7; return 7;
default: default:
transform (oper.begin(), oper.end(), oper.begin(), to_lower()); boost::algorithm::to_lower(oper);
if (oper.compare("or") == 0) if (oper.compare("or") == 0)
return 1; return 1;
@ -372,7 +373,7 @@ expression::associativity ExpressionParser::assoc(TreeNode* op)
return expression::left_associative; return expression::left_associative;
default: default:
transform (oper.begin(), oper.end(), oper.begin(), to_lower()); boost::algorithm::to_lower(oper);
if (oper.compare("or") == 0 || oper.compare("and") == 0) if (oper.compare("or") == 0 || oper.compare("and") == 0)
return expression::left_associative; return expression::left_associative;

View File

@ -46,17 +46,6 @@ namespace execplan
typedef std::stack<ParseTree*> OperandStack; typedef std::stack<ParseTree*> OperandStack;
typedef std::stack<TreeNode*> OperatorStack; typedef std::stack<TreeNode*> 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 /**@brief a structure to respent a token accepted by the parser
* *
* token structure * token structure

View File

@ -28,20 +28,6 @@
using namespace std; 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 namespace execplan
{ {

View File

@ -36,20 +36,6 @@ using namespace oam;
using namespace std; 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 namespace execplan
{ {

View File

@ -158,7 +158,8 @@ SimpleColumn::SimpleColumn(const string& token, const uint32_t sessionID):
SimpleColumn::SimpleColumn(const string& schemaName, SimpleColumn::SimpleColumn(const string& schemaName,
const string& tableName, const string& tableName,
const string& columnName, const string& columnName,
const uint32_t sessionID): const uint32_t sessionID,
const int lower_case_table_names) :
ReturnedColumn(sessionID), ReturnedColumn(sessionID),
fSchemaName (schemaName), fSchemaName (schemaName),
fTableName (tableName), fTableName (tableName),
@ -167,13 +168,20 @@ SimpleColumn::SimpleColumn(const string& schemaName,
{ {
setOID(); setOID();
fDistinct = false; 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, SimpleColumn::SimpleColumn(const string& schemaName,
const string& tableName, const string& tableName,
const string& columnName, const string& columnName,
const bool isColumnStore, const bool isColumnStore,
const uint32_t sessionID): const uint32_t sessionID,
const int lower_case_table_names) :
ReturnedColumn(sessionID), ReturnedColumn(sessionID),
fSchemaName (schemaName), fSchemaName (schemaName),
fTableName (tableName), fTableName (tableName),
@ -182,8 +190,13 @@ SimpleColumn::SimpleColumn(const string& schemaName,
{ {
if (isColumnStore) if (isColumnStore)
setOID(); setOID();
fDistinct = false; 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): SimpleColumn::SimpleColumn (const SimpleColumn& rhs, const uint32_t sessionID):

View File

@ -33,6 +33,7 @@
#include "calpontsystemcatalog.h" #include "calpontsystemcatalog.h"
#include "dataconvert.h" #include "dataconvert.h"
#include "calpontselectexecutionplan.h" #include "calpontselectexecutionplan.h"
#include <boost/algorithm/string/case_conv.hpp>
namespace messageqcpp namespace messageqcpp
{ {
@ -66,12 +67,14 @@ public:
SimpleColumn(const std::string& schema, SimpleColumn(const std::string& schema,
const std::string& table, const std::string& table,
const std::string& col, 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, SimpleColumn(const std::string& schema,
const std::string& table, const std::string& table,
const std::string& col, const std::string& col,
const bool isColumnStore, 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); SimpleColumn(const SimpleColumn& rhs, const uint32_t sessionID = 0);
/** /**
@ -87,9 +90,11 @@ public:
return fSchemaName; return fSchemaName;
} }
inline void schemaName(const std::string& schemaName) inline void schemaName(const std::string& schemaName, int lower_case_table_names = 0)
{ {
fSchemaName = schemaName; fSchemaName = schemaName;
if (lower_case_table_names)
boost::algorithm::to_lower(fSchemaName);
} }
inline const std::string& tableName() const inline const std::string& tableName() const
@ -97,9 +102,11 @@ public:
return fTableName; return fTableName;
} }
inline void tableName(const std::string& tableName) inline void tableName(const std::string& tableName, int lower_case_table_names = 0)
{ {
fTableName = tableName; fTableName = tableName;
if (lower_case_table_names)
boost::algorithm::to_lower(fTableName);
} }
inline const std::string& columnName() const inline const std::string& columnName() const
@ -132,9 +139,11 @@ public:
{ {
return fTableAlias; return fTableAlias;
} }
inline void tableAlias(const std::string& tableAlias) inline void tableAlias(const std::string& tableAlias, int lower_case_table_names = 0)
{ {
fTableAlias = tableAlias; fTableAlias = tableAlias;
if (lower_case_table_names)
boost::algorithm::to_lower(fTableAlias);
} }
inline const std::string& indexName() const inline const std::string& indexName() const
{ {
@ -148,9 +157,11 @@ public:
{ {
return fViewName; return fViewName;
} }
inline void viewName(const std::string& viewName) inline void viewName(const std::string& viewName, int lower_case_table_names = 0)
{ {
fViewName = viewName; fViewName = viewName;
if (lower_case_table_names)
boost::algorithm::to_lower(fViewName);
} }
inline const std::string& timeZone() const inline const std::string& timeZone() const
{ {

View File

@ -313,7 +313,7 @@ string UniqId::toString() const
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
string extractTableAlias(const SimpleColumn* sc) 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) string extractTableAlias(const SSC& sc)
{ {
return ba::to_lower_copy(sc->tableAlias()); return sc->tableAlias();
} }

View File

@ -63,7 +63,7 @@ SubQueryTransformer::SubQueryTransformer(JobInfo* jobInfo, SErrorInfo& err,
const string& view) : const string& view) :
fOutJobInfo(jobInfo), fSubJobInfo(NULL), fErrorInfo(err) 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) : const string& view) :
fOutJobInfo(jobInfo), fSubJobInfo(NULL), fErrorInfo(err) fOutJobInfo(jobInfo), fSubJobInfo(NULL), fErrorInfo(err)
{ {
fVtable.alias(algorithm::to_lower_copy(alias)); fVtable.alias(alias);
fVtable.view(algorithm::to_lower_copy(view)); fVtable.view(view);
} }

View File

@ -1,7 +1,6 @@
[mysqld] [mysqld]
plugin-load-add=ha_columnstore.so plugin-load-add=ha_columnstore.so
plugin-maturity=beta plugin-maturity=beta
lower_case_table_names=1
# Enable compression by default on create, set to NONE to turn off # Enable compression by default on create, set to NONE to turn off
#columnstore_compression_type=SNAPPY #columnstore_compression_type=SNAPPY

View File

@ -345,7 +345,7 @@ SCSEP FromSubQuery::transform()
gwi.subQuery = this; gwi.subQuery = this;
gwi.viewName = fGwip.viewName; gwi.viewName = fGwip.viewName;
csep->derivedTbAlias(fAlias); // always lower case 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) if (getSelectPlan(gwi, *fFromSub, csep, false) != 0)
{ {

View File

@ -478,7 +478,9 @@ extern "C"
tableName.table = args->args[0]; tableName.table = args->args[0];
if (thd->db.length) if (thd->db.length)
{
tableName.schema = thd->db.str; tableName.schema = thd->db.str;
}
else else
{ {
std::string msg("No schema information provided"); std::string msg("No schema information provided");
@ -487,6 +489,11 @@ extern "C"
return result; return result;
} }
} }
if (lower_case_table_names)
{
boost::algorithm::to_lower(tableName.schema);
boost::algorithm::to_lower(tableName.table);
}
if ( !ci->dmlProc ) if ( !ci->dmlProc )
{ {
@ -620,6 +627,11 @@ extern "C"
return -1; return -1;
} }
} }
if (lower_case_table_names)
{
boost::algorithm::to_lower(tableName.schema);
boost::algorithm::to_lower(tableName.table);
}
boost::shared_ptr<execplan::CalpontSystemCatalog> csc = boost::shared_ptr<execplan::CalpontSystemCatalog> csc =
execplan::CalpontSystemCatalog::makeCalpontSystemCatalog( execplan::CalpontSystemCatalog::makeCalpontSystemCatalog(

View File

@ -421,10 +421,14 @@ bool anyRowInTable(string& schema, string& tableName, int sessionID)
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
csc->identity(execplan::CalpontSystemCatalog::FE); csc->identity(execplan::CalpontSystemCatalog::FE);
CalpontSystemCatalog::TableName aTableName; CalpontSystemCatalog::TableName aTableName;
algorithm::to_lower(schema); if (lower_case_table_names)
algorithm::to_lower(tableName); {
algorithm::to_lower(schema);
algorithm::to_lower(tableName);
}
aTableName.schema = schema; aTableName.schema = schema;
aTableName.table = tableName; aTableName.table = tableName;
CalpontSystemCatalog::RIDList ridList = csc->columnRIDs(aTableName, true); CalpontSystemCatalog::RIDList ridList = csc->columnRIDs(aTableName, true);
CalpontSystemCatalog::TableColName tableColName = csc->colName(ridList[0].objnum); CalpontSystemCatalog::TableColName tableColName = csc->colName(ridList[0].objnum);
@ -558,8 +562,11 @@ bool anyTimestampColumn(string& schema, string& tableName, int sessionID)
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
csc->identity(execplan::CalpontSystemCatalog::FE); csc->identity(execplan::CalpontSystemCatalog::FE);
CalpontSystemCatalog::TableName aTableName; CalpontSystemCatalog::TableName aTableName;
algorithm::to_lower(schema); if (lower_case_table_names)
algorithm::to_lower(tableName); {
algorithm::to_lower(schema);
algorithm::to_lower(tableName);
}
// select columnname from calpontsys.syscolumn // select columnname from calpontsys.syscolumn
// where schema = schema and tablename = tableName // where schema = schema and tablename = tableName
@ -729,8 +736,11 @@ bool anyNullInTheColumn (THD* thd, string& schema, string& table, string& column
CalpontSelectExecutionPlan::ReturnedColumnList returnedColumnList; CalpontSelectExecutionPlan::ReturnedColumnList returnedColumnList;
CalpontSelectExecutionPlan::FilterTokenList filterTokenList; CalpontSelectExecutionPlan::FilterTokenList filterTokenList;
CalpontSelectExecutionPlan::ColumnMap colMap; CalpontSelectExecutionPlan::ColumnMap colMap;
algorithm::to_lower(schema); if (lower_case_table_names)
algorithm::to_lower(table); {
algorithm::to_lower(schema);
algorithm::to_lower(table);
}
algorithm::to_lower(columnName); algorithm::to_lower(columnName);
SessionManager sm; SessionManager sm;
@ -912,6 +922,11 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
if ( typeid ( stmt ) == typeid ( CreateTableStatement ) ) if ( typeid ( stmt ) == typeid ( CreateTableStatement ) )
{ {
CreateTableStatement* createTable = dynamic_cast <CreateTableStatement*> ( &stmt ); CreateTableStatement* createTable = dynamic_cast <CreateTableStatement*> ( &stmt );
if (lower_case_table_names)
{
algorithm::to_lower(createTable->fTableDef->fQualifiedName->fSchema);
algorithm::to_lower(createTable->fTableDef->fQualifiedName->fName);
}
bool matchedCol = false; bool matchedCol = false;
bool isFirstTimestamp = true; bool isFirstTimestamp = true;
@ -1215,6 +1230,11 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
else if ( typeid ( stmt ) == typeid ( AlterTableStatement ) ) else if ( typeid ( stmt ) == typeid ( AlterTableStatement ) )
{ {
AlterTableStatement* alterTable = dynamic_cast <AlterTableStatement*> ( &stmt ); AlterTableStatement* alterTable = dynamic_cast <AlterTableStatement*> ( &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()); alterTable->fTimeZone.assign(thd->variables.time_zone->get_name()->ptr());

View File

@ -1877,6 +1877,11 @@ std::string ha_mcs_impl_viewtablelock( cal_impl_if::cal_connection_info& ci, ex
std::string dmlStatement( "VIEWTABLELOCK" ); std::string dmlStatement( "VIEWTABLELOCK" );
VendorDMLStatement cmdStmt(dmlStatement, DML_COMMAND, sessionID); VendorDMLStatement cmdStmt(dmlStatement, DML_COMMAND, sessionID);
pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(cmdStmt); 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_SchemaName (tablename.schema);
pDMLPackage->set_TableName (tablename.table); pDMLPackage->set_TableName (tablename.table);

View File

@ -16,7 +16,6 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */ MA 02110-1301, USA. */
//#define DEBUG_WALK_COND
#include <strings.h> #include <strings.h>
#include <string> #include <string>
@ -129,15 +128,6 @@ public:
gp_walk_info* fgwip; gp_walk_info* fgwip;
}; };
namespace
{
string lower(string str)
{
boost::algorithm::to_lower(str);
return str;
}
}
#include "ha_view.h" #include "ha_view.h"
namespace cal_impl_if 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->db.length ? table->db.str : ""),
(table->table_name.length ? table->table_name.str : ""), (table->table_name.length ? table->table_name.str : ""),
(table->alias.length ? table->alias.str : ""), (table->alias.length ? table->alias.str : ""),
getViewName(table)); getViewName(table), true, lower_case_table_names);
gwi.innerTables.insert(ta); 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->db.length ? tab->db.str : ""),
(tab->table_name.length ? tab->table_name.str : ""), (tab->table_name.length ? tab->table_name.str : ""),
(tab->alias.length ? tab->alias.str : ""), (tab->alias.length ? tab->alias.str : ""),
getViewName(tab)); getViewName(tab), true, lower_case_table_names);
gwi.innerTables.insert(ta); 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->db.length ? table_ptr->db.str : ""),
(table_ptr->table_name.length ? table_ptr->table_name.str : ""), (table_ptr->table_name.length ? table_ptr->table_name.str : ""),
(table_ptr->alias.length ? table_ptr->alias.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) 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->db.length ? table->db.str : ""),
(table->table_name.length ? table->table_name.str : ""), (table->table_name.length ? table->table_name.str : ""),
(table->alias.length ? table->alias.str : ""), (table->alias.length ? table->alias.str : ""),
getViewName(table)); getViewName(table), true, lower_case_table_names);
gwi_outer.innerTables.insert(ta); 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->db.length ? table->db.str : ""),
(table->table_name.length ? table->table_name.str : ""), (table->table_name.length ? table->table_name.str : ""),
(table->alias.length ? table->alias.str : ""), (table->alias.length ? table->alias.str : ""),
getViewName(table)); getViewName(table), true, lower_case_table_names);
gwi_outer.innerTables.insert(ta); 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. // @bug 3003. Keep column alias if it has.
sc->alias(ifp->is_autogenerated_name() ? tcn.column : ifp->name.str); sc->alias(ifp->is_autogenerated_name() ? tcn.column : ifp->name.str);
sc->tableAlias(lower(gwi.tbList[i].alias)); sc->tableAlias(gwi.tbList[i].alias);
sc->viewName(lower(viewName)); sc->viewName(viewName, lower_case_table_names);
sc->resultType(ct); sc->resultType(ct);
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
break; 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->alias(ifp->is_autogenerated_name() ? cols[j]->alias() : ifp->name.str);
sc->tableName(csep->derivedTbAlias()); sc->tableName(csep->derivedTbAlias());
sc->colPosition(j); sc->colPosition(j);
string tableAlias(csep->derivedTbAlias()); sc->tableAlias(csep->derivedTbAlias());
sc->tableAlias(lower(tableAlias));
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
if (!viewName.empty()) if (!viewName.empty())
{ {
// TODO: Remove lower when MCOL-4144 fixed sc->viewName(viewName, lower_case_table_names);
sc->viewName(lower(viewName));
} }
else else
{ {
sc->viewName(lower(csep->derivedTbView())); sc->viewName(csep->derivedTbView());
} }
sc->resultType(cols[j]->resultType()); sc->resultType(cols[j]->resultType());
sc->hasAggregate(cols[j]->hasAggregate()); sc->hasAggregate(cols[j]->hasAggregate());
@ -2570,15 +2558,14 @@ void collectAllCols(gp_walk_info& gwi, Item_field* ifp)
SimpleColumn* sc = new SimpleColumn(); SimpleColumn* sc = new SimpleColumn();
sc->columnName(cols[j]->alias()); sc->columnName(cols[j]->alias());
sc->colPosition(j); sc->colPosition(j);
string tableAlias(csep->derivedTbAlias()); sc->tableAlias(csep->derivedTbAlias());
sc->tableAlias(lower(tableAlias)); sc->viewName(gwi.tbList[i].view);
sc->viewName(lower(gwi.tbList[i].view));
sc->resultType(cols[j]->resultType()); sc->resultType(cols[j]->resultType());
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
// @bug5634 derived table optimization // @bug5634 derived table optimization
cols[j]->incRefCount(); cols[j]->incRefCount();
sc->derivedTable(tableAlias); sc->derivedTable(sc->tableAlias());
sc->derivedRefCol(cols[j].get()); sc->derivedRefCol(cols[j].get());
srcp.reset(sc); srcp.reset(sc);
gwi.returnedCols.push_back(srcp); 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); CalpontSystemCatalog::TableName tn(gwi.tbList[i].schema, gwi.tbList[i].table);
if (!tableName.empty() && (strcasecmp(tableName.c_str(), tn.table.c_str()) != 0 && if (lower_case_table_names)
strcasecmp(tableName.c_str(), gwi.tbList[i].alias.c_str()) != 0 )) {
continue; 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); CalpontSystemCatalog::RIDList oidlist = gwi.csc->columnRIDs(tn, true);
for (unsigned int j = 0; j < oidlist.size(); j++) 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::TableColName tcn = gwi.csc->colName(oidlist[j].objnum);
CalpontSystemCatalog::ColType ct = gwi.csc->colType(oidlist[j].objnum); CalpontSystemCatalog::ColType ct = gwi.csc->colType(oidlist[j].objnum);
sc->columnName(tcn.column); sc->columnName(tcn.column);
sc->tableName(tcn.table); sc->tableName(tcn.table, lower_case_table_names);
sc->schemaName(tcn.schema); sc->schemaName(tcn.schema, lower_case_table_names);
sc->oid(oidlist[j].objnum); sc->oid(oidlist[j].objnum);
sc->alias(tcn.column); sc->alias(tcn.column);
sc->resultType(ct); sc->resultType(ct);
sc->tableAlias(lower(gwi.tbList[i].alias)); sc->tableAlias(gwi.tbList[i].alias, lower_case_table_names);
sc->viewName(lower(viewName)); sc->viewName(viewName, lower_case_table_names);
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
srcp.reset(sc); srcp.reset(sc);
gwi.returnedCols.push_back(srcp); gwi.returnedCols.push_back(srcp);
@ -2887,6 +2887,15 @@ SimpleColumn* getSmallestColumn(boost::shared_ptr<CalpontSystemCatalog> csc,
TABLE* table, TABLE* table,
gp_walk_info& gwi) 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 // derived table
if (tan.schema.empty()) if (tan.schema.empty())
{ {
@ -2901,7 +2910,7 @@ SimpleColumn* getSmallestColumn(boost::shared_ptr<CalpontSystemCatalog> csc,
SimpleColumn* sc = new SimpleColumn(); SimpleColumn* sc = new SimpleColumn();
sc->columnName(rc->alias()); sc->columnName(rc->alias());
sc->sequence(0); sc->sequence(0);
sc->tableAlias(lower(tan.alias)); sc->tableAlias(tan.alias);
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
// @bug5634 derived table optimization. // @bug5634 derived table optimization.
rc->incRefCount(); rc->incRefCount();
@ -2919,9 +2928,8 @@ SimpleColumn* getSmallestColumn(boost::shared_ptr<CalpontSystemCatalog> csc,
{ {
// get the first column to project. @todo optimization to get the smallest one for foreign engine. // get the first column to project. @todo optimization to get the smallest one for foreign engine.
Field* field = *(table->field); 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); 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);
string alias(table->alias.ptr()); sc->tableAlias(table->alias.ptr(), lower_case_table_names);
sc->tableAlias(lower(alias));
sc->isColumnStore(false); sc->isColumnStore(false);
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
sc->resultType(fieldType_MysqlToIDB(field)); sc->resultType(fieldType_MysqlToIDB(field));
@ -2950,8 +2958,8 @@ SimpleColumn* getSmallestColumn(boost::shared_ptr<CalpontSystemCatalog> csc,
tcn = csc->colName(oidlist[minWidthColOffset].objnum); tcn = csc->colName(oidlist[minWidthColOffset].objnum);
SimpleColumn* sc = new SimpleColumn(tcn.schema, tcn.table, tcn.column, csc->sessionID()); SimpleColumn* sc = new SimpleColumn(tcn.schema, tcn.table, tcn.column, csc->sessionID());
sc->tableAlias(lower(tan.alias)); sc->tableAlias(tan.alias);
sc->viewName(lower(tan.view)); sc->viewName(tan.view);
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
sc->resultType(csc->colType(oidlist[minWidthColOffset].objnum)); sc->resultType(csc->colType(oidlist[minWidthColOffset].objnum));
sc->charsetNumber(3000); sc->charsetNumber(3000);
@ -4499,15 +4507,15 @@ SimpleColumn* buildSimpleColumn(Item_field* ifp, gp_walk_info& gwi)
if (isInformationSchema) if (isInformationSchema)
{ {
sc->schemaName("information_schema"); 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 // 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->alias(ifp->name.str);
sc->isColumnStore(columnStore); sc->isColumnStore(columnStore);
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
@ -5231,7 +5239,7 @@ void gp_walk(const Item* item, void* arg)
break; break;
string aliasTableName(scp->tableAlias()); string aliasTableName(scp->tableAlias());
scp->tableAlias(lower(aliasTableName)); scp->tableAlias(aliasTableName);
gwip->rcWorkStack.push(scp->clone()); gwip->rcWorkStack.push(scp->clone());
boost::shared_ptr<SimpleColumn> scsp(scp); boost::shared_ptr<SimpleColumn> scsp(scp);
gwip->scsp = scsp; gwip->scsp = scsp;
@ -6214,6 +6222,10 @@ int processFrom(bool &isUnion,
} }
string viewName = getViewName(table_ptr); string viewName = getViewName(table_ptr);
if (lower_case_table_names)
{
boost::algorithm::to_lower(viewName);
}
// @todo process from subquery // @todo process from subquery
if (table_ptr->derived) if (table_ptr->derived)
@ -6221,7 +6233,11 @@ int processFrom(bool &isUnion,
SELECT_LEX* select_cursor = table_ptr->derived->first_select(); SELECT_LEX* select_cursor = table_ptr->derived->first_select();
FromSubQuery fromSub(gwi, select_cursor); FromSubQuery fromSub(gwi, select_cursor);
string alias(table_ptr->alias.str); 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); CalpontSystemCatalog::TableAliasName tn = make_aliasview("", "", alias, viewName);
// @bug 3852. check return execplan // @bug 3852. check return execplan
@ -6244,7 +6260,7 @@ int processFrom(bool &isUnion,
else if (table_ptr->view) else if (table_ptr->view)
{ {
View* view = new View(*table_ptr->view->first_select_lex(), &gwi); View* view = new View(*table_ptr->view->first_select_lex(), &gwi);
CalpontSystemCatalog::TableAliasName tn = make_aliastable(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str); 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); view->viewName(tn);
gwi.viewList.push_back(view); gwi.viewList.push_back(view);
view->transform(); view->transform();
@ -6256,7 +6272,7 @@ int processFrom(bool &isUnion,
// trigger system catalog cache // trigger system catalog cache
if (columnStore) 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; 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) 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); 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); 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); gwi.tableMap[tan] = make_pair(0, table_ptr);
#ifdef DEBUG_WALK_COND #ifdef DEBUG_WALK_COND
cerr << tn << endl; 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()); rc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
if (sub->get_select_lex()->get_table_list()) 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) if (sub->name.length)
rc->alias(sub->name.str); rc->alias(sub->name.str);
@ -7968,7 +7985,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
sc1->columnName(sc->columnName()); sc1->columnName(sc->columnName());
sc1->tableName(sc->tableName()); sc1->tableName(sc->tableName());
sc1->tableAlias(sc->tableAlias()); sc1->tableAlias(sc->tableAlias());
sc1->viewName(lower(sc->viewName())); sc1->viewName(sc->viewName());
sc1->colPosition(0); sc1->colPosition(0);
sc1->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); sc1->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
minSc.reset(sc1); 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); SimpleColumn* sc = new SimpleColumn(table->s->db.str, table->s->table_name.str, field->field_name.str, sessionID);
string alias(table->alias.c_ptr()); 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()); sc->timeZone(gwi->thd->variables.time_zone->get_name()->ptr());
assert (sc); assert (sc);
boost::shared_ptr<SimpleColumn> spsc(sc); boost::shared_ptr<SimpleColumn> spsc(sc);
@ -8117,7 +8138,7 @@ int cp_get_table_plan(THD* thd, SCSEP& csep, cal_table_info& ti)
csep->returnedCols(gwi->returnedCols); csep->returnedCols(gwi->returnedCols);
csep->columnMap(gwi->columnMap); csep->columnMap(gwi->columnMap);
CalpontSelectExecutionPlan::TableList tblist; 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); csep->tableList(tblist);
// @bug 3321. Set max number of blocks in a dictionary file to be scanned for filtering // @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); string viewName = getViewName(table_ptr);
if (lower_case_table_names)
{
boost::algorithm::to_lower(viewName);
}
// @todo process from subquery // @todo process from subquery
if (table_ptr->derived) 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 // Use Pushdown handler for subquery processing
FromSubQuery fromSub(gwi, select_cursor); FromSubQuery fromSub(gwi, select_cursor);
string alias(table_ptr->alias.str); 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); CalpontSystemCatalog::TableAliasName tn = make_aliasview("", "", alias, viewName);
// @bug 3852. check return execplan // @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) else if (table_ptr->view)
{ {
View* view = new View(*table_ptr->view->first_select_lex(), &gwi); View* view = new View(*table_ptr->view->first_select_lex(), &gwi);
CalpontSystemCatalog::TableAliasName tn = make_aliastable(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str); 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); view->viewName(tn);
gwi.viewList.push_back(view); gwi.viewList.push_back(view);
view->transform(); view->transform();
@ -8389,7 +8418,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
// trigger system catalog cache // trigger system catalog cache
if (columnStore) 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; 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) 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); 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); 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); gwi.tableMap[tan] = make_pair(0, table_ptr);
#ifdef DEBUG_WALK_COND #ifdef DEBUG_WALK_COND
cerr << tn << endl; 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()); rc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
if (sub->get_select_lex()->get_table_list()) 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) if (sub->name.length)
rc->alias(sub->name.str); 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); funcFieldVec[i]->print(&str, QT_ORDINARY);
sc->alias(string(str.c_ptr())); sc->alias(string(str.c_ptr()));
//sc->tableAlias(funcFieldVec[i]->table_name); //sc->tableAlias(funcFieldVec[i]->table_name);
sc->tableAlias(sc->tableAlias()); sc->tableAlias(sc->alias());
SRCP srcp(sc); SRCP srcp(sc);
uint32_t j = 0; 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->columnName(sc->columnName());
sc1->tableName(sc->tableName()); sc1->tableName(sc->tableName());
sc1->tableAlias(sc->tableAlias()); sc1->tableAlias(sc->tableAlias());
sc1->viewName(lower(sc->viewName())); sc1->viewName(sc->viewName());
sc1->timeZone(gwi.thd->variables.time_zone->get_name()->ptr()); sc1->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
sc1->colPosition(0); sc1->colPosition(0);
minSc.reset(sc1); minSc.reset(sc1);

View File

@ -965,8 +965,6 @@ vector<string> getOnUpdateTimestampColumns(string& schema, string& tableName, in
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
csc->identity(execplan::CalpontSystemCatalog::FE); csc->identity(execplan::CalpontSystemCatalog::FE);
CalpontSystemCatalog::TableName aTableName; CalpontSystemCatalog::TableName aTableName;
boost::algorithm::to_lower(schema);
boost::algorithm::to_lower(tableName);
// select columnname from calpontsys.syscolumn // select columnname from calpontsys.syscolumn
// where schema = schema and tablename = tableName // where schema = schema and tablename = tableName
@ -1304,11 +1302,18 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
else else
aliasName = item->table_name.str; 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) if (strcasecmp(tableName.c_str(), "") == 0)
{ {
tableName = tmpTableName; 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 //@ Bug3326 error out for multi table update
string emsg(IDBErrorInfo::instance()->errorMsg(ERR_UPDATE_NOT_SUPPORT_FEATURE)); 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<COND*>& c
} }
} }
else else
{
schemaName = string(item->db_name.str); schemaName = string(item->db_name.str);
if (lower_case_table_names)
{
boost::algorithm::to_lower(schemaName);
}
}
columnAssignmentPtr = new ColumnAssignment(item->name.str, "=", ""); columnAssignmentPtr = new ColumnAssignment(item->name.str, "=", "");
if (item->field_type() == MYSQL_TYPE_TIMESTAMP || if (item->field_type() == MYSQL_TYPE_TIMESTAMP ||
item->field_type() == MYSQL_TYPE_TIMESTAMP2) item->field_type() == MYSQL_TYPE_TIMESTAMP2)
@ -1567,6 +1577,11 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
aTableName.schema = first_table->table->s->db.str; aTableName.schema = first_table->table->s->db.str;
aTableName.table = first_table->table->s->table_name.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; CalpontDMLPackage* pDMLPackage = 0;
// dmlStmt += ";"; // dmlStmt += ";";
@ -1604,6 +1619,12 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
schemaName = first_table->db.str; schemaName = first_table->db.str;
tableName = first_table->table_name.str; tableName = first_table->table_name.str;
aliasName = first_table->alias.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->fName = tableName;
qualifiedTablName->fSchema = schemaName; qualifiedTablName->fSchema = schemaName;
pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(dmlStatement); pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(dmlStatement);
@ -1623,6 +1644,12 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
schemaName = first_table->table->s->db.str; schemaName = first_table->table->s->db.str;
tableName = first_table->table->s->table_name.str; tableName = first_table->table->s->table_name.str;
aliasName = first_table->alias.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->fName = tableName;
qualifiedTablName->fSchema = schemaName; qualifiedTablName->fSchema = schemaName;
pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(dmlStatement); pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(dmlStatement);
@ -1634,6 +1661,12 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
schemaName = first_table->table->s->db.str; schemaName = first_table->table->s->db.str;
tableName = first_table->table->s->table_name.str; tableName = first_table->table->s->table_name.str;
aliasName = first_table->alias.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->fName = tableName;
qualifiedTablName->fSchema = schemaName; qualifiedTablName->fSchema = schemaName;
pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(dmlStatement); pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(dmlStatement);
@ -1821,7 +1854,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
try try
{ {
colrids = csc->columnRIDs(deleteTableName); colrids = csc->columnRIDs(deleteTableName, false, lower_case_table_names);
} }
catch (IDBExcept& ie) catch (IDBExcept& ie)
{ {
@ -1916,7 +1949,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
CalpontSystemCatalog::ROPair roPair; CalpontSystemCatalog::ROPair roPair;
try try
{ {
roPair = csc->tableRID( aTableName ); roPair = csc->tableRID(aTableName);
} }
catch (IDBExcept& ie) catch (IDBExcept& ie)
{ {
@ -2238,7 +2271,7 @@ int ha_mcs_impl_discover_existence(const char* schema, const char* name)
try 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) if (oid)
return 1; return 1;
@ -2438,7 +2471,7 @@ int ha_mcs::impl_rnd_init(TABLE* table, const std::vector<COND*>& condStack)
ti.csep->sessionID(sessionID); ti.csep->sessionID(sessionID);
if (thd->db.length) 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.csep->traceFlags(ci->traceFlags);
ti.msTablePtr = table; ti.msTablePtr = table;
@ -2629,7 +2662,7 @@ int ha_mcs::impl_rnd_init(TABLE* table, const std::vector<COND*>& condStack)
// populate coltypes here for table mode because tableband gives treeoid for dictionary column // 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) if (oidlist.size() != num_attr)
{ {
@ -3180,7 +3213,7 @@ void ha_mcs_impl_start_bulk_insert(ha_rows rows, TABLE* table, bool is_cache_ins
try try
{ {
colrids = csc->columnRIDs(tableName); colrids = csc->columnRIDs(tableName, false, lower_case_table_names);
} }
catch (IDBExcept& ie) catch (IDBExcept& ie)
{ {
@ -3591,7 +3624,7 @@ void ha_mcs_impl_start_bulk_insert(ha_rows rows, TABLE* table, bool is_cache_ins
try try
{ {
CalpontSystemCatalog::ROPair roPair = csc->tableRID( tableName ); CalpontSystemCatalog::ROPair roPair = csc->tableRID(tableName, lower_case_table_names);
ci->tableOid = roPair.objnum; ci->tableOid = roPair.objnum;
} }
catch (IDBExcept& ie) catch (IDBExcept& ie)
@ -4331,7 +4364,7 @@ int ha_mcs_impl_group_by_init(mcs_handler_info *handler_info, TABLE* table)
csep->sessionID(sessionID); csep->sessionID(sessionID);
if (group_hand->table_list->db.length) 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); csep->traceFlags(ci->traceFlags);
@ -5086,7 +5119,7 @@ int ha_mcs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
csep->sessionID(sessionID); csep->sessionID(sessionID);
if (thd->db.length) if (thd->db.length)
csep->schemaName(thd->db.str); csep->schemaName(thd->db.str, lower_case_table_names);
csep->traceFlags(ci->traceFlags); csep->traceFlags(ci->traceFlags);

View File

@ -450,8 +450,10 @@ void parsePartitionString(UDF_ARGS* args,
string& errMsg, string& errMsg,
execplan::CalpontSystemCatalog::TableName tableName) execplan::CalpontSystemCatalog::TableName tableName)
{ {
//@Bug 4695 if (lower_case_table_names)
algorithm::to_lower(tableName.schema); {
boost::algorithm::to_lower(tableName.schema);
}
if (tableName.schema == "calpontsys") if (tableName.schema == "calpontsys")
{ {
@ -654,12 +656,17 @@ void partitionByValue_common(UDF_ARGS* args, // input
column = (char*)(args->args[1]); 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.schema = schema;
tableName.table = table; tableName.table = table;
//@Bug 4695 //@Bug 4695
algorithm::to_lower(tableName.schema);
if (tableName.schema == "calpontsys") if (tableName.schema == "calpontsys")
{ {
errMsg = IDBErrorInfo::instance()->errorMsg(SYSTABLE_PARTITION); errMsg = IDBErrorInfo::instance()->errorMsg(SYSTABLE_PARTITION);
@ -670,7 +677,7 @@ void partitionByValue_common(UDF_ARGS* args, // input
{ {
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(tid2sid(current_thd->thread_id)); boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(tid2sid(current_thd->thread_id));
csc->identity(execplan::CalpontSystemCatalog::FE); 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); csc->identity(CalpontSystemCatalog::FE);
OID_t oid = csc->lookupOID(tcn); OID_t oid = csc->lookupOID(tcn);
ct = csc->colType(oid); ct = csc->colType(oid);
@ -1029,10 +1036,16 @@ extern "C"
table = (char*)(args->args[0]); table = (char*)(args->args[0]);
column = (char*)(args->args[1]); 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<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(tid2sid(current_thd->thread_id)); boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(tid2sid(current_thd->thread_id));
csc->identity(CalpontSystemCatalog::FE); 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); OID_t oid = csc->lookupOID(tcn);
ct = csc->colType(oid); ct = csc->colType(oid);
@ -1735,9 +1748,16 @@ extern "C"
column = (char*)(args->args[1]); 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<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(tid2sid(current_thd->thread_id)); boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(tid2sid(current_thd->thread_id));
csc->identity(CalpontSystemCatalog::FE); 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); OID_t oid = csc->lookupOID(tcn);
ct = csc->colType(oid); ct = csc->colType(oid);

View File

@ -88,14 +88,21 @@ void View::transform()
continue; continue;
string viewName = getViewName(table_ptr); string viewName = getViewName(table_ptr);
if (lower_case_table_names)
{
boost::algorithm::to_lower(viewName);
}
if (table_ptr->derived) if (table_ptr->derived)
{ {
SELECT_LEX* select_cursor = table_ptr->derived->first_select(); SELECT_LEX* select_cursor = table_ptr->derived->first_select();
FromSubQuery* fromSub = new FromSubQuery(gwi, select_cursor); FromSubQuery* fromSub = new FromSubQuery(gwi, select_cursor);
string alias(table_ptr->alias.str); string alias(table_ptr->alias.str);
gwi.viewName = make_aliasview("", alias, table_ptr->belong_to_view->alias.str, ""); if (lower_case_table_names)
algorithm::to_lower(alias); {
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); fromSub->alias(alias);
gwi.derivedTbList.push_back(SCSEP(fromSub->transform())); gwi.derivedTbList.push_back(SCSEP(fromSub->transform()));
// set alias to both table name and alias name of the derived table // 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) else if (table_ptr->view)
{ {
// for nested view, the view name is vout.vin... format // 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); 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); 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* view = new View(*table_ptr->view->first_select_lex(), &gwi);
view->viewName(gwi.viewName); view->viewName(gwi.viewName);
gwi.viewList.push_back(view); gwi.viewList.push_back(view);
@ -122,9 +129,9 @@ void View::transform()
// trigger system catalog cache // trigger system catalog cache
if (columnStore) 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.tbList.push_back(tn);
gwi.tableMap[tn] = make_pair(0, table_ptr); gwi.tableMap[tn] = make_pair(0, table_ptr);
fParentGwip->tableMap[tn] = make_pair(0, table_ptr); fParentGwip->tableMap[tn] = make_pair(0, table_ptr);

View File

@ -28,6 +28,9 @@ template <class T> bool isnan(T);
#endif #endif
#endif #endif
//#define INFINIDB_DEBUG
//#define DEBUG_WALK_COND
#define MYSQL_SERVER 1 //needed for definition of struct THD in mysql_priv.h #define MYSQL_SERVER 1 //needed for definition of struct THD in mysql_priv.h
#define USE_CALPONT_REGEX #define USE_CALPONT_REGEX
@ -45,7 +48,7 @@ template <class T> bool isnan(T);
#ifndef ENABLED_DEBUG_SYNC #ifndef ENABLED_DEBUG_SYNC
#define ENABLED_DEBUG_SYNC #define ENABLED_DEBUG_SYNC
#endif #endif
//#define INFINIDB_DEBUG
#define DBUG_ON 1 #define DBUG_ON 1
#undef DBUG_OFF #undef DBUG_OFF
#else #else
@ -73,6 +76,7 @@ template <class T> bool isnan(T);
#include "derived_handler.h" #include "derived_handler.h"
#include "select_handler.h" #include "select_handler.h"
#include "rpl_rli.h" #include "rpl_rli.h"
#include "my_dbug.h"
// Now clean up the pollution as best we can... // Now clean up the pollution as best we can...
#undef min #undef min

View File

@ -151,7 +151,7 @@ static int is_columnstore_columns_fill(THD* thd, TABLE_LIST* tables, COND* cond)
// So simply ignore the dropped table. // So simply ignore the dropped table.
try try
{ {
column_rid_list = systemCatalogPtr->columnRIDs((*it).second, true); column_rid_list = systemCatalogPtr->columnRIDs((*it).second, true, lower_case_table_names);
} }
catch (IDBExcept& ex) catch (IDBExcept& ex)
{ {

View File

@ -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); try
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(); execplan::CalpontSystemCatalog::TableInfo tb_info = systemCatalogPtr->tableInfo((*it).second);
table->field[5]->store(systemCatalogPtr->nextAutoIncrValue((*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; return 0;

View File

@ -42,16 +42,6 @@ using namespace funcexp;
#include "collation.h" #include "collation.h"
class to_lower
{
public:
char operator() (char c) const // notice the return type
{
return tolower(c);
}
};
namespace funcexp namespace funcexp
{ {

View File

@ -37,15 +37,6 @@ using namespace joblist;
#include "collation.h" #include "collation.h"
class to_lower
{
public:
char operator() (char c) const // notice the return type
{
return tolower(c);
}
};
namespace funcexp namespace funcexp
{ {

View File

@ -42,17 +42,6 @@ using namespace funcexp;
#include "collation.h" #include "collation.h"
class to_lower
{
public:
char operator() (char c) const // notice the return type
{
return tolower(c);
}
};
namespace funcexp namespace funcexp
{ {

View File

@ -36,16 +36,6 @@ using namespace rowgroup;
#include "joblisttypes.h" #include "joblisttypes.h"
using namespace joblist; using namespace joblist;
class to_lower
{
public:
char operator() (char c) const // notice the return type
{
return tolower(c);
}
};
namespace funcexp namespace funcexp
{ {

View File

@ -45,16 +45,6 @@ using namespace funcexp;
struct charset_info_st; struct charset_info_st;
typedef const struct charset_info_st CHARSET_INFO; 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 namespace funcexp
{ {

View File

@ -182,14 +182,12 @@ uint8_t WE_DDLCommandProc::writeSystable(ByteStream& bs, std::string& err)
if (TABLENAME_COL == column.tableColName.column) if (TABLENAME_COL == column.tableColName.column)
{ {
std::string tablename = tableDef.fQualifiedName->fName; std::string tablename = tableDef.fQualifiedName->fName;
boost::to_lower(tablename);
colTuple.data = tablename; colTuple.data = tablename;
tmpStr = tablename; tmpStr = tablename;
} }
else if (SCHEMA_COL == column.tableColName.column) else if (SCHEMA_COL == column.tableColName.column)
{ {
std::string schema = tableDef.fQualifiedName->fSchema; std::string schema = tableDef.fQualifiedName->fSchema;
boost::to_lower(schema);
colTuple.data = schema; colTuple.data = schema;
tmpStr = schema; tmpStr = schema;
} }
@ -519,13 +517,11 @@ uint8_t WE_DDLCommandProc::writeCreateSyscolumn(ByteStream& bs, std::string& err
if (SCHEMA_COL == column.tableColName.column) if (SCHEMA_COL == column.tableColName.column)
{ {
boost::to_lower(qualifiedName.fSchema);
colTuple.data = qualifiedName.fSchema; colTuple.data = qualifiedName.fSchema;
tmpStr = qualifiedName.fSchema; tmpStr = qualifiedName.fSchema;
} }
else if (TABLENAME_COL == column.tableColName.column) else if (TABLENAME_COL == column.tableColName.column)
{ {
boost::to_lower(qualifiedName.fName);
colTuple.data = qualifiedName.fName; colTuple.data = qualifiedName.fName;
tmpStr = 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) if (SCHEMA_COL == column.tableColName.column)
{ {
boost::to_lower(schema);
colTuple.data = schema; colTuple.data = schema;
tmpStr = schema; tmpStr = schema;
} }
else if (TABLENAME_COL == column.tableColName.column) else if (TABLENAME_COL == column.tableColName.column)
{ {
boost::to_lower(tablename);
colTuple.data = tablename; colTuple.data = tablename;
tmpStr = tablename; tmpStr = tablename;
} }