You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-12-06 08:40:57 +03:00
Reformat all code to coding standard
This commit is contained in:
@@ -25,287 +25,299 @@
|
||||
#include "ddlpkg.h"
|
||||
#undef DDLPKG_DLLEXPORT
|
||||
|
||||
namespace ddlpackage {
|
||||
using namespace std;
|
||||
namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
AlterTableStatement::AlterTableStatement(QualifiedName *qName, AlterTableActionList *ataList):
|
||||
fTableName(qName),
|
||||
fActions(*ataList)
|
||||
{
|
||||
delete ataList;
|
||||
}
|
||||
AlterTableStatement::AlterTableStatement(QualifiedName* qName, AlterTableActionList* ataList):
|
||||
fTableName(qName),
|
||||
fActions(*ataList)
|
||||
{
|
||||
delete ataList;
|
||||
}
|
||||
|
||||
AlterTableStatement::~AlterTableStatement()
|
||||
{
|
||||
delete fTableName;
|
||||
AlterTableActionList::iterator itr;
|
||||
for(itr=fActions.begin(); itr != fActions.end(); ++itr) {
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
AlterTableStatement::~AlterTableStatement()
|
||||
{
|
||||
delete fTableName;
|
||||
AlterTableActionList::iterator itr;
|
||||
|
||||
std::ostream& AlterTableStatement::put(std::ostream& os) const
|
||||
{
|
||||
AlterTableActionList::const_iterator itr;
|
||||
os << "Alter Table " << *fTableName << endl;
|
||||
for (itr = fActions.begin(); itr != fActions.end(); ++itr)
|
||||
{
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
|
||||
for(itr = fActions.begin(); itr != fActions.end(); ++itr) {
|
||||
os << **itr << endl;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
std::ostream& AlterTableStatement::put(std::ostream& os) const
|
||||
{
|
||||
AlterTableActionList::const_iterator itr;
|
||||
os << "Alter Table " << *fTableName << endl;
|
||||
|
||||
for (itr = fActions.begin(); itr != fActions.end(); ++itr)
|
||||
{
|
||||
os << **itr << endl;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
/** @brief Format to ostream. Diagnostic. */
|
||||
std::ostream& AlterTableAction::put(std::ostream& os) const
|
||||
{
|
||||
os << "AlterTableAction put stub";
|
||||
return os;
|
||||
}
|
||||
|
||||
/** @brief Invokes the virtual function put, to dispatch to subclass
|
||||
ostream writers. */
|
||||
std::ostream &operator<<(std::ostream& os, const AlterTableAction &ata)
|
||||
{
|
||||
return ata.put(os);
|
||||
}
|
||||
|
||||
/** @brief Format to ostream. Diagnostic. */
|
||||
std::ostream& AlterTableAction::put(std::ostream& os) const
|
||||
{
|
||||
os << "AlterTableAction put stub";
|
||||
return os;
|
||||
}
|
||||
|
||||
AtaAddColumn::~AtaAddColumn()
|
||||
{
|
||||
delete fColumnDef;
|
||||
}
|
||||
/** @brief Invokes the virtual function put, to dispatch to subclass
|
||||
ostream writers. */
|
||||
std::ostream& operator<<(std::ostream& os, const AlterTableAction& ata)
|
||||
{
|
||||
return ata.put(os);
|
||||
}
|
||||
|
||||
|
||||
/** @brief ostream output */
|
||||
std::ostream& AtaAddColumn::put(std::ostream& os) const
|
||||
{
|
||||
os << "Add Column" << endl;
|
||||
os << *fColumnDef << endl;
|
||||
return os;
|
||||
}
|
||||
AtaAddColumn::~AtaAddColumn()
|
||||
{
|
||||
delete fColumnDef;
|
||||
}
|
||||
|
||||
|
||||
/** @brief ostream output */
|
||||
std::ostream& AtaAddColumn::put(std::ostream& os) const
|
||||
{
|
||||
os << "Add Column" << endl;
|
||||
os << *fColumnDef << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
AtaDropColumn::AtaDropColumn(std::string columnName, DDL_REFERENTIAL_ACTION dropBehavior) :
|
||||
fColumnName(columnName),
|
||||
fDropBehavior(dropBehavior)
|
||||
{
|
||||
}
|
||||
|
||||
std::ostream& AtaDropColumn::put(std::ostream& os) const
|
||||
{
|
||||
os << "Drop Column: " << fColumnName << " "
|
||||
<< ReferentialActionStrings[fDropBehavior];
|
||||
return os;
|
||||
}
|
||||
|
||||
AtaDropColumn::AtaDropColumn(std::string columnName, DDL_REFERENTIAL_ACTION dropBehavior) :
|
||||
fColumnName(columnName),
|
||||
fDropBehavior(dropBehavior)
|
||||
{
|
||||
}
|
||||
|
||||
AtaModifyColumnType::~AtaModifyColumnType()
|
||||
{
|
||||
delete fColumnType;
|
||||
}
|
||||
std::ostream& AtaDropColumn::put(std::ostream& os) const
|
||||
{
|
||||
os << "Drop Column: " << fColumnName << " "
|
||||
<< ReferentialActionStrings[fDropBehavior];
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream& AtaModifyColumnType::put(std::ostream& os) const
|
||||
{
|
||||
os << "Modify column type: " << fName << " " << *fColumnType;
|
||||
|
||||
return os;
|
||||
}
|
||||
AtaModifyColumnType::~AtaModifyColumnType()
|
||||
{
|
||||
delete fColumnType;
|
||||
}
|
||||
|
||||
std::ostream& AtaModifyColumnType::put(std::ostream& os) const
|
||||
{
|
||||
os << "Modify column type: " << fName << " " << *fColumnType;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
AtaRenameColumn::~AtaRenameColumn()
|
||||
{
|
||||
delete fNewType;
|
||||
}
|
||||
|
||||
std::ostream& AtaRenameColumn::put(std::ostream& os) const
|
||||
{
|
||||
os << "Rename Column: " << fName << " -> " << fNewName << " (" << *fNewType << ')';
|
||||
return os;
|
||||
}
|
||||
|
||||
AtaRenameColumn::~AtaRenameColumn()
|
||||
{
|
||||
delete fNewType;
|
||||
}
|
||||
|
||||
std::ostream& AtaRenameColumn::put(std::ostream& os) const
|
||||
{
|
||||
os << "Rename Column: " << fName << " -> " << fNewName << " (" << *fNewType << ')';
|
||||
return os;
|
||||
}
|
||||
|
||||
AtaSetColumnDefault::AtaSetColumnDefault(const char *colName, ColumnDefaultValue *defaultValue) :
|
||||
fColumnName(colName),
|
||||
fDefaultValue(defaultValue)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AtaSetColumnDefault::~AtaSetColumnDefault()
|
||||
{
|
||||
delete fDefaultValue;
|
||||
}
|
||||
AtaSetColumnDefault::AtaSetColumnDefault(const char* colName, ColumnDefaultValue* defaultValue) :
|
||||
fColumnName(colName),
|
||||
fDefaultValue(defaultValue)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
std::ostream& AtaSetColumnDefault::put(std::ostream& os) const
|
||||
{
|
||||
os << "Set Column Default: " << fColumnName << " "
|
||||
<< *fDefaultValue << endl;
|
||||
return os;
|
||||
}
|
||||
AtaSetColumnDefault::~AtaSetColumnDefault()
|
||||
{
|
||||
delete fDefaultValue;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& AtaSetColumnDefault::put(std::ostream& os) const
|
||||
{
|
||||
os << "Set Column Default: " << fColumnName << " "
|
||||
<< *fDefaultValue << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
AtaDropColumnDefault::AtaDropColumnDefault(const char *colName) :
|
||||
fColumnName(colName)
|
||||
{
|
||||
}
|
||||
|
||||
std::ostream& AtaDropColumnDefault::put(std::ostream& os) const
|
||||
{
|
||||
os << "Drop Column Default: " << fColumnName << " ";
|
||||
return os;
|
||||
}
|
||||
|
||||
AtaDropColumnDefault::AtaDropColumnDefault(const char* colName) :
|
||||
fColumnName(colName)
|
||||
{
|
||||
}
|
||||
|
||||
std::ostream& AtaDropColumnDefault::put(std::ostream& os) const
|
||||
{
|
||||
os << "Drop Column Default: " << fColumnName << " ";
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
AtaRenameTable::AtaRenameTable(QualifiedName *qualifiedName) :
|
||||
fQualifiedName(qualifiedName)
|
||||
{
|
||||
}
|
||||
|
||||
AtaRenameTable::~AtaRenameTable()
|
||||
{
|
||||
delete fQualifiedName;
|
||||
}
|
||||
|
||||
AtaRenameTable::AtaRenameTable(QualifiedName* qualifiedName) :
|
||||
fQualifiedName(qualifiedName)
|
||||
{
|
||||
}
|
||||
|
||||
std::ostream& AtaRenameTable::put(std::ostream& os) const
|
||||
{
|
||||
os << "Rename Table: " << *fQualifiedName << endl;
|
||||
return os;
|
||||
}
|
||||
AtaRenameTable::~AtaRenameTable()
|
||||
{
|
||||
delete fQualifiedName;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& AtaRenameTable::put(std::ostream& os) const
|
||||
{
|
||||
os << "Rename Table: " << *fQualifiedName << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
AtaTableComment::AtaTableComment(const char *tableComment) :
|
||||
fTableComment(tableComment)
|
||||
{
|
||||
}
|
||||
|
||||
AtaTableComment::~AtaTableComment()
|
||||
{
|
||||
}
|
||||
|
||||
AtaTableComment::AtaTableComment(const char* tableComment) :
|
||||
fTableComment(tableComment)
|
||||
{
|
||||
}
|
||||
|
||||
std::ostream& AtaTableComment::put(std::ostream& os) const
|
||||
{
|
||||
os << "TableComment: " << fTableComment << endl;
|
||||
return os;
|
||||
}
|
||||
AtaTableComment::~AtaTableComment()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AtaAddColumns::~AtaAddColumns()
|
||||
{
|
||||
ColumnDefList::iterator itr;
|
||||
for(itr=fColumns.begin(); itr != fColumns.end(); itr++)
|
||||
delete *itr;
|
||||
}
|
||||
std::ostream& AtaTableComment::put(std::ostream& os) const
|
||||
{
|
||||
os << "TableComment: " << fTableComment << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
AtaAddColumns::AtaAddColumns(TableElementList *tableElements)
|
||||
{
|
||||
/* It is convenient to reuse the grammar rules for
|
||||
table_element_list, and we do. So, it is possible for
|
||||
there to be errant table constraint defs in the input list.
|
||||
We ignore them. That is all we are doing here.
|
||||
*/
|
||||
ColumnDef *column;
|
||||
TableElementList::const_iterator itr;
|
||||
for(itr = tableElements->begin();
|
||||
itr != tableElements->end();
|
||||
++itr)
|
||||
{
|
||||
column = dynamic_cast<ColumnDef *>(*itr);
|
||||
if(0 != column) {
|
||||
fColumns.push_back(column);
|
||||
}
|
||||
}
|
||||
delete tableElements;
|
||||
}
|
||||
AtaAddColumns::~AtaAddColumns()
|
||||
{
|
||||
ColumnDefList::iterator itr;
|
||||
|
||||
std::ostream& AtaAddColumns::put(std::ostream& os) const
|
||||
{
|
||||
os << "Add Columns: " << endl;
|
||||
ColumnDefList::const_iterator itr;
|
||||
for(itr = fColumns.begin();
|
||||
itr != fColumns.end();
|
||||
++itr)
|
||||
{
|
||||
os << **itr << endl;
|
||||
}
|
||||
for (itr = fColumns.begin(); itr != fColumns.end(); itr++)
|
||||
delete *itr;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
//////////////////////////
|
||||
|
||||
AtaDropColumns::~AtaDropColumns()
|
||||
{
|
||||
}
|
||||
AtaAddColumns::AtaAddColumns(TableElementList* tableElements)
|
||||
{
|
||||
/* It is convenient to reuse the grammar rules for
|
||||
table_element_list, and we do. So, it is possible for
|
||||
there to be errant table constraint defs in the input list.
|
||||
We ignore them. That is all we are doing here.
|
||||
*/
|
||||
ColumnDef* column;
|
||||
TableElementList::const_iterator itr;
|
||||
|
||||
for (itr = tableElements->begin();
|
||||
itr != tableElements->end();
|
||||
++itr)
|
||||
{
|
||||
column = dynamic_cast<ColumnDef*>(*itr);
|
||||
|
||||
AtaDropColumns::AtaDropColumns(ColumnNameList *columnNames)
|
||||
{
|
||||
fColumns = *columnNames;
|
||||
delete columnNames;
|
||||
}
|
||||
if (0 != column)
|
||||
{
|
||||
fColumns.push_back(column);
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& AtaDropColumns::put(std::ostream& os) const
|
||||
{
|
||||
os << "Drop Columns: " << endl;
|
||||
ColumnNameList::const_iterator itr;
|
||||
for(itr = fColumns.begin();
|
||||
itr != fColumns.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << endl;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AtaAddTableConstraint::AtaAddTableConstraint(TableConstraintDef *tableConstraint) :
|
||||
fTableConstraint(tableConstraint)
|
||||
{
|
||||
}
|
||||
|
||||
AtaAddTableConstraint::~AtaAddTableConstraint()
|
||||
{
|
||||
delete fTableConstraint;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& AtaAddTableConstraint::put(std::ostream& os) const
|
||||
{
|
||||
os << "Add Table Constraint:" << endl;
|
||||
os << *fTableConstraint << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AtaDropTableConstraint::AtaDropTableConstraint
|
||||
(const char *constraintName, DDL_REFERENTIAL_ACTION dropBehavior) :
|
||||
fConstraintName(constraintName),
|
||||
fDropBehavior(dropBehavior)
|
||||
{
|
||||
}
|
||||
|
||||
std::ostream& AtaDropTableConstraint::put(std::ostream& os) const
|
||||
{
|
||||
os << "Drop Table Constraint: " << fConstraintName;
|
||||
return os;
|
||||
}
|
||||
delete tableElements;
|
||||
}
|
||||
|
||||
std::ostream& AtaAddColumns::put(std::ostream& os) const
|
||||
{
|
||||
os << "Add Columns: " << endl;
|
||||
ColumnDefList::const_iterator itr;
|
||||
|
||||
for (itr = fColumns.begin();
|
||||
itr != fColumns.end();
|
||||
++itr)
|
||||
{
|
||||
os << **itr << endl;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
//////////////////////////
|
||||
|
||||
AtaDropColumns::~AtaDropColumns()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AtaDropColumns::AtaDropColumns(ColumnNameList* columnNames)
|
||||
{
|
||||
fColumns = *columnNames;
|
||||
delete columnNames;
|
||||
}
|
||||
|
||||
std::ostream& AtaDropColumns::put(std::ostream& os) const
|
||||
{
|
||||
os << "Drop Columns: " << endl;
|
||||
ColumnNameList::const_iterator itr;
|
||||
|
||||
for (itr = fColumns.begin();
|
||||
itr != fColumns.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << endl;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AtaAddTableConstraint::AtaAddTableConstraint(TableConstraintDef* tableConstraint) :
|
||||
fTableConstraint(tableConstraint)
|
||||
{
|
||||
}
|
||||
|
||||
AtaAddTableConstraint::~AtaAddTableConstraint()
|
||||
{
|
||||
delete fTableConstraint;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& AtaAddTableConstraint::put(std::ostream& os) const
|
||||
{
|
||||
os << "Add Table Constraint:" << endl;
|
||||
os << *fTableConstraint << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AtaDropTableConstraint::AtaDropTableConstraint
|
||||
(const char* constraintName, DDL_REFERENTIAL_ACTION dropBehavior) :
|
||||
fConstraintName(constraintName),
|
||||
fDropBehavior(dropBehavior)
|
||||
{
|
||||
}
|
||||
|
||||
std::ostream& AtaDropTableConstraint::put(std::ostream& os) const
|
||||
{
|
||||
os << "Drop Table Constraint: " << fConstraintName;
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,120 +28,133 @@
|
||||
#include "ddlpkg.h"
|
||||
#undef DDLPKG_DLLEXPORT
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
using namespace std;
|
||||
|
||||
ColumnDef::~ColumnDef()
|
||||
{
|
||||
delete fType;
|
||||
delete fDefaultValue;
|
||||
ColumnConstraintList::iterator itr;
|
||||
for(itr=fConstraints.begin(); itr != fConstraints.end(); ++itr) {
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
ColumnDef::~ColumnDef()
|
||||
{
|
||||
delete fType;
|
||||
delete fDefaultValue;
|
||||
ColumnConstraintList::iterator itr;
|
||||
|
||||
ColumnDef::ColumnDef(const char *name, ColumnType* columnType, ColumnConstraintList *constraints,
|
||||
ColumnDefaultValue *defaultValue, const char * comment ) :
|
||||
SchemaObject(name),
|
||||
fType(columnType),
|
||||
fDefaultValue(defaultValue)
|
||||
{
|
||||
if(constraints) {
|
||||
fConstraints = *constraints;
|
||||
delete constraints;
|
||||
}
|
||||
if ( comment )
|
||||
fComment = comment;
|
||||
}
|
||||
for (itr = fConstraints.begin(); itr != fConstraints.end(); ++itr)
|
||||
{
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
|
||||
ColumnDef::ColumnDef(const char* name, ColumnType* columnType, ColumnConstraintList* constraints,
|
||||
ColumnDefaultValue* defaultValue, const char* comment ) :
|
||||
SchemaObject(name),
|
||||
fType(columnType),
|
||||
fDefaultValue(defaultValue)
|
||||
{
|
||||
if (constraints)
|
||||
{
|
||||
fConstraints = *constraints;
|
||||
delete constraints;
|
||||
}
|
||||
|
||||
if ( comment )
|
||||
fComment = comment;
|
||||
}
|
||||
|
||||
|
||||
ostream &operator<<(ostream& os, const ColumnType& columnType)
|
||||
{
|
||||
os << setw(12) << left << DDLDatatypeString[columnType.fType]
|
||||
<< "["
|
||||
<< "L=" << setw(2) << columnType.fLength << ","
|
||||
<< "P=" << setw(2) << columnType.fPrecision << ","
|
||||
<< "S=" << setw(2) << columnType.fScale << ","
|
||||
<< "T=" << setw(2) << columnType.fWithTimezone
|
||||
<< "]";
|
||||
return os;
|
||||
}
|
||||
ostream& operator<<(ostream& os, const ColumnType& columnType)
|
||||
{
|
||||
os << setw(12) << left << DDLDatatypeString[columnType.fType]
|
||||
<< "["
|
||||
<< "L=" << setw(2) << columnType.fLength << ","
|
||||
<< "P=" << setw(2) << columnType.fPrecision << ","
|
||||
<< "S=" << setw(2) << columnType.fScale << ","
|
||||
<< "T=" << setw(2) << columnType.fWithTimezone
|
||||
<< "]";
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
ostream &operator<<(ostream& os, const ColumnDef &column)
|
||||
{
|
||||
os << "Column: " << column.fName << " " << *column.fType;
|
||||
ostream& operator<<(ostream& os, const ColumnDef& column)
|
||||
{
|
||||
os << "Column: " << column.fName << " " << *column.fType;
|
||||
|
||||
if(column.fDefaultValue) {
|
||||
os << " def=";
|
||||
if (column.fDefaultValue)
|
||||
{
|
||||
os << " def=";
|
||||
|
||||
if (column.fDefaultValue->fNull)
|
||||
os << "NULL";
|
||||
else
|
||||
os << column.fDefaultValue->fValue;
|
||||
}
|
||||
if (column.fDefaultValue->fNull)
|
||||
os << "NULL";
|
||||
else
|
||||
os << column.fDefaultValue->fValue;
|
||||
}
|
||||
|
||||
os << endl << " " << column.fConstraints.size()
|
||||
<< " constraints ";
|
||||
os << endl << " " << column.fConstraints.size()
|
||||
<< " constraints ";
|
||||
|
||||
ColumnConstraintList::const_iterator itr;
|
||||
for(itr = column.fConstraints.begin();
|
||||
itr != column.fConstraints.end();
|
||||
++itr) {
|
||||
ColumnConstraintDef *con = *itr;
|
||||
os << *con;
|
||||
}
|
||||
ColumnConstraintList::const_iterator itr;
|
||||
|
||||
for (itr = column.fConstraints.begin();
|
||||
itr != column.fConstraints.end();
|
||||
++itr)
|
||||
{
|
||||
ColumnConstraintDef* con = *itr;
|
||||
os << *con;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return os;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
ostream &operator<<(ostream& os, const ColumnConstraintDef &con)
|
||||
{
|
||||
os << " Constraint: "
|
||||
<< con.fName << " "
|
||||
<< ConstraintString[con.fConstraintType] << " "
|
||||
<< "defer=" << con.fDeferrable << " "
|
||||
<< ConstraintAttrStrings[con.fCheckTime] << " ";
|
||||
if(!con.fCheck.empty())
|
||||
os << "check=" << "\"" << con.fCheck << "\"";
|
||||
ostream& operator<<(ostream& os, const ColumnConstraintDef& con)
|
||||
{
|
||||
os << " Constraint: "
|
||||
<< con.fName << " "
|
||||
<< ConstraintString[con.fConstraintType] << " "
|
||||
<< "defer=" << con.fDeferrable << " "
|
||||
<< ConstraintAttrStrings[con.fCheckTime] << " ";
|
||||
|
||||
return os;
|
||||
}
|
||||
if (!con.fCheck.empty())
|
||||
os << "check=" << "\"" << con.fCheck << "\"";
|
||||
|
||||
std::ostream &operator<<(std::ostream& os, const ColumnDefList &clist)
|
||||
{
|
||||
ColumnDefList::const_iterator itr;
|
||||
for(itr = clist.begin(); itr != clist.end(); ++itr){
|
||||
os << **itr;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const ColumnDefList& clist)
|
||||
{
|
||||
ColumnDefList::const_iterator itr;
|
||||
|
||||
for (itr = clist.begin(); itr != clist.end(); ++itr)
|
||||
{
|
||||
os << **itr;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
ColumnDefaultValue::ColumnDefaultValue(const char *value) :
|
||||
fNull(false)
|
||||
{
|
||||
if(0 == value)
|
||||
fNull = true;
|
||||
else
|
||||
fValue = value;
|
||||
}
|
||||
ColumnDefaultValue::ColumnDefaultValue(const char* value) :
|
||||
fNull(false)
|
||||
{
|
||||
if (0 == value)
|
||||
fNull = true;
|
||||
else
|
||||
fValue = value;
|
||||
}
|
||||
|
||||
|
||||
std::ostream &operator<<(std::ostream& os, const ColumnDefaultValue &defaultValue)
|
||||
{
|
||||
os << " def=";
|
||||
std::ostream& operator<<(std::ostream& os, const ColumnDefaultValue& defaultValue)
|
||||
{
|
||||
os << " def=";
|
||||
|
||||
if (defaultValue.fNull)
|
||||
os << "NULL";
|
||||
else
|
||||
os << defaultValue.fValue;
|
||||
return os;
|
||||
}
|
||||
if (defaultValue.fNull)
|
||||
os << "NULL";
|
||||
else
|
||||
os << defaultValue.fValue;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,38 +23,39 @@
|
||||
|
||||
#include "ddlpkg.h"
|
||||
|
||||
namespace ddlpackage {
|
||||
using namespace std;
|
||||
namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
CreateIndexStatement::CreateIndexStatement():
|
||||
fIndexName(NULL),
|
||||
fTableName(NULL),
|
||||
fColumnNames(),
|
||||
fUnique(false)
|
||||
{
|
||||
}
|
||||
CreateIndexStatement::CreateIndexStatement():
|
||||
fIndexName(NULL),
|
||||
fTableName(NULL),
|
||||
fColumnNames(),
|
||||
fUnique(false)
|
||||
{
|
||||
}
|
||||
|
||||
CreateIndexStatement::CreateIndexStatement(QualifiedName *indexName, QualifiedName *tableName,
|
||||
ColumnNameList *columnNames, bool unique) :
|
||||
fIndexName(indexName),
|
||||
fTableName(tableName),
|
||||
fColumnNames(*columnNames),
|
||||
fUnique(unique)
|
||||
{
|
||||
delete columnNames;
|
||||
}
|
||||
CreateIndexStatement::CreateIndexStatement(QualifiedName* indexName, QualifiedName* tableName,
|
||||
ColumnNameList* columnNames, bool unique) :
|
||||
fIndexName(indexName),
|
||||
fTableName(tableName),
|
||||
fColumnNames(*columnNames),
|
||||
fUnique(unique)
|
||||
{
|
||||
delete columnNames;
|
||||
}
|
||||
|
||||
CreateIndexStatement::~CreateIndexStatement()
|
||||
{
|
||||
delete fIndexName;
|
||||
delete fTableName;
|
||||
}
|
||||
CreateIndexStatement::~CreateIndexStatement()
|
||||
{
|
||||
delete fIndexName;
|
||||
delete fTableName;
|
||||
}
|
||||
|
||||
std::ostream& CreateIndexStatement::put(std::ostream& os) const
|
||||
{
|
||||
os << "Create Index: " << *fIndexName << " on " << *fTableName
|
||||
<< fColumnNames << endl;
|
||||
return os;
|
||||
}
|
||||
std::ostream& CreateIndexStatement::put(std::ostream& os) const
|
||||
{
|
||||
os << "Create Index: " << *fIndexName << " on " << *fTableName
|
||||
<< fColumnNames << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,34 +27,35 @@
|
||||
#include "ddlpkg.h"
|
||||
#undef DDLPKG_DLLEXPORT
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
using namespace std;
|
||||
|
||||
CreateTableStatement::CreateTableStatement() :
|
||||
fTableDef(0)
|
||||
{
|
||||
}
|
||||
|
||||
CreateTableStatement::CreateTableStatement(TableDef* tableDef) :
|
||||
fTableDef(tableDef)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CreateTableStatement::~CreateTableStatement()
|
||||
{
|
||||
if (fTableDef)
|
||||
{
|
||||
delete fTableDef;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Put to ostream. */
|
||||
ostream& CreateTableStatement::put(ostream& os) const
|
||||
{
|
||||
os << "CreateTable "
|
||||
<< *fTableDef;
|
||||
return os;
|
||||
}
|
||||
CreateTableStatement::CreateTableStatement() :
|
||||
fTableDef(0)
|
||||
{
|
||||
}
|
||||
|
||||
CreateTableStatement::CreateTableStatement(TableDef* tableDef) :
|
||||
fTableDef(tableDef)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CreateTableStatement::~CreateTableStatement()
|
||||
{
|
||||
if (fTableDef)
|
||||
{
|
||||
delete fTableDef;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Put to ostream. */
|
||||
ostream& CreateTableStatement::put(ostream& os) const
|
||||
{
|
||||
os << "CreateTable "
|
||||
<< *fTableDef;
|
||||
return os;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -36,93 +36,94 @@
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
ACTION = 258,
|
||||
ADD = 259,
|
||||
ALTER = 260,
|
||||
AUTO_INCREMENT = 261,
|
||||
BIGINT = 262,
|
||||
BIT = 263,
|
||||
IDB_BLOB = 264,
|
||||
CASCADE = 265,
|
||||
IDB_CHAR = 266,
|
||||
CHARACTER = 267,
|
||||
CHECK = 268,
|
||||
CLOB = 269,
|
||||
COLUMN = 270,
|
||||
COLUMNS = 271,
|
||||
COMMENT = 272,
|
||||
CONSTRAINT = 273,
|
||||
CONSTRAINTS = 274,
|
||||
CREATE = 275,
|
||||
CURRENT_USER = 276,
|
||||
DATETIME = 277,
|
||||
DEC = 278,
|
||||
DECIMAL = 279,
|
||||
DEFAULT = 280,
|
||||
DEFERRABLE = 281,
|
||||
DEFERRED = 282,
|
||||
IDB_DELETE = 283,
|
||||
DROP = 284,
|
||||
ENGINE = 285,
|
||||
FOREIGN = 286,
|
||||
FULL = 287,
|
||||
IMMEDIATE = 288,
|
||||
INDEX = 289,
|
||||
INITIALLY = 290,
|
||||
IDB_INT = 291,
|
||||
INTEGER = 292,
|
||||
KEY = 293,
|
||||
MATCH = 294,
|
||||
MAX_ROWS = 295,
|
||||
MIN_ROWS = 296,
|
||||
MODIFY = 297,
|
||||
NO = 298,
|
||||
NOT = 299,
|
||||
NULL_TOK = 300,
|
||||
NUMBER = 301,
|
||||
NUMERIC = 302,
|
||||
ON = 303,
|
||||
PARTIAL = 304,
|
||||
PRECISION = 305,
|
||||
PRIMARY = 306,
|
||||
REFERENCES = 307,
|
||||
RENAME = 308,
|
||||
RESTRICT = 309,
|
||||
SET = 310,
|
||||
SMALLINT = 311,
|
||||
TABLE = 312,
|
||||
TIME = 313,
|
||||
TINYINT = 314,
|
||||
TO = 315,
|
||||
UNIQUE = 316,
|
||||
UNSIGNED = 317,
|
||||
UPDATE = 318,
|
||||
USER = 319,
|
||||
SESSION_USER = 320,
|
||||
SYSTEM_USER = 321,
|
||||
VARCHAR = 322,
|
||||
VARBINARY = 323,
|
||||
VARYING = 324,
|
||||
WITH = 325,
|
||||
ZONE = 326,
|
||||
DOUBLE = 327,
|
||||
IDB_FLOAT = 328,
|
||||
REAL = 329,
|
||||
CHARSET = 330,
|
||||
IDB_IF = 331,
|
||||
EXISTS = 332,
|
||||
CHANGE = 333,
|
||||
TRUNCATE = 334,
|
||||
IDENT = 335,
|
||||
FCONST = 336,
|
||||
SCONST = 337,
|
||||
CP_SEARCH_CONDITION_TEXT = 338,
|
||||
ICONST = 339,
|
||||
DATE = 340
|
||||
};
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype
|
||||
{
|
||||
ACTION = 258,
|
||||
ADD = 259,
|
||||
ALTER = 260,
|
||||
AUTO_INCREMENT = 261,
|
||||
BIGINT = 262,
|
||||
BIT = 263,
|
||||
IDB_BLOB = 264,
|
||||
CASCADE = 265,
|
||||
IDB_CHAR = 266,
|
||||
CHARACTER = 267,
|
||||
CHECK = 268,
|
||||
CLOB = 269,
|
||||
COLUMN = 270,
|
||||
COLUMNS = 271,
|
||||
COMMENT = 272,
|
||||
CONSTRAINT = 273,
|
||||
CONSTRAINTS = 274,
|
||||
CREATE = 275,
|
||||
CURRENT_USER = 276,
|
||||
DATETIME = 277,
|
||||
DEC = 278,
|
||||
DECIMAL = 279,
|
||||
DEFAULT = 280,
|
||||
DEFERRABLE = 281,
|
||||
DEFERRED = 282,
|
||||
IDB_DELETE = 283,
|
||||
DROP = 284,
|
||||
ENGINE = 285,
|
||||
FOREIGN = 286,
|
||||
FULL = 287,
|
||||
IMMEDIATE = 288,
|
||||
INDEX = 289,
|
||||
INITIALLY = 290,
|
||||
IDB_INT = 291,
|
||||
INTEGER = 292,
|
||||
KEY = 293,
|
||||
MATCH = 294,
|
||||
MAX_ROWS = 295,
|
||||
MIN_ROWS = 296,
|
||||
MODIFY = 297,
|
||||
NO = 298,
|
||||
NOT = 299,
|
||||
NULL_TOK = 300,
|
||||
NUMBER = 301,
|
||||
NUMERIC = 302,
|
||||
ON = 303,
|
||||
PARTIAL = 304,
|
||||
PRECISION = 305,
|
||||
PRIMARY = 306,
|
||||
REFERENCES = 307,
|
||||
RENAME = 308,
|
||||
RESTRICT = 309,
|
||||
SET = 310,
|
||||
SMALLINT = 311,
|
||||
TABLE = 312,
|
||||
TIME = 313,
|
||||
TINYINT = 314,
|
||||
TO = 315,
|
||||
UNIQUE = 316,
|
||||
UNSIGNED = 317,
|
||||
UPDATE = 318,
|
||||
USER = 319,
|
||||
SESSION_USER = 320,
|
||||
SYSTEM_USER = 321,
|
||||
VARCHAR = 322,
|
||||
VARBINARY = 323,
|
||||
VARYING = 324,
|
||||
WITH = 325,
|
||||
ZONE = 326,
|
||||
DOUBLE = 327,
|
||||
IDB_FLOAT = 328,
|
||||
REAL = 329,
|
||||
CHARSET = 330,
|
||||
IDB_IF = 331,
|
||||
EXISTS = 332,
|
||||
CHANGE = 333,
|
||||
TRUNCATE = 334,
|
||||
IDENT = 335,
|
||||
FCONST = 336,
|
||||
SCONST = 337,
|
||||
CP_SEARCH_CONDITION_TEXT = 338,
|
||||
ICONST = 339,
|
||||
DATE = 340
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -132,33 +133,33 @@ typedef union YYSTYPE
|
||||
{
|
||||
|
||||
|
||||
ddlpackage::AlterTableStatement *alterTableStmt;
|
||||
ddlpackage::AlterTableAction *ata;
|
||||
ddlpackage::AlterTableActionList *ataList;
|
||||
ddlpackage::DDL_CONSTRAINT_ATTRIBUTES cattr;
|
||||
std::pair<std::string, std::string> *tableOption;
|
||||
const char *columnOption;
|
||||
ddlpackage::ColumnConstraintDef *columnConstraintDef;
|
||||
ddlpackage::ColumnNameList *columnNameList;
|
||||
ddlpackage::ColumnType* columnType;
|
||||
ddlpackage::ConstraintAttributes *constraintAttributes;
|
||||
ddlpackage::ColumnConstraintList *constraintList;
|
||||
ddlpackage::DDL_CONSTRAINTS constraintType;
|
||||
double dval;
|
||||
bool flag;
|
||||
int ival;
|
||||
ddlpackage::QualifiedName *qualifiedName;
|
||||
ddlpackage::SchemaObject *schemaObject;
|
||||
ddlpackage::SqlStatement *sqlStmt;
|
||||
ddlpackage::SqlStatementList *sqlStmtList;
|
||||
const char *str;
|
||||
ddlpackage::TableConstraintDef *tableConstraint;
|
||||
ddlpackage::TableElementList *tableElementList;
|
||||
ddlpackage::TableOptionMap *tableOptionMap;
|
||||
ddlpackage::ColumnDefaultValue *colDefault;
|
||||
ddlpackage::DDL_MATCH_TYPE matchType;
|
||||
ddlpackage::DDL_REFERENTIAL_ACTION refActionCode;
|
||||
ddlpackage::ReferentialAction *refAction;
|
||||
ddlpackage::AlterTableStatement* alterTableStmt;
|
||||
ddlpackage::AlterTableAction* ata;
|
||||
ddlpackage::AlterTableActionList* ataList;
|
||||
ddlpackage::DDL_CONSTRAINT_ATTRIBUTES cattr;
|
||||
std::pair<std::string, std::string>* tableOption;
|
||||
const char* columnOption;
|
||||
ddlpackage::ColumnConstraintDef* columnConstraintDef;
|
||||
ddlpackage::ColumnNameList* columnNameList;
|
||||
ddlpackage::ColumnType* columnType;
|
||||
ddlpackage::ConstraintAttributes* constraintAttributes;
|
||||
ddlpackage::ColumnConstraintList* constraintList;
|
||||
ddlpackage::DDL_CONSTRAINTS constraintType;
|
||||
double dval;
|
||||
bool flag;
|
||||
int ival;
|
||||
ddlpackage::QualifiedName* qualifiedName;
|
||||
ddlpackage::SchemaObject* schemaObject;
|
||||
ddlpackage::SqlStatement* sqlStmt;
|
||||
ddlpackage::SqlStatementList* sqlStmtList;
|
||||
const char* str;
|
||||
ddlpackage::TableConstraintDef* tableConstraint;
|
||||
ddlpackage::TableElementList* tableElementList;
|
||||
ddlpackage::TableOptionMap* tableOptionMap;
|
||||
ddlpackage::ColumnDefaultValue* colDefault;
|
||||
ddlpackage::DDL_MATCH_TYPE matchType;
|
||||
ddlpackage::DDL_REFERENTIAL_ACTION refActionCode;
|
||||
ddlpackage::ReferentialAction* refAction;
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,180 +29,190 @@
|
||||
|
||||
namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std;
|
||||
|
||||
QualifiedName::QualifiedName(const char *name):
|
||||
fName(name)
|
||||
{
|
||||
}
|
||||
QualifiedName::QualifiedName(const char* name):
|
||||
fName(name)
|
||||
{
|
||||
}
|
||||
|
||||
QualifiedName::QualifiedName(const char *schema, const char *name):
|
||||
fName(name),
|
||||
fSchema(schema)
|
||||
{
|
||||
}
|
||||
QualifiedName::QualifiedName(const char* schema, const char* name):
|
||||
fName(name),
|
||||
fSchema(schema)
|
||||
{
|
||||
}
|
||||
|
||||
QualifiedName::QualifiedName(const char* catalog, const char *schema, const char *name):
|
||||
fCatalog(catalog),
|
||||
fName(name),
|
||||
fSchema(schema)
|
||||
{
|
||||
}
|
||||
QualifiedName::QualifiedName(const char* catalog, const char* schema, const char* name):
|
||||
fCatalog(catalog),
|
||||
fName(name),
|
||||
fSchema(schema)
|
||||
{
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream &os, const QualifiedName& qname)
|
||||
{
|
||||
if(!qname.fCatalog.empty())
|
||||
os << qname.fCatalog << ".";
|
||||
if(!qname.fSchema.empty())
|
||||
os << qname.fSchema << ".";
|
||||
os << qname.fName;
|
||||
return os;
|
||||
}
|
||||
ostream& operator<<(ostream& os, const QualifiedName& qname)
|
||||
{
|
||||
if (!qname.fCatalog.empty())
|
||||
os << qname.fCatalog << ".";
|
||||
|
||||
if (!qname.fSchema.empty())
|
||||
os << qname.fSchema << ".";
|
||||
|
||||
os << qname.fName;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
/** @brief Map a DECIMAL precision to data width in bytes */
|
||||
unsigned int precision_width(unsigned p)
|
||||
{
|
||||
switch(p)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
return 1;
|
||||
case 3:
|
||||
case 4:
|
||||
return 2;
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
return 4;
|
||||
default:
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
|
||||
ColumnType::ColumnType(int prec, int scale) :
|
||||
fType(DDL_INVALID_DATATYPE),
|
||||
fLength(0),
|
||||
fPrecision(prec),
|
||||
fScale(scale),
|
||||
fWithTimezone(false)
|
||||
{
|
||||
fLength = precision_width(fPrecision);
|
||||
}
|
||||
|
||||
ColumnType::ColumnType(int type) :
|
||||
fType(type),
|
||||
fLength(0),
|
||||
fScale(0),
|
||||
fWithTimezone(false)
|
||||
{
|
||||
switch ( type )
|
||||
{
|
||||
case DDL_TINYINT:
|
||||
case DDL_UNSIGNED_TINYINT:
|
||||
fPrecision = 3;
|
||||
break;
|
||||
case DDL_SMALLINT:
|
||||
case DDL_UNSIGNED_SMALLINT:
|
||||
fPrecision = 5;
|
||||
break;
|
||||
case DDL_INT:
|
||||
case DDL_UNSIGNED_INT:
|
||||
case DDL_MEDINT:
|
||||
fPrecision = 10;
|
||||
break;
|
||||
case DDL_BIGINT:
|
||||
fPrecision = 19;
|
||||
case DDL_UNSIGNED_BIGINT:
|
||||
fPrecision = 20;
|
||||
break;
|
||||
default:
|
||||
fPrecision = 10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
ColumnType::ColumnType(int type, int length, int precision, int scale, int compressiontype, const char* autoIncrement, int64_t nextValue, bool withTimezone) :
|
||||
fType(type) ,
|
||||
fLength(length),
|
||||
fPrecision(precision),
|
||||
fScale(scale),
|
||||
fWithTimezone(withTimezone),
|
||||
fCompressiontype(compressiontype),
|
||||
fAutoincrement(autoIncrement),
|
||||
fNextvalue(nextValue)
|
||||
/** @brief Map a DECIMAL precision to data width in bytes */
|
||||
unsigned int precision_width(unsigned p)
|
||||
{
|
||||
switch (p)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
ColumnConstraintDef::ColumnConstraintDef(DDL_CONSTRAINTS type) :
|
||||
SchemaObject(),
|
||||
fDeferrable(false),
|
||||
fCheckTime(DDL_INITIALLY_IMMEDIATE),
|
||||
fConstraintType(type),
|
||||
fCheck("")
|
||||
{
|
||||
}
|
||||
case 1:
|
||||
case 2:
|
||||
return 1;
|
||||
|
||||
ColumnConstraintDef::ColumnConstraintDef(const char *check) :
|
||||
SchemaObject(),
|
||||
fDeferrable(false),
|
||||
fCheckTime(DDL_INITIALLY_IMMEDIATE),
|
||||
fConstraintType(DDL_CHECK),
|
||||
fCheck(check)
|
||||
{
|
||||
}
|
||||
case 3:
|
||||
case 4:
|
||||
return 2;
|
||||
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
return 4;
|
||||
|
||||
AtaAddColumn::AtaAddColumn(ColumnDef *columnDef) :
|
||||
fColumnDef(columnDef)
|
||||
{
|
||||
}
|
||||
|
||||
ostream &operator<<(ostream& os, const ReferentialAction& ref)
|
||||
{
|
||||
os << "ref action: u=" << ReferentialActionStrings[ref.fOnUpdate] << " "
|
||||
<< "d=" << ReferentialActionStrings[ref.fOnDelete];
|
||||
return os;
|
||||
}
|
||||
|
||||
void ColumnDef::convertDecimal()
|
||||
{
|
||||
//@Bug 2089 decimal precision default to 10 if 0 is used.
|
||||
if (fType->fPrecision <= 0)
|
||||
fType->fPrecision = 10;
|
||||
|
||||
if (fType->fPrecision == -1 || fType->fPrecision == 0)
|
||||
{
|
||||
fType->fType = DDL_BIGINT;
|
||||
fType->fLength = 8;
|
||||
fType->fScale = 0;
|
||||
}
|
||||
else if ((fType->fPrecision > 0) && (fType->fPrecision < 3))
|
||||
{
|
||||
//dataType = CalpontSystemCatalog::TINYINT;
|
||||
fType->fType = DDL_TINYINT;
|
||||
fType->fLength = 1;
|
||||
}
|
||||
|
||||
else if (fType->fPrecision < 5 && (fType->fPrecision > 2))
|
||||
{
|
||||
//dataType = CalpontSystemCatalog::SMALLINT;
|
||||
fType->fType = DDL_SMALLINT;
|
||||
fType->fLength = 2;
|
||||
}
|
||||
else if (fType->fPrecision > 4 && fType->fPrecision < 10)
|
||||
{
|
||||
//dataType = CalpontSystemCatalog::INT;
|
||||
fType->fType = DDL_INT;
|
||||
fType->fLength = 4;
|
||||
}
|
||||
else if (fType->fPrecision > 9 && fType->fPrecision < 19)
|
||||
{
|
||||
//dataType = CalpontSystemCatalog::BIGINT;
|
||||
fType->fType = DDL_BIGINT;
|
||||
fType->fLength = 8;
|
||||
}
|
||||
default:
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
|
||||
ColumnType::ColumnType(int prec, int scale) :
|
||||
fType(DDL_INVALID_DATATYPE),
|
||||
fLength(0),
|
||||
fPrecision(prec),
|
||||
fScale(scale),
|
||||
fWithTimezone(false)
|
||||
{
|
||||
fLength = precision_width(fPrecision);
|
||||
}
|
||||
|
||||
ColumnType::ColumnType(int type) :
|
||||
fType(type),
|
||||
fLength(0),
|
||||
fScale(0),
|
||||
fWithTimezone(false)
|
||||
{
|
||||
switch ( type )
|
||||
{
|
||||
case DDL_TINYINT:
|
||||
case DDL_UNSIGNED_TINYINT:
|
||||
fPrecision = 3;
|
||||
break;
|
||||
|
||||
case DDL_SMALLINT:
|
||||
case DDL_UNSIGNED_SMALLINT:
|
||||
fPrecision = 5;
|
||||
break;
|
||||
|
||||
case DDL_INT:
|
||||
case DDL_UNSIGNED_INT:
|
||||
case DDL_MEDINT:
|
||||
fPrecision = 10;
|
||||
break;
|
||||
|
||||
case DDL_BIGINT:
|
||||
fPrecision = 19;
|
||||
|
||||
case DDL_UNSIGNED_BIGINT:
|
||||
fPrecision = 20;
|
||||
break;
|
||||
|
||||
default:
|
||||
fPrecision = 10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
ColumnType::ColumnType(int type, int length, int precision, int scale, int compressiontype, const char* autoIncrement, int64_t nextValue, bool withTimezone) :
|
||||
fType(type),
|
||||
fLength(length),
|
||||
fPrecision(precision),
|
||||
fScale(scale),
|
||||
fWithTimezone(withTimezone),
|
||||
fCompressiontype(compressiontype),
|
||||
fAutoincrement(autoIncrement),
|
||||
fNextvalue(nextValue)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
ColumnConstraintDef::ColumnConstraintDef(DDL_CONSTRAINTS type) :
|
||||
SchemaObject(),
|
||||
fDeferrable(false),
|
||||
fCheckTime(DDL_INITIALLY_IMMEDIATE),
|
||||
fConstraintType(type),
|
||||
fCheck("")
|
||||
{
|
||||
}
|
||||
|
||||
ColumnConstraintDef::ColumnConstraintDef(const char* check) :
|
||||
SchemaObject(),
|
||||
fDeferrable(false),
|
||||
fCheckTime(DDL_INITIALLY_IMMEDIATE),
|
||||
fConstraintType(DDL_CHECK),
|
||||
fCheck(check)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AtaAddColumn::AtaAddColumn(ColumnDef* columnDef) :
|
||||
fColumnDef(columnDef)
|
||||
{
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& os, const ReferentialAction& ref)
|
||||
{
|
||||
os << "ref action: u=" << ReferentialActionStrings[ref.fOnUpdate] << " "
|
||||
<< "d=" << ReferentialActionStrings[ref.fOnDelete];
|
||||
return os;
|
||||
}
|
||||
|
||||
void ColumnDef::convertDecimal()
|
||||
{
|
||||
//@Bug 2089 decimal precision default to 10 if 0 is used.
|
||||
if (fType->fPrecision <= 0)
|
||||
fType->fPrecision = 10;
|
||||
|
||||
if (fType->fPrecision == -1 || fType->fPrecision == 0)
|
||||
{
|
||||
fType->fType = DDL_BIGINT;
|
||||
fType->fLength = 8;
|
||||
fType->fScale = 0;
|
||||
}
|
||||
else if ((fType->fPrecision > 0) && (fType->fPrecision < 3))
|
||||
{
|
||||
//dataType = CalpontSystemCatalog::TINYINT;
|
||||
fType->fType = DDL_TINYINT;
|
||||
fType->fLength = 1;
|
||||
}
|
||||
|
||||
else if (fType->fPrecision < 5 && (fType->fPrecision > 2))
|
||||
{
|
||||
//dataType = CalpontSystemCatalog::SMALLINT;
|
||||
fType->fType = DDL_SMALLINT;
|
||||
fType->fLength = 2;
|
||||
}
|
||||
else if (fType->fPrecision > 4 && fType->fPrecision < 10)
|
||||
{
|
||||
//dataType = CalpontSystemCatalog::INT;
|
||||
fType->fType = DDL_INT;
|
||||
fType->fLength = 4;
|
||||
}
|
||||
else if (fType->fPrecision > 9 && fType->fPrecision < 19)
|
||||
{
|
||||
//dataType = CalpontSystemCatalog::BIGINT;
|
||||
fType->fType = DDL_BIGINT;
|
||||
fType->fLength = 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,23 +23,24 @@
|
||||
|
||||
#include "ddlpkg.h"
|
||||
|
||||
namespace ddlpackage {
|
||||
using namespace std;
|
||||
namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
DropIndexStatement::~DropIndexStatement()
|
||||
{
|
||||
delete fIndexName;
|
||||
}
|
||||
DropIndexStatement::~DropIndexStatement()
|
||||
{
|
||||
delete fIndexName;
|
||||
}
|
||||
|
||||
DropIndexStatement::DropIndexStatement(QualifiedName *qualifiedName) :
|
||||
fIndexName(qualifiedName)
|
||||
{
|
||||
}
|
||||
DropIndexStatement::DropIndexStatement(QualifiedName* qualifiedName) :
|
||||
fIndexName(qualifiedName)
|
||||
{
|
||||
}
|
||||
|
||||
std::ostream& DropIndexStatement::put(std::ostream& os) const
|
||||
{
|
||||
os << "Drop Index: " << *fIndexName << endl;
|
||||
return os;
|
||||
}
|
||||
std::ostream& DropIndexStatement::put(std::ostream& os) const
|
||||
{
|
||||
os << "Drop Index: " << *fIndexName << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,22 +27,25 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
DropPartitionStatement::DropPartitionStatement(QualifiedName *qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
DropPartitionStatement::DropPartitionStatement(QualifiedName* qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
{
|
||||
}
|
||||
|
||||
ostream& DropPartitionStatement::put(ostream& os) const
|
||||
{
|
||||
os << "Mark partitions out of service: " << *fTableName << endl;
|
||||
os << " partitions: ";
|
||||
set<BRM::LogicalPartition>::const_iterator it;
|
||||
for (it=fPartitions.begin(); it!=fPartitions.end(); ++it)
|
||||
os << (*it) << " ";
|
||||
os << endl;
|
||||
return os;
|
||||
os << "Mark partitions out of service: " << *fTableName << endl;
|
||||
os << " partitions: ";
|
||||
set<BRM::LogicalPartition>::const_iterator it;
|
||||
|
||||
for (it = fPartitions.begin(); it != fPartitions.end(); ++it)
|
||||
os << (*it) << " ";
|
||||
|
||||
os << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,29 +27,30 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
DropTableStatement::DropTableStatement(QualifiedName *qualifiedName, bool cascade) :
|
||||
fTableName(qualifiedName),
|
||||
fCascade(cascade)
|
||||
DropTableStatement::DropTableStatement(QualifiedName* qualifiedName, bool cascade) :
|
||||
fTableName(qualifiedName),
|
||||
fCascade(cascade)
|
||||
{
|
||||
}
|
||||
|
||||
ostream& DropTableStatement::put(ostream& os) const
|
||||
{
|
||||
os << "Drop Table: " << *fTableName << " " << "C=" << fCascade << endl;
|
||||
return os;
|
||||
os << "Drop Table: " << *fTableName << " " << "C=" << fCascade << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
TruncTableStatement::TruncTableStatement(QualifiedName *qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
TruncTableStatement::TruncTableStatement(QualifiedName* qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
{
|
||||
}
|
||||
|
||||
ostream& TruncTableStatement::put(ostream& os) const
|
||||
{
|
||||
os << "Truncate Table: " << *fTableName << endl;
|
||||
return os;
|
||||
os << "Truncate Table: " << *fTableName << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,44 +31,48 @@ namespace po = boost::program_options;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
string sqlfile;
|
||||
int count;
|
||||
string sqlfile;
|
||||
int count;
|
||||
|
||||
po::options_description desc ("Allowed options");
|
||||
desc.add_options ()
|
||||
("help", "produce help message")
|
||||
("bisond", /* po::value <string>(),*/ "Have bison produce debug output")
|
||||
("count", po::value <int>(), "number of runs")
|
||||
("sql", po::value < string > (), "sql file");
|
||||
po::variables_map vm;
|
||||
po::store (po::parse_command_line (argc, argv, desc), vm);
|
||||
po::notify (vm);
|
||||
if (vm.count ("sql"))
|
||||
sqlfile = vm["sql"].as <string> ();
|
||||
po::options_description desc ("Allowed options");
|
||||
desc.add_options ()
|
||||
("help", "produce help message")
|
||||
("bisond", /* po::value <string>(),*/ "Have bison produce debug output")
|
||||
("count", po::value <int>(), "number of runs")
|
||||
("sql", po::value < string > (), "sql file");
|
||||
po::variables_map vm;
|
||||
po::store (po::parse_command_line (argc, argv, desc), vm);
|
||||
po::notify (vm);
|
||||
|
||||
if (vm.count ("sql"))
|
||||
sqlfile = vm["sql"].as <string> ();
|
||||
|
||||
|
||||
if (vm.count("count"))
|
||||
count = vm["count"].as<int>();
|
||||
if (vm.count("count"))
|
||||
count = vm["count"].as<int>();
|
||||
|
||||
SqlFileParser parser;
|
||||
if (vm.count ("bisond"))
|
||||
parser.SetDebug(true);
|
||||
SqlFileParser parser;
|
||||
|
||||
parser.Parse(sqlfile);
|
||||
if (vm.count ("bisond"))
|
||||
parser.SetDebug(true);
|
||||
|
||||
if(parser.Good()) {
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
parser.Parse(sqlfile);
|
||||
|
||||
cout << "Parser succeeded." << endl;
|
||||
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
||||
cout << ptree;
|
||||
cout << endl;
|
||||
}
|
||||
else {
|
||||
cout << "Parser failed." << endl;
|
||||
}
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
return parser.Good() ? 0 : -1;
|
||||
cout << "Parser succeeded." << endl;
|
||||
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
||||
cout << ptree;
|
||||
cout << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Parser failed." << endl;
|
||||
}
|
||||
|
||||
return parser.Good() ? 0 : -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,22 +27,25 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
MarkPartitionStatement::MarkPartitionStatement(QualifiedName *qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
MarkPartitionStatement::MarkPartitionStatement(QualifiedName* qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
{
|
||||
}
|
||||
|
||||
ostream& MarkPartitionStatement::put(ostream& os) const
|
||||
{
|
||||
os << "Mark partition out of service: " << *fTableName;
|
||||
os << " partitions: ";
|
||||
set<BRM::LogicalPartition>::const_iterator it;
|
||||
for (it=fPartitions.begin(); it!=fPartitions.end(); ++it)
|
||||
os << (*it) << " ";
|
||||
os << endl;
|
||||
return os;
|
||||
os << "Mark partition out of service: " << *fTableName;
|
||||
os << " partitions: ";
|
||||
set<BRM::LogicalPartition>::const_iterator it;
|
||||
|
||||
for (it = fPartitions.begin(); it != fPartitions.end(); ++it)
|
||||
os << (*it) << " ";
|
||||
|
||||
os << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,22 +27,25 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
RestorePartitionStatement::RestorePartitionStatement(QualifiedName *qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
RestorePartitionStatement::RestorePartitionStatement(QualifiedName* qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
{
|
||||
}
|
||||
|
||||
ostream& RestorePartitionStatement::put(ostream& os) const
|
||||
{
|
||||
os << "Mark partition out of service: " << *fTableName;
|
||||
os << " partitions: ";
|
||||
set<BRM::LogicalPartition>::const_iterator it;
|
||||
for (it=fPartitions.begin(); it!=fPartitions.end(); ++it)
|
||||
os << (*it) << " ";
|
||||
os << endl;
|
||||
return os;
|
||||
os << "Mark partition out of service: " << *fTableName;
|
||||
os << " partitions: ";
|
||||
set<BRM::LogicalPartition>::const_iterator it;
|
||||
|
||||
for (it = fPartitions.begin(); it != fPartitions.end(); ++it)
|
||||
os << (*it) << " ";
|
||||
|
||||
os << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -36,102 +36,108 @@
|
||||
#endif
|
||||
|
||||
void scanner_finish(void* yyscanner);
|
||||
void scanner_init(const char *str, void* yyscanner);
|
||||
int ddllex_init_extra(void* user_defined,void** yyscanner);
|
||||
void scanner_init(const char* str, void* yyscanner);
|
||||
int ddllex_init_extra(void* user_defined, void** yyscanner);
|
||||
int ddllex_destroy(void* yyscanner);
|
||||
int ddlparse(ddlpackage::pass_to_bison* x);
|
||||
void set_schema(std::string schema);
|
||||
namespace ddlpackage {
|
||||
using namespace std;
|
||||
namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
SqlParser::SqlParser() :
|
||||
fStatus(-1),
|
||||
fDebug(false),
|
||||
x(&fParseTree)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SqlParser::SetDebug(bool debug)
|
||||
{
|
||||
fDebug = debug;
|
||||
}
|
||||
|
||||
void SqlParser::setDefaultSchema(std::string schema)
|
||||
{
|
||||
x.fDBSchema=schema;
|
||||
}
|
||||
|
||||
int SqlParser::Parse(const char* sqltext)
|
||||
{
|
||||
ddllex_init_extra(&scanData, &x.scanner);
|
||||
scanner_init(sqltext, x.scanner);
|
||||
fStatus = ddlparse(&x);
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
|
||||
const ParseTree& SqlParser::GetParseTree(void)
|
||||
{
|
||||
if(!Good()) {
|
||||
throw logic_error("The ParseTree is invalid");
|
||||
}
|
||||
return fParseTree;
|
||||
}
|
||||
|
||||
|
||||
bool SqlParser::Good()
|
||||
{
|
||||
return fStatus == 0;
|
||||
}
|
||||
|
||||
|
||||
SqlParser::~SqlParser()
|
||||
{
|
||||
scanner_finish(x.scanner); // free scanner allocated memory
|
||||
ddllex_destroy(x.scanner);
|
||||
}
|
||||
|
||||
|
||||
SqlFileParser::SqlFileParser() :
|
||||
SqlParser()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int SqlFileParser::Parse(const string& sqlfile)
|
||||
{
|
||||
fStatus = -1;
|
||||
|
||||
ifstream ifsql;
|
||||
ifsql.open(sqlfile.c_str());
|
||||
if(!ifsql.is_open()) {
|
||||
perror(sqlfile.c_str());
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
char sqlbuf[1024*1024];
|
||||
unsigned length;
|
||||
ifsql.seekg (0, ios::end);
|
||||
length = ifsql.tellg();
|
||||
ifsql.seekg (0, ios::beg);
|
||||
|
||||
if(length > sizeof(sqlbuf) - 1) {
|
||||
throw length_error("SqlFileParser has file size hard limit of 16K.");
|
||||
}
|
||||
|
||||
unsigned rcount;
|
||||
rcount = ifsql.readsome(sqlbuf, sizeof(sqlbuf) - 1);
|
||||
|
||||
if(rcount < 0)
|
||||
return fStatus;
|
||||
|
||||
sqlbuf[rcount] = 0;
|
||||
|
||||
//cout << endl << sqlfile << "(" << rcount << ")" << endl;
|
||||
//cout << "----------------------" << endl;
|
||||
//cout << sqlbuf << endl;
|
||||
|
||||
return SqlParser::Parse(sqlbuf);
|
||||
}
|
||||
SqlParser::SqlParser() :
|
||||
fStatus(-1),
|
||||
fDebug(false),
|
||||
x(&fParseTree)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SqlParser::SetDebug(bool debug)
|
||||
{
|
||||
fDebug = debug;
|
||||
}
|
||||
|
||||
void SqlParser::setDefaultSchema(std::string schema)
|
||||
{
|
||||
x.fDBSchema = schema;
|
||||
}
|
||||
|
||||
int SqlParser::Parse(const char* sqltext)
|
||||
{
|
||||
ddllex_init_extra(&scanData, &x.scanner);
|
||||
scanner_init(sqltext, x.scanner);
|
||||
fStatus = ddlparse(&x);
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
|
||||
const ParseTree& SqlParser::GetParseTree(void)
|
||||
{
|
||||
if (!Good())
|
||||
{
|
||||
throw logic_error("The ParseTree is invalid");
|
||||
}
|
||||
|
||||
return fParseTree;
|
||||
}
|
||||
|
||||
|
||||
bool SqlParser::Good()
|
||||
{
|
||||
return fStatus == 0;
|
||||
}
|
||||
|
||||
|
||||
SqlParser::~SqlParser()
|
||||
{
|
||||
scanner_finish(x.scanner); // free scanner allocated memory
|
||||
ddllex_destroy(x.scanner);
|
||||
}
|
||||
|
||||
|
||||
SqlFileParser::SqlFileParser() :
|
||||
SqlParser()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int SqlFileParser::Parse(const string& sqlfile)
|
||||
{
|
||||
fStatus = -1;
|
||||
|
||||
ifstream ifsql;
|
||||
ifsql.open(sqlfile.c_str());
|
||||
|
||||
if (!ifsql.is_open())
|
||||
{
|
||||
perror(sqlfile.c_str());
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
char sqlbuf[1024 * 1024];
|
||||
unsigned length;
|
||||
ifsql.seekg (0, ios::end);
|
||||
length = ifsql.tellg();
|
||||
ifsql.seekg (0, ios::beg);
|
||||
|
||||
if (length > sizeof(sqlbuf) - 1)
|
||||
{
|
||||
throw length_error("SqlFileParser has file size hard limit of 16K.");
|
||||
}
|
||||
|
||||
unsigned rcount;
|
||||
rcount = ifsql.readsome(sqlbuf, sizeof(sqlbuf) - 1);
|
||||
|
||||
if (rcount < 0)
|
||||
return fStatus;
|
||||
|
||||
sqlbuf[rcount] = 0;
|
||||
|
||||
//cout << endl << sqlfile << "(" << rcount << ")" << endl;
|
||||
//cout << "----------------------" << endl;
|
||||
//cout << sqlbuf << endl;
|
||||
|
||||
return SqlParser::Parse(sqlbuf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,18 +75,19 @@ typedef std::vector<char*> valbuf_t;
|
||||
|
||||
struct scan_data
|
||||
{
|
||||
/* Handles to the buffer that the lexer uses internally */
|
||||
char* scanbuf;
|
||||
void* scanbufhandle; // This is a YY_BUFFER_STATE defined in ddl-scan.cpp
|
||||
valbuf_t valbuf;
|
||||
/* Handles to the buffer that the lexer uses internally */
|
||||
char* scanbuf;
|
||||
void* scanbufhandle; // This is a YY_BUFFER_STATE defined in ddl-scan.cpp
|
||||
valbuf_t valbuf;
|
||||
};
|
||||
|
||||
struct pass_to_bison {
|
||||
struct pass_to_bison
|
||||
{
|
||||
ParseTree* fParseTree;
|
||||
std::string fDBSchema;
|
||||
void* scanner;
|
||||
void* scanner;
|
||||
|
||||
pass_to_bison(ParseTree* pt) : fParseTree(pt), scanner(NULL) {};
|
||||
pass_to_bison(ParseTree* pt) : fParseTree(pt), scanner(NULL) {};
|
||||
};
|
||||
|
||||
class SqlParser
|
||||
@@ -108,24 +109,24 @@ public:
|
||||
*/
|
||||
EXPORT bool Good(void);
|
||||
|
||||
/** @brief Control bison debugging
|
||||
*/
|
||||
/** @brief Control bison debugging
|
||||
*/
|
||||
EXPORT void SetDebug(bool debug);
|
||||
|
||||
/** @brief Set the default schema to use if it is not
|
||||
* supplied in the DDL statement
|
||||
*
|
||||
* @param schema the default schema
|
||||
*/
|
||||
/** @brief Set the default schema to use if it is not
|
||||
* supplied in the DDL statement
|
||||
*
|
||||
* @param schema the default schema
|
||||
*/
|
||||
EXPORT void setDefaultSchema(std::string schema);
|
||||
|
||||
protected:
|
||||
ParseTree fParseTree;
|
||||
std::string fDBSchema;
|
||||
std::string fDBSchema;
|
||||
int fStatus; ///< return from yyparse() stored here.
|
||||
bool fDebug; ///< Turn on bison debugging.
|
||||
scan_data scanData;
|
||||
pass_to_bison x;
|
||||
scan_data scanData;
|
||||
pass_to_bison x;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -25,22 +25,23 @@
|
||||
#include "ddlpkg.h"
|
||||
#undef DDLPKG_DLLEXPORT
|
||||
|
||||
namespace ddlpackage {
|
||||
using namespace std;
|
||||
namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
static uint32_t sessionID = 1;
|
||||
static uint32_t sessionID = 1;
|
||||
|
||||
SqlStatement::SqlStatement()
|
||||
{
|
||||
fSessionID = sessionID;
|
||||
}
|
||||
|
||||
SqlStatement::~SqlStatement()
|
||||
{
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream &os, const SqlStatement& stmt)
|
||||
{
|
||||
return stmt.put(os);
|
||||
}
|
||||
SqlStatement::SqlStatement()
|
||||
{
|
||||
fSessionID = sessionID;
|
||||
}
|
||||
|
||||
SqlStatement::~SqlStatement()
|
||||
{
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& os, const SqlStatement& stmt)
|
||||
{
|
||||
return stmt.put(os);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,34 +25,39 @@
|
||||
#include "ddlpkg.h"
|
||||
#undef DDLPKG_DLLEXPORT
|
||||
|
||||
namespace ddlpackage {
|
||||
using namespace std;
|
||||
namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
|
||||
ostream &operator<<(ostream& os, const SqlStatementList &ssl)
|
||||
{
|
||||
vector<SqlStatement*>::const_iterator itr;
|
||||
ostream& operator<<(ostream& os, const SqlStatementList& ssl)
|
||||
{
|
||||
vector<SqlStatement*>::const_iterator itr;
|
||||
|
||||
for(itr = ssl.fList.begin(); itr != ssl.fList.end(); ++itr) {
|
||||
SqlStatement &stmt = **itr;
|
||||
os << stmt;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
for (itr = ssl.fList.begin(); itr != ssl.fList.end(); ++itr)
|
||||
{
|
||||
SqlStatement& stmt = **itr;
|
||||
os << stmt;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
void SqlStatementList::push_back(SqlStatement* v)
|
||||
{
|
||||
fList.push_back(v);
|
||||
}
|
||||
void SqlStatementList::push_back(SqlStatement* v)
|
||||
{
|
||||
fList.push_back(v);
|
||||
}
|
||||
|
||||
|
||||
SqlStatementList::~SqlStatementList()
|
||||
{
|
||||
vector<SqlStatement*>::iterator itr;
|
||||
for(itr = fList.begin(); itr != fList.end(); ++itr) {
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
SqlStatementList::~SqlStatementList()
|
||||
{
|
||||
vector<SqlStatement*>::iterator itr;
|
||||
|
||||
for (itr = fList.begin(); itr != fList.end(); ++itr)
|
||||
{
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,266 +28,295 @@
|
||||
|
||||
namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std;
|
||||
|
||||
|
||||
TableDef::~TableDef()
|
||||
{
|
||||
{
|
||||
ColumnDefList::iterator itr;
|
||||
for(itr=fColumns.begin(); itr != fColumns.end(); itr++) {
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
{
|
||||
TableConstraintDefList::iterator itr;
|
||||
for(itr=fConstraints.begin(); itr != fConstraints.end(); itr++) {
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
TableDef::~TableDef()
|
||||
{
|
||||
{
|
||||
ColumnDefList::iterator itr;
|
||||
|
||||
delete fQualifiedName;
|
||||
}
|
||||
for (itr = fColumns.begin(); itr != fColumns.end(); itr++)
|
||||
{
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
{
|
||||
TableConstraintDefList::iterator itr;
|
||||
|
||||
for (itr = fConstraints.begin(); itr != fConstraints.end(); itr++)
|
||||
{
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
|
||||
delete fQualifiedName;
|
||||
}
|
||||
|
||||
|
||||
TableDef::TableDef(QualifiedName* name, TableElementList* elements, TableOptionMap* options) :
|
||||
fQualifiedName(name)
|
||||
{
|
||||
if(options) {
|
||||
fOptions = *options;
|
||||
delete options;
|
||||
}
|
||||
TableDef::TableDef(QualifiedName* name, TableElementList* elements, TableOptionMap* options) :
|
||||
fQualifiedName(name)
|
||||
{
|
||||
if (options)
|
||||
{
|
||||
fOptions = *options;
|
||||
delete options;
|
||||
}
|
||||
|
||||
ColumnDef *column;
|
||||
TableConstraintDef *constraint;
|
||||
ColumnDef* column;
|
||||
TableConstraintDef* constraint;
|
||||
|
||||
/* When parsing, it is necessary to collect ColumnDefs and
|
||||
TableConstraintDefs as TableElements. Here we separate
|
||||
them out into separately typed lists.
|
||||
*/
|
||||
TableElementList::iterator itr;
|
||||
for(itr = elements->begin(); itr != elements->end(); ++itr) {
|
||||
column = dynamic_cast<ColumnDef*>(*itr);
|
||||
if(column) {
|
||||
fColumns.push_back(column);
|
||||
}
|
||||
else {
|
||||
constraint = dynamic_cast<TableConstraintDef *>(*itr);
|
||||
if(constraint) {
|
||||
fConstraints.push_back(constraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* When parsing, it is necessary to collect ColumnDefs and
|
||||
TableConstraintDefs as TableElements. Here we separate
|
||||
them out into separately typed lists.
|
||||
*/
|
||||
TableElementList::iterator itr;
|
||||
|
||||
delete elements;
|
||||
}
|
||||
for (itr = elements->begin(); itr != elements->end(); ++itr)
|
||||
{
|
||||
column = dynamic_cast<ColumnDef*>(*itr);
|
||||
|
||||
if (column)
|
||||
{
|
||||
fColumns.push_back(column);
|
||||
}
|
||||
else
|
||||
{
|
||||
constraint = dynamic_cast<TableConstraintDef*>(*itr);
|
||||
|
||||
if (constraint)
|
||||
{
|
||||
fConstraints.push_back(constraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete elements;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Put to ostream. */
|
||||
ostream& operator<<(ostream& os, const TableDef& tableDef)
|
||||
{
|
||||
os << "CreateTable ";
|
||||
if(tableDef.fQualifiedName->fSchema != "")
|
||||
//cout << tableDef.fQualifiedName->fSchema << ".";
|
||||
os << tableDef.fQualifiedName->fName
|
||||
<< " " << tableDef.fConstraints.size()
|
||||
<< " table constraints"
|
||||
<< endl;
|
||||
/** \brief Put to ostream. */
|
||||
ostream& operator<<(ostream& os, const TableDef& tableDef)
|
||||
{
|
||||
os << "CreateTable ";
|
||||
|
||||
{
|
||||
ColumnDefList::const_iterator itr;
|
||||
for(itr = tableDef.fColumns.begin();
|
||||
itr != tableDef.fColumns.end(); ++itr)
|
||||
{
|
||||
ColumnDef* col = *itr;
|
||||
os << *col << endl;
|
||||
}
|
||||
}
|
||||
if (tableDef.fQualifiedName->fSchema != "")
|
||||
//cout << tableDef.fQualifiedName->fSchema << ".";
|
||||
os << tableDef.fQualifiedName->fName
|
||||
<< " " << tableDef.fConstraints.size()
|
||||
<< " table constraints"
|
||||
<< endl;
|
||||
|
||||
{
|
||||
ColumnDefList::const_iterator itr;
|
||||
|
||||
for (itr = tableDef.fColumns.begin();
|
||||
itr != tableDef.fColumns.end(); ++itr)
|
||||
{
|
||||
ColumnDef* col = *itr;
|
||||
os << *col << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
TableConstraintDefList::const_iterator itr;
|
||||
for(itr = tableDef.fConstraints.begin();
|
||||
itr != tableDef.fConstraints.end();
|
||||
++itr)
|
||||
{
|
||||
os << (**itr);
|
||||
}
|
||||
}
|
||||
{
|
||||
TableConstraintDefList::const_iterator itr;
|
||||
|
||||
pair<string, string> oval;
|
||||
TableOptionMap::const_iterator oitr;
|
||||
os << "Table Options" << endl;
|
||||
if(!tableDef.fOptions.empty()) {
|
||||
TableOptionMap::const_iterator oitr;
|
||||
for(oitr = tableDef.fOptions.begin();
|
||||
oitr != tableDef.fOptions.end(); ++oitr) {
|
||||
oval = *oitr;
|
||||
os << " " << oval.first << "=" << oval.second << endl;
|
||||
}
|
||||
}
|
||||
for (itr = tableDef.fConstraints.begin();
|
||||
itr != tableDef.fConstraints.end();
|
||||
++itr)
|
||||
{
|
||||
os << (**itr);
|
||||
}
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
pair<string, string> oval;
|
||||
TableOptionMap::const_iterator oitr;
|
||||
os << "Table Options" << endl;
|
||||
|
||||
if (!tableDef.fOptions.empty())
|
||||
{
|
||||
TableOptionMap::const_iterator oitr;
|
||||
|
||||
for (oitr = tableDef.fOptions.begin();
|
||||
oitr != tableDef.fOptions.end(); ++oitr)
|
||||
{
|
||||
oval = *oitr;
|
||||
os << " " << oval.first << "=" << oval.second << endl;
|
||||
}
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ostream& operator<<(ostream &os, const TableConstraintDef& constraint)
|
||||
{
|
||||
return constraint.put(os);
|
||||
}
|
||||
ostream& operator<<(ostream& os, const TableConstraintDef& constraint)
|
||||
{
|
||||
return constraint.put(os);
|
||||
}
|
||||
|
||||
std::ostream& TableConstraintDef::put(std::ostream& os) const
|
||||
{
|
||||
os << "No!!!" << endl;
|
||||
std::ostream& TableConstraintDef::put(std::ostream& os) const
|
||||
{
|
||||
os << "No!!!" << endl;
|
||||
|
||||
return os;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
TableConstraintDef::TableConstraintDef(DDL_CONSTRAINTS cType) :
|
||||
fConstraintType(cType)
|
||||
{
|
||||
}
|
||||
TableConstraintDef::TableConstraintDef(DDL_CONSTRAINTS cType) :
|
||||
fConstraintType(cType)
|
||||
{
|
||||
}
|
||||
|
||||
TableConstraintDef::TableConstraintDef() :
|
||||
fConstraintType(DDL_INVALID_CONSTRAINT)
|
||||
{
|
||||
}
|
||||
TableConstraintDef::TableConstraintDef() :
|
||||
fConstraintType(DDL_INVALID_CONSTRAINT)
|
||||
{
|
||||
}
|
||||
|
||||
TableCheckConstraintDef::TableCheckConstraintDef(const char *check) :
|
||||
TableConstraintDef(DDL_CHECK),
|
||||
fCheck(check)
|
||||
{
|
||||
}
|
||||
std::ostream& TableCheckConstraintDef::put(std::ostream& os) const
|
||||
{
|
||||
os << "Constraint: "
|
||||
<< ConstraintString[fConstraintType] << " ";
|
||||
os << "\"" << fCheck << "\"";
|
||||
os << endl;
|
||||
TableCheckConstraintDef::TableCheckConstraintDef(const char* check) :
|
||||
TableConstraintDef(DDL_CHECK),
|
||||
fCheck(check)
|
||||
{
|
||||
}
|
||||
std::ostream& TableCheckConstraintDef::put(std::ostream& os) const
|
||||
{
|
||||
os << "Constraint: "
|
||||
<< ConstraintString[fConstraintType] << " ";
|
||||
os << "\"" << fCheck << "\"";
|
||||
os << endl;
|
||||
|
||||
return os;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
TableUniqueConstraintDef::TableUniqueConstraintDef(ColumnNameList *columns) :
|
||||
TableConstraintDef(DDL_UNIQUE),
|
||||
fColumnNameList(*columns)
|
||||
{
|
||||
delete columns;
|
||||
}
|
||||
std::ostream& TableUniqueConstraintDef::put(std::ostream& os) const
|
||||
{
|
||||
os << "Constraint: "
|
||||
<< fName << " "
|
||||
<< ConstraintString[fConstraintType] << " ";
|
||||
TableUniqueConstraintDef::TableUniqueConstraintDef(ColumnNameList* columns) :
|
||||
TableConstraintDef(DDL_UNIQUE),
|
||||
fColumnNameList(*columns)
|
||||
{
|
||||
delete columns;
|
||||
}
|
||||
std::ostream& TableUniqueConstraintDef::put(std::ostream& os) const
|
||||
{
|
||||
os << "Constraint: "
|
||||
<< fName << " "
|
||||
<< ConstraintString[fConstraintType] << " ";
|
||||
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << "(";
|
||||
for(itr = fColumnNameList.begin();
|
||||
itr != fColumnNameList.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
os << ")";
|
||||
return os;
|
||||
}
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << "(";
|
||||
|
||||
TablePrimaryKeyConstraintDef::TablePrimaryKeyConstraintDef(ColumnNameList *columns) :
|
||||
TableConstraintDef(DDL_PRIMARY_KEY),
|
||||
fColumnNameList(*columns)
|
||||
{
|
||||
delete columns;
|
||||
}
|
||||
std::ostream& TablePrimaryKeyConstraintDef::put(std::ostream& os) const
|
||||
{
|
||||
os << "Constraint: "
|
||||
<< fName << " "
|
||||
<< ConstraintString[fConstraintType] << " ";
|
||||
for (itr = fColumnNameList.begin();
|
||||
itr != fColumnNameList.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << "(";
|
||||
for(itr = fColumnNameList.begin();
|
||||
itr != fColumnNameList.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
os << ")";
|
||||
os << ")";
|
||||
return os;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
TablePrimaryKeyConstraintDef::TablePrimaryKeyConstraintDef(ColumnNameList* columns) :
|
||||
TableConstraintDef(DDL_PRIMARY_KEY),
|
||||
fColumnNameList(*columns)
|
||||
{
|
||||
delete columns;
|
||||
}
|
||||
std::ostream& TablePrimaryKeyConstraintDef::put(std::ostream& os) const
|
||||
{
|
||||
os << "Constraint: "
|
||||
<< fName << " "
|
||||
<< ConstraintString[fConstraintType] << " ";
|
||||
|
||||
TableReferencesConstraintDef::TableReferencesConstraintDef
|
||||
(ColumnNameList *columns,
|
||||
QualifiedName *tableName,
|
||||
ColumnNameList *foreignColumns,
|
||||
DDL_MATCH_TYPE matchType,
|
||||
ReferentialAction *refAction) :
|
||||
TableConstraintDef(DDL_REFERENCES),
|
||||
fColumns(*columns),
|
||||
fTableName(tableName),
|
||||
fForeignColumns(*foreignColumns),
|
||||
fMatchType(matchType),
|
||||
fRefAction(refAction)
|
||||
{
|
||||
delete columns;
|
||||
delete foreignColumns;
|
||||
}
|
||||
std::ostream& TableReferencesConstraintDef::put(std::ostream& os) const
|
||||
{
|
||||
os << "Constraint: "
|
||||
<< fName << " "
|
||||
<< ConstraintString[fConstraintType] << " ";
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << "(";
|
||||
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << "lcols (";
|
||||
for(itr = fColumns.begin();
|
||||
itr != fColumns.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
os << ")";
|
||||
for (itr = fColumnNameList.begin();
|
||||
itr != fColumnNameList.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
|
||||
os << " ftable=" << *fTableName;
|
||||
os << ")";
|
||||
|
||||
os << " ";
|
||||
return os;
|
||||
}
|
||||
|
||||
os << "fcols (";
|
||||
for(itr = fForeignColumns.begin();
|
||||
itr != fForeignColumns.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
os << ")";
|
||||
TableReferencesConstraintDef::TableReferencesConstraintDef
|
||||
(ColumnNameList* columns,
|
||||
QualifiedName* tableName,
|
||||
ColumnNameList* foreignColumns,
|
||||
DDL_MATCH_TYPE matchType,
|
||||
ReferentialAction* refAction) :
|
||||
TableConstraintDef(DDL_REFERENCES),
|
||||
fColumns(*columns),
|
||||
fTableName(tableName),
|
||||
fForeignColumns(*foreignColumns),
|
||||
fMatchType(matchType),
|
||||
fRefAction(refAction)
|
||||
{
|
||||
delete columns;
|
||||
delete foreignColumns;
|
||||
}
|
||||
std::ostream& TableReferencesConstraintDef::put(std::ostream& os) const
|
||||
{
|
||||
os << "Constraint: "
|
||||
<< fName << " "
|
||||
<< ConstraintString[fConstraintType] << " ";
|
||||
|
||||
return os;
|
||||
}
|
||||
std::ostream &operator<<(std::ostream& os, const ColumnNameList &columnNames)
|
||||
{
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << '(';
|
||||
for(itr = columnNames.begin();
|
||||
itr != columnNames.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
os << ')';
|
||||
return os;
|
||||
}
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << "lcols (";
|
||||
|
||||
for (itr = fColumns.begin();
|
||||
itr != fColumns.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
|
||||
os << ")";
|
||||
|
||||
os << " ftable=" << *fTableName;
|
||||
|
||||
os << " ";
|
||||
|
||||
os << "fcols (";
|
||||
|
||||
for (itr = fForeignColumns.begin();
|
||||
itr != fForeignColumns.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
|
||||
os << ")";
|
||||
|
||||
return os;
|
||||
}
|
||||
std::ostream& operator<<(std::ostream& os, const ColumnNameList& columnNames)
|
||||
{
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << '(';
|
||||
|
||||
for (itr = columnNames.begin();
|
||||
itr != columnNames.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
|
||||
os << ')';
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
TableReferencesConstraintDef::~TableReferencesConstraintDef()
|
||||
{
|
||||
delete fTableName;
|
||||
delete fRefAction;
|
||||
}
|
||||
TableReferencesConstraintDef::~TableReferencesConstraintDef()
|
||||
{
|
||||
delete fTableName;
|
||||
delete fRefAction;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -34,125 +34,125 @@
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
/** @brief specialization of a DDLPackageProcessor
|
||||
* for interacting with the Write Engine
|
||||
* to process alter table ddl statements.
|
||||
/** @brief specialization of a DDLPackageProcessor
|
||||
* for interacting with the Write Engine
|
||||
* to process alter table ddl statements.
|
||||
*/
|
||||
class AlterTableProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
AlterTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||
/** @brief process an alter table statement
|
||||
*
|
||||
* @param alterTableStmt the AlterTableStatement
|
||||
*/
|
||||
class AlterTableProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
AlterTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm){}
|
||||
/** @brief process an alter table statement
|
||||
*
|
||||
* @param alterTableStmt the AlterTableStatement
|
||||
*/
|
||||
EXPORT DDLResult processPackage(ddlpackage::AlterTableStatement& alterTableStmt);
|
||||
/** @brief add a physical column file
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param addColumn the AtaAddColumn object
|
||||
* @param fTableName the QualifiedName of the table
|
||||
*/
|
||||
EXPORT void addColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::ColumnDef* columnDefPtr,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
EXPORT DDLResult processPackage(ddlpackage::AlterTableStatement& alterTableStmt);
|
||||
/** @brief add a physical column file
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param addColumn the AtaAddColumn object
|
||||
* @param fTableName the QualifiedName of the table
|
||||
*/
|
||||
EXPORT void addColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::ColumnDef* columnDefPtr,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
|
||||
/** @brief drop a column
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataDropColumn the AtaDropColumn object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void dropColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaDropColumn& ataDropColumn,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
/** @brief drop a column
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataDropColumn the AtaDropColumn object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void dropColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaDropColumn& ataDropColumn,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
|
||||
/** @brief drop columns
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataDropColumns the AtaDropColumn object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void dropColumns(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaDropColumns& ataDropColumns,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId );
|
||||
/** @brief drop columns
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataDropColumns the AtaDropColumn object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void dropColumns(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaDropColumns& ataDropColumns,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId );
|
||||
|
||||
/** @brief add table constraint
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataAddTableConstraint the AtaDropColumn object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void addTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaAddTableConstraint& ataAddTableConstraint,
|
||||
ddlpackage::QualifiedName& fTableName );
|
||||
/** @brief add table constraint
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataAddTableConstraint the AtaDropColumn object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void addTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaAddTableConstraint& ataAddTableConstraint,
|
||||
ddlpackage::QualifiedName& fTableName );
|
||||
|
||||
/** @brief set column default
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataSetColumnDefault the AtaSetColumnDefault object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void setColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaSetColumnDefault& ataSetColumnDefault,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId );
|
||||
/** @brief set column default
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataSetColumnDefault the AtaSetColumnDefault object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void setColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaSetColumnDefault& ataSetColumnDefault,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId );
|
||||
|
||||
/** @brief drop column default
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataDropColumnDefault the AtaDropColumnDefault object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void dropColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaDropColumnDefault& ataDropColumnDefault,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId );
|
||||
/** @brief drop column default
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataDropColumnDefault the AtaDropColumnDefault object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void dropColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaDropColumnDefault& ataDropColumnDefault,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId );
|
||||
|
||||
/** @brief drop table constraint
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataDropTableConstraint the AtaDropTableConstraint object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void dropTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaDropTableConstraint& ataDropTableConstraint,
|
||||
ddlpackage::QualifiedName& fTableName );
|
||||
/** @brief rename a table
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataRenameTable the AtaRenameTable object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void renameTable(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result, ddlpackage::AtaRenameTable& ataRenameTable,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
/** @brief drop table constraint
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataDropTableConstraint the AtaDropTableConstraint object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void dropTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaDropTableConstraint& ataDropTableConstraint,
|
||||
ddlpackage::QualifiedName& fTableName );
|
||||
/** @brief rename a table
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataRenameTable the AtaRenameTable object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void renameTable(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result, ddlpackage::AtaRenameTable& ataRenameTable,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
|
||||
/** @brief rename a column
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataRenameColumn the AtaRenameColumn object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void renameColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaRenameColumn& ataRenameColumn,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
/** @brief rename a column
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataRenameColumn the AtaRenameColumn object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void renameColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaRenameColumn& ataRenameColumn,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
|
||||
/** @brief change a table autoincrement via a comment
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataTableComment the AtaTableComment object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void tableComment(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaTableComment& ataTableComment,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
/** @brief change a table autoincrement via a comment
|
||||
*
|
||||
* @param result the result of the operation
|
||||
* @param ataTableComment the AtaTableComment object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void tableComment(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaTableComment& ataTableComment,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
|
||||
|
||||
protected:
|
||||
void rollBackAlter(const std::string& error, BRM::TxnID txnID, int sessionId, DDLResult& result, uint64_t uniqueId);
|
||||
protected:
|
||||
void rollBackAlter(const std::string& error, BRM::TxnID txnID, int sessionId, DDLResult& result, uint64_t uniqueId);
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
} //namespace ddlpackageprocessor
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
DETAIL_INFO(createIndexStmt);
|
||||
|
||||
BRM::TxnID txnID;
|
||||
txnID.id= fTxnid.id;
|
||||
txnID.valid= fTxnid.valid;
|
||||
txnID.id = fTxnid.id;
|
||||
txnID.valid = fTxnid.valid;
|
||||
/*Check whether the table exists already. If not, it is assumed from primary key creating.
|
||||
This is based on the assumption that Front end is already error out if the user trys to
|
||||
create index on non-existing table. */
|
||||
@@ -66,13 +66,15 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
tableName.table = (createIndexStmt.fTableName)->fName;
|
||||
CalpontSystemCatalog::ROPair roPair;
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog( createIndexStmt.fSessionID );
|
||||
try {
|
||||
roPair = systemCatalogPtr->tableRID( tableName );
|
||||
|
||||
try
|
||||
{
|
||||
roPair = systemCatalogPtr->tableRID( tableName );
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
// store primary key name in fPKName
|
||||
fPKName = createIndexStmt.fIndexName->fName;
|
||||
// store primary key name in fPKName
|
||||
fPKName = createIndexStmt.fIndexName->fName;
|
||||
return result;
|
||||
|
||||
}
|
||||
@@ -80,10 +82,12 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if ( roPair.objnum < 3000 )
|
||||
{
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
fPKName = createIndexStmt.fIndexName->fName;
|
||||
int err = 0;
|
||||
|
||||
@@ -103,10 +107,12 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
|
||||
VERBOSE_INFO("Writing meta data to SYSINDEX");
|
||||
bool multicol = false;
|
||||
|
||||
if ( createIndexStmt.fColumnNames.size() > 1 )
|
||||
{
|
||||
multicol = true;
|
||||
multicol = true;
|
||||
}
|
||||
|
||||
//validate index columns
|
||||
CalpontSystemCatalog::TableColName tableColName;
|
||||
tableColName.schema = (createIndexStmt.fTableName)->fSchema;
|
||||
@@ -116,25 +122,27 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
ColumnNameList::const_iterator colIter;
|
||||
int totalWidth = 0;
|
||||
DDLIndexPopulator pop(&fWriteEngine, &fSessionManager, createIndexStmt.fSessionID, txnID.id, result,
|
||||
fIdxOID, createIndexStmt.fColumnNames, *createIndexStmt.fTableName,
|
||||
type, getDebugLevel());
|
||||
fIdxOID, createIndexStmt.fColumnNames, *createIndexStmt.fTableName,
|
||||
type, getDebugLevel());
|
||||
|
||||
if ( multicol)
|
||||
{
|
||||
for ( colIter = createIndexStmt.fColumnNames.begin(); colIter != createIndexStmt.fColumnNames.end(); colIter++)
|
||||
{
|
||||
tableColName.column = *colIter;
|
||||
for ( colIter = createIndexStmt.fColumnNames.begin(); colIter != createIndexStmt.fColumnNames.end(); colIter++)
|
||||
{
|
||||
tableColName.column = *colIter;
|
||||
|
||||
roPair = systemCatalogPtr->columnRID( tableColName );
|
||||
oid = systemCatalogPtr->lookupOID( tableColName );
|
||||
colType = systemCatalogPtr->colType (oid );
|
||||
totalWidth += (pop.isDictionaryType(colType)) ? 8 : colType.colWidth;
|
||||
}
|
||||
if ( totalWidth > 32 )
|
||||
{
|
||||
stringstream ss;
|
||||
ss << totalWidth;
|
||||
DETAIL_INFO("Total indexed column width greater than 32: " + ss.str());
|
||||
logging::Message::Args args;
|
||||
roPair = systemCatalogPtr->columnRID( tableColName );
|
||||
oid = systemCatalogPtr->lookupOID( tableColName );
|
||||
colType = systemCatalogPtr->colType (oid );
|
||||
totalWidth += (pop.isDictionaryType(colType)) ? 8 : colType.colWidth;
|
||||
}
|
||||
|
||||
if ( totalWidth > 32 )
|
||||
{
|
||||
stringstream ss;
|
||||
ss << totalWidth;
|
||||
DETAIL_INFO("Total indexed column width greater than 32: " + ss.str());
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add("Error creating index: ");
|
||||
args.add("Total indexed column width");
|
||||
@@ -144,71 +152,73 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
result.result = CREATE_ERROR;
|
||||
result.message = message;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//writeSysIndexMetaData(createIndexStmt.fSessionID, txnID.id, result, *createIndexStmt.fTableName, type, createIndexStmt.fIndexName->fName, multicol);
|
||||
|
||||
//fIdxOID values are set in writeSysIndexMetaData.
|
||||
pop.setIdxOID(fIdxOID);
|
||||
|
||||
VERBOSE_INFO("Writing meta data to SYSINDEXCOL");
|
||||
//writeSysIndexColMetaData(createIndexStmt.fSessionID, txnID.id, result,*createIndexStmt.fTableName, createIndexStmt.fColumnNames, createIndexStmt.fIndexName->fName );
|
||||
|
||||
if (createIndexStmt.fUnique)
|
||||
try
|
||||
{
|
||||
VERBOSE_INFO("Writing column constraint meta data to SYSCONSTRAINT");
|
||||
WriteEngine::ColStruct colStruct;
|
||||
WriteEngine::ColTuple colTuple;
|
||||
WriteEngine::ColStructList colStructs;
|
||||
WriteEngine::ColTupleList colTuples;
|
||||
WriteEngine::ColValueList colValuesList;
|
||||
WriteEngine::RIDList ridList;
|
||||
//writeSysIndexMetaData(createIndexStmt.fSessionID, txnID.id, result, *createIndexStmt.fTableName, type, createIndexStmt.fIndexName->fName, multicol);
|
||||
|
||||
DDLColumn column;
|
||||
//fIdxOID values are set in writeSysIndexMetaData.
|
||||
pop.setIdxOID(fIdxOID);
|
||||
|
||||
CalpontSystemCatalog::TableName sysConsTableName;
|
||||
sysConsTableName.schema = CALPONT_SCHEMA;
|
||||
sysConsTableName.table = SYSCONSTRAINT_TABLE;
|
||||
VERBOSE_INFO("Writing meta data to SYSINDEXCOL");
|
||||
//writeSysIndexColMetaData(createIndexStmt.fSessionID, txnID.id, result,*createIndexStmt.fTableName, createIndexStmt.fColumnNames, createIndexStmt.fIndexName->fName );
|
||||
|
||||
bool isNull = false;
|
||||
int error = 0;
|
||||
|
||||
// get the columns for the SYSCONSTRAINT table
|
||||
ColumnList sysConsColumns;
|
||||
ColumnList::const_iterator sysCons_iterator;
|
||||
getColumnsForTable(createIndexStmt.fSessionID, sysConsTableName.schema,sysConsTableName.table, sysConsColumns);
|
||||
sysCons_iterator = sysConsColumns.begin();
|
||||
std::string idxData;
|
||||
while ( sysCons_iterator != sysConsColumns.end() )
|
||||
if (createIndexStmt.fUnique)
|
||||
{
|
||||
column = *sysCons_iterator;
|
||||
VERBOSE_INFO("Writing column constraint meta data to SYSCONSTRAINT");
|
||||
WriteEngine::ColStruct colStruct;
|
||||
WriteEngine::ColTuple colTuple;
|
||||
WriteEngine::ColStructList colStructs;
|
||||
WriteEngine::ColTupleList colTuples;
|
||||
WriteEngine::ColValueList colValuesList;
|
||||
WriteEngine::RIDList ridList;
|
||||
|
||||
DDLColumn column;
|
||||
|
||||
CalpontSystemCatalog::TableName sysConsTableName;
|
||||
sysConsTableName.schema = CALPONT_SCHEMA;
|
||||
sysConsTableName.table = SYSCONSTRAINT_TABLE;
|
||||
|
||||
bool isNull = false;
|
||||
int error = 0;
|
||||
|
||||
// get the columns for the SYSCONSTRAINT table
|
||||
ColumnList sysConsColumns;
|
||||
ColumnList::const_iterator sysCons_iterator;
|
||||
getColumnsForTable(createIndexStmt.fSessionID, sysConsTableName.schema, sysConsTableName.table, sysConsColumns);
|
||||
sysCons_iterator = sysConsColumns.begin();
|
||||
std::string idxData;
|
||||
|
||||
while ( sysCons_iterator != sysConsColumns.end() )
|
||||
{
|
||||
column = *sysCons_iterator;
|
||||
boost::algorithm::to_lower(column.tableColName.column);
|
||||
isNull = false;
|
||||
|
||||
if (CONSTRAINTNAME_COL == column.tableColName.column)
|
||||
{
|
||||
idxData = createIndexStmt.fIndexName->fName;
|
||||
boost::algorithm::to_lower(idxData);
|
||||
idxData = createIndexStmt.fIndexName->fName;
|
||||
boost::algorithm::to_lower(idxData);
|
||||
colTuple.data = idxData;
|
||||
}
|
||||
else if (SCHEMA_COL == column.tableColName.column)
|
||||
{
|
||||
idxData = (createIndexStmt.fTableName)->fSchema;
|
||||
boost::algorithm::to_lower(idxData);
|
||||
boost::algorithm::to_lower(idxData);
|
||||
colTuple.data = idxData;
|
||||
}
|
||||
else if (TABLENAME_COL == column.tableColName.column)
|
||||
{
|
||||
idxData = (createIndexStmt.fTableName)->fName;
|
||||
boost::algorithm::to_lower(idxData);
|
||||
boost::algorithm::to_lower(idxData);
|
||||
colTuple.data = idxData;
|
||||
}
|
||||
else if (CONSTRAINTTYPE_COL == column.tableColName.column)
|
||||
{
|
||||
std::string consType;
|
||||
char constraint_type = getConstraintCode(type);
|
||||
char constraint_type = getConstraintCode(type);
|
||||
consType += constraint_type;
|
||||
colTuple.data = consType;
|
||||
}
|
||||
@@ -219,14 +229,14 @@ try
|
||||
}
|
||||
else if (CONSTRAINTTEXT_COL == column.tableColName.column)
|
||||
{
|
||||
colTuple.data = getNullValueForType(column.colType);
|
||||
isNull = true;
|
||||
colTuple.data = getNullValueForType(column.colType);
|
||||
isNull = true;
|
||||
}
|
||||
else if (INDEXNAME_COL == column.tableColName.column)
|
||||
{
|
||||
idxData = createIndexStmt.fIndexName->fName;
|
||||
boost::algorithm::to_lower(idxData);
|
||||
colTuple.data = idxData;
|
||||
idxData = createIndexStmt.fIndexName->fName;
|
||||
boost::algorithm::to_lower(idxData);
|
||||
colTuple.data = idxData;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -245,6 +255,7 @@ try
|
||||
{
|
||||
colTuple.data = tokenizeData(txnID.id, result, column.colType, colTuple.data);
|
||||
}
|
||||
|
||||
colStructs.push_back( colStruct );
|
||||
|
||||
colTuples.push_back( colTuple );
|
||||
@@ -255,14 +266,14 @@ try
|
||||
++sysCons_iterator;
|
||||
}
|
||||
|
||||
if (colStructs.size() != 0)
|
||||
if (colStructs.size() != 0)
|
||||
{
|
||||
//fWriteEngine.setDebugLevel(WriteEngine::DEBUG_3);
|
||||
//error = fWriteEngine.insertColumnRec( txnID.id, colStructs, colValuesList, ridList );
|
||||
if ( error != WriteEngine::NO_ERROR )
|
||||
{
|
||||
//fWriteEngine.setDebugLevel(WriteEngine::DEBUG_3);
|
||||
//error = fWriteEngine.insertColumnRec( txnID.id, colStructs, colValuesList, ridList );
|
||||
if ( error != WriteEngine::NO_ERROR )
|
||||
{
|
||||
|
||||
return rollBackCreateIndex(errorString( "WE: Error inserting Column Record: ", error), txnID, createIndexStmt.fSessionID);
|
||||
return rollBackCreateIndex(errorString( "WE: Error inserting Column Record: ", error), txnID, createIndexStmt.fSessionID);
|
||||
// logging::Message::Args args;
|
||||
// logging::Message message(9);
|
||||
// args.add("Error updating: ");
|
||||
@@ -273,35 +284,36 @@ try
|
||||
//
|
||||
// result.result = CREATE_ERROR;
|
||||
// result.message = message;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.result = NO_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.result = NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
VERBOSE_INFO("Writing column constraint meta data to SYSCONSTRAINTCOL");
|
||||
WriteEngine::ColStruct colStructCol;
|
||||
WriteEngine::ColTuple colTupleCol;
|
||||
WriteEngine::ColStructList colStructsCol;
|
||||
WriteEngine::ColTupleList colTuplesCol;
|
||||
WriteEngine::ColValueList colValuesListCol;
|
||||
CalpontSystemCatalog::TableName sysConsColTableName;
|
||||
sysConsColTableName.schema = CALPONT_SCHEMA;
|
||||
sysConsColTableName.table = SYSCONSTRAINTCOL_TABLE;
|
||||
colValuesList.clear();
|
||||
colTuples.clear();
|
||||
isNull = false;
|
||||
error = 0;
|
||||
// get the columns for the SYSCONSTRAINTCOL table
|
||||
ColumnList sysConsColColumns;
|
||||
ColumnList::const_iterator sysConsCol_iterator;
|
||||
getColumnsForTable(createIndexStmt.fSessionID, sysConsColTableName.schema,sysConsColTableName.table, sysConsColColumns);
|
||||
// write sysconstraintcol
|
||||
sysConsCol_iterator = sysConsColColumns.begin();
|
||||
std::string colData;
|
||||
while ( sysConsCol_iterator != sysConsColColumns.end() )
|
||||
{
|
||||
VERBOSE_INFO("Writing column constraint meta data to SYSCONSTRAINTCOL");
|
||||
WriteEngine::ColStruct colStructCol;
|
||||
WriteEngine::ColTuple colTupleCol;
|
||||
WriteEngine::ColStructList colStructsCol;
|
||||
WriteEngine::ColTupleList colTuplesCol;
|
||||
WriteEngine::ColValueList colValuesListCol;
|
||||
CalpontSystemCatalog::TableName sysConsColTableName;
|
||||
sysConsColTableName.schema = CALPONT_SCHEMA;
|
||||
sysConsColTableName.table = SYSCONSTRAINTCOL_TABLE;
|
||||
colValuesList.clear();
|
||||
colTuples.clear();
|
||||
isNull = false;
|
||||
error = 0;
|
||||
// get the columns for the SYSCONSTRAINTCOL table
|
||||
ColumnList sysConsColColumns;
|
||||
ColumnList::const_iterator sysConsCol_iterator;
|
||||
getColumnsForTable(createIndexStmt.fSessionID, sysConsColTableName.schema, sysConsColTableName.table, sysConsColColumns);
|
||||
// write sysconstraintcol
|
||||
sysConsCol_iterator = sysConsColColumns.begin();
|
||||
std::string colData;
|
||||
|
||||
while ( sysConsCol_iterator != sysConsColColumns.end() )
|
||||
{
|
||||
column = *sysConsCol_iterator;
|
||||
boost::algorithm::to_lower(column.tableColName.column);
|
||||
|
||||
@@ -315,14 +327,14 @@ try
|
||||
}
|
||||
else if (TABLENAME_COL == column.tableColName.column)
|
||||
{
|
||||
colData = (createIndexStmt.fTableName)->fName;
|
||||
colData = (createIndexStmt.fTableName)->fName;
|
||||
boost::algorithm::to_lower(colData);
|
||||
colTupleCol.data = colData;
|
||||
}
|
||||
else if (COLNAME_COL == column.tableColName.column)
|
||||
{
|
||||
colData = createIndexStmt.fColumnNames[0];
|
||||
boost::algorithm::to_lower(colData);
|
||||
colData = createIndexStmt.fColumnNames[0];
|
||||
boost::algorithm::to_lower(colData);
|
||||
colTupleCol.data = colData;
|
||||
|
||||
}
|
||||
@@ -360,68 +372,72 @@ try
|
||||
++sysConsCol_iterator;
|
||||
}
|
||||
|
||||
if (colStructsCol.size() != 0)
|
||||
if (colStructsCol.size() != 0)
|
||||
{
|
||||
//fWriteEngine.setDebugLevel(WriteEngine::DEBUG_3);
|
||||
//error = fWriteEngine.insertColumnRec( txnID.id, colStructsCol, colValuesListCol, ridList );
|
||||
if ( error != WriteEngine::NO_ERROR )
|
||||
{
|
||||
return rollBackCreateIndex(errorString( "WE: Error inserting Column Record: ", error), txnID, createIndexStmt.fSessionID);
|
||||
//fWriteEngine.setDebugLevel(WriteEngine::DEBUG_3);
|
||||
//error = fWriteEngine.insertColumnRec( txnID.id, colStructsCol, colValuesListCol, ridList );
|
||||
if ( error != WriteEngine::NO_ERROR )
|
||||
{
|
||||
return rollBackCreateIndex(errorString( "WE: Error inserting Column Record: ", error), txnID, createIndexStmt.fSessionID);
|
||||
|
||||
/* logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add("Error updating: ");
|
||||
args.add("calpont.sysconstraintcol");
|
||||
args.add("error number: ");
|
||||
args.add( error );
|
||||
message.format( args );
|
||||
/* logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add("Error updating: ");
|
||||
args.add("calpont.sysconstraintcol");
|
||||
args.add("error number: ");
|
||||
args.add( error );
|
||||
message.format( args );
|
||||
|
||||
result.result = CREATE_ERROR;
|
||||
result.message = message;*/
|
||||
}
|
||||
else
|
||||
{
|
||||
result.result = NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
result.result = CREATE_ERROR;
|
||||
result.message = message;*/
|
||||
}
|
||||
else
|
||||
{
|
||||
result.result = NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VERBOSE_INFO("Creating index files");
|
||||
err = fWriteEngine.createIndex( txnID.id, fIdxOID.treeOID, fIdxOID.listOID );
|
||||
if (err)
|
||||
{
|
||||
return rollBackCreateIndex(errorString("Write engine failed to create the new index. ", err), txnID, createIndexStmt.fSessionID);
|
||||
}
|
||||
// new if BULK_LOAD close
|
||||
err = pop.populateIndex(result);
|
||||
if ( err )
|
||||
{
|
||||
return rollBackCreateIndex(errorString("Failed to populate index with current data. ", err), txnID, createIndexStmt.fSessionID);
|
||||
}
|
||||
VERBOSE_INFO("Creating index files");
|
||||
err = fWriteEngine.createIndex( txnID.id, fIdxOID.treeOID, fIdxOID.listOID );
|
||||
|
||||
if (err)
|
||||
{
|
||||
return rollBackCreateIndex(errorString("Write engine failed to create the new index. ", err), txnID, createIndexStmt.fSessionID);
|
||||
}
|
||||
|
||||
// new if BULK_LOAD close
|
||||
err = pop.populateIndex(result);
|
||||
|
||||
if ( err )
|
||||
{
|
||||
return rollBackCreateIndex(errorString("Failed to populate index with current data. ", err), txnID, createIndexStmt.fSessionID);
|
||||
}
|
||||
|
||||
|
||||
// Log the DDL statement.
|
||||
logging::logDDL(createIndexStmt.fSessionID, txnID.id, createIndexStmt.fSql, createIndexStmt.fOwner);
|
||||
// Log the DDL statement.
|
||||
logging::logDDL(createIndexStmt.fSessionID, txnID.id, createIndexStmt.fSql, createIndexStmt.fOwner);
|
||||
|
||||
DETAIL_INFO("Commiting transaction");
|
||||
err = fWriteEngine.commit( txnID.id );
|
||||
if (err)
|
||||
{
|
||||
return rollBackCreateIndex(errorString("Failed to commit the create index transaction. ", err), txnID, createIndexStmt.fSessionID);
|
||||
}
|
||||
DETAIL_INFO("Commiting transaction");
|
||||
err = fWriteEngine.commit( txnID.id );
|
||||
|
||||
fSessionManager.committed(txnID);
|
||||
if (err)
|
||||
{
|
||||
return rollBackCreateIndex(errorString("Failed to commit the create index transaction. ", err), txnID, createIndexStmt.fSessionID);
|
||||
}
|
||||
|
||||
fSessionManager.committed(txnID);
|
||||
// original if BULK_LOAD close }
|
||||
} // try
|
||||
} // try
|
||||
|
||||
catch (exception& ex)
|
||||
{
|
||||
result = rollBackCreateIndex(ex.what(), txnID, createIndexStmt.fSessionID);
|
||||
result = rollBackCreateIndex(ex.what(), txnID, createIndexStmt.fSessionID);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
string msg("CreateIndexProcessor::processPackage: caught unknown exception!");
|
||||
result = rollBackCreateIndex(msg, txnID, createIndexStmt.fSessionID);
|
||||
string msg("CreateIndexProcessor::processPackage: caught unknown exception!");
|
||||
result = rollBackCreateIndex(msg, txnID, createIndexStmt.fSessionID);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -429,44 +445,47 @@ try
|
||||
|
||||
string CreateIndexProcessor::errorString(const string& msg, int error)
|
||||
{
|
||||
WriteEngine::WErrorCodes ec;
|
||||
return string(msg + ec.errorString(error));
|
||||
WriteEngine::WErrorCodes ec;
|
||||
return string(msg + ec.errorString(error));
|
||||
}
|
||||
|
||||
|
||||
CreateIndexProcessor::DDLResult CreateIndexProcessor::rollBackCreateIndex(const string& error, BRM::TxnID& txnID, int sessionId)
|
||||
{
|
||||
cerr << "CreatetableProcessor::processPackage: " << error << endl;
|
||||
DETAIL_INFO(error);
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add("Create Index Failed: ");
|
||||
args.add( error );
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format( args );
|
||||
DDLResult result;
|
||||
cerr << "CreatetableProcessor::processPackage: " << error << endl;
|
||||
DETAIL_INFO(error);
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add("Create Index Failed: ");
|
||||
args.add( error );
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format( args );
|
||||
DDLResult result;
|
||||
result.result = CREATE_ERROR;
|
||||
result.message = message;
|
||||
rollBackIndex(txnID, sessionId);
|
||||
return result;
|
||||
rollBackIndex(txnID, sessionId);
|
||||
return result;
|
||||
}
|
||||
|
||||
void CreateIndexProcessor::rollBackIndex(BRM::TxnID& txnID, int sessionId)
|
||||
{
|
||||
fWriteEngine.rollbackTran(txnID.id, sessionId);
|
||||
fWriteEngine.dropIndex(txnID.id,fIdxOID.listOID, fIdxOID.treeOID);
|
||||
try {
|
||||
//execplan::ObjectIDManager fObjectIDManager;
|
||||
//fObjectIDManager.returnOIDs(fIdxOID.treeOID, fIdxOID.listOID);
|
||||
}
|
||||
catch ( exception& ex )
|
||||
{
|
||||
fWriteEngine.rollbackTran(txnID.id, sessionId);
|
||||
fWriteEngine.dropIndex(txnID.id, fIdxOID.listOID, fIdxOID.treeOID);
|
||||
|
||||
}
|
||||
catch (... )
|
||||
{ }
|
||||
fSessionManager.rolledback(txnID);
|
||||
try
|
||||
{
|
||||
//execplan::ObjectIDManager fObjectIDManager;
|
||||
//fObjectIDManager.returnOIDs(fIdxOID.treeOID, fIdxOID.listOID);
|
||||
}
|
||||
catch ( exception& ex )
|
||||
{
|
||||
|
||||
}
|
||||
catch (... )
|
||||
{ }
|
||||
|
||||
fSessionManager.rolledback(txnID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,26 +29,26 @@
|
||||
const int BULK_LOAD = 1;
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
/** @brief specialization of a DDLPackageProcessor
|
||||
* for interacting with the Write Engine to process
|
||||
* create index ddl statements
|
||||
/** @brief specialization of a DDLPackageProcessor
|
||||
* for interacting with the Write Engine to process
|
||||
* create index ddl statements
|
||||
*/
|
||||
class CreateIndexProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
/** @brief process a create index statement
|
||||
*
|
||||
* @param createIndexStmt the create index statement
|
||||
*/
|
||||
class CreateIndexProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
/** @brief process a create index statement
|
||||
*
|
||||
* @param createIndexStmt the create index statement
|
||||
*/
|
||||
DDLResult processPackage(ddlpackage::CreateIndexStatement& createIndexStmt);
|
||||
DDLResult processPackage(ddlpackage::CreateIndexStatement& createIndexStmt);
|
||||
|
||||
protected:
|
||||
DDLResult rollBackCreateIndex(const std::string& error, BRM::TxnID& txnID, int sessionId);
|
||||
void rollBackIndex(BRM::TxnID& txnID);
|
||||
std::string errorString(const std::string& msg, int error);
|
||||
private:
|
||||
protected:
|
||||
DDLResult rollBackCreateIndex(const std::string& error, BRM::TxnID& txnID, int sessionId);
|
||||
void rollBackIndex(BRM::TxnID& txnID);
|
||||
std::string errorString(const std::string& msg, int error);
|
||||
private:
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
} //namespace ddlpackageprocessor
|
||||
#endif //CREATEINDEXPROCESSOR_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -43,7 +43,7 @@ class CreateTableProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
|
||||
CreateTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm){}
|
||||
CreateTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||
/** @brief process a create table statement
|
||||
*
|
||||
* @param createTableStmt the CreateTableStatement
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
EXPORT DDLResult processPackage(ddlpackage::CreateTableStatement& createTableStmt);
|
||||
|
||||
protected:
|
||||
void rollBackCreateTable(const std::string& error, BRM::TxnID txnID, int sessionId, ddlpackage::TableDef& tableDef, DDLResult& result);
|
||||
void rollBackCreateTable(const std::string& error, BRM::TxnID txnID, int sessionId, ddlpackage::TableDef& tableDef, DDLResult& result);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -52,24 +52,26 @@ using namespace messageqcpp;
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
bool DDLIndexPopulator::populateIndex(DDLPackageProcessor::DDLResult& result)
|
||||
{
|
||||
bool DDLIndexPopulator::populateIndex(DDLPackageProcessor::DDLResult& result)
|
||||
{
|
||||
if (makeIndexStructs() )
|
||||
insertIndex();
|
||||
insertIndex();
|
||||
|
||||
result = fResult;
|
||||
return NO_ERROR != fResult.result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool DDLIndexPopulator::makeIndexStructs( )
|
||||
{
|
||||
bool DDLIndexPopulator::makeIndexStructs( )
|
||||
{
|
||||
CalpontSelectExecutionPlan csep;
|
||||
makeCsep(csep);
|
||||
ResourceManager *rm;
|
||||
ResourceManager* rm;
|
||||
|
||||
if (! fEC)
|
||||
{
|
||||
fEC = DistributedEngineComm::instance(rm);
|
||||
fEC->Open();
|
||||
fEC = DistributedEngineComm::instance(rm);
|
||||
fEC->Open();
|
||||
}
|
||||
|
||||
SJLP jbl = joblist::JobListFactory::makeJobList(&csep, rm);
|
||||
@@ -90,46 +92,52 @@ namespace ddlpackageprocessor
|
||||
|
||||
CalpontSystemCatalog::OID tableOid = (csc->tableRID ( tableName )).objnum;
|
||||
CalpontSystemCatalog::NJLSysDataList sysDataList;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
TableBand band;
|
||||
band = jbl->projectTable(tableOid);
|
||||
if (band.getRowCount() == 0)
|
||||
{
|
||||
// No more bands, table is done
|
||||
break;
|
||||
}
|
||||
band.convertToSysDataList(sysDataList, csc);
|
||||
break;
|
||||
}
|
||||
{
|
||||
TableBand band;
|
||||
band = jbl->projectTable(tableOid);
|
||||
|
||||
if (band.getRowCount() == 0)
|
||||
{
|
||||
// No more bands, table is done
|
||||
break;
|
||||
}
|
||||
|
||||
band.convertToSysDataList(sysDataList, csc);
|
||||
break;
|
||||
}
|
||||
|
||||
//size_t cnt = fColNames.size();
|
||||
size_t i = 0;
|
||||
vector<ColumnResult*>::const_iterator it;
|
||||
vector<int>::const_iterator oid_iter;
|
||||
|
||||
for (it = sysDataList.begin(); it != sysDataList.end(); it++)
|
||||
{
|
||||
if (isUnique())
|
||||
fUniqueColResultList.push_back(*it);
|
||||
for ( oid_iter = fOidList.begin(); oid_iter != fOidList.end(); oid_iter++ )
|
||||
{
|
||||
if ( (*it)->ColumnOID() == *oid_iter )
|
||||
{
|
||||
CalpontSystemCatalog::ColType coltype = makeIdxStruct(*it, fColNames.size(), csc);
|
||||
addColumnData(*it, coltype, i);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
if (isUnique())
|
||||
fUniqueColResultList.push_back(*it);
|
||||
|
||||
for ( oid_iter = fOidList.begin(); oid_iter != fOidList.end(); oid_iter++ )
|
||||
{
|
||||
if ( (*it)->ColumnOID() == *oid_iter )
|
||||
{
|
||||
CalpontSystemCatalog::ColType coltype = makeIdxStruct(*it, fColNames.size(), csc);
|
||||
addColumnData(*it, coltype, i);
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return (fIdxValueList.size() && NO_ERROR == fResult.result );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DDLIndexPopulator::makeCsep(CalpontSelectExecutionPlan& csep)
|
||||
{
|
||||
void DDLIndexPopulator::makeCsep(CalpontSelectExecutionPlan& csep)
|
||||
{
|
||||
|
||||
csep.sessionID(fSessionID);
|
||||
|
||||
@@ -138,31 +146,33 @@ namespace ddlpackageprocessor
|
||||
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList colList;
|
||||
CalpontSelectExecutionPlan::ColumnMap colMap;
|
||||
CalpontSystemCatalog::TableColName tableColName;
|
||||
CalpontSystemCatalog::OID oid;
|
||||
tableColName.schema = fTable.fSchema;
|
||||
tableColName.table = fTable.fName;
|
||||
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog( fSessionID );
|
||||
CalpontSystemCatalog::TableColName tableColName;
|
||||
CalpontSystemCatalog::OID oid;
|
||||
tableColName.schema = fTable.fSchema;
|
||||
tableColName.table = fTable.fName;
|
||||
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog( fSessionID );
|
||||
string tableName(fTable.fSchema + "." + fTable.fName + ".");
|
||||
|
||||
ColumnNameList::const_iterator cend = fColNames.end();
|
||||
|
||||
for (ColumnNameList::const_iterator cname = fColNames.begin(); cname != cend; ++cname)
|
||||
{
|
||||
string fullColName(tableName + *cname);
|
||||
string fullColName(tableName + *cname);
|
||||
SRCP srcp(new SimpleColumn (fullColName, fSessionID));
|
||||
colList.push_back(srcp);
|
||||
tableColName.column = *cname;
|
||||
oid = csc->lookupOID( tableColName );
|
||||
fOidList.push_back( oid );
|
||||
colMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(fullColName, srcp));
|
||||
colList.push_back(srcp);
|
||||
tableColName.column = *cname;
|
||||
oid = csc->lookupOID( tableColName );
|
||||
fOidList.push_back( oid );
|
||||
colMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(fullColName, srcp));
|
||||
}
|
||||
|
||||
csep.columnMap (colMap);
|
||||
csep.returnedCols (colList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CalpontSystemCatalog::ColType DDLIndexPopulator::makeIdxStruct(const ColumnResult* cr, size_t cols, boost::shared_ptr<CalpontSystemCatalog> csc )
|
||||
{
|
||||
CalpontSystemCatalog::ColType DDLIndexPopulator::makeIdxStruct(const ColumnResult* cr, size_t cols, boost::shared_ptr<CalpontSystemCatalog> csc )
|
||||
{
|
||||
IdxStruct idx;
|
||||
idx.treeOid = fIdxOID.treeOID;
|
||||
idx.listOid = fIdxOID.listOID;
|
||||
@@ -172,64 +182,67 @@ namespace ddlpackageprocessor
|
||||
|
||||
if (isDictionaryType(coltype) )
|
||||
{
|
||||
idx.idxWidth = fTOKENSIZE;
|
||||
idx.idxType = WR_CHAR;
|
||||
idx.idxWidth = fTOKENSIZE;
|
||||
idx.idxType = WR_CHAR;
|
||||
}//@bug 410: index sizes are either 1, 4 or 8
|
||||
else if (exeplan::isCharType(coltype))
|
||||
{
|
||||
if (1 == coltype.colWidth) idx.idxWidth = 1;
|
||||
else idx.idxWidth = (coltype.colWidth > 4) ? 8 : 4;
|
||||
idx.idxType = WR_CHAR;
|
||||
if (1 == coltype.colWidth) idx.idxWidth = 1;
|
||||
else idx.idxWidth = (coltype.colWidth > 4) ? 8 : 4;
|
||||
|
||||
idx.idxType = WR_CHAR;
|
||||
}
|
||||
else
|
||||
idx.idxWidth = coltype.colWidth;
|
||||
idx.idxWidth = coltype.colWidth;
|
||||
|
||||
fIdxStructList.push_back(idx);
|
||||
return coltype;
|
||||
}
|
||||
}
|
||||
|
||||
void DDLIndexPopulator::addColumnData(const execplan::ColumnResult* cr, const CalpontSystemCatalog::ColType colType, int added)
|
||||
{
|
||||
void DDLIndexPopulator::addColumnData(const execplan::ColumnResult* cr, const CalpontSystemCatalog::ColType colType, int added)
|
||||
{
|
||||
WriteEngine::IdxTupleList tupleList;
|
||||
WriteEngine::IdxTuple tuple;
|
||||
|
||||
for(int i=0;i < cr->dataCount(); ++i)
|
||||
for (int i = 0; i < cr->dataCount(); ++i)
|
||||
{
|
||||
|
||||
WriteEngine::IdxTuple tuple ;
|
||||
convertColData( cr, i, colType, tuple);
|
||||
WriteEngine::IdxTuple tuple ;
|
||||
convertColData( cr, i, colType, tuple);
|
||||
|
||||
if (checkConstraints( tuple, colType, i, added))
|
||||
{
|
||||
tupleList.push_back(tuple);
|
||||
if (! added )
|
||||
fRidList.push_back(cr->GetRid(i));
|
||||
}
|
||||
else
|
||||
break;
|
||||
if (checkConstraints( tuple, colType, i, added))
|
||||
{
|
||||
tupleList.push_back(tuple);
|
||||
|
||||
if (! added )
|
||||
fRidList.push_back(cr->GetRid(i));
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (tupleList.size())
|
||||
fIdxValueList.push_back(tupleList);
|
||||
}
|
||||
fIdxValueList.push_back(tupleList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DDLIndexPopulator::convertColData(const execplan::ColumnResult* cr, int idx, const CalpontSystemCatalog::ColType& colType, WriteEngine::IdxTuple& tuple)
|
||||
{
|
||||
void DDLIndexPopulator::convertColData(const execplan::ColumnResult* cr, int idx, const CalpontSystemCatalog::ColType& colType, WriteEngine::IdxTuple& tuple)
|
||||
{
|
||||
if (isDictionaryType(colType))
|
||||
{
|
||||
/* tuple.data = tokenizeData ( colType, cr->GetStringData(idx) );*/
|
||||
/* tuple.data = tokenizeData ( cr->GetRid(idx) );*/
|
||||
tuple.data = convertTokenData(cr->GetStringData(idx));
|
||||
/* tuple.data = tokenizeData ( colType, cr->GetStringData(idx) );*/
|
||||
/* tuple.data = tokenizeData ( cr->GetRid(idx) );*/
|
||||
tuple.data = convertTokenData(cr->GetStringData(idx));
|
||||
}
|
||||
else tuple.data = convertData( colType, cr, idx);
|
||||
}
|
||||
}
|
||||
|
||||
boost::any DDLIndexPopulator::convertTokenData( const std::string& data )
|
||||
{
|
||||
boost::any DDLIndexPopulator::convertTokenData( const std::string& data )
|
||||
{
|
||||
string strData((size_t)fTOKENSIZE < data.length() ? data.substr(0, fTOKENSIZE) : data);
|
||||
return strData;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Disabled this function as it is currently not used.
|
||||
@@ -237,26 +250,27 @@ namespace ddlpackageprocessor
|
||||
// With iteration 17, the more common version of this getFileName() takes a
|
||||
// partition and segment number in addition to an OID. openColumnFile
|
||||
// should perhaps be changed to use this updated version of getFileName().
|
||||
bool DDLIndexPopulator::openColumnFile(WriteEngine::OID oid)
|
||||
{
|
||||
bool DDLIndexPopulator::openColumnFile(WriteEngine::OID oid)
|
||||
{
|
||||
FileOp fileOp;
|
||||
char fileName[WriteEngine::FILE_NAME_SIZE];
|
||||
|
||||
if (WriteEngine::NO_ERROR == fileOp.getFileName(oid, fileName) )
|
||||
{
|
||||
fColumnFile.open(fileName);
|
||||
return true;
|
||||
fColumnFile.open(fileName);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
logError("Could not get column file name for data");
|
||||
return false;
|
||||
logError("Could not get column file name for data");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Workaround to get original column token and not "retokenize" the string value
|
||||
boost::any DDLIndexPopulator::tokenizeData( WriteEngine::RID rid )
|
||||
{
|
||||
boost::any DDLIndexPopulator::tokenizeData( WriteEngine::RID rid )
|
||||
{
|
||||
int64_t byteOffset = rid * fTOKENSIZE;
|
||||
ByteStream::byte inbuf[fTOKENSIZE];
|
||||
fColumnFile.seekg(byteOffset, ios::beg);
|
||||
@@ -265,127 +279,148 @@ namespace ddlpackageprocessor
|
||||
WriteEngine::Token token;
|
||||
memcpy(&token, inbuf, fTOKENSIZE);
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boost::any DDLIndexPopulator::tokenizeData( const execplan::CalpontSystemCatalog::ColType& colType, const std::string& data )
|
||||
{
|
||||
boost::any DDLIndexPopulator::tokenizeData( const execplan::CalpontSystemCatalog::ColType& colType, const std::string& data )
|
||||
{
|
||||
WriteEngine::DctnryTuple dictTuple;
|
||||
|
||||
if ( data.length() > (unsigned int)colType.colWidth )
|
||||
{
|
||||
logError("Insert value is too large for column");
|
||||
logError("Insert value is too large for column");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteEngine::DctnryStruct dictStruct;
|
||||
dictStruct.treeOid = colType.ddn.treeOID;
|
||||
dictStruct.listOid = colType.ddn.listOID;
|
||||
dictStruct.dctnryOid = colType.ddn.dictOID;
|
||||
dictTuple.sigValue = data.c_str();
|
||||
dictTuple.sigSize = data.length();
|
||||
int error = NO_ERROR;
|
||||
if ( NO_ERROR != (error = fWriteEngine->tokenize( fTxnID, dictStruct, dictTuple)) )
|
||||
{
|
||||
logError("Tokenization failed", error);
|
||||
}
|
||||
dictStruct.treeOid = colType.ddn.treeOID;
|
||||
dictStruct.listOid = colType.ddn.listOID;
|
||||
dictStruct.dctnryOid = colType.ddn.dictOID;
|
||||
dictTuple.sigValue = data.c_str();
|
||||
dictTuple.sigSize = data.length();
|
||||
int error = NO_ERROR;
|
||||
|
||||
if ( NO_ERROR != (error = fWriteEngine->tokenize( fTxnID, dictStruct, dictTuple)) )
|
||||
{
|
||||
logError("Tokenization failed", error);
|
||||
}
|
||||
}
|
||||
|
||||
return dictTuple.token;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
boost::any DDLIndexPopulator::convertData(const CalpontSystemCatalog::ColType& colType, const execplan::ColumnResult* cr, int idx )
|
||||
{
|
||||
boost::any DDLIndexPopulator::convertData(const CalpontSystemCatalog::ColType& colType, const execplan::ColumnResult* cr, int idx )
|
||||
{
|
||||
uint64_t data = cr->GetData(idx);
|
||||
switch( colType.colDataType )
|
||||
|
||||
switch ( colType.colDataType )
|
||||
{
|
||||
case CalpontSystemCatalog::BIT:
|
||||
case execplan::CalpontSystemCatalog::TINYINT: return *reinterpret_cast<char*>(&data);
|
||||
case execplan::CalpontSystemCatalog::SMALLINT: return *reinterpret_cast<short*>(&data);
|
||||
case execplan::CalpontSystemCatalog::DATE: // @bug 375
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::INT: return *reinterpret_cast<int*>(&data);
|
||||
case execplan::CalpontSystemCatalog::DATETIME: // @bug 375
|
||||
case execplan::CalpontSystemCatalog::BIGINT: return *reinterpret_cast<long long*>(&data);
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
{
|
||||
if (colType.colWidth <= CalpontSystemCatalog::FOUR_BYTE) return *reinterpret_cast<short*>(&data);
|
||||
case CalpontSystemCatalog::BIT:
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
return *reinterpret_cast<char*>(&data);
|
||||
|
||||
else if (colType.colWidth <= 9) return *reinterpret_cast<int*>(&data);
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
return *reinterpret_cast<short*>(&data);
|
||||
|
||||
else return *reinterpret_cast<long long*>(&data);
|
||||
}
|
||||
case execplan::CalpontSystemCatalog::DATE: // @bug 375
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
return *reinterpret_cast<int*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::FLOAT: return *reinterpret_cast<float*>(&data);
|
||||
case execplan::CalpontSystemCatalog::DOUBLE: return *reinterpret_cast<double*>(&data);
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
{
|
||||
string strData(cr->GetStringData(idx) );
|
||||
return *reinterpret_cast<string*>(&strData);
|
||||
}
|
||||
default: break;
|
||||
case execplan::CalpontSystemCatalog::DATETIME: // @bug 375
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
return *reinterpret_cast<long long*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
{
|
||||
if (colType.colWidth <= CalpontSystemCatalog::FOUR_BYTE) return *reinterpret_cast<short*>(&data);
|
||||
|
||||
else if (colType.colWidth <= 9) return *reinterpret_cast<int*>(&data);
|
||||
|
||||
else return *reinterpret_cast<long long*>(&data);
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
return *reinterpret_cast<float*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
return *reinterpret_cast<double*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
{
|
||||
string strData(cr->GetStringData(idx) );
|
||||
return *reinterpret_cast<string*>(&strData);
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
logError("Invalid column type");
|
||||
throw std::runtime_error("Invalid data");
|
||||
|
||||
return *reinterpret_cast<long long*>(&data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DDLIndexPopulator::insertIndex( )
|
||||
{
|
||||
void DDLIndexPopulator::insertIndex( )
|
||||
{
|
||||
// @bug 359 use bulk load build
|
||||
int rc = (1 < fIdxStructList.size()) ?
|
||||
(void)0
|
||||
: (void)0;
|
||||
int rc = (1 < fIdxStructList.size()) ?
|
||||
(void)0
|
||||
: (void)0;
|
||||
|
||||
if (rc)
|
||||
logError("Error inserting index values", rc );
|
||||
logError("Error inserting index values", rc );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool DDLIndexPopulator::isDictionaryType(const CalpontSystemCatalog::ColType& colType)
|
||||
{
|
||||
bool DDLIndexPopulator::isDictionaryType(const CalpontSystemCatalog::ColType& colType)
|
||||
{
|
||||
return ( (CalpontSystemCatalog::CHAR == colType.colDataType && 8 < colType.colWidth )
|
||||
|| (CalpontSystemCatalog::VARCHAR == colType.colDataType && 7 < colType.colWidth )
|
||||
|| (CalpontSystemCatalog::DECIMAL == colType.colDataType && 18 < colType.precision ));
|
||||
|| (CalpontSystemCatalog::VARCHAR == colType.colDataType && 7 < colType.colWidth )
|
||||
|| (CalpontSystemCatalog::DECIMAL == colType.colDataType && 18 < colType.precision ));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool DDLIndexPopulator::checkConstraints( const IdxTuple& data, const CalpontSystemCatalog::ColType& ctype, int i, int column)
|
||||
{
|
||||
bool DDLIndexPopulator::checkConstraints( const IdxTuple& data, const CalpontSystemCatalog::ColType& ctype, int i, int column)
|
||||
{
|
||||
|
||||
switch( fConstraint )
|
||||
switch ( fConstraint )
|
||||
{
|
||||
case DDL_INVALID_CONSTRAINT:
|
||||
return true;
|
||||
case DDL_INVALID_CONSTRAINT:
|
||||
return true;
|
||||
|
||||
case DDL_UNIQUE:
|
||||
case DDL_PRIMARY_KEY:
|
||||
if ((size_t)column + 1 < fColNames.size() )
|
||||
return true;
|
||||
return checkUnique( i, ctype );
|
||||
case DDL_UNIQUE:
|
||||
case DDL_PRIMARY_KEY:
|
||||
if ((size_t)column + 1 < fColNames.size() )
|
||||
return true;
|
||||
|
||||
case DDL_NOT_NULL:
|
||||
return checkNotNull( data, ctype );
|
||||
return checkUnique( i, ctype );
|
||||
|
||||
case DDL_CHECK:
|
||||
return checkCheck( data, ctype );
|
||||
case DDL_NOT_NULL:
|
||||
return checkNotNull( data, ctype );
|
||||
|
||||
default:
|
||||
return true; //?
|
||||
case DDL_CHECK:
|
||||
return checkCheck( data, ctype );
|
||||
|
||||
default:
|
||||
return true; //?
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the row of data at idx is already in fUniqueColResultList
|
||||
|
||||
bool DDLIndexPopulator::checkUnique( int idx, const CalpontSystemCatalog::ColType& colType )
|
||||
{
|
||||
bool DDLIndexPopulator::checkUnique( int idx, const CalpontSystemCatalog::ColType& colType )
|
||||
{
|
||||
if (0 == idx)
|
||||
return true;
|
||||
return true;
|
||||
|
||||
//Get row of data as each column result data at idx
|
||||
size_t indexSize = fColNames.size();
|
||||
vector <uint64_t> rowIntData(indexSize);
|
||||
@@ -393,147 +428,162 @@ namespace ddlpackageprocessor
|
||||
|
||||
for (size_t i = 0; i < indexSize; ++i)
|
||||
{
|
||||
//if ( isStringType(fUniqueColResultList[i]->columnType()) )
|
||||
if ( isStringType(colType.colDataType) )
|
||||
rowStrData[i] = fUniqueColResultList[i]->GetStringData(idx);
|
||||
else
|
||||
rowIntData[i] = fUniqueColResultList[i]->GetData(idx);
|
||||
//if ( isStringType(fUniqueColResultList[i]->columnType()) )
|
||||
if ( isStringType(colType.colDataType) )
|
||||
rowStrData[i] = fUniqueColResultList[i]->GetStringData(idx);
|
||||
else
|
||||
rowIntData[i] = fUniqueColResultList[i]->GetData(idx);
|
||||
}
|
||||
//check if each value in the idx row is equal to each value in a previous row
|
||||
// i is the row; j is the column.
|
||||
|
||||
//check if each value in the idx row is equal to each value in a previous row
|
||||
// i is the row; j is the column.
|
||||
bool unique = true;
|
||||
|
||||
for (int i = 0; i < idx && unique; ++i)
|
||||
{
|
||||
bool equal = true;
|
||||
for (size_t j = 0; j < indexSize && equal; ++j)
|
||||
{
|
||||
if ( isStringType(colType.colDataType) )
|
||||
{
|
||||
equal = fUniqueColResultList[j]->GetStringData(i) == rowStrData[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
equal = (static_cast<uint64_t>(fUniqueColResultList[j]->GetData(i)) == rowIntData[j]);
|
||||
}
|
||||
}
|
||||
unique = ! equal;
|
||||
bool equal = true;
|
||||
|
||||
for (size_t j = 0; j < indexSize && equal; ++j)
|
||||
{
|
||||
if ( isStringType(colType.colDataType) )
|
||||
{
|
||||
equal = fUniqueColResultList[j]->GetStringData(i) == rowStrData[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
equal = (static_cast<uint64_t>(fUniqueColResultList[j]->GetData(i)) == rowIntData[j]);
|
||||
}
|
||||
}
|
||||
|
||||
unique = ! equal;
|
||||
}
|
||||
|
||||
if (! unique)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << idx;
|
||||
logError("Unique Constraint violated on row: " + ss.str() );
|
||||
stringstream ss;
|
||||
ss << idx;
|
||||
logError("Unique Constraint violated on row: " + ss.str() );
|
||||
}
|
||||
|
||||
return unique;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool DDLIndexPopulator::checkNotNull(const IdxTuple& data, const CalpontSystemCatalog::ColType& colType)
|
||||
{
|
||||
bool DDLIndexPopulator::checkNotNull(const IdxTuple& data, const CalpontSystemCatalog::ColType& colType)
|
||||
{
|
||||
|
||||
any nullvalue = DDLNullValueForType(colType);
|
||||
bool isNull = false;
|
||||
|
||||
switch( colType.colDataType )
|
||||
switch ( colType.colDataType )
|
||||
{
|
||||
case CalpontSystemCatalog::BIT:
|
||||
break;
|
||||
case CalpontSystemCatalog::BIT:
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
isNull = any_cast<char>(data.data) == any_cast<char>(nullvalue);
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
isNull = any_cast<char>(data.data) == any_cast<char>(nullvalue);
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
isNull = any_cast<short>(data.data) == any_cast<short>(nullvalue);
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
isNull = any_cast<short>(data.data) == any_cast<short>(nullvalue);
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
isNull = any_cast<int>(data.data) == any_cast<int>(nullvalue);
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
isNull = any_cast<int>(data.data) == any_cast<int>(nullvalue);
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
isNull = any_cast<long long>(data.data) == any_cast<long long>(nullvalue);
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
isNull = any_cast<long long>(data.data) == any_cast<long long>(nullvalue);
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
{
|
||||
if (colType.colWidth <= CalpontSystemCatalog::FOUR_BYTE)
|
||||
isNull = any_cast<short>(data.data) == any_cast<short>(nullvalue);
|
||||
else if (colType.colWidth <= 9)
|
||||
isNull = any_cast<int>(data.data) == any_cast<int>(nullvalue);
|
||||
else if (colType.colWidth <= 18)
|
||||
isNull = any_cast<long long>(data.data) == any_cast<long long>(nullvalue);
|
||||
else
|
||||
isNull = compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
break;
|
||||
}
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
isNull = any_cast<float>(data.data) == any_cast<float>(nullvalue);
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
{
|
||||
if (colType.colWidth <= CalpontSystemCatalog::FOUR_BYTE)
|
||||
isNull = any_cast<short>(data.data) == any_cast<short>(nullvalue);
|
||||
else if (colType.colWidth <= 9)
|
||||
isNull = any_cast<int>(data.data) == any_cast<int>(nullvalue);
|
||||
else if (colType.colWidth <= 18)
|
||||
isNull = any_cast<long long>(data.data) == any_cast<long long>(nullvalue);
|
||||
else
|
||||
isNull = compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
isNull = any_cast<double>(data.data) == any_cast<double>(nullvalue);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATE:
|
||||
isNull = any_cast<int>(data.data) == any_cast<int>(nullvalue);
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
isNull = any_cast<float>(data.data) == any_cast<float>(nullvalue);
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATETIME:
|
||||
isNull = any_cast<long long>(data.data) == any_cast<long long>(nullvalue);
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
isNull = any_cast<double>(data.data) == any_cast<double>(nullvalue);
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
{
|
||||
if (colType.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
|
||||
isNull = any_cast<string>(data.data) == any_cast<string>(nullvalue);
|
||||
else if (colType.colWidth == execplan::CalpontSystemCatalog::TWO_BYTE)
|
||||
isNull = any_cast<string>(data.data) == any_cast<string>(nullvalue);
|
||||
else if (colType.colWidth <= execplan::CalpontSystemCatalog::FOUR_BYTE)
|
||||
isNull = any_cast<string>(data.data) == any_cast<string>(nullvalue);
|
||||
else
|
||||
isNull = compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::DATE:
|
||||
isNull = any_cast<int>(data.data) == any_cast<int>(nullvalue);
|
||||
break;
|
||||
|
||||
}
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
{
|
||||
if (colType.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
|
||||
isNull = any_cast<string>(data.data) == any_cast<string>(nullvalue);
|
||||
else if (colType.colWidth < execplan::CalpontSystemCatalog::FOUR_BYTE)
|
||||
isNull = any_cast<string>(data.data) == any_cast<string>(nullvalue);
|
||||
else
|
||||
isNull = compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw std::runtime_error("getNullValueForType: unkown column data type");
|
||||
case execplan::CalpontSystemCatalog::DATETIME:
|
||||
isNull = any_cast<long long>(data.data) == any_cast<long long>(nullvalue);
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
{
|
||||
if (colType.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
|
||||
isNull = any_cast<string>(data.data) == any_cast<string>(nullvalue);
|
||||
else if (colType.colWidth == execplan::CalpontSystemCatalog::TWO_BYTE)
|
||||
isNull = any_cast<string>(data.data) == any_cast<string>(nullvalue);
|
||||
else if (colType.colWidth <= execplan::CalpontSystemCatalog::FOUR_BYTE)
|
||||
isNull = any_cast<string>(data.data) == any_cast<string>(nullvalue);
|
||||
else
|
||||
isNull = compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
{
|
||||
if (colType.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
|
||||
isNull = any_cast<string>(data.data) == any_cast<string>(nullvalue);
|
||||
else if (colType.colWidth < execplan::CalpontSystemCatalog::FOUR_BYTE)
|
||||
isNull = any_cast<string>(data.data) == any_cast<string>(nullvalue);
|
||||
else
|
||||
isNull = compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw std::runtime_error("getNullValueForType: unkown column data type");
|
||||
}
|
||||
|
||||
if (isNull)
|
||||
logError("Null value not allowed in index");
|
||||
logError("Null value not allowed in index");
|
||||
|
||||
return ! isNull;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void DDLIndexPopulator::logError(const string& msg, int error)
|
||||
{
|
||||
void DDLIndexPopulator::logError(const string& msg, int error)
|
||||
{
|
||||
|
||||
Message::Args args;
|
||||
Message message(9);
|
||||
args.add((string)__FILE__ + ": ");
|
||||
args.add(msg);
|
||||
|
||||
if (error)
|
||||
{
|
||||
args.add("Error number: ");
|
||||
args.add(error);
|
||||
args.add("Error number: ");
|
||||
args.add(error);
|
||||
}
|
||||
|
||||
message.format( args );
|
||||
|
||||
fResult.result = DDLPackageProcessor::CREATE_ERROR;
|
||||
fResult.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} //namespace
|
||||
|
||||
@@ -43,7 +43,8 @@
|
||||
|
||||
#include "joblistfactory.h"
|
||||
|
||||
namespace joblist {
|
||||
namespace joblist
|
||||
{
|
||||
class DistributedEngineComm;
|
||||
}
|
||||
|
||||
@@ -57,25 +58,25 @@ class DDLIndexPopulator
|
||||
{
|
||||
|
||||
public:
|
||||
/** @brief constructor
|
||||
*
|
||||
*/
|
||||
DDLIndexPopulator(WriteEngine::WriteEngineWrapper* writeEngine,
|
||||
execplan::SessionManager* sessionManager,
|
||||
uint32_t sessionID,
|
||||
execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLPackageProcessor::DDLResult& result,
|
||||
const DDLPackageProcessor::IndexOID& idxOID,
|
||||
const ddlpackage::ColumnNameList& colNames,
|
||||
const ddlpackage::QualifiedName& table,
|
||||
const ddlpackage::DDL_CONSTRAINTS constraint,
|
||||
const DDLPackageProcessor::DebugLevel debug):
|
||||
fWriteEngine(writeEngine), fSessionManager(sessionManager),
|
||||
fSessionID(sessionID), fTxnID(txnID), fResult(result),
|
||||
fIdxOID(idxOID), fColNames(colNames), fTable(table), fDebugLevel(debug),
|
||||
fEC(0), fRidList(), fIdxStructList(), fIdxValueList(),
|
||||
/* fTOKENSIZE(sizeof(WriteEngine::Token) ) {}*/
|
||||
fConstraint(constraint), fUniqueColResultList() {}
|
||||
/** @brief constructor
|
||||
*
|
||||
*/
|
||||
DDLIndexPopulator(WriteEngine::WriteEngineWrapper* writeEngine,
|
||||
execplan::SessionManager* sessionManager,
|
||||
uint32_t sessionID,
|
||||
execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLPackageProcessor::DDLResult& result,
|
||||
const DDLPackageProcessor::IndexOID& idxOID,
|
||||
const ddlpackage::ColumnNameList& colNames,
|
||||
const ddlpackage::QualifiedName& table,
|
||||
const ddlpackage::DDL_CONSTRAINTS constraint,
|
||||
const DDLPackageProcessor::DebugLevel debug):
|
||||
fWriteEngine(writeEngine), fSessionManager(sessionManager),
|
||||
fSessionID(sessionID), fTxnID(txnID), fResult(result),
|
||||
fIdxOID(idxOID), fColNames(colNames), fTable(table), fDebugLevel(debug),
|
||||
fEC(0), fRidList(), fIdxStructList(), fIdxValueList(),
|
||||
/* fTOKENSIZE(sizeof(WriteEngine::Token) ) {}*/
|
||||
fConstraint(constraint), fUniqueColResultList() {}
|
||||
|
||||
|
||||
/** @brief destructor
|
||||
@@ -85,20 +86,35 @@ public:
|
||||
|
||||
/** @brief Is it required to debug
|
||||
*/
|
||||
const bool isDebug( const DDLPackageProcessor::DebugLevel level ) const { return level <= fDebugLevel; }
|
||||
const bool isDebug( const DDLPackageProcessor::DebugLevel level ) const
|
||||
{
|
||||
return level <= fDebugLevel;
|
||||
}
|
||||
|
||||
/** @brief Get debug level
|
||||
*/
|
||||
const DDLPackageProcessor::DebugLevel getDebugLevel() const { return fDebugLevel; }
|
||||
const DDLPackageProcessor::DebugLevel getDebugLevel() const
|
||||
{
|
||||
return fDebugLevel;
|
||||
}
|
||||
|
||||
|
||||
/** @brief set distributedEngineComm pointer ( for
|
||||
* loading index).
|
||||
*/
|
||||
void setEngineComm(joblist::DistributedEngineComm* ec) { fEC = ec; }
|
||||
void setIdxOID(const DDLPackageProcessor::IndexOID& idxOID) { fIdxOID = idxOID; }
|
||||
void setEngineComm(joblist::DistributedEngineComm* ec)
|
||||
{
|
||||
fEC = ec;
|
||||
}
|
||||
void setIdxOID(const DDLPackageProcessor::IndexOID& idxOID)
|
||||
{
|
||||
fIdxOID = idxOID;
|
||||
}
|
||||
|
||||
DDLPackageProcessor::DDLResult getResult() const { return fResult; }
|
||||
DDLPackageProcessor::DDLResult getResult() const
|
||||
{
|
||||
return fResult;
|
||||
}
|
||||
|
||||
|
||||
/** @brief add data to the index from the statement
|
||||
@@ -107,15 +123,15 @@ public:
|
||||
* returns if there was an error.
|
||||
*/
|
||||
bool populateIndex(DDLPackageProcessor::DDLResult& result);
|
||||
/** @brief returns if dictionary type
|
||||
/** @brief returns if dictionary type
|
||||
*
|
||||
* determines if coltype is dictionary type based on type and size
|
||||
*/
|
||||
bool isDictionaryType(const execplan::CalpontSystemCatalog::ColType& ctype);
|
||||
bool isDictionaryType(const execplan::CalpontSystemCatalog::ColType& ctype);
|
||||
|
||||
void setConstraint(ddlpackage::DDL_CONSTRAINTS constraint);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
/** @brief make the structures to update the index
|
||||
*
|
||||
@@ -148,9 +164,9 @@ public:
|
||||
void insertIndex();
|
||||
|
||||
|
||||
private:
|
||||
DDLIndexPopulator(const DDLIndexPopulator& );
|
||||
void operator=(const DDLIndexPopulator& );
|
||||
private:
|
||||
DDLIndexPopulator(const DDLIndexPopulator& );
|
||||
void operator=(const DDLIndexPopulator& );
|
||||
/** @brief makes Calpont Select Execution Plan
|
||||
*
|
||||
* builds csep to select data from all columns from fColNames
|
||||
@@ -165,12 +181,12 @@ public:
|
||||
|
||||
bool isStringType(int type) const
|
||||
{
|
||||
return (type == execplan::CalpontSystemCatalog::CHAR
|
||||
|| type == execplan::CalpontSystemCatalog::VARCHAR
|
||||
|| type == execplan::CalpontSystemCatalog::FLOAT
|
||||
|| type == execplan::CalpontSystemCatalog::DOUBLE
|
||||
|| type == execplan::CalpontSystemCatalog::UFLOAT
|
||||
|| type == execplan::CalpontSystemCatalog::UDOUBLE );
|
||||
return (type == execplan::CalpontSystemCatalog::CHAR
|
||||
|| type == execplan::CalpontSystemCatalog::VARCHAR
|
||||
|| type == execplan::CalpontSystemCatalog::FLOAT
|
||||
|| type == execplan::CalpontSystemCatalog::DOUBLE
|
||||
|| type == execplan::CalpontSystemCatalog::UFLOAT
|
||||
|| type == execplan::CalpontSystemCatalog::UDOUBLE );
|
||||
}
|
||||
|
||||
/** @brief converts column result data
|
||||
@@ -183,31 +199,31 @@ public:
|
||||
*/
|
||||
boost::any convertData(const execplan::CalpontSystemCatalog::ColType& colType, const execplan::ColumnResult* cr, int idx );
|
||||
|
||||
/** @brief returns token for string data
|
||||
*
|
||||
* There are two methods, the one using the rid is a workaround.
|
||||
* Use the method that passes string data when WriteEngine::tokenize is
|
||||
* able to return an existing token for a string. The rid method reads
|
||||
* the column file directly.
|
||||
*/
|
||||
/** @brief returns token for string data
|
||||
*
|
||||
* There are two methods, the one using the rid is a workaround.
|
||||
* Use the method that passes string data when WriteEngine::tokenize is
|
||||
* able to return an existing token for a string. The rid method reads
|
||||
* the column file directly.
|
||||
*/
|
||||
boost::any tokenizeData( const execplan::CalpontSystemCatalog::ColType& colType, const std::string& data );
|
||||
|
||||
boost::any tokenizeData( WriteEngine::RID rid );
|
||||
|
||||
/** @brief convert token data
|
||||
*
|
||||
* Indexes will use the first 8 bytes of a token type value instead
|
||||
* of a token.
|
||||
*/
|
||||
/** @brief convert token data
|
||||
*
|
||||
* Indexes will use the first 8 bytes of a token type value instead
|
||||
* of a token.
|
||||
*/
|
||||
|
||||
boost::any convertTokenData( const std::string& data );
|
||||
|
||||
/** @brief opens the column file for the oid
|
||||
*
|
||||
* This method is needed only as long as the class is using the rid
|
||||
* tokenizeData method. The fColumnFile and this method are no longer
|
||||
* needed when the WriteEngine::tokenize method can be used.
|
||||
*/
|
||||
/** @brief opens the column file for the oid
|
||||
*
|
||||
* This method is needed only as long as the class is using the rid
|
||||
* tokenizeData method. The fColumnFile and this method are no longer
|
||||
* needed when the WriteEngine::tokenize method can be used.
|
||||
*/
|
||||
//bool openColumnFile(WriteEngine::OID oid);
|
||||
|
||||
/** @brief returns if data violated its constraint
|
||||
@@ -229,9 +245,15 @@ public:
|
||||
*/
|
||||
bool checkUnique(int i, const execplan::CalpontSystemCatalog::ColType& colType );
|
||||
|
||||
bool checkCheck( const WriteEngine::IdxTuple& data, const execplan::CalpontSystemCatalog::ColType& ctype) const { return true; }
|
||||
bool checkCheck( const WriteEngine::IdxTuple& data, const execplan::CalpontSystemCatalog::ColType& ctype) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isUnique() { return ddlpackage::DDL_PRIMARY_KEY == fConstraint || ddlpackage::DDL_UNIQUE == fConstraint; }
|
||||
bool isUnique()
|
||||
{
|
||||
return ddlpackage::DDL_PRIMARY_KEY == fConstraint || ddlpackage::DDL_UNIQUE == fConstraint;
|
||||
}
|
||||
/** @brief logs error and message
|
||||
*
|
||||
* Updates result with message and sets it to CREATE_ERROR
|
||||
@@ -240,7 +262,7 @@ public:
|
||||
|
||||
bool compareToken(const WriteEngine::Token& first, const WriteEngine::Token& second) const
|
||||
{
|
||||
return (first.op == second.op && first.fbo == second.fbo && first.spare == second.spare);
|
||||
return (first.op == second.op && first.fbo == second.fbo && first.spare == second.spare);
|
||||
}
|
||||
|
||||
WriteEngine::WriteEngineWrapper* fWriteEngine;
|
||||
@@ -265,13 +287,13 @@ public:
|
||||
|
||||
struct DDLNullValueForType : DDLPackageProcessor
|
||||
{
|
||||
DDLNullValueForType(const execplan::CalpontSystemCatalog::ColType& ctype)
|
||||
: DDLPackageProcessor(), fType(ctype) {}
|
||||
boost::any operator()(execplan::CalpontSystemCatalog::ColType& ctype)
|
||||
{
|
||||
return getNullValueForType(fType);
|
||||
}
|
||||
const execplan::CalpontSystemCatalog::ColType& fType;
|
||||
DDLNullValueForType(const execplan::CalpontSystemCatalog::ColType& ctype)
|
||||
: DDLPackageProcessor(), fType(ctype) {}
|
||||
boost::any operator()(execplan::CalpontSystemCatalog::ColType& ctype)
|
||||
{
|
||||
return getNullValueForType(fType);
|
||||
}
|
||||
const execplan::CalpontSystemCatalog::ColType& fType;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -88,25 +88,27 @@ public:
|
||||
*/
|
||||
enum ResultCode { NO_ERROR, CREATE_ERROR, ALTER_ERROR, DROP_ERROR, TRUNC_ERROR,
|
||||
TOKENIZATION_ERROR, NOT_ACCEPTING_PACKAGES, PK_NOTNULL_ERROR, WARNING, USER_ERROR, NETWORK_ERROR, PARTITION_WARNING,
|
||||
WARN_NO_PARTITION};
|
||||
WARN_NO_PARTITION
|
||||
};
|
||||
|
||||
enum DebugLevel { /** @brief Debug level type enumeration */
|
||||
enum DebugLevel /** @brief Debug level type enumeration */
|
||||
{
|
||||
NONE = 0, /** @brief No debug info */
|
||||
SUMMARY = 1, /** @brief Summary level debug info */
|
||||
DETAIL = 2, /** @brief A little detail debug info */
|
||||
VERBOSE = 3, /** @brief Detailed debug info */
|
||||
};
|
||||
|
||||
enum LogFileType { DROPTABLE_LOG, DROPPART_LOG, TRUNCATE_LOG};
|
||||
typedef std::vector<execplan::CalpontSystemCatalog::OID> OidList;
|
||||
typedef std::set<BRM::LogicalPartition> PartitionNums;
|
||||
struct LogInfo
|
||||
{
|
||||
LogFileType fileType;
|
||||
OidList oids;
|
||||
PartitionNums partitionNums;
|
||||
};
|
||||
typedef std::map<execplan::CalpontSystemCatalog::OID, LogInfo> TableLogInfo;
|
||||
enum LogFileType { DROPTABLE_LOG, DROPPART_LOG, TRUNCATE_LOG};
|
||||
typedef std::vector<execplan::CalpontSystemCatalog::OID> OidList;
|
||||
typedef std::set<BRM::LogicalPartition> PartitionNums;
|
||||
struct LogInfo
|
||||
{
|
||||
LogFileType fileType;
|
||||
OidList oids;
|
||||
PartitionNums partitionNums;
|
||||
};
|
||||
typedef std::map<execplan::CalpontSystemCatalog::OID, LogInfo> TableLogInfo;
|
||||
|
||||
/** @brief the result of dml operations
|
||||
*/
|
||||
@@ -153,58 +155,72 @@ public:
|
||||
int dictOID;
|
||||
int listOID;
|
||||
int treeOID;
|
||||
int colWidth;
|
||||
int compressionType;
|
||||
int colWidth;
|
||||
int compressionType;
|
||||
};
|
||||
/** @brief a structure to hold a date
|
||||
*/
|
||||
|
||||
struct Date
|
||||
{
|
||||
unsigned spare : 6;
|
||||
unsigned day : 6;
|
||||
unsigned month : 4;
|
||||
unsigned year : 16;
|
||||
// NULL column value = 0xFFFFFFFE
|
||||
EXPORT Date( ) { year = 0xFFFF; month = 0xF; day = 0x3F; spare = 0x3E;}
|
||||
unsigned spare : 6;
|
||||
unsigned day : 6;
|
||||
unsigned month : 4;
|
||||
unsigned year : 16;
|
||||
// NULL column value = 0xFFFFFFFE
|
||||
EXPORT Date( )
|
||||
{
|
||||
year = 0xFFFF;
|
||||
month = 0xF;
|
||||
day = 0x3F;
|
||||
spare = 0x3E;
|
||||
}
|
||||
};
|
||||
/*
|
||||
struct Date
|
||||
{
|
||||
int year : 16;
|
||||
int month : 4;
|
||||
int day : 6;
|
||||
int spare : 6;
|
||||
Date( ) { year = 0; month = 0; day = 0; spare = 0;}
|
||||
}; */
|
||||
/*
|
||||
struct Date
|
||||
{
|
||||
int year : 16;
|
||||
int month : 4;
|
||||
int day : 6;
|
||||
int spare : 6;
|
||||
Date( ) { year = 0; month = 0; day = 0; spare = 0;}
|
||||
}; */
|
||||
/** @brief a structure to hold a datetime
|
||||
*/
|
||||
struct dateTime
|
||||
{
|
||||
unsigned msecond : 20;
|
||||
unsigned second : 6;
|
||||
unsigned minute : 6;
|
||||
unsigned hour : 6;
|
||||
unsigned day : 6;
|
||||
unsigned month : 4;
|
||||
unsigned year : 16;
|
||||
// NULL column value = 0xFFFFFFFFFFFFFFFE
|
||||
EXPORT dateTime( ) { year = 0xFFFF; month = 0xF; day = 0x3F; hour = 0x3F; minute = 0x3F; second = 0x3F;
|
||||
msecond = 0xFFFFE; }
|
||||
unsigned msecond : 20;
|
||||
unsigned second : 6;
|
||||
unsigned minute : 6;
|
||||
unsigned hour : 6;
|
||||
unsigned day : 6;
|
||||
unsigned month : 4;
|
||||
unsigned year : 16;
|
||||
// NULL column value = 0xFFFFFFFFFFFFFFFE
|
||||
EXPORT dateTime( )
|
||||
{
|
||||
year = 0xFFFF;
|
||||
month = 0xF;
|
||||
day = 0x3F;
|
||||
hour = 0x3F;
|
||||
minute = 0x3F;
|
||||
second = 0x3F;
|
||||
msecond = 0xFFFFE;
|
||||
}
|
||||
};
|
||||
/*
|
||||
struct dateTime
|
||||
{
|
||||
int year : 16;
|
||||
int month : 4;
|
||||
int day : 6;
|
||||
int hour : 6;
|
||||
int minute : 6;
|
||||
int second : 6;
|
||||
int msecond : 20;
|
||||
dateTime( ) { year = 0; month = 0; day = 0; hour = 0; minute = 0; second = 0; msecond = 0; }
|
||||
}
|
||||
; */
|
||||
/*
|
||||
struct dateTime
|
||||
{
|
||||
int year : 16;
|
||||
int month : 4;
|
||||
int day : 6;
|
||||
int hour : 6;
|
||||
int minute : 6;
|
||||
int second : 6;
|
||||
int msecond : 20;
|
||||
dateTime( ) { year = 0; month = 0; day = 0; hour = 0; minute = 0; second = 0; msecond = 0; }
|
||||
}
|
||||
; */
|
||||
/** @brief a vector of dictionary object ids
|
||||
*/
|
||||
typedef std::vector<DictOID> DictionaryOIDList;
|
||||
@@ -215,33 +231,48 @@ public:
|
||||
struct NJLSysDataList
|
||||
{
|
||||
NJLSysDataVector sysDataVec;
|
||||
EXPORT NJLSysDataList(){};
|
||||
EXPORT NJLSysDataList() {};
|
||||
EXPORT ~NJLSysDataList();
|
||||
NJLSysDataVector::const_iterator begin() {return sysDataVec.begin();}
|
||||
NJLSysDataVector::const_iterator end() {return sysDataVec.end();}
|
||||
void push_back(execplan::ColumnResult* cr) {sysDataVec.push_back(cr);}
|
||||
unsigned int size() {return static_cast<unsigned int>(sysDataVec.size());}
|
||||
int findColumn(const execplan::CalpontSystemCatalog::OID& columnOID)
|
||||
{
|
||||
for(uint32_t i = 0; i < sysDataVec.size(); i++) {
|
||||
if(sysDataVec[i]->ColumnOID() == columnOID) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
NJLSysDataVector::const_iterator begin()
|
||||
{
|
||||
return sysDataVec.begin();
|
||||
}
|
||||
NJLSysDataVector::const_iterator end()
|
||||
{
|
||||
return sysDataVec.end();
|
||||
}
|
||||
void push_back(execplan::ColumnResult* cr)
|
||||
{
|
||||
sysDataVec.push_back(cr);
|
||||
}
|
||||
unsigned int size()
|
||||
{
|
||||
return static_cast<unsigned int>(sysDataVec.size());
|
||||
}
|
||||
int findColumn(const execplan::CalpontSystemCatalog::OID& columnOID)
|
||||
{
|
||||
for (uint32_t i = 0; i < sysDataVec.size(); i++)
|
||||
{
|
||||
if (sysDataVec[i]->ColumnOID() == columnOID)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** @brief constructor
|
||||
*/
|
||||
DDLPackageProcessor(BRM::DBRM* aDbrm) : fStartingColOID(0), fDDLLoggingId(23), fDebugLevel( NONE )
|
||||
{
|
||||
fWEClient = new WriteEngine::WEClients(WriteEngine::WEClients::DDLPROC);
|
||||
fPMCount = fWEClient->getPmCount();
|
||||
fDbrm = aDbrm;
|
||||
//std::cout << "in DDLPackageProcessor constructor " << this << std::endl;
|
||||
}
|
||||
{
|
||||
fWEClient = new WriteEngine::WEClients(WriteEngine::WEClients::DDLPROC);
|
||||
fPMCount = fWEClient->getPmCount();
|
||||
fDbrm = aDbrm;
|
||||
//std::cout << "in DDLPackageProcessor constructor " << this << std::endl;
|
||||
}
|
||||
|
||||
/** @brief destructor
|
||||
*/
|
||||
@@ -250,56 +281,77 @@ public:
|
||||
|
||||
/** @brief Is it required to debug
|
||||
*/
|
||||
const bool isDebug( const DebugLevel level ) const { return level <= fDebugLevel; }
|
||||
const bool isDebug( const DebugLevel level ) const
|
||||
{
|
||||
return level <= fDebugLevel;
|
||||
}
|
||||
|
||||
/** @brief Get debug level
|
||||
*/
|
||||
const DebugLevel getDebugLevel() const { return fDebugLevel; }
|
||||
const DebugLevel getDebugLevel() const
|
||||
{
|
||||
return fDebugLevel;
|
||||
}
|
||||
|
||||
/** @brief Set debug level
|
||||
*/
|
||||
void setDebugLevel( const DebugLevel level ) { fDebugLevel = level; }
|
||||
void setDebugLevel( const DebugLevel level )
|
||||
{
|
||||
fDebugLevel = level;
|
||||
}
|
||||
|
||||
/** @brief Get index oid that was allocated during index creation
|
||||
*/
|
||||
IndexOID getIndexOID() const { return fIdxOID; }
|
||||
IndexOID getIndexOID() const
|
||||
{
|
||||
return fIdxOID;
|
||||
}
|
||||
|
||||
/** @brief Get starting column oid that was allocated during table
|
||||
* creation.
|
||||
*/
|
||||
int getStartingColumnOID() const { return fStartingColOID; }
|
||||
int getStartingColumnOID() const
|
||||
{
|
||||
return fStartingColOID;
|
||||
}
|
||||
|
||||
/** @brief access and mutator of fPKName */
|
||||
const std::string PKName() const {return fPKName;}
|
||||
void PKName (const std::string PKName) {fPKName = PKName;}
|
||||
/** @brief Flush primproc cache for associated lbids.
|
||||
*
|
||||
* @param oidList the list of OIDs for
|
||||
* which the lbids for those files will be removed
|
||||
*/
|
||||
const std::string PKName() const
|
||||
{
|
||||
return fPKName;
|
||||
}
|
||||
void PKName (const std::string PKName)
|
||||
{
|
||||
fPKName = PKName;
|
||||
}
|
||||
/** @brief Flush primproc cache for associated lbids.
|
||||
*
|
||||
* @param oidList the list of OIDs for
|
||||
* which the lbids for those files will be removed
|
||||
*/
|
||||
EXPORT void flushPrimprocCache( std::vector<execplan::CalpontSystemCatalog::OID>& oidList );
|
||||
|
||||
/** @brief remove the physical files
|
||||
*
|
||||
* @param txnID the transaction id
|
||||
* @param oidList the list of OIDs for
|
||||
* which the files should be removed
|
||||
*/
|
||||
/** @brief remove the physical files
|
||||
*
|
||||
* @param txnID the transaction id
|
||||
* @param oidList the list of OIDs for
|
||||
* which the files should be removed
|
||||
*/
|
||||
EXPORT void removeFiles(const uint64_t uniqueId, std::vector<execplan::CalpontSystemCatalog::OID>& oidList);
|
||||
|
||||
EXPORT void createFiles(execplan::CalpontSystemCatalog::TableName aTableName, const int useDBRoot, const uint64_t uniqueId, const uint32_t numOids);
|
||||
EXPORT void createFiles(execplan::CalpontSystemCatalog::TableName aTableName, const int useDBRoot, const uint64_t uniqueId, const uint32_t numOids);
|
||||
|
||||
/** @brief remove the physical files for the specified partition
|
||||
/** @brief remove the physical files for the specified partition
|
||||
*
|
||||
* @param oidList the list of OIDs for
|
||||
* which the files should be removed
|
||||
* @param partition number
|
||||
* @param partition number
|
||||
*/
|
||||
EXPORT void removePartitionFiles(std::vector<execplan::CalpontSystemCatalog::OID>& oidList,
|
||||
const PartitionNums& partitions,
|
||||
uint64_t uniqueId);
|
||||
const PartitionNums& partitions,
|
||||
uint64_t uniqueId);
|
||||
|
||||
/** @brief remove the extents from extent map
|
||||
/** @brief remove the extents from extent map
|
||||
*
|
||||
* @param txnID the transaction id
|
||||
* @param result the result of the operation
|
||||
@@ -309,46 +361,46 @@ public:
|
||||
EXPORT void removeExtents(std::vector<execplan::CalpontSystemCatalog::OID>& oidList);
|
||||
|
||||
|
||||
/** @brief create and open log file to log a table information
|
||||
*
|
||||
* @param tableOid the oid of the table
|
||||
* @param tableName the shcema, table name
|
||||
*/
|
||||
/** @brief create and open log file to log a table information
|
||||
*
|
||||
* @param tableOid the oid of the table
|
||||
* @param tableName the shcema, table name
|
||||
*/
|
||||
EXPORT void createWriteDropLogFile(execplan::CalpontSystemCatalog::OID tableOid,
|
||||
uint64_t uniqueId, std::vector<execplan::CalpontSystemCatalog::OID>& oidList);
|
||||
uint64_t uniqueId, std::vector<execplan::CalpontSystemCatalog::OID>& oidList);
|
||||
|
||||
/** @brief create and open log file to log a table partition information
|
||||
/** @brief create and open log file to log a table partition information
|
||||
*
|
||||
* @param tableOid the oid of the table
|
||||
* @param tableName the shcema, table name
|
||||
* @param partition the partition number to be dropped
|
||||
* @param tableName the shcema, table name
|
||||
* @param partition the partition number to be dropped
|
||||
*/
|
||||
EXPORT void createWritePartitionLogFile(execplan::CalpontSystemCatalog::OID tableOid,
|
||||
const PartitionNums& partitionNums,
|
||||
std::vector<execplan::CalpontSystemCatalog::OID>& oidList,
|
||||
uint64_t uniqueId);
|
||||
const PartitionNums& partitionNums,
|
||||
std::vector<execplan::CalpontSystemCatalog::OID>& oidList,
|
||||
uint64_t uniqueId);
|
||||
|
||||
// EXPORT void createOpenTruncateTableLogFile(execplan::CalpontSystemCatalog::OID tableOid, execplan::CalpontSystemCatalog::TableName tableName);
|
||||
|
||||
/** @brief create and open log file to log a truncae table information
|
||||
/** @brief create and open log file to log a truncae table information
|
||||
*
|
||||
* @param tableOid the oid of the table
|
||||
* @param tableName the shcema, table name
|
||||
* @param tableName the shcema, table name
|
||||
*/
|
||||
EXPORT void createWriteTruncateTableLogFile(execplan::CalpontSystemCatalog::OID tableOid, uint64_t uniqueId, std::vector<execplan::CalpontSystemCatalog::OID>& oidList);
|
||||
|
||||
|
||||
/** @brief delete log file
|
||||
/** @brief delete log file
|
||||
*
|
||||
*/
|
||||
EXPORT void deleteLogFile(LogFileType fileType, execplan::CalpontSystemCatalog::OID tableOid, uint64_t uniqueId);
|
||||
|
||||
/** @brief fetch log file infomation
|
||||
/** @brief fetch log file infomation
|
||||
*
|
||||
*/
|
||||
EXPORT void fetchLogFile(TableLogInfo & tableLogInfos, uint64_t uniqueId);
|
||||
EXPORT void fetchLogFile(TableLogInfo& tableLogInfos, uint64_t uniqueId);
|
||||
|
||||
BRM::TxnID fTxnid;
|
||||
BRM::TxnID fTxnid;
|
||||
|
||||
protected:
|
||||
/** @brief get a list of DDLColumns for the given schema.table
|
||||
@@ -357,8 +409,8 @@ protected:
|
||||
* @param table the table name
|
||||
* @param colList will contain the list of columns on return
|
||||
*/
|
||||
EXPORT void getColumnsForTable( uint32_t sessionID, std::string schema,std::string table,
|
||||
ColumnList& colList );
|
||||
EXPORT void getColumnsForTable( uint32_t sessionID, std::string schema, std::string table,
|
||||
ColumnList& colList );
|
||||
|
||||
/** @brief convert parsed ddl data type to a system catalog data type
|
||||
*
|
||||
@@ -452,9 +504,9 @@ protected:
|
||||
* @param constraintList the table constrain list
|
||||
* @param qualifiedName the name of catalog, schema, object names
|
||||
*/
|
||||
// void writeTableSysConstraintMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::TableConstraintDefList& constraintList, ddlpackage::QualifiedName&
|
||||
// qualifiedName, bool alterFlag=false );
|
||||
// void writeTableSysConstraintMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::TableConstraintDefList& constraintList, ddlpackage::QualifiedName&
|
||||
// qualifiedName, bool alterFlag=false );
|
||||
/** @brief write the table constraint meta data to the SYSCONSTRAINTCOL table
|
||||
*
|
||||
* @param txnID the transaction id
|
||||
@@ -462,9 +514,9 @@ protected:
|
||||
* @param constraintList the table constrain list
|
||||
* @param qualifiedName the name of catalog, schema, object names
|
||||
*/
|
||||
// void writeTableSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
// const DDLResult& result, ddlpackage::TableConstraintDefList& constraintList,
|
||||
// ddlpackage::QualifiedName& qualifiedName, bool alterFlag=false );
|
||||
// void writeTableSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
// const DDLResult& result, ddlpackage::TableConstraintDefList& constraintList,
|
||||
// ddlpackage::QualifiedName& qualifiedName, bool alterFlag=false );
|
||||
|
||||
/** @brief write the column constraint meta data to the SYSCONTRAINT table
|
||||
*
|
||||
@@ -485,7 +537,7 @@ protected:
|
||||
*/
|
||||
// void writeColumnSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
// const DDLResult& result, ddlpackage::ColumnDefList& tableDefCols,
|
||||
// ddlpackage::QualifiedName& qualifiedName);
|
||||
// ddlpackage::QualifiedName& qualifiedName);
|
||||
|
||||
|
||||
/** @brief write the index meta data to the SYSINDEX table
|
||||
@@ -496,10 +548,10 @@ protected:
|
||||
* @param consDef the table constraint
|
||||
* @param indexName name of the index
|
||||
*/
|
||||
// void writeSysIndexMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||
// ddlpackage::QualifiedName& qualifiedName,
|
||||
// ddlpackage::DDL_CONSTRAINTS type,
|
||||
// std::string& indexName, bool multicol, bool alterFlag=false);
|
||||
// void writeSysIndexMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||
// ddlpackage::QualifiedName& qualifiedName,
|
||||
// ddlpackage::DDL_CONSTRAINTS type,
|
||||
// std::string& indexName, bool multicol, bool alterFlag=false);
|
||||
|
||||
/** @brief write the index meta data to the SYSINDEXCOL table
|
||||
*
|
||||
@@ -509,10 +561,10 @@ protected:
|
||||
* @param constraintCols the list of columns in this index
|
||||
* @param indexName name of the index
|
||||
*/
|
||||
// void writeSysIndexColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||
// void writeSysIndexColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||
//ddlpackage::QualifiedName& qualifiedName,
|
||||
// ddlpackage::ColumnNameList& constraintCols,
|
||||
// std::string& indexName, bool alterFlag=false);
|
||||
// ddlpackage::ColumnNameList& constraintCols,
|
||||
// std::string& indexName, bool alterFlag=false);
|
||||
|
||||
/** @brief remove all indexes for the supplied table from the SYSINDEX table
|
||||
*
|
||||
@@ -521,7 +573,7 @@ protected:
|
||||
* @param tableName the qualified name of the table
|
||||
*/
|
||||
//void removeSysIndexMetaDataForTable(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
// DDLResult& result, ddlpackage::QualifiedName& tableName);
|
||||
// DDLResult& result, ddlpackage::QualifiedName& tableName);
|
||||
|
||||
/** @brief remove all index columns for the supplied table from the SYSINDEXCOL table
|
||||
*
|
||||
@@ -529,8 +581,8 @@ protected:
|
||||
* @param result the result of the operation
|
||||
* @param tableName the qualified name of the table
|
||||
*/
|
||||
// void removeSysIndexColMetaDataForTable(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
// DDLResult& result, ddlpackage::QualifiedName& tableName);
|
||||
// void removeSysIndexColMetaDataForTable(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
// DDLResult& result, ddlpackage::QualifiedName& tableName);
|
||||
|
||||
/** @brief remove an index from the SYSINDEX table
|
||||
*
|
||||
@@ -538,7 +590,7 @@ protected:
|
||||
* @param result the result of the operation
|
||||
* @param indexName the qualified name of the index
|
||||
*/
|
||||
// void removeSysIndexMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// void removeSysIndexMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::QualifiedName& indexName);
|
||||
|
||||
/** @brief remove index columns from the SYSINDEXCOL table
|
||||
@@ -547,8 +599,8 @@ protected:
|
||||
* @param result the result of the operation
|
||||
* @param indexName the qualified name of the index
|
||||
*/
|
||||
// void removeSysIndexColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::QualifiedName& indexName);
|
||||
// void removeSysIndexColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::QualifiedName& indexName);
|
||||
|
||||
/** @brief remove the table meta data from the SYSTABLE table
|
||||
*
|
||||
@@ -556,8 +608,8 @@ protected:
|
||||
* @param result the result of the operation
|
||||
* @param tableName the qualified name of the table to remove
|
||||
*/
|
||||
// void removeSysTableMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::QualifiedName& tableName);
|
||||
// void removeSysTableMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::QualifiedName& tableName);
|
||||
|
||||
/** @brief remove the column meta data from the SYSCOLUMN table
|
||||
*
|
||||
@@ -566,8 +618,8 @@ protected:
|
||||
* @param tableName the qualified name of the table whose columns
|
||||
* are to be removed
|
||||
*/
|
||||
// void removeSysColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::QualifiedName& tableName);
|
||||
// void removeSysColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::QualifiedName& tableName);
|
||||
|
||||
/** @brief remove the column meta data from the SYSCOLUMN table
|
||||
*
|
||||
@@ -576,8 +628,8 @@ protected:
|
||||
* @param columnInfo the qualified name of the column
|
||||
* to be removed
|
||||
*/
|
||||
// void removeColSysColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::QualifiedName& columnInfo);
|
||||
// void removeColSysColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::QualifiedName& columnInfo);
|
||||
|
||||
/** @brief remove the constraint meta data from the SYSCONSTRAINT table
|
||||
*
|
||||
@@ -586,8 +638,8 @@ protected:
|
||||
* @param tableName the qualified name of the table whose constraints
|
||||
* are to be removed
|
||||
*/
|
||||
// void removeSysContraintMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::QualifiedName& tableName);
|
||||
// void removeSysContraintMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::QualifiedName& tableName);
|
||||
|
||||
/** @brief remove the constraint meta data from the SYSCONSTRAINT table
|
||||
*
|
||||
@@ -595,9 +647,9 @@ protected:
|
||||
* @param result the result of the operation
|
||||
* @param indexName the index name to be removed
|
||||
*/
|
||||
// void removeSysIndexMetaDataForIndex(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
// DDLResult& result,
|
||||
// execplan::CalpontSystemCatalog::IndexNameList& indexNameList);
|
||||
// void removeSysIndexMetaDataForIndex(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
// DDLResult& result,
|
||||
// execplan::CalpontSystemCatalog::IndexNameList& indexNameList);
|
||||
|
||||
/** @brief remove the column constraint meta data from the SYSCONSTRAINTCOL table
|
||||
*
|
||||
@@ -606,19 +658,19 @@ protected:
|
||||
* @param tableName the qualified name of the table whose column constraints
|
||||
* are to be removed
|
||||
*/
|
||||
// void removeSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::QualifiedName& tableName);
|
||||
/** @brief remove the column constraint meta data from the SYSCONSTRAINT table
|
||||
*
|
||||
* @param txnID the transaction id
|
||||
* @param result the result of the operation
|
||||
* @param constrintNames the names of the constraints
|
||||
* are to be removed
|
||||
*/
|
||||
// void removeSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::QualifiedName& tableName);
|
||||
/** @brief remove the column constraint meta data from the SYSCONSTRAINT table
|
||||
*
|
||||
* @param txnID the transaction id
|
||||
* @param result the result of the operation
|
||||
* @param constrintNames the names of the constraints
|
||||
* are to be removed
|
||||
*/
|
||||
#if 0
|
||||
void removeSysContraintMetaDataForConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result,
|
||||
execplan::CalpontSystemCatalog::IndexNameList& constrintNames);
|
||||
DDLResult& result,
|
||||
execplan::CalpontSystemCatalog::IndexNameList& constrintNames);
|
||||
/** @brief remove the column constraint meta data from the SYSCONSTRAINTCOL table
|
||||
*
|
||||
* @param txnID the transaction id
|
||||
@@ -627,7 +679,7 @@ protected:
|
||||
* are to be removed
|
||||
*/
|
||||
void removeColSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::QualifiedName& columnInfo);
|
||||
ddlpackage::QualifiedName& columnInfo);
|
||||
|
||||
/** @brief create the physical dictionary files
|
||||
*
|
||||
@@ -643,7 +695,7 @@ protected:
|
||||
* @param tableDefCols the table column definition list
|
||||
*/
|
||||
void createColumnFiles(execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||
ddlpackage::ColumnDefList& tableDefCols, const int useDBRoot, const uint32_t partitionNum=0);
|
||||
ddlpackage::ColumnDefList& tableDefCols, const int useDBRoot, const uint32_t partitionNum = 0);
|
||||
|
||||
/** @brief update the SYSCOLUMN table
|
||||
*
|
||||
@@ -653,9 +705,9 @@ protected:
|
||||
* which the column file should be removed
|
||||
*/
|
||||
void updateSyscolumns( execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result, WriteEngine::RIDList& ridList,
|
||||
WriteEngine::ColValueList& colValuesList,
|
||||
WriteEngine::ColValueList& colOldValuesList);
|
||||
DDLResult& result, WriteEngine::RIDList& ridList,
|
||||
WriteEngine::ColValueList& colValuesList,
|
||||
WriteEngine::ColValueList& colOldValuesList);
|
||||
|
||||
/** @brief remove the physical index files
|
||||
*
|
||||
@@ -740,9 +792,9 @@ protected:
|
||||
* @return true if violation
|
||||
*/
|
||||
bool checkConstraintViolation(uint32_t sessionID,
|
||||
DDLResult& result,
|
||||
ddlpackage::QualifiedName& qualifiedName,
|
||||
std::string& checkConstraint);
|
||||
DDLResult& result,
|
||||
ddlpackage::QualifiedName& qualifiedName,
|
||||
std::string& checkConstraint);
|
||||
|
||||
|
||||
/** @brief remove the supplied rows from the supplied system catalog table
|
||||
@@ -758,11 +810,11 @@ protected:
|
||||
|
||||
WriteEngine::WriteEngineWrapper fWriteEngine;
|
||||
|
||||
BRM::DBRM* fDbrm;
|
||||
BRM::DBRM* fDbrm;
|
||||
|
||||
execplan::SessionManager fSessionManager;
|
||||
uint32_t fPMCount;
|
||||
WriteEngine::WEClients* fWEClient;
|
||||
uint32_t fPMCount;
|
||||
WriteEngine::WEClients* fWEClient;
|
||||
|
||||
|
||||
DictionaryOIDList fDictionaryOIDList;
|
||||
@@ -773,45 +825,45 @@ protected:
|
||||
int fStartingColOID;
|
||||
int fColumnNum;
|
||||
IndexOID fIdxOID;
|
||||
std::ofstream fDDLLogFile;
|
||||
std::string fDDLLogFileName;
|
||||
std::ofstream fDDLLogFile;
|
||||
std::string fDDLLogFileName;
|
||||
|
||||
std::string fPKName; // primary key name supplied by Oracle. Oracle will issue
|
||||
// two separate DDL statements for a create table with primary
|
||||
// key DDL, with the 1st one being create index and the 2nd
|
||||
// one being create table. This PK name will be stored here
|
||||
// when creatindexprocessor gets the create index statement. This
|
||||
// is to make sure Calpont use the same system primary key name as Oracle
|
||||
// two separate DDL statements for a create table with primary
|
||||
// key DDL, with the 1st one being create index and the 2nd
|
||||
// one being create table. This PK name will be stored here
|
||||
// when creatindexprocessor gets the create index statement. This
|
||||
// is to make sure Calpont use the same system primary key name as Oracle
|
||||
unsigned const fDDLLoggingId;
|
||||
|
||||
//std::ofstream fDDLLogFile;
|
||||
//std::string fDDLLogFileName;
|
||||
//std::ofstream fDDLLogFile;
|
||||
//std::string fDDLLogFileName;
|
||||
|
||||
/** @brief convert absolute rid to relative rid in a segement file
|
||||
/** @brief convert absolute rid to relative rid in a segement file
|
||||
*
|
||||
* @param rid in:the absolute rid out: relative rid in a segement file
|
||||
* @param dbRoot,partition, segment the extent information obtained from rid
|
||||
* @param filesPerColumnPartition,extentRows, extentsPerSegmentFile the extent map parameters
|
||||
* @param startDBRoot the dbroot this table starts
|
||||
* @param dbrootCnt the number of dbroot in db
|
||||
*/
|
||||
void convertRidToColumn(uint64_t& rid, unsigned& dbRoot, unsigned& partition,
|
||||
unsigned& segment, unsigned filesPerColumnPartition,
|
||||
unsigned extentsPerSegmentFile, unsigned extentRows,
|
||||
unsigned startDBRoot, unsigned dbrootCnt);
|
||||
* @param startDBRoot the dbroot this table starts
|
||||
* @param dbrootCnt the number of dbroot in db
|
||||
*/
|
||||
void convertRidToColumn(uint64_t& rid, unsigned& dbRoot, unsigned& partition,
|
||||
unsigned& segment, unsigned filesPerColumnPartition,
|
||||
unsigned extentsPerSegmentFile, unsigned extentRows,
|
||||
unsigned startDBRoot, unsigned dbrootCnt);
|
||||
|
||||
int rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID);
|
||||
int commitTransaction(uint64_t uniqueId, BRM::TxnID txnID);
|
||||
int rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID);
|
||||
int commitTransaction(uint64_t uniqueId, BRM::TxnID txnID);
|
||||
|
||||
// MCOL-66 The DBRM can't handle concurrent DDL
|
||||
static boost::mutex dbrmMutex;
|
||||
private:
|
||||
/** @brief clean beginning and ending glitches and spaces from string
|
||||
*
|
||||
* @param s string to be cleaned
|
||||
*/
|
||||
/** @brief clean beginning and ending glitches and spaces from string
|
||||
*
|
||||
* @param s string to be cleaned
|
||||
*/
|
||||
void cleanString(std::string& s);
|
||||
//std::string fDDLLogFileName;
|
||||
//std::string fDDLLogFileName;
|
||||
DebugLevel fDebugLevel; // internal use debug level
|
||||
|
||||
|
||||
@@ -823,7 +875,7 @@ private:
|
||||
template <class T>
|
||||
bool from_string(T& t,
|
||||
const std::string& s,
|
||||
std::ios_base& (*f)(std::ios_base&))
|
||||
std::ios_base & (*f)(std::ios_base&))
|
||||
{
|
||||
std::istringstream iss(s);
|
||||
return !(iss >> f >> t).fail();
|
||||
|
||||
@@ -28,30 +28,31 @@
|
||||
|
||||
using namespace ddlpackage;
|
||||
|
||||
namespace ddlpackageprocessor {
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
DDLPackageProcessor* DDLPackageProcessorFactory::
|
||||
makePackageProcessor(int packageType, ddlpackage::CalpontDDLPackage& cpackage)
|
||||
{
|
||||
DDLPackageProcessor* ddlProcPtr = 0;
|
||||
DDLPackageProcessor* ddlProcPtr = 0;
|
||||
|
||||
switch( packageType )
|
||||
{
|
||||
case DDL_CREATE:
|
||||
ddlProcPtr = new CreatePackageProcessor();
|
||||
break;
|
||||
switch ( packageType )
|
||||
{
|
||||
case DDL_CREATE:
|
||||
ddlProcPtr = new CreatePackageProcessor();
|
||||
break;
|
||||
|
||||
case DDL_ALTER:
|
||||
ddlProcPtr = new AlterPackageProcessor();
|
||||
break;
|
||||
case DDL_ALTER:
|
||||
ddlProcPtr = new AlterPackageProcessor();
|
||||
break;
|
||||
|
||||
case DDL_DROP:
|
||||
ddlProcPtr = new DropPackageProcessor();
|
||||
break;
|
||||
case DDL_DROP:
|
||||
ddlProcPtr = new DropPackageProcessor();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return ddlProcPtr;
|
||||
return ddlProcPtr;
|
||||
}
|
||||
|
||||
} // namespace ddlpackageprocessor
|
||||
|
||||
@@ -28,22 +28,24 @@
|
||||
#include "ddlpackageprocessor.h"
|
||||
|
||||
|
||||
namespace ddlpackageprocessor {
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
/** @brief create a ddlPackageProcessor object from a CalpontddlPackage object
|
||||
*
|
||||
*/
|
||||
class DDLPackageProcessorFactory {
|
||||
class DDLPackageProcessorFactory
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/** @brief static ddlPackageProcessor constructor method
|
||||
*
|
||||
* @param packageType the ddl Package type
|
||||
* @param cpackage the CalpontddlPackage from which the ddlPackageProcessor is constructed
|
||||
*/
|
||||
static DDLPackageProcessor*
|
||||
makePackageProcessor( int packageType, ddlpackage::CalpontDDLPackage& cpackage );
|
||||
/** @brief static ddlPackageProcessor constructor method
|
||||
*
|
||||
* @param packageType the ddl Package type
|
||||
* @param cpackage the CalpontddlPackage from which the ddlPackageProcessor is constructed
|
||||
*/
|
||||
static DDLPackageProcessor*
|
||||
makePackageProcessor( int packageType, ddlpackage::CalpontDDLPackage& cpackage );
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
||||
CalpontSystemCatalog::IndexOID indexOID;
|
||||
|
||||
BRM::TxnID txnID;
|
||||
txnID.id= fTxnid.id;
|
||||
txnID.valid= fTxnid.valid;
|
||||
txnID.id = fTxnid.id;
|
||||
txnID.valid = fTxnid.valid;
|
||||
|
||||
DDLResult result;
|
||||
result.result = NO_ERROR;
|
||||
@@ -49,9 +49,9 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
||||
|
||||
VERBOSE_INFO(dropIndexStmt);
|
||||
|
||||
SQLLogger logger(dropIndexStmt.fSql, fDDLLoggingId, dropIndexStmt.fSessionID, txnID.id);
|
||||
SQLLogger logger(dropIndexStmt.fSql, fDDLLoggingId, dropIndexStmt.fSessionID, txnID.id);
|
||||
|
||||
indexName.schema = dropIndexStmt.fIndexName->fSchema;
|
||||
indexName.schema = dropIndexStmt.fIndexName->fSchema;
|
||||
indexName.index = dropIndexStmt.fIndexName->fName;
|
||||
//Look up table name from indexname. Oracle will error out if same constraintname or indexname exists.
|
||||
CalpontSystemCatalog::TableName tableName = sysCatalogPtr->lookupTableForIndex (dropIndexStmt.fIndexName->fName, dropIndexStmt.fIndexName->fSchema );
|
||||
@@ -60,6 +60,7 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
||||
|
||||
VERBOSE_INFO("Removing the SYSINDEX meta data");
|
||||
removeSysIndexMetaData(dropIndexStmt.fSessionID, txnID.id, result, *dropIndexStmt.fIndexName);
|
||||
|
||||
if (result.result != NO_ERROR)
|
||||
{
|
||||
DETAIL_INFO("writeSysIndexMetaData failed");
|
||||
@@ -68,6 +69,7 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
||||
|
||||
VERBOSE_INFO("Removing the SYSINDEXCOL meta data");
|
||||
removeSysIndexColMetaData(dropIndexStmt.fSessionID, txnID.id, result, *dropIndexStmt.fIndexName);
|
||||
|
||||
if (result.result != NO_ERROR)
|
||||
{
|
||||
DETAIL_INFO("writeSysIndexMetaData failed");
|
||||
@@ -76,7 +78,8 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
||||
|
||||
|
||||
VERBOSE_INFO("Removing the index files");
|
||||
err = fWriteEngine.dropIndex(txnID.id, indexOID.objnum,indexOID.listOID);
|
||||
err = fWriteEngine.dropIndex(txnID.id, indexOID.objnum, indexOID.listOID);
|
||||
|
||||
if (err)
|
||||
{
|
||||
DETAIL_INFO("WriteEngine dropIndex failed");
|
||||
@@ -88,11 +91,13 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
||||
|
||||
// register the changes
|
||||
err = fWriteEngine.commit( txnID.id );
|
||||
|
||||
if (err)
|
||||
{
|
||||
DETAIL_INFO("Failed to commit the drop index transaction");
|
||||
goto rollback;
|
||||
}
|
||||
|
||||
fSessionManager.committed(txnID);
|
||||
//fObjectIDManager.returnOID(indexOID.objnum);
|
||||
//fObjectIDManager.returnOID(indexOID.listOID);
|
||||
|
||||
@@ -28,24 +28,24 @@
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
/** @brief specialization of a DDLPacakageProcessor
|
||||
* for interaction with the Write Engine to process
|
||||
* drop index statements.
|
||||
/** @brief specialization of a DDLPacakageProcessor
|
||||
* for interaction with the Write Engine to process
|
||||
* drop index statements.
|
||||
*/
|
||||
class DropIndexProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
/** @brief process a drop index statement
|
||||
*
|
||||
* @param dropIndexStmt the drop index statement
|
||||
*/
|
||||
class DropIndexProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
/** @brief process a drop index statement
|
||||
*
|
||||
* @param dropIndexStmt the drop index statement
|
||||
*/
|
||||
DDLResult processPackage(ddlpackage::DropIndexStatement& dropIndexStmt);
|
||||
DDLResult processPackage(ddlpackage::DropIndexStatement& dropIndexStmt);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
} //namespace ddlpackageprocessor
|
||||
#endif //DROPINDEXPROCESSOR_H
|
||||
|
||||
@@ -38,316 +38,343 @@ using namespace oam;
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
DropPartitionProcessor::DDLResult DropPartitionProcessor::processPackage(ddlpackage::DropPartitionStatement& dropPartitionStmt)
|
||||
{
|
||||
SUMMARY_INFO("DropPartitionProcessor::processPackage");
|
||||
DropPartitionProcessor::DDLResult DropPartitionProcessor::processPackage(ddlpackage::DropPartitionStatement& dropPartitionStmt)
|
||||
{
|
||||
SUMMARY_INFO("DropPartitionProcessor::processPackage");
|
||||
|
||||
DDLResult result;
|
||||
result.result = NO_ERROR;
|
||||
std::string err;
|
||||
VERBOSE_INFO(dropPartitionStmt);
|
||||
DDLResult result;
|
||||
result.result = NO_ERROR;
|
||||
std::string err;
|
||||
VERBOSE_INFO(dropPartitionStmt);
|
||||
|
||||
// Commit current transaction.
|
||||
// all DDL statements cause an implicit commit
|
||||
VERBOSE_INFO("Getting current txnID");
|
||||
// Commit current transaction.
|
||||
// all DDL statements cause an implicit commit
|
||||
VERBOSE_INFO("Getting current txnID");
|
||||
|
||||
int rc = 0;
|
||||
rc = fDbrm->isReadWrite();
|
||||
BRM::TxnID txnID;
|
||||
txnID.id= fTxnid.id;
|
||||
txnID.valid= fTxnid.valid;
|
||||
if (rc != 0 )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add("Unable to execute the statement due to DBRM is read only");
|
||||
message.format(args);
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
int rc = 0;
|
||||
rc = fDbrm->isReadWrite();
|
||||
BRM::TxnID txnID;
|
||||
txnID.id = fTxnid.id;
|
||||
txnID.valid = fTxnid.valid;
|
||||
|
||||
if (rc != 0 )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add("Unable to execute the statement due to DBRM is read only");
|
||||
message.format(args);
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
std::vector <CalpontSystemCatalog::OID> oidList;
|
||||
CalpontSystemCatalog::RIDList tableColRidList;
|
||||
CalpontSystemCatalog::DictOIDList dictOIDList;
|
||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||
uint32_t processID = 0;
|
||||
uint64_t uniqueID = 0;
|
||||
uint32_t sessionID = dropPartitionStmt.fSessionID;
|
||||
std::string processName("DDLProc");
|
||||
uint64_t uniqueId = 0;
|
||||
std::vector <CalpontSystemCatalog::OID> oidList;
|
||||
CalpontSystemCatalog::RIDList tableColRidList;
|
||||
CalpontSystemCatalog::DictOIDList dictOIDList;
|
||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||
uint32_t processID = 0;
|
||||
uint64_t uniqueID = 0;
|
||||
uint32_t sessionID = dropPartitionStmt.fSessionID;
|
||||
std::string processName("DDLProc");
|
||||
uint64_t uniqueId = 0;
|
||||
|
||||
//Bug 5070. Added exception handling
|
||||
try {
|
||||
uniqueId = fDbrm->getUnique64();
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add(ex.what());
|
||||
message.format(args);
|
||||
result.result = ALTER_ERROR;
|
||||
result.message = message;
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add("Unknown error occured while getting unique number.");
|
||||
message.format(args);
|
||||
result.result = ALTER_ERROR;
|
||||
result.message = message;
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
//Bug 5070. Added exception handling
|
||||
try
|
||||
{
|
||||
uniqueId = fDbrm->getUnique64();
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add(ex.what());
|
||||
message.format(args);
|
||||
result.result = ALTER_ERROR;
|
||||
result.message = message;
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add("Unknown error occured while getting unique number.");
|
||||
message.format(args);
|
||||
result.result = ALTER_ERROR;
|
||||
result.message = message;
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
string stmt = dropPartitionStmt.fSql + "|" + dropPartitionStmt.fTableName->fSchema +"|";
|
||||
SQLLogger logger(stmt, fDDLLoggingId, sessionID, txnID.id);
|
||||
string stmt = dropPartitionStmt.fSql + "|" + dropPartitionStmt.fTableName->fSchema + "|";
|
||||
SQLLogger logger(stmt, fDDLLoggingId, sessionID, txnID.id);
|
||||
|
||||
try
|
||||
{
|
||||
//check table lock
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(dropPartitionStmt.fSessionID);
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
systemCatalogPtr->sessionID(dropPartitionStmt.fSessionID);
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
tableName.schema = dropPartitionStmt.fTableName->fSchema;
|
||||
tableName.table = dropPartitionStmt.fTableName->fName;
|
||||
roPair = systemCatalogPtr->tableRID( tableName );
|
||||
//@Bug 3054 check for system catalog
|
||||
if ( roPair.objnum < 3000 )
|
||||
{
|
||||
throw std::runtime_error("Drop partition cannot be operated on Calpont system catalog.");
|
||||
}
|
||||
int i = 0;
|
||||
processID = ::getpid();
|
||||
oam::OamCache * oamcache = OamCache::makeOamCache();
|
||||
std::vector<int> pmList = oamcache->getModuleIds();
|
||||
std::vector<uint32_t> pms;
|
||||
for (unsigned i=0; i < pmList.size(); i++)
|
||||
{
|
||||
pms.push_back((uint32_t)pmList[i]);
|
||||
}
|
||||
try
|
||||
{
|
||||
//check table lock
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(dropPartitionStmt.fSessionID);
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
systemCatalogPtr->sessionID(dropPartitionStmt.fSessionID);
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
tableName.schema = dropPartitionStmt.fTableName->fSchema;
|
||||
tableName.table = dropPartitionStmt.fTableName->fName;
|
||||
roPair = systemCatalogPtr->tableRID( tableName );
|
||||
|
||||
try {
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
// no need to release lock. dbrm un-hold the lock
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
//@Bug 3054 check for system catalog
|
||||
if ( roPair.objnum < 3000 )
|
||||
{
|
||||
throw std::runtime_error("Drop partition cannot be operated on Calpont system catalog.");
|
||||
}
|
||||
|
||||
if ( uniqueID == 0 )
|
||||
{
|
||||
int waitPeriod = 10;
|
||||
int sleepTime = 100; // sleep 100 milliseconds between checks
|
||||
int numTries = 10; // try 10 times per second
|
||||
waitPeriod = Config::getWaitPeriod();
|
||||
numTries = waitPeriod * 10;
|
||||
struct timespec rm_ts;
|
||||
int i = 0;
|
||||
processID = ::getpid();
|
||||
oam::OamCache* oamcache = OamCache::makeOamCache();
|
||||
std::vector<int> pmList = oamcache->getModuleIds();
|
||||
std::vector<uint32_t> pms;
|
||||
|
||||
rm_ts.tv_sec = sleepTime/1000;
|
||||
rm_ts.tv_nsec = sleepTime%1000 *1000000;
|
||||
for (unsigned i = 0; i < pmList.size(); i++)
|
||||
{
|
||||
pms.push_back((uint32_t)pmList[i]);
|
||||
}
|
||||
|
||||
for (; i < numTries; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
// no need to release lock. dbrm un-hold the lock
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
if ( uniqueID == 0 )
|
||||
{
|
||||
int waitPeriod = 10;
|
||||
int sleepTime = 100; // sleep 100 milliseconds between checks
|
||||
int numTries = 10; // try 10 times per second
|
||||
waitPeriod = Config::getWaitPeriod();
|
||||
numTries = waitPeriod * 10;
|
||||
struct timespec rm_ts;
|
||||
|
||||
rm_ts.tv_sec = sleepTime / 1000;
|
||||
rm_ts.tv_nsec = sleepTime % 1000 * 1000000;
|
||||
|
||||
for (; i < numTries; i++)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
#else
|
||||
struct timespec abs_ts;
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while(nanosleep(&abs_ts,&rm_ts) < 0);
|
||||
struct timespec abs_ts;
|
||||
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
// reset
|
||||
sessionID = dropPartitionStmt.fSessionID;
|
||||
txnID.id= fTxnid.id;
|
||||
txnID.valid= fTxnid.valid;
|
||||
processID = ::getpid();
|
||||
processName = "DDLProc";
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
// reset
|
||||
sessionID = dropPartitionStmt.fSessionID;
|
||||
txnID.id = fTxnid.id;
|
||||
txnID.valid = fTxnid.valid;
|
||||
processID = ::getpid();
|
||||
processName = "DDLProc";
|
||||
|
||||
if (uniqueID > 0)
|
||||
break;
|
||||
}
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (i >= numTries) //error out
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
logging::Message::Args args;
|
||||
string strOp("drop partition");
|
||||
args.add(strOp);
|
||||
args.add(processName);
|
||||
args.add((uint64_t)processID);
|
||||
args.add((uint64_t)sessionID);
|
||||
result.message = Message(IDBErrorInfo::instance()->errorMsg(ERR_TABLE_LOCKED,args));
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (uniqueID > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
// 1. Get the OIDs for the columns
|
||||
// 2. Get the OIDs for the dictionaries
|
||||
// 3. Save the OIDs to a log file
|
||||
// 4. Disable the extents from extentmap for the partition
|
||||
// 5. Remove the column and dictionary files for the partition
|
||||
// 6. Flush PrimProc Cache
|
||||
// 7. Remove the extents from extentmap for the partition
|
||||
if (i >= numTries) //error out
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
logging::Message::Args args;
|
||||
string strOp("drop partition");
|
||||
args.add(strOp);
|
||||
args.add(processName);
|
||||
args.add((uint64_t)processID);
|
||||
args.add((uint64_t)sessionID);
|
||||
result.message = Message(IDBErrorInfo::instance()->errorMsg(ERR_TABLE_LOCKED, args));
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
CalpontSystemCatalog::TableName userTableName;
|
||||
userTableName.schema = dropPartitionStmt.fTableName->fSchema;
|
||||
userTableName.table = dropPartitionStmt.fTableName->fName;
|
||||
// 1. Get the OIDs for the columns
|
||||
// 2. Get the OIDs for the dictionaries
|
||||
// 3. Save the OIDs to a log file
|
||||
// 4. Disable the extents from extentmap for the partition
|
||||
// 5. Remove the column and dictionary files for the partition
|
||||
// 6. Flush PrimProc Cache
|
||||
// 7. Remove the extents from extentmap for the partition
|
||||
|
||||
tableColRidList = systemCatalogPtr->columnRIDs( userTableName );
|
||||
CalpontSystemCatalog::TableName userTableName;
|
||||
userTableName.schema = dropPartitionStmt.fTableName->fSchema;
|
||||
userTableName.table = dropPartitionStmt.fTableName->fName;
|
||||
|
||||
dictOIDList = systemCatalogPtr->dictOIDs( userTableName );
|
||||
tableColRidList = systemCatalogPtr->columnRIDs( userTableName );
|
||||
|
||||
//Save qualified tablename, all column, dictionary OIDs, and transaction ID into a file in ASCII format
|
||||
for ( unsigned i=0; i < tableColRidList.size(); i++ )
|
||||
{
|
||||
if ( tableColRidList[i].objnum > 3000 )
|
||||
oidList.push_back( tableColRidList[i].objnum );
|
||||
}
|
||||
for ( unsigned i=0; i < dictOIDList.size(); i++ )
|
||||
{
|
||||
if ( dictOIDList[i].dictOID > 3000 )
|
||||
oidList.push_back( dictOIDList[i].dictOID );
|
||||
}
|
||||
dictOIDList = systemCatalogPtr->dictOIDs( userTableName );
|
||||
|
||||
//Mark the partition disabled from extent map
|
||||
string emsg;
|
||||
rc = fDbrm->markPartitionForDeletion( oidList, dropPartitionStmt.fPartitions, emsg);
|
||||
if (rc != 0 && rc !=BRM::ERR_PARTITION_DISABLED &&
|
||||
rc != BRM::ERR_INVALID_OP_LAST_PARTITION &&
|
||||
rc != BRM::ERR_NOT_EXIST_PARTITION)
|
||||
{
|
||||
throw std::runtime_error(emsg);
|
||||
}
|
||||
//Save qualified tablename, all column, dictionary OIDs, and transaction ID into a file in ASCII format
|
||||
for ( unsigned i = 0; i < tableColRidList.size(); i++ )
|
||||
{
|
||||
if ( tableColRidList[i].objnum > 3000 )
|
||||
oidList.push_back( tableColRidList[i].objnum );
|
||||
}
|
||||
|
||||
set<BRM::LogicalPartition> markedPartitions;
|
||||
set<BRM::LogicalPartition> outOfServicePartitions;
|
||||
for ( unsigned i = 0; i < dictOIDList.size(); i++ )
|
||||
{
|
||||
if ( dictOIDList[i].dictOID > 3000 )
|
||||
oidList.push_back( dictOIDList[i].dictOID );
|
||||
}
|
||||
|
||||
// only log partitions that are successfully marked disabled.
|
||||
rc = fDbrm->getOutOfServicePartitions(oidList[0], outOfServicePartitions);
|
||||
//Mark the partition disabled from extent map
|
||||
string emsg;
|
||||
rc = fDbrm->markPartitionForDeletion( oidList, dropPartitionStmt.fPartitions, emsg);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
string errorMsg;
|
||||
BRM::errString(rc, errorMsg);
|
||||
ostringstream oss;
|
||||
oss << "getOutOfServicePartitions failed due to " << errorMsg;
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
if (rc != 0 && rc != BRM::ERR_PARTITION_DISABLED &&
|
||||
rc != BRM::ERR_INVALID_OP_LAST_PARTITION &&
|
||||
rc != BRM::ERR_NOT_EXIST_PARTITION)
|
||||
{
|
||||
throw std::runtime_error(emsg);
|
||||
}
|
||||
|
||||
set<BRM::LogicalPartition>::iterator it;
|
||||
for (it = dropPartitionStmt.fPartitions.begin(); it != dropPartitionStmt.fPartitions.end(); ++it)
|
||||
{
|
||||
if (outOfServicePartitions.find(*it) != outOfServicePartitions.end())
|
||||
markedPartitions.insert(*it);
|
||||
}
|
||||
set<BRM::LogicalPartition> markedPartitions;
|
||||
set<BRM::LogicalPartition> outOfServicePartitions;
|
||||
|
||||
//Save the oids to a file
|
||||
createWritePartitionLogFile( roPair.objnum, markedPartitions, oidList, uniqueId);
|
||||
// only log partitions that are successfully marked disabled.
|
||||
rc = fDbrm->getOutOfServicePartitions(oidList[0], outOfServicePartitions);
|
||||
|
||||
VERBOSE_INFO("Removing files");
|
||||
removePartitionFiles( oidList, markedPartitions, uniqueId );
|
||||
//Flush PrimProc cache for those lbids
|
||||
rc = cacheutils::flushPartition( oidList, markedPartitions );
|
||||
if (rc != 0)
|
||||
{
|
||||
string errorMsg;
|
||||
BRM::errString(rc, errorMsg);
|
||||
ostringstream oss;
|
||||
oss << "getOutOfServicePartitions failed due to " << errorMsg;
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
|
||||
//Remove the partition from extent map
|
||||
emsg.clear();
|
||||
rc = fDbrm->deletePartition( oidList, dropPartitionStmt.fPartitions, emsg);
|
||||
if ( rc != 0 )
|
||||
throw std::runtime_error(emsg);
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
cerr << "DropPartitionProcessor::processPackage: " << ex.what() << endl;
|
||||
set<BRM::LogicalPartition>::iterator it;
|
||||
|
||||
logging::Message::Args args;
|
||||
logging::Message message(ex.what());
|
||||
for (it = dropPartitionStmt.fPartitions.begin(); it != dropPartitionStmt.fPartitions.end(); ++it)
|
||||
{
|
||||
if (outOfServicePartitions.find(*it) != outOfServicePartitions.end())
|
||||
markedPartitions.insert(*it);
|
||||
}
|
||||
|
||||
if (rc == BRM::ERR_TABLE_NOT_LOCKED)
|
||||
result.result = USER_ERROR;
|
||||
else if (rc == BRM::ERR_NOT_EXIST_PARTITION || rc == BRM::ERR_INVALID_OP_LAST_PARTITION)
|
||||
result.result = PARTITION_WARNING;
|
||||
else if (rc == BRM::ERR_NO_PARTITION_PERFORMED)
|
||||
result.result = WARN_NO_PARTITION;
|
||||
else
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
try {
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cerr << "DropPartitionProcessor::processPackage: caught unknown exception!" << endl;
|
||||
//Save the oids to a file
|
||||
createWritePartitionLogFile( roPair.objnum, markedPartitions, oidList, uniqueId);
|
||||
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add("Drop partition failed: ");
|
||||
args.add( "encountered unkown exception" );
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format( args );
|
||||
VERBOSE_INFO("Removing files");
|
||||
removePartitionFiles( oidList, markedPartitions, uniqueId );
|
||||
//Flush PrimProc cache for those lbids
|
||||
rc = cacheutils::flushPartition( oidList, markedPartitions );
|
||||
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
try {
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
// Log the DDL statement
|
||||
logging::logDDL(dropPartitionStmt.fSessionID, txnID.id, dropPartitionStmt.fSql, dropPartitionStmt.fOwner);
|
||||
//Remove the log file
|
||||
//release the transaction
|
||||
try {
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
deleteLogFile(DROPPART_LOG, roPair.objnum, uniqueId);
|
||||
} catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
fSessionManager.committed(txnID);
|
||||
return result;
|
||||
}
|
||||
//Remove the partition from extent map
|
||||
emsg.clear();
|
||||
rc = fDbrm->deletePartition( oidList, dropPartitionStmt.fPartitions, emsg);
|
||||
|
||||
if ( rc != 0 )
|
||||
throw std::runtime_error(emsg);
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
cerr << "DropPartitionProcessor::processPackage: " << ex.what() << endl;
|
||||
|
||||
logging::Message::Args args;
|
||||
logging::Message message(ex.what());
|
||||
|
||||
if (rc == BRM::ERR_TABLE_NOT_LOCKED)
|
||||
result.result = USER_ERROR;
|
||||
else if (rc == BRM::ERR_NOT_EXIST_PARTITION || rc == BRM::ERR_INVALID_OP_LAST_PARTITION)
|
||||
result.result = PARTITION_WARNING;
|
||||
else if (rc == BRM::ERR_NO_PARTITION_PERFORMED)
|
||||
result.result = WARN_NO_PARTITION;
|
||||
else
|
||||
result.result = DROP_ERROR;
|
||||
|
||||
result.message = message;
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cerr << "DropPartitionProcessor::processPackage: caught unknown exception!" << endl;
|
||||
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add("Drop partition failed: ");
|
||||
args.add( "encountered unkown exception" );
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format( args );
|
||||
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Log the DDL statement
|
||||
logging::logDDL(dropPartitionStmt.fSessionID, txnID.id, dropPartitionStmt.fSql, dropPartitionStmt.fOwner);
|
||||
|
||||
//Remove the log file
|
||||
//release the transaction
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
deleteLogFile(DROPPART_LOG, roPair.objnum, uniqueId);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
fSessionManager.committed(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,25 +34,25 @@
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
/** @brief specialization of a DDLPacakageProcessor
|
||||
* for interacting with the Write Engine to process
|
||||
* drop table ddl statements.
|
||||
/** @brief specialization of a DDLPacakageProcessor
|
||||
* for interacting with the Write Engine to process
|
||||
* drop table ddl statements.
|
||||
*/
|
||||
class DropPartitionProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
DropPartitionProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||
/** @brief process a drop table statement
|
||||
*
|
||||
* @param dropTableStmt the drop table statement
|
||||
*/
|
||||
class DropPartitionProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
DropPartitionProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm){}
|
||||
/** @brief process a drop table statement
|
||||
*
|
||||
* @param dropTableStmt the drop table statement
|
||||
*/
|
||||
EXPORT DDLResult processPackage(ddlpackage::DropPartitionStatement& dropPartitionStmt);
|
||||
EXPORT DDLResult processPackage(ddlpackage::DropPartitionStatement& dropPartitionStmt);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
};
|
||||
};
|
||||
} // namespace ddlpackageprocessor
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,45 +34,45 @@
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
/** @brief specialization of a DDLPacakageProcessor
|
||||
* for interacting with the Write Engine to process
|
||||
* drop table ddl statements.
|
||||
/** @brief specialization of a DDLPacakageProcessor
|
||||
* for interacting with the Write Engine to process
|
||||
* drop table ddl statements.
|
||||
*/
|
||||
class DropTableProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
DropTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||
/** @brief process a drop table statement
|
||||
*
|
||||
* @param dropTableStmt the drop table statement
|
||||
*/
|
||||
class DropTableProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
DropTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm){}
|
||||
/** @brief process a drop table statement
|
||||
*
|
||||
* @param dropTableStmt the drop table statement
|
||||
*/
|
||||
EXPORT DDLResult processPackage(ddlpackage::DropTableStatement& dropTableStmt);
|
||||
EXPORT DDLResult processPackage(ddlpackage::DropTableStatement& dropTableStmt);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
/** @brief specialization of a DDLPacakageProcessor
|
||||
* for interacting with the Write Engine to process
|
||||
* truncate table ddl statements.
|
||||
/** @brief specialization of a DDLPacakageProcessor
|
||||
* for interacting with the Write Engine to process
|
||||
* truncate table ddl statements.
|
||||
*/
|
||||
class TruncTableProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
TruncTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||
/** @brief process a truncate table statement
|
||||
*
|
||||
* @param truncTableStmt the truncate table statement
|
||||
*/
|
||||
class TruncTableProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
TruncTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm){}
|
||||
/** @brief process a truncate table statement
|
||||
*
|
||||
* @param truncTableStmt the truncate table statement
|
||||
*/
|
||||
EXPORT DDLResult processPackage(ddlpackage::TruncTableStatement& truncTableStmt);
|
||||
EXPORT DDLResult processPackage(ddlpackage::TruncTableStatement& truncTableStmt);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace ddlpackageprocessor
|
||||
|
||||
|
||||
@@ -37,237 +37,261 @@ namespace ddlpackageprocessor
|
||||
|
||||
MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpackage::MarkPartitionStatement& markPartitionStmt)
|
||||
{
|
||||
SUMMARY_INFO("RestorePartitionProcessor::processPackage");
|
||||
SUMMARY_INFO("RestorePartitionProcessor::processPackage");
|
||||
|
||||
DDLResult result;
|
||||
result.result = NO_ERROR;
|
||||
std::string err;
|
||||
VERBOSE_INFO(markPartitionStmt);
|
||||
DDLResult result;
|
||||
result.result = NO_ERROR;
|
||||
std::string err;
|
||||
VERBOSE_INFO(markPartitionStmt);
|
||||
|
||||
BRM::TxnID txnID;
|
||||
txnID.id= fTxnid.id;
|
||||
txnID.valid= fTxnid.valid;
|
||||
BRM::TxnID txnID;
|
||||
txnID.id = fTxnid.id;
|
||||
txnID.valid = fTxnid.valid;
|
||||
|
||||
int rc = 0;
|
||||
rc = fDbrm->isReadWrite();
|
||||
if (rc != 0 )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add("Unable to execute the statement due to DBRM is read only");
|
||||
message.format(args);
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
std::vector <CalpontSystemCatalog::OID> oidList;
|
||||
CalpontSystemCatalog::RIDList tableColRidList;
|
||||
CalpontSystemCatalog::DictOIDList dictOIDList;
|
||||
std::string processName("DDLProc");
|
||||
int rc = 0;
|
||||
rc = fDbrm->isReadWrite();
|
||||
|
||||
string stmt = markPartitionStmt.fSql + "|" + markPartitionStmt.fTableName->fSchema +"|";
|
||||
SQLLogger logger(stmt, fDDLLoggingId, markPartitionStmt.fSessionID, txnID.id);
|
||||
if (rc != 0 )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add("Unable to execute the statement due to DBRM is read only");
|
||||
message.format(args);
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t processID = 0;
|
||||
uint64_t uniqueID = 0;
|
||||
uint32_t sessionID = markPartitionStmt.fSessionID;
|
||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||
std::vector <CalpontSystemCatalog::OID> oidList;
|
||||
CalpontSystemCatalog::RIDList tableColRidList;
|
||||
CalpontSystemCatalog::DictOIDList dictOIDList;
|
||||
std::string processName("DDLProc");
|
||||
|
||||
try
|
||||
{
|
||||
//check table lock
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(markPartitionStmt.fSessionID);
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
systemCatalogPtr->sessionID(markPartitionStmt.fSessionID);
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
tableName.schema = markPartitionStmt.fTableName->fSchema;
|
||||
tableName.table = markPartitionStmt.fTableName->fName;
|
||||
roPair = systemCatalogPtr->tableRID( tableName );
|
||||
//@Bug 3054 check for system catalog
|
||||
if ( roPair.objnum < 3000 )
|
||||
{
|
||||
throw std::runtime_error("Drop partition cannot be operated on Calpont system catalog.");
|
||||
}
|
||||
int i = 0;
|
||||
processID = ::getpid();
|
||||
oam::OamCache * oamcache = OamCache::makeOamCache();
|
||||
std::vector<int> pmList = oamcache->getModuleIds();
|
||||
std::vector<uint32_t> pms;
|
||||
for (unsigned i=0; i < pmList.size(); i++)
|
||||
{
|
||||
pms.push_back((uint32_t)pmList[i]);
|
||||
}
|
||||
string stmt = markPartitionStmt.fSql + "|" + markPartitionStmt.fTableName->fSchema + "|";
|
||||
SQLLogger logger(stmt, fDDLLoggingId, markPartitionStmt.fSessionID, txnID.id);
|
||||
|
||||
try {
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
uint32_t processID = 0;
|
||||
uint64_t uniqueID = 0;
|
||||
uint32_t sessionID = markPartitionStmt.fSessionID;
|
||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||
|
||||
if ( uniqueID == 0 )
|
||||
{
|
||||
int waitPeriod = 10;
|
||||
int sleepTime = 100; // sleep 100 milliseconds between checks
|
||||
int numTries = 10; // try 10 times per second
|
||||
waitPeriod = Config::getWaitPeriod();
|
||||
numTries = waitPeriod * 10;
|
||||
struct timespec rm_ts;
|
||||
try
|
||||
{
|
||||
//check table lock
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(markPartitionStmt.fSessionID);
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
systemCatalogPtr->sessionID(markPartitionStmt.fSessionID);
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
tableName.schema = markPartitionStmt.fTableName->fSchema;
|
||||
tableName.table = markPartitionStmt.fTableName->fName;
|
||||
roPair = systemCatalogPtr->tableRID( tableName );
|
||||
|
||||
rm_ts.tv_sec = sleepTime/1000;
|
||||
rm_ts.tv_nsec = sleepTime%1000 *1000000;
|
||||
//@Bug 3054 check for system catalog
|
||||
if ( roPair.objnum < 3000 )
|
||||
{
|
||||
throw std::runtime_error("Drop partition cannot be operated on Calpont system catalog.");
|
||||
}
|
||||
|
||||
for (; i < numTries; i++)
|
||||
{
|
||||
int i = 0;
|
||||
processID = ::getpid();
|
||||
oam::OamCache* oamcache = OamCache::makeOamCache();
|
||||
std::vector<int> pmList = oamcache->getModuleIds();
|
||||
std::vector<uint32_t> pms;
|
||||
|
||||
for (unsigned i = 0; i < pmList.size(); i++)
|
||||
{
|
||||
pms.push_back((uint32_t)pmList[i]);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
if ( uniqueID == 0 )
|
||||
{
|
||||
int waitPeriod = 10;
|
||||
int sleepTime = 100; // sleep 100 milliseconds between checks
|
||||
int numTries = 10; // try 10 times per second
|
||||
waitPeriod = Config::getWaitPeriod();
|
||||
numTries = waitPeriod * 10;
|
||||
struct timespec rm_ts;
|
||||
|
||||
rm_ts.tv_sec = sleepTime / 1000;
|
||||
rm_ts.tv_nsec = sleepTime % 1000 * 1000000;
|
||||
|
||||
for (; i < numTries; i++)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
#else
|
||||
struct timespec abs_ts;
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while(nanosleep(&abs_ts,&rm_ts) < 0);
|
||||
struct timespec abs_ts;
|
||||
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
// reset
|
||||
sessionID = markPartitionStmt.fSessionID;
|
||||
txnID.id= fTxnid.id;
|
||||
txnID.valid= fTxnid.valid;
|
||||
processID = ::getpid();
|
||||
processName = "DDLProc";
|
||||
// reset
|
||||
sessionID = markPartitionStmt.fSessionID;
|
||||
txnID.id = fTxnid.id;
|
||||
txnID.valid = fTxnid.valid;
|
||||
processID = ::getpid();
|
||||
processName = "DDLProc";
|
||||
|
||||
try {
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (uniqueID > 0)
|
||||
break;
|
||||
}
|
||||
if (uniqueID > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i >= numTries) //error out
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
logging::Message::Args args;
|
||||
args.add(processName);
|
||||
args.add((uint64_t)processID);
|
||||
args.add((uint64_t)sessionID);
|
||||
result.message = Message(IDBErrorInfo::instance()->errorMsg(ERR_TABLE_LOCKED,args));
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (i >= numTries) //error out
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
logging::Message::Args args;
|
||||
args.add(processName);
|
||||
args.add((uint64_t)processID);
|
||||
args.add((uint64_t)sessionID);
|
||||
result.message = Message(IDBErrorInfo::instance()->errorMsg(ERR_TABLE_LOCKED, args));
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// 1. Get the OIDs for the columns
|
||||
// 2. Get the OIDs for the dictionaries
|
||||
// 3. Save the OIDs to a log file
|
||||
// 4. Remove the extents from extentmap
|
||||
// 5. Flush PrimProc Cache
|
||||
// 6. Remove the column and dictionary files for the partition
|
||||
// 1. Get the OIDs for the columns
|
||||
// 2. Get the OIDs for the dictionaries
|
||||
// 3. Save the OIDs to a log file
|
||||
// 4. Remove the extents from extentmap
|
||||
// 5. Flush PrimProc Cache
|
||||
// 6. Remove the column and dictionary files for the partition
|
||||
|
||||
CalpontSystemCatalog::TableName userTableName;
|
||||
userTableName.schema = markPartitionStmt.fTableName->fSchema;
|
||||
userTableName.table = markPartitionStmt.fTableName->fName;
|
||||
CalpontSystemCatalog::TableName userTableName;
|
||||
userTableName.schema = markPartitionStmt.fTableName->fSchema;
|
||||
userTableName.table = markPartitionStmt.fTableName->fName;
|
||||
|
||||
tableColRidList = systemCatalogPtr->columnRIDs( userTableName );
|
||||
tableColRidList = systemCatalogPtr->columnRIDs( userTableName );
|
||||
|
||||
dictOIDList = systemCatalogPtr->dictOIDs( userTableName );
|
||||
dictOIDList = systemCatalogPtr->dictOIDs( userTableName );
|
||||
|
||||
//Save qualified tablename, all column, dictionary OIDs, and transaction ID into a file in ASCII format
|
||||
for ( unsigned i=0; i < tableColRidList.size(); i++ )
|
||||
{
|
||||
if ( tableColRidList[i].objnum > 3000 )
|
||||
oidList.push_back( tableColRidList[i].objnum );
|
||||
}
|
||||
for ( unsigned i=0; i < dictOIDList.size(); i++ )
|
||||
{
|
||||
if ( dictOIDList[i].dictOID > 3000 )
|
||||
oidList.push_back( dictOIDList[i].dictOID );
|
||||
}
|
||||
//Save qualified tablename, all column, dictionary OIDs, and transaction ID into a file in ASCII format
|
||||
for ( unsigned i = 0; i < tableColRidList.size(); i++ )
|
||||
{
|
||||
if ( tableColRidList[i].objnum > 3000 )
|
||||
oidList.push_back( tableColRidList[i].objnum );
|
||||
}
|
||||
|
||||
//Remove the partition from extent map
|
||||
string emsg;
|
||||
rc = fDbrm->markPartitionForDeletion( oidList, markPartitionStmt.fPartitions, emsg);
|
||||
if ( rc != 0 )
|
||||
{
|
||||
throw std::runtime_error(emsg);
|
||||
}
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(ex.what());
|
||||
for ( unsigned i = 0; i < dictOIDList.size(); i++ )
|
||||
{
|
||||
if ( dictOIDList[i].dictOID > 3000 )
|
||||
oidList.push_back( dictOIDList[i].dictOID );
|
||||
}
|
||||
|
||||
if (rc == BRM::ERR_TABLE_NOT_LOCKED)
|
||||
result.result = USER_ERROR;
|
||||
else if (rc == BRM::ERR_PARTITION_DISABLED || rc == BRM::ERR_INVALID_OP_LAST_PARTITION ||
|
||||
rc == BRM::ERR_NOT_EXIST_PARTITION)
|
||||
result.result = PARTITION_WARNING;
|
||||
else if (rc == BRM::ERR_NO_PARTITION_PERFORMED)
|
||||
result.result = WARN_NO_PARTITION;
|
||||
else
|
||||
result.result = DROP_ERROR;
|
||||
//Remove the partition from extent map
|
||||
string emsg;
|
||||
rc = fDbrm->markPartitionForDeletion( oidList, markPartitionStmt.fPartitions, emsg);
|
||||
|
||||
result.message = message;
|
||||
try {
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
//cerr << "MarkPartitionProcessor::processPackage: caught unknown exception!" << endl;
|
||||
if ( rc != 0 )
|
||||
{
|
||||
throw std::runtime_error(emsg);
|
||||
}
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(ex.what());
|
||||
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add("Disable partition failed: ");
|
||||
args.add( "encountered unkown exception" );
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format( args );
|
||||
if (rc == BRM::ERR_TABLE_NOT_LOCKED)
|
||||
result.result = USER_ERROR;
|
||||
else if (rc == BRM::ERR_PARTITION_DISABLED || rc == BRM::ERR_INVALID_OP_LAST_PARTITION ||
|
||||
rc == BRM::ERR_NOT_EXIST_PARTITION)
|
||||
result.result = PARTITION_WARNING;
|
||||
else if (rc == BRM::ERR_NO_PARTITION_PERFORMED)
|
||||
result.result = WARN_NO_PARTITION;
|
||||
else
|
||||
result.result = DROP_ERROR;
|
||||
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
try {
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
// Log the DDL statement
|
||||
logging::logDDL(markPartitionStmt.fSessionID, 0, markPartitionStmt.fSql, markPartitionStmt.fOwner);
|
||||
try {
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
fSessionManager.committed(txnID);
|
||||
return result;
|
||||
result.message = message;
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
//cerr << "MarkPartitionProcessor::processPackage: caught unknown exception!" << endl;
|
||||
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add("Disable partition failed: ");
|
||||
args.add( "encountered unkown exception" );
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format( args );
|
||||
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Log the DDL statement
|
||||
logging::logDDL(markPartitionStmt.fSessionID, 0, markPartitionStmt.fSql, markPartitionStmt.fOwner);
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
fSessionManager.committed(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace ddlpackageprocessor
|
||||
class MarkPartitionProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
MarkPartitionProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm){}
|
||||
MarkPartitionProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||
/** @brief process a create table statement
|
||||
*
|
||||
* @param createTableStmt the CreateTableStatement
|
||||
|
||||
@@ -62,532 +62,543 @@ class PopulateIndexTest
|
||||
{
|
||||
public:
|
||||
|
||||
PopulateIndexTest(DistributedEngineComm* ec) : fEC(ec) { }
|
||||
DistributedEngineComm *fEC;
|
||||
PopulateIndexTest(DistributedEngineComm* ec) : fEC(ec) { }
|
||||
DistributedEngineComm* fEC;
|
||||
|
||||
void test_createindex()
|
||||
{
|
||||
cout << "Begining create index test ... " << endl;
|
||||
std::string sqlbuf = "CREATE INDEX test1_idx ON tpch.nation (n_nationkey)";
|
||||
cout << sqlbuf << endl;
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
|
||||
cout << "Parser succeeded." << endl;
|
||||
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
||||
cout << ptree.fSqlText << endl;
|
||||
|
||||
try
|
||||
{
|
||||
CreateIndexProcessor processor;
|
||||
processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
CreateIndexProcessor::DDLResult result;
|
||||
DISPLAY(stmt.fSessionID);
|
||||
|
||||
result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_createuniqueindex()
|
||||
{
|
||||
cout << "Begining create unique index test ..." << endl;
|
||||
std::string sqlbuf = "CREATE UNIQUE INDEX test2_idx ON tpch.nation (n_name)";
|
||||
cout << sqlbuf << endl;
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
cout << ptree.fSqlText << endl;
|
||||
|
||||
try
|
||||
{
|
||||
CreateIndexProcessor processor;
|
||||
processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
CreateIndexProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_createindextest(std::string& sqlbuf)
|
||||
{
|
||||
cout << "Begining create index test ..." << endl;
|
||||
cout << sqlbuf << endl;
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
cout << ptree.fSqlText << endl;
|
||||
|
||||
try
|
||||
{
|
||||
CreateIndexProcessor processor;
|
||||
processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
CreateIndexProcessor::DDLResult result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_createtabletest(const string& sqlbuf)
|
||||
void test_createindex()
|
||||
{
|
||||
cout << "Begining create table test: " << sqlbuf << endl;
|
||||
cout << "Begining create index test ... " << endl;
|
||||
std::string sqlbuf = "CREATE INDEX test1_idx ON tpch.nation (n_nationkey)";
|
||||
cout << sqlbuf << endl;
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
cout << ptree.fSqlText << endl;
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
cout << "Parser succeeded." << endl;
|
||||
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
||||
cout << ptree.fSqlText << endl;
|
||||
|
||||
try
|
||||
{
|
||||
CreateTableProcessor processor;
|
||||
processor.setDebugLevel(CreateTableProcessor::VERBOSE);
|
||||
CreateIndexProcessor processor;
|
||||
processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
CreateIndexProcessor::DDLResult result;
|
||||
DISPLAY(stmt.fSessionID);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
CreateTableProcessor::DDLResult result;
|
||||
result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||
|
||||
result = processor.processPackage(dynamic_cast<CreateTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_altertable_addtableconstraint(std::string& sqlbuf)
|
||||
{
|
||||
cout << "Begining Alter Table add table constraint test ... " << endl;
|
||||
cout << sqlbuf << endl;
|
||||
void test_createuniqueindex()
|
||||
{
|
||||
cout << "Begining create unique index test ..." << endl;
|
||||
std::string sqlbuf = "CREATE UNIQUE INDEX test2_idx ON tpch.nation (n_name)";
|
||||
cout << sqlbuf << endl;
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
cout << ptree.fSqlText << endl;
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
cout << ptree.fSqlText << endl;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
CreateIndexProcessor processor;
|
||||
processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
||||
|
||||
void test_altertable_addtablenullconstraint()
|
||||
{
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
CreateIndexProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_createindextest(std::string& sqlbuf)
|
||||
{
|
||||
cout << "Begining create index test ..." << endl;
|
||||
cout << sqlbuf << endl;
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
cout << ptree.fSqlText << endl;
|
||||
|
||||
try
|
||||
{
|
||||
CreateIndexProcessor processor;
|
||||
processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
||||
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
CreateIndexProcessor::DDLResult result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_createtabletest(const string& sqlbuf)
|
||||
{
|
||||
cout << "Begining create table test: " << sqlbuf << endl;
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
cout << ptree.fSqlText << endl;
|
||||
|
||||
try
|
||||
{
|
||||
CreateTableProcessor processor;
|
||||
processor.setDebugLevel(CreateTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
CreateTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<CreateTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_altertable_addtableconstraint(std::string& sqlbuf)
|
||||
{
|
||||
cout << "Begining Alter Table add table constraint test ... " << endl;
|
||||
cout << sqlbuf << endl;
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
cout << ptree.fSqlText << endl;
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_altertable_addtablenullconstraint()
|
||||
{
|
||||
//sql syntax error? (Does not build index test.)
|
||||
cout << "Begining Alter Table add table not null constraint test ... " << endl;
|
||||
std::string sqlbuf = "ALTER TABLE tpch.region add CONSTRAINT not null(r_regionkey);";
|
||||
cout << sqlbuf << endl;
|
||||
cout << "Begining Alter Table add table not null constraint test ... " << endl;
|
||||
std::string sqlbuf = "ALTER TABLE tpch.region add CONSTRAINT not null(r_regionkey);";
|
||||
cout << sqlbuf << endl;
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
cout << ptree.fSqlText << endl;
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
cout << ptree.fSqlText << endl;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
int main( int argc, char **argv)
|
||||
int main( int argc, char** argv)
|
||||
{
|
||||
int DoAll = 0;
|
||||
int Do1 = 0;
|
||||
int Do2 = 0;
|
||||
int Do3 = 0;
|
||||
int Do4 = 0;
|
||||
int Do5 = 0;
|
||||
int Do6 = 0;
|
||||
int Do7 = 0;
|
||||
int Do8 = 0;
|
||||
int Do9 = 0;
|
||||
int Do10 = 0;
|
||||
int Do11 = 0;
|
||||
int Do12 = 0;
|
||||
int Do13 = 0;
|
||||
int Do14 = 0;
|
||||
int Do15 = 0;
|
||||
int Do16 = 0;
|
||||
int Do17 = 0;
|
||||
int Do18 = 0;
|
||||
int Do19 = 0;
|
||||
int Do20 = 0;
|
||||
int Do21 = 0;
|
||||
int Do22 = 0;
|
||||
int Do23 = 0;
|
||||
int Do24 = 0;
|
||||
int Do25 = 0;
|
||||
int Do26 = 0;
|
||||
int Do27 = 0;
|
||||
int Do28 = 0;
|
||||
int Do29 = 0;
|
||||
int Do30 = 0;
|
||||
int Do31 = 0;
|
||||
int Do32 = 0;
|
||||
int Do33 = 0;
|
||||
int Do34 = 0;
|
||||
int Do35 = 0;
|
||||
int Do36 = 0;
|
||||
int DoAll = 0;
|
||||
int Do1 = 0;
|
||||
int Do2 = 0;
|
||||
int Do3 = 0;
|
||||
int Do4 = 0;
|
||||
int Do5 = 0;
|
||||
int Do6 = 0;
|
||||
int Do7 = 0;
|
||||
int Do8 = 0;
|
||||
int Do9 = 0;
|
||||
int Do10 = 0;
|
||||
int Do11 = 0;
|
||||
int Do12 = 0;
|
||||
int Do13 = 0;
|
||||
int Do14 = 0;
|
||||
int Do15 = 0;
|
||||
int Do16 = 0;
|
||||
int Do17 = 0;
|
||||
int Do18 = 0;
|
||||
int Do19 = 0;
|
||||
int Do20 = 0;
|
||||
int Do21 = 0;
|
||||
int Do22 = 0;
|
||||
int Do23 = 0;
|
||||
int Do24 = 0;
|
||||
int Do25 = 0;
|
||||
int Do26 = 0;
|
||||
int Do27 = 0;
|
||||
int Do28 = 0;
|
||||
int Do29 = 0;
|
||||
int Do30 = 0;
|
||||
int Do31 = 0;
|
||||
int Do32 = 0;
|
||||
int Do33 = 0;
|
||||
int Do34 = 0;
|
||||
int Do35 = 0;
|
||||
int Do36 = 0;
|
||||
|
||||
cout << "Driver Test starting with " << argc << " parameters." << endl;
|
||||
cout << "Driver Test starting with " << argc << " parameters." << endl;
|
||||
|
||||
for (int i=0; i<argc; i++)
|
||||
for (int i = 0; i < argc; i++)
|
||||
{
|
||||
cout << "Arg " << i << ": " << argv[i] << endl;
|
||||
cout << "Arg " << i << ": " << argv[i] << endl;
|
||||
}
|
||||
|
||||
if (argc > 1)
|
||||
if (argc > 1)
|
||||
{
|
||||
if (strcmp(argv[1],"All") == 0) DoAll = 1;
|
||||
else if (strcmp(argv[1],"t1") == 0) Do1 = 1;
|
||||
else if (strcmp(argv[1],"t2") == 0) Do2 = 1;
|
||||
else if (strcmp(argv[1],"t3") == 0) Do3 = 1;
|
||||
else if (strcmp(argv[1],"t4") == 0) Do4 = 1;
|
||||
else if (strcmp(argv[1],"t5") == 0) Do5 = 1;
|
||||
else if (strcmp(argv[1],"t6") == 0) Do6 = 1;
|
||||
else if (strcmp(argv[1],"t7") == 0) Do7 = 1;
|
||||
else if (strcmp(argv[1],"t8") == 0) Do8 = 1;
|
||||
else if (strcmp(argv[1],"t9") == 0) Do9 = 1;
|
||||
else if (strcmp(argv[1],"t10") == 0) Do10 = 1;
|
||||
else if (strcmp(argv[1],"t11") == 0) Do11= 1;
|
||||
else if (strcmp(argv[1],"t12") == 0) Do12= 1;
|
||||
else if (strcmp(argv[1],"t13") == 0) Do13= 1;
|
||||
else if (strcmp(argv[1],"t14") == 0) Do14= 1;
|
||||
else if (strcmp(argv[1],"t15") == 0) Do15= 1;
|
||||
else if (strcmp(argv[1],"t16") == 0) Do16= 1;
|
||||
else if (strcmp(argv[1],"t17") == 0) Do17= 1;
|
||||
else if (strcmp(argv[1],"t18") == 0) Do18= 1;
|
||||
else if (strcmp(argv[1],"t19") == 0) Do19= 1;
|
||||
else if (strcmp(argv[1],"t20") == 0) Do20= 1;
|
||||
else if (strcmp(argv[1],"t21") == 0) Do21= 1;
|
||||
else if (strcmp(argv[1],"t22") == 0) Do22= 1;
|
||||
else if (strcmp(argv[1],"t23") == 0) Do23= 1;
|
||||
else if (strcmp(argv[1],"t24") == 0) Do24= 1;
|
||||
else if (strcmp(argv[1],"t25") == 0) Do25= 1;
|
||||
else if (strcmp(argv[1],"t26") == 0) Do26= 1;
|
||||
else if (strcmp(argv[1],"t27") == 0) Do27= 1;
|
||||
else if (strcmp(argv[1],"t28") == 0) Do28= 1;
|
||||
else if (strcmp(argv[1],"t29") == 0) Do29= 1;
|
||||
else if (strcmp(argv[1],"t30") == 0) Do30= 1;
|
||||
else if (strcmp(argv[1],"t31") == 0) Do31= 1;
|
||||
else if (strcmp(argv[1],"t32") == 0) Do32= 1;
|
||||
else if (strcmp(argv[1],"t33") == 0) Do33= 1;
|
||||
else if (strcmp(argv[1],"t34") == 0) Do34= 1;
|
||||
else if (strcmp(argv[1],"t35") == 0) Do35= 1;
|
||||
else if (strcmp(argv[1],"t36") == 0) Do35= 1;
|
||||
if (strcmp(argv[1], "All") == 0) DoAll = 1;
|
||||
else if (strcmp(argv[1], "t1") == 0) Do1 = 1;
|
||||
else if (strcmp(argv[1], "t2") == 0) Do2 = 1;
|
||||
else if (strcmp(argv[1], "t3") == 0) Do3 = 1;
|
||||
else if (strcmp(argv[1], "t4") == 0) Do4 = 1;
|
||||
else if (strcmp(argv[1], "t5") == 0) Do5 = 1;
|
||||
else if (strcmp(argv[1], "t6") == 0) Do6 = 1;
|
||||
else if (strcmp(argv[1], "t7") == 0) Do7 = 1;
|
||||
else if (strcmp(argv[1], "t8") == 0) Do8 = 1;
|
||||
else if (strcmp(argv[1], "t9") == 0) Do9 = 1;
|
||||
else if (strcmp(argv[1], "t10") == 0) Do10 = 1;
|
||||
else if (strcmp(argv[1], "t11") == 0) Do11 = 1;
|
||||
else if (strcmp(argv[1], "t12") == 0) Do12 = 1;
|
||||
else if (strcmp(argv[1], "t13") == 0) Do13 = 1;
|
||||
else if (strcmp(argv[1], "t14") == 0) Do14 = 1;
|
||||
else if (strcmp(argv[1], "t15") == 0) Do15 = 1;
|
||||
else if (strcmp(argv[1], "t16") == 0) Do16 = 1;
|
||||
else if (strcmp(argv[1], "t17") == 0) Do17 = 1;
|
||||
else if (strcmp(argv[1], "t18") == 0) Do18 = 1;
|
||||
else if (strcmp(argv[1], "t19") == 0) Do19 = 1;
|
||||
else if (strcmp(argv[1], "t20") == 0) Do20 = 1;
|
||||
else if (strcmp(argv[1], "t21") == 0) Do21 = 1;
|
||||
else if (strcmp(argv[1], "t22") == 0) Do22 = 1;
|
||||
else if (strcmp(argv[1], "t23") == 0) Do23 = 1;
|
||||
else if (strcmp(argv[1], "t24") == 0) Do24 = 1;
|
||||
else if (strcmp(argv[1], "t25") == 0) Do25 = 1;
|
||||
else if (strcmp(argv[1], "t26") == 0) Do26 = 1;
|
||||
else if (strcmp(argv[1], "t27") == 0) Do27 = 1;
|
||||
else if (strcmp(argv[1], "t28") == 0) Do28 = 1;
|
||||
else if (strcmp(argv[1], "t29") == 0) Do29 = 1;
|
||||
else if (strcmp(argv[1], "t30") == 0) Do30 = 1;
|
||||
else if (strcmp(argv[1], "t31") == 0) Do31 = 1;
|
||||
else if (strcmp(argv[1], "t32") == 0) Do32 = 1;
|
||||
else if (strcmp(argv[1], "t33") == 0) Do33 = 1;
|
||||
else if (strcmp(argv[1], "t34") == 0) Do34 = 1;
|
||||
else if (strcmp(argv[1], "t35") == 0) Do35 = 1;
|
||||
else if (strcmp(argv[1], "t36") == 0) Do35 = 1;
|
||||
|
||||
|
||||
}
|
||||
PopulateIndexTest pit(DistributedEngineComm::instance());
|
||||
boost::timer theTimer;
|
||||
|
||||
if (DoAll)
|
||||
{
|
||||
cout << "Starting all tests" << endl;
|
||||
PopulateIndexTest pit(DistributedEngineComm::instance());
|
||||
boost::timer theTimer;
|
||||
|
||||
pit.test_createindex();
|
||||
pit.test_createuniqueindex();
|
||||
std::string altsql = "ALTER TABLE tpch.region add CONSTRAINT test1_cstr unique(r_name);";
|
||||
pit.test_altertable_addtableconstraint(altsql);
|
||||
pit.test_altertable_addtablenullconstraint();
|
||||
if (DoAll)
|
||||
{
|
||||
cout << "Starting all tests" << endl;
|
||||
|
||||
cout << "Finished all tests" << endl;
|
||||
}
|
||||
else if (Do1)
|
||||
{
|
||||
pit.test_createindex();
|
||||
pit.test_createindex();
|
||||
pit.test_createuniqueindex();
|
||||
std::string altsql = "ALTER TABLE tpch.region add CONSTRAINT test1_cstr unique(r_name);";
|
||||
pit.test_altertable_addtableconstraint(altsql);
|
||||
pit.test_altertable_addtablenullconstraint();
|
||||
|
||||
cout << "Finished create index test" << endl;
|
||||
cout << "Finished all tests" << endl;
|
||||
}
|
||||
else if (Do2)
|
||||
else if (Do1)
|
||||
{
|
||||
pit.test_createuniqueindex();
|
||||
pit.test_createindex();
|
||||
|
||||
cout << "Finished create unique index test" << endl;
|
||||
cout << "Finished create index test" << endl;
|
||||
}
|
||||
else if (Do3)
|
||||
else if (Do2)
|
||||
{
|
||||
std::string sqlbuf = "ALTER TABLE tpch.region add CONSTRAINT test1r5_cstr unique(r_name);";
|
||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
||||
cout << "Finished add table constraint test" << endl;
|
||||
}
|
||||
else if (Do4)
|
||||
{
|
||||
std::string sql("CREATE INDEX test4_idx ON tpch.part (p_size)");
|
||||
pit.test_createindextest(sql);
|
||||
pit.test_createuniqueindex();
|
||||
|
||||
cout << "Finished " << sql << endl;
|
||||
cout << "Finished create unique index test" << endl;
|
||||
}
|
||||
else if (Do5)
|
||||
else if (Do3)
|
||||
{
|
||||
std::string sql("CREATE INDEX test5_idx ON tpch.part (p_name)");
|
||||
pit.test_createindextest(sql);
|
||||
std::string sqlbuf = "ALTER TABLE tpch.region add CONSTRAINT test1r5_cstr unique(r_name);";
|
||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
||||
cout << "Finished add table constraint test" << endl;
|
||||
}
|
||||
else if (Do4)
|
||||
{
|
||||
std::string sql("CREATE INDEX test4_idx ON tpch.part (p_size)");
|
||||
pit.test_createindextest(sql);
|
||||
|
||||
cout << "Finished " << sql << endl;
|
||||
cout << "Finished " << sql << endl;
|
||||
}
|
||||
else if (Do6)
|
||||
else if (Do5)
|
||||
{
|
||||
std::string sql("CREATE INDEX test6_idx ON tpch.orders (o_orderkey, o_custkey)");
|
||||
pit.test_createindextest(sql);
|
||||
std::string sql("CREATE INDEX test5_idx ON tpch.part (p_name)");
|
||||
pit.test_createindextest(sql);
|
||||
|
||||
cout << "Finished " << sql << endl;
|
||||
cout << "Finished " << sql << endl;
|
||||
}
|
||||
else if (Do7)
|
||||
else if (Do6)
|
||||
{
|
||||
std::string sqlbuf = "ALTER TABLE tpch.supplier add CONSTRAINT tests2_cstr unique(s_name);";
|
||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
||||
cout << "Finished add table constraint test" << endl;
|
||||
std::string sql("CREATE INDEX test6_idx ON tpch.orders (o_orderkey, o_custkey)");
|
||||
pit.test_createindextest(sql);
|
||||
|
||||
cout << "Finished " << sql << endl;
|
||||
}
|
||||
else if (Do8)
|
||||
else if (Do7)
|
||||
{
|
||||
std::string sqlbuf = "ALTER TABLE tpch.partsupp add CONSTRAINT testps1_cstr unique(ps_partkey);";
|
||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
||||
cout << "Finished add table constraint test: should fail ps_partkey is not unique" << endl;
|
||||
std::string sqlbuf = "ALTER TABLE tpch.supplier add CONSTRAINT tests2_cstr unique(s_name);";
|
||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
||||
cout << "Finished add table constraint test" << endl;
|
||||
}
|
||||
else if (Do8)
|
||||
{
|
||||
std::string sqlbuf = "ALTER TABLE tpch.partsupp add CONSTRAINT testps1_cstr unique(ps_partkey);";
|
||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
||||
cout << "Finished add table constraint test: should fail ps_partkey is not unique" << endl;
|
||||
}
|
||||
else if (Do9)
|
||||
{
|
||||
std::string sql("CREATE INDEX test7_idx ON tpch.customer (c_custkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE INDEX test7_idx ON tpch.customer (c_custkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do10)
|
||||
{
|
||||
std::string sql("CREATE INDEX test8_idx ON tpch.supplier(s_phone)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE INDEX test8_idx ON tpch.supplier(s_phone)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do11)
|
||||
{
|
||||
std::string sql("CREATE INDEX test9_idx ON tpch.part (p_retailprice)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE INDEX test9_idx ON tpch.part (p_retailprice)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do12)
|
||||
{
|
||||
std::string sql("CREATE INDEX test10_idx ON tpch.customer (c_acctbal)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE INDEX test10_idx ON tpch.customer (c_acctbal)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do13)
|
||||
{
|
||||
std::string sql("CREATE UNIQUE INDEX test11_idx ON tpch.orders (o_clerk)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test: should fail" << endl;
|
||||
std::string sql("CREATE UNIQUE INDEX test11_idx ON tpch.orders (o_clerk)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test: should fail" << endl;
|
||||
}
|
||||
else if (Do14)
|
||||
{
|
||||
std::string sql("CREATE INDEX test12_idx ON tpch.lineitem (l_returnflag)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE INDEX test12_idx ON tpch.lineitem (l_returnflag)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do15)
|
||||
{
|
||||
std::string sql("CREATE INDEX test13_idx ON tpch.lineitem (l_linestatus)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE INDEX test13_idx ON tpch.lineitem (l_linestatus)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do16)
|
||||
{
|
||||
std::string sql("CREATE INDEX multi_4idx ON tpch.region (r_regionkey, r_name)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE INDEX multi_4idx ON tpch.region (r_regionkey, r_name)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do17)
|
||||
{
|
||||
std::string sql("CREATE INDEX multi_5idx ON tpch.orders (o_orderkey, o_orderstatus)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE INDEX multi_5idx ON tpch.orders (o_orderkey, o_orderstatus)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do18)
|
||||
{
|
||||
std::string sql("CREATE UNIQUE INDEX orderkey_idx ON tpch.orders (o_orderkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE UNIQUE INDEX orderkey_idx ON tpch.orders (o_orderkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do19)
|
||||
{
|
||||
std::string sql("CREATE UNIQUE INDEX partkey_idx ON tpch.part (p_partkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE UNIQUE INDEX partkey_idx ON tpch.part (p_partkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do20)
|
||||
{
|
||||
std::string sql("CREATE INDEX lorderkey_idx ON tpch.lineitem (l_orderkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE INDEX lorderkey_idx ON tpch.lineitem (l_orderkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do21)
|
||||
{
|
||||
std::string sql("CREATE INDEX lpartkey1_idx ON tpch.lineitem (l_partkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE INDEX lpartkey1_idx ON tpch.lineitem (l_partkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do22)
|
||||
{
|
||||
std::string sql("CREATE INDEX suppkey1_idx ON tpch.lineitem (l_suppkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE INDEX suppkey1_idx ON tpch.lineitem (l_suppkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do23)
|
||||
else if (Do23)
|
||||
{
|
||||
std::string sql("CREATE INDEX n_regionkey_id ON tpch.nation (n_regionkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE INDEX n_regionkey_id ON tpch.nation (n_regionkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do24)
|
||||
{
|
||||
std::string sql("CREATE INDEX multi_cust_idx ON tpch.customer (c_name, c_address, c_phone, c_mktsegment)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test: " << sql << endl;
|
||||
std::string sql("CREATE INDEX multi_cust_idx ON tpch.customer (c_name, c_address, c_phone, c_mktsegment)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test: " << sql << endl;
|
||||
}
|
||||
else if (Do25)
|
||||
{
|
||||
std::string sql("CREATE INDEX multi_part_no_idx ON tpch.part (p_name, p_mfgr, p_brand, p_container, p_size)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test: " << sql << endl;
|
||||
std::string sql("CREATE INDEX multi_part_no_idx ON tpch.part (p_name, p_mfgr, p_brand, p_container, p_size)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test: " << sql << endl;
|
||||
}
|
||||
else if (Do26)
|
||||
{
|
||||
std::string sql("CREATE INDEX o_date_idx ON tpch.orders (o_orderdate)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test: " << sql << endl;
|
||||
std::string sql("CREATE INDEX o_date_idx ON tpch.orders (o_orderdate)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test: " << sql << endl;
|
||||
}
|
||||
else if (Do27)
|
||||
{
|
||||
std::string sql("CREATE INDEX multi_order_idx ON tpch.orders (o_orderkey, o_orderstatus, o_orderdate)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test: " << sql << endl;
|
||||
std::string sql("CREATE INDEX multi_order_idx ON tpch.orders (o_orderkey, o_orderstatus, o_orderdate)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test: " << sql << endl;
|
||||
}
|
||||
else if (Do28)
|
||||
{
|
||||
string sql("create table tpch.tablea( c1 integer, c2 char);");
|
||||
pit.test_createtabletest(sql);
|
||||
std::string sqlbuf = "ALTER TABLE tpch.tablea add CONSTRAINT tablea_cstr1 unique(c2);";
|
||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
||||
cout << "Finished add table constraint test" << endl;
|
||||
string sql("create table tpch.tablea( c1 integer, c2 char);");
|
||||
pit.test_createtabletest(sql);
|
||||
std::string sqlbuf = "ALTER TABLE tpch.tablea add CONSTRAINT tablea_cstr1 unique(c2);";
|
||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
||||
cout << "Finished add table constraint test" << endl;
|
||||
|
||||
}
|
||||
else if (Do29)
|
||||
{
|
||||
std::string sqlbuf = "ALTER TABLE tpch.nation add CONSTRAINT testn1_cstr unique(n_regionkey);";
|
||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
||||
cout << "Finished add table constraint test: should fail n_regionkey is not unique" << endl;
|
||||
std::string sqlbuf = "ALTER TABLE tpch.nation add CONSTRAINT testn1_cstr unique(n_regionkey);";
|
||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
||||
cout << "Finished add table constraint test: should fail n_regionkey is not unique" << endl;
|
||||
}
|
||||
else if (Do30)
|
||||
{
|
||||
std::string sql("CREATE UNIQUE INDEX multicstr_1idx ON tpch.region (r_regionkey, r_name)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE UNIQUE INDEX multicstr_1idx ON tpch.region (r_regionkey, r_name)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do31)
|
||||
{
|
||||
std::string sql("CREATE UNIQUE INDEX multicsto_1idx ON tpch.orders (o_orderkey, o_orderstatus)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE UNIQUE INDEX multicsto_1idx ON tpch.orders (o_orderkey, o_orderstatus)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do32)
|
||||
{
|
||||
std::string sql("CREATE UNIQUE INDEX multicstn_1idx ON tpch.nation (n_nationkey, n_regionkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE UNIQUE INDEX multicstn_1idx ON tpch.nation (n_nationkey, n_regionkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do33)
|
||||
else if (Do33)
|
||||
{
|
||||
std::string sql("CREATE UNIQUE INDEX multicstps_1idx ON tpch.partsupp (ps_partkey, ps_suppkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
std::string sql("CREATE UNIQUE INDEX multicstps_1idx ON tpch.partsupp (ps_partkey, ps_suppkey)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test" << endl;
|
||||
}
|
||||
else if (Do34)
|
||||
else if (Do34)
|
||||
{
|
||||
std::string sql("CREATE UNIQUE INDEX multicsto_2idx ON tpch.orders (o_orderstatus, o_orderpriority)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test: should fail" << endl;
|
||||
std::string sql("CREATE UNIQUE INDEX multicsto_2idx ON tpch.orders (o_orderstatus, o_orderpriority)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test: should fail" << endl;
|
||||
}
|
||||
else if (Do35)
|
||||
{
|
||||
std::string sql("ALTER TABLE tpch.nation add CONSTRAINT testn2_cstr unique(n_nationkey);");
|
||||
pit.test_altertable_addtableconstraint(sql);
|
||||
cout << "Finished add table constraint test" << endl;
|
||||
std::string sql("ALTER TABLE tpch.nation add CONSTRAINT testn2_cstr unique(n_nationkey);");
|
||||
pit.test_altertable_addtableconstraint(sql);
|
||||
cout << "Finished add table constraint test" << endl;
|
||||
}
|
||||
else if (Do36)
|
||||
{
|
||||
pit.test_altertable_addtablenullconstraint();
|
||||
pit.test_altertable_addtablenullconstraint();
|
||||
|
||||
cout << "Finished add table not null constraint test" << endl;
|
||||
cout << "Finished add table not null constraint test" << endl;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
cout << "No Test Selected!" << endl << endl;
|
||||
cout << "No Test Selected!" << endl << endl;
|
||||
|
||||
cout << "All" << endl;
|
||||
cout << "t1" << endl;
|
||||
cout << "t2" << endl;
|
||||
cout << "t3" << endl;
|
||||
cout << "t4" << endl;
|
||||
cout << endl;
|
||||
cout << "All" << endl;
|
||||
cout << "t1" << endl;
|
||||
cout << "t2" << endl;
|
||||
cout << "t3" << endl;
|
||||
cout << "t4" << endl;
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
cout << "Create index test took :" << theTimer.elapsed() << " seconds to complete." << endl;
|
||||
|
||||
|
||||
|
||||
@@ -35,238 +35,262 @@ using namespace WriteEngine;
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
RestorePartitionProcessor::DDLResult RestorePartitionProcessor::processPackage(ddlpackage::RestorePartitionStatement& restorePartitionStmt)
|
||||
{
|
||||
SUMMARY_INFO("RestorePartitionProcessor::processPackage");
|
||||
RestorePartitionProcessor::DDLResult RestorePartitionProcessor::processPackage(ddlpackage::RestorePartitionStatement& restorePartitionStmt)
|
||||
{
|
||||
SUMMARY_INFO("RestorePartitionProcessor::processPackage");
|
||||
|
||||
DDLResult result;
|
||||
result.result = NO_ERROR;
|
||||
std::string err;
|
||||
VERBOSE_INFO(restorePartitionStmt);
|
||||
DDLResult result;
|
||||
result.result = NO_ERROR;
|
||||
std::string err;
|
||||
VERBOSE_INFO(restorePartitionStmt);
|
||||
|
||||
BRM::TxnID txnID;
|
||||
txnID.id= fTxnid.id;
|
||||
txnID.valid= fTxnid.valid;
|
||||
BRM::TxnID txnID;
|
||||
txnID.id = fTxnid.id;
|
||||
txnID.valid = fTxnid.valid;
|
||||
|
||||
int rc = 0;
|
||||
rc = fDbrm->isReadWrite();
|
||||
if (rc != 0 )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add("Unable to execute the statement due to DBRM is read only");
|
||||
message.format(args);
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
std::vector <CalpontSystemCatalog::OID> oidList;
|
||||
CalpontSystemCatalog::RIDList tableColRidList;
|
||||
CalpontSystemCatalog::DictOIDList dictOIDList;
|
||||
std::string processName("DDLProc");
|
||||
int rc = 0;
|
||||
rc = fDbrm->isReadWrite();
|
||||
|
||||
string stmt = restorePartitionStmt.fSql + "|" + restorePartitionStmt.fTableName->fSchema +"|";
|
||||
SQLLogger logger(stmt, fDDLLoggingId, restorePartitionStmt.fSessionID, txnID.id);
|
||||
if (rc != 0 )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add("Unable to execute the statement due to DBRM is read only");
|
||||
message.format(args);
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t processID = 0;
|
||||
uint64_t uniqueID = 0;
|
||||
uint32_t sessionID = restorePartitionStmt.fSessionID;
|
||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||
std::vector <CalpontSystemCatalog::OID> oidList;
|
||||
CalpontSystemCatalog::RIDList tableColRidList;
|
||||
CalpontSystemCatalog::DictOIDList dictOIDList;
|
||||
std::string processName("DDLProc");
|
||||
|
||||
try
|
||||
{
|
||||
//check table lock
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(restorePartitionStmt.fSessionID);
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
systemCatalogPtr->sessionID(restorePartitionStmt.fSessionID);
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
tableName.schema = restorePartitionStmt.fTableName->fSchema;
|
||||
tableName.table = restorePartitionStmt.fTableName->fName;
|
||||
roPair = systemCatalogPtr->tableRID( tableName );
|
||||
//@Bug 3054 check for system catalog
|
||||
if ( roPair.objnum < 3000 )
|
||||
{
|
||||
throw std::runtime_error("Drop partition cannot be operated on Calpont system catalog.");
|
||||
}
|
||||
int i = 0;
|
||||
processID = ::getpid();
|
||||
oam::OamCache * oamcache = oam::OamCache::makeOamCache();
|
||||
std::vector<int> pmList = oamcache->getModuleIds();
|
||||
std::vector<uint32_t> pms;
|
||||
for (unsigned i=0; i < pmList.size(); i++)
|
||||
{
|
||||
pms.push_back((uint32_t)pmList[i]);
|
||||
}
|
||||
string stmt = restorePartitionStmt.fSql + "|" + restorePartitionStmt.fTableName->fSchema + "|";
|
||||
SQLLogger logger(stmt, fDDLLoggingId, restorePartitionStmt.fSessionID, txnID.id);
|
||||
|
||||
try {
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
uint32_t processID = 0;
|
||||
uint64_t uniqueID = 0;
|
||||
uint32_t sessionID = restorePartitionStmt.fSessionID;
|
||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||
|
||||
if ( uniqueID == 0 )
|
||||
{
|
||||
int waitPeriod = 10;
|
||||
int sleepTime = 100; // sleep 100 milliseconds between checks
|
||||
int numTries = 10; // try 10 times per second
|
||||
waitPeriod = Config::getWaitPeriod();
|
||||
numTries = waitPeriod * 10;
|
||||
struct timespec rm_ts;
|
||||
try
|
||||
{
|
||||
//check table lock
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(restorePartitionStmt.fSessionID);
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
systemCatalogPtr->sessionID(restorePartitionStmt.fSessionID);
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
tableName.schema = restorePartitionStmt.fTableName->fSchema;
|
||||
tableName.table = restorePartitionStmt.fTableName->fName;
|
||||
roPair = systemCatalogPtr->tableRID( tableName );
|
||||
|
||||
rm_ts.tv_sec = sleepTime/1000;
|
||||
rm_ts.tv_nsec = sleepTime%1000 *1000000;
|
||||
//@Bug 3054 check for system catalog
|
||||
if ( roPair.objnum < 3000 )
|
||||
{
|
||||
throw std::runtime_error("Drop partition cannot be operated on Calpont system catalog.");
|
||||
}
|
||||
|
||||
for (; i < numTries; i++)
|
||||
{
|
||||
int i = 0;
|
||||
processID = ::getpid();
|
||||
oam::OamCache* oamcache = oam::OamCache::makeOamCache();
|
||||
std::vector<int> pmList = oamcache->getModuleIds();
|
||||
std::vector<uint32_t> pms;
|
||||
|
||||
for (unsigned i = 0; i < pmList.size(); i++)
|
||||
{
|
||||
pms.push_back((uint32_t)pmList[i]);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
if ( uniqueID == 0 )
|
||||
{
|
||||
int waitPeriod = 10;
|
||||
int sleepTime = 100; // sleep 100 milliseconds between checks
|
||||
int numTries = 10; // try 10 times per second
|
||||
waitPeriod = Config::getWaitPeriod();
|
||||
numTries = waitPeriod * 10;
|
||||
struct timespec rm_ts;
|
||||
|
||||
rm_ts.tv_sec = sleepTime / 1000;
|
||||
rm_ts.tv_nsec = sleepTime % 1000 * 1000000;
|
||||
|
||||
for (; i < numTries; i++)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
#else
|
||||
struct timespec abs_ts;
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while(nanosleep(&abs_ts,&rm_ts) < 0);
|
||||
struct timespec abs_ts;
|
||||
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
// reset
|
||||
sessionID = restorePartitionStmt.fSessionID;
|
||||
txnID.id= fTxnid.id;
|
||||
txnID.valid= fTxnid.valid;
|
||||
processID = ::getpid();
|
||||
processName = "DDLProc";
|
||||
// reset
|
||||
sessionID = restorePartitionStmt.fSessionID;
|
||||
txnID.id = fTxnid.id;
|
||||
txnID.valid = fTxnid.valid;
|
||||
processID = ::getpid();
|
||||
processName = "DDLProc";
|
||||
|
||||
try {
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (uniqueID > 0)
|
||||
break;
|
||||
}
|
||||
if (uniqueID > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i >= numTries) //error out
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
logging::Message::Args args;
|
||||
string strOp("restore partition");
|
||||
args.add(strOp);
|
||||
args.add(processName);
|
||||
args.add((uint64_t)processID);
|
||||
args.add((uint64_t)sessionID);
|
||||
result.message = Message(IDBErrorInfo::instance()->errorMsg(ERR_TABLE_LOCKED,args));
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (i >= numTries) //error out
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
logging::Message::Args args;
|
||||
string strOp("restore partition");
|
||||
args.add(strOp);
|
||||
args.add(processName);
|
||||
args.add((uint64_t)processID);
|
||||
args.add((uint64_t)sessionID);
|
||||
result.message = Message(IDBErrorInfo::instance()->errorMsg(ERR_TABLE_LOCKED, args));
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// 1. Get the OIDs for the columns
|
||||
// 2. Get the OIDs for the dictionaries
|
||||
// 3. Save the OIDs to a log file
|
||||
// 4. Remove the extents from extentmap
|
||||
// 5. Flush PrimProc Cache
|
||||
// 6. Remove the column and dictionary files for the partition
|
||||
// 1. Get the OIDs for the columns
|
||||
// 2. Get the OIDs for the dictionaries
|
||||
// 3. Save the OIDs to a log file
|
||||
// 4. Remove the extents from extentmap
|
||||
// 5. Flush PrimProc Cache
|
||||
// 6. Remove the column and dictionary files for the partition
|
||||
|
||||
CalpontSystemCatalog::TableName userTableName;
|
||||
userTableName.schema = restorePartitionStmt.fTableName->fSchema;
|
||||
userTableName.table = restorePartitionStmt.fTableName->fName;
|
||||
CalpontSystemCatalog::TableName userTableName;
|
||||
userTableName.schema = restorePartitionStmt.fTableName->fSchema;
|
||||
userTableName.table = restorePartitionStmt.fTableName->fName;
|
||||
|
||||
tableColRidList = systemCatalogPtr->columnRIDs( userTableName );
|
||||
tableColRidList = systemCatalogPtr->columnRIDs( userTableName );
|
||||
|
||||
dictOIDList = systemCatalogPtr->dictOIDs( userTableName );
|
||||
dictOIDList = systemCatalogPtr->dictOIDs( userTableName );
|
||||
|
||||
//Save qualified tablename, all column, dictionary OIDs, and transaction ID into a file in ASCII format
|
||||
for ( unsigned i=0; i < tableColRidList.size(); i++ )
|
||||
{
|
||||
if ( tableColRidList[i].objnum > 3000 )
|
||||
oidList.push_back( tableColRidList[i].objnum );
|
||||
}
|
||||
for ( unsigned i=0; i < dictOIDList.size(); i++ )
|
||||
{
|
||||
if ( dictOIDList[i].dictOID > 3000 )
|
||||
oidList.push_back( dictOIDList[i].dictOID );
|
||||
}
|
||||
//Save qualified tablename, all column, dictionary OIDs, and transaction ID into a file in ASCII format
|
||||
for ( unsigned i = 0; i < tableColRidList.size(); i++ )
|
||||
{
|
||||
if ( tableColRidList[i].objnum > 3000 )
|
||||
oidList.push_back( tableColRidList[i].objnum );
|
||||
}
|
||||
|
||||
//Remove the partition from extent map
|
||||
string emsg;
|
||||
rc = fDbrm->restorePartition( oidList, restorePartitionStmt.fPartitions, emsg);
|
||||
if ( rc != 0 )
|
||||
{
|
||||
throw std::runtime_error(emsg);
|
||||
}
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(ex.what());
|
||||
for ( unsigned i = 0; i < dictOIDList.size(); i++ )
|
||||
{
|
||||
if ( dictOIDList[i].dictOID > 3000 )
|
||||
oidList.push_back( dictOIDList[i].dictOID );
|
||||
}
|
||||
|
||||
if (( rc == BRM::ERR_NOT_EXIST_PARTITION) || (rc == BRM::ERR_INVALID_OP_LAST_PARTITION) ||
|
||||
(rc == BRM::ERR_PARTITION_DISABLED) || (rc == BRM::ERR_TABLE_NOT_LOCKED))
|
||||
result.result = USER_ERROR;
|
||||
else if (rc == BRM::ERR_PARTITION_ENABLED)
|
||||
result.result = PARTITION_WARNING;
|
||||
else
|
||||
result.result = DROP_ERROR;
|
||||
//Remove the partition from extent map
|
||||
string emsg;
|
||||
rc = fDbrm->restorePartition( oidList, restorePartitionStmt.fPartitions, emsg);
|
||||
|
||||
result.message = message;
|
||||
try {
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
//cerr << "RestorePartitionProcessor::processPackage: caught unknown exception!" << endl;
|
||||
if ( rc != 0 )
|
||||
{
|
||||
throw std::runtime_error(emsg);
|
||||
}
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(ex.what());
|
||||
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add("Enable partition: ");
|
||||
args.add( "encountered unkown exception" );
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format( args );
|
||||
if (( rc == BRM::ERR_NOT_EXIST_PARTITION) || (rc == BRM::ERR_INVALID_OP_LAST_PARTITION) ||
|
||||
(rc == BRM::ERR_PARTITION_DISABLED) || (rc == BRM::ERR_TABLE_NOT_LOCKED))
|
||||
result.result = USER_ERROR;
|
||||
else if (rc == BRM::ERR_PARTITION_ENABLED)
|
||||
result.result = PARTITION_WARNING;
|
||||
else
|
||||
result.result = DROP_ERROR;
|
||||
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
try {
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
// Log the DDL statement
|
||||
logging::logDDL(restorePartitionStmt.fSessionID, txnID.id, restorePartitionStmt.fSql, restorePartitionStmt.fOwner);
|
||||
try {
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
fSessionManager.committed(txnID);
|
||||
return result;
|
||||
}
|
||||
result.message = message;
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
//cerr << "RestorePartitionProcessor::processPackage: caught unknown exception!" << endl;
|
||||
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add("Enable partition: ");
|
||||
args.add( "encountered unkown exception" );
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format( args );
|
||||
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Log the DDL statement
|
||||
logging::logDDL(restorePartitionStmt.fSessionID, txnID.id, restorePartitionStmt.fSql, restorePartitionStmt.fOwner);
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
fSessionManager.committed(txnID);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,25 +34,25 @@
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
/** @brief specialization of a DDLPacakageProcessor
|
||||
* for interacting with the Write Engine to process
|
||||
* drop table ddl statements.
|
||||
/** @brief specialization of a DDLPacakageProcessor
|
||||
* for interacting with the Write Engine to process
|
||||
* drop table ddl statements.
|
||||
*/
|
||||
class RestorePartitionProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
RestorePartitionProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||
/** @brief process a drop table statement
|
||||
*
|
||||
* @param dropTableStmt the drop table statement
|
||||
*/
|
||||
class RestorePartitionProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
RestorePartitionProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm){}
|
||||
/** @brief process a drop table statement
|
||||
*
|
||||
* @param dropTableStmt the drop table statement
|
||||
*/
|
||||
EXPORT DDLResult processPackage(ddlpackage::RestorePartitionStatement& RestorePartitionStmt);
|
||||
EXPORT DDLResult processPackage(ddlpackage::RestorePartitionStatement& RestorePartitionStmt);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
};
|
||||
};
|
||||
} // namespace ddlpackageprocessor
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
@@ -404,55 +404,59 @@ public:
|
||||
|
||||
};
|
||||
|
||||
void destroySemaphores()
|
||||
{
|
||||
key_t semkey;
|
||||
int sems, err;
|
||||
void destroySemaphores()
|
||||
{
|
||||
key_t semkey;
|
||||
int sems, err;
|
||||
|
||||
semkey = 0x2149bdd2;
|
||||
sems = semget(semkey, 2, 0666);
|
||||
if (sems != -1)
|
||||
semkey = 0x2149bdd2;
|
||||
sems = semget(semkey, 2, 0666);
|
||||
|
||||
if (sems != -1)
|
||||
{
|
||||
err = semctl(sems, 0, IPC_RMID);
|
||||
|
||||
if (err == -1)
|
||||
perror("tdriver: semctl");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void destroyShmseg()
|
||||
{
|
||||
key_t shmkey;
|
||||
int shms, err;
|
||||
|
||||
shmkey = 0x2149bdd2;
|
||||
shms = shmget(shmkey, 0, 0666);
|
||||
|
||||
if (shms != -1)
|
||||
{
|
||||
err = shmctl(shms, IPC_RMID, NULL);
|
||||
|
||||
if (err == -1 && errno != EINVAL)
|
||||
{
|
||||
err = semctl(sems, 0, IPC_RMID);
|
||||
if (err == -1)
|
||||
perror("tdriver: semctl");
|
||||
perror("tdriver: shmctl");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{
|
||||
destroySemaphores();
|
||||
destroyShmseg();
|
||||
unlink("/tmp/oidbitmap");
|
||||
SystemCatalogBuilder::build();
|
||||
}
|
||||
|
||||
|
||||
void destroyShmseg()
|
||||
{
|
||||
key_t shmkey;
|
||||
int shms, err;
|
||||
|
||||
shmkey = 0x2149bdd2;
|
||||
shms = shmget(shmkey, 0, 0666);
|
||||
if (shms != -1)
|
||||
{
|
||||
err = shmctl(shms, IPC_RMID, NULL);
|
||||
if (err == -1 && errno != EINVAL)
|
||||
{
|
||||
perror("tdriver: shmctl");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{
|
||||
destroySemaphores();
|
||||
destroyShmseg();
|
||||
unlink("/tmp/oidbitmap");
|
||||
SystemCatalogBuilder::build();
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
destroySemaphores();
|
||||
destroyShmseg();
|
||||
unlink("/tmp/oidbitmap");
|
||||
}
|
||||
void tearDown()
|
||||
{
|
||||
destroySemaphores();
|
||||
destroyShmseg();
|
||||
unlink("/tmp/oidbitmap");
|
||||
}
|
||||
|
||||
class DDLPackageProcessorTest : public CppUnit::TestFixture
|
||||
{
|
||||
@@ -492,30 +496,33 @@ public:
|
||||
*/
|
||||
void test_createtable_region()
|
||||
{
|
||||
cout << "Begining create region table testing..." << endl;
|
||||
cout << "Begining create region table testing..." << endl;
|
||||
std::string sqlbuf = "create table region( r_regionkey integer NOT NULL, r_name char(25) ,r_comment varchar(152));";
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
CreateTableProcessor processor;
|
||||
processor.setDebugLevel(CreateTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
CreateTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<CreateTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -524,36 +531,39 @@ public:
|
||||
//setUp();
|
||||
//removeSystemCatalog();
|
||||
//createSystemCatalog();
|
||||
cout << "Begining create table testing..." << endl;
|
||||
cout << "Begining create table testing..." << endl;
|
||||
std::string sqlbuf = "create table tpch.part( p_partkey integer NOT NULL ,p_name varchar(55) default 'helloworld', p_mfgr char(6), p_brand char(10) , p_type varchar(25) default 'foobar' , p_size integer , p_container char(10) ,p_retailprice integer , p_comment varchar(23), CONSTRAINT PK_PART PRIMARY KEY(p_partkey) )";
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
CreateTableProcessor processor;
|
||||
processor.setDebugLevel(CreateTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
|
||||
CreateTableStatement& ct = dynamic_cast<CreateTableStatement&>(stmt);
|
||||
CreateTableStatement& ct = dynamic_cast<CreateTableStatement&>(stmt);
|
||||
|
||||
cout << "Parsed CreateTable:" << endl;
|
||||
cout << ct << endl;
|
||||
cout << "Parsed CreateTable:" << endl;
|
||||
cout << ct << endl;
|
||||
|
||||
CreateTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(ct);
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -563,86 +573,93 @@ public:
|
||||
std::string sqlbuf = "CREATE INDEX test_idx ON tpch.part (p_size)";
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
CreateIndexProcessor processor;
|
||||
processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
CreateIndexProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
void test_createuniqueindex()
|
||||
{
|
||||
cout << "Begining create unique index test ..." << endl;
|
||||
cout << "Begining create unique index test ..." << endl;
|
||||
std::string sqlbuf = "CREATE UNIQUE INDEX test_idx ON tpch.part (p_mfgr)";
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
CreateIndexProcessor processor;
|
||||
processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
CreateIndexProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
void test_altertable_addacolumn()
|
||||
{
|
||||
cout << "Begoning Alter Table Add column test ..." << endl;
|
||||
cout << "Begoning Alter Table Add column test ..." << endl;
|
||||
std::string sqlbuf = "ALTER TABLE tpch.part ADD COLUMN c3 char(50)";
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -653,56 +670,62 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
void test_altertable_addacolumnunique()
|
||||
void test_altertable_addacolumnunique()
|
||||
{
|
||||
cout << "Begining Alter Table add column with constraint test ..." << endl;
|
||||
std::string sqlbuf = "ALTER TABLE tpch.part ADD COLUMN c3 char(50) UNIQUE";
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
void test_altertable_dropacolumn()
|
||||
@@ -712,26 +735,29 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -742,26 +768,29 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -772,26 +801,29 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
void test_dropindex()
|
||||
@@ -801,27 +833,29 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
DropIndexProcessor processor;
|
||||
processor.setDebugLevel(DropIndexProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
DropIndexProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<DropIndexStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
void test_altertable_renamecolumn()
|
||||
@@ -831,26 +865,29 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -862,26 +899,29 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
void test_altertable_addtableconstraint()
|
||||
@@ -891,26 +931,29 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -921,26 +964,29 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -951,26 +997,29 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
void test_altertable_dropcolumndefault()
|
||||
@@ -980,26 +1029,29 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -1010,26 +1062,29 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
AlterTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -1040,27 +1095,29 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree &ptree = parser.GetParseTree();
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
DropTableProcessor processor;
|
||||
processor.setDebugLevel(DropTableProcessor::VERBOSE);
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
DropTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<DropTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
tearDown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -1071,12 +1128,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION( DDLPackageProcessorTest );
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
|
||||
int main( int argc, char **argv)
|
||||
int main( int argc, char** argv)
|
||||
{
|
||||
// Uncomment before running tests
|
||||
//setUp();
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
runner.addTest( registry.makeTest() );
|
||||
bool wasSuccessful = runner.run( "", false );
|
||||
return (wasSuccessful ? 0 : 1);
|
||||
|
||||
@@ -50,22 +50,25 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackage(dmlpacka
|
||||
std::string defaultSchema /*= ""*/)
|
||||
{
|
||||
CalpontDMLPackage* packagePtr = 0;
|
||||
|
||||
try
|
||||
{
|
||||
std::string dmlStatement = vpackage.get_DMLStatement();
|
||||
//@Bug 2680. DMLParser is not thread safe.
|
||||
boost::mutex::scoped_lock lk(fParserLock);
|
||||
//@Bug 2680. DMLParser is not thread safe.
|
||||
boost::mutex::scoped_lock lk(fParserLock);
|
||||
DMLParser parser;
|
||||
|
||||
if (defaultSchema.size())
|
||||
{
|
||||
{
|
||||
parser.setDefaultSchema(defaultSchema);
|
||||
}
|
||||
}
|
||||
|
||||
parser.parse(dmlStatement.c_str());
|
||||
|
||||
if (parser.good())
|
||||
{
|
||||
|
||||
const ParseTree &ptree = parser.getParseTree();
|
||||
const ParseTree& ptree = parser.getParseTree();
|
||||
SqlStatement* statementPtr = ptree[0];
|
||||
|
||||
int dmlStatementType = statementPtr->getStatementType();
|
||||
@@ -75,21 +78,21 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackage(dmlpacka
|
||||
case DML_INSERT:
|
||||
packagePtr = new InsertDMLPackage(statementPtr->getSchemaName(), statementPtr->getTableName(),
|
||||
ptree.fSqlText, vpackage.get_SessionID() );
|
||||
packagePtr->set_SQLStatement(dmlStatement);
|
||||
packagePtr->set_SQLStatement(dmlStatement);
|
||||
(void)packagePtr->buildFromSqlStatement(*statementPtr);
|
||||
break;
|
||||
|
||||
case DML_UPDATE:
|
||||
packagePtr = new UpdateDMLPackage(statementPtr->getSchemaName(), statementPtr->getTableName(),
|
||||
ptree.fSqlText, vpackage.get_SessionID() );
|
||||
packagePtr->set_SQLStatement(dmlStatement);
|
||||
packagePtr->set_SQLStatement(dmlStatement);
|
||||
(void)packagePtr->buildFromSqlStatement(*statementPtr);
|
||||
break;
|
||||
|
||||
case DML_DELETE:
|
||||
packagePtr = new DeleteDMLPackage(statementPtr->getSchemaName(), statementPtr->getTableName(),
|
||||
ptree.fSqlText, vpackage.get_SessionID() );
|
||||
packagePtr->set_SQLStatement(dmlStatement);
|
||||
packagePtr->set_SQLStatement(dmlStatement);
|
||||
(void)packagePtr->buildFromSqlStatement(*statementPtr);
|
||||
break;
|
||||
|
||||
@@ -122,32 +125,38 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackage(dmlpacka
|
||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromBuffer(dmlpackage::VendorDMLStatement& vpackage)
|
||||
{
|
||||
CalpontDMLPackage* packagePtr = 0;
|
||||
|
||||
try
|
||||
{
|
||||
int dmlStatementType = vpackage.get_DMLStatementType();
|
||||
|
||||
switch (dmlStatementType)
|
||||
{
|
||||
case DML_INSERT:
|
||||
packagePtr = new InsertDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(), vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer
|
||||
(),vpackage.get_Columns(), vpackage.get_Rows());
|
||||
(), vpackage.get_Columns(), vpackage.get_Rows());
|
||||
break;
|
||||
|
||||
case DML_UPDATE:
|
||||
packagePtr = new UpdateDMLPackage(vpackage.get_SchemaName(),
|
||||
vpackage.get_TableName(),vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
vpackage.get_TableName(), vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer
|
||||
(),vpackage.get_Columns(), vpackage.get_Rows());
|
||||
(), vpackage.get_Columns(), vpackage.get_Rows());
|
||||
break;
|
||||
|
||||
case DML_DELETE:
|
||||
packagePtr = new DeleteDMLPackage(vpackage.get_SchemaName(),
|
||||
vpackage.get_TableName(),vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
vpackage.get_TableName(), vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer
|
||||
(),vpackage.get_Columns(), vpackage.get_Rows());
|
||||
(), vpackage.get_Columns(), vpackage.get_Rows());
|
||||
break;
|
||||
|
||||
case DML_COMMAND:
|
||||
packagePtr = new CommandDMLPackage(vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
cerr << "makeCalpontDMLPackage: invalid statement type" << endl;
|
||||
break;
|
||||
@@ -161,34 +170,40 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromBuffe
|
||||
{
|
||||
cerr << "makeCalpontDMLPackage: caught unknown exception!" << endl;
|
||||
}
|
||||
|
||||
return packagePtr;
|
||||
}
|
||||
|
||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage)
|
||||
{
|
||||
CalpontDMLPackage* packagePtr = 0;
|
||||
try
|
||||
|
||||
try
|
||||
{
|
||||
int dmlStatementType = vpackage.get_DMLStatementType();
|
||||
|
||||
switch (dmlStatementType)
|
||||
{
|
||||
case DML_INSERT:
|
||||
packagePtr = new InsertDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(), vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromMysqlBuffer(vpackage.get_ColNames(), vpackage.get_values(), vpackage.get_Columns(), vpackage.get_Rows(), vpackage.get_nullValues());
|
||||
break;
|
||||
case DML_COMMAND:
|
||||
|
||||
case DML_COMMAND:
|
||||
packagePtr = new CommandDMLPackage(vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
||||
break;
|
||||
case DML_DELETE:
|
||||
break;
|
||||
|
||||
case DML_DELETE:
|
||||
packagePtr = new DeleteDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(),
|
||||
vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
||||
vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
||||
(void)packagePtr->buildFromMysqlBuffer(vpackage.get_ColNames(), vpackage.get_values(), vpackage.get_Columns(), vpackage.get_Rows(), vpackage.get_nullValues());
|
||||
break;
|
||||
default:
|
||||
|
||||
default:
|
||||
cerr << "makeCalpontDMLPackage: invalid statement type" << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
cerr << "makeCalpontDMLPackage:" << ex.what() << endl;
|
||||
@@ -197,16 +212,17 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromMysql
|
||||
{
|
||||
cerr << "makeCalpontDMLPackage: caught unknown exception!" << endl;
|
||||
}
|
||||
return packagePtr;
|
||||
|
||||
return packagePtr;
|
||||
}
|
||||
|
||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontUpdatePackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage, dmlpackage::UpdateSqlStatement& updateStmt)
|
||||
{
|
||||
CalpontDMLPackage* packagePtr = new UpdateDMLPackage((updateStmt.fNamePtr)->fSchema, (updateStmt.fNamePtr)->fName,
|
||||
vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
||||
UpdateDMLPackage* updatePkgPtr = dynamic_cast<UpdateDMLPackage*>(packagePtr);
|
||||
CalpontDMLPackage* packagePtr = new UpdateDMLPackage((updateStmt.fNamePtr)->fSchema, (updateStmt.fNamePtr)->fName,
|
||||
vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
||||
UpdateDMLPackage* updatePkgPtr = dynamic_cast<UpdateDMLPackage*>(packagePtr);
|
||||
updatePkgPtr->buildUpdateFromMysqlBuffer(updateStmt);
|
||||
packagePtr = dynamic_cast<CalpontDMLPackage*>(updatePkgPtr);
|
||||
return packagePtr;
|
||||
packagePtr = dynamic_cast<CalpontDMLPackage*>(updatePkgPtr);
|
||||
return packagePtr;
|
||||
}
|
||||
} //namespace dmlpackage
|
||||
|
||||
@@ -59,13 +59,13 @@ public:
|
||||
*/
|
||||
EXPORT static dmlpackage::CalpontDMLPackage* makeCalpontDMLPackageFromBuffer(dmlpackage::VendorDMLStatement& vpackage);
|
||||
|
||||
EXPORT static dmlpackage::CalpontDMLPackage* makeCalpontDMLPackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage);
|
||||
static dmlpackage::CalpontDMLPackage* makeCalpontUpdatePackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage, dmlpackage::UpdateSqlStatement& updateStmt);
|
||||
EXPORT static dmlpackage::CalpontDMLPackage* makeCalpontDMLPackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage);
|
||||
static dmlpackage::CalpontDMLPackage* makeCalpontUpdatePackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage, dmlpackage::UpdateSqlStatement& updateStmt);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
static boost::mutex fParserLock;
|
||||
static boost::mutex fParserLock;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -26,59 +26,62 @@ using namespace std;
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
/**
|
||||
* Constructors/Destructors
|
||||
*/
|
||||
/**
|
||||
* Constructors/Destructors
|
||||
*/
|
||||
|
||||
CalpontDMLPackage::CalpontDMLPackage()
|
||||
:fPlan(new messageqcpp::ByteStream()), fTable(0), fHasFilter(0), fLogging(true), fIsInsertSelect(false), fIsBatchInsert(false), fIsAutocommitOn(false), fTableOid(0)
|
||||
CalpontDMLPackage::CalpontDMLPackage()
|
||||
: fPlan(new messageqcpp::ByteStream()), fTable(0), fHasFilter(0), fLogging(true), fIsInsertSelect(false), fIsBatchInsert(false), fIsAutocommitOn(false), fTableOid(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CalpontDMLPackage::CalpontDMLPackage( std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID )
|
||||
: fSchemaName(schemaName), fTableName( tableName ), fDMLStatement( dmlStatement ),
|
||||
fSessionID(sessionID), fPlan(new messageqcpp::ByteStream()), fTable(0), fHasFilter(false), fLogging(true), fIsInsertSelect(false),
|
||||
fIsBatchInsert(false), fIsAutocommitOn(false), fIsWarnToError(false), fTableOid(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CalpontDMLPackage::~CalpontDMLPackage()
|
||||
{
|
||||
if ( 0 != fTable )
|
||||
delete fTable;
|
||||
}
|
||||
|
||||
/*
|
||||
* strip off whitespaces from a string
|
||||
*/
|
||||
std::string CalpontDMLPackage::StripLeadingWhitespace( std::string value )
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
string::size_type pos = value.find (' ', 0);
|
||||
|
||||
}
|
||||
|
||||
CalpontDMLPackage::CalpontDMLPackage( std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID )
|
||||
:fSchemaName(schemaName), fTableName( tableName ), fDMLStatement( dmlStatement ),
|
||||
fSessionID(sessionID), fPlan(new messageqcpp::ByteStream()), fTable(0), fHasFilter(false), fLogging(true), fIsInsertSelect(false),
|
||||
fIsBatchInsert(false), fIsAutocommitOn(false), fIsWarnToError(false), fTableOid(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CalpontDMLPackage::~CalpontDMLPackage()
|
||||
{
|
||||
if ( 0 != fTable )
|
||||
delete fTable;
|
||||
}
|
||||
|
||||
/*
|
||||
* strip off whitespaces from a string
|
||||
*/
|
||||
std::string CalpontDMLPackage::StripLeadingWhitespace( std::string value )
|
||||
{
|
||||
for(;;)
|
||||
if (pos == 0)
|
||||
{
|
||||
string::size_type pos = value.find (' ',0);
|
||||
if (pos == 0)
|
||||
{
|
||||
value = value.substr (pos+1,10000);
|
||||
}
|
||||
else
|
||||
{ // no more whitespace
|
||||
break;
|
||||
}
|
||||
value = value.substr (pos + 1, 10000);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
void CalpontDMLPackage::initializeTable()
|
||||
{
|
||||
if (0 == fTable)
|
||||
else
|
||||
{
|
||||
fTable = new DMLTable();
|
||||
fTable->set_SchemaName(fSchemaName);
|
||||
fTable->set_TableName(fTableName);
|
||||
// no more whitespace
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void CalpontDMLPackage::initializeTable()
|
||||
{
|
||||
if (0 == fTable)
|
||||
{
|
||||
fTable = new DMLTable();
|
||||
fTable->set_SchemaName(fSchemaName);
|
||||
fTable->set_TableName(fTableName);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dmlpackage
|
||||
|
||||
@@ -36,231 +36,335 @@
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
/** @brief abstract class that defines the general interface and
|
||||
* implemetation of a CalpontDMLPackage
|
||||
/** @brief abstract class that defines the general interface and
|
||||
* implemetation of a CalpontDMLPackage
|
||||
*/
|
||||
class CalpontDMLPackage
|
||||
{
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
class CalpontDMLPackage
|
||||
CalpontDMLPackage();
|
||||
|
||||
/** @brief ctor
|
||||
*
|
||||
* @param schemaName the schema of the table being operated on
|
||||
* @param tableName the name of the table being operated on
|
||||
* @param dmlStatement the dml statement
|
||||
* @param sessionID the session id
|
||||
*/
|
||||
CalpontDMLPackage( std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID );
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
virtual ~CalpontDMLPackage();
|
||||
|
||||
/** @brief write a CalpontDMLPackage to a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to write to
|
||||
*/
|
||||
virtual int write( messageqcpp::ByteStream& bytestream ) = 0;
|
||||
|
||||
/** @brief read a CalpontDMLPackage from a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to read from
|
||||
*/
|
||||
virtual int read( messageqcpp::ByteStream& bytestream ) = 0;
|
||||
|
||||
/** @brief build a CalpontDMLPackage from a string buffer
|
||||
*
|
||||
* @param buffer the row buffer
|
||||
* @param columns the number of columns in the buffer
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
virtual int buildFromBuffer( std::string& buffer, int columns, int rows ) = 0;
|
||||
|
||||
/** @brief build a CalpontDMLPackage from a parsed SqlStatement
|
||||
*
|
||||
* @param sqlStatement the parsed SqlStatement
|
||||
*/
|
||||
virtual int buildFromSqlStatement( SqlStatement& sqlStatement ) = 0;
|
||||
|
||||
/** @brief build a CalpontDMLPackage from valuelist built from mysql table fields
|
||||
*
|
||||
* @param tableValuesMap the value list for each column in the table
|
||||
* @param colNameList the column name for each column
|
||||
* @param columns number of columns in the table
|
||||
* @param rows number of rows to be touched
|
||||
*/
|
||||
virtual int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues) = 0;
|
||||
|
||||
/** @brief get the table object
|
||||
*/
|
||||
DMLTable* get_Table()
|
||||
{
|
||||
return fTable;
|
||||
}
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
CalpontDMLPackage();
|
||||
/** @brief set the DML statement (the parsed statement)
|
||||
*
|
||||
* @param statement the dml statement to set
|
||||
*/
|
||||
void set_DMLStatement( const std::string& statement )
|
||||
{
|
||||
fDMLStatement = statement;
|
||||
}
|
||||
|
||||
/** @brief ctor
|
||||
*
|
||||
* @param schemaName the schema of the table being operated on
|
||||
* @param tableName the name of the table being operated on
|
||||
* @param dmlStatement the dml statement
|
||||
* @param sessionID the session id
|
||||
*/
|
||||
CalpontDMLPackage( std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID );
|
||||
/** @brief get the DML statement (the parsed statement)
|
||||
*/
|
||||
const std::string get_DMLStatement() const
|
||||
{
|
||||
return fDMLStatement;
|
||||
}
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
virtual ~CalpontDMLPackage();
|
||||
/** @brief set the SQL statement (the original SQL statement)
|
||||
*
|
||||
* @param statement the SQL statement to set (the original SQL statement with quotes)
|
||||
*/
|
||||
void set_SQLStatement( const std::string& statement )
|
||||
{
|
||||
fSQLStatement = statement;
|
||||
}
|
||||
|
||||
/** @brief write a CalpontDMLPackage to a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to write to
|
||||
*/
|
||||
virtual int write( messageqcpp::ByteStream& bytestream ) = 0;
|
||||
/** @brief get the SQL statement (the original SQL statement)
|
||||
*/
|
||||
const std::string get_SQLStatement() const
|
||||
{
|
||||
return fSQLStatement;
|
||||
}
|
||||
|
||||
/** @brief read a CalpontDMLPackage from a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to read from
|
||||
*/
|
||||
virtual int read( messageqcpp::ByteStream& bytestream ) = 0;
|
||||
/** @brief get the logging flag
|
||||
*/
|
||||
const bool get_Logging() const
|
||||
{
|
||||
return fLogging;
|
||||
}
|
||||
|
||||
/** @brief build a CalpontDMLPackage from a string buffer
|
||||
*
|
||||
* @param buffer the row buffer
|
||||
* @param columns the number of columns in the buffer
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
virtual int buildFromBuffer( std::string& buffer, int columns, int rows ) = 0;
|
||||
/** @brief set the logging flag
|
||||
*
|
||||
* @param logging the logging flag to set
|
||||
*/
|
||||
void set_Logging( bool logging )
|
||||
{
|
||||
fLogging = logging;
|
||||
}
|
||||
|
||||
/** @brief build a CalpontDMLPackage from a parsed SqlStatement
|
||||
*
|
||||
* @param sqlStatement the parsed SqlStatement
|
||||
*/
|
||||
virtual int buildFromSqlStatement( SqlStatement& sqlStatement ) = 0;
|
||||
/** @brief get the logending flag
|
||||
*/
|
||||
const bool get_Logending() const
|
||||
{
|
||||
return fLogending;
|
||||
}
|
||||
|
||||
/** @brief build a CalpontDMLPackage from valuelist built from mysql table fields
|
||||
*
|
||||
* @param tableValuesMap the value list for each column in the table
|
||||
* @param colNameList the column name for each column
|
||||
* @param columns number of columns in the table
|
||||
* @param rows number of rows to be touched
|
||||
*/
|
||||
virtual int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues) = 0;
|
||||
/** @brief set the logending flag
|
||||
*
|
||||
* @param logending the logending flag to set
|
||||
*/
|
||||
void set_Logending( bool logending )
|
||||
{
|
||||
fLogending = logending;
|
||||
}
|
||||
|
||||
/** @brief get the table object
|
||||
*/
|
||||
DMLTable* get_Table() { return fTable; }
|
||||
/** @brief get the isFromCol flag
|
||||
*/
|
||||
const bool get_IsFromCol() const
|
||||
{
|
||||
return fIsFromCol;
|
||||
}
|
||||
|
||||
/** @brief set the DML statement (the parsed statement)
|
||||
*
|
||||
* @param statement the dml statement to set
|
||||
*/
|
||||
void set_DMLStatement( const std::string& statement ) { fDMLStatement = statement; }
|
||||
/** @brief set the update column from column flag
|
||||
*
|
||||
* @param logging the logging flag to set
|
||||
*/
|
||||
void set_IsFromCol ( bool isFromCol )
|
||||
{
|
||||
fIsFromCol = isFromCol;
|
||||
}
|
||||
/** @brief set the Table name
|
||||
*
|
||||
* @param tableName the name to set
|
||||
*/
|
||||
void set_TableName( std::string& tableName )
|
||||
{
|
||||
fTableName = tableName;
|
||||
|
||||
/** @brief get the DML statement (the parsed statement)
|
||||
*/
|
||||
const std::string get_DMLStatement() const { return fDMLStatement; }
|
||||
if (fTable != 0)
|
||||
fTable->set_TableName(tableName);
|
||||
}
|
||||
|
||||
/** @brief set the SQL statement (the original SQL statement)
|
||||
*
|
||||
* @param statement the SQL statement to set (the original SQL statement with quotes)
|
||||
*/
|
||||
void set_SQLStatement( const std::string& statement ) { fSQLStatement = statement; }
|
||||
/** @brief get the Table name
|
||||
*/
|
||||
const std::string get_TableName() const
|
||||
{
|
||||
return fTableName;
|
||||
}
|
||||
|
||||
/** @brief get the SQL statement (the original SQL statement)
|
||||
*/
|
||||
const std::string get_SQLStatement() const { return fSQLStatement; }
|
||||
/** @brief set the Schema name
|
||||
*
|
||||
* @param the schema to set
|
||||
*/
|
||||
void set_SchemaName( std::string& schemaName )
|
||||
{
|
||||
fSchemaName = schemaName;
|
||||
|
||||
/** @brief get the logging flag
|
||||
*/
|
||||
const bool get_Logging() const { return fLogging; }
|
||||
if (fTable != 0)
|
||||
fTable->set_SchemaName(schemaName);
|
||||
}
|
||||
|
||||
/** @brief set the logging flag
|
||||
*
|
||||
* @param logging the logging flag to set
|
||||
*/
|
||||
void set_Logging( bool logging ) { fLogging = logging; }
|
||||
/** @brief get the Schema name
|
||||
*/
|
||||
const std::string get_SchemaName() const
|
||||
{
|
||||
return fSchemaName;
|
||||
}
|
||||
|
||||
/** @brief get the logending flag
|
||||
*/
|
||||
const bool get_Logending() const { return fLogending; }
|
||||
/** @brief does this dml statement have a filter
|
||||
*/
|
||||
bool HasFilter() const
|
||||
{
|
||||
return fHasFilter;
|
||||
}
|
||||
void HasFilter( bool hasFilter)
|
||||
{
|
||||
fHasFilter = hasFilter;
|
||||
}
|
||||
|
||||
/** @brief set the logending flag
|
||||
*
|
||||
* @param logending the logending flag to set
|
||||
*/
|
||||
void set_Logending( bool logending ) { fLogending = logending; }
|
||||
/** @brief get the filter statement
|
||||
*/
|
||||
const std::string get_QueryString() const
|
||||
{
|
||||
return fQueryString;
|
||||
}
|
||||
|
||||
/** @brief get the isFromCol flag
|
||||
*/
|
||||
const bool get_IsFromCol() const { return fIsFromCol; }
|
||||
/** @brief set the sessionID associated with this package
|
||||
*/
|
||||
void set_SessionID( int sessionID )
|
||||
{
|
||||
fSessionID = sessionID;
|
||||
}
|
||||
|
||||
/** @brief set the update column from column flag
|
||||
*
|
||||
* @param logging the logging flag to set
|
||||
*/
|
||||
void set_IsFromCol ( bool isFromCol ) { fIsFromCol = isFromCol; }
|
||||
/** @brief set the Table name
|
||||
*
|
||||
* @param tableName the name to set
|
||||
*/
|
||||
void set_TableName( std::string& tableName )
|
||||
{
|
||||
fTableName = tableName;
|
||||
if(fTable != 0)
|
||||
fTable->set_TableName(tableName);
|
||||
}
|
||||
/** @brief get the sessionID associated with this package
|
||||
*/
|
||||
int get_SessionID() const
|
||||
{
|
||||
return fSessionID;
|
||||
}
|
||||
|
||||
/** @brief get the Table name
|
||||
*/
|
||||
const std::string get_TableName() const { return fTableName; }
|
||||
/** @brief set the transaction ID associated with this package
|
||||
*/
|
||||
void set_TxnID( execplan::CalpontSystemCatalog::SCN txnID )
|
||||
{
|
||||
fTxnId = txnID;
|
||||
}
|
||||
|
||||
/** @brief set the Schema name
|
||||
*
|
||||
* @param the schema to set
|
||||
*/
|
||||
void set_SchemaName( std::string& schemaName )
|
||||
{
|
||||
fSchemaName = schemaName;
|
||||
if(fTable != 0)
|
||||
fTable->set_SchemaName(schemaName);
|
||||
}
|
||||
/** @brief get the transaction ID associated with this package
|
||||
*/
|
||||
execplan::CalpontSystemCatalog::SCN get_TxnID() const
|
||||
{
|
||||
return fTxnId;
|
||||
}
|
||||
/** @brief set the chunkmanager associated with this package
|
||||
*/
|
||||
void set_ChunkManager( WriteEngine::ChunkManager* cm )
|
||||
{
|
||||
fCM = cm;
|
||||
}
|
||||
|
||||
/** @brief get the Schema name
|
||||
*/
|
||||
const std::string get_SchemaName() const { return fSchemaName; }
|
||||
/** @brief get the chunkmanager associated with this package
|
||||
*/
|
||||
WriteEngine::ChunkManager* get_ChunkManager() const
|
||||
{
|
||||
return fCM;
|
||||
}
|
||||
|
||||
/** @brief does this dml statement have a filter
|
||||
*/
|
||||
bool HasFilter() const { return fHasFilter; }
|
||||
void HasFilter( bool hasFilter) { fHasFilter = hasFilter; }
|
||||
/** @brief get the ExecutionPlan associated with this package
|
||||
*/
|
||||
boost::shared_ptr<messageqcpp::ByteStream> get_ExecutionPlan()
|
||||
{
|
||||
return fPlan;
|
||||
}
|
||||
|
||||
/** @brief get the filter statement
|
||||
*/
|
||||
const std::string get_QueryString() const { return fQueryString; }
|
||||
bool get_isInsertSelect()
|
||||
{
|
||||
return fIsInsertSelect;
|
||||
}
|
||||
void set_isInsertSelect( const bool isInsertSelect )
|
||||
{
|
||||
fIsInsertSelect = isInsertSelect;
|
||||
}
|
||||
|
||||
/** @brief set the sessionID associated with this package
|
||||
*/
|
||||
void set_SessionID( int sessionID ) { fSessionID = sessionID; }
|
||||
bool get_isBatchInsert()
|
||||
{
|
||||
return fIsBatchInsert;
|
||||
}
|
||||
void set_isBatchInsert( const bool isBatchInsert )
|
||||
{
|
||||
fIsBatchInsert = isBatchInsert;
|
||||
}
|
||||
|
||||
/** @brief get the sessionID associated with this package
|
||||
*/
|
||||
int get_SessionID() const { return fSessionID; }
|
||||
bool get_isAutocommitOn()
|
||||
{
|
||||
return fIsAutocommitOn;
|
||||
}
|
||||
void set_isAutocommitOn( const bool isAutocommitOn )
|
||||
{
|
||||
fIsAutocommitOn = isAutocommitOn;
|
||||
}
|
||||
|
||||
/** @brief set the transaction ID associated with this package
|
||||
*/
|
||||
void set_TxnID( execplan::CalpontSystemCatalog::SCN txnID ) { fTxnId = txnID; }
|
||||
bool get_isWarnToError()
|
||||
{
|
||||
return fIsWarnToError;
|
||||
}
|
||||
void set_isWarnToError( const bool isWarnToError )
|
||||
{
|
||||
fIsWarnToError = isWarnToError;
|
||||
}
|
||||
|
||||
/** @brief get the transaction ID associated with this package
|
||||
*/
|
||||
execplan::CalpontSystemCatalog::SCN get_TxnID() const { return fTxnId; }
|
||||
/** @brief set the chunkmanager associated with this package
|
||||
*/
|
||||
void set_ChunkManager( WriteEngine::ChunkManager* cm ) { fCM = cm; }
|
||||
uint32_t getTableOid()
|
||||
{
|
||||
return fTableOid;
|
||||
}
|
||||
void setTableOid( const uint32_t tableOid )
|
||||
{
|
||||
fTableOid = tableOid;
|
||||
}
|
||||
|
||||
/** @brief get the chunkmanager associated with this package
|
||||
*/
|
||||
WriteEngine::ChunkManager* get_ChunkManager() const { return fCM; }
|
||||
void uuid(const boost::uuids::uuid& uuid)
|
||||
{
|
||||
fUuid = uuid;
|
||||
}
|
||||
const boost::uuids::uuid& uuid() const
|
||||
{
|
||||
return fUuid;
|
||||
}
|
||||
|
||||
/** @brief get the ExecutionPlan associated with this package
|
||||
*/
|
||||
boost::shared_ptr<messageqcpp::ByteStream> get_ExecutionPlan()
|
||||
{
|
||||
return fPlan;
|
||||
}
|
||||
protected:
|
||||
|
||||
bool get_isInsertSelect() { return fIsInsertSelect; }
|
||||
void set_isInsertSelect( const bool isInsertSelect ) { fIsInsertSelect = isInsertSelect; }
|
||||
void initializeTable();
|
||||
|
||||
bool get_isBatchInsert() { return fIsBatchInsert; }
|
||||
void set_isBatchInsert( const bool isBatchInsert ) { fIsBatchInsert = isBatchInsert; }
|
||||
|
||||
bool get_isAutocommitOn() { return fIsAutocommitOn; }
|
||||
void set_isAutocommitOn( const bool isAutocommitOn ) { fIsAutocommitOn = isAutocommitOn; }
|
||||
|
||||
bool get_isWarnToError() { return fIsWarnToError; }
|
||||
void set_isWarnToError( const bool isWarnToError ) { fIsWarnToError = isWarnToError; }
|
||||
|
||||
uint32_t getTableOid() { return fTableOid; }
|
||||
void setTableOid( const uint32_t tableOid ) { fTableOid = tableOid; }
|
||||
|
||||
void uuid(const boost::uuids::uuid& uuid) { fUuid = uuid; }
|
||||
const boost::uuids::uuid& uuid() const { return fUuid; }
|
||||
|
||||
protected:
|
||||
|
||||
void initializeTable();
|
||||
|
||||
std::string fSchemaName;
|
||||
std::string fTableName;
|
||||
std::string fDMLStatement;
|
||||
std::string fSQLStatement;
|
||||
std::string fQueryString;
|
||||
int fSessionID;
|
||||
boost::uuids::uuid fUuid;
|
||||
execplan::CalpontSystemCatalog::SCN fTxnId;
|
||||
boost::shared_ptr<messageqcpp::ByteStream> fPlan;
|
||||
DMLTable *fTable;
|
||||
bool fHasFilter;
|
||||
bool fLogging;
|
||||
bool fLogending;
|
||||
bool fIsFromCol;
|
||||
std::string StripLeadingWhitespace( std::string value );
|
||||
bool fIsInsertSelect;
|
||||
bool fIsBatchInsert;
|
||||
bool fIsAutocommitOn;
|
||||
bool fIsWarnToError;
|
||||
uint32_t fTableOid;
|
||||
WriteEngine::ChunkManager* fCM;
|
||||
};
|
||||
std::string fSchemaName;
|
||||
std::string fTableName;
|
||||
std::string fDMLStatement;
|
||||
std::string fSQLStatement;
|
||||
std::string fQueryString;
|
||||
int fSessionID;
|
||||
boost::uuids::uuid fUuid;
|
||||
execplan::CalpontSystemCatalog::SCN fTxnId;
|
||||
boost::shared_ptr<messageqcpp::ByteStream> fPlan;
|
||||
DMLTable* fTable;
|
||||
bool fHasFilter;
|
||||
bool fLogging;
|
||||
bool fLogending;
|
||||
bool fIsFromCol;
|
||||
std::string StripLeadingWhitespace( std::string value );
|
||||
bool fIsInsertSelect;
|
||||
bool fIsBatchInsert;
|
||||
bool fIsAutocommitOn;
|
||||
bool fIsWarnToError;
|
||||
uint32_t fTableOid;
|
||||
WriteEngine::ChunkManager* fCM;
|
||||
};
|
||||
}
|
||||
#endif //CALPONTDMLPACKAGE_H
|
||||
|
||||
@@ -32,67 +32,67 @@ using namespace std;
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
CommandDMLPackage::CommandDMLPackage()
|
||||
{}
|
||||
CommandDMLPackage::CommandDMLPackage()
|
||||
{}
|
||||
|
||||
CommandDMLPackage::CommandDMLPackage( std::string dmlStatement, int sessionID)
|
||||
:CalpontDMLPackage( "", "", dmlStatement, sessionID)
|
||||
{}
|
||||
CommandDMLPackage::CommandDMLPackage( std::string dmlStatement, int sessionID)
|
||||
: CalpontDMLPackage( "", "", dmlStatement, sessionID)
|
||||
{}
|
||||
|
||||
CommandDMLPackage::~CommandDMLPackage()
|
||||
{}
|
||||
CommandDMLPackage::~CommandDMLPackage()
|
||||
{}
|
||||
|
||||
int CommandDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||
{
|
||||
int retval = 1;
|
||||
int CommandDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||
{
|
||||
int retval = 1;
|
||||
|
||||
messageqcpp::ByteStream::byte package_type = DML_COMMAND;
|
||||
bytestream << package_type;
|
||||
messageqcpp::ByteStream::byte package_type = DML_COMMAND;
|
||||
bytestream << package_type;
|
||||
|
||||
messageqcpp::ByteStream::quadbyte session_id = fSessionID;
|
||||
bytestream << session_id;
|
||||
messageqcpp::ByteStream::quadbyte session_id = fSessionID;
|
||||
bytestream << session_id;
|
||||
|
||||
bytestream << fUuid;
|
||||
bytestream << fUuid;
|
||||
|
||||
bytestream << fDMLStatement;
|
||||
bytestream << fSQLStatement; // for cleartablelock, this is table lockID
|
||||
bytestream << (uint8_t)fLogging;
|
||||
bytestream << fSchemaName;
|
||||
bytestream << fTableName;
|
||||
bytestream << fTableOid;
|
||||
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsAutocommitOn);
|
||||
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsBatchInsert);
|
||||
return retval;
|
||||
}
|
||||
bytestream << fDMLStatement;
|
||||
bytestream << fSQLStatement; // for cleartablelock, this is table lockID
|
||||
bytestream << (uint8_t)fLogging;
|
||||
bytestream << fSchemaName;
|
||||
bytestream << fTableName;
|
||||
bytestream << fTableOid;
|
||||
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsAutocommitOn);
|
||||
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsBatchInsert);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int CommandDMLPackage::read(messageqcpp::ByteStream& bytestream)
|
||||
{
|
||||
int retval = 1;
|
||||
int CommandDMLPackage::read(messageqcpp::ByteStream& bytestream)
|
||||
{
|
||||
int retval = 1;
|
||||
|
||||
messageqcpp::ByteStream::quadbyte session_id;
|
||||
bytestream >> session_id;
|
||||
fSessionID = session_id;
|
||||
bytestream >> fUuid;
|
||||
messageqcpp::ByteStream::quadbyte session_id;
|
||||
bytestream >> session_id;
|
||||
fSessionID = session_id;
|
||||
bytestream >> fUuid;
|
||||
|
||||
bytestream >> fDMLStatement;
|
||||
bytestream >> fSQLStatement; // for cleartablelock, this is table lockID
|
||||
uint8_t logging;
|
||||
bytestream >> logging;
|
||||
fLogging = (logging != 0);
|
||||
bytestream >> fSchemaName;
|
||||
bytestream >> fTableName;
|
||||
bytestream >> fTableOid;
|
||||
bytestream >> reinterpret_cast< messageqcpp::ByteStream::byte&>(fIsAutocommitOn);
|
||||
bytestream >> reinterpret_cast< messageqcpp::ByteStream::byte&>(fIsBatchInsert);
|
||||
return retval;
|
||||
}
|
||||
bytestream >> fDMLStatement;
|
||||
bytestream >> fSQLStatement; // for cleartablelock, this is table lockID
|
||||
uint8_t logging;
|
||||
bytestream >> logging;
|
||||
fLogging = (logging != 0);
|
||||
bytestream >> fSchemaName;
|
||||
bytestream >> fTableName;
|
||||
bytestream >> fTableOid;
|
||||
bytestream >> reinterpret_cast< messageqcpp::ByteStream::byte&>(fIsAutocommitOn);
|
||||
bytestream >> reinterpret_cast< messageqcpp::ByteStream::byte&>(fIsBatchInsert);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int CommandDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
{
|
||||
CommandSqlStatement& cmdStmt = dynamic_cast<CommandSqlStatement&>(sqlStatement);
|
||||
fDMLStatement = cmdStmt.fCommandText;
|
||||
int CommandDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
{
|
||||
CommandSqlStatement& cmdStmt = dynamic_cast<CommandSqlStatement&>(sqlStatement);
|
||||
fDMLStatement = cmdStmt.fCommandText;
|
||||
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
} // namespace dmlpackage
|
||||
|
||||
@@ -36,67 +36,67 @@
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
/** @brief concrete implementation of a CalpontDMLPackage
|
||||
* Specifically for representing COMMAND DML Statements
|
||||
/** @brief concrete implementation of a CalpontDMLPackage
|
||||
* Specifically for representing COMMAND DML Statements
|
||||
*/
|
||||
class CommandDMLPackage : public CalpontDMLPackage
|
||||
{
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
class CommandDMLPackage : public CalpontDMLPackage
|
||||
EXPORT CommandDMLPackage();
|
||||
|
||||
/** @brief ctor
|
||||
*/
|
||||
EXPORT CommandDMLPackage( std::string dmlStatement, int sessionID );
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
EXPORT virtual ~CommandDMLPackage();
|
||||
|
||||
/** @brief write a CommandDMLPackage to a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to write to
|
||||
*/
|
||||
EXPORT int write(messageqcpp::ByteStream& bytestream);
|
||||
|
||||
/** @brief read CommandDMLPackage from bytestream
|
||||
*
|
||||
* @param bytestream the ByteStream to read from
|
||||
*/
|
||||
EXPORT int read(messageqcpp::ByteStream& bytestream);
|
||||
/** @brief do nothing
|
||||
*
|
||||
* @param buffer
|
||||
* @param columns the number of columns in the buffer
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
inline int buildFromBuffer(std::string& buffer, int columns = 0, int rows = 0)
|
||||
{
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
EXPORT CommandDMLPackage();
|
||||
|
||||
/** @brief ctor
|
||||
*/
|
||||
EXPORT CommandDMLPackage( std::string dmlStatement, int sessionID );
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
EXPORT virtual ~CommandDMLPackage();
|
||||
|
||||
/** @brief write a CommandDMLPackage to a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to write to
|
||||
*/
|
||||
EXPORT int write(messageqcpp::ByteStream& bytestream);
|
||||
|
||||
/** @brief read CommandDMLPackage from bytestream
|
||||
*
|
||||
* @param bytestream the ByteStream to read from
|
||||
*/
|
||||
EXPORT int read(messageqcpp::ByteStream& bytestream);
|
||||
/** @brief do nothing
|
||||
*
|
||||
* @param buffer
|
||||
* @param columns the number of columns in the buffer
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
inline int buildFromBuffer(std::string& buffer, int columns=0, int rows=0)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
/** @brief build a CommandDMLPackage from a CommandSqlStatement
|
||||
*/
|
||||
EXPORT int buildFromSqlStatement(SqlStatement& sqlStatement);
|
||||
|
||||
/** @brief build a InsertDMLPackage from MySQL buffer
|
||||
*
|
||||
* @param colNameList, tableValuesMap
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
/** @brief build a CommandDMLPackage from a CommandSqlStatement
|
||||
*/
|
||||
EXPORT int buildFromSqlStatement(SqlStatement& sqlStatement);
|
||||
|
||||
/** @brief build a InsertDMLPackage from MySQL buffer
|
||||
*
|
||||
* @param colNameList, tableValuesMap
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
@@ -38,7 +38,7 @@ DeleteDMLPackage::DeleteDMLPackage()
|
||||
|
||||
DeleteDMLPackage::DeleteDMLPackage(std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID)
|
||||
:CalpontDMLPackage( schemaName, tableName, dmlStatement, sessionID )
|
||||
: CalpontDMLPackage( schemaName, tableName, dmlStatement, sessionID )
|
||||
{}
|
||||
|
||||
DeleteDMLPackage::~DeleteDMLPackage()
|
||||
@@ -54,11 +54,11 @@ int DeleteDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||
messageqcpp::ByteStream::quadbyte session_id = fSessionID;
|
||||
bytestream << session_id;
|
||||
|
||||
/* if(fPlan != 0)
|
||||
fHasFilter = true;
|
||||
else
|
||||
fHasFilter = false;
|
||||
*/
|
||||
/* if(fPlan != 0)
|
||||
fHasFilter = true;
|
||||
else
|
||||
fHasFilter = false;
|
||||
*/
|
||||
messageqcpp::ByteStream::quadbyte hasFilter = fHasFilter;
|
||||
bytestream << hasFilter;
|
||||
|
||||
@@ -67,11 +67,13 @@ int DeleteDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||
bytestream << fDMLStatement;
|
||||
bytestream << fSQLStatement;
|
||||
bytestream << fSchemaName;
|
||||
|
||||
if (fTable != 0)
|
||||
{
|
||||
retval = fTable->write(bytestream);
|
||||
}
|
||||
if(fHasFilter)
|
||||
|
||||
if (fHasFilter)
|
||||
{
|
||||
bytestream += *(fPlan.get());
|
||||
}
|
||||
@@ -103,9 +105,10 @@ int DeleteDMLPackage::read(messageqcpp::ByteStream& bytestream)
|
||||
|
||||
fTable = new DMLTable();
|
||||
retval = fTable->read(bytestream);
|
||||
if(fHasFilter)
|
||||
|
||||
if (fHasFilter)
|
||||
{
|
||||
fPlan.reset(new messageqcpp::ByteStream(bytestream));
|
||||
fPlan.reset(new messageqcpp::ByteStream(bytestream));
|
||||
}
|
||||
|
||||
return retval;
|
||||
@@ -124,6 +127,7 @@ int DeleteDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
fHasFilter = true;
|
||||
fQueryString = deleteStmt.getQueryString();
|
||||
}
|
||||
|
||||
// else all rows are deleted
|
||||
|
||||
return retval;
|
||||
@@ -146,6 +150,7 @@ int DeleteDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||
boost::char_separator<char> sep(":");
|
||||
tokenizer tokens(buffer, sep);
|
||||
|
||||
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
||||
{
|
||||
dataList.push_back(StripLeadingWhitespace(*tok_iter));
|
||||
@@ -153,7 +158,8 @@ int DeleteDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
for (int i=0; i < rows; i++)
|
||||
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
//get a new row
|
||||
Row aRow;
|
||||
@@ -195,21 +201,21 @@ int DeleteDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValues
|
||||
|
||||
initializeTable();
|
||||
//The row already built from MySql parser.
|
||||
/* Row *aRowPtr = new Row();
|
||||
std::string colName;
|
||||
std::vector<std::string> colValList;
|
||||
for (int j = 0; j < columns; j++)
|
||||
{
|
||||
//Build a column list
|
||||
colName = colNameList[j];
|
||||
/* Row *aRowPtr = new Row();
|
||||
std::string colName;
|
||||
std::vector<std::string> colValList;
|
||||
for (int j = 0; j < columns; j++)
|
||||
{
|
||||
//Build a column list
|
||||
colName = colNameList[j];
|
||||
|
||||
colValList = tableValuesMap[j];
|
||||
colValList = tableValuesMap[j];
|
||||
|
||||
DMLColumn* aColumn = new DMLColumn(colName, colValList, false);
|
||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||
}
|
||||
//build a row list for a table
|
||||
fTable->get_RowList().push_back(aRowPtr); */
|
||||
DMLColumn* aColumn = new DMLColumn(colName, colValList, false);
|
||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||
}
|
||||
//build a row list for a table
|
||||
fTable->get_RowList().push_back(aRowPtr); */
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,69 +36,69 @@
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
/** @brief concrete implementation of a CalpontDMLPackage
|
||||
* Specifically for representing DELETE DML Statements
|
||||
/** @brief concrete implementation of a CalpontDMLPackage
|
||||
* Specifically for representing DELETE DML Statements
|
||||
*/
|
||||
class DeleteDMLPackage : public CalpontDMLPackage
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/** @brief ctor
|
||||
*/
|
||||
class DeleteDMLPackage : public CalpontDMLPackage
|
||||
{
|
||||
EXPORT DeleteDMLPackage();
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*
|
||||
* @param schemaName the schema of the table being operated on
|
||||
* @param tableName the name of the table being operated on
|
||||
* @param dmlStatement the dml statement
|
||||
* @param sessionID the session ID
|
||||
*/
|
||||
EXPORT DeleteDMLPackage( std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID );
|
||||
|
||||
/** @brief ctor
|
||||
*/
|
||||
EXPORT DeleteDMLPackage();
|
||||
/** @brief dtor
|
||||
*/
|
||||
EXPORT virtual ~DeleteDMLPackage();
|
||||
|
||||
/** @brief ctor
|
||||
*
|
||||
* @param schemaName the schema of the table being operated on
|
||||
* @param tableName the name of the table being operated on
|
||||
* @param dmlStatement the dml statement
|
||||
* @param sessionID the session ID
|
||||
*/
|
||||
EXPORT DeleteDMLPackage( std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID );
|
||||
/** @brief write a DeleteDMLPackage to a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to write to
|
||||
*/
|
||||
EXPORT int write(messageqcpp::ByteStream& bytestream);
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
EXPORT virtual ~DeleteDMLPackage();
|
||||
/** @brief read a DeleteDMLPackage from a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to read from
|
||||
*/
|
||||
EXPORT int read(messageqcpp::ByteStream& bytestream);
|
||||
|
||||
/** @brief write a DeleteDMLPackage to a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to write to
|
||||
*/
|
||||
EXPORT int write(messageqcpp::ByteStream& bytestream);
|
||||
/** @brief build a DeleteDMLPackage from a string buffer
|
||||
*
|
||||
* @param buffer [rowId, columnName, colValue]
|
||||
* @param columns the number of columns in the buffer
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
EXPORT int buildFromBuffer(std::string& buffer, int columns, int rows);
|
||||
|
||||
/** @brief read a DeleteDMLPackage from a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to read from
|
||||
*/
|
||||
EXPORT int read(messageqcpp::ByteStream& bytestream);
|
||||
/** @brief build a DeleteDMLPackage from a parsed DeleteSqlStatement
|
||||
*
|
||||
* @param sqlStatement the parsed DeleteSqlStatement
|
||||
*/
|
||||
EXPORT int buildFromSqlStatement(SqlStatement& sqlStatement);
|
||||
/** @brief build a InsertDMLPackage from MySQL buffer
|
||||
*
|
||||
* @param colNameList, tableValuesMap
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues);
|
||||
|
||||
/** @brief build a DeleteDMLPackage from a string buffer
|
||||
*
|
||||
* @param buffer [rowId, columnName, colValue]
|
||||
* @param columns the number of columns in the buffer
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
EXPORT int buildFromBuffer(std::string& buffer, int columns, int rows);
|
||||
protected:
|
||||
|
||||
/** @brief build a DeleteDMLPackage from a parsed DeleteSqlStatement
|
||||
*
|
||||
* @param sqlStatement the parsed DeleteSqlStatement
|
||||
*/
|
||||
EXPORT int buildFromSqlStatement(SqlStatement& sqlStatement);
|
||||
/** @brief build a InsertDMLPackage from MySQL buffer
|
||||
*
|
||||
* @param colNameList, tableValuesMap
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues);
|
||||
private:
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -36,98 +36,99 @@
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
NAME = 258,
|
||||
STRING = 259,
|
||||
INTNUM = 260,
|
||||
APPROXNUM = 261,
|
||||
SELECT = 262,
|
||||
ALL = 263,
|
||||
DISTINCT = 264,
|
||||
NULLX = 265,
|
||||
USER = 266,
|
||||
INDICATOR = 267,
|
||||
AMMSC = 268,
|
||||
PARAMETER = 269,
|
||||
ANY = 270,
|
||||
SOME = 271,
|
||||
OR = 272,
|
||||
AND = 273,
|
||||
NOT = 274,
|
||||
COMPARISON = 275,
|
||||
UMINUS = 276,
|
||||
AS = 277,
|
||||
ASC = 278,
|
||||
AUTHORIZATION = 279,
|
||||
BETWEEN = 280,
|
||||
BY = 281,
|
||||
CHARACTER = 282,
|
||||
CHECK = 283,
|
||||
CLOSE = 284,
|
||||
COMMIT = 285,
|
||||
CONTINUE = 286,
|
||||
CREATE = 287,
|
||||
CURRENT = 288,
|
||||
CURSOR = 289,
|
||||
IDB_DECIMAL = 290,
|
||||
DECLARE = 291,
|
||||
DEFAULT = 292,
|
||||
DELETE = 293,
|
||||
DESC = 294,
|
||||
IDB_DOUBLE = 295,
|
||||
ESCAPE = 296,
|
||||
EXISTS = 297,
|
||||
FETCH = 298,
|
||||
IDB_FLOAT = 299,
|
||||
FOR = 300,
|
||||
FOREIGN = 301,
|
||||
FOUND = 302,
|
||||
FROM = 303,
|
||||
GOTO = 304,
|
||||
GRANT = 305,
|
||||
IDB_GROUP = 306,
|
||||
HAVING = 307,
|
||||
IN = 308,
|
||||
INSERT = 309,
|
||||
INTEGER = 310,
|
||||
INTO = 311,
|
||||
IS = 312,
|
||||
KEY = 313,
|
||||
LANGUAGE = 314,
|
||||
LIKE = 315,
|
||||
NUMERIC = 316,
|
||||
OF = 317,
|
||||
ON = 318,
|
||||
OPEN = 319,
|
||||
OPTION = 320,
|
||||
ORDER = 321,
|
||||
PRECISION = 322,
|
||||
PRIMARY = 323,
|
||||
PRIVILEGES = 324,
|
||||
PROCEDURE = 325,
|
||||
PUBLIC = 326,
|
||||
REAL = 327,
|
||||
REFERENCES = 328,
|
||||
ROLLBACK = 329,
|
||||
SCHEMA = 330,
|
||||
SET = 331,
|
||||
SMALLINT = 332,
|
||||
SQLCODE = 333,
|
||||
SQLERROR = 334,
|
||||
TABLE = 335,
|
||||
TO = 336,
|
||||
UNION = 337,
|
||||
UNIQUE = 338,
|
||||
UPDATE = 339,
|
||||
VALUES = 340,
|
||||
VIEW = 341,
|
||||
WHENEVER = 342,
|
||||
WHERE = 343,
|
||||
WITH = 344,
|
||||
WORK = 345
|
||||
};
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype
|
||||
{
|
||||
NAME = 258,
|
||||
STRING = 259,
|
||||
INTNUM = 260,
|
||||
APPROXNUM = 261,
|
||||
SELECT = 262,
|
||||
ALL = 263,
|
||||
DISTINCT = 264,
|
||||
NULLX = 265,
|
||||
USER = 266,
|
||||
INDICATOR = 267,
|
||||
AMMSC = 268,
|
||||
PARAMETER = 269,
|
||||
ANY = 270,
|
||||
SOME = 271,
|
||||
OR = 272,
|
||||
AND = 273,
|
||||
NOT = 274,
|
||||
COMPARISON = 275,
|
||||
UMINUS = 276,
|
||||
AS = 277,
|
||||
ASC = 278,
|
||||
AUTHORIZATION = 279,
|
||||
BETWEEN = 280,
|
||||
BY = 281,
|
||||
CHARACTER = 282,
|
||||
CHECK = 283,
|
||||
CLOSE = 284,
|
||||
COMMIT = 285,
|
||||
CONTINUE = 286,
|
||||
CREATE = 287,
|
||||
CURRENT = 288,
|
||||
CURSOR = 289,
|
||||
IDB_DECIMAL = 290,
|
||||
DECLARE = 291,
|
||||
DEFAULT = 292,
|
||||
DELETE = 293,
|
||||
DESC = 294,
|
||||
IDB_DOUBLE = 295,
|
||||
ESCAPE = 296,
|
||||
EXISTS = 297,
|
||||
FETCH = 298,
|
||||
IDB_FLOAT = 299,
|
||||
FOR = 300,
|
||||
FOREIGN = 301,
|
||||
FOUND = 302,
|
||||
FROM = 303,
|
||||
GOTO = 304,
|
||||
GRANT = 305,
|
||||
IDB_GROUP = 306,
|
||||
HAVING = 307,
|
||||
IN = 308,
|
||||
INSERT = 309,
|
||||
INTEGER = 310,
|
||||
INTO = 311,
|
||||
IS = 312,
|
||||
KEY = 313,
|
||||
LANGUAGE = 314,
|
||||
LIKE = 315,
|
||||
NUMERIC = 316,
|
||||
OF = 317,
|
||||
ON = 318,
|
||||
OPEN = 319,
|
||||
OPTION = 320,
|
||||
ORDER = 321,
|
||||
PRECISION = 322,
|
||||
PRIMARY = 323,
|
||||
PRIVILEGES = 324,
|
||||
PROCEDURE = 325,
|
||||
PUBLIC = 326,
|
||||
REAL = 327,
|
||||
REFERENCES = 328,
|
||||
ROLLBACK = 329,
|
||||
SCHEMA = 330,
|
||||
SET = 331,
|
||||
SMALLINT = 332,
|
||||
SQLCODE = 333,
|
||||
SQLERROR = 334,
|
||||
TABLE = 335,
|
||||
TO = 336,
|
||||
UNION = 337,
|
||||
UNIQUE = 338,
|
||||
UPDATE = 339,
|
||||
VALUES = 340,
|
||||
VIEW = 341,
|
||||
WHENEVER = 342,
|
||||
WHERE = 343,
|
||||
WITH = 344,
|
||||
WORK = 345
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -137,37 +138,37 @@ typedef union YYSTYPE
|
||||
{
|
||||
|
||||
|
||||
int intval;
|
||||
double floatval;
|
||||
char *strval;
|
||||
int subtok;
|
||||
dmlpackage::SqlStatementList *sqlStmtList;
|
||||
dmlpackage::SqlStatement *sqlStmt;
|
||||
dmlpackage::TableName* tblName;
|
||||
dmlpackage::ColumnNameList* colNameList;
|
||||
dmlpackage::ValuesOrQuery* valsOrQuery;
|
||||
dmlpackage::ValuesList* valsList;
|
||||
dmlpackage::QuerySpec* querySpec;
|
||||
dmlpackage::TableNameList* tableNameList;
|
||||
dmlpackage::TableExpression* tableExpression;
|
||||
dmlpackage::WhereClause* whereClause;
|
||||
dmlpackage::SearchCondition* searchCondition;
|
||||
dmlpackage::ExistanceTestPredicate* existPredicate;
|
||||
dmlpackage::AllOrAnyPredicate* allOrAnyPredicate;
|
||||
dmlpackage::InPredicate* inPredicate;
|
||||
dmlpackage::NullTestPredicate* nullTestPredicate;
|
||||
dmlpackage::LikePredicate* likePredicate;
|
||||
dmlpackage::BetweenPredicate* betweenPredicate;
|
||||
dmlpackage::ComparisonPredicate* comparisonPredicate;
|
||||
dmlpackage::Predicate* predicate;
|
||||
dmlpackage::FromClause* fromClause;
|
||||
dmlpackage::SelectFilter* selectFilter;
|
||||
dmlpackage::GroupByClause* groupByClause;
|
||||
dmlpackage::HavingClause* havingClause;
|
||||
dmlpackage::Escape* escape;
|
||||
dmlpackage::AtomList* atomList;
|
||||
dmlpackage::ColumnAssignment* colAssignment;
|
||||
dmlpackage::ColumnAssignmentList* colAssignmentList;
|
||||
int intval;
|
||||
double floatval;
|
||||
char* strval;
|
||||
int subtok;
|
||||
dmlpackage::SqlStatementList* sqlStmtList;
|
||||
dmlpackage::SqlStatement* sqlStmt;
|
||||
dmlpackage::TableName* tblName;
|
||||
dmlpackage::ColumnNameList* colNameList;
|
||||
dmlpackage::ValuesOrQuery* valsOrQuery;
|
||||
dmlpackage::ValuesList* valsList;
|
||||
dmlpackage::QuerySpec* querySpec;
|
||||
dmlpackage::TableNameList* tableNameList;
|
||||
dmlpackage::TableExpression* tableExpression;
|
||||
dmlpackage::WhereClause* whereClause;
|
||||
dmlpackage::SearchCondition* searchCondition;
|
||||
dmlpackage::ExistanceTestPredicate* existPredicate;
|
||||
dmlpackage::AllOrAnyPredicate* allOrAnyPredicate;
|
||||
dmlpackage::InPredicate* inPredicate;
|
||||
dmlpackage::NullTestPredicate* nullTestPredicate;
|
||||
dmlpackage::LikePredicate* likePredicate;
|
||||
dmlpackage::BetweenPredicate* betweenPredicate;
|
||||
dmlpackage::ComparisonPredicate* comparisonPredicate;
|
||||
dmlpackage::Predicate* predicate;
|
||||
dmlpackage::FromClause* fromClause;
|
||||
dmlpackage::SelectFilter* selectFilter;
|
||||
dmlpackage::GroupByClause* groupByClause;
|
||||
dmlpackage::HavingClause* havingClause;
|
||||
dmlpackage::Escape* escape;
|
||||
dmlpackage::AtomList* atomList;
|
||||
dmlpackage::ColumnAssignment* colAssignment;
|
||||
dmlpackage::ColumnAssignmentList* colAssignmentList;
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -40,13 +40,15 @@ DMLColumn::DMLColumn(std::string name, std::string value, bool isFromCol, uint32
|
||||
{
|
||||
fName = name;
|
||||
fData = value;
|
||||
|
||||
if (( strcasecmp(value.c_str(), "NULL") == 0) || (value.length() == 0) )
|
||||
{
|
||||
isNULL = true;
|
||||
isNULL = true;
|
||||
}
|
||||
|
||||
fisNULL = isNULL;
|
||||
fIsFromCol = isFromCol;
|
||||
fFuncScale = funcScale;
|
||||
fIsFromCol = isFromCol;
|
||||
fFuncScale = funcScale;
|
||||
|
||||
}
|
||||
|
||||
@@ -55,8 +57,8 @@ DMLColumn::DMLColumn(std::string name, std::vector<std::string>& valueList, bool
|
||||
fName = name;
|
||||
fColValuesList = valueList;
|
||||
fisNULL = isNULL;
|
||||
fIsFromCol = isFromCol;
|
||||
fFuncScale = funcScale;
|
||||
fIsFromCol = isFromCol;
|
||||
fFuncScale = funcScale;
|
||||
}
|
||||
|
||||
DMLColumn::~DMLColumn()
|
||||
@@ -66,30 +68,32 @@ int DMLColumn::read(messageqcpp::ByteStream& bytestream)
|
||||
{
|
||||
int retval = 1;
|
||||
bytestream >> fName;
|
||||
bytestream >> reinterpret_cast<messageqcpp::ByteStream::byte&>(fisNULL);
|
||||
uint32_t vectorSize;
|
||||
bytestream >> vectorSize;
|
||||
if (vectorSize > 0 )
|
||||
{
|
||||
for ( uint32_t i = 0; i < vectorSize; i++ )
|
||||
{
|
||||
std::string dataStr;
|
||||
bytestream >> dataStr;
|
||||
// if ( !fisNULL && (dataStr.length() == 0 ))
|
||||
// dataStr = (char) 0;
|
||||
bytestream >> reinterpret_cast<messageqcpp::ByteStream::byte&>(fisNULL);
|
||||
uint32_t vectorSize;
|
||||
bytestream >> vectorSize;
|
||||
|
||||
fColValuesList.push_back( dataStr);
|
||||
}
|
||||
if (vectorSize > 0 )
|
||||
{
|
||||
for ( uint32_t i = 0; i < vectorSize; i++ )
|
||||
{
|
||||
std::string dataStr;
|
||||
bytestream >> dataStr;
|
||||
// if ( !fisNULL && (dataStr.length() == 0 ))
|
||||
// dataStr = (char) 0;
|
||||
|
||||
}
|
||||
else
|
||||
bytestream >> fData; //deprecated.
|
||||
fColValuesList.push_back( dataStr);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
bytestream >> fData; //deprecated.
|
||||
|
||||
if ( (fColValuesList.size() < 1) && (fColValuesList.size() > 0) ) //deprecated.
|
||||
fData = fColValuesList[0] ; //deprecated.
|
||||
|
||||
if ( (fColValuesList.size() <1) && (fColValuesList.size() > 0) ) //deprecated.
|
||||
fData =fColValuesList[0] ; //deprecated.
|
||||
//bytestream >> reinterpret_cast<messageqcpp::ByteStream::byte&>(fisNULL);
|
||||
bytestream >> reinterpret_cast<messageqcpp::ByteStream::byte&>(fIsFromCol);
|
||||
bytestream >> (uint32_t&) fFuncScale;
|
||||
bytestream >> reinterpret_cast<messageqcpp::ByteStream::byte&>(fIsFromCol);
|
||||
bytestream >> (uint32_t&) fFuncScale;
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -97,22 +101,24 @@ int DMLColumn::write(messageqcpp::ByteStream& bytestream)
|
||||
{
|
||||
int retval = 1;
|
||||
bytestream << fName;
|
||||
bytestream << static_cast<uint8_t>(fisNULL);
|
||||
uint32_t vectorSize = fColValuesList.size();
|
||||
bytestream << vectorSize;
|
||||
if (vectorSize > 0 )
|
||||
{
|
||||
for ( uint32_t i = 0; i < vectorSize; i++ )
|
||||
{
|
||||
bytestream << fColValuesList[i];
|
||||
}
|
||||
bytestream << static_cast<uint8_t>(fisNULL);
|
||||
uint32_t vectorSize = fColValuesList.size();
|
||||
bytestream << vectorSize;
|
||||
|
||||
if (vectorSize > 0 )
|
||||
{
|
||||
for ( uint32_t i = 0; i < vectorSize; i++ )
|
||||
{
|
||||
bytestream << fColValuesList[i];
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
bytestream << fData; //deprecated.
|
||||
|
||||
}
|
||||
else
|
||||
bytestream << fData; //deprecated.
|
||||
//bytestream << static_cast<uint8_t>(fisNULL);
|
||||
bytestream << static_cast<uint8_t>(fIsFromCol);
|
||||
bytestream <<(uint32_t)fFuncScale;
|
||||
bytestream << static_cast<uint8_t>(fIsFromCol);
|
||||
bytestream << (uint32_t)fFuncScale;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,12 +52,12 @@ public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
|
||||
EXPORT DMLColumn(std::string name, std::string value, bool isFromCol = false, uint32_t funcScale=0, bool isNULL=false);
|
||||
/** @brief new ctor
|
||||
* isNUll is currently not in use. It supposed to indicate whether each value is null or not.
|
||||
EXPORT DMLColumn(std::string name, std::string value, bool isFromCol = false, uint32_t funcScale = 0, bool isNULL = false);
|
||||
/** @brief new ctor
|
||||
* isNUll is currently not in use. It supposed to indicate whether each value is null or not.
|
||||
*/
|
||||
|
||||
EXPORT DMLColumn(std::string name, std::vector<std::string>& valueList, bool isFromCol = false, uint32_t funcScale=0, bool isNULL=false );
|
||||
EXPORT DMLColumn(std::string name, std::vector<std::string>& valueList, bool isFromCol = false, uint32_t funcScale = 0, bool isNULL = false );
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
@@ -77,55 +77,85 @@ public:
|
||||
|
||||
/** @brief get the data for the column
|
||||
*/
|
||||
const std::string get_Data() const { return fData; }
|
||||
const std::string get_Data() const
|
||||
{
|
||||
return fData;
|
||||
}
|
||||
|
||||
|
||||
const std::vector<std::string>& get_DataVector() const { return fColValuesList; }
|
||||
const std::vector<std::string>& get_DataVector() const
|
||||
{
|
||||
return fColValuesList;
|
||||
}
|
||||
|
||||
/** @brief get the data for the column
|
||||
/** @brief get the data for the column
|
||||
*/
|
||||
const bool get_isnull() const
|
||||
{
|
||||
return fisNULL;
|
||||
}
|
||||
/** @brief get the fIsFromCol data for the column
|
||||
*/
|
||||
const bool get_isnull() const { return fisNULL; }
|
||||
/** @brief get the fIsFromCol data for the column
|
||||
const bool get_isFromCol() const
|
||||
{
|
||||
return fIsFromCol;
|
||||
}
|
||||
/** @brief get the fFuncScale data for the column
|
||||
*/
|
||||
const bool get_isFromCol() const { return fIsFromCol; }
|
||||
/** @brief get the fFuncScale data for the column
|
||||
*/
|
||||
const uint32_t get_funcScale() const { return fFuncScale; }
|
||||
const uint32_t get_funcScale() const
|
||||
{
|
||||
return fFuncScale;
|
||||
}
|
||||
/** @brief get the column name
|
||||
*/
|
||||
const std::string get_Name() const { return fName; }
|
||||
const std::string get_Name() const
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
/** @brief set the column name
|
||||
*/
|
||||
EXPORT void set_Name( std::string name)
|
||||
{ boost::algorithm::to_lower(name);
|
||||
fName = name; }
|
||||
{
|
||||
boost::algorithm::to_lower(name);
|
||||
fName = name;
|
||||
}
|
||||
/** @brief set the NULL flag
|
||||
*/
|
||||
void set_isnull( bool isNULL)
|
||||
{ fisNULL = isNULL; }
|
||||
/** @brief set the fIsFromCol flag
|
||||
{
|
||||
fisNULL = isNULL;
|
||||
}
|
||||
/** @brief set the fIsFromCol flag
|
||||
*/
|
||||
void set_isFromCol( bool isFromCol)
|
||||
{ fIsFromCol = isFromCol; }
|
||||
/** @brief set the fFuncScale
|
||||
{
|
||||
fIsFromCol = isFromCol;
|
||||
}
|
||||
/** @brief set the fFuncScale
|
||||
*/
|
||||
void set_funcScale( uint32_t funcScale)
|
||||
{ fFuncScale = funcScale; }
|
||||
void set_funcScale( uint32_t funcScale)
|
||||
{
|
||||
fFuncScale = funcScale;
|
||||
}
|
||||
void set_Data ( std::string data)
|
||||
{ fData = data; }
|
||||
{
|
||||
fData = data;
|
||||
}
|
||||
|
||||
void set_DataVector ( std::vector<std::string>& dataVec)
|
||||
{ fColValuesList = dataVec; }
|
||||
void set_DataVector ( std::vector<std::string>& dataVec)
|
||||
{
|
||||
fColValuesList = dataVec;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
std::string fName;
|
||||
std::string fData;
|
||||
std::vector<std::string> fColValuesList;
|
||||
std::vector<std::string> fColValuesList;
|
||||
bool fisNULL;
|
||||
bool fIsFromCol;
|
||||
uint32_t fFuncScale;
|
||||
bool fIsFromCol;
|
||||
uint32_t fFuncScale;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
|
||||
#include "dmlobject.h"
|
||||
|
||||
namespace dmlpackage {
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
DMLObject::DMLObject()
|
||||
{
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
#define DML_DEBUG 0 // debug flag 0 for off, 1 for on
|
||||
#define DML_DEBUG 0 // debug flag 0 for off, 1 for on
|
||||
|
||||
const std::string nullValue = "nvl";
|
||||
//const size_t maxThreads = 100;
|
||||
//const size_t queueSize = 200;
|
||||
const std::string nullValue = "nvl";
|
||||
//const size_t maxThreads = 100;
|
||||
//const size_t queueSize = 200;
|
||||
} // namespace dmlpackage
|
||||
#endif //DMLPACKAGE_H
|
||||
|
||||
@@ -44,119 +44,128 @@ int dmlparse(void* yyscanner);
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std;
|
||||
|
||||
void scanner_finish(void* yyscanner);
|
||||
void scanner_init(const char *str, void* yyscanner);
|
||||
void grammar_init(dmlpackage::ParseTree* _ptree, bool);
|
||||
valbuf_t get_valbuffer(void);
|
||||
void scanner_finish(void* yyscanner);
|
||||
void scanner_init(const char* str, void* yyscanner);
|
||||
void grammar_init(dmlpackage::ParseTree* _ptree, bool);
|
||||
valbuf_t get_valbuffer(void);
|
||||
|
||||
void free_copybuffer();
|
||||
void set_defaultSchema(std::string schema);
|
||||
void free_copybuffer();
|
||||
void set_defaultSchema(std::string schema);
|
||||
|
||||
DMLParser::DMLParser() :
|
||||
DMLParser::DMLParser() :
|
||||
fStatus(-1), fDebug(false)
|
||||
{}
|
||||
{}
|
||||
|
||||
DMLParser::~DMLParser()
|
||||
{
|
||||
scanner_finish(scanner);
|
||||
dmllex_destroy(scanner);
|
||||
}
|
||||
DMLParser::~DMLParser()
|
||||
{
|
||||
scanner_finish(scanner);
|
||||
dmllex_destroy(scanner);
|
||||
}
|
||||
|
||||
void DMLParser::setDebug(bool debug)
|
||||
{
|
||||
fDebug = true;
|
||||
}
|
||||
void DMLParser::setDebug(bool debug)
|
||||
{
|
||||
fDebug = true;
|
||||
}
|
||||
|
||||
int DMLParser::parse(const char* dmltext)
|
||||
int DMLParser::parse(const char* dmltext)
|
||||
{
|
||||
dmllex_init_extra(&scanData, &scanner);
|
||||
scanner_init(dmltext, scanner);
|
||||
grammar_init(&fParseTree, fDebug);
|
||||
fStatus = dmlparse(scanner);
|
||||
|
||||
if (fStatus == 0)
|
||||
{
|
||||
dmllex_init_extra(&scanData, &scanner);
|
||||
scanner_init(dmltext, scanner);
|
||||
grammar_init(&fParseTree, fDebug);
|
||||
fStatus = dmlparse(scanner);
|
||||
if (fStatus == 0)
|
||||
char* str;
|
||||
valbuf_t valueBuffer = get_valbuffer();
|
||||
|
||||
for (unsigned int i = 0; i < valueBuffer.size(); i++)
|
||||
{
|
||||
char* str;
|
||||
valbuf_t valueBuffer = get_valbuffer();
|
||||
str = valueBuffer[i];
|
||||
|
||||
for(unsigned int i=0; i < valueBuffer.size(); i++)
|
||||
if (str)
|
||||
{
|
||||
str = valueBuffer[i];
|
||||
if(str)
|
||||
{
|
||||
if (i > 0)
|
||||
fParseTree.fSqlText += " ";
|
||||
fParseTree.fSqlText += str;
|
||||
}
|
||||
if (i > 0)
|
||||
fParseTree.fSqlText += " ";
|
||||
|
||||
fParseTree.fSqlText += str;
|
||||
}
|
||||
}
|
||||
free_copybuffer();
|
||||
}
|
||||
|
||||
free_copybuffer();
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
const ParseTree& DMLParser::getParseTree()
|
||||
{
|
||||
if (!good())
|
||||
{
|
||||
throw logic_error("The ParseTree is invalid");
|
||||
}
|
||||
|
||||
return fParseTree;
|
||||
|
||||
}
|
||||
|
||||
bool DMLParser::good()
|
||||
{
|
||||
return fStatus == 0;
|
||||
}
|
||||
|
||||
void DMLParser::setDefaultSchema(std::string schema)
|
||||
{
|
||||
set_defaultSchema(schema);
|
||||
}
|
||||
|
||||
DMLFileParser::DMLFileParser()
|
||||
: DMLParser()
|
||||
{}
|
||||
|
||||
int DMLFileParser::parse(const string& fileName)
|
||||
{
|
||||
fStatus = -1;
|
||||
|
||||
ifstream ifdml;
|
||||
ifdml.open(fileName.c_str());
|
||||
|
||||
if (!ifdml.is_open())
|
||||
{
|
||||
perror(fileName.c_str());
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
const ParseTree& DMLParser::getParseTree()
|
||||
{
|
||||
if (!good())
|
||||
{
|
||||
throw logic_error("The ParseTree is invalid");
|
||||
}
|
||||
return fParseTree;
|
||||
char dmlbuf[1024 * 1024];
|
||||
unsigned length;
|
||||
ifdml.seekg(0, ios::end);
|
||||
length = ifdml.tellg();
|
||||
ifdml.seekg(0, ios::beg);
|
||||
|
||||
if (length > sizeof(dmlbuf) - 1)
|
||||
{
|
||||
throw length_error("DMLFileParser has file size hard limit of 16K.");
|
||||
}
|
||||
|
||||
bool DMLParser::good()
|
||||
{
|
||||
return fStatus == 0;
|
||||
}
|
||||
unsigned rcount;
|
||||
rcount = ifdml.readsome(dmlbuf, sizeof(dmlbuf) - 1);
|
||||
|
||||
void DMLParser::setDefaultSchema(std::string schema)
|
||||
{
|
||||
set_defaultSchema(schema);
|
||||
}
|
||||
if (rcount < 0)
|
||||
return fStatus;
|
||||
|
||||
DMLFileParser::DMLFileParser()
|
||||
:DMLParser()
|
||||
{}
|
||||
dmlbuf[rcount] = 0;
|
||||
|
||||
int DMLFileParser::parse(const string& fileName)
|
||||
{
|
||||
fStatus = -1;
|
||||
// cout << endl << fileName << "(" << rcount << ")" << endl;
|
||||
//cout << "-----------------------------" << endl;
|
||||
//cout << dmlbuf << endl;
|
||||
|
||||
ifstream ifdml;
|
||||
ifdml.open(fileName.c_str());
|
||||
if (!ifdml.is_open())
|
||||
{
|
||||
perror(fileName.c_str());
|
||||
return fStatus;
|
||||
}
|
||||
char dmlbuf[1024*1024];
|
||||
unsigned length;
|
||||
ifdml.seekg(0, ios::end);
|
||||
length = ifdml.tellg();
|
||||
ifdml.seekg(0, ios::beg);
|
||||
if (length > sizeof(dmlbuf) - 1)
|
||||
{
|
||||
throw length_error("DMLFileParser has file size hard limit of 16K.");
|
||||
}
|
||||
return DMLParser::parse(dmlbuf);
|
||||
}
|
||||
|
||||
unsigned rcount;
|
||||
rcount = ifdml.readsome(dmlbuf, sizeof(dmlbuf) - 1);
|
||||
if (rcount < 0)
|
||||
return fStatus;
|
||||
void end_sql(void)
|
||||
{
|
||||
|
||||
dmlbuf[rcount] = 0;
|
||||
|
||||
// cout << endl << fileName << "(" << rcount << ")" << endl;
|
||||
//cout << "-----------------------------" << endl;
|
||||
//cout << dmlbuf << endl;
|
||||
|
||||
return DMLParser::parse(dmlbuf);
|
||||
}
|
||||
|
||||
void end_sql(void)
|
||||
{
|
||||
|
||||
} /* end_sql */
|
||||
} /* end_sql */
|
||||
|
||||
} // dmlpackage
|
||||
|
||||
@@ -31,90 +31,90 @@
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
typedef std::vector<char*> valbuf_t;
|
||||
typedef std::vector<char*> valbuf_t;
|
||||
|
||||
|
||||
typedef SqlStatementList ParseTree;
|
||||
typedef SqlStatementList ParseTree;
|
||||
|
||||
// instance data for the parser
|
||||
typedef std::vector<char*> valbuf_t;
|
||||
// instance data for the parser
|
||||
typedef std::vector<char*> valbuf_t;
|
||||
|
||||
struct scan_data
|
||||
{
|
||||
/* Handles to the buffer that the lexer uses internally */
|
||||
char* scanbuf;
|
||||
void* scanbufhandle; // This is a YY_BUFFER_STATE defined in ddl-scan.cpp
|
||||
valbuf_t valbuf;
|
||||
};
|
||||
struct scan_data
|
||||
{
|
||||
/* Handles to the buffer that the lexer uses internally */
|
||||
char* scanbuf;
|
||||
void* scanbufhandle; // This is a YY_BUFFER_STATE defined in ddl-scan.cpp
|
||||
valbuf_t valbuf;
|
||||
};
|
||||
|
||||
/** @brief BISON parser wrapper class
|
||||
*/
|
||||
class DMLParser
|
||||
{
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
DMLParser();
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
virtual ~DMLParser();
|
||||
|
||||
/** @brief parse the supplied dml statement
|
||||
*
|
||||
* @param dmltext the dml statement to parse
|
||||
*/
|
||||
int parse(const char* dmltext);
|
||||
|
||||
/** @brief get the parse tree
|
||||
*/
|
||||
const ParseTree& getParseTree();
|
||||
|
||||
void setDefaultSchema(std::string schema);
|
||||
|
||||
/** @brief was the parse successful
|
||||
*/
|
||||
bool good();
|
||||
|
||||
/** @brief put the parser in debug mode so as to dump
|
||||
* diagnostic information
|
||||
*/
|
||||
void setDebug(bool debug);
|
||||
|
||||
protected:
|
||||
ParseTree fParseTree;
|
||||
int fStatus;
|
||||
bool fDebug;
|
||||
void* scanner; // yyscan_t * needed for re-entrant flex scanner
|
||||
scan_data scanData;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
/** @brief specialization of the DMLParser class
|
||||
* specifically for reading the dml statement
|
||||
* from a file
|
||||
/** @brief BISON parser wrapper class
|
||||
*/
|
||||
class DMLParser
|
||||
{
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
class DMLFileParser : public DMLParser
|
||||
{
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
DMLFileParser();
|
||||
DMLParser();
|
||||
|
||||
/** @brief parse the dml statement contained in the
|
||||
* supplied file
|
||||
*
|
||||
* @param fileName the fully qualified file name to open
|
||||
* and parse the contents of
|
||||
*/
|
||||
int parse(const std::string& fileName);
|
||||
/** @brief dtor
|
||||
*/
|
||||
virtual ~DMLParser();
|
||||
|
||||
protected:
|
||||
/** @brief parse the supplied dml statement
|
||||
*
|
||||
* @param dmltext the dml statement to parse
|
||||
*/
|
||||
int parse(const char* dmltext);
|
||||
|
||||
private:
|
||||
};
|
||||
/** @brief get the parse tree
|
||||
*/
|
||||
const ParseTree& getParseTree();
|
||||
|
||||
void setDefaultSchema(std::string schema);
|
||||
|
||||
/** @brief was the parse successful
|
||||
*/
|
||||
bool good();
|
||||
|
||||
/** @brief put the parser in debug mode so as to dump
|
||||
* diagnostic information
|
||||
*/
|
||||
void setDebug(bool debug);
|
||||
|
||||
protected:
|
||||
ParseTree fParseTree;
|
||||
int fStatus;
|
||||
bool fDebug;
|
||||
void* scanner; // yyscan_t * needed for re-entrant flex scanner
|
||||
scan_data scanData;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
/** @brief specialization of the DMLParser class
|
||||
* specifically for reading the dml statement
|
||||
* from a file
|
||||
*/
|
||||
class DMLFileParser : public DMLParser
|
||||
{
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
DMLFileParser();
|
||||
|
||||
/** @brief parse the dml statement contained in the
|
||||
* supplied file
|
||||
*
|
||||
* @param fileName the fully qualified file name to open
|
||||
* and parse the contents of
|
||||
*/
|
||||
int parse(const std::string& fileName);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
#endif // DMLPARSER_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -123,7 +123,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout.
|
||||
*/
|
||||
virtual std::ostream& put(std::ostream &os) const = 0;
|
||||
virtual std::ostream& put(std::ostream& os) const = 0;
|
||||
|
||||
/** @brief get the query string associated with the
|
||||
* SqlStatement
|
||||
@@ -225,7 +225,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
virtual std::ostream& put(std::ostream &os) const;
|
||||
virtual std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get a string representation of the query spec
|
||||
*/
|
||||
@@ -233,7 +233,10 @@ public:
|
||||
|
||||
/** @brief get the statement type - DML_INSERT
|
||||
*/
|
||||
inline virtual int getStatementType() const { return DML_INSERT; }
|
||||
inline virtual int getStatementType() const
|
||||
{
|
||||
return DML_INSERT;
|
||||
}
|
||||
|
||||
ValuesOrQuery* fValuesOrQueryPtr;
|
||||
ColumnNameList fColumnList;
|
||||
@@ -267,7 +270,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
virtual std::ostream& put(std::ostream &os) const;
|
||||
virtual std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the
|
||||
* SET assignment_commalist opt_where_clause
|
||||
@@ -277,7 +280,10 @@ public:
|
||||
|
||||
/** @brief get the statement type - DML_UPDATE
|
||||
*/
|
||||
inline virtual int getStatementType() const { return DML_UPDATE; }
|
||||
inline virtual int getStatementType() const
|
||||
{
|
||||
return DML_UPDATE;
|
||||
}
|
||||
|
||||
ColumnAssignmentList* fColAssignmentListPtr;
|
||||
WhereClause* fWhereClausePtr;
|
||||
@@ -309,7 +315,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
virtual std::ostream& put(std::ostream &os) const;
|
||||
virtual std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the WHERE clause
|
||||
*/
|
||||
@@ -317,7 +323,10 @@ public:
|
||||
|
||||
/** @brief get the statement type - DML_DELETE
|
||||
*/
|
||||
inline virtual int getStatementType() const { return DML_DELETE; }
|
||||
inline virtual int getStatementType() const
|
||||
{
|
||||
return DML_DELETE;
|
||||
}
|
||||
|
||||
WhereClause* fWhereClausePtr;
|
||||
};
|
||||
@@ -344,11 +353,14 @@ public:
|
||||
|
||||
/** @brief get the statement type - DML_COMMAND
|
||||
*/
|
||||
inline virtual int getStatementType() const { return DML_COMMAND; }
|
||||
inline virtual int getStatementType() const
|
||||
{
|
||||
return DML_COMMAND;
|
||||
}
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
virtual std::ostream& put(std::ostream &os) const;
|
||||
virtual std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the COMMIT or ROLLBACK string
|
||||
*/
|
||||
@@ -382,7 +394,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
std::ostream& put(std::ostream &os) const;
|
||||
std::ostream& put(std::ostream& os) const;
|
||||
|
||||
std::string fName;
|
||||
std::string fSchema;
|
||||
@@ -399,7 +411,7 @@ class ColumnAssignment
|
||||
public:
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
std::ostream& put(std::ostream &os) const;
|
||||
std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of
|
||||
* the column assignment
|
||||
@@ -409,8 +421,8 @@ public:
|
||||
std::string fColumn;
|
||||
std::string fOperator;
|
||||
std::string fScalarExpression;
|
||||
bool fFromCol;
|
||||
uint32_t fFuncScale;
|
||||
bool fFromCol;
|
||||
uint32_t fFuncScale;
|
||||
};
|
||||
|
||||
/** @brief Stores a value list or a query specification
|
||||
@@ -444,7 +456,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
std::ostream& put(std::ostream &os) const;
|
||||
std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string reperesentation of
|
||||
* the ValuesList or the QuerySpec
|
||||
@@ -480,7 +492,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
std::ostream& put(std::ostream &os) const;
|
||||
std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string represntation of the SELECT statement
|
||||
*/
|
||||
@@ -513,7 +525,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
std::ostream& put(std::ostream &os) const;
|
||||
std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the FROM clause
|
||||
*/
|
||||
@@ -540,7 +552,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
std::ostream& put(std::ostream &os) const;
|
||||
std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the WHERE clause
|
||||
*/
|
||||
@@ -569,7 +581,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
std::ostream& put(std::ostream &os) const;
|
||||
std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the GROUP BY clause
|
||||
*/
|
||||
@@ -597,7 +609,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
std::ostream& put(std::ostream &os) const;
|
||||
std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the HAVING clause
|
||||
*/
|
||||
@@ -618,7 +630,7 @@ class Escape
|
||||
public:
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
std::ostream& put(std::ostream &os) const;
|
||||
std::ostream& put(std::ostream& os) const;
|
||||
|
||||
std::string fEscapeChar;
|
||||
};
|
||||
@@ -653,7 +665,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
virtual std::ostream& put(std::ostream &os) const;
|
||||
virtual std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @param get the string representation of the predicate
|
||||
*/
|
||||
@@ -682,7 +694,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
virtual std::ostream& put(std::ostream &os) const;
|
||||
virtual std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the COMPARISON
|
||||
* predicate
|
||||
@@ -717,7 +729,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
virtual std::ostream& put(std::ostream &os) const;
|
||||
virtual std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the BETWEEN
|
||||
* predicate
|
||||
@@ -752,7 +764,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
virtual std::ostream& put(std::ostream &os) const;
|
||||
virtual std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the LIKE
|
||||
* predicate
|
||||
@@ -786,7 +798,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
virtual std::ostream& put(std::ostream &os) const;
|
||||
virtual std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the NULL test
|
||||
* predicate
|
||||
@@ -820,7 +832,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
virtual std::ostream& put(std::ostream &os) const;
|
||||
virtual std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the IN
|
||||
* predicate
|
||||
@@ -853,7 +865,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
virtual std::ostream& put(std::ostream &os) const;
|
||||
virtual std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the
|
||||
* ALL or ANY predicate
|
||||
@@ -886,7 +898,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
virtual std::ostream& put(std::ostream &os) const;
|
||||
virtual std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the EXISTS
|
||||
* predicate
|
||||
@@ -919,7 +931,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
std::ostream& put(std::ostream &os) const;
|
||||
std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the striong representation of the
|
||||
* search condition
|
||||
@@ -965,7 +977,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
std::ostream& put(std::ostream &os) const;
|
||||
std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the
|
||||
* table expression
|
||||
@@ -1013,7 +1025,7 @@ public:
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
std::ostream& put(std::ostream &os) const;
|
||||
std::ostream& put(std::ostream& os) const;
|
||||
|
||||
/** @brief get the string representation of the
|
||||
* query specification
|
||||
|
||||
@@ -35,13 +35,14 @@ DMLTable::~DMLTable()
|
||||
try
|
||||
{
|
||||
RowList::iterator it = fRows.begin();
|
||||
while(it != fRows.end())
|
||||
|
||||
while (it != fRows.end())
|
||||
{
|
||||
delete *it;
|
||||
it++;
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
cout << "failed to delete the table rows" << endl;
|
||||
}
|
||||
@@ -67,6 +68,7 @@ int DMLTable::read(messageqcpp::ByteStream& bytestream)
|
||||
retval = aRow->read(bytestream);
|
||||
fRows.push_back(aRow);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -82,6 +84,7 @@ int DMLTable::write(messageqcpp::ByteStream& bytestream)
|
||||
//write the row list
|
||||
RowList::iterator rowListPtr;
|
||||
rowListPtr = fRows.begin();
|
||||
|
||||
for (; rowListPtr != fRows.end(); ++rowListPtr)
|
||||
{
|
||||
retval = (*rowListPtr)->write(bytestream);
|
||||
|
||||
@@ -51,23 +51,38 @@ public:
|
||||
|
||||
/** @brief get the schema name
|
||||
*/
|
||||
inline const std::string get_SchemaName() const { return fSchema; }
|
||||
inline const std::string get_SchemaName() const
|
||||
{
|
||||
return fSchema;
|
||||
}
|
||||
|
||||
/** @brief set the schema name
|
||||
*/
|
||||
inline void set_SchemaName( std::string& sName ) { fSchema = sName; }
|
||||
inline void set_SchemaName( std::string& sName )
|
||||
{
|
||||
fSchema = sName;
|
||||
}
|
||||
|
||||
/** @brief get the table name
|
||||
*/
|
||||
inline const std::string get_TableName() const { return fName; }
|
||||
inline const std::string get_TableName() const
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
|
||||
/** @brief set the table name
|
||||
*/
|
||||
inline void set_TableName( std::string& tName ) { fName = tName; }
|
||||
inline void set_TableName( std::string& tName )
|
||||
{
|
||||
fName = tName;
|
||||
}
|
||||
|
||||
/** @brief get the row list
|
||||
*/
|
||||
inline RowList& get_RowList() { return fRows; }
|
||||
inline RowList& get_RowList()
|
||||
{
|
||||
return fRows;
|
||||
}
|
||||
|
||||
/** @brief read a DMLTable from a ByteStream
|
||||
*
|
||||
|
||||
@@ -37,13 +37,14 @@ int main(int argc, char* argv[])
|
||||
|
||||
po::options_description desc ("Allowed options");
|
||||
desc.add_options ()
|
||||
("help", "produce help message")
|
||||
("bisond", /* po::value <string>(),*/ "Have bison produce debug output")
|
||||
("count", po::value <int>(), "number of runs")
|
||||
("sql", po::value < string > (), "sql file");
|
||||
("help", "produce help message")
|
||||
("bisond", /* po::value <string>(),*/ "Have bison produce debug output")
|
||||
("count", po::value <int>(), "number of runs")
|
||||
("sql", po::value < string > (), "sql file");
|
||||
po::variables_map vm;
|
||||
po::store (po::parse_command_line (argc, argv, desc), vm);
|
||||
po::notify (vm);
|
||||
|
||||
if (vm.count ("sql"))
|
||||
sqlfile = vm["sql"].as <string> ();
|
||||
|
||||
@@ -51,14 +52,15 @@ int main(int argc, char* argv[])
|
||||
count = vm["count"].as<int>();
|
||||
|
||||
DMLFileParser parser;
|
||||
|
||||
if (vm.count ("bisond"))
|
||||
parser.setDebug(true);
|
||||
|
||||
parser.parse(sqlfile);
|
||||
|
||||
if(parser.good())
|
||||
if (parser.good())
|
||||
{
|
||||
const ParseTree &ptree = parser.getParseTree();
|
||||
const ParseTree& ptree = parser.getParseTree();
|
||||
|
||||
cout << "Parser succeeded." << endl;
|
||||
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
||||
@@ -66,8 +68,10 @@ int main(int argc, char* argv[])
|
||||
cout << ptree;
|
||||
|
||||
SqlStatement* statementPtr = ptree[0];
|
||||
|
||||
if (statementPtr)
|
||||
cout << statementPtr->getQueryString();
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -41,7 +41,7 @@ InsertDMLPackage::InsertDMLPackage()
|
||||
|
||||
InsertDMLPackage::InsertDMLPackage( std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID )
|
||||
:CalpontDMLPackage( schemaName, tableName, dmlStatement, sessionID )
|
||||
: CalpontDMLPackage( schemaName, tableName, dmlStatement, sessionID )
|
||||
{}
|
||||
|
||||
InsertDMLPackage::~InsertDMLPackage()
|
||||
@@ -64,10 +64,12 @@ int InsertDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||
bytestream << fSchemaName;
|
||||
bytestream << (uint8_t)fLogging;
|
||||
bytestream << (uint8_t)fLogending;
|
||||
|
||||
if (fTable != 0)
|
||||
{
|
||||
retval = fTable->write(bytestream);
|
||||
}
|
||||
|
||||
bytestream << fTableOid;
|
||||
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsInsertSelect);
|
||||
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsBatchInsert);
|
||||
@@ -108,7 +110,7 @@ int InsertDMLPackage::read(messageqcpp::ByteStream& bytestream)
|
||||
int InsertDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows)
|
||||
{
|
||||
#ifdef DML_PACKAGE_DEBUG
|
||||
// cout << "The data buffer received: " << buffer << endl;
|
||||
// cout << "The data buffer received: " << buffer << endl;
|
||||
#endif
|
||||
int retval = 1;
|
||||
|
||||
@@ -118,6 +120,7 @@ int InsertDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||
boost::char_separator<char> sep(",");
|
||||
tokenizer tokens(buffer, sep);
|
||||
|
||||
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
||||
{
|
||||
dataList.push_back(StripLeadingWhitespace(*tok_iter));
|
||||
@@ -125,12 +128,14 @@ int InsertDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
for (int i=0; i < rows; i++)
|
||||
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
//get a new row
|
||||
Row *aRowPtr = new Row();
|
||||
Row* aRowPtr = new Row();
|
||||
std::string colName;
|
||||
std::string colValue;
|
||||
|
||||
for (int j = 0; j < columns; j++)
|
||||
{
|
||||
//Build a column list
|
||||
@@ -144,6 +149,7 @@ int InsertDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
DMLColumn* aColumn = new DMLColumn(colName, colValue, false);
|
||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||
}
|
||||
|
||||
//build a row list for a table
|
||||
fTable->get_RowList().push_back(aRowPtr);
|
||||
}
|
||||
@@ -156,19 +162,21 @@ int InsertDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValues
|
||||
int retval = 1;
|
||||
|
||||
initializeTable();
|
||||
Row *aRowPtr = new Row();
|
||||
Row* aRowPtr = new Row();
|
||||
std::string colName;
|
||||
std::vector<std::string> colValList;
|
||||
|
||||
for (int j = 0; j < columns; j++)
|
||||
{
|
||||
//Build a column list
|
||||
colName = colNameList[j];
|
||||
//Build a column list
|
||||
colName = colNameList[j];
|
||||
|
||||
colValList = tableValuesMap[j];
|
||||
colValList = tableValuesMap[j];
|
||||
|
||||
DMLColumn* aColumn = new DMLColumn(colName, colValList, false, 0, nullValues[j]);
|
||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||
DMLColumn* aColumn = new DMLColumn(colName, colValList, false, 0, nullValues[j]);
|
||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||
}
|
||||
|
||||
//build a row list for a table
|
||||
fTable->get_RowList().push_back(aRowPtr);
|
||||
aRowPtr = NULL;
|
||||
@@ -188,6 +196,7 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
|
||||
initializeTable();
|
||||
bool isNULL = false;
|
||||
|
||||
// only if we don't have a select statement
|
||||
if (0 == insertStmt.fValuesOrQueryPtr->fQuerySpecPtr)
|
||||
{
|
||||
@@ -198,16 +207,20 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
{
|
||||
|
||||
ValuesList valuesList = insertStmt.fValuesOrQueryPtr->fValuesList;
|
||||
|
||||
if (columnNameList.size() != valuesList.size())
|
||||
{
|
||||
throw logic_error("Column names and values count mismatch!");
|
||||
}
|
||||
|
||||
Row* aRow = new Row();
|
||||
|
||||
for (unsigned int i = 0; i < columnNameList.size(); i++)
|
||||
{
|
||||
DMLColumn *aColumn = new DMLColumn(columnNameList[i],valuesList[i], isNULL);
|
||||
DMLColumn* aColumn = new DMLColumn(columnNameList[i], valuesList[i], isNULL);
|
||||
(aRow->get_ColumnList()).push_back(aColumn);
|
||||
}
|
||||
|
||||
fTable->get_RowList().push_back(aRow);
|
||||
|
||||
}
|
||||
@@ -218,9 +231,11 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
Row* aRow = new Row();
|
||||
std::string colName = "";
|
||||
std::string colValue;
|
||||
|
||||
while (iter != valuesList.end())
|
||||
{
|
||||
colValue = *iter;
|
||||
|
||||
if ( strcasecmp(colValue.c_str(), "NULL") == 0)
|
||||
{
|
||||
isNULL = true;
|
||||
@@ -229,11 +244,13 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
{
|
||||
isNULL = false;
|
||||
}
|
||||
DMLColumn *aColumn = new DMLColumn(colName,colValue, isNULL);
|
||||
|
||||
DMLColumn* aColumn = new DMLColumn(colName, colValue, isNULL);
|
||||
(aRow->get_ColumnList()).push_back(aColumn);
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
fTable->get_RowList().push_back(aRow);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
* @param sessionID the session id
|
||||
*/
|
||||
EXPORT InsertDMLPackage(std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID );
|
||||
std::string dmlStatement, int sessionID );
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
@@ -81,12 +81,12 @@ public:
|
||||
*/
|
||||
EXPORT int buildFromBuffer(std::string& buffer, int columns, int rows);
|
||||
|
||||
/** @brief build a InsertDMLPackage from MySQL buffer
|
||||
/** @brief build a InsertDMLPackage from MySQL buffer
|
||||
*
|
||||
* @param tableValuesMap the value list for each column in the table
|
||||
* @param colNameList the column name for each column
|
||||
* @param columns number of columns in the table
|
||||
* @param rows number of rows to be touched
|
||||
* @param tableValuesMap the value list for each column in the table
|
||||
* @param colNameList the column name for each column
|
||||
* @param columns number of columns in the table
|
||||
* @param rows number of rows to be touched
|
||||
*/
|
||||
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class MySQLDMLStatement : public VendorDMLStatement
|
||||
{
|
||||
|
||||
public:
|
||||
MySQLDMLStatement() : VendorDMLStatement("", 0) {}
|
||||
MySQLDMLStatement() : VendorDMLStatement("", 0) {}
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class OracleDMLStatement : public VendorDMLStatement
|
||||
{
|
||||
|
||||
public:
|
||||
OracleDMLStatement() : VendorDMLStatement("", 0) {}
|
||||
OracleDMLStatement() : VendorDMLStatement("", 0) {}
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace dmlpackage
|
||||
{
|
||||
|
||||
Row::Row()
|
||||
:fRowID(std::numeric_limits<WriteEngine::RID>::max())
|
||||
: fRowID(std::numeric_limits<WriteEngine::RID>::max())
|
||||
{}
|
||||
|
||||
Row::~Row()
|
||||
@@ -39,17 +39,19 @@ Row::~Row()
|
||||
{
|
||||
delete fColumnList[i];
|
||||
}
|
||||
|
||||
fColumnList.clear();
|
||||
}
|
||||
|
||||
Row::Row(const Row& row)
|
||||
{
|
||||
for(unsigned int i = 0; i < row.fColumnList.size(); i++)
|
||||
for (unsigned int i = 0; i < row.fColumnList.size(); i++)
|
||||
{
|
||||
const DMLColumn* aColumn = row.get_ColumnAt(i);
|
||||
DMLColumn* newColumn = new DMLColumn(aColumn->get_Name(), aColumn->get_Data());
|
||||
fColumnList.push_back(newColumn);
|
||||
const DMLColumn* aColumn = row.get_ColumnAt(i);
|
||||
DMLColumn* newColumn = new DMLColumn(aColumn->get_Name(), aColumn->get_Data());
|
||||
fColumnList.push_back(newColumn);
|
||||
}
|
||||
|
||||
fRowID = row.fRowID;
|
||||
}
|
||||
int Row::read(messageqcpp::ByteStream& bytestream)
|
||||
@@ -60,12 +62,14 @@ int Row::read(messageqcpp::ByteStream& bytestream)
|
||||
set_RowID(rowID);
|
||||
messageqcpp::ByteStream::quadbyte col_count;
|
||||
bytestream >> col_count;
|
||||
|
||||
for (unsigned int i = 0; i < col_count; i++)
|
||||
{
|
||||
DMLColumn* aColumn = new DMLColumn();
|
||||
retval = aColumn->read(bytestream);
|
||||
fColumnList.push_back(aColumn);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -79,6 +83,7 @@ int Row::write(messageqcpp::ByteStream& bytestream)
|
||||
colListPtr = fColumnList.begin();
|
||||
messageqcpp::ByteStream::quadbyte col_count = fColumnList.size();
|
||||
bytestream << col_count;
|
||||
|
||||
for (; colListPtr != fColumnList.end(); ++colListPtr)
|
||||
{
|
||||
retval = (*colListPtr)->write(bytestream);
|
||||
|
||||
@@ -71,19 +71,31 @@ public:
|
||||
|
||||
/** @brief get the list of columns in the row
|
||||
*/
|
||||
inline ColumnList& get_ColumnList() { return fColumnList; }
|
||||
inline ColumnList& get_ColumnList()
|
||||
{
|
||||
return fColumnList;
|
||||
}
|
||||
|
||||
/** @brief get the row id
|
||||
*/
|
||||
inline WriteEngine::RID get_RowID() const { return fRowID; }
|
||||
inline WriteEngine::RID get_RowID() const
|
||||
{
|
||||
return fRowID;
|
||||
}
|
||||
|
||||
/** @brief set the row id
|
||||
*/
|
||||
inline void set_RowID(WriteEngine::RID rowId) { fRowID = rowId; }
|
||||
inline void set_RowID(WriteEngine::RID rowId)
|
||||
{
|
||||
fRowID = rowId;
|
||||
}
|
||||
|
||||
/** @brief get the number of columns
|
||||
*/
|
||||
inline unsigned int get_NumberOfColumns() const { return static_cast<unsigned int>(fColumnList.size()); }
|
||||
inline unsigned int get_NumberOfColumns() const
|
||||
{
|
||||
return static_cast<unsigned int>(fColumnList.size());
|
||||
}
|
||||
|
||||
/** @brief get the column at the specified index
|
||||
*
|
||||
|
||||
@@ -46,9 +46,10 @@ bool parse_file(char* fileName)
|
||||
DMLFileParser parser;
|
||||
parser.parse(fileName);
|
||||
bool good = parser.good();
|
||||
|
||||
if (good)
|
||||
{
|
||||
const ParseTree &ptree = parser.getParseTree();
|
||||
const ParseTree& ptree = parser.getParseTree();
|
||||
|
||||
cout << "Parser succeeded." << endl;
|
||||
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
||||
@@ -56,8 +57,10 @@ bool parse_file(char* fileName)
|
||||
cout << ptree;
|
||||
|
||||
SqlStatement* statementPtr = ptree[0];
|
||||
|
||||
if (statementPtr)
|
||||
cout << statementPtr->getQueryString();
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
@@ -87,39 +90,69 @@ public:
|
||||
|
||||
void tearDown() {}
|
||||
|
||||
void test_i01() { CPPUNIT_ASSERT(parse_file("sql/i01.sql")); }
|
||||
void test_i01()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/i01.sql"));
|
||||
}
|
||||
|
||||
void test_i02() { CPPUNIT_ASSERT(parse_file("sql/i02.sql")); }
|
||||
void test_i02()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/i02.sql"));
|
||||
}
|
||||
|
||||
void test_i03() { CPPUNIT_ASSERT(parse_file("sql/i03.sql")); }
|
||||
void test_i03()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/i03.sql"));
|
||||
}
|
||||
|
||||
void test_i04() { CPPUNIT_ASSERT(parse_file("sql/i04.sql")); }
|
||||
void test_i04()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/i04.sql"));
|
||||
}
|
||||
|
||||
void test_u01() { CPPUNIT_ASSERT(parse_file("sql/u01.sql")); }
|
||||
void test_u01()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/u01.sql"));
|
||||
}
|
||||
|
||||
void test_u02() { CPPUNIT_ASSERT(parse_file("sql/u02.sql")); }
|
||||
void test_u02()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/u02.sql"));
|
||||
}
|
||||
|
||||
void test_d01() { CPPUNIT_ASSERT(parse_file("sql/d01.sql")); }
|
||||
void test_d01()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/d01.sql"));
|
||||
}
|
||||
|
||||
void test_d02() { CPPUNIT_ASSERT(parse_file("sql/d02.sql")); }
|
||||
void test_d02()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/d02.sql"));
|
||||
}
|
||||
|
||||
void test_d03() { CPPUNIT_ASSERT(parse_file("sql/d03.sql")); }
|
||||
void test_d03()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/d03.sql"));
|
||||
}
|
||||
|
||||
void test_d04() { CPPUNIT_ASSERT(parse_file("sql/d04.sql")); }
|
||||
void test_d04()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/d04.sql"));
|
||||
}
|
||||
};
|
||||
|
||||
class DMLTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE( DMLTest );
|
||||
// CPPUNIT_TEST( test_direct_insert );
|
||||
// CPPUNIT_TEST( test_query_insert );
|
||||
// CPPUNIT_TEST( test_direct_insert );
|
||||
// CPPUNIT_TEST( test_query_insert );
|
||||
CPPUNIT_TEST( test_direct_update );
|
||||
// CPPUNIT_TEST( test_query_update );
|
||||
// CPPUNIT_TEST( test_delete_all );
|
||||
// CPPUNIT_TEST( test_delete_query );
|
||||
// CPPUNIT_TEST( test_commit );
|
||||
// CPPUNIT_TEST( test_rollback );
|
||||
// CPPUNIT_TEST( test_query_update );
|
||||
// CPPUNIT_TEST( test_delete_all );
|
||||
// CPPUNIT_TEST( test_delete_query );
|
||||
// CPPUNIT_TEST( test_commit );
|
||||
// CPPUNIT_TEST( test_rollback );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
@@ -154,6 +187,7 @@ public:
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||
|
||||
if ( pDMLPackage->HasFilter() )
|
||||
{
|
||||
cout << "This INSERT statement has a filter:" << endl;
|
||||
@@ -180,7 +214,7 @@ public:
|
||||
|
||||
CPPUNIT_ASSERT( DML_INSERT == package_type );
|
||||
|
||||
InsertDMLPackage *pObject = new InsertDMLPackage();
|
||||
InsertDMLPackage* pObject = new InsertDMLPackage();
|
||||
|
||||
pObject->read( bs );
|
||||
|
||||
@@ -196,7 +230,7 @@ public:
|
||||
|
||||
cout << dmlStatement << endl;
|
||||
|
||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
|
||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||
@@ -212,15 +246,17 @@ public:
|
||||
|
||||
cout << dmlStatement << endl;
|
||||
|
||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
|
||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||
|
||||
if (pDMLPackage->HasFilter())
|
||||
{
|
||||
cout << "This DELETE statement has a filter:" << endl;
|
||||
cout << pDMLPackage->get_QueryString() << endl;
|
||||
}
|
||||
|
||||
write_DML_object(bytestream, pDMLPackage);
|
||||
delete pDMLPackage;
|
||||
read_delete_object(bytestream);
|
||||
@@ -235,7 +271,7 @@ public:
|
||||
|
||||
CPPUNIT_ASSERT( DML_DELETE == package_type );
|
||||
|
||||
DeleteDMLPackage *pObject = new DeleteDMLPackage();
|
||||
DeleteDMLPackage* pObject = new DeleteDMLPackage();
|
||||
|
||||
pObject->read( bs );
|
||||
|
||||
@@ -249,7 +285,7 @@ public:
|
||||
std::string dmlStatement = "UPDATE tpch.part SET p_partno = 1, p_name = 'joe' where p_partno=2;";
|
||||
cout << dmlStatement << endl;
|
||||
|
||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||
write_DML_object(bytestream, pDMLPackage);
|
||||
@@ -267,6 +303,7 @@ public:
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||
|
||||
if (pDMLPackage->HasFilter())
|
||||
{
|
||||
cout << "This UPDATE statement has a filter:" << endl;
|
||||
@@ -286,7 +323,7 @@ public:
|
||||
|
||||
CPPUNIT_ASSERT( DML_UPDATE == package_type );
|
||||
|
||||
UpdateDMLPackage *pObject = new UpdateDMLPackage();
|
||||
UpdateDMLPackage* pObject = new UpdateDMLPackage();
|
||||
|
||||
pObject->read( bs );
|
||||
|
||||
@@ -300,7 +337,7 @@ public:
|
||||
std::string dmlStatement = "COMMIT;";
|
||||
cout << dmlStatement << endl;
|
||||
|
||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||
write_DML_object(bytestream, pDMLPackage);
|
||||
@@ -315,7 +352,7 @@ public:
|
||||
std::string dmlStatement = "ROLLBACK;";
|
||||
cout << dmlStatement << endl;
|
||||
|
||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||
write_DML_object(bytestream, pDMLPackage);
|
||||
@@ -331,7 +368,7 @@ public:
|
||||
|
||||
CPPUNIT_ASSERT( DML_COMMAND == package_type );
|
||||
|
||||
CommandDMLPackage *pObject = new CommandDMLPackage();
|
||||
CommandDMLPackage* pObject = new CommandDMLPackage();
|
||||
|
||||
pObject->read( bs );
|
||||
|
||||
@@ -346,10 +383,10 @@ CPPUNIT_TEST_SUITE_REGISTRATION( DMLTest );
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
|
||||
int main( int argc, char **argv)
|
||||
int main( int argc, char** argv)
|
||||
{
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
runner.addTest( registry.makeTest() );
|
||||
bool wasSuccessful = runner.run( "", false );
|
||||
return (wasSuccessful ? 0 : 1);
|
||||
|
||||
@@ -38,7 +38,7 @@ UpdateDMLPackage::UpdateDMLPackage()
|
||||
|
||||
UpdateDMLPackage::UpdateDMLPackage(std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID)
|
||||
:CalpontDMLPackage( schemaName, tableName, dmlStatement, sessionID)
|
||||
: CalpontDMLPackage( schemaName, tableName, dmlStatement, sessionID)
|
||||
{}
|
||||
|
||||
UpdateDMLPackage::~UpdateDMLPackage()
|
||||
@@ -52,12 +52,12 @@ int UpdateDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||
|
||||
messageqcpp::ByteStream::quadbyte session_id = fSessionID;
|
||||
bytestream << session_id;
|
||||
/*
|
||||
if(fPlan != 0)
|
||||
fHasFilter = true;
|
||||
else
|
||||
fHasFilter = false;
|
||||
*/
|
||||
/*
|
||||
if(fPlan != 0)
|
||||
fHasFilter = true;
|
||||
else
|
||||
fHasFilter = false;
|
||||
*/
|
||||
messageqcpp::ByteStream::quadbyte hasFilter = fHasFilter;
|
||||
bytestream << hasFilter;
|
||||
|
||||
@@ -67,11 +67,13 @@ int UpdateDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||
bytestream << fSQLStatement;
|
||||
bytestream << fSchemaName;
|
||||
bytestream << (uint8_t)fIsFromCol;
|
||||
|
||||
if (fTable != 0)
|
||||
{
|
||||
retval = fTable->write(bytestream);
|
||||
}
|
||||
if(fHasFilter)
|
||||
|
||||
if (fHasFilter)
|
||||
{
|
||||
bytestream += *(fPlan.get());
|
||||
}
|
||||
@@ -105,7 +107,8 @@ int UpdateDMLPackage::read(messageqcpp::ByteStream& bytestream)
|
||||
fIsFromCol = (isFromCol != 0);
|
||||
fTable = new DMLTable();
|
||||
retval = fTable->read(bytestream);
|
||||
if(fHasFilter)
|
||||
|
||||
if (fHasFilter)
|
||||
{
|
||||
fPlan.reset(new messageqcpp::ByteStream(bytestream));
|
||||
}
|
||||
@@ -130,6 +133,7 @@ int UpdateDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
// Push one row always and let the filter happen on the proc side.
|
||||
Row* rowPtr = new Row();
|
||||
ColumnAssignmentList::const_iterator iter = updateStmt.fColAssignmentListPtr->begin();
|
||||
|
||||
while (iter != updateStmt.fColAssignmentListPtr->end())
|
||||
{
|
||||
ColumnAssignment* colaPtr = *iter;
|
||||
@@ -138,7 +142,9 @@ int UpdateDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
fTable->get_RowList().push_back(rowPtr);
|
||||
|
||||
if (0 != updateStmt.fWhereClausePtr)
|
||||
{
|
||||
// We need to filter the rows...get row ids
|
||||
@@ -166,6 +172,7 @@ int UpdateDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||
boost::char_separator<char> sep(":,");
|
||||
tokenizer tokens(buffer, sep);
|
||||
|
||||
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
||||
{
|
||||
dataList.push_back(StripLeadingWhitespace(*tok_iter));
|
||||
@@ -173,10 +180,11 @@ int UpdateDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
for (int i=0; i < rows; i++)
|
||||
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
//get a new row
|
||||
Row *aRowPtr = new Row();
|
||||
Row* aRowPtr = new Row();
|
||||
std::string colName;
|
||||
std::string colValue;
|
||||
//get row ID from the buffer
|
||||
@@ -200,6 +208,7 @@ int UpdateDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
DMLColumn* aColumn = new DMLColumn(colName, colValue);
|
||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||
}
|
||||
|
||||
//build a row list for a table
|
||||
fTable->get_RowList().push_back(aRowPtr);
|
||||
}
|
||||
@@ -211,19 +220,21 @@ int UpdateDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValues
|
||||
int retval = 1;
|
||||
|
||||
initializeTable();
|
||||
Row *aRowPtr = new Row();
|
||||
Row* aRowPtr = new Row();
|
||||
std::string colName;
|
||||
std::vector<std::string> colValList;
|
||||
|
||||
for (int j = 0; j < columns; j++)
|
||||
{
|
||||
//Build a column list
|
||||
colName = colNameList[j];
|
||||
//Build a column list
|
||||
colName = colNameList[j];
|
||||
|
||||
colValList = tableValuesMap[j];
|
||||
colValList = tableValuesMap[j];
|
||||
|
||||
DMLColumn* aColumn = new DMLColumn(colName, colValList, false, 0, nullValues[j]);
|
||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||
DMLColumn* aColumn = new DMLColumn(colName, colValList, false, 0, nullValues[j]);
|
||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||
}
|
||||
|
||||
//build a row list for a table
|
||||
fTable->get_RowList().push_back(aRowPtr);
|
||||
return retval;
|
||||
@@ -242,6 +253,7 @@ void UpdateDMLPackage::buildUpdateFromMysqlBuffer(UpdateSqlStatement& updateStm
|
||||
// Push one row always and let the filter happen on the proc side.
|
||||
Row* rowPtr = new Row();
|
||||
ColumnAssignmentList::const_iterator iter = updateStmt.fColAssignmentListPtr->begin();
|
||||
|
||||
while (iter != updateStmt.fColAssignmentListPtr->end())
|
||||
{
|
||||
ColumnAssignment* colaPtr = *iter;
|
||||
@@ -250,6 +262,7 @@ void UpdateDMLPackage::buildUpdateFromMysqlBuffer(UpdateSqlStatement& updateStm
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
fTable->get_RowList().push_back(rowPtr);
|
||||
}
|
||||
} // namespace dmlpackage
|
||||
|
||||
@@ -36,71 +36,71 @@
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
/** @brief concrete implementation of a CalpontDMLPackage
|
||||
* Specifically for representing UPDATE DML Statements
|
||||
/** @brief concrete implementation of a CalpontDMLPackage
|
||||
* Specifically for representing UPDATE DML Statements
|
||||
*/
|
||||
class UpdateDMLPackage : public CalpontDMLPackage
|
||||
{
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
class UpdateDMLPackage : public CalpontDMLPackage
|
||||
{
|
||||
EXPORT UpdateDMLPackage();
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
EXPORT UpdateDMLPackage();
|
||||
/** @brief ctor
|
||||
*
|
||||
* @param schemaName the schema of the table being operated on
|
||||
* @param tableName the name of the table being operated on
|
||||
* @param dmlStatement the dml statement
|
||||
* @param sessionID the session ID
|
||||
*/
|
||||
EXPORT UpdateDMLPackage( std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID );
|
||||
|
||||
/** @brief ctor
|
||||
*
|
||||
* @param schemaName the schema of the table being operated on
|
||||
* @param tableName the name of the table being operated on
|
||||
* @param dmlStatement the dml statement
|
||||
* @param sessionID the session ID
|
||||
*/
|
||||
EXPORT UpdateDMLPackage( std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID );
|
||||
/** @brief dtor
|
||||
*/
|
||||
EXPORT virtual ~UpdateDMLPackage();
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
EXPORT virtual ~UpdateDMLPackage();
|
||||
/** @brief write a UpdateDMLPackage to a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to write to
|
||||
*/
|
||||
EXPORT int write(messageqcpp::ByteStream& bytestream);
|
||||
|
||||
/** @brief write a UpdateDMLPackage to a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to write to
|
||||
*/
|
||||
EXPORT int write(messageqcpp::ByteStream& bytestream);
|
||||
/** @brief read a UpdateDMLPackage from a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to read from
|
||||
*/
|
||||
EXPORT int read(messageqcpp::ByteStream& bytestream);
|
||||
|
||||
/** @brief read a UpdateDMLPackage from a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to read from
|
||||
*/
|
||||
EXPORT int read(messageqcpp::ByteStream& bytestream);
|
||||
/** @brief build a UpdateDMLPackage from a string buffer
|
||||
*
|
||||
* @param buffer
|
||||
* @param columns the number of columns in the buffer
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
EXPORT int buildFromBuffer(std::string& buffer, int columns, int rows);
|
||||
|
||||
/** @brief build a UpdateDMLPackage from a string buffer
|
||||
*
|
||||
* @param buffer
|
||||
* @param columns the number of columns in the buffer
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
EXPORT int buildFromBuffer(std::string& buffer, int columns, int rows);
|
||||
/** @brief build a UpdateDMLPackage from a parsed UpdateSqlStatement
|
||||
*
|
||||
* @param sqlStatement the parsed UpdateSqlStatement
|
||||
*/
|
||||
EXPORT int buildFromSqlStatement(SqlStatement& sqlStatement);
|
||||
|
||||
/** @brief build a UpdateDMLPackage from a parsed UpdateSqlStatement
|
||||
*
|
||||
* @param sqlStatement the parsed UpdateSqlStatement
|
||||
*/
|
||||
EXPORT int buildFromSqlStatement(SqlStatement& sqlStatement);
|
||||
|
||||
/** @brief build a InsertDMLPackage from MySQL buffer
|
||||
*
|
||||
* @param colNameList, tableValuesMap
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues);
|
||||
void buildUpdateFromMysqlBuffer(UpdateSqlStatement& updateStmt );
|
||||
/** @brief build a InsertDMLPackage from MySQL buffer
|
||||
*
|
||||
* @param colNameList, tableValuesMap
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues);
|
||||
void buildUpdateFromMysqlBuffer(UpdateSqlStatement& updateStmt );
|
||||
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
@@ -30,30 +30,30 @@ using namespace std;
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int sessionID)
|
||||
:fDMLStatement(dmlstatement),fSessionID(sessionID), fLogging(true),fLogending(true)
|
||||
{}
|
||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int sessionID)
|
||||
: fDMLStatement(dmlstatement), fSessionID(sessionID), fLogging(true), fLogending(true)
|
||||
{}
|
||||
|
||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int stmttype, int sessionID)
|
||||
:fDMLStatement(dmlstatement), fDMLStatementType(stmttype), fSessionID(sessionID),fLogging(true),fLogending(true)
|
||||
{}
|
||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int stmttype, int sessionID)
|
||||
: fDMLStatement(dmlstatement), fDMLStatementType(stmttype), fSessionID(sessionID), fLogging(true), fLogending(true)
|
||||
{}
|
||||
|
||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int stmttype,
|
||||
std::string tName, std::string schema,
|
||||
int rows, int columns, std::string buf,
|
||||
int sessionID)
|
||||
:fDMLStatement(dmlstatement), fDMLStatementType(stmttype),
|
||||
fTableName(tName), fSchema(schema), fRows(rows), fColumns(columns),
|
||||
fDataBuffer(buf), fSessionID(sessionID), fLogging(true),fLogending(true)
|
||||
{}
|
||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int stmttype,
|
||||
std::string tName, std::string schema,
|
||||
int rows, int columns, std::string buf,
|
||||
int sessionID)
|
||||
: fDMLStatement(dmlstatement), fDMLStatementType(stmttype),
|
||||
fTableName(tName), fSchema(schema), fRows(rows), fColumns(columns),
|
||||
fDataBuffer(buf), fSessionID(sessionID), fLogging(true), fLogending(true)
|
||||
{}
|
||||
|
||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int stmttype, std::string tName, std::string schema, int rows, int columns,
|
||||
ColNameList& colNameList, TableValuesMap& tableValuesMap, NullValuesBitset& nullValues, int sessionID)
|
||||
:fDMLStatement(dmlstatement), fDMLStatementType(stmttype),
|
||||
fTableName(tName), fSchema(schema), fRows(rows), fColumns(columns),
|
||||
fColNameList(colNameList), fTableValuesMap(tableValuesMap), fNullValues(nullValues), fSessionID(sessionID), fLogging(true),fLogending(true)
|
||||
{}
|
||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int stmttype, std::string tName, std::string schema, int rows, int columns,
|
||||
ColNameList& colNameList, TableValuesMap& tableValuesMap, NullValuesBitset& nullValues, int sessionID)
|
||||
: fDMLStatement(dmlstatement), fDMLStatementType(stmttype),
|
||||
fTableName(tName), fSchema(schema), fRows(rows), fColumns(columns),
|
||||
fColNameList(colNameList), fTableValuesMap(tableValuesMap), fNullValues(nullValues), fSessionID(sessionID), fLogging(true), fLogending(true)
|
||||
{}
|
||||
|
||||
VendorDMLStatement::~VendorDMLStatement()
|
||||
{}
|
||||
VendorDMLStatement::~VendorDMLStatement()
|
||||
{}
|
||||
}
|
||||
|
||||
@@ -36,152 +36,215 @@
|
||||
#endif
|
||||
namespace dmlpackage
|
||||
{
|
||||
typedef std::vector<std::string> ColValuesList;
|
||||
typedef std::vector<std::string> ColNameList;
|
||||
typedef std::map<uint32_t, ColValuesList> TableValuesMap;
|
||||
typedef std::bitset<4096> NullValuesBitset;
|
||||
typedef std::vector<std::string> ColValuesList;
|
||||
typedef std::vector<std::string> ColNameList;
|
||||
typedef std::map<uint32_t, ColValuesList> TableValuesMap;
|
||||
typedef std::bitset<4096> NullValuesBitset;
|
||||
|
||||
/** @brief describes the general interface
|
||||
* and implementation of a Vendor DML Statement
|
||||
/** @brief describes the general interface
|
||||
* and implementation of a Vendor DML Statement
|
||||
*/
|
||||
class VendorDMLStatement
|
||||
{
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
class VendorDMLStatement
|
||||
EXPORT VendorDMLStatement(std::string dmlstatement, int sessionID);
|
||||
|
||||
/** @brief ctor
|
||||
*/
|
||||
EXPORT VendorDMLStatement(std::string dmlstatement, int stmttype, int sessionID);
|
||||
|
||||
/** @brief old ctor!
|
||||
*/
|
||||
EXPORT VendorDMLStatement(std::string dmlstatement, int stmttype, std::string tName,
|
||||
std::string schema, int rows, int columns, std::string buf,
|
||||
int sessionID);
|
||||
|
||||
/** @brief ctor for mysql
|
||||
*/
|
||||
EXPORT VendorDMLStatement(std::string dmlstatement, int stmttype, std::string tName, std::string schema, int rows, int columns,
|
||||
ColNameList& colNameList, TableValuesMap& tableValuesMap, NullValuesBitset& nullValues, int sessionID);
|
||||
|
||||
/** @brief destructor
|
||||
*/
|
||||
EXPORT ~VendorDMLStatement();
|
||||
|
||||
/** @brief Get the table name
|
||||
*/
|
||||
inline std::string get_TableName() const
|
||||
{
|
||||
return fTableName;
|
||||
}
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
EXPORT VendorDMLStatement(std::string dmlstatement, int sessionID);
|
||||
/** @brief Set the table name
|
||||
*/
|
||||
inline void set_TableName( std::string value )
|
||||
{
|
||||
fTableName = value;
|
||||
}
|
||||
|
||||
/** @brief ctor
|
||||
*/
|
||||
EXPORT VendorDMLStatement(std::string dmlstatement, int stmttype, int sessionID);
|
||||
/** @brief Get the schema name
|
||||
*/
|
||||
inline std::string get_SchemaName() const
|
||||
{
|
||||
return fSchema;
|
||||
}
|
||||
|
||||
/** @brief old ctor!
|
||||
*/
|
||||
EXPORT VendorDMLStatement(std::string dmlstatement, int stmttype, std::string tName,
|
||||
std::string schema, int rows, int columns, std::string buf,
|
||||
int sessionID);
|
||||
/** @brief Set the schema name
|
||||
*/
|
||||
inline void set_SchemaName( std::string value )
|
||||
{
|
||||
fSchema = value;
|
||||
}
|
||||
|
||||
/** @brief ctor for mysql
|
||||
*/
|
||||
EXPORT VendorDMLStatement(std::string dmlstatement, int stmttype, std::string tName, std::string schema, int rows, int columns,
|
||||
ColNameList& colNameList, TableValuesMap& tableValuesMap, NullValuesBitset& nullValues, int sessionID);
|
||||
/** @brief Get the DML statVendorDMLStatement classement type
|
||||
*/
|
||||
inline int get_DMLStatementType() const
|
||||
{
|
||||
return fDMLStatementType;
|
||||
}
|
||||
|
||||
/** @brief destructor
|
||||
*/
|
||||
EXPORT ~VendorDMLStatement();
|
||||
/** @brief Set the DML statement type
|
||||
*/
|
||||
inline void set_DMLStatementType( int value )
|
||||
{
|
||||
fDMLStatementType = value;
|
||||
}
|
||||
|
||||
/** @brief Get the table name
|
||||
*/
|
||||
inline std::string get_TableName() const { return fTableName; }
|
||||
/** @brief Get the DML statement
|
||||
*/
|
||||
inline const std::string get_DMLStatement() const
|
||||
{
|
||||
return fDMLStatement;
|
||||
}
|
||||
|
||||
/** @brief Set the table name
|
||||
*/
|
||||
inline void set_TableName( std::string value ) { fTableName = value; }
|
||||
/** @brief Set the DML statVendorDMLStatement classement
|
||||
*/
|
||||
inline void set_DMLStatement( std::string dmlStatement )
|
||||
{
|
||||
fDMLStatement = dmlStatement;
|
||||
}
|
||||
|
||||
/** @brief Get the schema name
|
||||
*/
|
||||
inline std::string get_SchemaName() const { return fSchema; }
|
||||
/** @brief Get the number of rows
|
||||
*/
|
||||
inline int get_Rows() const
|
||||
{
|
||||
return fRows;
|
||||
}
|
||||
|
||||
/** @brief Set the schema name
|
||||
*/
|
||||
inline void set_SchemaName( std::string value ) { fSchema = value; }
|
||||
/** @brief Set the number of rows
|
||||
*/
|
||||
inline void set_Rows( int value )
|
||||
{
|
||||
fRows = value;
|
||||
}
|
||||
|
||||
/** @brief Get the DML statVendorDMLStatement classement type
|
||||
*/
|
||||
inline int get_DMLStatementType() const { return fDMLStatementType; }
|
||||
/** @brief Get the number of columns
|
||||
*/
|
||||
inline int get_Columns() const
|
||||
{
|
||||
return fColumns;
|
||||
}
|
||||
|
||||
/** @brief Set the DML statement type
|
||||
*/
|
||||
inline void set_DMLStatementType( int value ) { fDMLStatementType = value; }
|
||||
/** @brief Set the number of columns
|
||||
*/
|
||||
inline void set_Columns( int value )
|
||||
{
|
||||
fColumns = value;
|
||||
}
|
||||
|
||||
/** @brief Get the DML statement
|
||||
*/
|
||||
inline const std::string get_DMLStatement() const { return fDMLStatement; }
|
||||
/** @brief Get the data buffer
|
||||
*/
|
||||
inline std::string& get_DataBuffer()
|
||||
{
|
||||
return fDataBuffer;
|
||||
}
|
||||
|
||||
/** @brief Set the DML statVendorDMLStatement classement
|
||||
*/
|
||||
inline void set_DMLStatement( std::string dmlStatement ) { fDMLStatement = dmlStatement; }
|
||||
/** @brief Set the data buffer
|
||||
*/
|
||||
inline void set_DataBuffer( std::string value )
|
||||
{
|
||||
fDataBuffer = value;
|
||||
}
|
||||
/** @brief Get the session ID
|
||||
*/
|
||||
inline int get_SessionID()
|
||||
{
|
||||
return fSessionID;
|
||||
}
|
||||
|
||||
/** @brief Get the number of rows
|
||||
*/
|
||||
inline int get_Rows() const { return fRows; }
|
||||
inline NullValuesBitset& get_nullValues()
|
||||
{
|
||||
return fNullValues;
|
||||
}
|
||||
|
||||
/** @brief Set the number of rows
|
||||
*/
|
||||
inline void set_Rows( int value ) { fRows = value; }
|
||||
/** @brief Set the session ID
|
||||
*/
|
||||
inline void set_SessionID( int value )
|
||||
{
|
||||
fSessionID = value;
|
||||
}
|
||||
|
||||
/** @brief Get the number of columns
|
||||
*/
|
||||
inline int get_Columns() const { return fColumns; }
|
||||
inline ColNameList& get_ColNames()
|
||||
{
|
||||
return fColNameList;
|
||||
}
|
||||
inline TableValuesMap& get_values()
|
||||
{
|
||||
return fTableValuesMap;
|
||||
}
|
||||
/** @brief get the logging flag
|
||||
*/
|
||||
inline const bool get_Logging() const
|
||||
{
|
||||
return fLogging;
|
||||
}
|
||||
|
||||
/** @brief Set the number of columns
|
||||
*/
|
||||
inline void set_Columns( int value ) { fColumns = value; }
|
||||
/** @brief set the logging flag
|
||||
*
|
||||
* @param logging the logging flag to set
|
||||
*/
|
||||
inline void set_Logging( bool logging )
|
||||
{
|
||||
fLogging = logging;
|
||||
}
|
||||
|
||||
/** @brief Get the data buffer
|
||||
*/
|
||||
inline std::string& get_DataBuffer() { return fDataBuffer; }
|
||||
/** @brief get the logging flag
|
||||
*/
|
||||
inline const bool get_Logending() const
|
||||
{
|
||||
return fLogending;
|
||||
}
|
||||
|
||||
/** @brief Set the data buffer
|
||||
*/
|
||||
inline void set_DataBuffer( std::string value ) { fDataBuffer= value; }
|
||||
/** @brief Get the session ID
|
||||
*/
|
||||
inline int get_SessionID() { return fSessionID; }
|
||||
/** @brief set the logending flag
|
||||
*
|
||||
* @param logending the logending flag to set
|
||||
*/
|
||||
inline void set_Logending( bool logending )
|
||||
{
|
||||
fLogending = logending;
|
||||
}
|
||||
|
||||
inline NullValuesBitset& get_nullValues() { return fNullValues; }
|
||||
protected:
|
||||
|
||||
/** @brief Set the session ID
|
||||
*/
|
||||
inline void set_SessionID( int value ) { fSessionID = value; }
|
||||
private:
|
||||
std::string fDMLStatement;
|
||||
int fDMLStatementType;
|
||||
std::string fTableName;
|
||||
std::string fSchema;
|
||||
int fRows;
|
||||
int fColumns;
|
||||
std::string fDataBuffer;
|
||||
ColNameList fColNameList;
|
||||
TableValuesMap fTableValuesMap;
|
||||
NullValuesBitset fNullValues;
|
||||
int fSessionID;
|
||||
bool fLogging;
|
||||
bool fLogending;
|
||||
|
||||
inline ColNameList& get_ColNames() { return fColNameList; }
|
||||
inline TableValuesMap& get_values() { return fTableValuesMap; }
|
||||
/** @brief get the logging flag
|
||||
*/
|
||||
inline const bool get_Logging() const { return fLogging; }
|
||||
|
||||
/** @brief set the logging flag
|
||||
*
|
||||
* @param logging the logging flag to set
|
||||
*/
|
||||
inline void set_Logging( bool logging )
|
||||
{
|
||||
fLogging = logging;
|
||||
}
|
||||
|
||||
/** @brief get the logging flag
|
||||
*/
|
||||
inline const bool get_Logending() const { return fLogending; }
|
||||
|
||||
/** @brief set the logending flag
|
||||
*
|
||||
* @param logending the logending flag to set
|
||||
*/
|
||||
inline void set_Logending( bool logending )
|
||||
{
|
||||
fLogending = logending;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
std::string fDMLStatement;
|
||||
int fDMLStatementType;
|
||||
std::string fTableName;
|
||||
std::string fSchema;
|
||||
int fRows;
|
||||
int fColumns;
|
||||
std::string fDataBuffer;
|
||||
ColNameList fColNameList;
|
||||
TableValuesMap fTableValuesMap;
|
||||
NullValuesBitset fNullValues;
|
||||
int fSessionID;
|
||||
bool fLogging;
|
||||
bool fLogending;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ void AutoincrementData::removeAutoincrementData(uint32_t sessionID)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(map_mutex);
|
||||
AutoincDataMap::iterator it = fAutoincDataMap.find(sessionID);
|
||||
|
||||
if (it != fAutoincDataMap.end())
|
||||
{
|
||||
delete (*it).second;
|
||||
@@ -72,26 +73,28 @@ AutoincrementData::~AutoincrementData()
|
||||
|
||||
void AutoincrementData::setNextValue(uint32_t columnOid, long long nextValue)
|
||||
{
|
||||
boost::mutex::scoped_lock lk(fOIDnextvalLock);
|
||||
fOidNextValueMap[columnOid] = nextValue;
|
||||
boost::mutex::scoped_lock lk(fOIDnextvalLock);
|
||||
fOidNextValueMap[columnOid] = nextValue;
|
||||
}
|
||||
|
||||
long long AutoincrementData::getNextValue(uint32_t columnOid)
|
||||
{
|
||||
boost::mutex::scoped_lock lk(fOIDnextvalLock);
|
||||
long long nextValue = 0;
|
||||
OIDNextValue::iterator it = fOidNextValueMap.find(columnOid);
|
||||
if (it != fOidNextValueMap.end())
|
||||
{
|
||||
nextValue = it->second;
|
||||
}
|
||||
return nextValue;
|
||||
boost::mutex::scoped_lock lk(fOIDnextvalLock);
|
||||
long long nextValue = 0;
|
||||
OIDNextValue::iterator it = fOidNextValueMap.find(columnOid);
|
||||
|
||||
if (it != fOidNextValueMap.end())
|
||||
{
|
||||
nextValue = it->second;
|
||||
}
|
||||
|
||||
return nextValue;
|
||||
}
|
||||
|
||||
AutoincrementData::OIDNextValue & AutoincrementData::getOidNextValueMap()
|
||||
AutoincrementData::OIDNextValue& AutoincrementData::getOidNextValueMap()
|
||||
{
|
||||
boost::mutex::scoped_lock lk(fOIDnextvalLock);
|
||||
boost::mutex::scoped_lock lk(fOIDnextvalLock);
|
||||
|
||||
return fOidNextValueMap;
|
||||
return fOidNextValueMap;
|
||||
}
|
||||
// vim:ts=4 sw=4:
|
||||
|
||||
@@ -31,22 +31,22 @@
|
||||
class AutoincrementData
|
||||
{
|
||||
public:
|
||||
typedef std::map <uint32_t, AutoincrementData*> AutoincDataMap;
|
||||
typedef std::map<uint32_t, long long> OIDNextValue;
|
||||
static AutoincrementData* makeAutoincrementData(uint32_t sessionID = 0);
|
||||
static void removeAutoincrementData(uint32_t sessionID = 0);
|
||||
void setNextValue(uint32_t columnOid, long long nextValue);
|
||||
long long getNextValue(uint32_t columnOid);
|
||||
OIDNextValue & getOidNextValueMap();
|
||||
typedef std::map <uint32_t, AutoincrementData*> AutoincDataMap;
|
||||
typedef std::map<uint32_t, long long> OIDNextValue;
|
||||
static AutoincrementData* makeAutoincrementData(uint32_t sessionID = 0);
|
||||
static void removeAutoincrementData(uint32_t sessionID = 0);
|
||||
void setNextValue(uint32_t columnOid, long long nextValue);
|
||||
long long getNextValue(uint32_t columnOid);
|
||||
OIDNextValue& getOidNextValueMap();
|
||||
|
||||
private:
|
||||
/** Constuctors */
|
||||
/** Constuctors */
|
||||
explicit AutoincrementData();
|
||||
explicit AutoincrementData(const AutoincrementData& rhs);
|
||||
~AutoincrementData();
|
||||
~AutoincrementData();
|
||||
|
||||
static boost::mutex map_mutex;
|
||||
static AutoincDataMap fAutoincDataMap;
|
||||
static boost::mutex map_mutex;
|
||||
static AutoincDataMap fAutoincDataMap;
|
||||
OIDNextValue fOidNextValueMap;
|
||||
boost::mutex fOIDnextvalLock;
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -50,7 +50,7 @@ class CommandPackageProcessor : public DMLPackageProcessor
|
||||
{
|
||||
|
||||
public:
|
||||
CommandPackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : DMLPackageProcessor(aDbrm, sid){}
|
||||
CommandPackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : DMLPackageProcessor(aDbrm, sid) {}
|
||||
/** @brief process an CommandDMLPackage
|
||||
*
|
||||
* @param cpackage the CommandDMLPackage to process
|
||||
@@ -60,17 +60,17 @@ public:
|
||||
protected:
|
||||
|
||||
private:
|
||||
void viewTableLock(const dmlpackage::CalpontDMLPackage& cpackage,
|
||||
DMLResult& result );
|
||||
void clearTableLock(uint64_t uniqueId,
|
||||
const dmlpackage::CalpontDMLPackage& cpackage,
|
||||
DMLResult& result );
|
||||
void establishTableLockToClear(uint64_t tableLockID,
|
||||
BRM::TableLockInfo& lockInfo);
|
||||
void viewTableLock(const dmlpackage::CalpontDMLPackage& cpackage,
|
||||
DMLResult& result );
|
||||
void clearTableLock(uint64_t uniqueId,
|
||||
const dmlpackage::CalpontDMLPackage& cpackage,
|
||||
DMLResult& result );
|
||||
void establishTableLockToClear(uint64_t tableLockID,
|
||||
BRM::TableLockInfo& lockInfo);
|
||||
|
||||
// Tracks active cleartablelock commands by storing set of table lock IDs
|
||||
static std::set<uint64_t> fActiveClearTableLockCmds;
|
||||
static boost::mutex fActiveClearTableLockCmdMutex;
|
||||
// Tracks active cleartablelock commands by storing set of table lock IDs
|
||||
static std::set<uint64_t> fActiveClearTableLockCmds;
|
||||
static boost::mutex fActiveClearTableLockCmdMutex;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
1512
dbcon/dmlpackageproc/deletepackageprocessor.cpp
Executable file → Normal file
1512
dbcon/dmlpackageproc/deletepackageprocessor.cpp
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
@@ -49,40 +49,40 @@ class DeletePackageProcessor : public DMLPackageProcessor
|
||||
|
||||
public:
|
||||
|
||||
DeletePackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : DMLPackageProcessor(aDbrm, sid){}
|
||||
DeletePackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : DMLPackageProcessor(aDbrm, sid) {}
|
||||
/** @brief process a DeleteDMLPackage
|
||||
*
|
||||
* @param cpackage the delete dml package to process
|
||||
*/
|
||||
EXPORT DMLResult processPackage(dmlpackage::CalpontDMLPackage& cpackage);
|
||||
EXPORT DMLResult processPackage(dmlpackage::CalpontDMLPackage& cpackage);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
/** @brief delete a row
|
||||
*
|
||||
* @param txnID the transaction id
|
||||
* @param tablePtr a pointer to the table that is being operated on
|
||||
* @param rowIDList upon return containts the row ids of the rows deleted
|
||||
* @param colOldValuesList upon return contains the values the were delete
|
||||
* @param result upon return will containt the result of the operation
|
||||
/** @brief delete a row
|
||||
*
|
||||
* @param txnID the transaction id
|
||||
* @param tablePtr a pointer to the table that is being operated on
|
||||
* @param rowIDList upon return containts the row ids of the rows deleted
|
||||
* @param colOldValuesList upon return contains the values the were delete
|
||||
* @param result upon return will containt the result of the operation
|
||||
bool deleteRows(execplan::CalpontSystemCatalog::SCN txnID, dmlpackage::DMLTable* tablePtr,
|
||||
WriteEngine::RIDList& rowIDList, WriteEngine::ColValueList& colOldValuesList,
|
||||
DMLResult& result);
|
||||
*/
|
||||
bool processRowgroup(messageqcpp::ByteStream & aRowGroup, DMLResult& result, const uint64_t uniqueId, dmlpackage::CalpontDMLPackage& cpackage, std::map<unsigned, bool>& pmStateDel,
|
||||
bool isMeta = false, uint32_t dbroot=1);
|
||||
WriteEngine::RIDList& rowIDList, WriteEngine::ColValueList& colOldValuesList,
|
||||
DMLResult& result);
|
||||
*/
|
||||
bool processRowgroup(messageqcpp::ByteStream& aRowGroup, DMLResult& result, const uint64_t uniqueId, dmlpackage::CalpontDMLPackage& cpackage, std::map<unsigned, bool>& pmStateDel,
|
||||
bool isMeta = false, uint32_t dbroot = 1);
|
||||
|
||||
|
||||
/** @brief add all rows if we have no filter for the delete
|
||||
*
|
||||
* @param tablePtr a pointer to the table that is being operated on
|
||||
*/
|
||||
uint64_t fixUpRows(dmlpackage::CalpontDMLPackage& cpackage, DMLResult& result, const uint64_t uniqueId, const uint32_t tableOid);
|
||||
bool receiveAll(DMLResult& result, const uint64_t uniqueId, std::vector<int>& fPMs, std::map<unsigned, bool>& pmStateDel, const uint32_t tableOid);
|
||||
uint64_t fixUpRows(dmlpackage::CalpontDMLPackage& cpackage, DMLResult& result, const uint64_t uniqueId, const uint32_t tableOid);
|
||||
bool receiveAll(DMLResult& result, const uint64_t uniqueId, std::vector<int>& fPMs, std::map<unsigned, bool>& pmStateDel, const uint32_t tableOid);
|
||||
|
||||
//bandListsByExtent bandListsMap;
|
||||
//bandListsByExtent bandListsMap;
|
||||
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -119,57 +119,72 @@ public:
|
||||
std::string miniStats;
|
||||
querystats::QueryStats stats;
|
||||
|
||||
DMLResult():result(NO_ERROR),rowCount(0){};
|
||||
DMLResult(): result(NO_ERROR), rowCount(0) {};
|
||||
};
|
||||
/** @brief a structure to hold a date
|
||||
*/
|
||||
struct Date
|
||||
{
|
||||
unsigned spare : 6;
|
||||
unsigned day : 6;
|
||||
unsigned month : 4;
|
||||
unsigned year : 16;
|
||||
// NULL column value = 0xFFFFFFFE
|
||||
Date( ) { year = 0xFFFF; month = 0xF; day = 0x3F; spare = 0x3E;}
|
||||
unsigned spare : 6;
|
||||
unsigned day : 6;
|
||||
unsigned month : 4;
|
||||
unsigned year : 16;
|
||||
// NULL column value = 0xFFFFFFFE
|
||||
Date( )
|
||||
{
|
||||
year = 0xFFFF;
|
||||
month = 0xF;
|
||||
day = 0x3F;
|
||||
spare = 0x3E;
|
||||
}
|
||||
};
|
||||
/** @brief a structure to hold a datetime
|
||||
*/
|
||||
struct dateTime
|
||||
{
|
||||
unsigned msecond : 20;
|
||||
unsigned second : 6;
|
||||
unsigned minute : 6;
|
||||
unsigned hour : 6;
|
||||
unsigned day : 6;
|
||||
unsigned month : 4;
|
||||
unsigned year : 16;
|
||||
// NULL column value = 0xFFFFFFFFFFFFFFFE
|
||||
dateTime( ) { year = 0xFFFF; month = 0xF; day = 0x3F; hour = 0x3F; minute = 0x3F; second = 0x3F;
|
||||
msecond = 0xFFFFE; }
|
||||
unsigned msecond : 20;
|
||||
unsigned second : 6;
|
||||
unsigned minute : 6;
|
||||
unsigned hour : 6;
|
||||
unsigned day : 6;
|
||||
unsigned month : 4;
|
||||
unsigned year : 16;
|
||||
// NULL column value = 0xFFFFFFFFFFFFFFFE
|
||||
dateTime( )
|
||||
{
|
||||
year = 0xFFFF;
|
||||
month = 0xF;
|
||||
day = 0x3F;
|
||||
hour = 0x3F;
|
||||
minute = 0x3F;
|
||||
second = 0x3F;
|
||||
msecond = 0xFFFFE;
|
||||
}
|
||||
};
|
||||
|
||||
/** @brief ctor
|
||||
*/
|
||||
DMLPackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : fEC(0), DMLLoggingId(21), fRollbackPending(false), fDebugLevel(NONE)
|
||||
{
|
||||
try {
|
||||
fWEClient = new WriteEngine::WEClients(WriteEngine::WEClients::DMLPROC);
|
||||
//std::cout << "In DMLPackageProcessor constructor " << this << std::endl;
|
||||
fPMCount = fWEClient->getPmCount();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cout << "Cannot make connection to WES" << std::endl;
|
||||
}
|
||||
{
|
||||
try
|
||||
{
|
||||
fWEClient = new WriteEngine::WEClients(WriteEngine::WEClients::DMLPROC);
|
||||
//std::cout << "In DMLPackageProcessor constructor " << this << std::endl;
|
||||
fPMCount = fWEClient->getPmCount();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cout << "Cannot make connection to WES" << std::endl;
|
||||
}
|
||||
|
||||
oam::OamCache * oamCache = oam::OamCache::makeOamCache();
|
||||
fDbRootPMMap = oamCache->getDBRootToPMMap();
|
||||
fDbrm = aDbrm;
|
||||
fSessionID = sid;
|
||||
fExeMgr = new execplan::ClientRotator(fSessionID, "ExeMgr");
|
||||
//std::cout << " fSessionID is " << fSessionID << std::endl;
|
||||
fExeMgr->connect(0.005);
|
||||
}
|
||||
oam::OamCache* oamCache = oam::OamCache::makeOamCache();
|
||||
fDbRootPMMap = oamCache->getDBRootToPMMap();
|
||||
fDbrm = aDbrm;
|
||||
fSessionID = sid;
|
||||
fExeMgr = new execplan::ClientRotator(fSessionID, "ExeMgr");
|
||||
//std::cout << " fSessionID is " << fSessionID << std::endl;
|
||||
fExeMgr->connect(0.005);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -179,22 +194,34 @@ public:
|
||||
|
||||
/** @brief Is it required to debug
|
||||
*/
|
||||
inline const bool isDebug( const DebugLevel level ) const { return level <= fDebugLevel; }
|
||||
inline const bool isDebug( const DebugLevel level ) const
|
||||
{
|
||||
return level <= fDebugLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get debug level
|
||||
*/
|
||||
inline const DebugLevel getDebugLevel() const { return fDebugLevel; }
|
||||
inline const DebugLevel getDebugLevel() const
|
||||
{
|
||||
return fDebugLevel;
|
||||
}
|
||||
//int rollBackTransaction(uint64_t uniqueId, uint32_t txnID, uint32_t sessionID, std::string & errorMsg);
|
||||
/**
|
||||
* @brief Set debug level
|
||||
*/
|
||||
inline void setDebugLevel( const DebugLevel level ) { fDebugLevel = level; }
|
||||
inline void setDebugLevel( const DebugLevel level )
|
||||
{
|
||||
fDebugLevel = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Distributed Engine Comm object
|
||||
*/
|
||||
inline void setEngineComm(joblist::DistributedEngineComm* ec) { fEC = ec; }
|
||||
inline void setEngineComm(joblist::DistributedEngineComm* ec)
|
||||
{
|
||||
fEC = ec;
|
||||
}
|
||||
|
||||
/** @brief process the dml package
|
||||
*
|
||||
@@ -202,11 +229,14 @@ public:
|
||||
*/
|
||||
virtual DMLResult processPackage(dmlpackage::CalpontDMLPackage& cpackage) = 0;
|
||||
|
||||
inline void setRM ( joblist::ResourceManager* frm) { fRM = frm; };
|
||||
inline void setRM ( joblist::ResourceManager* frm)
|
||||
{
|
||||
fRM = frm;
|
||||
};
|
||||
|
||||
EXPORT int rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, std::string & errorMsg);
|
||||
EXPORT int rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, std::string& errorMsg);
|
||||
|
||||
EXPORT int rollBackBatchAutoOnTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, const uint32_t tableOid, std::string & errorMsg);
|
||||
EXPORT int rollBackBatchAutoOnTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, const uint32_t tableOid, std::string& errorMsg);
|
||||
/**
|
||||
* @brief convert a columns data, represnted as a string, to it's native
|
||||
* data type
|
||||
@@ -262,11 +292,17 @@ public:
|
||||
|
||||
/** @brief Access the rollback pending flag
|
||||
*/
|
||||
bool getRollbackPending() {return fRollbackPending;}
|
||||
bool getRollbackPending()
|
||||
{
|
||||
return fRollbackPending;
|
||||
}
|
||||
|
||||
/** @brief Set the rollback pending flag
|
||||
*/
|
||||
void setRollbackPending(bool rollback) {fRollbackPending = rollback;}
|
||||
void setRollbackPending(bool rollback)
|
||||
{
|
||||
fRollbackPending = rollback;
|
||||
}
|
||||
|
||||
protected:
|
||||
/** @brief update the indexes on the target table
|
||||
@@ -279,7 +315,7 @@ protected:
|
||||
* @param colNameList the updated column names, only valid for update SQL statement
|
||||
*/
|
||||
bool updateIndexes( uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const std::string& schema,
|
||||
const std::string& table,const dmlpackage::RowList& rows, DMLResult& result,
|
||||
const std::string& table, const dmlpackage::RowList& rows, DMLResult& result,
|
||||
std::vector<WriteEngine::RID> ridList,
|
||||
WriteEngine::ColValueList& colValuesList, std::vector<std::string>& colNameList, const char updateFlag,
|
||||
std::vector<dicStrValues>& dicStrValCols );
|
||||
@@ -311,9 +347,9 @@ protected:
|
||||
* @param result the result structure
|
||||
*/
|
||||
bool violatesUniqueConstraint( const dmlpackage::RowList& rows,
|
||||
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
||||
unsigned int sessionID,
|
||||
DMLResult& result);
|
||||
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
||||
unsigned int sessionID,
|
||||
DMLResult& result);
|
||||
|
||||
/** @brief validate that the column does not violate a check constraint
|
||||
*
|
||||
@@ -321,9 +357,9 @@ protected:
|
||||
* @param result the result structure
|
||||
*/
|
||||
bool violatesCheckConstraint( const dmlpackage::RowList& rows,
|
||||
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
||||
unsigned int sessionID, unsigned int colOffset,
|
||||
DMLResult& result );
|
||||
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
||||
unsigned int sessionID, unsigned int colOffset,
|
||||
DMLResult& result );
|
||||
|
||||
/** @brief validate that the column does not violate a not null constraint
|
||||
*
|
||||
@@ -334,13 +370,13 @@ protected:
|
||||
bool violatesNotNullConstraint( const dmlpackage::RowList& rows, unsigned int colOffset,
|
||||
DMLResult& result );
|
||||
|
||||
/** @brief validate that the column does not violate a reference (foreign key) constraint
|
||||
*
|
||||
* @param rows the row set to validate
|
||||
* @param colOffset the offset of this column in the row
|
||||
* @param constraintInfo the column constraint infomation
|
||||
* @param result the result structure
|
||||
*/
|
||||
/** @brief validate that the column does not violate a reference (foreign key) constraint
|
||||
*
|
||||
* @param rows the row set to validate
|
||||
* @param colOffset the offset of this column in the row
|
||||
* @param constraintInfo the column constraint infomation
|
||||
* @param result the result structure
|
||||
*/
|
||||
bool violatesReferenceConstraint( const dmlpackage::RowList& rows,
|
||||
unsigned int colOffset,
|
||||
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
||||
@@ -354,48 +390,48 @@ protected:
|
||||
* @param rows the lists of rows to check column constraints on
|
||||
* @param result the result structure
|
||||
*/
|
||||
bool violatesPKRefConnstraint ( uint32_t sessionID,
|
||||
const std::string& schema,
|
||||
const std::string& table,
|
||||
const dmlpackage::RowList& rows,
|
||||
const WriteEngine::ColValueList& oldValueList,
|
||||
DMLResult& result );
|
||||
bool violatesPKRefConnstraint ( uint32_t sessionID,
|
||||
const std::string& schema,
|
||||
const std::string& table,
|
||||
const dmlpackage::RowList& rows,
|
||||
const WriteEngine::ColValueList& oldValueList,
|
||||
DMLResult& result );
|
||||
|
||||
bool violatesPKRefConnstraint ( uint32_t sessionID,
|
||||
const std::string& schema,
|
||||
const std::string& table,
|
||||
std::vector<WriteEngine::RID>& rowIDList,
|
||||
std::vector<void *>& oldValueList,
|
||||
DMLResult& result );
|
||||
const std::string& schema,
|
||||
const std::string& table,
|
||||
std::vector<WriteEngine::RID>& rowIDList,
|
||||
std::vector<void*>& oldValueList,
|
||||
DMLResult& result );
|
||||
|
||||
/** @brief validate that the rows deleted does not violate a reference (foreign key) constraint
|
||||
*
|
||||
* @param rows the row set to validate
|
||||
* @param colOffset the offset of this column in the row
|
||||
* @param constraintInfo the column constraint infomation
|
||||
* @param result the result structure
|
||||
*/
|
||||
/** @brief validate that the rows deleted does not violate a reference (foreign key) constraint
|
||||
*
|
||||
* @param rows the row set to validate
|
||||
* @param colOffset the offset of this column in the row
|
||||
* @param constraintInfo the column constraint infomation
|
||||
* @param result the result structure
|
||||
*/
|
||||
bool violatesReferenceConstraint_PK( const WriteEngine::ColValueList& oldValueList,
|
||||
const execplan::CalpontSystemCatalog::ColType& colType,
|
||||
unsigned int colOffset,
|
||||
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
||||
DMLResult& result );
|
||||
const execplan::CalpontSystemCatalog::ColType& colType,
|
||||
unsigned int colOffset,
|
||||
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
||||
DMLResult& result );
|
||||
|
||||
bool violatesReferenceConstraint_PK( std::vector<void *>& oldValueList,
|
||||
bool violatesReferenceConstraint_PK( std::vector<void*>& oldValueList,
|
||||
const int totalRows,
|
||||
const execplan::CalpontSystemCatalog::ColType& colType,
|
||||
unsigned int colOffset,
|
||||
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
||||
DMLResult& result );
|
||||
|
||||
/** @brief validate that none of the columns in the update row(s) violate
|
||||
* any reference constraints of the foreign key table
|
||||
*
|
||||
* @param schema the schema name
|
||||
* @param table the table name
|
||||
* @param rows the lists of rows to check column constraints on
|
||||
* @param result the result structure
|
||||
*/
|
||||
/** @brief validate that none of the columns in the update row(s) violate
|
||||
* any reference constraints of the foreign key table
|
||||
*
|
||||
* @param schema the schema name
|
||||
* @param table the table name
|
||||
* @param rows the lists of rows to check column constraints on
|
||||
* @param result the result structure
|
||||
*/
|
||||
bool violatesUpdtRefConstraints( uint32_t sessionID,
|
||||
const std::string& schema,
|
||||
const std::string& table,
|
||||
@@ -424,7 +460,7 @@ protected:
|
||||
*/
|
||||
void getColumnsForTable( uint32_t sessionID, std::string schema, std::string table, dmlpackage::ColumnList& colList );
|
||||
|
||||
/** @brief convert absolute rid to relative rid in a segement file
|
||||
/** @brief convert absolute rid to relative rid in a segement file
|
||||
*
|
||||
* @param rid in:the absolute rid out: relative rid in a segement file
|
||||
* @param dbRoot,partition, segment the extent information obtained from rid
|
||||
@@ -433,24 +469,24 @@ protected:
|
||||
* @param dbrootCnt the number of dbroot in db
|
||||
*/
|
||||
void convertRidToColumn(uint64_t& rid, unsigned& dbRoot, unsigned& partition,
|
||||
unsigned& segment, unsigned filesPerColumnPartition,
|
||||
unsigned extentsPerSegmentFile, unsigned extentRows,
|
||||
unsigned startDBRoot, unsigned dbrootCnt,
|
||||
const unsigned startPartitionNum );
|
||||
unsigned& segment, unsigned filesPerColumnPartition,
|
||||
unsigned extentsPerSegmentFile, unsigned extentRows,
|
||||
unsigned startDBRoot, unsigned dbrootCnt,
|
||||
const unsigned startPartitionNum );
|
||||
|
||||
inline bool isDictCol ( execplan::CalpontSystemCatalog::ColType colType )
|
||||
{
|
||||
if (((colType.colDataType == execplan::CalpontSystemCatalog::CHAR) && (colType.colWidth > 8))
|
||||
|| ((colType.colDataType == execplan::CalpontSystemCatalog::VARCHAR) && (colType.colWidth > 7))
|
||||
|| ((colType.colDataType == execplan::CalpontSystemCatalog::DECIMAL) && (colType.precision > 18))
|
||||
|| (colType.colDataType == execplan::CalpontSystemCatalog::VARBINARY)
|
||||
|| (colType.colDataType == execplan::CalpontSystemCatalog::BLOB)
|
||||
|| (colType.colDataType == execplan::CalpontSystemCatalog::TEXT))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
if (((colType.colDataType == execplan::CalpontSystemCatalog::CHAR) && (colType.colWidth > 8))
|
||||
|| ((colType.colDataType == execplan::CalpontSystemCatalog::VARCHAR) && (colType.colWidth > 7))
|
||||
|| ((colType.colDataType == execplan::CalpontSystemCatalog::DECIMAL) && (colType.precision > 18))
|
||||
|| (colType.colDataType == execplan::CalpontSystemCatalog::VARBINARY)
|
||||
|| (colType.colDataType == execplan::CalpontSystemCatalog::BLOB)
|
||||
|| (colType.colDataType == execplan::CalpontSystemCatalog::TEXT))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -463,18 +499,18 @@ protected:
|
||||
|
||||
// bool validateNextValue(execplan::CalpontSystemCatalog::ColType colType, int64_t value, bool & offByOne);
|
||||
|
||||
bool validateVarbinaryVal( std::string & inStr);
|
||||
bool validateVarbinaryVal( std::string& inStr);
|
||||
int commitTransaction(uint64_t uniqueId, BRM::TxnID txnID);
|
||||
int commitBatchAutoOnTransaction(uint64_t uniqueId, BRM::TxnID txnID, const uint32_t tableOid, std::string & errorMsg);
|
||||
int commitBatchAutoOffTransaction(uint64_t uniqueId, BRM::TxnID txnID, const uint32_t tableOid, std::string & errorMsg);
|
||||
int rollBackBatchAutoOffTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, const uint32_t tableOid, std::string & errorMsg);
|
||||
int flushDataFiles (int rc, std::map<uint32_t,uint32_t> & columnOids, uint64_t uniqueId, BRM::TxnID txnID, uint32_t tableOid);
|
||||
int endTransaction (uint64_t uniqueId, BRM::TxnID txnID, bool success);
|
||||
int commitBatchAutoOnTransaction(uint64_t uniqueId, BRM::TxnID txnID, const uint32_t tableOid, std::string& errorMsg);
|
||||
int commitBatchAutoOffTransaction(uint64_t uniqueId, BRM::TxnID txnID, const uint32_t tableOid, std::string& errorMsg);
|
||||
int rollBackBatchAutoOffTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, const uint32_t tableOid, std::string& errorMsg);
|
||||
int flushDataFiles (int rc, std::map<uint32_t, uint32_t>& columnOids, uint64_t uniqueId, BRM::TxnID txnID, uint32_t tableOid);
|
||||
int endTransaction (uint64_t uniqueId, BRM::TxnID txnID, bool success);
|
||||
|
||||
/** @brief the Session Manager interface
|
||||
*/
|
||||
execplan::SessionManager fSessionManager;
|
||||
joblist::DistributedEngineComm *fEC;
|
||||
joblist::DistributedEngineComm* fEC;
|
||||
joblist::ResourceManager* fRM;
|
||||
char* strlower(char* in);
|
||||
uint32_t fSessionID;
|
||||
@@ -485,14 +521,14 @@ protected:
|
||||
boost::shared_ptr<std::map<int, int> > fDbRootPMMap;
|
||||
oam::Oam fOam;
|
||||
bool fRollbackPending; // When set, any derived object should stop what it's doing and cleanup in preparation for a Rollback
|
||||
execplan::ClientRotator* fExeMgr;
|
||||
execplan::ClientRotator* fExeMgr;
|
||||
|
||||
private:
|
||||
|
||||
/** @brief clean beginning and ending glitches and spaces from string
|
||||
*
|
||||
* @param s string to be cleaned
|
||||
*/
|
||||
/** @brief clean beginning and ending glitches and spaces from string
|
||||
*
|
||||
* @param s string to be cleaned
|
||||
*/
|
||||
void cleanString(std::string& s);
|
||||
|
||||
DebugLevel fDebugLevel; // internal use debug level
|
||||
@@ -505,7 +541,7 @@ private:
|
||||
template <class T>
|
||||
bool from_string(T& t,
|
||||
const std::string& s,
|
||||
std::ios_base& (*f)(std::ios_base&))
|
||||
std::ios_base & (*f)(std::ios_base&))
|
||||
{
|
||||
std::istringstream iss(s);
|
||||
return !(iss >> f >> t).fail();
|
||||
|
||||
@@ -31,34 +31,35 @@
|
||||
|
||||
using namespace dmlpackage;
|
||||
|
||||
namespace dmlpackageprocessor {
|
||||
namespace dmlpackageprocessor
|
||||
{
|
||||
|
||||
DMLPackageProcessor* DMLPackageProcessorFactory::
|
||||
makePackageProcessor(int packageType, dmlpackage::CalpontDMLPackage& cpackage)
|
||||
{
|
||||
DMLPackageProcessor* dmlProcPtr = 0;
|
||||
DMLPackageProcessor* dmlProcPtr = 0;
|
||||
|
||||
switch( packageType )
|
||||
{
|
||||
case DML_INSERT:
|
||||
dmlProcPtr = new InsertPackageProcessor();
|
||||
break;
|
||||
switch ( packageType )
|
||||
{
|
||||
case DML_INSERT:
|
||||
dmlProcPtr = new InsertPackageProcessor();
|
||||
break;
|
||||
|
||||
case DML_DELETE:
|
||||
dmlProcPtr = new DeletePackageProcessor();
|
||||
break;
|
||||
case DML_DELETE:
|
||||
dmlProcPtr = new DeletePackageProcessor();
|
||||
break;
|
||||
|
||||
case DML_UPDATE:
|
||||
dmlProcPtr = new UpdatePackageProcessor();
|
||||
break;
|
||||
case DML_UPDATE:
|
||||
dmlProcPtr = new UpdatePackageProcessor();
|
||||
break;
|
||||
|
||||
case DML_COMMAND:
|
||||
dmlProcPtr = new CommandPackageProcessor();
|
||||
break;
|
||||
case DML_COMMAND:
|
||||
dmlProcPtr = new CommandPackageProcessor();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return dmlProcPtr;
|
||||
return dmlProcPtr;
|
||||
}
|
||||
|
||||
} // namespace dmlpackageprocessor
|
||||
|
||||
@@ -33,22 +33,24 @@
|
||||
#define EXPORT
|
||||
#endif
|
||||
|
||||
namespace dmlpackageprocessor {
|
||||
namespace dmlpackageprocessor
|
||||
{
|
||||
|
||||
/** @brief create a DMLPackageProcessor object from a CalpontDMLPackage object
|
||||
*
|
||||
*/
|
||||
class DMLPackageProcessorFactory {
|
||||
class DMLPackageProcessorFactory
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/** @brief static DMLPackageProcessor constructor method
|
||||
*
|
||||
* @param packageType the DML Package type
|
||||
* @param cpackage the CalpontDMLPackage from which the DMLPackageProcessor is constructed
|
||||
*/
|
||||
EXPORT static DMLPackageProcessor*
|
||||
makePackageProcessor( int packageType, dmlpackage::CalpontDMLPackage& cpackage );
|
||||
/** @brief static DMLPackageProcessor constructor method
|
||||
*
|
||||
* @param packageType the DML Package type
|
||||
* @param cpackage the CalpontDMLPackage from which the DMLPackageProcessor is constructed
|
||||
*/
|
||||
EXPORT static DMLPackageProcessor*
|
||||
makePackageProcessor( int packageType, dmlpackage::CalpontDMLPackage& cpackage );
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -51,362 +51,383 @@ using namespace messageqcpp;
|
||||
namespace dmlpackageprocessor
|
||||
{
|
||||
|
||||
DMLPackageProcessor::DMLResult InsertPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage & cpackage)
|
||||
{
|
||||
SUMMARY_INFO("InsertPackageProcessor::processPackage");
|
||||
DMLPackageProcessor::DMLResult InsertPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
{
|
||||
SUMMARY_INFO("InsertPackageProcessor::processPackage");
|
||||
|
||||
DMLResult result;
|
||||
result.result = NO_ERROR;
|
||||
BRM::TxnID txnid;
|
||||
// set-up the transaction
|
||||
txnid.id = cpackage.get_TxnID();
|
||||
txnid.valid = true;
|
||||
fSessionID = cpackage.get_SessionID();
|
||||
DMLTable *tablePtr = cpackage.get_Table();
|
||||
DMLResult result;
|
||||
result.result = NO_ERROR;
|
||||
BRM::TxnID txnid;
|
||||
// set-up the transaction
|
||||
txnid.id = cpackage.get_TxnID();
|
||||
txnid.valid = true;
|
||||
fSessionID = cpackage.get_SessionID();
|
||||
DMLTable* tablePtr = cpackage.get_Table();
|
||||
|
||||
LoggingID logid( DMLLoggingId, fSessionID, txnid.id);
|
||||
logging::Message::Args args1;
|
||||
logging::Message msg(1);
|
||||
args1.add("Start SQL statement: ");
|
||||
ostringstream oss;
|
||||
oss << cpackage.get_SQLStatement() << "; |" << tablePtr->get_SchemaName()<<"|";
|
||||
args1.add(oss.str());
|
||||
LoggingID logid( DMLLoggingId, fSessionID, txnid.id);
|
||||
logging::Message::Args args1;
|
||||
logging::Message msg(1);
|
||||
args1.add("Start SQL statement: ");
|
||||
ostringstream oss;
|
||||
oss << cpackage.get_SQLStatement() << "; |" << tablePtr->get_SchemaName() << "|";
|
||||
args1.add(oss.str());
|
||||
|
||||
msg.format( args1 );
|
||||
Logger logger(logid.fSubsysID);
|
||||
logger.logMessage(LOG_TYPE_DEBUG, msg, logid);
|
||||
//WriteEngine::ChunkManager* cm = cpackage.get_ChunkManager();
|
||||
//fWriteEngine.setChunkManager(cm);
|
||||
//std::map<uint32_t,uint32_t> oids;
|
||||
VERBOSE_INFO("Processing Insert DML Package...");
|
||||
uint64_t uniqueId = 0;
|
||||
//Bug 5070. Added exception handling
|
||||
try {
|
||||
uniqueId = fDbrm->getUnique64();
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add(ex.what());
|
||||
message.format(args);
|
||||
result.result = INSERT_ERROR;
|
||||
result.message = message;
|
||||
fSessionManager.rolledback(txnid);
|
||||
return result;
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add("Unknown error occured while getting unique number.");
|
||||
message.format(args);
|
||||
result.result = INSERT_ERROR;
|
||||
result.message = message;
|
||||
fSessionManager.rolledback(txnid);
|
||||
return result;
|
||||
}
|
||||
uint64_t tableLockId = 0;
|
||||
int rc = 0;
|
||||
std::string errorMsg;
|
||||
OamCache * oamcache = OamCache::makeOamCache();
|
||||
std::vector<int> moduleIds = oamcache->getModuleIds();
|
||||
std::vector<uint32_t> pms;
|
||||
msg.format( args1 );
|
||||
Logger logger(logid.fSubsysID);
|
||||
logger.logMessage(LOG_TYPE_DEBUG, msg, logid);
|
||||
//WriteEngine::ChunkManager* cm = cpackage.get_ChunkManager();
|
||||
//fWriteEngine.setChunkManager(cm);
|
||||
//std::map<uint32_t,uint32_t> oids;
|
||||
VERBOSE_INFO("Processing Insert DML Package...");
|
||||
uint64_t uniqueId = 0;
|
||||
|
||||
try
|
||||
{
|
||||
for (unsigned int i=0; i <moduleIds.size(); i++)
|
||||
{
|
||||
pms.push_back((uint32_t)moduleIds[i]);
|
||||
}
|
||||
//Bug 5070. Added exception handling
|
||||
try
|
||||
{
|
||||
uniqueId = fDbrm->getUnique64();
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add(ex.what());
|
||||
message.format(args);
|
||||
result.result = INSERT_ERROR;
|
||||
result.message = message;
|
||||
fSessionManager.rolledback(txnid);
|
||||
return result;
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
args.add("Unknown error occured while getting unique number.");
|
||||
message.format(args);
|
||||
result.result = INSERT_ERROR;
|
||||
result.message = message;
|
||||
fSessionManager.rolledback(txnid);
|
||||
return result;
|
||||
}
|
||||
|
||||
//cout << "single insert get transaction id " << txnid.id << endl;
|
||||
// get the table object from the package
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(fSessionID);
|
||||
//cout << "DMLProc using syscatptr:sessionid = " << systemCatalogPtr <<":" << fSessionID<< endl;
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||
TablelockData * tablelockData = TablelockData::makeTablelockData(fSessionID);
|
||||
if (0 != tablePtr)
|
||||
{
|
||||
//check table lock
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
systemCatalogPtr->sessionID(fSessionID);
|
||||
tableName.schema = tablePtr->get_SchemaName();
|
||||
tableName.table = tablePtr->get_TableName();
|
||||
roPair = systemCatalogPtr->tableRID( tableName );
|
||||
uint64_t tableLockId = 0;
|
||||
int rc = 0;
|
||||
std::string errorMsg;
|
||||
OamCache* oamcache = OamCache::makeOamCache();
|
||||
std::vector<int> moduleIds = oamcache->getModuleIds();
|
||||
std::vector<uint32_t> pms;
|
||||
|
||||
tableLockId = tablelockData->getTablelockId(roPair.objnum); //check whether this table is locked already for this session
|
||||
if (tableLockId == 0)
|
||||
{
|
||||
//cout << "tablelock is not found in cache, getting from dbrm" << endl;
|
||||
uint32_t processID = ::getpid();
|
||||
int32_t txnId = txnid.id;
|
||||
int32_t sessionId = fSessionID;
|
||||
std::string processName("DMLProc");
|
||||
int i = 0;
|
||||
try
|
||||
{
|
||||
for (unsigned int i = 0; i < moduleIds.size(); i++)
|
||||
{
|
||||
pms.push_back((uint32_t)moduleIds[i]);
|
||||
}
|
||||
|
||||
try {
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnId, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
throw std::runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE));
|
||||
}
|
||||
//cout << "single insert get transaction id " << txnid.id << endl;
|
||||
// get the table object from the package
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(fSessionID);
|
||||
//cout << "DMLProc using syscatptr:sessionid = " << systemCatalogPtr <<":" << fSessionID<< endl;
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||
TablelockData* tablelockData = TablelockData::makeTablelockData(fSessionID);
|
||||
|
||||
if ( tableLockId == 0 )
|
||||
{
|
||||
int waitPeriod = 10;
|
||||
int sleepTime = 100; // sleep 100 milliseconds between checks
|
||||
int numTries = 10; // try 10 times per second
|
||||
waitPeriod = Config::getWaitPeriod();
|
||||
numTries = waitPeriod * 10;
|
||||
struct timespec rm_ts;
|
||||
if (0 != tablePtr)
|
||||
{
|
||||
//check table lock
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
systemCatalogPtr->sessionID(fSessionID);
|
||||
tableName.schema = tablePtr->get_SchemaName();
|
||||
tableName.table = tablePtr->get_TableName();
|
||||
roPair = systemCatalogPtr->tableRID( tableName );
|
||||
|
||||
rm_ts.tv_sec = sleepTime/1000;
|
||||
rm_ts.tv_nsec = sleepTime%1000 *1000000;
|
||||
tableLockId = tablelockData->getTablelockId(roPair.objnum); //check whether this table is locked already for this session
|
||||
|
||||
for (; i < numTries; i++)
|
||||
{
|
||||
if (tableLockId == 0)
|
||||
{
|
||||
//cout << "tablelock is not found in cache, getting from dbrm" << endl;
|
||||
uint32_t processID = ::getpid();
|
||||
int32_t txnId = txnid.id;
|
||||
int32_t sessionId = fSessionID;
|
||||
std::string processName("DMLProc");
|
||||
int i = 0;
|
||||
|
||||
try
|
||||
{
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnId, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
throw std::runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE));
|
||||
}
|
||||
|
||||
if ( tableLockId == 0 )
|
||||
{
|
||||
int waitPeriod = 10;
|
||||
int sleepTime = 100; // sleep 100 milliseconds between checks
|
||||
int numTries = 10; // try 10 times per second
|
||||
waitPeriod = Config::getWaitPeriod();
|
||||
numTries = waitPeriod * 10;
|
||||
struct timespec rm_ts;
|
||||
|
||||
rm_ts.tv_sec = sleepTime / 1000;
|
||||
rm_ts.tv_nsec = sleepTime % 1000 * 1000000;
|
||||
|
||||
for (; i < numTries; i++)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
#else
|
||||
struct timespec abs_ts;
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while(nanosleep(&abs_ts,&rm_ts) < 0);
|
||||
struct timespec abs_ts;
|
||||
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
try {
|
||||
processID = ::getpid();
|
||||
txnId = txnid.id;
|
||||
sessionId = fSessionID;
|
||||
processName = "DMLProc";
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnId, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
throw std::runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE));
|
||||
}
|
||||
|
||||
if (tableLockId > 0)
|
||||
break;
|
||||
}
|
||||
if (i >= numTries) //error out
|
||||
{
|
||||
result.result = INSERT_ERROR;
|
||||
logging::Message::Args args;
|
||||
string strOp("insert");
|
||||
args.add(strOp);
|
||||
args.add(processName);
|
||||
args.add((uint64_t)processID);
|
||||
args.add(sessionId);
|
||||
throw std::runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_TABLE_LOCKED,args));
|
||||
}
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
processID = ::getpid();
|
||||
txnId = txnid.id;
|
||||
sessionId = fSessionID;
|
||||
processName = "DMLProc";
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnId, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
throw std::runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE));
|
||||
}
|
||||
|
||||
//cout << " tablelock is obtained with id " << tableLockId << endl;
|
||||
tablelockData->setTablelock(roPair.objnum, tableLockId);
|
||||
if (tableLockId > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
int pmNum = 0;
|
||||
if (i >= numTries) //error out
|
||||
{
|
||||
result.result = INSERT_ERROR;
|
||||
logging::Message::Args args;
|
||||
string strOp("insert");
|
||||
args.add(strOp);
|
||||
args.add(processName);
|
||||
args.add((uint64_t)processID);
|
||||
args.add(sessionId);
|
||||
throw std::runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_TABLE_LOCKED, args));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Select PM to receive the row.
|
||||
// 1. Get BRM information
|
||||
// 2. Find the DBRoot with the fewest in-service blocks.
|
||||
// DBRoots having no blocks are excluded
|
||||
// 3. Map the selected DBRoot to the corresponding PM
|
||||
CalpontSystemCatalog::RIDList ridList = systemCatalogPtr->columnRIDs(tableName, true);
|
||||
std::vector<BRM::EmDbRootHWMInfo_v> allInfo (pms.size());
|
||||
for (unsigned i = 0; i < pms.size(); i++)
|
||||
{
|
||||
rc = fDbrm->getDbRootHWMInfo((ridList[0].objnum), pms[i], allInfo[i]);
|
||||
if ( rc !=0 ) //@Bug 4760.
|
||||
{
|
||||
result.result = INSERT_ERROR;
|
||||
ostringstream oss;
|
||||
oss << "Error getting extent information for table " << tableName.table;
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
}
|
||||
//cout << " tablelock is obtained with id " << tableLockId << endl;
|
||||
tablelockData->setTablelock(roPair.objnum, tableLockId);
|
||||
|
||||
// Find DBRoot with fewest blocks; if all DBRoots
|
||||
// have 0 blocks, then we select the first DBRoot
|
||||
BRM::EmDbRootHWMInfo tmp;
|
||||
bool tmpSet = false;
|
||||
for (unsigned i=0; i < allInfo.size(); i++)
|
||||
{
|
||||
BRM::EmDbRootHWMInfo_v emDbRootHWMInfos = allInfo[i];
|
||||
int pmNum = 0;
|
||||
|
||||
for (unsigned j=0; j < emDbRootHWMInfos.size(); j++)
|
||||
{
|
||||
if (!tmpSet)
|
||||
{
|
||||
tmp = emDbRootHWMInfos[j];
|
||||
tmpSet = true;
|
||||
}
|
||||
else if (emDbRootHWMInfos[j].totalBlocks > 0)
|
||||
{
|
||||
if ((emDbRootHWMInfos[j].totalBlocks < tmp.totalBlocks) ||
|
||||
(tmp.totalBlocks == 0))
|
||||
{
|
||||
tmp = emDbRootHWMInfos[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Select PM to receive the row.
|
||||
// 1. Get BRM information
|
||||
// 2. Find the DBRoot with the fewest in-service blocks.
|
||||
// DBRoots having no blocks are excluded
|
||||
// 3. Map the selected DBRoot to the corresponding PM
|
||||
CalpontSystemCatalog::RIDList ridList = systemCatalogPtr->columnRIDs(tableName, true);
|
||||
std::vector<BRM::EmDbRootHWMInfo_v> allInfo (pms.size());
|
||||
|
||||
// Select the PM to receive the row
|
||||
uint32_t dbroot;
|
||||
if (tmpSet)
|
||||
{
|
||||
dbroot = tmp.dbRoot;
|
||||
boost::shared_ptr<std::map<int, int> > dbRootPMMap = oamcache->getDBRootToPMMap();
|
||||
pmNum = (*dbRootPMMap)[dbroot];
|
||||
for (unsigned i = 0; i < pms.size(); i++)
|
||||
{
|
||||
rc = fDbrm->getDbRootHWMInfo((ridList[0].objnum), pms[i], allInfo[i]);
|
||||
|
||||
//@Bug 4760. validate pm value
|
||||
if (pmNum == 0)
|
||||
{
|
||||
result.result = INSERT_ERROR;
|
||||
ostringstream oss;
|
||||
oss << "Error mapping extent/DBRoot to PM for table " << tableName.table;
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.result = INSERT_ERROR;
|
||||
ostringstream oss;
|
||||
oss << "There is no extent information for table " << tableName.table;
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
if ( rc != 0 ) //@Bug 4760.
|
||||
{
|
||||
result.result = INSERT_ERROR;
|
||||
ostringstream oss;
|
||||
oss << "Error getting extent information for table " << tableName.table;
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
}
|
||||
|
||||
//This is for single insert only. Batch insert is handled in dmlprocessor.
|
||||
//cout << "fWEClient = " << fWEClient << endl;
|
||||
fWEClient->addQueue(uniqueId);
|
||||
ByteStream bytestream;
|
||||
bytestream << (uint8_t)WE_SVR_SINGLE_INSERT;
|
||||
bytestream << uniqueId;
|
||||
bytestream << (uint32_t)txnid.id;
|
||||
bytestream << dbroot;
|
||||
cpackage.write(bytestream);
|
||||
boost::shared_ptr<messageqcpp::ByteStream> bsIn;
|
||||
// Find DBRoot with fewest blocks; if all DBRoots
|
||||
// have 0 blocks, then we select the first DBRoot
|
||||
BRM::EmDbRootHWMInfo tmp;
|
||||
bool tmpSet = false;
|
||||
|
||||
ByteStream::byte rc1;
|
||||
try
|
||||
{
|
||||
fWEClient->write(bytestream, (uint32_t)pmNum);
|
||||
for (unsigned i = 0; i < allInfo.size(); i++)
|
||||
{
|
||||
BRM::EmDbRootHWMInfo_v emDbRootHWMInfos = allInfo[i];
|
||||
|
||||
for (unsigned j = 0; j < emDbRootHWMInfos.size(); j++)
|
||||
{
|
||||
if (!tmpSet)
|
||||
{
|
||||
tmp = emDbRootHWMInfos[j];
|
||||
tmpSet = true;
|
||||
}
|
||||
else if (emDbRootHWMInfos[j].totalBlocks > 0)
|
||||
{
|
||||
if ((emDbRootHWMInfos[j].totalBlocks < tmp.totalBlocks) ||
|
||||
(tmp.totalBlocks == 0))
|
||||
{
|
||||
tmp = emDbRootHWMInfos[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Select the PM to receive the row
|
||||
uint32_t dbroot;
|
||||
|
||||
if (tmpSet)
|
||||
{
|
||||
dbroot = tmp.dbRoot;
|
||||
boost::shared_ptr<std::map<int, int> > dbRootPMMap = oamcache->getDBRootToPMMap();
|
||||
pmNum = (*dbRootPMMap)[dbroot];
|
||||
|
||||
//@Bug 4760. validate pm value
|
||||
if (pmNum == 0)
|
||||
{
|
||||
result.result = INSERT_ERROR;
|
||||
ostringstream oss;
|
||||
oss << "Error mapping extent/DBRoot to PM for table " << tableName.table;
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.result = INSERT_ERROR;
|
||||
ostringstream oss;
|
||||
oss << "There is no extent information for table " << tableName.table;
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
|
||||
//This is for single insert only. Batch insert is handled in dmlprocessor.
|
||||
//cout << "fWEClient = " << fWEClient << endl;
|
||||
fWEClient->addQueue(uniqueId);
|
||||
ByteStream bytestream;
|
||||
bytestream << (uint8_t)WE_SVR_SINGLE_INSERT;
|
||||
bytestream << uniqueId;
|
||||
bytestream << (uint32_t)txnid.id;
|
||||
bytestream << dbroot;
|
||||
cpackage.write(bytestream);
|
||||
boost::shared_ptr<messageqcpp::ByteStream> bsIn;
|
||||
|
||||
ByteStream::byte rc1;
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->write(bytestream, (uint32_t)pmNum);
|
||||
#ifdef IDB_DML_DEBUG
|
||||
cout << "Single insert sending WE_SVR_SINGLE_INSERT to pm " << pmNum << endl;
|
||||
cout << "Single insert sending WE_SVR_SINGLE_INSERT to pm " << pmNum << endl;
|
||||
#endif
|
||||
|
||||
bsIn.reset(new ByteStream());
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = NETWORK_ERROR;
|
||||
errorMsg = "Lost connection to Write Engine Server while updating SYSTABLES";
|
||||
}
|
||||
else {
|
||||
*bsIn >> rc1;
|
||||
if (rc1 != 0) {
|
||||
*bsIn >> errorMsg;
|
||||
rc = rc1;
|
||||
}
|
||||
}
|
||||
bsIn.reset(new ByteStream());
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
}
|
||||
catch (runtime_error& ex) //write error
|
||||
{
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = NETWORK_ERROR;
|
||||
errorMsg = "Lost connection to Write Engine Server while updating SYSTABLES";
|
||||
}
|
||||
else
|
||||
{
|
||||
*bsIn >> rc1;
|
||||
|
||||
if (rc1 != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
rc = rc1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (runtime_error& ex) //write error
|
||||
{
|
||||
#ifdef IDB_DML_DEBUG
|
||||
cout << "Single insert got exception" << ex.what() << endl;
|
||||
cout << "Single insert got exception" << ex.what() << endl;
|
||||
#endif
|
||||
rc = NETWORK_ERROR;
|
||||
errorMsg = ex.what();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
errorMsg = "Caught ... exception during single row insert";
|
||||
rc = NETWORK_ERROR;
|
||||
rc = NETWORK_ERROR;
|
||||
errorMsg = ex.what();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
errorMsg = "Caught ... exception during single row insert";
|
||||
rc = NETWORK_ERROR;
|
||||
#ifdef IDB_DML_DEBUG
|
||||
cout << "Single insert got unknown exception" << endl;
|
||||
cout << "Single insert got unknown exception" << endl;
|
||||
#endif
|
||||
}
|
||||
// Log the insert statement.
|
||||
LoggingID logid( DMLLoggingId, fSessionID, txnid.id);
|
||||
logging::Message::Args args1;
|
||||
logging::Message msg(1);
|
||||
args1.add("End SQL statement");
|
||||
msg.format( args1 );
|
||||
Logger logger(logid.fSubsysID);
|
||||
logger.logMessage(LOG_TYPE_DEBUG, msg, logid);
|
||||
logging::logDML(cpackage.get_SessionID(), txnid.id, cpackage.get_SQLStatement()+ ";", cpackage.get_SchemaName());
|
||||
}
|
||||
}
|
||||
catch(exception & ex)
|
||||
{
|
||||
cerr << "InsertPackageProcessor::processPackage: " << ex.what() << endl;
|
||||
}
|
||||
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add("Insert Failed: ");
|
||||
args.add(ex.what());
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format(args);
|
||||
// Log the insert statement.
|
||||
LoggingID logid( DMLLoggingId, fSessionID, txnid.id);
|
||||
logging::Message::Args args1;
|
||||
logging::Message msg(1);
|
||||
args1.add("End SQL statement");
|
||||
msg.format( args1 );
|
||||
Logger logger(logid.fSubsysID);
|
||||
logger.logMessage(LOG_TYPE_DEBUG, msg, logid);
|
||||
logging::logDML(cpackage.get_SessionID(), txnid.id, cpackage.get_SQLStatement() + ";", cpackage.get_SchemaName());
|
||||
}
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
cerr << "InsertPackageProcessor::processPackage: " << ex.what() << endl;
|
||||
|
||||
if ( result.result != VB_OVERFLOW_ERROR )
|
||||
{
|
||||
result.result = INSERT_ERROR;
|
||||
result.message = message;
|
||||
errorMsg = ex.what();
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
cerr << "InsertPackageProcessor::processPackage: caught unknown exception!" << endl;
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add("Insert Failed: ");
|
||||
args.add("encountered unkown exception");
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format(args);
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add("Insert Failed: ");
|
||||
args.add(ex.what());
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format(args);
|
||||
|
||||
result.result = INSERT_ERROR;
|
||||
result.message = message;
|
||||
}
|
||||
if ( result.result != VB_OVERFLOW_ERROR )
|
||||
{
|
||||
result.result = INSERT_ERROR;
|
||||
result.message = message;
|
||||
errorMsg = ex.what();
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cerr << "InsertPackageProcessor::processPackage: caught unknown exception!" << endl;
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add("Insert Failed: ");
|
||||
args.add("encountered unkown exception");
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format(args);
|
||||
|
||||
if (( rc !=0) && (rc != IDBRANGE_WARNING))
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add("Insert Failed: ");
|
||||
args.add(errorMsg);
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format(args);
|
||||
result.result = INSERT_ERROR;
|
||||
result.message = message;
|
||||
}
|
||||
else if (rc == IDBRANGE_WARNING)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add(errorMsg);
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format(args);
|
||||
result.result = IDBRANGE_WARNING;
|
||||
result.message = message;
|
||||
}
|
||||
result.result = INSERT_ERROR;
|
||||
result.message = message;
|
||||
}
|
||||
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
VERBOSE_INFO("Finished Processing Insert DML Package");
|
||||
return result;
|
||||
}
|
||||
if (( rc != 0) && (rc != IDBRANGE_WARNING))
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add("Insert Failed: ");
|
||||
args.add(errorMsg);
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format(args);
|
||||
result.result = INSERT_ERROR;
|
||||
result.message = message;
|
||||
}
|
||||
else if (rc == IDBRANGE_WARNING)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
logging::Message message(1);
|
||||
args.add(errorMsg);
|
||||
args.add("");
|
||||
args.add("");
|
||||
message.format(args);
|
||||
result.result = IDBRANGE_WARNING;
|
||||
result.message = message;
|
||||
}
|
||||
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
VERBOSE_INFO("Finished Processing Insert DML Package");
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace dmlpackageprocessor
|
||||
|
||||
|
||||
@@ -48,8 +48,9 @@ class InsertPackageProcessor : public DMLPackageProcessor
|
||||
{
|
||||
|
||||
public:
|
||||
InsertPackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : DMLPackageProcessor(aDbrm, sid) {
|
||||
}
|
||||
InsertPackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : DMLPackageProcessor(aDbrm, sid)
|
||||
{
|
||||
}
|
||||
/** @brief process an InsertDMLPackage
|
||||
*
|
||||
* @param cpackage the InsertDMLPackage to process
|
||||
|
||||
@@ -59,6 +59,7 @@ void TablelockData::removeTablelockData(uint32_t sessionID)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(map_mutex);
|
||||
TablelockDataMap::iterator it = fTablelockDataMap.find(sessionID);
|
||||
|
||||
if (it != fTablelockDataMap.end())
|
||||
{
|
||||
delete (*it).second;
|
||||
@@ -75,27 +76,29 @@ TablelockData::~TablelockData()
|
||||
|
||||
void TablelockData::setTablelock(uint32_t tableOid, uint64_t tablelockId)
|
||||
{
|
||||
boost::mutex::scoped_lock lk(fOIDTablelock);
|
||||
fOIDTablelockMap[tableOid] = tablelockId;
|
||||
boost::mutex::scoped_lock lk(fOIDTablelock);
|
||||
fOIDTablelockMap[tableOid] = tablelockId;
|
||||
}
|
||||
|
||||
uint64_t TablelockData::getTablelockId(uint32_t tableOid)
|
||||
{
|
||||
boost::mutex::scoped_lock lk(fOIDTablelock);
|
||||
uint64_t tablelockId = 0;
|
||||
OIDTablelock::iterator it = fOIDTablelockMap.find(tableOid);
|
||||
if (it != fOIDTablelockMap.end())
|
||||
{
|
||||
tablelockId = it->second;
|
||||
}
|
||||
return tablelockId;
|
||||
boost::mutex::scoped_lock lk(fOIDTablelock);
|
||||
uint64_t tablelockId = 0;
|
||||
OIDTablelock::iterator it = fOIDTablelockMap.find(tableOid);
|
||||
|
||||
if (it != fOIDTablelockMap.end())
|
||||
{
|
||||
tablelockId = it->second;
|
||||
}
|
||||
|
||||
return tablelockId;
|
||||
}
|
||||
|
||||
TablelockData::OIDTablelock & TablelockData::getOidTablelockMap()
|
||||
TablelockData::OIDTablelock& TablelockData::getOidTablelockMap()
|
||||
{
|
||||
boost::mutex::scoped_lock lk(fOIDTablelock);
|
||||
boost::mutex::scoped_lock lk(fOIDTablelock);
|
||||
|
||||
return fOIDTablelockMap;
|
||||
return fOIDTablelockMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,22 +39,22 @@ namespace dmlpackageprocessor
|
||||
class TablelockData
|
||||
{
|
||||
public:
|
||||
typedef std::map <uint32_t, TablelockData*> TablelockDataMap;
|
||||
typedef std::map<uint32_t, uint64_t> OIDTablelock;
|
||||
EXPORT static TablelockData* makeTablelockData(uint32_t sessionID = 0);
|
||||
EXPORT static void removeTablelockData(uint32_t sessionID = 0);
|
||||
EXPORT void setTablelock(uint32_t tableOid, uint64_t tablelockId);
|
||||
EXPORT uint64_t getTablelockId(uint32_t tableOid);
|
||||
OIDTablelock & getOidTablelockMap();
|
||||
typedef std::map <uint32_t, TablelockData*> TablelockDataMap;
|
||||
typedef std::map<uint32_t, uint64_t> OIDTablelock;
|
||||
EXPORT static TablelockData* makeTablelockData(uint32_t sessionID = 0);
|
||||
EXPORT static void removeTablelockData(uint32_t sessionID = 0);
|
||||
EXPORT void setTablelock(uint32_t tableOid, uint64_t tablelockId);
|
||||
EXPORT uint64_t getTablelockId(uint32_t tableOid);
|
||||
OIDTablelock& getOidTablelockMap();
|
||||
|
||||
private:
|
||||
/** Constuctors */
|
||||
/** Constuctors */
|
||||
explicit TablelockData();
|
||||
explicit TablelockData(const TablelockData& rhs);
|
||||
~TablelockData();
|
||||
~TablelockData();
|
||||
|
||||
static boost::mutex map_mutex;
|
||||
static TablelockDataMap fTablelockDataMap;
|
||||
static boost::mutex map_mutex;
|
||||
static TablelockDataMap fTablelockDataMap;
|
||||
OIDTablelock fOIDTablelockMap;
|
||||
boost::mutex fOIDTablelock;
|
||||
};
|
||||
|
||||
@@ -448,7 +448,7 @@ public:
|
||||
createStmt = "create table tpch.supplier( s_suppkey integer NOT NULL, s_name char(25) , s_address varchar(40), s_nationkey integer , s_phone char(15) , s_acctbal integer, s_comment varchar(101))";
|
||||
buildTable(createStmt);
|
||||
|
||||
createStmt = "create table tpch.part( p_partkey integer NOT NULL ,p_name varchar(55) , p_mfgr char(25), p_brand char(10) , p_type varchar(25) , p_size integer , p_container char(10) ,p_retailprice integer , p_comment varchar(23), PRIMARY KEY(p_partkey))";
|
||||
createStmt = "create table tpch.part( p_partkey integer NOT NULL ,p_name varchar(55) , p_mfgr char(25), p_brand char(10) , p_type varchar(25) , p_size integer , p_container char(10) ,p_retailprice integer , p_comment varchar(23), PRIMARY KEY(p_partkey))";
|
||||
buildTable(createStmt);
|
||||
|
||||
}
|
||||
@@ -458,21 +458,23 @@ public:
|
||||
|
||||
ddlpackage::SqlParser parser;
|
||||
parser.Parse(createText.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ddlpackage::ParseTree &ptree = parser.GetParseTree();
|
||||
const ddlpackage::ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
ddlpackageprocessor::CreateTableProcessor processor;
|
||||
processor.setDebugLevel(ddlpackageprocessor::CreateTableProcessor::VERBOSE);
|
||||
|
||||
ddlpackage::SqlStatement &stmt = *ptree.fList[0];
|
||||
ddlpackage::SqlStatement& stmt = *ptree.fList[0];
|
||||
ddlpackageprocessor::CreateTableProcessor::DDLResult result;
|
||||
|
||||
result = processor.processPackage(dynamic_cast<ddlpackage::CreateTableStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
|
||||
throw;
|
||||
@@ -493,9 +495,11 @@ void destroySemaphores()
|
||||
|
||||
semkey = 0x2149bdd2;
|
||||
sems = semget(semkey, 2, 0666);
|
||||
|
||||
if (sems != -1)
|
||||
{
|
||||
err = semctl(sems, 0, IPC_RMID);
|
||||
|
||||
if (err == -1)
|
||||
perror("tdriver: semctl");
|
||||
}
|
||||
@@ -508,9 +512,11 @@ void destroyShmseg()
|
||||
|
||||
shmkey = 0x2149bdd2;
|
||||
shms = shmget(shmkey, 0, 0666);
|
||||
|
||||
if (shms != -1)
|
||||
{
|
||||
err = shmctl(shms, IPC_RMID, NULL);
|
||||
|
||||
if (err == -1 && errno != EINVAL)
|
||||
{
|
||||
perror("tdriver: shmctl");
|
||||
@@ -650,7 +656,7 @@ public:
|
||||
|
||||
cout << "\nDML statement:" << dmlStatement.c_str() << endl;
|
||||
|
||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||
|
||||
@@ -676,7 +682,7 @@ public:
|
||||
|
||||
cout << "\nDML statement:" << dmlStatement.c_str() << endl;
|
||||
|
||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||
|
||||
@@ -708,7 +714,7 @@ public:
|
||||
|
||||
CPPUNIT_ASSERT( DML_INSERT == package_type );
|
||||
|
||||
InsertDMLPackage *pObject = new InsertDMLPackage();
|
||||
InsertDMLPackage* pObject = new InsertDMLPackage();
|
||||
|
||||
pObject->read( bs );
|
||||
|
||||
@@ -720,6 +726,7 @@ public:
|
||||
|
||||
pkgProcPtr->setDebugLevel(DMLPackageProcessor::VERBOSE);
|
||||
DMLPackageProcessor::DMLResult result = pkgProcPtr->processPackage( *pObject );
|
||||
|
||||
if ( DMLPackageProcessor::NO_ERROR != result.result )
|
||||
{
|
||||
cout << "Insert failed!" << endl;
|
||||
@@ -770,7 +777,7 @@ public:
|
||||
|
||||
cout << "\nDML statement:" << dmlStatement.c_str() << endl;
|
||||
|
||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||
|
||||
@@ -801,7 +808,7 @@ public:
|
||||
|
||||
CPPUNIT_ASSERT( DML_DELETE == package_type );
|
||||
|
||||
DeleteDMLPackage *pObject = new DeleteDMLPackage();
|
||||
DeleteDMLPackage* pObject = new DeleteDMLPackage();
|
||||
|
||||
pObject->read( bs );
|
||||
|
||||
@@ -822,6 +829,7 @@ public:
|
||||
|
||||
ml.logDebugMessage( result.message );
|
||||
}
|
||||
|
||||
delete pkgProcPtr;
|
||||
delete pObject;
|
||||
|
||||
@@ -837,7 +845,7 @@ public:
|
||||
|
||||
cout << "\nDML statement:" << dmlStatement.c_str() << endl;
|
||||
|
||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||
|
||||
@@ -866,6 +874,7 @@ public:
|
||||
ByteStream bytestream;
|
||||
|
||||
std::vector<std::string>::const_iterator iter = commands.begin();
|
||||
|
||||
while (iter != commands.end())
|
||||
{
|
||||
std::string command = *iter;
|
||||
@@ -873,6 +882,7 @@ public:
|
||||
|
||||
VendorDMLStatement dml_command(command, 1);
|
||||
CalpontDMLPackage* dmlCommandPkgPtr = CalpontDMLFactory::makeCalpontDMLPackage(dml_command);
|
||||
|
||||
if (dmlCommandPkgPtr)
|
||||
{
|
||||
cout << "CalpontDMLFactory::makeCalpontDMLPackage: success" << endl;
|
||||
@@ -900,7 +910,7 @@ public:
|
||||
|
||||
CPPUNIT_ASSERT( DML_COMMAND == package_type );
|
||||
|
||||
CommandDMLPackage *pObject = new CommandDMLPackage();
|
||||
CommandDMLPackage* pObject = new CommandDMLPackage();
|
||||
|
||||
pObject->read( bs );
|
||||
|
||||
@@ -921,6 +931,7 @@ public:
|
||||
|
||||
ml.logDebugMessage( result.message );
|
||||
}
|
||||
|
||||
delete pkgProcPtr;
|
||||
delete pObject;
|
||||
}
|
||||
@@ -967,7 +978,7 @@ public:
|
||||
|
||||
CPPUNIT_ASSERT( DML_UPDATE == package_type );
|
||||
|
||||
UpdateDMLPackage *pObject = new UpdateDMLPackage();
|
||||
UpdateDMLPackage* pObject = new UpdateDMLPackage();
|
||||
|
||||
pObject->read( bs );
|
||||
|
||||
@@ -1002,13 +1013,13 @@ CPPUNIT_TEST_SUITE_REGISTRATION( DMLPackageProcessorTest );
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
|
||||
int main( int argc, char **argv)
|
||||
int main( int argc, char** argv)
|
||||
{
|
||||
// Uncomment before running tests
|
||||
//setUp();
|
||||
//setUp();
|
||||
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
runner.addTest( registry.makeTest() );
|
||||
bool wasSuccessful = runner.run( "", false );
|
||||
|
||||
|
||||
1615
dbcon/dmlpackageproc/updatepackageprocessor.cpp
Executable file → Normal file
1615
dbcon/dmlpackageproc/updatepackageprocessor.cpp
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
@@ -45,8 +45,9 @@ class UpdatePackageProcessor : public DMLPackageProcessor
|
||||
{
|
||||
|
||||
public:
|
||||
UpdatePackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : DMLPackageProcessor(aDbrm, sid) {
|
||||
}
|
||||
UpdatePackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : DMLPackageProcessor(aDbrm, sid)
|
||||
{
|
||||
}
|
||||
/** @brief process an UpdateDMLPackage
|
||||
*
|
||||
* @param cpackage the UpdateDMLPackage to process
|
||||
@@ -58,8 +59,8 @@ protected:
|
||||
private:
|
||||
/** @brief send execution plan to ExeMgr and fetch rows
|
||||
*
|
||||
* @param cpackage the UpdateDMLPackage to process
|
||||
* @param result the result of the operation
|
||||
* @param cpackage the UpdateDMLPackage to process
|
||||
* @param result the result of the operation
|
||||
* @return rows processed
|
||||
*/
|
||||
uint64_t fixUpRows(dmlpackage::CalpontDMLPackage& cpackage, DMLResult& result, const uint64_t uniqueId, const uint32_t tableOid);
|
||||
@@ -67,13 +68,13 @@ private:
|
||||
|
||||
/** @brief send row group to the PM to process
|
||||
*
|
||||
* @param aRowGroup the row group to be sent
|
||||
* @param result the result of the operation
|
||||
* @param aRowGroup the row group to be sent
|
||||
* @param result the result of the operation
|
||||
* @return the error code
|
||||
*/
|
||||
bool processRowgroup(messageqcpp::ByteStream & aRowGroup, DMLResult& result, const uint64_t uniqueId, dmlpackage::CalpontDMLPackage& cpackage, std::map<unsigned, bool>& pmState, bool isMeta = false, uint32_t dbroot=1);
|
||||
bool receiveAll(DMLResult& result, const uint64_t uniqueId, std::vector<int>& fPMs, std::map<unsigned, bool>& pmState, const uint32_t tableOid);
|
||||
};
|
||||
bool processRowgroup(messageqcpp::ByteStream& aRowGroup, DMLResult& result, const uint64_t uniqueId, dmlpackage::CalpontDMLPackage& cpackage, std::map<unsigned, bool>& pmState, bool isMeta = false, uint32_t dbroot = 1);
|
||||
bool receiveAll(DMLResult& result, const uint64_t uniqueId, std::vector<int>& fPMs, std::map<unsigned, bool>& pmState, const uint32_t tableOid);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,30 +25,31 @@
|
||||
#ifndef DBCON_CALPONTSYSTEMCATALOG_H
|
||||
#define DBCON_CALPONTSYSTEMCATALOG_H
|
||||
|
||||
namespace dbcon {
|
||||
namespace dbcon
|
||||
{
|
||||
|
||||
class CalpontSystemCatalog
|
||||
{
|
||||
public:
|
||||
/** looks up a column's TCN in the System Catalog
|
||||
*
|
||||
* For a unique table_name.column_name return the internal TCN
|
||||
*/
|
||||
TCN lookupTCN(const TableColName& tableColName) const;
|
||||
/** looks up a column's TCN in the System Catalog
|
||||
*
|
||||
* For a unique table_name.column_name return the internal TCN
|
||||
*/
|
||||
TCN lookupTCN(const TableColName& tableColName) const;
|
||||
|
||||
/** returns the colunm type attribute(s) for a column
|
||||
*
|
||||
* return the various colunm attributes for a given TCN:
|
||||
* dictionary/native
|
||||
* DDN
|
||||
*/
|
||||
ColType colType(const TCN& tcn) const;
|
||||
/** returns the colunm type attribute(s) for a column
|
||||
*
|
||||
* return the various colunm attributes for a given TCN:
|
||||
* dictionary/native
|
||||
* DDN
|
||||
*/
|
||||
ColType colType(const TCN& tcn) const;
|
||||
|
||||
/** return the current SCN
|
||||
*
|
||||
* returns the current System Change Number (for versioning support)
|
||||
*/
|
||||
SCN scn(void) const;
|
||||
/** return the current SCN
|
||||
*
|
||||
* returns the current System Change Number (for versioning support)
|
||||
*/
|
||||
SCN scn(void) const;
|
||||
};
|
||||
|
||||
} //namespace dbcon
|
||||
|
||||
@@ -43,56 +43,58 @@ using namespace joblist;
|
||||
#include "functioncolumn.h"
|
||||
#include "objectreader.h"
|
||||
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
|
||||
void getAggCols(execplan::ParseTree* n, void* obj)
|
||||
{
|
||||
vector<AggregateColumn*>* list = reinterpret_cast< vector<AggregateColumn*>*>(obj);
|
||||
TreeNode* tn = n->data();
|
||||
AggregateColumn *sc = dynamic_cast<AggregateColumn*>(tn);
|
||||
FunctionColumn *fc = dynamic_cast<FunctionColumn*>(tn);
|
||||
ArithmeticColumn *ac = dynamic_cast<ArithmeticColumn*>(tn);
|
||||
SimpleFilter *sf = dynamic_cast<SimpleFilter*>(tn);
|
||||
ConstantFilter *cf = dynamic_cast<ConstantFilter*>(tn);
|
||||
if (sc)
|
||||
{
|
||||
list->push_back(sc);
|
||||
}
|
||||
else if (fc)
|
||||
{
|
||||
fc->hasAggregate();
|
||||
list->insert(list->end(), fc->aggColumnList().begin(), fc->aggColumnList().end());
|
||||
}
|
||||
else if (ac)
|
||||
{
|
||||
ac->hasAggregate();
|
||||
list->insert(list->end(), ac->aggColumnList().begin(), ac->aggColumnList().end());
|
||||
}
|
||||
else if (sf)
|
||||
{
|
||||
sf->hasAggregate();
|
||||
list->insert(list->end(), sf->aggColumnList().begin(), sf->aggColumnList().end());
|
||||
}
|
||||
else if (cf)
|
||||
{
|
||||
cf->hasAggregate();
|
||||
list->insert(list->end(), cf->aggColumnList().begin(), cf->aggColumnList().end());
|
||||
}
|
||||
vector<AggregateColumn*>* list = reinterpret_cast< vector<AggregateColumn*>*>(obj);
|
||||
TreeNode* tn = n->data();
|
||||
AggregateColumn* sc = dynamic_cast<AggregateColumn*>(tn);
|
||||
FunctionColumn* fc = dynamic_cast<FunctionColumn*>(tn);
|
||||
ArithmeticColumn* ac = dynamic_cast<ArithmeticColumn*>(tn);
|
||||
SimpleFilter* sf = dynamic_cast<SimpleFilter*>(tn);
|
||||
ConstantFilter* cf = dynamic_cast<ConstantFilter*>(tn);
|
||||
|
||||
if (sc)
|
||||
{
|
||||
list->push_back(sc);
|
||||
}
|
||||
else if (fc)
|
||||
{
|
||||
fc->hasAggregate();
|
||||
list->insert(list->end(), fc->aggColumnList().begin(), fc->aggColumnList().end());
|
||||
}
|
||||
else if (ac)
|
||||
{
|
||||
ac->hasAggregate();
|
||||
list->insert(list->end(), ac->aggColumnList().begin(), ac->aggColumnList().end());
|
||||
}
|
||||
else if (sf)
|
||||
{
|
||||
sf->hasAggregate();
|
||||
list->insert(list->end(), sf->aggColumnList().begin(), sf->aggColumnList().end());
|
||||
}
|
||||
else if (cf)
|
||||
{
|
||||
cf->hasAggregate();
|
||||
list->insert(list->end(), cf->aggColumnList().begin(), cf->aggColumnList().end());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructors/Destructors
|
||||
*/
|
||||
AggregateColumn::AggregateColumn():
|
||||
fAggOp(NOOP),
|
||||
fAsc(false)
|
||||
fAggOp(NOOP),
|
||||
fAsc(false)
|
||||
{
|
||||
}
|
||||
|
||||
AggregateColumn::AggregateColumn(const uint32_t sessionID):
|
||||
ReturnedColumn(sessionID),
|
||||
fAggOp(NOOP),
|
||||
fAsc(false)
|
||||
ReturnedColumn(sessionID),
|
||||
fAggOp(NOOP),
|
||||
fAsc(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -102,7 +104,7 @@ AggregateColumn::AggregateColumn(const AggOp aggOp, ReturnedColumn* parm, const
|
||||
fAsc(false),
|
||||
fData(aggOp + "(" + parm->data() + ")")
|
||||
{
|
||||
fFunctionParms.reset(parm);
|
||||
fFunctionParms.reset(parm);
|
||||
}
|
||||
|
||||
AggregateColumn::AggregateColumn(const AggOp aggOp, const string& content, const uint32_t sessionID):
|
||||
@@ -111,31 +113,31 @@ AggregateColumn::AggregateColumn(const AggOp aggOp, const string& content, const
|
||||
fAsc(false),
|
||||
fData(aggOp + "(" + content + ")")
|
||||
{
|
||||
// TODO: need to handle distinct
|
||||
fFunctionParms.reset(new ArithmeticColumn(content));
|
||||
// TODO: need to handle distinct
|
||||
fFunctionParms.reset(new ArithmeticColumn(content));
|
||||
}
|
||||
|
||||
// deprecated constructor. use function name as string
|
||||
AggregateColumn::AggregateColumn(const std::string& functionName, ReturnedColumn* parm, const uint32_t sessionID):
|
||||
ReturnedColumn(sessionID),
|
||||
fFunctionName(functionName),
|
||||
fAggOp(NOOP),
|
||||
fAsc(false),
|
||||
fData(functionName + "(" + parm->data() + ")")
|
||||
ReturnedColumn(sessionID),
|
||||
fFunctionName(functionName),
|
||||
fAggOp(NOOP),
|
||||
fAsc(false),
|
||||
fData(functionName + "(" + parm->data() + ")")
|
||||
{
|
||||
fFunctionParms.reset(parm);
|
||||
fFunctionParms.reset(parm);
|
||||
}
|
||||
|
||||
// deprecated constructor. use function name as string
|
||||
AggregateColumn::AggregateColumn(const string& functionName, const string& content, const uint32_t sessionID):
|
||||
ReturnedColumn(sessionID),
|
||||
fFunctionName(functionName),
|
||||
fAggOp(NOOP),
|
||||
fAsc(false),
|
||||
fData(functionName + "(" + content + ")")
|
||||
ReturnedColumn(sessionID),
|
||||
fFunctionName(functionName),
|
||||
fAggOp(NOOP),
|
||||
fAsc(false),
|
||||
fData(functionName + "(" + content + ")")
|
||||
{
|
||||
// TODO: need to handle distinct
|
||||
fFunctionParms.reset(new ArithmeticColumn(content));
|
||||
// TODO: need to handle distinct
|
||||
fFunctionParms.reset(new ArithmeticColumn(content));
|
||||
}
|
||||
|
||||
AggregateColumn::AggregateColumn( const AggregateColumn& rhs, const uint32_t sessionID ):
|
||||
@@ -148,7 +150,7 @@ AggregateColumn::AggregateColumn( const AggregateColumn& rhs, const uint32_t ses
|
||||
fData(rhs.data()),
|
||||
fConstCol(rhs.fConstCol)
|
||||
{
|
||||
fAlias = rhs.alias();
|
||||
fAlias = rhs.alias();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,390 +159,481 @@ AggregateColumn::AggregateColumn( const AggregateColumn& rhs, const uint32_t ses
|
||||
|
||||
const string AggregateColumn::toString() const
|
||||
{
|
||||
ostringstream output;
|
||||
output << "AggregateColumn " << data() << endl;
|
||||
output << "func/distinct: " << (int)fAggOp << "/" << fDistinct << endl;
|
||||
output << "expressionId=" << fExpressionId << endl;
|
||||
if (fAlias.length() > 0) output << "/Alias: " << fAlias << endl;
|
||||
if (fFunctionParms == 0)
|
||||
output << "No arguments" << endl;
|
||||
else
|
||||
output << *fFunctionParms << endl;
|
||||
if (fConstCol)
|
||||
output << *fConstCol;
|
||||
return output.str();
|
||||
ostringstream output;
|
||||
output << "AggregateColumn " << data() << endl;
|
||||
output << "func/distinct: " << (int)fAggOp << "/" << fDistinct << endl;
|
||||
output << "expressionId=" << fExpressionId << endl;
|
||||
|
||||
if (fAlias.length() > 0) output << "/Alias: " << fAlias << endl;
|
||||
|
||||
if (fFunctionParms == 0)
|
||||
output << "No arguments" << endl;
|
||||
else
|
||||
output << *fFunctionParms << endl;
|
||||
|
||||
if (fConstCol)
|
||||
output << *fConstCol;
|
||||
|
||||
return output.str();
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& output, const AggregateColumn& rhs)
|
||||
{
|
||||
output << rhs.toString();
|
||||
return output;
|
||||
output << rhs.toString();
|
||||
return output;
|
||||
}
|
||||
|
||||
void AggregateColumn::serialize(messageqcpp::ByteStream& b) const
|
||||
{
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList::const_iterator rcit;
|
||||
b << (uint8_t) ObjectReader::AGGREGATECOLUMN;
|
||||
ReturnedColumn::serialize(b);
|
||||
b << fFunctionName;
|
||||
b << static_cast<uint8_t>(fAggOp);
|
||||
if (fFunctionParms == 0)
|
||||
b << (uint8_t) ObjectReader::NULL_CLASS;
|
||||
else
|
||||
fFunctionParms->serialize(b);
|
||||
b << static_cast<uint32_t>(fGroupByColList.size());
|
||||
for (rcit = fGroupByColList.begin(); rcit != fGroupByColList.end(); ++rcit)
|
||||
(*rcit)->serialize(b);
|
||||
b << static_cast<uint32_t>(fProjectColList.size());
|
||||
for (rcit = fProjectColList.begin(); rcit != fProjectColList.end(); ++rcit)
|
||||
(*rcit)->serialize(b);
|
||||
b << fData;
|
||||
//b << fAlias;
|
||||
b << fTableAlias;
|
||||
b << static_cast<const ByteStream::doublebyte>(fAsc);
|
||||
if (fConstCol.get() == 0)
|
||||
b << (uint8_t) ObjectReader::NULL_CLASS;
|
||||
else
|
||||
fConstCol->serialize(b);
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList::const_iterator rcit;
|
||||
b << (uint8_t) ObjectReader::AGGREGATECOLUMN;
|
||||
ReturnedColumn::serialize(b);
|
||||
b << fFunctionName;
|
||||
b << static_cast<uint8_t>(fAggOp);
|
||||
|
||||
if (fFunctionParms == 0)
|
||||
b << (uint8_t) ObjectReader::NULL_CLASS;
|
||||
else
|
||||
fFunctionParms->serialize(b);
|
||||
|
||||
b << static_cast<uint32_t>(fGroupByColList.size());
|
||||
|
||||
for (rcit = fGroupByColList.begin(); rcit != fGroupByColList.end(); ++rcit)
|
||||
(*rcit)->serialize(b);
|
||||
|
||||
b << static_cast<uint32_t>(fProjectColList.size());
|
||||
|
||||
for (rcit = fProjectColList.begin(); rcit != fProjectColList.end(); ++rcit)
|
||||
(*rcit)->serialize(b);
|
||||
|
||||
b << fData;
|
||||
//b << fAlias;
|
||||
b << fTableAlias;
|
||||
b << static_cast<const ByteStream::doublebyte>(fAsc);
|
||||
|
||||
if (fConstCol.get() == 0)
|
||||
b << (uint8_t) ObjectReader::NULL_CLASS;
|
||||
else
|
||||
fConstCol->serialize(b);
|
||||
}
|
||||
|
||||
void AggregateColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
{
|
||||
ObjectReader::checkType(b, ObjectReader::AGGREGATECOLUMN);
|
||||
fGroupByColList.erase(fGroupByColList.begin(), fGroupByColList.end());
|
||||
fProjectColList.erase(fProjectColList.begin(), fProjectColList.end());
|
||||
ReturnedColumn::unserialize(b);
|
||||
b >> fFunctionName;
|
||||
b >> fAggOp;
|
||||
//delete fFunctionParms;
|
||||
fFunctionParms.reset(
|
||||
dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b)));
|
||||
ObjectReader::checkType(b, ObjectReader::AGGREGATECOLUMN);
|
||||
fGroupByColList.erase(fGroupByColList.begin(), fGroupByColList.end());
|
||||
fProjectColList.erase(fProjectColList.begin(), fProjectColList.end());
|
||||
ReturnedColumn::unserialize(b);
|
||||
b >> fFunctionName;
|
||||
b >> fAggOp;
|
||||
//delete fFunctionParms;
|
||||
fFunctionParms.reset(
|
||||
dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b)));
|
||||
|
||||
messageqcpp::ByteStream::quadbyte size;
|
||||
messageqcpp::ByteStream::quadbyte i;
|
||||
ReturnedColumn *rc;
|
||||
messageqcpp::ByteStream::quadbyte size;
|
||||
messageqcpp::ByteStream::quadbyte i;
|
||||
ReturnedColumn* rc;
|
||||
|
||||
b >> size;
|
||||
for (i = 0; i < size; i++) {
|
||||
rc = dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b));
|
||||
SRCP srcp(rc);
|
||||
fGroupByColList.push_back(srcp);
|
||||
}
|
||||
b >> size;
|
||||
for (i = 0; i < size; i++) {
|
||||
rc = dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b));
|
||||
SRCP srcp(rc);
|
||||
fProjectColList.push_back(srcp);
|
||||
}
|
||||
b >> fData;
|
||||
//b >> fAlias;
|
||||
b >> fTableAlias;
|
||||
b >> reinterpret_cast< ByteStream::doublebyte&>(fAsc);
|
||||
fConstCol.reset(dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b)));
|
||||
b >> size;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
rc = dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b));
|
||||
SRCP srcp(rc);
|
||||
fGroupByColList.push_back(srcp);
|
||||
}
|
||||
|
||||
b >> size;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
rc = dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b));
|
||||
SRCP srcp(rc);
|
||||
fProjectColList.push_back(srcp);
|
||||
}
|
||||
|
||||
b >> fData;
|
||||
//b >> fAlias;
|
||||
b >> fTableAlias;
|
||||
b >> reinterpret_cast< ByteStream::doublebyte&>(fAsc);
|
||||
fConstCol.reset(dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b)));
|
||||
}
|
||||
|
||||
bool AggregateColumn::operator==(const AggregateColumn& t) const
|
||||
{
|
||||
const ReturnedColumn *rc1, *rc2;
|
||||
const ReturnedColumn* rc1, *rc2;
|
||||
|
||||
rc1 = static_cast<const ReturnedColumn*>(this);
|
||||
rc2 = static_cast<const ReturnedColumn*>(&t);
|
||||
if (*rc1 != *rc2)
|
||||
return false;
|
||||
if (fFunctionName != t.fFunctionName)
|
||||
return false;
|
||||
if (fAggOp == COUNT_ASTERISK && t.fAggOp == COUNT_ASTERISK)
|
||||
return true;
|
||||
if (fAggOp != t.fAggOp)
|
||||
return false;
|
||||
if (fFunctionParms.get() != NULL && t.fFunctionParms.get() != NULL)
|
||||
{
|
||||
if (*fFunctionParms.get() != t.fFunctionParms.get())
|
||||
return false;
|
||||
}
|
||||
else if (fFunctionParms.get() != NULL || t.fFunctionParms.get() != NULL)
|
||||
return false;
|
||||
//if (fAlias != t.fAlias)
|
||||
// return false;
|
||||
if (fTableAlias != t.fTableAlias)
|
||||
return false;
|
||||
if (fData != t.fData)
|
||||
return false;
|
||||
if (fAsc != t.fAsc)
|
||||
return false;
|
||||
if ((fConstCol.get() != NULL && t.fConstCol.get() == NULL) ||
|
||||
(fConstCol.get() == NULL && t.fConstCol.get() != NULL) ||
|
||||
(fConstCol.get() != NULL && t.fConstCol.get() != NULL &&
|
||||
*(fConstCol.get()) != t.fConstCol.get()))
|
||||
return false;
|
||||
return true;
|
||||
rc1 = static_cast<const ReturnedColumn*>(this);
|
||||
rc2 = static_cast<const ReturnedColumn*>(&t);
|
||||
|
||||
if (*rc1 != *rc2)
|
||||
return false;
|
||||
|
||||
if (fFunctionName != t.fFunctionName)
|
||||
return false;
|
||||
|
||||
if (fAggOp == COUNT_ASTERISK && t.fAggOp == COUNT_ASTERISK)
|
||||
return true;
|
||||
|
||||
if (fAggOp != t.fAggOp)
|
||||
return false;
|
||||
|
||||
if (fFunctionParms.get() != NULL && t.fFunctionParms.get() != NULL)
|
||||
{
|
||||
if (*fFunctionParms.get() != t.fFunctionParms.get())
|
||||
return false;
|
||||
}
|
||||
else if (fFunctionParms.get() != NULL || t.fFunctionParms.get() != NULL)
|
||||
return false;
|
||||
|
||||
//if (fAlias != t.fAlias)
|
||||
// return false;
|
||||
if (fTableAlias != t.fTableAlias)
|
||||
return false;
|
||||
|
||||
if (fData != t.fData)
|
||||
return false;
|
||||
|
||||
if (fAsc != t.fAsc)
|
||||
return false;
|
||||
|
||||
if ((fConstCol.get() != NULL && t.fConstCol.get() == NULL) ||
|
||||
(fConstCol.get() == NULL && t.fConstCol.get() != NULL) ||
|
||||
(fConstCol.get() != NULL && t.fConstCol.get() != NULL &&
|
||||
*(fConstCol.get()) != t.fConstCol.get()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AggregateColumn::operator==(const TreeNode* t) const
|
||||
{
|
||||
const AggregateColumn *ac;
|
||||
const AggregateColumn* ac;
|
||||
|
||||
ac = dynamic_cast<const AggregateColumn*>(t);
|
||||
if (ac == NULL)
|
||||
return false;
|
||||
return *this == *ac;
|
||||
ac = dynamic_cast<const AggregateColumn*>(t);
|
||||
|
||||
if (ac == NULL)
|
||||
return false;
|
||||
|
||||
return *this == *ac;
|
||||
}
|
||||
|
||||
bool AggregateColumn::operator!=(const AggregateColumn& t) const
|
||||
{
|
||||
return !(*this == t);
|
||||
return !(*this == t);
|
||||
}
|
||||
|
||||
bool AggregateColumn::operator!=(const TreeNode* t) const
|
||||
{
|
||||
return !(*this == t);
|
||||
return !(*this == t);
|
||||
}
|
||||
|
||||
bool AggregateColumn::hasAggregate()
|
||||
{
|
||||
fAggColumnList.push_back(this);
|
||||
return true;
|
||||
fAggColumnList.push_back(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AggregateColumn::evaluate(Row& row, bool& isNull)
|
||||
{
|
||||
switch (fResultType.colDataType)
|
||||
{
|
||||
case CalpontSystemCatalog::DATE:
|
||||
if (row.equals<4>(DATENULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getUintField<4>(fInputIndex);
|
||||
break;
|
||||
case CalpontSystemCatalog::DATETIME:
|
||||
if (row.equals<8>(DATETIMENULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getUintField<8>(fInputIndex);
|
||||
break;
|
||||
case CalpontSystemCatalog::CHAR:
|
||||
case CalpontSystemCatalog::VARCHAR:
|
||||
case CalpontSystemCatalog::STRINT:
|
||||
case CalpontSystemCatalog::TEXT:
|
||||
switch (row.getColumnWidth(fInputIndex))
|
||||
{
|
||||
case 1:
|
||||
if (row.equals<1>(CHAR1NULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.origIntVal = row.getUintField<1>(fInputIndex);
|
||||
break;
|
||||
case 2:
|
||||
if (row.equals<2>(CHAR2NULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.origIntVal = row.getUintField<2>(fInputIndex);
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
if (row.equals<4>(CHAR4NULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.origIntVal = row.getUintField<4>(fInputIndex);
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
if (row.equals<8>(CHAR8NULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.origIntVal = row.getUintField<8>(fInputIndex);
|
||||
break;
|
||||
default:
|
||||
if (row.equals(CPNULLSTRMARK, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.strVal = row.getStringField(fInputIndex);
|
||||
// stringColVal is padded with '\0' to colWidth so can't use str.length()
|
||||
if (strlen(fResult.strVal.c_str()) == 0)
|
||||
isNull = true;
|
||||
break;
|
||||
}
|
||||
if (fResultType.colDataType == CalpontSystemCatalog::STRINT)
|
||||
fResult.intVal = uint64ToStr(fResult.origIntVal);
|
||||
else
|
||||
fResult.intVal = atoll((char*)&fResult.origIntVal);
|
||||
break;
|
||||
case CalpontSystemCatalog::BIGINT:
|
||||
if (row.equals<8>(BIGINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getIntField<8>(fInputIndex);
|
||||
break;
|
||||
case CalpontSystemCatalog::UBIGINT:
|
||||
if (row.equals<8>(UBIGINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.uintVal = row.getUintField<8>(fInputIndex);
|
||||
break;
|
||||
case CalpontSystemCatalog::INT:
|
||||
case CalpontSystemCatalog::MEDINT:
|
||||
if (row.equals<4>(INTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getIntField<4>(fInputIndex);
|
||||
break;
|
||||
case CalpontSystemCatalog::UINT:
|
||||
case CalpontSystemCatalog::UMEDINT:
|
||||
if (row.equals<4>(UINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.uintVal = row.getUintField<4>(fInputIndex);
|
||||
break;
|
||||
case CalpontSystemCatalog::SMALLINT:
|
||||
if (row.equals<2>(SMALLINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getIntField<2>(fInputIndex);
|
||||
break;
|
||||
case CalpontSystemCatalog::USMALLINT:
|
||||
if (row.equals<2>(USMALLINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.uintVal = row.getUintField<2>(fInputIndex);
|
||||
break;
|
||||
case CalpontSystemCatalog::TINYINT:
|
||||
if (row.equals<1>(TINYINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getIntField<1>(fInputIndex);
|
||||
break;
|
||||
case CalpontSystemCatalog::UTINYINT:
|
||||
if (row.equals<1>(UTINYINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.uintVal = row.getUintField<1>(fInputIndex);
|
||||
break;
|
||||
//In this case, we're trying to load a double output column with float data. This is the
|
||||
// case when you do sum(floatcol), e.g.
|
||||
case CalpontSystemCatalog::FLOAT:
|
||||
case CalpontSystemCatalog::UFLOAT:
|
||||
if (row.equals<4>(FLOATNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.floatVal = row.getFloatField(fInputIndex);
|
||||
break;
|
||||
case CalpontSystemCatalog::DOUBLE:
|
||||
case CalpontSystemCatalog::UDOUBLE:
|
||||
if (row.equals<8>(DOUBLENULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.doubleVal = row.getDoubleField(fInputIndex);
|
||||
break;
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
switch (fResultType.colWidth)
|
||||
{
|
||||
case 1:
|
||||
if (row.equals<1>(TINYINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
{
|
||||
fResult.decimalVal.value = row.getIntField<1>(fInputIndex);
|
||||
fResult.decimalVal.scale = (unsigned)fResultType.scale;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (row.equals<2>(SMALLINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
{
|
||||
fResult.decimalVal.value = row.getIntField<2>(fInputIndex);
|
||||
fResult.decimalVal.scale = (unsigned)fResultType.scale;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (row.equals<4>(INTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
{
|
||||
fResult.decimalVal.value = row.getIntField<4>(fInputIndex);
|
||||
fResult.decimalVal.scale = (unsigned)fResultType.scale;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (row.equals<8>(BIGINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
{
|
||||
fResult.decimalVal.value = (int64_t)row.getUintField<8>(fInputIndex);
|
||||
fResult.decimalVal.scale = (unsigned)fResultType.scale;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CalpontSystemCatalog::VARBINARY:
|
||||
case CalpontSystemCatalog::BLOB:
|
||||
isNull = true;
|
||||
break;
|
||||
default: // treat as int64
|
||||
if (row.equals<8>(BIGINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getUintField<8>(fInputIndex);
|
||||
break;
|
||||
}
|
||||
switch (fResultType.colDataType)
|
||||
{
|
||||
case CalpontSystemCatalog::DATE:
|
||||
if (row.equals<4>(DATENULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getUintField<4>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::DATETIME:
|
||||
if (row.equals<8>(DATETIMENULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getUintField<8>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::CHAR:
|
||||
case CalpontSystemCatalog::VARCHAR:
|
||||
case CalpontSystemCatalog::STRINT:
|
||||
case CalpontSystemCatalog::TEXT:
|
||||
switch (row.getColumnWidth(fInputIndex))
|
||||
{
|
||||
case 1:
|
||||
if (row.equals<1>(CHAR1NULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.origIntVal = row.getUintField<1>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (row.equals<2>(CHAR2NULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.origIntVal = row.getUintField<2>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case 4:
|
||||
if (row.equals<4>(CHAR4NULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.origIntVal = row.getUintField<4>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
if (row.equals<8>(CHAR8NULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.origIntVal = row.getUintField<8>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if (row.equals(CPNULLSTRMARK, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.strVal = row.getStringField(fInputIndex);
|
||||
|
||||
// stringColVal is padded with '\0' to colWidth so can't use str.length()
|
||||
if (strlen(fResult.strVal.c_str()) == 0)
|
||||
isNull = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (fResultType.colDataType == CalpontSystemCatalog::STRINT)
|
||||
fResult.intVal = uint64ToStr(fResult.origIntVal);
|
||||
else
|
||||
fResult.intVal = atoll((char*)&fResult.origIntVal);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::BIGINT:
|
||||
if (row.equals<8>(BIGINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getIntField<8>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::UBIGINT:
|
||||
if (row.equals<8>(UBIGINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.uintVal = row.getUintField<8>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::INT:
|
||||
case CalpontSystemCatalog::MEDINT:
|
||||
if (row.equals<4>(INTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getIntField<4>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::UINT:
|
||||
case CalpontSystemCatalog::UMEDINT:
|
||||
if (row.equals<4>(UINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.uintVal = row.getUintField<4>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::SMALLINT:
|
||||
if (row.equals<2>(SMALLINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getIntField<2>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::USMALLINT:
|
||||
if (row.equals<2>(USMALLINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.uintVal = row.getUintField<2>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::TINYINT:
|
||||
if (row.equals<1>(TINYINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getIntField<1>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::UTINYINT:
|
||||
if (row.equals<1>(UTINYINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.uintVal = row.getUintField<1>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
//In this case, we're trying to load a double output column with float data. This is the
|
||||
// case when you do sum(floatcol), e.g.
|
||||
case CalpontSystemCatalog::FLOAT:
|
||||
case CalpontSystemCatalog::UFLOAT:
|
||||
if (row.equals<4>(FLOATNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.floatVal = row.getFloatField(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::DOUBLE:
|
||||
case CalpontSystemCatalog::UDOUBLE:
|
||||
if (row.equals<8>(DOUBLENULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.doubleVal = row.getDoubleField(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
switch (fResultType.colWidth)
|
||||
{
|
||||
case 1:
|
||||
if (row.equals<1>(TINYINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
{
|
||||
fResult.decimalVal.value = row.getIntField<1>(fInputIndex);
|
||||
fResult.decimalVal.scale = (unsigned)fResultType.scale;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (row.equals<2>(SMALLINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
{
|
||||
fResult.decimalVal.value = row.getIntField<2>(fInputIndex);
|
||||
fResult.decimalVal.scale = (unsigned)fResultType.scale;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (row.equals<4>(INTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
{
|
||||
fResult.decimalVal.value = row.getIntField<4>(fInputIndex);
|
||||
fResult.decimalVal.scale = (unsigned)fResultType.scale;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if (row.equals<8>(BIGINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
{
|
||||
fResult.decimalVal.value = (int64_t)row.getUintField<8>(fInputIndex);
|
||||
fResult.decimalVal.scale = (unsigned)fResultType.scale;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::VARBINARY:
|
||||
case CalpontSystemCatalog::BLOB:
|
||||
isNull = true;
|
||||
break;
|
||||
|
||||
default: // treat as int64
|
||||
if (row.equals<8>(BIGINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getUintField<8>(fInputIndex);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/
|
||||
AggregateColumn::AggOp AggregateColumn::agname2num(const string& agname)
|
||||
{
|
||||
/*
|
||||
NOOP = 0,
|
||||
COUNT_ASTERISK,
|
||||
COUNT,
|
||||
SUM,
|
||||
AVG,
|
||||
MIN,
|
||||
MAX,
|
||||
CONSTANT,
|
||||
DISTINCT_COUNT,
|
||||
DISTINCT_SUM,
|
||||
DISTINCT_AVG,
|
||||
STDDEV_POP,
|
||||
STDDEV_SAMP,
|
||||
VAR_POP,
|
||||
VAR_SAMP,
|
||||
BIT_AND,
|
||||
BIT_OR,
|
||||
BIT_XOR,
|
||||
GROUP_CONCAT
|
||||
*/
|
||||
string lfn(agname);
|
||||
algorithm::to_lower(lfn);
|
||||
if (lfn == "count(*)")
|
||||
return COUNT_ASTERISK;
|
||||
if (lfn == "count")
|
||||
return COUNT;
|
||||
if (lfn == "sum")
|
||||
return SUM;
|
||||
if (lfn == "avg")
|
||||
return AVG;
|
||||
if (lfn == "min")
|
||||
return MIN;
|
||||
if (lfn == "max")
|
||||
return MAX;
|
||||
if (lfn == "std")
|
||||
return STDDEV_POP;
|
||||
if (lfn == "stddev_pop")
|
||||
return STDDEV_POP;
|
||||
if (lfn == "stddev_samp")
|
||||
return STDDEV_SAMP;
|
||||
if (lfn == "stddev")
|
||||
return STDDEV_POP;
|
||||
if (lfn == "var_pop")
|
||||
return VAR_POP;
|
||||
if (lfn == "var_samp")
|
||||
return VAR_SAMP;
|
||||
if (lfn == "variance")
|
||||
return VAR_POP;
|
||||
return NOOP;
|
||||
/*
|
||||
NOOP = 0,
|
||||
COUNT_ASTERISK,
|
||||
COUNT,
|
||||
SUM,
|
||||
AVG,
|
||||
MIN,
|
||||
MAX,
|
||||
CONSTANT,
|
||||
DISTINCT_COUNT,
|
||||
DISTINCT_SUM,
|
||||
DISTINCT_AVG,
|
||||
STDDEV_POP,
|
||||
STDDEV_SAMP,
|
||||
VAR_POP,
|
||||
VAR_SAMP,
|
||||
BIT_AND,
|
||||
BIT_OR,
|
||||
BIT_XOR,
|
||||
GROUP_CONCAT
|
||||
*/
|
||||
string lfn(agname);
|
||||
algorithm::to_lower(lfn);
|
||||
|
||||
if (lfn == "count(*)")
|
||||
return COUNT_ASTERISK;
|
||||
|
||||
if (lfn == "count")
|
||||
return COUNT;
|
||||
|
||||
if (lfn == "sum")
|
||||
return SUM;
|
||||
|
||||
if (lfn == "avg")
|
||||
return AVG;
|
||||
|
||||
if (lfn == "min")
|
||||
return MIN;
|
||||
|
||||
if (lfn == "max")
|
||||
return MAX;
|
||||
|
||||
if (lfn == "std")
|
||||
return STDDEV_POP;
|
||||
|
||||
if (lfn == "stddev_pop")
|
||||
return STDDEV_POP;
|
||||
|
||||
if (lfn == "stddev_samp")
|
||||
return STDDEV_SAMP;
|
||||
|
||||
if (lfn == "stddev")
|
||||
return STDDEV_POP;
|
||||
|
||||
if (lfn == "var_pop")
|
||||
return VAR_POP;
|
||||
|
||||
if (lfn == "var_samp")
|
||||
return VAR_SAMP;
|
||||
|
||||
if (lfn == "variance")
|
||||
return VAR_POP;
|
||||
|
||||
return NOOP;
|
||||
}
|
||||
|
||||
} // namespace execplan
|
||||
|
||||
616
dbcon/execplan/aggregatecolumn.h
Executable file → Normal file
616
dbcon/execplan/aggregatecolumn.h
Executable file → Normal file
@@ -29,14 +29,16 @@
|
||||
#include "calpontselectexecutionplan.h"
|
||||
#include "returnedcolumn.h"
|
||||
|
||||
namespace messageqcpp {
|
||||
namespace messageqcpp
|
||||
{
|
||||
class ByteStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Namespace
|
||||
*/
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief A class to represent a aggregate return column
|
||||
@@ -44,333 +46,379 @@ namespace execplan {
|
||||
* This class is a specialization of class ReturnedColumn that
|
||||
* handles an aggregate function call (e.g., SUM, COUNT, MIN, MAX).
|
||||
*/
|
||||
class AggregateColumn : public ReturnedColumn {
|
||||
class AggregateColumn : public ReturnedColumn
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* AggOp enum
|
||||
*/
|
||||
enum AggOp
|
||||
{
|
||||
NOOP = 0,
|
||||
COUNT_ASTERISK,
|
||||
COUNT,
|
||||
SUM,
|
||||
AVG,
|
||||
MIN,
|
||||
MAX,
|
||||
CONSTANT,
|
||||
DISTINCT_COUNT,
|
||||
DISTINCT_SUM,
|
||||
DISTINCT_AVG,
|
||||
STDDEV_POP,
|
||||
STDDEV_SAMP,
|
||||
VAR_POP,
|
||||
VAR_SAMP,
|
||||
BIT_AND,
|
||||
BIT_OR,
|
||||
BIT_XOR,
|
||||
GROUP_CONCAT,
|
||||
UDAF
|
||||
};
|
||||
/**
|
||||
* AggOp enum
|
||||
*/
|
||||
enum AggOp
|
||||
{
|
||||
NOOP = 0,
|
||||
COUNT_ASTERISK,
|
||||
COUNT,
|
||||
SUM,
|
||||
AVG,
|
||||
MIN,
|
||||
MAX,
|
||||
CONSTANT,
|
||||
DISTINCT_COUNT,
|
||||
DISTINCT_SUM,
|
||||
DISTINCT_AVG,
|
||||
STDDEV_POP,
|
||||
STDDEV_SAMP,
|
||||
VAR_POP,
|
||||
VAR_SAMP,
|
||||
BIT_AND,
|
||||
BIT_OR,
|
||||
BIT_XOR,
|
||||
GROUP_CONCAT,
|
||||
UDAF
|
||||
};
|
||||
|
||||
/**
|
||||
* typedef
|
||||
*/
|
||||
typedef std::vector<SRCP> ColumnList;
|
||||
/*
|
||||
* Constructors
|
||||
*/
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
AggregateColumn();
|
||||
/**
|
||||
* typedef
|
||||
*/
|
||||
typedef std::vector<SRCP> ColumnList;
|
||||
/*
|
||||
* Constructors
|
||||
*/
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
AggregateColumn();
|
||||
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
AggregateColumn(const uint32_t sessionID);
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
AggregateColumn(const uint32_t sessionID);
|
||||
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
AggregateColumn(const AggOp aggop, ReturnedColumn* parm, const uint32_t sessionID=0);
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
AggregateColumn(const AggOp aggop, ReturnedColumn* parm, const uint32_t sessionID = 0);
|
||||
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
AggregateColumn(const AggOp aggop, const std::string& content, const uint32_t sessionID=0);
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
AggregateColumn(const AggOp aggop, const std::string& content, const uint32_t sessionID = 0);
|
||||
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
AggregateColumn(const std::string& functionName, ReturnedColumn* parm, const uint32_t sessionID=0);
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
AggregateColumn(const std::string& functionName, ReturnedColumn* parm, const uint32_t sessionID = 0);
|
||||
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
AggregateColumn(const std::string& functionName, const std::string& content, const uint32_t sessionID=0);
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
AggregateColumn(const std::string& functionName, const std::string& content, const uint32_t sessionID = 0);
|
||||
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
AggregateColumn( const AggregateColumn& rhs, const uint32_t sessionID=0 );
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
AggregateColumn( const AggregateColumn& rhs, const uint32_t sessionID = 0 );
|
||||
|
||||
/**
|
||||
* Destructors
|
||||
*/
|
||||
virtual ~AggregateColumn() { }
|
||||
/**
|
||||
* Destructors
|
||||
*/
|
||||
virtual ~AggregateColumn() { }
|
||||
|
||||
/**
|
||||
* Accessor Methods
|
||||
*/
|
||||
virtual const std::string functionName() const
|
||||
{
|
||||
return fFunctionName;
|
||||
}
|
||||
/**
|
||||
* Accessor Methods
|
||||
*/
|
||||
virtual const std::string functionName() const
|
||||
{
|
||||
return fFunctionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual void functionName(const std::string& functionName)
|
||||
{
|
||||
fFunctionName = functionName;
|
||||
}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual void functionName(const std::string& functionName)
|
||||
{
|
||||
fFunctionName = functionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual const uint8_t aggOp() const {return fAggOp;}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual void aggOp(const uint8_t aggOp) {fAggOp = aggOp;}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual const uint8_t aggOp() const
|
||||
{
|
||||
return fAggOp;
|
||||
}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual void aggOp(const uint8_t aggOp)
|
||||
{
|
||||
fAggOp = aggOp;
|
||||
}
|
||||
|
||||
/** get function parms
|
||||
*
|
||||
* set the function parms from this object
|
||||
*/
|
||||
virtual const SRCP functionParms() const
|
||||
{
|
||||
return fFunctionParms;
|
||||
}
|
||||
/** get function parms
|
||||
*
|
||||
* set the function parms from this object
|
||||
*/
|
||||
virtual const SRCP functionParms() const
|
||||
{
|
||||
return fFunctionParms;
|
||||
}
|
||||
|
||||
/** set function parms
|
||||
*
|
||||
* set the function parms for this object
|
||||
*/
|
||||
virtual void functionParms(const SRCP& functionParms)
|
||||
{
|
||||
fFunctionParms = functionParms;
|
||||
}
|
||||
/** set function parms
|
||||
*
|
||||
* set the function parms for this object
|
||||
*/
|
||||
virtual void functionParms(const SRCP& functionParms)
|
||||
{
|
||||
fFunctionParms = functionParms;
|
||||
}
|
||||
|
||||
/** return a copy of this pointer
|
||||
*
|
||||
* deep copy of this pointer and return the copy
|
||||
*/
|
||||
inline virtual AggregateColumn* clone() const
|
||||
{
|
||||
return new AggregateColumn (*this);
|
||||
}
|
||||
/** return a copy of this pointer
|
||||
*
|
||||
* deep copy of this pointer and return the copy
|
||||
*/
|
||||
inline virtual AggregateColumn* clone() const
|
||||
{
|
||||
return new AggregateColumn (*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* table alias name
|
||||
*/
|
||||
virtual const std::string tableAlias() const { return fTableAlias; }
|
||||
/**
|
||||
* table alias name
|
||||
*/
|
||||
virtual void tableAlias (const std::string& tableAlias) { fTableAlias = tableAlias; }
|
||||
/**
|
||||
* table alias name
|
||||
*/
|
||||
virtual const std::string tableAlias() const
|
||||
{
|
||||
return fTableAlias;
|
||||
}
|
||||
/**
|
||||
* table alias name
|
||||
*/
|
||||
virtual void tableAlias (const std::string& tableAlias)
|
||||
{
|
||||
fTableAlias = tableAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* ASC flag
|
||||
*/
|
||||
inline virtual const bool asc() const { return fAsc; }
|
||||
/**
|
||||
* ASC flag
|
||||
*/
|
||||
inline virtual void asc(const bool asc) { fAsc = asc; }
|
||||
/**
|
||||
* ASC flag
|
||||
*/
|
||||
inline virtual const bool asc() const
|
||||
{
|
||||
return fAsc;
|
||||
}
|
||||
/**
|
||||
* ASC flag
|
||||
*/
|
||||
inline virtual void asc(const bool asc)
|
||||
{
|
||||
fAsc = asc;
|
||||
}
|
||||
|
||||
/**
|
||||
* fData: SQL representation of this object
|
||||
*/
|
||||
virtual const std::string data() const { return fData; }
|
||||
/**
|
||||
* fData: SQL representation of this object
|
||||
*/
|
||||
virtual void data(const std::string& data) { fData = data; }
|
||||
/**
|
||||
* fData: SQL representation of this object
|
||||
*/
|
||||
virtual const std::string data() const
|
||||
{
|
||||
return fData;
|
||||
}
|
||||
/**
|
||||
* fData: SQL representation of this object
|
||||
*/
|
||||
virtual void data(const std::string& data)
|
||||
{
|
||||
fData = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded stream operator
|
||||
*/
|
||||
virtual const std::string toString() const;
|
||||
/**
|
||||
* Overloaded stream operator
|
||||
*/
|
||||
virtual const std::string toString() const;
|
||||
|
||||
/**
|
||||
* Serialize interface
|
||||
*/
|
||||
virtual void serialize(messageqcpp::ByteStream&) const;
|
||||
/**
|
||||
* Serialize interface
|
||||
*/
|
||||
virtual void unserialize(messageqcpp::ByteStream&);
|
||||
/**
|
||||
* Serialize interface
|
||||
*/
|
||||
virtual void serialize(messageqcpp::ByteStream&) const;
|
||||
/**
|
||||
* Serialize interface
|
||||
*/
|
||||
virtual void unserialize(messageqcpp::ByteStream&);
|
||||
|
||||
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
|
||||
*
|
||||
* Do a deep, strict (as opposed to semantic) equivalence test.
|
||||
* @return true iff every member of t is a duplicate copy of every member of this; false otherwise
|
||||
*/
|
||||
virtual bool operator==(const TreeNode* t) const;
|
||||
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
|
||||
*
|
||||
* Do a deep, strict (as opposed to semantic) equivalence test.
|
||||
* @return true iff every member of t is a duplicate copy of every member of this; false otherwise
|
||||
*/
|
||||
virtual bool operator==(const TreeNode* t) const;
|
||||
|
||||
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
|
||||
*
|
||||
* Do a deep, strict (as opposed to semantic) equivalence test.
|
||||
* @return true iff every member of t is a duplicate copy of every member of this; false otherwise
|
||||
*/
|
||||
virtual bool operator==(const AggregateColumn& t) const;
|
||||
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
|
||||
*
|
||||
* Do a deep, strict (as opposed to semantic) equivalence test.
|
||||
* @return true iff every member of t is a duplicate copy of every member of this; false otherwise
|
||||
*/
|
||||
virtual bool operator==(const AggregateColumn& t) const;
|
||||
|
||||
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
|
||||
*
|
||||
* Do a deep, strict (as opposed to semantic) equivalence test.
|
||||
* @return false iff every member of t is a duplicate copy of every member of this; true otherwise
|
||||
*/
|
||||
virtual bool operator!=(const TreeNode* t) const;
|
||||
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
|
||||
*
|
||||
* Do a deep, strict (as opposed to semantic) equivalence test.
|
||||
* @return false iff every member of t is a duplicate copy of every member of this; true otherwise
|
||||
*/
|
||||
virtual bool operator!=(const TreeNode* t) const;
|
||||
|
||||
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
|
||||
*
|
||||
* Do a deep, strict (as opposed to semantic) equivalence test.
|
||||
* @return false iff every member of t is a duplicate copy of every member of this; true otherwise
|
||||
*/
|
||||
virtual bool operator!=(const AggregateColumn& t) const;
|
||||
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
|
||||
*
|
||||
* Do a deep, strict (as opposed to semantic) equivalence test.
|
||||
* @return false iff every member of t is a duplicate copy of every member of this; true otherwise
|
||||
*/
|
||||
virtual bool operator!=(const AggregateColumn& t) const;
|
||||
|
||||
/** @brief push back arg to group by column list*/
|
||||
virtual void addGroupByCol(SRCP ac) {fGroupByColList.push_back(ac);}
|
||||
/** @brief push back arg to group by column list*/
|
||||
virtual void addGroupByCol(SRCP ac)
|
||||
{
|
||||
fGroupByColList.push_back(ac);
|
||||
}
|
||||
|
||||
/** @brief push back arg to project by column list*/
|
||||
virtual void addProjectCol(SRCP ac) {fProjectColList.push_back(ac);}
|
||||
/** @brief push back arg to project by column list*/
|
||||
virtual void addProjectCol(SRCP ac)
|
||||
{
|
||||
fProjectColList.push_back(ac);
|
||||
}
|
||||
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual const ColumnList& groupByColList() const { return fGroupByColList;}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual const ColumnList& projectColList() const { return fProjectColList;}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual const ColumnList& groupByColList() const
|
||||
{
|
||||
return fGroupByColList;
|
||||
}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual const ColumnList& projectColList() const
|
||||
{
|
||||
return fProjectColList;
|
||||
}
|
||||
|
||||
/** @brief constant argument for aggregate with constant */
|
||||
inline const SRCP constCol() const { return fConstCol; }
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
inline void constCol(const SRCP& constCol) { fConstCol = constCol; }
|
||||
/** @brief constant argument for aggregate with constant */
|
||||
inline const SRCP constCol() const
|
||||
{
|
||||
return fConstCol;
|
||||
}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
inline void constCol(const SRCP& constCol)
|
||||
{
|
||||
fConstCol = constCol;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert an aggregate name to an AggOp enum
|
||||
*/
|
||||
static AggOp agname2num(const std::string&);
|
||||
/**
|
||||
* convert an aggregate name to an AggOp enum
|
||||
*/
|
||||
static AggOp agname2num(const std::string&);
|
||||
|
||||
virtual bool hasAggregate();
|
||||
virtual bool hasWindowFunc() {return false;}
|
||||
virtual bool hasAggregate();
|
||||
virtual bool hasWindowFunc()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string fFunctionName; // deprecated field
|
||||
uint8_t fAggOp;
|
||||
std::string fFunctionName; // deprecated field
|
||||
uint8_t fAggOp;
|
||||
|
||||
/**
|
||||
* A ReturnedColumn objects that are the arguments to this function
|
||||
*/
|
||||
SRCP fFunctionParms;
|
||||
/**
|
||||
* A ReturnedColumn objects that are the arguments to this function
|
||||
*/
|
||||
SRCP fFunctionParms;
|
||||
|
||||
/** table alias
|
||||
* A string to represent table alias name which contains this column
|
||||
*/
|
||||
std:: string fTableAlias;
|
||||
/** table alias
|
||||
* A string to represent table alias name which contains this column
|
||||
*/
|
||||
std:: string fTableAlias;
|
||||
|
||||
/**
|
||||
* Flag to indicate asc or desc order for order by column
|
||||
*/
|
||||
bool fAsc;
|
||||
std::string fData;
|
||||
ColumnList fGroupByColList;
|
||||
ColumnList fProjectColList;
|
||||
SRCP fConstCol;
|
||||
/**
|
||||
* Flag to indicate asc or desc order for order by column
|
||||
*/
|
||||
bool fAsc;
|
||||
std::string fData;
|
||||
ColumnList fGroupByColList;
|
||||
ColumnList fProjectColList;
|
||||
SRCP fConstCol;
|
||||
|
||||
public:
|
||||
/***********************************************************
|
||||
* F&E framework *
|
||||
***********************************************************/
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual const std::string& getStrVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getStrVal();
|
||||
}
|
||||
/***********************************************************
|
||||
* F&E framework *
|
||||
***********************************************************/
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual const std::string& getStrVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getStrVal();
|
||||
}
|
||||
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual int64_t getIntVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getIntVal();
|
||||
}
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual int64_t getIntVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getIntVal();
|
||||
}
|
||||
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual uint64_t getUintVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getUintVal();
|
||||
}
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual uint64_t getUintVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getUintVal();
|
||||
}
|
||||
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual float getFloatVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getFloatVal();
|
||||
}
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual float getFloatVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getFloatVal();
|
||||
}
|
||||
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual double getDoubleVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getDoubleVal();
|
||||
}
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual double getDoubleVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getDoubleVal();
|
||||
}
|
||||
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual IDB_Decimal getDecimalVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getDecimalVal();
|
||||
}
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual int32_t getDateIntVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getDateIntVal();
|
||||
}
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual int64_t getDatetimeIntVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getDatetimeIntVal();
|
||||
}
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual IDB_Decimal getDecimalVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getDecimalVal();
|
||||
}
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual int32_t getDateIntVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getDateIntVal();
|
||||
}
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
virtual int64_t getDatetimeIntVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getDatetimeIntVal();
|
||||
}
|
||||
|
||||
private:
|
||||
void evaluate(rowgroup::Row& row, bool& isNull);
|
||||
void evaluate(rowgroup::Row& row, bool& isNull);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user