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"
|
#include "ddlpkg.h"
|
||||||
#undef DDLPKG_DLLEXPORT
|
#undef DDLPKG_DLLEXPORT
|
||||||
|
|
||||||
namespace ddlpackage {
|
namespace ddlpackage
|
||||||
using namespace std;
|
{
|
||||||
|
using namespace std;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AtaAddColumn::~AtaAddColumn()
|
AlterTableStatement::AlterTableStatement(QualifiedName* qName, AlterTableActionList* ataList):
|
||||||
{
|
fTableName(qName),
|
||||||
delete fColumnDef;
|
fActions(*ataList)
|
||||||
}
|
{
|
||||||
|
delete ataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
AlterTableStatement::~AlterTableStatement()
|
||||||
|
{
|
||||||
|
delete fTableName;
|
||||||
|
AlterTableActionList::iterator itr;
|
||||||
|
|
||||||
/** @brief ostream output */
|
for (itr = fActions.begin(); itr != fActions.end(); ++itr)
|
||||||
std::ostream& AtaAddColumn::put(std::ostream& os) const
|
{
|
||||||
{
|
delete *itr;
|
||||||
os << "Add Column" << endl;
|
}
|
||||||
os << *fColumnDef << 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;
|
||||||
|
}
|
||||||
|
|
||||||
AtaDropColumn::AtaDropColumn(std::string columnName, DDL_REFERENTIAL_ACTION dropBehavior) :
|
return os;
|
||||||
fColumnName(columnName),
|
}
|
||||||
fDropBehavior(dropBehavior)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream& AtaDropColumn::put(std::ostream& os) const
|
|
||||||
{
|
|
||||||
os << "Drop Column: " << fColumnName << " "
|
|
||||||
<< ReferentialActionStrings[fDropBehavior];
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AtaModifyColumnType::~AtaModifyColumnType()
|
|
||||||
{
|
|
||||||
delete fColumnType;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream& AtaModifyColumnType::put(std::ostream& os) const
|
/** @brief Format to ostream. Diagnostic. */
|
||||||
{
|
std::ostream& AlterTableAction::put(std::ostream& os) const
|
||||||
os << "Modify column type: " << fName << " " << *fColumnType;
|
{
|
||||||
|
os << "AlterTableAction put stub";
|
||||||
return os;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
AtaRenameColumn::~AtaRenameColumn()
|
AtaAddColumn::~AtaAddColumn()
|
||||||
{
|
{
|
||||||
delete fNewType;
|
delete fColumnDef;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AtaRenameTable::AtaRenameTable(QualifiedName *qualifiedName) :
|
|
||||||
fQualifiedName(qualifiedName)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/** @brief ostream output */
|
||||||
|
std::ostream& AtaAddColumn::put(std::ostream& os) const
|
||||||
|
{
|
||||||
|
os << "Add Column" << endl;
|
||||||
|
os << *fColumnDef << endl;
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
std::ostream& AtaTableComment::put(std::ostream& os) const
|
|
||||||
{
|
|
||||||
os << "TableComment: " << fTableComment << endl;
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AtaAddColumns::~AtaAddColumns()
|
AtaDropColumn::AtaDropColumn(std::string columnName, DDL_REFERENTIAL_ACTION dropBehavior) :
|
||||||
{
|
fColumnName(columnName),
|
||||||
ColumnDefList::iterator itr;
|
fDropBehavior(dropBehavior)
|
||||||
for(itr=fColumns.begin(); itr != fColumns.end(); itr++)
|
{
|
||||||
delete *itr;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
std::ostream& AtaDropColumn::put(std::ostream& os) const
|
||||||
|
{
|
||||||
|
os << "Drop Column: " << fColumnName << " "
|
||||||
|
<< ReferentialActionStrings[fDropBehavior];
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
AtaAddColumns::AtaAddColumns(TableElementList *tableElements)
|
|
||||||
{
|
AtaModifyColumnType::~AtaModifyColumnType()
|
||||||
/* It is convenient to reuse the grammar rules for
|
{
|
||||||
table_element_list, and we do. So, it is possible for
|
delete fColumnType;
|
||||||
there to be errant table constraint defs in the input list.
|
}
|
||||||
We ignore them. That is all we are doing here.
|
|
||||||
*/
|
std::ostream& AtaModifyColumnType::put(std::ostream& os) const
|
||||||
ColumnDef *column;
|
{
|
||||||
TableElementList::const_iterator itr;
|
os << "Modify column type: " << fName << " " << *fColumnType;
|
||||||
for(itr = tableElements->begin();
|
|
||||||
itr != tableElements->end();
|
return os;
|
||||||
++itr)
|
}
|
||||||
{
|
|
||||||
column = dynamic_cast<ColumnDef *>(*itr);
|
|
||||||
if(0 != column) {
|
|
||||||
fColumns.push_back(column);
|
AtaRenameColumn::~AtaRenameColumn()
|
||||||
}
|
{
|
||||||
}
|
delete fNewType;
|
||||||
delete tableElements;
|
}
|
||||||
}
|
|
||||||
|
std::ostream& AtaRenameColumn::put(std::ostream& os) const
|
||||||
std::ostream& AtaAddColumns::put(std::ostream& os) const
|
{
|
||||||
{
|
os << "Rename Column: " << fName << " -> " << fNewName << " (" << *fNewType << ')';
|
||||||
os << "Add Columns: " << endl;
|
return os;
|
||||||
ColumnDefList::const_iterator itr;
|
}
|
||||||
for(itr = fColumns.begin();
|
|
||||||
itr != fColumns.end();
|
|
||||||
++itr)
|
|
||||||
{
|
AtaSetColumnDefault::AtaSetColumnDefault(const char* colName, ColumnDefaultValue* defaultValue) :
|
||||||
os << **itr << endl;
|
fColumnName(colName),
|
||||||
}
|
fDefaultValue(defaultValue)
|
||||||
|
{
|
||||||
return os;
|
}
|
||||||
}
|
|
||||||
//////////////////////////
|
|
||||||
|
AtaSetColumnDefault::~AtaSetColumnDefault()
|
||||||
AtaDropColumns::~AtaDropColumns()
|
{
|
||||||
{
|
delete fDefaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AtaDropColumns::AtaDropColumns(ColumnNameList *columnNames)
|
std::ostream& AtaSetColumnDefault::put(std::ostream& os) const
|
||||||
{
|
{
|
||||||
fColumns = *columnNames;
|
os << "Set Column Default: " << fColumnName << " "
|
||||||
delete columnNames;
|
<< *fDefaultValue << endl;
|
||||||
}
|
return os;
|
||||||
|
}
|
||||||
std::ostream& AtaDropColumns::put(std::ostream& os) const
|
|
||||||
{
|
|
||||||
os << "Drop Columns: " << endl;
|
|
||||||
ColumnNameList::const_iterator itr;
|
|
||||||
for(itr = fColumns.begin();
|
AtaDropColumnDefault::AtaDropColumnDefault(const char* colName) :
|
||||||
itr != fColumns.end();
|
fColumnName(colName)
|
||||||
++itr)
|
{
|
||||||
{
|
}
|
||||||
os << *itr << endl;
|
|
||||||
}
|
std::ostream& AtaDropColumnDefault::put(std::ostream& os) const
|
||||||
|
{
|
||||||
return os;
|
os << "Drop Column Default: " << fColumnName << " ";
|
||||||
}
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AtaAddTableConstraint::AtaAddTableConstraint(TableConstraintDef *tableConstraint) :
|
|
||||||
fTableConstraint(tableConstraint)
|
AtaRenameTable::AtaRenameTable(QualifiedName* qualifiedName) :
|
||||||
{
|
fQualifiedName(qualifiedName)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
AtaAddTableConstraint::~AtaAddTableConstraint()
|
|
||||||
{
|
AtaRenameTable::~AtaRenameTable()
|
||||||
delete fTableConstraint;
|
{
|
||||||
}
|
delete fQualifiedName;
|
||||||
|
}
|
||||||
|
|
||||||
std::ostream& AtaAddTableConstraint::put(std::ostream& os) const
|
|
||||||
{
|
std::ostream& AtaRenameTable::put(std::ostream& os) const
|
||||||
os << "Add Table Constraint:" << endl;
|
{
|
||||||
os << *fTableConstraint << endl;
|
os << "Rename Table: " << *fQualifiedName << endl;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AtaTableComment::AtaTableComment(const char* tableComment) :
|
||||||
AtaDropTableConstraint::AtaDropTableConstraint
|
fTableComment(tableComment)
|
||||||
(const char *constraintName, DDL_REFERENTIAL_ACTION dropBehavior) :
|
{
|
||||||
fConstraintName(constraintName),
|
}
|
||||||
fDropBehavior(dropBehavior)
|
|
||||||
{
|
AtaTableComment::~AtaTableComment()
|
||||||
}
|
{
|
||||||
|
}
|
||||||
std::ostream& AtaDropTableConstraint::put(std::ostream& os) const
|
|
||||||
{
|
|
||||||
os << "Drop Table Constraint: " << fConstraintName;
|
std::ostream& AtaTableComment::put(std::ostream& os) const
|
||||||
return os;
|
{
|
||||||
}
|
os << "TableComment: " << fTableComment << endl;
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AtaAddColumns::~AtaAddColumns()
|
||||||
|
{
|
||||||
|
ColumnDefList::iterator itr;
|
||||||
|
|
||||||
|
for (itr = fColumns.begin(); itr != fColumns.end(); itr++)
|
||||||
|
delete *itr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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"
|
#include "ddlpkg.h"
|
||||||
#undef DDLPKG_DLLEXPORT
|
#undef DDLPKG_DLLEXPORT
|
||||||
|
|
||||||
namespace ddlpackage {
|
namespace ddlpackage
|
||||||
|
{
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
ColumnDef::~ColumnDef()
|
ColumnDef::~ColumnDef()
|
||||||
{
|
{
|
||||||
delete fType;
|
delete fType;
|
||||||
delete fDefaultValue;
|
delete fDefaultValue;
|
||||||
ColumnConstraintList::iterator itr;
|
ColumnConstraintList::iterator itr;
|
||||||
for(itr=fConstraints.begin(); itr != fConstraints.end(); ++itr) {
|
|
||||||
delete *itr;
|
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),
|
ColumnDef::ColumnDef(const char* name, ColumnType* columnType, ColumnConstraintList* constraints,
|
||||||
fType(columnType),
|
ColumnDefaultValue* defaultValue, const char* comment ) :
|
||||||
fDefaultValue(defaultValue)
|
SchemaObject(name),
|
||||||
{
|
fType(columnType),
|
||||||
if(constraints) {
|
fDefaultValue(defaultValue)
|
||||||
fConstraints = *constraints;
|
{
|
||||||
delete constraints;
|
if (constraints)
|
||||||
}
|
{
|
||||||
if ( comment )
|
fConstraints = *constraints;
|
||||||
fComment = comment;
|
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 ColumnDef& column)
|
||||||
|
{
|
||||||
|
os << "Column: " << column.fName << " " << *column.fType;
|
||||||
|
|
||||||
|
if (column.fDefaultValue)
|
||||||
|
{
|
||||||
|
os << " def=";
|
||||||
|
|
||||||
|
if (column.fDefaultValue->fNull)
|
||||||
|
os << "NULL";
|
||||||
|
else
|
||||||
|
os << column.fDefaultValue->fValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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 << "\"";
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& os, const ColumnDefaultValue& defaultValue)
|
||||||
|
{
|
||||||
|
os << " def=";
|
||||||
|
|
||||||
|
if (defaultValue.fNull)
|
||||||
|
os << "NULL";
|
||||||
|
else
|
||||||
|
os << defaultValue.fValue;
|
||||||
|
|
||||||
|
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;
|
|
||||||
|
|
||||||
if(column.fDefaultValue) {
|
|
||||||
os << " def=";
|
|
||||||
|
|
||||||
if (column.fDefaultValue->fNull)
|
|
||||||
os << "NULL";
|
|
||||||
else
|
|
||||||
os << column.fDefaultValue->fValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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 << "\"";
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream& os, const ColumnDefaultValue &defaultValue)
|
|
||||||
{
|
|
||||||
os << " def=";
|
|
||||||
|
|
||||||
if (defaultValue.fNull)
|
|
||||||
os << "NULL";
|
|
||||||
else
|
|
||||||
os << defaultValue.fValue;
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,38 +23,39 @@
|
|||||||
|
|
||||||
#include "ddlpkg.h"
|
#include "ddlpkg.h"
|
||||||
|
|
||||||
namespace ddlpackage {
|
namespace ddlpackage
|
||||||
using namespace std;
|
{
|
||||||
|
using namespace std;
|
||||||
CreateIndexStatement::CreateIndexStatement():
|
|
||||||
fIndexName(NULL),
|
CreateIndexStatement::CreateIndexStatement():
|
||||||
fTableName(NULL),
|
fIndexName(NULL),
|
||||||
fColumnNames(),
|
fTableName(NULL),
|
||||||
fUnique(false)
|
fColumnNames(),
|
||||||
{
|
fUnique(false)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
CreateIndexStatement::CreateIndexStatement(QualifiedName *indexName, QualifiedName *tableName,
|
|
||||||
ColumnNameList *columnNames, bool unique) :
|
CreateIndexStatement::CreateIndexStatement(QualifiedName* indexName, QualifiedName* tableName,
|
||||||
fIndexName(indexName),
|
ColumnNameList* columnNames, bool unique) :
|
||||||
fTableName(tableName),
|
fIndexName(indexName),
|
||||||
fColumnNames(*columnNames),
|
fTableName(tableName),
|
||||||
fUnique(unique)
|
fColumnNames(*columnNames),
|
||||||
{
|
fUnique(unique)
|
||||||
delete columnNames;
|
{
|
||||||
}
|
delete columnNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateIndexStatement::~CreateIndexStatement()
|
||||||
|
{
|
||||||
|
delete fIndexName;
|
||||||
|
delete fTableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& CreateIndexStatement::put(std::ostream& os) const
|
||||||
|
{
|
||||||
|
os << "Create Index: " << *fIndexName << " on " << *fTableName
|
||||||
|
<< fColumnNames << endl;
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
CreateIndexStatement::~CreateIndexStatement()
|
|
||||||
{
|
|
||||||
delete fIndexName;
|
|
||||||
delete fTableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
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"
|
#include "ddlpkg.h"
|
||||||
#undef DDLPKG_DLLEXPORT
|
#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() :
|
||||||
CreateTableStatement::~CreateTableStatement()
|
fTableDef(0)
|
||||||
{
|
{
|
||||||
if (fTableDef)
|
}
|
||||||
{
|
|
||||||
delete fTableDef;
|
CreateTableStatement::CreateTableStatement(TableDef* tableDef) :
|
||||||
}
|
fTableDef(tableDef)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
/** \brief Put to ostream. */
|
|
||||||
ostream& CreateTableStatement::put(ostream& os) const
|
|
||||||
{
|
CreateTableStatement::~CreateTableStatement()
|
||||||
os << "CreateTable "
|
{
|
||||||
<< *fTableDef;
|
if (fTableDef)
|
||||||
return os;
|
{
|
||||||
}
|
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
@@ -1,173 +1,174 @@
|
|||||||
|
|
||||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||||
|
|
||||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||||
|
|
||||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
/* As a special exception, you may create a larger work that contains
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
part or all of the Bison parser skeleton and distribute that work
|
||||||
under terms of your choice, so long as that work isn't itself a
|
under terms of your choice, so long as that work isn't itself a
|
||||||
parser generator using the skeleton or a modified version thereof
|
parser generator using the skeleton or a modified version thereof
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
the parser skeleton itself, you may (at your option) remove this
|
||||||
special exception, which will cause the skeleton and the resulting
|
special exception, which will cause the skeleton and the resulting
|
||||||
Bison output files to be licensed under the GNU General Public
|
Bison output files to be licensed under the GNU General Public
|
||||||
License without this special exception.
|
License without this special exception.
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
This special exception was added by the Free Software Foundation in
|
||||||
version 2.2 of Bison. */
|
version 2.2 of Bison. */
|
||||||
|
|
||||||
|
|
||||||
/* Tokens. */
|
/* Tokens. */
|
||||||
#ifndef YYTOKENTYPE
|
#ifndef YYTOKENTYPE
|
||||||
# define YYTOKENTYPE
|
# define YYTOKENTYPE
|
||||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||||
know about them. */
|
know about them. */
|
||||||
enum yytokentype {
|
enum yytokentype
|
||||||
ACTION = 258,
|
{
|
||||||
ADD = 259,
|
ACTION = 258,
|
||||||
ALTER = 260,
|
ADD = 259,
|
||||||
AUTO_INCREMENT = 261,
|
ALTER = 260,
|
||||||
BIGINT = 262,
|
AUTO_INCREMENT = 261,
|
||||||
BIT = 263,
|
BIGINT = 262,
|
||||||
IDB_BLOB = 264,
|
BIT = 263,
|
||||||
CASCADE = 265,
|
IDB_BLOB = 264,
|
||||||
IDB_CHAR = 266,
|
CASCADE = 265,
|
||||||
CHARACTER = 267,
|
IDB_CHAR = 266,
|
||||||
CHECK = 268,
|
CHARACTER = 267,
|
||||||
CLOB = 269,
|
CHECK = 268,
|
||||||
COLUMN = 270,
|
CLOB = 269,
|
||||||
COLUMNS = 271,
|
COLUMN = 270,
|
||||||
COMMENT = 272,
|
COLUMNS = 271,
|
||||||
CONSTRAINT = 273,
|
COMMENT = 272,
|
||||||
CONSTRAINTS = 274,
|
CONSTRAINT = 273,
|
||||||
CREATE = 275,
|
CONSTRAINTS = 274,
|
||||||
CURRENT_USER = 276,
|
CREATE = 275,
|
||||||
DATETIME = 277,
|
CURRENT_USER = 276,
|
||||||
DEC = 278,
|
DATETIME = 277,
|
||||||
DECIMAL = 279,
|
DEC = 278,
|
||||||
DEFAULT = 280,
|
DECIMAL = 279,
|
||||||
DEFERRABLE = 281,
|
DEFAULT = 280,
|
||||||
DEFERRED = 282,
|
DEFERRABLE = 281,
|
||||||
IDB_DELETE = 283,
|
DEFERRED = 282,
|
||||||
DROP = 284,
|
IDB_DELETE = 283,
|
||||||
ENGINE = 285,
|
DROP = 284,
|
||||||
FOREIGN = 286,
|
ENGINE = 285,
|
||||||
FULL = 287,
|
FOREIGN = 286,
|
||||||
IMMEDIATE = 288,
|
FULL = 287,
|
||||||
INDEX = 289,
|
IMMEDIATE = 288,
|
||||||
INITIALLY = 290,
|
INDEX = 289,
|
||||||
IDB_INT = 291,
|
INITIALLY = 290,
|
||||||
INTEGER = 292,
|
IDB_INT = 291,
|
||||||
KEY = 293,
|
INTEGER = 292,
|
||||||
MATCH = 294,
|
KEY = 293,
|
||||||
MAX_ROWS = 295,
|
MATCH = 294,
|
||||||
MIN_ROWS = 296,
|
MAX_ROWS = 295,
|
||||||
MODIFY = 297,
|
MIN_ROWS = 296,
|
||||||
NO = 298,
|
MODIFY = 297,
|
||||||
NOT = 299,
|
NO = 298,
|
||||||
NULL_TOK = 300,
|
NOT = 299,
|
||||||
NUMBER = 301,
|
NULL_TOK = 300,
|
||||||
NUMERIC = 302,
|
NUMBER = 301,
|
||||||
ON = 303,
|
NUMERIC = 302,
|
||||||
PARTIAL = 304,
|
ON = 303,
|
||||||
PRECISION = 305,
|
PARTIAL = 304,
|
||||||
PRIMARY = 306,
|
PRECISION = 305,
|
||||||
REFERENCES = 307,
|
PRIMARY = 306,
|
||||||
RENAME = 308,
|
REFERENCES = 307,
|
||||||
RESTRICT = 309,
|
RENAME = 308,
|
||||||
SET = 310,
|
RESTRICT = 309,
|
||||||
SMALLINT = 311,
|
SET = 310,
|
||||||
TABLE = 312,
|
SMALLINT = 311,
|
||||||
TIME = 313,
|
TABLE = 312,
|
||||||
TINYINT = 314,
|
TIME = 313,
|
||||||
TO = 315,
|
TINYINT = 314,
|
||||||
UNIQUE = 316,
|
TO = 315,
|
||||||
UNSIGNED = 317,
|
UNIQUE = 316,
|
||||||
UPDATE = 318,
|
UNSIGNED = 317,
|
||||||
USER = 319,
|
UPDATE = 318,
|
||||||
SESSION_USER = 320,
|
USER = 319,
|
||||||
SYSTEM_USER = 321,
|
SESSION_USER = 320,
|
||||||
VARCHAR = 322,
|
SYSTEM_USER = 321,
|
||||||
VARBINARY = 323,
|
VARCHAR = 322,
|
||||||
VARYING = 324,
|
VARBINARY = 323,
|
||||||
WITH = 325,
|
VARYING = 324,
|
||||||
ZONE = 326,
|
WITH = 325,
|
||||||
DOUBLE = 327,
|
ZONE = 326,
|
||||||
IDB_FLOAT = 328,
|
DOUBLE = 327,
|
||||||
REAL = 329,
|
IDB_FLOAT = 328,
|
||||||
CHARSET = 330,
|
REAL = 329,
|
||||||
IDB_IF = 331,
|
CHARSET = 330,
|
||||||
EXISTS = 332,
|
IDB_IF = 331,
|
||||||
CHANGE = 333,
|
EXISTS = 332,
|
||||||
TRUNCATE = 334,
|
CHANGE = 333,
|
||||||
IDENT = 335,
|
TRUNCATE = 334,
|
||||||
FCONST = 336,
|
IDENT = 335,
|
||||||
SCONST = 337,
|
FCONST = 336,
|
||||||
CP_SEARCH_CONDITION_TEXT = 338,
|
SCONST = 337,
|
||||||
ICONST = 339,
|
CP_SEARCH_CONDITION_TEXT = 338,
|
||||||
DATE = 340
|
ICONST = 339,
|
||||||
};
|
DATE = 340
|
||||||
#endif
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
|
||||||
typedef union YYSTYPE
|
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||||
{
|
typedef union YYSTYPE
|
||||||
|
{
|
||||||
|
|
||||||
ddlpackage::AlterTableStatement *alterTableStmt;
|
|
||||||
ddlpackage::AlterTableAction *ata;
|
ddlpackage::AlterTableStatement* alterTableStmt;
|
||||||
ddlpackage::AlterTableActionList *ataList;
|
ddlpackage::AlterTableAction* ata;
|
||||||
ddlpackage::DDL_CONSTRAINT_ATTRIBUTES cattr;
|
ddlpackage::AlterTableActionList* ataList;
|
||||||
std::pair<std::string, std::string> *tableOption;
|
ddlpackage::DDL_CONSTRAINT_ATTRIBUTES cattr;
|
||||||
const char *columnOption;
|
std::pair<std::string, std::string>* tableOption;
|
||||||
ddlpackage::ColumnConstraintDef *columnConstraintDef;
|
const char* columnOption;
|
||||||
ddlpackage::ColumnNameList *columnNameList;
|
ddlpackage::ColumnConstraintDef* columnConstraintDef;
|
||||||
ddlpackage::ColumnType* columnType;
|
ddlpackage::ColumnNameList* columnNameList;
|
||||||
ddlpackage::ConstraintAttributes *constraintAttributes;
|
ddlpackage::ColumnType* columnType;
|
||||||
ddlpackage::ColumnConstraintList *constraintList;
|
ddlpackage::ConstraintAttributes* constraintAttributes;
|
||||||
ddlpackage::DDL_CONSTRAINTS constraintType;
|
ddlpackage::ColumnConstraintList* constraintList;
|
||||||
double dval;
|
ddlpackage::DDL_CONSTRAINTS constraintType;
|
||||||
bool flag;
|
double dval;
|
||||||
int ival;
|
bool flag;
|
||||||
ddlpackage::QualifiedName *qualifiedName;
|
int ival;
|
||||||
ddlpackage::SchemaObject *schemaObject;
|
ddlpackage::QualifiedName* qualifiedName;
|
||||||
ddlpackage::SqlStatement *sqlStmt;
|
ddlpackage::SchemaObject* schemaObject;
|
||||||
ddlpackage::SqlStatementList *sqlStmtList;
|
ddlpackage::SqlStatement* sqlStmt;
|
||||||
const char *str;
|
ddlpackage::SqlStatementList* sqlStmtList;
|
||||||
ddlpackage::TableConstraintDef *tableConstraint;
|
const char* str;
|
||||||
ddlpackage::TableElementList *tableElementList;
|
ddlpackage::TableConstraintDef* tableConstraint;
|
||||||
ddlpackage::TableOptionMap *tableOptionMap;
|
ddlpackage::TableElementList* tableElementList;
|
||||||
ddlpackage::ColumnDefaultValue *colDefault;
|
ddlpackage::TableOptionMap* tableOptionMap;
|
||||||
ddlpackage::DDL_MATCH_TYPE matchType;
|
ddlpackage::ColumnDefaultValue* colDefault;
|
||||||
ddlpackage::DDL_REFERENTIAL_ACTION refActionCode;
|
ddlpackage::DDL_MATCH_TYPE matchType;
|
||||||
ddlpackage::ReferentialAction *refAction;
|
ddlpackage::DDL_REFERENTIAL_ACTION refActionCode;
|
||||||
|
ddlpackage::ReferentialAction* refAction;
|
||||||
|
|
||||||
|
|
||||||
} YYSTYPE;
|
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
} YYSTYPE;
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||||
#endif
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
|
#endif
|
||||||
extern YYSTYPE ddllval;
|
|
||||||
|
extern YYSTYPE ddllval;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -27,182 +27,192 @@
|
|||||||
#include "ddlpkg.h"
|
#include "ddlpkg.h"
|
||||||
#undef DDLPKG_DLLEXPORT
|
#undef DDLPKG_DLLEXPORT
|
||||||
|
|
||||||
namespace ddlpackage
|
namespace ddlpackage
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
QualifiedName::QualifiedName(const char *name):
|
QualifiedName::QualifiedName(const char* name):
|
||||||
fName(name)
|
fName(name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QualifiedName::QualifiedName(const char *schema, const char *name):
|
QualifiedName::QualifiedName(const char* schema, const char* name):
|
||||||
fName(name),
|
fName(name),
|
||||||
fSchema(schema)
|
fSchema(schema)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QualifiedName::QualifiedName(const char* catalog, const char *schema, const char *name):
|
QualifiedName::QualifiedName(const char* catalog, const char* schema, const char* name):
|
||||||
fCatalog(catalog),
|
fCatalog(catalog),
|
||||||
fName(name),
|
fName(name),
|
||||||
fSchema(schema)
|
fSchema(schema)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& operator<<(ostream &os, const QualifiedName& qname)
|
ostream& operator<<(ostream& os, const QualifiedName& qname)
|
||||||
{
|
{
|
||||||
if(!qname.fCatalog.empty())
|
if (!qname.fCatalog.empty())
|
||||||
os << qname.fCatalog << ".";
|
os << qname.fCatalog << ".";
|
||||||
if(!qname.fSchema.empty())
|
|
||||||
os << qname.fSchema << ".";
|
if (!qname.fSchema.empty())
|
||||||
os << qname.fName;
|
os << qname.fSchema << ".";
|
||||||
return os;
|
|
||||||
}
|
os << qname.fName;
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @brief Map a DECIMAL precision to data width in bytes */
|
/** @brief Map a DECIMAL precision to data width in bytes */
|
||||||
unsigned int precision_width(unsigned p)
|
unsigned int precision_width(unsigned p)
|
||||||
{
|
{
|
||||||
switch(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)
|
|
||||||
{
|
{
|
||||||
}
|
case 1:
|
||||||
#endif
|
case 2:
|
||||||
ColumnConstraintDef::ColumnConstraintDef(DDL_CONSTRAINTS type) :
|
return 1;
|
||||||
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) :
|
case 3:
|
||||||
fColumnDef(columnDef)
|
case 4:
|
||||||
{
|
return 2;
|
||||||
}
|
|
||||||
|
|
||||||
ostream &operator<<(ostream& os, const ReferentialAction& ref)
|
case 5:
|
||||||
{
|
case 6:
|
||||||
os << "ref action: u=" << ReferentialActionStrings[ref.fOnUpdate] << " "
|
case 7:
|
||||||
<< "d=" << ReferentialActionStrings[ref.fOnDelete];
|
case 8:
|
||||||
return os;
|
case 9:
|
||||||
}
|
return 4;
|
||||||
|
|
||||||
void ColumnDef::convertDecimal()
|
default:
|
||||||
{
|
return 8;
|
||||||
//@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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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"
|
#include "ddlpkg.h"
|
||||||
|
|
||||||
namespace ddlpackage {
|
namespace ddlpackage
|
||||||
using namespace std;
|
{
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
DropIndexStatement::~DropIndexStatement()
|
DropIndexStatement::~DropIndexStatement()
|
||||||
{
|
{
|
||||||
delete fIndexName;
|
delete fIndexName;
|
||||||
}
|
}
|
||||||
|
|
||||||
DropIndexStatement::DropIndexStatement(QualifiedName *qualifiedName) :
|
DropIndexStatement::DropIndexStatement(QualifiedName* qualifiedName) :
|
||||||
fIndexName(qualifiedName)
|
fIndexName(qualifiedName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& DropIndexStatement::put(std::ostream& os) const
|
std::ostream& DropIndexStatement::put(std::ostream& os) const
|
||||||
{
|
{
|
||||||
os << "Drop Index: " << *fIndexName << endl;
|
os << "Drop Index: " << *fIndexName << endl;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,22 +27,25 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace ddlpackage {
|
namespace ddlpackage
|
||||||
|
{
|
||||||
|
|
||||||
DropPartitionStatement::DropPartitionStatement(QualifiedName *qualifiedName) :
|
DropPartitionStatement::DropPartitionStatement(QualifiedName* qualifiedName) :
|
||||||
fTableName(qualifiedName)
|
fTableName(qualifiedName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& DropPartitionStatement::put(ostream& os) const
|
ostream& DropPartitionStatement::put(ostream& os) const
|
||||||
{
|
{
|
||||||
os << "Mark partitions out of service: " << *fTableName << endl;
|
os << "Mark partitions out of service: " << *fTableName << endl;
|
||||||
os << " partitions: ";
|
os << " partitions: ";
|
||||||
set<BRM::LogicalPartition>::const_iterator it;
|
set<BRM::LogicalPartition>::const_iterator it;
|
||||||
for (it=fPartitions.begin(); it!=fPartitions.end(); ++it)
|
|
||||||
os << (*it) << " ";
|
for (it = fPartitions.begin(); it != fPartitions.end(); ++it)
|
||||||
os << endl;
|
os << (*it) << " ";
|
||||||
return os;
|
|
||||||
|
os << endl;
|
||||||
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,29 +27,30 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace ddlpackage {
|
namespace ddlpackage
|
||||||
|
{
|
||||||
|
|
||||||
DropTableStatement::DropTableStatement(QualifiedName *qualifiedName, bool cascade) :
|
DropTableStatement::DropTableStatement(QualifiedName* qualifiedName, bool cascade) :
|
||||||
fTableName(qualifiedName),
|
fTableName(qualifiedName),
|
||||||
fCascade(cascade)
|
fCascade(cascade)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& DropTableStatement::put(ostream& os) const
|
ostream& DropTableStatement::put(ostream& os) const
|
||||||
{
|
{
|
||||||
os << "Drop Table: " << *fTableName << " " << "C=" << fCascade << endl;
|
os << "Drop Table: " << *fTableName << " " << "C=" << fCascade << endl;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
TruncTableStatement::TruncTableStatement(QualifiedName *qualifiedName) :
|
TruncTableStatement::TruncTableStatement(QualifiedName* qualifiedName) :
|
||||||
fTableName(qualifiedName)
|
fTableName(qualifiedName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& TruncTableStatement::put(ostream& os) const
|
ostream& TruncTableStatement::put(ostream& os) const
|
||||||
{
|
{
|
||||||
os << "Truncate Table: " << *fTableName << endl;
|
os << "Truncate Table: " << *fTableName << endl;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,44 +31,48 @@ namespace po = boost::program_options;
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
string sqlfile;
|
string sqlfile;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
po::options_description desc ("Allowed options");
|
po::options_description desc ("Allowed options");
|
||||||
desc.add_options ()
|
desc.add_options ()
|
||||||
("help", "produce help message")
|
("help", "produce help message")
|
||||||
("bisond", /* po::value <string>(),*/ "Have bison produce debug output")
|
("bisond", /* po::value <string>(),*/ "Have bison produce debug output")
|
||||||
("count", po::value <int>(), "number of runs")
|
("count", po::value <int>(), "number of runs")
|
||||||
("sql", po::value < string > (), "sql file");
|
("sql", po::value < string > (), "sql file");
|
||||||
po::variables_map vm;
|
po::variables_map vm;
|
||||||
po::store (po::parse_command_line (argc, argv, desc), vm);
|
po::store (po::parse_command_line (argc, argv, desc), vm);
|
||||||
po::notify (vm);
|
po::notify (vm);
|
||||||
if (vm.count ("sql"))
|
|
||||||
sqlfile = vm["sql"].as <string> ();
|
if (vm.count ("sql"))
|
||||||
|
sqlfile = vm["sql"].as <string> ();
|
||||||
|
|
||||||
|
|
||||||
if (vm.count("count"))
|
if (vm.count("count"))
|
||||||
count = vm["count"].as<int>();
|
count = vm["count"].as<int>();
|
||||||
|
|
||||||
SqlFileParser parser;
|
|
||||||
if (vm.count ("bisond"))
|
|
||||||
parser.SetDebug(true);
|
|
||||||
|
|
||||||
parser.Parse(sqlfile);
|
|
||||||
|
|
||||||
if(parser.Good()) {
|
SqlFileParser parser;
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
|
||||||
|
|
||||||
cout << "Parser succeeded." << endl;
|
if (vm.count ("bisond"))
|
||||||
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
parser.SetDebug(true);
|
||||||
cout << ptree;
|
|
||||||
cout << endl;
|
parser.Parse(sqlfile);
|
||||||
}
|
|
||||||
else {
|
if (parser.Good())
|
||||||
cout << "Parser failed." << endl;
|
{
|
||||||
}
|
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;
|
using namespace std;
|
||||||
|
|
||||||
namespace ddlpackage {
|
namespace ddlpackage
|
||||||
|
{
|
||||||
|
|
||||||
MarkPartitionStatement::MarkPartitionStatement(QualifiedName *qualifiedName) :
|
MarkPartitionStatement::MarkPartitionStatement(QualifiedName* qualifiedName) :
|
||||||
fTableName(qualifiedName)
|
fTableName(qualifiedName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& MarkPartitionStatement::put(ostream& os) const
|
ostream& MarkPartitionStatement::put(ostream& os) const
|
||||||
{
|
{
|
||||||
os << "Mark partition out of service: " << *fTableName;
|
os << "Mark partition out of service: " << *fTableName;
|
||||||
os << " partitions: ";
|
os << " partitions: ";
|
||||||
set<BRM::LogicalPartition>::const_iterator it;
|
set<BRM::LogicalPartition>::const_iterator it;
|
||||||
for (it=fPartitions.begin(); it!=fPartitions.end(); ++it)
|
|
||||||
os << (*it) << " ";
|
for (it = fPartitions.begin(); it != fPartitions.end(); ++it)
|
||||||
os << endl;
|
os << (*it) << " ";
|
||||||
return os;
|
|
||||||
|
os << endl;
|
||||||
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -27,22 +27,25 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace ddlpackage {
|
namespace ddlpackage
|
||||||
|
{
|
||||||
|
|
||||||
RestorePartitionStatement::RestorePartitionStatement(QualifiedName *qualifiedName) :
|
RestorePartitionStatement::RestorePartitionStatement(QualifiedName* qualifiedName) :
|
||||||
fTableName(qualifiedName)
|
fTableName(qualifiedName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& RestorePartitionStatement::put(ostream& os) const
|
ostream& RestorePartitionStatement::put(ostream& os) const
|
||||||
{
|
{
|
||||||
os << "Mark partition out of service: " << *fTableName;
|
os << "Mark partition out of service: " << *fTableName;
|
||||||
os << " partitions: ";
|
os << " partitions: ";
|
||||||
set<BRM::LogicalPartition>::const_iterator it;
|
set<BRM::LogicalPartition>::const_iterator it;
|
||||||
for (it=fPartitions.begin(); it!=fPartitions.end(); ++it)
|
|
||||||
os << (*it) << " ";
|
for (it = fPartitions.begin(); it != fPartitions.end(); ++it)
|
||||||
os << endl;
|
os << (*it) << " ";
|
||||||
return os;
|
|
||||||
|
os << endl;
|
||||||
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -36,102 +36,108 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void scanner_finish(void* yyscanner);
|
void scanner_finish(void* yyscanner);
|
||||||
void scanner_init(const char *str, void* yyscanner);
|
void scanner_init(const char* str, void* yyscanner);
|
||||||
int ddllex_init_extra(void* user_defined,void** yyscanner);
|
int ddllex_init_extra(void* user_defined, void** yyscanner);
|
||||||
int ddllex_destroy(void* yyscanner);
|
int ddllex_destroy(void* yyscanner);
|
||||||
int ddlparse(ddlpackage::pass_to_bison* x);
|
int ddlparse(ddlpackage::pass_to_bison* x);
|
||||||
void set_schema(std::string schema);
|
void set_schema(std::string schema);
|
||||||
namespace ddlpackage {
|
namespace ddlpackage
|
||||||
using namespace std;
|
{
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
SqlParser::SqlParser() :
|
SqlParser::SqlParser() :
|
||||||
fStatus(-1),
|
fStatus(-1),
|
||||||
fDebug(false),
|
fDebug(false),
|
||||||
x(&fParseTree)
|
x(&fParseTree)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SqlParser::SetDebug(bool debug)
|
void SqlParser::SetDebug(bool debug)
|
||||||
{
|
{
|
||||||
fDebug = debug;
|
fDebug = debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SqlParser::setDefaultSchema(std::string schema)
|
void SqlParser::setDefaultSchema(std::string schema)
|
||||||
{
|
{
|
||||||
x.fDBSchema=schema;
|
x.fDBSchema = schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SqlParser::Parse(const char* sqltext)
|
int SqlParser::Parse(const char* sqltext)
|
||||||
{
|
{
|
||||||
ddllex_init_extra(&scanData, &x.scanner);
|
ddllex_init_extra(&scanData, &x.scanner);
|
||||||
scanner_init(sqltext, x.scanner);
|
scanner_init(sqltext, x.scanner);
|
||||||
fStatus = ddlparse(&x);
|
fStatus = ddlparse(&x);
|
||||||
return fStatus;
|
return fStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const ParseTree& SqlParser::GetParseTree(void)
|
const ParseTree& SqlParser::GetParseTree(void)
|
||||||
{
|
{
|
||||||
if(!Good()) {
|
if (!Good())
|
||||||
throw logic_error("The ParseTree is invalid");
|
{
|
||||||
}
|
throw logic_error("The ParseTree is invalid");
|
||||||
return fParseTree;
|
}
|
||||||
}
|
|
||||||
|
return fParseTree;
|
||||||
|
}
|
||||||
bool SqlParser::Good()
|
|
||||||
{
|
|
||||||
return fStatus == 0;
|
bool SqlParser::Good()
|
||||||
}
|
{
|
||||||
|
return fStatus == 0;
|
||||||
|
}
|
||||||
SqlParser::~SqlParser()
|
|
||||||
{
|
|
||||||
scanner_finish(x.scanner); // free scanner allocated memory
|
SqlParser::~SqlParser()
|
||||||
ddllex_destroy(x.scanner);
|
{
|
||||||
}
|
scanner_finish(x.scanner); // free scanner allocated memory
|
||||||
|
ddllex_destroy(x.scanner);
|
||||||
|
}
|
||||||
SqlFileParser::SqlFileParser() :
|
|
||||||
SqlParser()
|
|
||||||
{
|
SqlFileParser::SqlFileParser() :
|
||||||
}
|
SqlParser()
|
||||||
|
{
|
||||||
|
}
|
||||||
int SqlFileParser::Parse(const string& sqlfile)
|
|
||||||
{
|
|
||||||
fStatus = -1;
|
int SqlFileParser::Parse(const string& sqlfile)
|
||||||
|
{
|
||||||
ifstream ifsql;
|
fStatus = -1;
|
||||||
ifsql.open(sqlfile.c_str());
|
|
||||||
if(!ifsql.is_open()) {
|
ifstream ifsql;
|
||||||
perror(sqlfile.c_str());
|
ifsql.open(sqlfile.c_str());
|
||||||
return fStatus;
|
|
||||||
}
|
if (!ifsql.is_open())
|
||||||
|
{
|
||||||
char sqlbuf[1024*1024];
|
perror(sqlfile.c_str());
|
||||||
unsigned length;
|
return fStatus;
|
||||||
ifsql.seekg (0, ios::end);
|
}
|
||||||
length = ifsql.tellg();
|
|
||||||
ifsql.seekg (0, ios::beg);
|
char sqlbuf[1024 * 1024];
|
||||||
|
unsigned length;
|
||||||
if(length > sizeof(sqlbuf) - 1) {
|
ifsql.seekg (0, ios::end);
|
||||||
throw length_error("SqlFileParser has file size hard limit of 16K.");
|
length = ifsql.tellg();
|
||||||
}
|
ifsql.seekg (0, ios::beg);
|
||||||
|
|
||||||
unsigned rcount;
|
if (length > sizeof(sqlbuf) - 1)
|
||||||
rcount = ifsql.readsome(sqlbuf, sizeof(sqlbuf) - 1);
|
{
|
||||||
|
throw length_error("SqlFileParser has file size hard limit of 16K.");
|
||||||
if(rcount < 0)
|
}
|
||||||
return fStatus;
|
|
||||||
|
unsigned rcount;
|
||||||
sqlbuf[rcount] = 0;
|
rcount = ifsql.readsome(sqlbuf, sizeof(sqlbuf) - 1);
|
||||||
|
|
||||||
//cout << endl << sqlfile << "(" << rcount << ")" << endl;
|
if (rcount < 0)
|
||||||
//cout << "----------------------" << endl;
|
return fStatus;
|
||||||
//cout << sqlbuf << endl;
|
|
||||||
|
sqlbuf[rcount] = 0;
|
||||||
return SqlParser::Parse(sqlbuf);
|
|
||||||
}
|
//cout << endl << sqlfile << "(" << rcount << ")" << endl;
|
||||||
|
//cout << "----------------------" << endl;
|
||||||
|
//cout << sqlbuf << endl;
|
||||||
|
|
||||||
|
return SqlParser::Parse(sqlbuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,20 +42,20 @@ typedef SqlStatementList ParseTree;
|
|||||||
|
|
||||||
/** @brief SqlParser is a class interface around the Bison parser
|
/** @brief SqlParser is a class interface around the Bison parser
|
||||||
* machinery for DDL.
|
* machinery for DDL.
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
*
|
*
|
||||||
* @verbatim
|
* @verbatim
|
||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf);
|
parser.Parse(sqlbuf);
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
SqlFileParser parser;
|
SqlFileParser parser;
|
||||||
parser.setDefaultSchema("tpch");
|
parser.setDefaultSchema("tpch");
|
||||||
parser.Parse(sqlFileName);
|
parser.Parse(sqlFileName);
|
||||||
|
|
||||||
if (parser.Good()) {
|
if (parser.Good()) {
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree &ptree = parser.GetParseTree();
|
||||||
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
||||||
@@ -64,29 +64,30 @@ typedef SqlStatementList ParseTree;
|
|||||||
else {
|
else {
|
||||||
cout << "Parser failed." << endl;
|
cout << "Parser failed." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@endverbatim
|
@endverbatim
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Instance specific data for use by the scanner.
|
Instance specific data for use by the scanner.
|
||||||
*/
|
*/
|
||||||
typedef std::vector<char*> valbuf_t;
|
typedef std::vector<char*> valbuf_t;
|
||||||
|
|
||||||
struct scan_data
|
struct scan_data
|
||||||
{
|
{
|
||||||
/* Handles to the buffer that the lexer uses internally */
|
/* Handles to the buffer that the lexer uses internally */
|
||||||
char* scanbuf;
|
char* scanbuf;
|
||||||
void* scanbufhandle; // This is a YY_BUFFER_STATE defined in ddl-scan.cpp
|
void* scanbufhandle; // This is a YY_BUFFER_STATE defined in ddl-scan.cpp
|
||||||
valbuf_t valbuf;
|
valbuf_t valbuf;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pass_to_bison {
|
struct pass_to_bison
|
||||||
|
{
|
||||||
ParseTree* fParseTree;
|
ParseTree* fParseTree;
|
||||||
std::string fDBSchema;
|
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
|
class SqlParser
|
||||||
@@ -99,33 +100,33 @@ public:
|
|||||||
EXPORT int Parse(const char* sqltext);
|
EXPORT int Parse(const char* sqltext);
|
||||||
|
|
||||||
/** @brief Return the ParseTree if state is Good. Otherwise
|
/** @brief Return the ParseTree if state is Good. Otherwise
|
||||||
* throw a logic_error.
|
* throw a logic_error.
|
||||||
*/
|
*/
|
||||||
EXPORT const ParseTree& GetParseTree(void);
|
EXPORT const ParseTree& GetParseTree(void);
|
||||||
|
|
||||||
/** @brief Tells whether current state resulted from a good
|
/** @brief Tells whether current state resulted from a good
|
||||||
* parse.
|
* parse.
|
||||||
*/
|
*/
|
||||||
EXPORT bool Good(void);
|
EXPORT bool Good(void);
|
||||||
|
|
||||||
/** @brief Control bison debugging
|
/** @brief Control bison debugging
|
||||||
*/
|
*/
|
||||||
EXPORT void SetDebug(bool debug);
|
EXPORT void SetDebug(bool debug);
|
||||||
|
|
||||||
/** @brief Set the default schema to use if it is not
|
/** @brief Set the default schema to use if it is not
|
||||||
* supplied in the DDL statement
|
* supplied in the DDL statement
|
||||||
*
|
*
|
||||||
* @param schema the default schema
|
* @param schema the default schema
|
||||||
*/
|
*/
|
||||||
EXPORT void setDefaultSchema(std::string schema);
|
EXPORT void setDefaultSchema(std::string schema);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ParseTree fParseTree;
|
ParseTree fParseTree;
|
||||||
std::string fDBSchema;
|
std::string fDBSchema;
|
||||||
int fStatus; ///< return from yyparse() stored here.
|
int fStatus; ///< return from yyparse() stored here.
|
||||||
bool fDebug; ///< Turn on bison debugging.
|
bool fDebug; ///< Turn on bison debugging.
|
||||||
scan_data scanData;
|
scan_data scanData;
|
||||||
pass_to_bison x;
|
pass_to_bison x;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,22 +25,23 @@
|
|||||||
#include "ddlpkg.h"
|
#include "ddlpkg.h"
|
||||||
#undef DDLPKG_DLLEXPORT
|
#undef DDLPKG_DLLEXPORT
|
||||||
|
|
||||||
namespace ddlpackage {
|
namespace ddlpackage
|
||||||
using namespace std;
|
{
|
||||||
|
using namespace std;
|
||||||
static uint32_t sessionID = 1;
|
|
||||||
|
|
||||||
SqlStatement::SqlStatement()
|
|
||||||
{
|
|
||||||
fSessionID = sessionID;
|
|
||||||
}
|
|
||||||
|
|
||||||
SqlStatement::~SqlStatement()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ostream& operator<<(ostream &os, const SqlStatement& stmt)
|
static uint32_t sessionID = 1;
|
||||||
{
|
|
||||||
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"
|
#include "ddlpkg.h"
|
||||||
#undef DDLPKG_DLLEXPORT
|
#undef DDLPKG_DLLEXPORT
|
||||||
|
|
||||||
namespace ddlpackage {
|
namespace ddlpackage
|
||||||
using namespace std;
|
{
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SqlStatementList::push_back(SqlStatement* v)
|
ostream& operator<<(ostream& os, const SqlStatementList& ssl)
|
||||||
{
|
{
|
||||||
fList.push_back(v);
|
vector<SqlStatement*>::const_iterator itr;
|
||||||
}
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,268 +26,297 @@
|
|||||||
#include "ddlpkg.h"
|
#include "ddlpkg.h"
|
||||||
#undef DDLPKG_DLLEXPORT
|
#undef DDLPKG_DLLEXPORT
|
||||||
|
|
||||||
namespace ddlpackage
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete fQualifiedName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TableDef::TableDef(QualifiedName* name, TableElementList* elements, TableOptionMap* options) :
|
|
||||||
fQualifiedName(name)
|
|
||||||
{
|
|
||||||
if(options) {
|
|
||||||
fOptions = *options;
|
|
||||||
delete options;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete elements;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** \brief Put to ostream. */
|
TableDef::~TableDef()
|
||||||
ostream& operator<<(ostream& os, const TableDef& tableDef)
|
{
|
||||||
{
|
{
|
||||||
os << "CreateTable ";
|
ColumnDefList::iterator itr;
|
||||||
if(tableDef.fQualifiedName->fSchema != "")
|
|
||||||
//cout << tableDef.fQualifiedName->fSchema << ".";
|
|
||||||
os << tableDef.fQualifiedName->fName
|
|
||||||
<< " " << tableDef.fConstraints.size()
|
|
||||||
<< " table constraints"
|
|
||||||
<< endl;
|
|
||||||
|
|
||||||
{
|
for (itr = fColumns.begin(); itr != fColumns.end(); itr++)
|
||||||
ColumnDefList::const_iterator itr;
|
{
|
||||||
for(itr = tableDef.fColumns.begin();
|
delete *itr;
|
||||||
itr != tableDef.fColumns.end(); ++itr)
|
}
|
||||||
{
|
}
|
||||||
ColumnDef* col = *itr;
|
{
|
||||||
os << *col << endl;
|
TableConstraintDefList::iterator itr;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
TableConstraintDefList::const_iterator itr;
|
|
||||||
for(itr = tableDef.fConstraints.begin();
|
|
||||||
itr != tableDef.fConstraints.end();
|
|
||||||
++itr)
|
|
||||||
{
|
|
||||||
os << (**itr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pair<string, string> oval;
|
for (itr = fConstraints.begin(); itr != fConstraints.end(); itr++)
|
||||||
TableOptionMap::const_iterator oitr;
|
{
|
||||||
os << "Table Options" << endl;
|
delete *itr;
|
||||||
if(!tableDef.fOptions.empty()) {
|
}
|
||||||
TableOptionMap::const_iterator oitr;
|
}
|
||||||
for(oitr = tableDef.fOptions.begin();
|
|
||||||
oitr != tableDef.fOptions.end(); ++oitr) {
|
delete fQualifiedName;
|
||||||
oval = *oitr;
|
}
|
||||||
os << " " << oval.first << "=" << oval.second << endl;
|
|
||||||
}
|
|
||||||
}
|
TableDef::TableDef(QualifiedName* name, TableElementList* elements, TableOptionMap* options) :
|
||||||
|
fQualifiedName(name)
|
||||||
return os;
|
{
|
||||||
}
|
if (options)
|
||||||
|
{
|
||||||
|
fOptions = *options;
|
||||||
|
delete options;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& TableConstraintDef::put(std::ostream& os) const
|
||||||
|
{
|
||||||
|
os << "No!!!" << endl;
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TableConstraintDef::TableConstraintDef(DDL_CONSTRAINTS cType) :
|
||||||
|
fConstraintType(cType)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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] << " ";
|
||||||
|
|
||||||
|
ColumnNameList::const_iterator itr;
|
||||||
|
os << "(";
|
||||||
|
|
||||||
|
for (itr = fColumnNameList.begin();
|
||||||
|
itr != fColumnNameList.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
os << *itr << " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
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] << " ";
|
||||||
|
|
||||||
|
ColumnNameList::const_iterator itr;
|
||||||
|
os << "(";
|
||||||
|
|
||||||
|
for (itr = fColumnNameList.begin();
|
||||||
|
itr != fColumnNameList.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
os << *itr << " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
os << ")";
|
||||||
|
|
||||||
|
return 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] << " ";
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ostream& operator<<(ostream &os, const TableConstraintDef& constraint)
|
|
||||||
{
|
|
||||||
return constraint.put(os);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream& TableConstraintDef::put(std::ostream& os) const
|
|
||||||
{
|
|
||||||
os << "No!!!" << endl;
|
|
||||||
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TableConstraintDef::TableConstraintDef(DDL_CONSTRAINTS cType) :
|
|
||||||
fConstraintType(cType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
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] << " ";
|
|
||||||
|
|
||||||
ColumnNameList::const_iterator itr;
|
|
||||||
os << "(";
|
|
||||||
for(itr = fColumnNameList.begin();
|
|
||||||
itr != fColumnNameList.end();
|
|
||||||
++itr)
|
|
||||||
{
|
|
||||||
os << *itr << " ";
|
|
||||||
}
|
|
||||||
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] << " ";
|
|
||||||
|
|
||||||
ColumnNameList::const_iterator itr;
|
|
||||||
os << "(";
|
|
||||||
for(itr = fColumnNameList.begin();
|
|
||||||
itr != fColumnNameList.end();
|
|
||||||
++itr)
|
|
||||||
{
|
|
||||||
os << *itr << " ";
|
|
||||||
}
|
|
||||||
os << ")";
|
|
||||||
|
|
||||||
return 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] << " ";
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
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
|
namespace ddlpackageprocessor
|
||||||
{
|
{
|
||||||
/** @brief specialization of a DDLPackageProcessor
|
/** @brief specialization of a DDLPackageProcessor
|
||||||
* for interacting with the Write Engine
|
* for interacting with the Write Engine
|
||||||
* to process alter table ddl statements.
|
* 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
|
EXPORT DDLResult processPackage(ddlpackage::AlterTableStatement& alterTableStmt);
|
||||||
{
|
/** @brief add a physical column file
|
||||||
public:
|
*
|
||||||
AlterTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm){}
|
* @param result the result of the operation
|
||||||
/** @brief process an alter table statement
|
* @param addColumn the AtaAddColumn object
|
||||||
*
|
* @param fTableName the QualifiedName of the table
|
||||||
* @param alterTableStmt the AlterTableStatement
|
*/
|
||||||
*/
|
EXPORT void addColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
EXPORT DDLResult processPackage(ddlpackage::AlterTableStatement& alterTableStmt);
|
ddlpackage::ColumnDef* columnDefPtr,
|
||||||
/** @brief add a physical column file
|
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||||
*
|
|
||||||
* @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
|
/** @brief drop a column
|
||||||
*
|
*
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param ataDropColumn the AtaDropColumn object
|
* @param ataDropColumn the AtaDropColumn object
|
||||||
* @param fTableName the QualifiedName for the table
|
* @param fTableName the QualifiedName for the table
|
||||||
*/
|
*/
|
||||||
EXPORT void dropColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
EXPORT void dropColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
ddlpackage::AtaDropColumn& ataDropColumn,
|
ddlpackage::AtaDropColumn& ataDropColumn,
|
||||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||||
|
|
||||||
/** @brief drop columns
|
/** @brief drop columns
|
||||||
*
|
*
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param ataDropColumns the AtaDropColumn object
|
* @param ataDropColumns the AtaDropColumn object
|
||||||
* @param fTableName the QualifiedName for the table
|
* @param fTableName the QualifiedName for the table
|
||||||
*/
|
*/
|
||||||
EXPORT void dropColumns(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
EXPORT void dropColumns(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
ddlpackage::AtaDropColumns& ataDropColumns,
|
ddlpackage::AtaDropColumns& ataDropColumns,
|
||||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId );
|
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId );
|
||||||
|
|
||||||
/** @brief add table constraint
|
/** @brief add table constraint
|
||||||
*
|
*
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param ataAddTableConstraint the AtaDropColumn object
|
* @param ataAddTableConstraint the AtaDropColumn object
|
||||||
* @param fTableName the QualifiedName for the table
|
* @param fTableName the QualifiedName for the table
|
||||||
*/
|
*/
|
||||||
EXPORT void addTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
EXPORT void addTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
ddlpackage::AtaAddTableConstraint& ataAddTableConstraint,
|
ddlpackage::AtaAddTableConstraint& ataAddTableConstraint,
|
||||||
ddlpackage::QualifiedName& fTableName );
|
ddlpackage::QualifiedName& fTableName );
|
||||||
|
|
||||||
/** @brief set column default
|
/** @brief set column default
|
||||||
*
|
*
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param ataSetColumnDefault the AtaSetColumnDefault object
|
* @param ataSetColumnDefault the AtaSetColumnDefault object
|
||||||
* @param fTableName the QualifiedName for the table
|
* @param fTableName the QualifiedName for the table
|
||||||
*/
|
*/
|
||||||
EXPORT void setColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
EXPORT void setColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
ddlpackage::AtaSetColumnDefault& ataSetColumnDefault,
|
ddlpackage::AtaSetColumnDefault& ataSetColumnDefault,
|
||||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId );
|
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId );
|
||||||
|
|
||||||
/** @brief drop column default
|
/** @brief drop column default
|
||||||
*
|
*
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param ataDropColumnDefault the AtaDropColumnDefault object
|
* @param ataDropColumnDefault the AtaDropColumnDefault object
|
||||||
* @param fTableName the QualifiedName for the table
|
* @param fTableName the QualifiedName for the table
|
||||||
*/
|
*/
|
||||||
EXPORT void dropColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
EXPORT void dropColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
ddlpackage::AtaDropColumnDefault& ataDropColumnDefault,
|
ddlpackage::AtaDropColumnDefault& ataDropColumnDefault,
|
||||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId );
|
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId );
|
||||||
|
|
||||||
/** @brief drop table constraint
|
/** @brief drop table constraint
|
||||||
*
|
*
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param ataDropTableConstraint the AtaDropTableConstraint object
|
* @param ataDropTableConstraint the AtaDropTableConstraint object
|
||||||
* @param fTableName the QualifiedName for the table
|
* @param fTableName the QualifiedName for the table
|
||||||
*/
|
*/
|
||||||
EXPORT void dropTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
EXPORT void dropTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
ddlpackage::AtaDropTableConstraint& ataDropTableConstraint,
|
ddlpackage::AtaDropTableConstraint& ataDropTableConstraint,
|
||||||
ddlpackage::QualifiedName& fTableName );
|
ddlpackage::QualifiedName& fTableName );
|
||||||
/** @brief rename a table
|
/** @brief rename a table
|
||||||
*
|
*
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param ataRenameTable the AtaRenameTable object
|
* @param ataRenameTable the AtaRenameTable object
|
||||||
* @param fTableName the QualifiedName for the table
|
* @param fTableName the QualifiedName for the table
|
||||||
*/
|
*/
|
||||||
EXPORT void renameTable(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
EXPORT void renameTable(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||||
DDLResult& result, ddlpackage::AtaRenameTable& ataRenameTable,
|
DDLResult& result, ddlpackage::AtaRenameTable& ataRenameTable,
|
||||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||||
|
|
||||||
/** @brief rename a column
|
/** @brief rename a column
|
||||||
*
|
*
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param ataRenameColumn the AtaRenameColumn object
|
* @param ataRenameColumn the AtaRenameColumn object
|
||||||
* @param fTableName the QualifiedName for the table
|
* @param fTableName the QualifiedName for the table
|
||||||
*/
|
*/
|
||||||
EXPORT void renameColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
EXPORT void renameColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
ddlpackage::AtaRenameColumn& ataRenameColumn,
|
ddlpackage::AtaRenameColumn& ataRenameColumn,
|
||||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||||
|
|
||||||
/** @brief change a table autoincrement via a comment
|
/** @brief change a table autoincrement via a comment
|
||||||
*
|
*
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param ataTableComment the AtaTableComment object
|
* @param ataTableComment the AtaTableComment object
|
||||||
* @param fTableName the QualifiedName for the table
|
* @param fTableName the QualifiedName for the table
|
||||||
*/
|
*/
|
||||||
EXPORT void tableComment(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
EXPORT void tableComment(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
ddlpackage::AtaTableComment& ataTableComment,
|
ddlpackage::AtaTableComment& ataTableComment,
|
||||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void rollBackAlter(const std::string& error, BRM::TxnID txnID, int sessionId, DDLResult& result, uint64_t uniqueId);
|
void rollBackAlter(const std::string& error, BRM::TxnID txnID, int sessionId, DDLResult& result, uint64_t uniqueId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace ddlpackageprocessor
|
} //namespace ddlpackageprocessor
|
||||||
|
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
|||||||
DETAIL_INFO(createIndexStmt);
|
DETAIL_INFO(createIndexStmt);
|
||||||
|
|
||||||
BRM::TxnID txnID;
|
BRM::TxnID txnID;
|
||||||
txnID.id= fTxnid.id;
|
txnID.id = fTxnid.id;
|
||||||
txnID.valid= fTxnid.valid;
|
txnID.valid = fTxnid.valid;
|
||||||
/*Check whether the table exists already. If not, it is assumed from primary key creating.
|
/*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
|
This is based on the assumption that Front end is already error out if the user trys to
|
||||||
create index on non-existing table. */
|
create index on non-existing table. */
|
||||||
@@ -66,13 +66,15 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
|||||||
tableName.table = (createIndexStmt.fTableName)->fName;
|
tableName.table = (createIndexStmt.fTableName)->fName;
|
||||||
CalpontSystemCatalog::ROPair roPair;
|
CalpontSystemCatalog::ROPair roPair;
|
||||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog( createIndexStmt.fSessionID );
|
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog( createIndexStmt.fSessionID );
|
||||||
try {
|
|
||||||
roPair = systemCatalogPtr->tableRID( tableName );
|
try
|
||||||
|
{
|
||||||
|
roPair = systemCatalogPtr->tableRID( tableName );
|
||||||
}
|
}
|
||||||
catch (exception& ex)
|
catch (exception& ex)
|
||||||
{
|
{
|
||||||
// store primary key name in fPKName
|
// store primary key name in fPKName
|
||||||
fPKName = createIndexStmt.fIndexName->fName;
|
fPKName = createIndexStmt.fIndexName->fName;
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -80,10 +82,12 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
|||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( roPair.objnum < 3000 )
|
if ( roPair.objnum < 3000 )
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
fPKName = createIndexStmt.fIndexName->fName;
|
fPKName = createIndexStmt.fIndexName->fName;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
@@ -103,10 +107,12 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
|||||||
|
|
||||||
VERBOSE_INFO("Writing meta data to SYSINDEX");
|
VERBOSE_INFO("Writing meta data to SYSINDEX");
|
||||||
bool multicol = false;
|
bool multicol = false;
|
||||||
|
|
||||||
if ( createIndexStmt.fColumnNames.size() > 1 )
|
if ( createIndexStmt.fColumnNames.size() > 1 )
|
||||||
{
|
{
|
||||||
multicol = true;
|
multicol = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//validate index columns
|
//validate index columns
|
||||||
CalpontSystemCatalog::TableColName tableColName;
|
CalpontSystemCatalog::TableColName tableColName;
|
||||||
tableColName.schema = (createIndexStmt.fTableName)->fSchema;
|
tableColName.schema = (createIndexStmt.fTableName)->fSchema;
|
||||||
@@ -116,25 +122,27 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
|||||||
ColumnNameList::const_iterator colIter;
|
ColumnNameList::const_iterator colIter;
|
||||||
int totalWidth = 0;
|
int totalWidth = 0;
|
||||||
DDLIndexPopulator pop(&fWriteEngine, &fSessionManager, createIndexStmt.fSessionID, txnID.id, result,
|
DDLIndexPopulator pop(&fWriteEngine, &fSessionManager, createIndexStmt.fSessionID, txnID.id, result,
|
||||||
fIdxOID, createIndexStmt.fColumnNames, *createIndexStmt.fTableName,
|
fIdxOID, createIndexStmt.fColumnNames, *createIndexStmt.fTableName,
|
||||||
type, getDebugLevel());
|
type, getDebugLevel());
|
||||||
|
|
||||||
if ( multicol)
|
if ( multicol)
|
||||||
{
|
{
|
||||||
for ( colIter = createIndexStmt.fColumnNames.begin(); colIter != createIndexStmt.fColumnNames.end(); colIter++)
|
for ( colIter = createIndexStmt.fColumnNames.begin(); colIter != createIndexStmt.fColumnNames.end(); colIter++)
|
||||||
{
|
{
|
||||||
tableColName.column = *colIter;
|
tableColName.column = *colIter;
|
||||||
|
|
||||||
roPair = systemCatalogPtr->columnRID( tableColName );
|
roPair = systemCatalogPtr->columnRID( tableColName );
|
||||||
oid = systemCatalogPtr->lookupOID( tableColName );
|
oid = systemCatalogPtr->lookupOID( tableColName );
|
||||||
colType = systemCatalogPtr->colType (oid );
|
colType = systemCatalogPtr->colType (oid );
|
||||||
totalWidth += (pop.isDictionaryType(colType)) ? 8 : colType.colWidth;
|
totalWidth += (pop.isDictionaryType(colType)) ? 8 : colType.colWidth;
|
||||||
}
|
}
|
||||||
if ( totalWidth > 32 )
|
|
||||||
{
|
if ( totalWidth > 32 )
|
||||||
stringstream ss;
|
{
|
||||||
ss << totalWidth;
|
stringstream ss;
|
||||||
DETAIL_INFO("Total indexed column width greater than 32: " + ss.str());
|
ss << totalWidth;
|
||||||
logging::Message::Args args;
|
DETAIL_INFO("Total indexed column width greater than 32: " + ss.str());
|
||||||
|
logging::Message::Args args;
|
||||||
logging::Message message(9);
|
logging::Message message(9);
|
||||||
args.add("Error creating index: ");
|
args.add("Error creating index: ");
|
||||||
args.add("Total indexed column width");
|
args.add("Total indexed column width");
|
||||||
@@ -144,71 +152,73 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
|||||||
result.result = CREATE_ERROR;
|
result.result = CREATE_ERROR;
|
||||||
result.message = message;
|
result.message = message;
|
||||||
return result;
|
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");
|
try
|
||||||
//writeSysIndexColMetaData(createIndexStmt.fSessionID, txnID.id, result,*createIndexStmt.fTableName, createIndexStmt.fColumnNames, createIndexStmt.fIndexName->fName );
|
|
||||||
|
|
||||||
if (createIndexStmt.fUnique)
|
|
||||||
{
|
{
|
||||||
VERBOSE_INFO("Writing column constraint meta data to SYSCONSTRAINT");
|
//writeSysIndexMetaData(createIndexStmt.fSessionID, txnID.id, result, *createIndexStmt.fTableName, type, createIndexStmt.fIndexName->fName, multicol);
|
||||||
WriteEngine::ColStruct colStruct;
|
|
||||||
WriteEngine::ColTuple colTuple;
|
|
||||||
WriteEngine::ColStructList colStructs;
|
|
||||||
WriteEngine::ColTupleList colTuples;
|
|
||||||
WriteEngine::ColValueList colValuesList;
|
|
||||||
WriteEngine::RIDList ridList;
|
|
||||||
|
|
||||||
DDLColumn column;
|
//fIdxOID values are set in writeSysIndexMetaData.
|
||||||
|
pop.setIdxOID(fIdxOID);
|
||||||
|
|
||||||
CalpontSystemCatalog::TableName sysConsTableName;
|
VERBOSE_INFO("Writing meta data to SYSINDEXCOL");
|
||||||
sysConsTableName.schema = CALPONT_SCHEMA;
|
//writeSysIndexColMetaData(createIndexStmt.fSessionID, txnID.id, result,*createIndexStmt.fTableName, createIndexStmt.fColumnNames, createIndexStmt.fIndexName->fName );
|
||||||
sysConsTableName.table = SYSCONSTRAINT_TABLE;
|
|
||||||
|
|
||||||
bool isNull = false;
|
if (createIndexStmt.fUnique)
|
||||||
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;
|
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);
|
boost::algorithm::to_lower(column.tableColName.column);
|
||||||
isNull = false;
|
isNull = false;
|
||||||
|
|
||||||
if (CONSTRAINTNAME_COL == column.tableColName.column)
|
if (CONSTRAINTNAME_COL == column.tableColName.column)
|
||||||
{
|
{
|
||||||
idxData = createIndexStmt.fIndexName->fName;
|
idxData = createIndexStmt.fIndexName->fName;
|
||||||
boost::algorithm::to_lower(idxData);
|
boost::algorithm::to_lower(idxData);
|
||||||
colTuple.data = idxData;
|
colTuple.data = idxData;
|
||||||
}
|
}
|
||||||
else if (SCHEMA_COL == column.tableColName.column)
|
else if (SCHEMA_COL == column.tableColName.column)
|
||||||
{
|
{
|
||||||
idxData = (createIndexStmt.fTableName)->fSchema;
|
idxData = (createIndexStmt.fTableName)->fSchema;
|
||||||
boost::algorithm::to_lower(idxData);
|
boost::algorithm::to_lower(idxData);
|
||||||
colTuple.data = idxData;
|
colTuple.data = idxData;
|
||||||
}
|
}
|
||||||
else if (TABLENAME_COL == column.tableColName.column)
|
else if (TABLENAME_COL == column.tableColName.column)
|
||||||
{
|
{
|
||||||
idxData = (createIndexStmt.fTableName)->fName;
|
idxData = (createIndexStmt.fTableName)->fName;
|
||||||
boost::algorithm::to_lower(idxData);
|
boost::algorithm::to_lower(idxData);
|
||||||
colTuple.data = idxData;
|
colTuple.data = idxData;
|
||||||
}
|
}
|
||||||
else if (CONSTRAINTTYPE_COL == column.tableColName.column)
|
else if (CONSTRAINTTYPE_COL == column.tableColName.column)
|
||||||
{
|
{
|
||||||
std::string consType;
|
std::string consType;
|
||||||
char constraint_type = getConstraintCode(type);
|
char constraint_type = getConstraintCode(type);
|
||||||
consType += constraint_type;
|
consType += constraint_type;
|
||||||
colTuple.data = consType;
|
colTuple.data = consType;
|
||||||
}
|
}
|
||||||
@@ -219,14 +229,14 @@ try
|
|||||||
}
|
}
|
||||||
else if (CONSTRAINTTEXT_COL == column.tableColName.column)
|
else if (CONSTRAINTTEXT_COL == column.tableColName.column)
|
||||||
{
|
{
|
||||||
colTuple.data = getNullValueForType(column.colType);
|
colTuple.data = getNullValueForType(column.colType);
|
||||||
isNull = true;
|
isNull = true;
|
||||||
}
|
}
|
||||||
else if (INDEXNAME_COL == column.tableColName.column)
|
else if (INDEXNAME_COL == column.tableColName.column)
|
||||||
{
|
{
|
||||||
idxData = createIndexStmt.fIndexName->fName;
|
idxData = createIndexStmt.fIndexName->fName;
|
||||||
boost::algorithm::to_lower(idxData);
|
boost::algorithm::to_lower(idxData);
|
||||||
colTuple.data = idxData;
|
colTuple.data = idxData;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -235,7 +245,7 @@ try
|
|||||||
}
|
}
|
||||||
|
|
||||||
colStruct.dataOid = column.oid;
|
colStruct.dataOid = column.oid;
|
||||||
|
|
||||||
colStruct.colWidth = column.colType.colWidth > 8 ? 8 : column.colType.colWidth;
|
colStruct.colWidth = column.colType.colWidth > 8 ? 8 : column.colType.colWidth;
|
||||||
colStruct.tokenFlag = false;
|
colStruct.tokenFlag = false;
|
||||||
colStruct.tokenFlag = column.colType.colWidth > 8 ? true : false;
|
colStruct.tokenFlag = column.colType.colWidth > 8 ? true : false;
|
||||||
@@ -245,8 +255,9 @@ try
|
|||||||
{
|
{
|
||||||
colTuple.data = tokenizeData(txnID.id, result, column.colType, colTuple.data);
|
colTuple.data = tokenizeData(txnID.id, result, column.colType, colTuple.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
colStructs.push_back( colStruct );
|
colStructs.push_back( colStruct );
|
||||||
|
|
||||||
colTuples.push_back( colTuple );
|
colTuples.push_back( colTuple );
|
||||||
|
|
||||||
colValuesList.push_back( colTuples );
|
colValuesList.push_back( colTuples );
|
||||||
@@ -255,14 +266,14 @@ try
|
|||||||
++sysCons_iterator;
|
++sysCons_iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colStructs.size() != 0)
|
if (colStructs.size() != 0)
|
||||||
{
|
{
|
||||||
//fWriteEngine.setDebugLevel(WriteEngine::DEBUG_3);
|
//fWriteEngine.setDebugLevel(WriteEngine::DEBUG_3);
|
||||||
//error = fWriteEngine.insertColumnRec( txnID.id, colStructs, colValuesList, ridList );
|
//error = fWriteEngine.insertColumnRec( txnID.id, colStructs, colValuesList, ridList );
|
||||||
if ( error != WriteEngine::NO_ERROR )
|
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::Args args;
|
||||||
// logging::Message message(9);
|
// logging::Message message(9);
|
||||||
// args.add("Error updating: ");
|
// args.add("Error updating: ");
|
||||||
@@ -270,38 +281,39 @@ try
|
|||||||
// args.add("error number: ");
|
// args.add("error number: ");
|
||||||
// args.add( error );
|
// args.add( error );
|
||||||
// message.format( args );
|
// message.format( args );
|
||||||
//
|
//
|
||||||
// result.result = CREATE_ERROR;
|
// result.result = CREATE_ERROR;
|
||||||
// result.message = message;
|
// result.message = message;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result.result = NO_ERROR;
|
result.result = NO_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VERBOSE_INFO("Writing column constraint meta data to SYSCONSTRAINTCOL");
|
VERBOSE_INFO("Writing column constraint meta data to SYSCONSTRAINTCOL");
|
||||||
WriteEngine::ColStruct colStructCol;
|
WriteEngine::ColStruct colStructCol;
|
||||||
WriteEngine::ColTuple colTupleCol;
|
WriteEngine::ColTuple colTupleCol;
|
||||||
WriteEngine::ColStructList colStructsCol;
|
WriteEngine::ColStructList colStructsCol;
|
||||||
WriteEngine::ColTupleList colTuplesCol;
|
WriteEngine::ColTupleList colTuplesCol;
|
||||||
WriteEngine::ColValueList colValuesListCol;
|
WriteEngine::ColValueList colValuesListCol;
|
||||||
CalpontSystemCatalog::TableName sysConsColTableName;
|
CalpontSystemCatalog::TableName sysConsColTableName;
|
||||||
sysConsColTableName.schema = CALPONT_SCHEMA;
|
sysConsColTableName.schema = CALPONT_SCHEMA;
|
||||||
sysConsColTableName.table = SYSCONSTRAINTCOL_TABLE;
|
sysConsColTableName.table = SYSCONSTRAINTCOL_TABLE;
|
||||||
colValuesList.clear();
|
colValuesList.clear();
|
||||||
colTuples.clear();
|
colTuples.clear();
|
||||||
isNull = false;
|
isNull = false;
|
||||||
error = 0;
|
error = 0;
|
||||||
// get the columns for the SYSCONSTRAINTCOL table
|
// get the columns for the SYSCONSTRAINTCOL table
|
||||||
ColumnList sysConsColColumns;
|
ColumnList sysConsColColumns;
|
||||||
ColumnList::const_iterator sysConsCol_iterator;
|
ColumnList::const_iterator sysConsCol_iterator;
|
||||||
getColumnsForTable(createIndexStmt.fSessionID, sysConsColTableName.schema,sysConsColTableName.table, sysConsColColumns);
|
getColumnsForTable(createIndexStmt.fSessionID, sysConsColTableName.schema, sysConsColTableName.table, sysConsColColumns);
|
||||||
// write sysconstraintcol
|
// write sysconstraintcol
|
||||||
sysConsCol_iterator = sysConsColColumns.begin();
|
sysConsCol_iterator = sysConsColColumns.begin();
|
||||||
std::string colData;
|
std::string colData;
|
||||||
while ( sysConsCol_iterator != sysConsColColumns.end() )
|
|
||||||
{
|
while ( sysConsCol_iterator != sysConsColColumns.end() )
|
||||||
|
{
|
||||||
column = *sysConsCol_iterator;
|
column = *sysConsCol_iterator;
|
||||||
boost::algorithm::to_lower(column.tableColName.column);
|
boost::algorithm::to_lower(column.tableColName.column);
|
||||||
|
|
||||||
@@ -311,20 +323,20 @@ try
|
|||||||
{
|
{
|
||||||
colData = (createIndexStmt.fTableName)->fSchema;
|
colData = (createIndexStmt.fTableName)->fSchema;
|
||||||
boost::algorithm::to_lower(colData);
|
boost::algorithm::to_lower(colData);
|
||||||
colTupleCol.data = colData;
|
colTupleCol.data = colData;
|
||||||
}
|
}
|
||||||
else if (TABLENAME_COL == column.tableColName.column)
|
else if (TABLENAME_COL == column.tableColName.column)
|
||||||
{
|
{
|
||||||
colData = (createIndexStmt.fTableName)->fName;
|
colData = (createIndexStmt.fTableName)->fName;
|
||||||
boost::algorithm::to_lower(colData);
|
boost::algorithm::to_lower(colData);
|
||||||
colTupleCol.data = colData;
|
colTupleCol.data = colData;
|
||||||
}
|
}
|
||||||
else if (COLNAME_COL == column.tableColName.column)
|
else if (COLNAME_COL == column.tableColName.column)
|
||||||
{
|
{
|
||||||
colData = createIndexStmt.fColumnNames[0];
|
colData = createIndexStmt.fColumnNames[0];
|
||||||
boost::algorithm::to_lower(colData);
|
boost::algorithm::to_lower(colData);
|
||||||
colTupleCol.data = colData;
|
colTupleCol.data = colData;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (CONSTRAINTNAME_COL == column.tableColName.column)
|
else if (CONSTRAINTNAME_COL == column.tableColName.column)
|
||||||
{
|
{
|
||||||
@@ -348,9 +360,9 @@ try
|
|||||||
{
|
{
|
||||||
colTupleCol.data = tokenizeData(txnID.id, result, column.colType, colTupleCol.data);
|
colTupleCol.data = tokenizeData(txnID.id, result, column.colType, colTupleCol.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
colStructsCol.push_back( colStructCol );
|
colStructsCol.push_back( colStructCol );
|
||||||
|
|
||||||
colTuplesCol.push_back( colTupleCol );
|
colTuplesCol.push_back( colTupleCol );
|
||||||
|
|
||||||
colValuesListCol.push_back( colTuplesCol );
|
colValuesListCol.push_back( colTuplesCol );
|
||||||
@@ -359,69 +371,73 @@ try
|
|||||||
|
|
||||||
++sysConsCol_iterator;
|
++sysConsCol_iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colStructsCol.size() != 0)
|
if (colStructsCol.size() != 0)
|
||||||
{
|
{
|
||||||
//fWriteEngine.setDebugLevel(WriteEngine::DEBUG_3);
|
//fWriteEngine.setDebugLevel(WriteEngine::DEBUG_3);
|
||||||
//error = fWriteEngine.insertColumnRec( txnID.id, colStructsCol, colValuesListCol, ridList );
|
//error = fWriteEngine.insertColumnRec( txnID.id, colStructsCol, colValuesListCol, ridList );
|
||||||
if ( error != WriteEngine::NO_ERROR )
|
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: ");
|
|
||||||
args.add("calpont.sysconstraintcol");
|
|
||||||
args.add("error number: ");
|
|
||||||
args.add( error );
|
|
||||||
message.format( args );
|
|
||||||
|
|
||||||
result.result = CREATE_ERROR;
|
/* logging::Message::Args args;
|
||||||
result.message = message;*/
|
logging::Message message(9);
|
||||||
}
|
args.add("Error updating: ");
|
||||||
else
|
args.add("calpont.sysconstraintcol");
|
||||||
{
|
args.add("error number: ");
|
||||||
result.result = NO_ERROR;
|
args.add( error );
|
||||||
}
|
message.format( args );
|
||||||
}
|
|
||||||
}
|
result.result = CREATE_ERROR;
|
||||||
|
result.message = message;*/
|
||||||
VERBOSE_INFO("Creating index files");
|
}
|
||||||
err = fWriteEngine.createIndex( txnID.id, fIdxOID.treeOID, fIdxOID.listOID );
|
else
|
||||||
if (err)
|
{
|
||||||
{
|
result.result = NO_ERROR;
|
||||||
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 )
|
VERBOSE_INFO("Creating index files");
|
||||||
{
|
err = fWriteEngine.createIndex( txnID.id, fIdxOID.treeOID, fIdxOID.listOID );
|
||||||
return rollBackCreateIndex(errorString("Failed to populate index with current data. ", err), txnID, createIndexStmt.fSessionID);
|
|
||||||
}
|
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.
|
// Log the DDL statement.
|
||||||
logging::logDDL(createIndexStmt.fSessionID, txnID.id, createIndexStmt.fSql, createIndexStmt.fOwner);
|
logging::logDDL(createIndexStmt.fSessionID, txnID.id, createIndexStmt.fSql, createIndexStmt.fOwner);
|
||||||
|
|
||||||
DETAIL_INFO("Commiting transaction");
|
DETAIL_INFO("Commiting transaction");
|
||||||
err = fWriteEngine.commit( txnID.id );
|
err = fWriteEngine.commit( txnID.id );
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
return rollBackCreateIndex(errorString("Failed to commit the create index transaction. ", err), txnID, createIndexStmt.fSessionID);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 }
|
// original if BULK_LOAD close }
|
||||||
} // try
|
} // try
|
||||||
|
|
||||||
catch (exception& ex)
|
catch (exception& ex)
|
||||||
{
|
{
|
||||||
result = rollBackCreateIndex(ex.what(), txnID, createIndexStmt.fSessionID);
|
result = rollBackCreateIndex(ex.what(), txnID, createIndexStmt.fSessionID);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
string msg("CreateIndexProcessor::processPackage: caught unknown exception!");
|
string msg("CreateIndexProcessor::processPackage: caught unknown exception!");
|
||||||
result = rollBackCreateIndex(msg, txnID, createIndexStmt.fSessionID);
|
result = rollBackCreateIndex(msg, txnID, createIndexStmt.fSessionID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -429,44 +445,47 @@ try
|
|||||||
|
|
||||||
string CreateIndexProcessor::errorString(const string& msg, int error)
|
string CreateIndexProcessor::errorString(const string& msg, int error)
|
||||||
{
|
{
|
||||||
WriteEngine::WErrorCodes ec;
|
WriteEngine::WErrorCodes ec;
|
||||||
return string(msg + ec.errorString(error));
|
return string(msg + ec.errorString(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CreateIndexProcessor::DDLResult CreateIndexProcessor::rollBackCreateIndex(const string& error, BRM::TxnID& txnID, int sessionId)
|
CreateIndexProcessor::DDLResult CreateIndexProcessor::rollBackCreateIndex(const string& error, BRM::TxnID& txnID, int sessionId)
|
||||||
{
|
{
|
||||||
cerr << "CreatetableProcessor::processPackage: " << error << endl;
|
cerr << "CreatetableProcessor::processPackage: " << error << endl;
|
||||||
DETAIL_INFO(error);
|
DETAIL_INFO(error);
|
||||||
logging::Message::Args args;
|
logging::Message::Args args;
|
||||||
logging::Message message(1);
|
logging::Message message(1);
|
||||||
args.add("Create Index Failed: ");
|
args.add("Create Index Failed: ");
|
||||||
args.add( error );
|
args.add( error );
|
||||||
args.add("");
|
args.add("");
|
||||||
args.add("");
|
args.add("");
|
||||||
message.format( args );
|
message.format( args );
|
||||||
DDLResult result;
|
DDLResult result;
|
||||||
result.result = CREATE_ERROR;
|
result.result = CREATE_ERROR;
|
||||||
result.message = message;
|
result.message = message;
|
||||||
rollBackIndex(txnID, sessionId);
|
rollBackIndex(txnID, sessionId);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateIndexProcessor::rollBackIndex(BRM::TxnID& txnID, int sessionId)
|
void CreateIndexProcessor::rollBackIndex(BRM::TxnID& txnID, int sessionId)
|
||||||
{
|
{
|
||||||
fWriteEngine.rollbackTran(txnID.id, sessionId);
|
fWriteEngine.rollbackTran(txnID.id, sessionId);
|
||||||
fWriteEngine.dropIndex(txnID.id,fIdxOID.listOID, fIdxOID.treeOID);
|
fWriteEngine.dropIndex(txnID.id, fIdxOID.listOID, fIdxOID.treeOID);
|
||||||
try {
|
|
||||||
//execplan::ObjectIDManager fObjectIDManager;
|
try
|
||||||
//fObjectIDManager.returnOIDs(fIdxOID.treeOID, fIdxOID.listOID);
|
{
|
||||||
}
|
//execplan::ObjectIDManager fObjectIDManager;
|
||||||
catch ( exception& ex )
|
//fObjectIDManager.returnOIDs(fIdxOID.treeOID, fIdxOID.listOID);
|
||||||
{
|
}
|
||||||
|
catch ( exception& ex )
|
||||||
}
|
{
|
||||||
catch (... )
|
|
||||||
{ }
|
}
|
||||||
fSessionManager.rolledback(txnID);
|
catch (... )
|
||||||
|
{ }
|
||||||
|
|
||||||
|
fSessionManager.rolledback(txnID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,26 +29,26 @@
|
|||||||
const int BULK_LOAD = 1;
|
const int BULK_LOAD = 1;
|
||||||
namespace ddlpackageprocessor
|
namespace ddlpackageprocessor
|
||||||
{
|
{
|
||||||
/** @brief specialization of a DDLPackageProcessor
|
/** @brief specialization of a DDLPackageProcessor
|
||||||
* for interacting with the Write Engine to process
|
* for interacting with the Write Engine to process
|
||||||
* create index ddl statements
|
* 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
|
DDLResult processPackage(ddlpackage::CreateIndexStatement& createIndexStmt);
|
||||||
{
|
|
||||||
public:
|
|
||||||
/** @brief process a create index statement
|
|
||||||
*
|
|
||||||
* @param createIndexStmt the create index statement
|
|
||||||
*/
|
|
||||||
DDLResult processPackage(ddlpackage::CreateIndexStatement& createIndexStmt);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DDLResult rollBackCreateIndex(const std::string& error, BRM::TxnID& txnID, int sessionId);
|
DDLResult rollBackCreateIndex(const std::string& error, BRM::TxnID& txnID, int sessionId);
|
||||||
void rollBackIndex(BRM::TxnID& txnID);
|
void rollBackIndex(BRM::TxnID& txnID);
|
||||||
std::string errorString(const std::string& msg, int error);
|
std::string errorString(const std::string& msg, int error);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace ddlpackageprocessor
|
} //namespace ddlpackageprocessor
|
||||||
#endif //CREATEINDEXPROCESSOR_H
|
#endif //CREATEINDEXPROCESSOR_H
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -42,8 +42,8 @@ namespace ddlpackageprocessor
|
|||||||
class CreateTableProcessor : public DDLPackageProcessor
|
class CreateTableProcessor : public DDLPackageProcessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CreateTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm){}
|
CreateTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||||
/** @brief process a create table statement
|
/** @brief process a create table statement
|
||||||
*
|
*
|
||||||
* @param createTableStmt the CreateTableStatement
|
* @param createTableStmt the CreateTableStatement
|
||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
EXPORT DDLResult processPackage(ddlpackage::CreateTableStatement& createTableStmt);
|
EXPORT DDLResult processPackage(ddlpackage::CreateTableStatement& createTableStmt);
|
||||||
|
|
||||||
protected:
|
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:
|
private:
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -43,62 +43,78 @@
|
|||||||
|
|
||||||
#include "joblistfactory.h"
|
#include "joblistfactory.h"
|
||||||
|
|
||||||
namespace joblist {
|
namespace joblist
|
||||||
|
{
|
||||||
class DistributedEngineComm;
|
class DistributedEngineComm;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ddlpackageprocessor
|
namespace ddlpackageprocessor
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @brief Populate an new Index
|
/** @brief Populate an new Index
|
||||||
* implementation of a DDLPopulator
|
* implementation of a DDLPopulator
|
||||||
*/
|
*/
|
||||||
class DDLIndexPopulator
|
class DDLIndexPopulator
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** @brief constructor
|
/** @brief constructor
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
DDLIndexPopulator(WriteEngine::WriteEngineWrapper* writeEngine,
|
DDLIndexPopulator(WriteEngine::WriteEngineWrapper* writeEngine,
|
||||||
execplan::SessionManager* sessionManager,
|
execplan::SessionManager* sessionManager,
|
||||||
uint32_t sessionID,
|
uint32_t sessionID,
|
||||||
execplan::CalpontSystemCatalog::SCN txnID,
|
execplan::CalpontSystemCatalog::SCN txnID,
|
||||||
DDLPackageProcessor::DDLResult& result,
|
DDLPackageProcessor::DDLResult& result,
|
||||||
const DDLPackageProcessor::IndexOID& idxOID,
|
const DDLPackageProcessor::IndexOID& idxOID,
|
||||||
const ddlpackage::ColumnNameList& colNames,
|
const ddlpackage::ColumnNameList& colNames,
|
||||||
const ddlpackage::QualifiedName& table,
|
const ddlpackage::QualifiedName& table,
|
||||||
const ddlpackage::DDL_CONSTRAINTS constraint,
|
const ddlpackage::DDL_CONSTRAINTS constraint,
|
||||||
const DDLPackageProcessor::DebugLevel debug):
|
const DDLPackageProcessor::DebugLevel debug):
|
||||||
fWriteEngine(writeEngine), fSessionManager(sessionManager),
|
fWriteEngine(writeEngine), fSessionManager(sessionManager),
|
||||||
fSessionID(sessionID), fTxnID(txnID), fResult(result),
|
fSessionID(sessionID), fTxnID(txnID), fResult(result),
|
||||||
fIdxOID(idxOID), fColNames(colNames), fTable(table), fDebugLevel(debug),
|
fIdxOID(idxOID), fColNames(colNames), fTable(table), fDebugLevel(debug),
|
||||||
fEC(0), fRidList(), fIdxStructList(), fIdxValueList(),
|
fEC(0), fRidList(), fIdxStructList(), fIdxValueList(),
|
||||||
/* fTOKENSIZE(sizeof(WriteEngine::Token) ) {}*/
|
/* fTOKENSIZE(sizeof(WriteEngine::Token) ) {}*/
|
||||||
fConstraint(constraint), fUniqueColResultList() {}
|
fConstraint(constraint), fUniqueColResultList() {}
|
||||||
|
|
||||||
|
|
||||||
/** @brief destructor
|
/** @brief destructor
|
||||||
*/
|
*/
|
||||||
virtual ~DDLIndexPopulator() { };
|
virtual ~DDLIndexPopulator() { };
|
||||||
|
|
||||||
|
|
||||||
/** @brief Is it required to debug
|
/** @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
|
/** @brief Get debug level
|
||||||
*/
|
*/
|
||||||
const DDLPackageProcessor::DebugLevel getDebugLevel() const { return fDebugLevel; }
|
const DDLPackageProcessor::DebugLevel getDebugLevel() const
|
||||||
|
{
|
||||||
|
return fDebugLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @brief set distributedEngineComm pointer ( for
|
/** @brief set distributedEngineComm pointer ( for
|
||||||
* loading index).
|
* loading index).
|
||||||
*/
|
*/
|
||||||
void setEngineComm(joblist::DistributedEngineComm* ec) { fEC = ec; }
|
void setEngineComm(joblist::DistributedEngineComm* ec)
|
||||||
void setIdxOID(const DDLPackageProcessor::IndexOID& idxOID) { fIdxOID = idxOID; }
|
{
|
||||||
|
fEC = ec;
|
||||||
DDLPackageProcessor::DDLResult getResult() const { return fResult; }
|
}
|
||||||
|
void setIdxOID(const DDLPackageProcessor::IndexOID& idxOID)
|
||||||
|
{
|
||||||
|
fIdxOID = idxOID;
|
||||||
|
}
|
||||||
|
|
||||||
|
DDLPackageProcessor::DDLResult getResult() const
|
||||||
|
{
|
||||||
|
return fResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @brief add data to the index from the statement
|
/** @brief add data to the index from the statement
|
||||||
@@ -107,16 +123,16 @@ public:
|
|||||||
* returns if there was an error.
|
* returns if there was an error.
|
||||||
*/
|
*/
|
||||||
bool populateIndex(DDLPackageProcessor::DDLResult& result);
|
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
|
* 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);
|
void setConstraint(ddlpackage::DDL_CONSTRAINTS constraint);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/** @brief make the structures to update the index
|
/** @brief make the structures to update the index
|
||||||
*
|
*
|
||||||
* builds and executes a query to retrieve all the data from the index columns
|
* builds and executes a query to retrieve all the data from the index columns
|
||||||
@@ -131,7 +147,7 @@ public:
|
|||||||
* the WriteEngine::IdxStruct
|
* the WriteEngine::IdxStruct
|
||||||
*/
|
*/
|
||||||
execplan::CalpontSystemCatalog::ColType makeIdxStruct(const execplan::ColumnResult* cr, size_t cols, boost::shared_ptr<execplan::CalpontSystemCatalog> csc );
|
execplan::CalpontSystemCatalog::ColType makeIdxStruct(const execplan::ColumnResult* cr, size_t cols, boost::shared_ptr<execplan::CalpontSystemCatalog> csc );
|
||||||
|
|
||||||
/** @brief add the column result data to the value list
|
/** @brief add the column result data to the value list
|
||||||
*
|
*
|
||||||
* Check contraints on each data item and adds it to a tuple list.
|
* Check contraints on each data item and adds it to a tuple list.
|
||||||
@@ -142,15 +158,15 @@ public:
|
|||||||
|
|
||||||
/** @brief insert data into index.
|
/** @brief insert data into index.
|
||||||
*
|
*
|
||||||
* updates the index with the data using the appropriate write engine method
|
* updates the index with the data using the appropriate write engine method
|
||||||
* based on multi column. Sets result to error if there is one.
|
* based on multi column. Sets result to error if there is one.
|
||||||
*/
|
*/
|
||||||
void insertIndex();
|
void insertIndex();
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
DDLIndexPopulator(const DDLIndexPopulator& );
|
private:
|
||||||
void operator=(const DDLIndexPopulator& );
|
DDLIndexPopulator(const DDLIndexPopulator& );
|
||||||
|
void operator=(const DDLIndexPopulator& );
|
||||||
/** @brief makes Calpont Select Execution Plan
|
/** @brief makes Calpont Select Execution Plan
|
||||||
*
|
*
|
||||||
* builds csep to select data from all columns from fColNames
|
* builds csep to select data from all columns from fColNames
|
||||||
@@ -165,12 +181,12 @@ public:
|
|||||||
|
|
||||||
bool isStringType(int type) const
|
bool isStringType(int type) const
|
||||||
{
|
{
|
||||||
return (type == execplan::CalpontSystemCatalog::CHAR
|
return (type == execplan::CalpontSystemCatalog::CHAR
|
||||||
|| type == execplan::CalpontSystemCatalog::VARCHAR
|
|| type == execplan::CalpontSystemCatalog::VARCHAR
|
||||||
|| type == execplan::CalpontSystemCatalog::FLOAT
|
|| type == execplan::CalpontSystemCatalog::FLOAT
|
||||||
|| type == execplan::CalpontSystemCatalog::DOUBLE
|
|| type == execplan::CalpontSystemCatalog::DOUBLE
|
||||||
|| type == execplan::CalpontSystemCatalog::UFLOAT
|
|| type == execplan::CalpontSystemCatalog::UFLOAT
|
||||||
|| type == execplan::CalpontSystemCatalog::UDOUBLE );
|
|| type == execplan::CalpontSystemCatalog::UDOUBLE );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief converts column result data
|
/** @brief converts column result data
|
||||||
@@ -182,32 +198,32 @@ public:
|
|||||||
/** @brief converts non token data to its original type
|
/** @brief converts non token data to its original type
|
||||||
*/
|
*/
|
||||||
boost::any convertData(const execplan::CalpontSystemCatalog::ColType& colType, const execplan::ColumnResult* cr, int idx );
|
boost::any convertData(const execplan::CalpontSystemCatalog::ColType& colType, const execplan::ColumnResult* cr, int idx );
|
||||||
|
|
||||||
/** @brief returns token for string data
|
/** @brief returns token for string data
|
||||||
*
|
*
|
||||||
* There are two methods, the one using the rid is a workaround.
|
* There are two methods, the one using the rid is a workaround.
|
||||||
* Use the method that passes string data when WriteEngine::tokenize is
|
* Use the method that passes string data when WriteEngine::tokenize is
|
||||||
* able to return an existing token for a string. The rid method reads
|
* able to return an existing token for a string. The rid method reads
|
||||||
* the column file directly.
|
* the column file directly.
|
||||||
*/
|
*/
|
||||||
boost::any tokenizeData( const execplan::CalpontSystemCatalog::ColType& colType, const std::string& data );
|
boost::any tokenizeData( const execplan::CalpontSystemCatalog::ColType& colType, const std::string& data );
|
||||||
|
|
||||||
boost::any tokenizeData( WriteEngine::RID rid );
|
boost::any tokenizeData( WriteEngine::RID rid );
|
||||||
|
|
||||||
/** @brief convert token data
|
/** @brief convert token data
|
||||||
*
|
*
|
||||||
* Indexes will use the first 8 bytes of a token type value instead
|
* Indexes will use the first 8 bytes of a token type value instead
|
||||||
* of a token.
|
* of a token.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
boost::any convertTokenData( const std::string& data );
|
boost::any convertTokenData( const std::string& data );
|
||||||
|
|
||||||
/** @brief opens the column file for the oid
|
/** @brief opens the column file for the oid
|
||||||
*
|
*
|
||||||
* This method is needed only as long as the class is using the rid
|
* This method is needed only as long as the class is using the rid
|
||||||
* tokenizeData method. The fColumnFile and this method are no longer
|
* tokenizeData method. The fColumnFile and this method are no longer
|
||||||
* needed when the WriteEngine::tokenize method can be used.
|
* needed when the WriteEngine::tokenize method can be used.
|
||||||
*/
|
*/
|
||||||
//bool openColumnFile(WriteEngine::OID oid);
|
//bool openColumnFile(WriteEngine::OID oid);
|
||||||
|
|
||||||
/** @brief returns if data violated its constraint
|
/** @brief returns if data violated its constraint
|
||||||
@@ -215,7 +231,7 @@ public:
|
|||||||
* checks data according to contraint in coltype and sets result to error
|
* checks data according to contraint in coltype and sets result to error
|
||||||
* if constraint violated. Returns if no error.
|
* if constraint violated. Returns if no error.
|
||||||
*/
|
*/
|
||||||
bool checkConstraints(const WriteEngine::IdxTuple& data, const execplan::CalpontSystemCatalog::ColType& ctype, int i, int column);
|
bool checkConstraints(const WriteEngine::IdxTuple& data, const execplan::CalpontSystemCatalog::ColType& ctype, int i, int column);
|
||||||
|
|
||||||
/** @brief returns if data not null
|
/** @brief returns if data not null
|
||||||
*
|
*
|
||||||
@@ -229,19 +245,25 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool checkUnique(int i, const execplan::CalpontSystemCatalog::ColType& colType );
|
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
|
/** @brief logs error and message
|
||||||
*
|
*
|
||||||
* Updates result with message and sets it to CREATE_ERROR
|
* Updates result with message and sets it to CREATE_ERROR
|
||||||
*/
|
*/
|
||||||
void logError(const std::string& msg, int error = 0);
|
void logError(const std::string& msg, int error = 0);
|
||||||
|
|
||||||
bool compareToken(const WriteEngine::Token& first, const WriteEngine::Token& second) const
|
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;
|
WriteEngine::WriteEngineWrapper* fWriteEngine;
|
||||||
execplan::SessionManager* fSessionManager;
|
execplan::SessionManager* fSessionManager;
|
||||||
@@ -251,8 +273,8 @@ public:
|
|||||||
DDLPackageProcessor::IndexOID fIdxOID;
|
DDLPackageProcessor::IndexOID fIdxOID;
|
||||||
ddlpackage::ColumnNameList fColNames;
|
ddlpackage::ColumnNameList fColNames;
|
||||||
ddlpackage::QualifiedName fTable;
|
ddlpackage::QualifiedName fTable;
|
||||||
DDLPackageProcessor::DebugLevel fDebugLevel;
|
DDLPackageProcessor::DebugLevel fDebugLevel;
|
||||||
joblist::DistributedEngineComm* fEC;
|
joblist::DistributedEngineComm* fEC;
|
||||||
WriteEngine::RIDList fRidList;
|
WriteEngine::RIDList fRidList;
|
||||||
WriteEngine::IdxStructList fIdxStructList;
|
WriteEngine::IdxStructList fIdxStructList;
|
||||||
WriteEngine::IdxValueList fIdxValueList;
|
WriteEngine::IdxValueList fIdxValueList;
|
||||||
@@ -265,16 +287,16 @@ public:
|
|||||||
|
|
||||||
struct DDLNullValueForType : DDLPackageProcessor
|
struct DDLNullValueForType : DDLPackageProcessor
|
||||||
{
|
{
|
||||||
DDLNullValueForType(const execplan::CalpontSystemCatalog::ColType& ctype)
|
DDLNullValueForType(const execplan::CalpontSystemCatalog::ColType& ctype)
|
||||||
: DDLPackageProcessor(), fType(ctype) {}
|
: DDLPackageProcessor(), fType(ctype) {}
|
||||||
boost::any operator()(execplan::CalpontSystemCatalog::ColType& ctype)
|
boost::any operator()(execplan::CalpontSystemCatalog::ColType& ctype)
|
||||||
{
|
{
|
||||||
return getNullValueForType(fType);
|
return getNullValueForType(fType);
|
||||||
}
|
}
|
||||||
const execplan::CalpontSystemCatalog::ColType& fType;
|
const execplan::CalpontSystemCatalog::ColType& fType;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif //DDLPINDEXPOPULATOR_H
|
#endif //DDLPINDEXPOPULATOR_H
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -88,26 +88,28 @@ public:
|
|||||||
*/
|
*/
|
||||||
enum ResultCode { NO_ERROR, CREATE_ERROR, ALTER_ERROR, DROP_ERROR, TRUNC_ERROR,
|
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,
|
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 */
|
NONE = 0, /** @brief No debug info */
|
||||||
SUMMARY = 1, /** @brief Summary level debug info */
|
SUMMARY = 1, /** @brief Summary level debug info */
|
||||||
DETAIL = 2, /** @brief A little detail debug info */
|
DETAIL = 2, /** @brief A little detail debug info */
|
||||||
VERBOSE = 3, /** @brief Detailed debug info */
|
VERBOSE = 3, /** @brief Detailed debug info */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum LogFileType { DROPTABLE_LOG, DROPPART_LOG, TRUNCATE_LOG};
|
enum LogFileType { DROPTABLE_LOG, DROPPART_LOG, TRUNCATE_LOG};
|
||||||
typedef std::vector<execplan::CalpontSystemCatalog::OID> OidList;
|
typedef std::vector<execplan::CalpontSystemCatalog::OID> OidList;
|
||||||
typedef std::set<BRM::LogicalPartition> PartitionNums;
|
typedef std::set<BRM::LogicalPartition> PartitionNums;
|
||||||
struct LogInfo
|
struct LogInfo
|
||||||
{
|
{
|
||||||
LogFileType fileType;
|
LogFileType fileType;
|
||||||
OidList oids;
|
OidList oids;
|
||||||
PartitionNums partitionNums;
|
PartitionNums partitionNums;
|
||||||
};
|
};
|
||||||
typedef std::map<execplan::CalpontSystemCatalog::OID, LogInfo> TableLogInfo;
|
typedef std::map<execplan::CalpontSystemCatalog::OID, LogInfo> TableLogInfo;
|
||||||
|
|
||||||
/** @brief the result of dml operations
|
/** @brief the result of dml operations
|
||||||
*/
|
*/
|
||||||
struct DDLResult
|
struct DDLResult
|
||||||
@@ -153,95 +155,124 @@ public:
|
|||||||
int dictOID;
|
int dictOID;
|
||||||
int listOID;
|
int listOID;
|
||||||
int treeOID;
|
int treeOID;
|
||||||
int colWidth;
|
int colWidth;
|
||||||
int compressionType;
|
int compressionType;
|
||||||
};
|
};
|
||||||
/** @brief a structure to hold a date
|
/** @brief a structure to hold a date
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct Date
|
struct Date
|
||||||
{
|
{
|
||||||
unsigned spare : 6;
|
unsigned spare : 6;
|
||||||
unsigned day : 6;
|
unsigned day : 6;
|
||||||
unsigned month : 4;
|
unsigned month : 4;
|
||||||
unsigned year : 16;
|
unsigned year : 16;
|
||||||
// NULL column value = 0xFFFFFFFE
|
// NULL column value = 0xFFFFFFFE
|
||||||
EXPORT Date( ) { year = 0xFFFF; month = 0xF; day = 0x3F; spare = 0x3E;}
|
EXPORT Date( )
|
||||||
|
{
|
||||||
|
year = 0xFFFF;
|
||||||
|
month = 0xF;
|
||||||
|
day = 0x3F;
|
||||||
|
spare = 0x3E;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
struct Date
|
struct Date
|
||||||
{
|
{
|
||||||
int year : 16;
|
int year : 16;
|
||||||
int month : 4;
|
int month : 4;
|
||||||
int day : 6;
|
int day : 6;
|
||||||
int spare : 6;
|
int spare : 6;
|
||||||
Date( ) { year = 0; month = 0; day = 0; spare = 0;}
|
Date( ) { year = 0; month = 0; day = 0; spare = 0;}
|
||||||
}; */
|
}; */
|
||||||
/** @brief a structure to hold a datetime
|
/** @brief a structure to hold a datetime
|
||||||
*/
|
*/
|
||||||
struct dateTime
|
struct dateTime
|
||||||
{
|
{
|
||||||
unsigned msecond : 20;
|
unsigned msecond : 20;
|
||||||
unsigned second : 6;
|
unsigned second : 6;
|
||||||
unsigned minute : 6;
|
unsigned minute : 6;
|
||||||
unsigned hour : 6;
|
unsigned hour : 6;
|
||||||
unsigned day : 6;
|
unsigned day : 6;
|
||||||
unsigned month : 4;
|
unsigned month : 4;
|
||||||
unsigned year : 16;
|
unsigned year : 16;
|
||||||
// NULL column value = 0xFFFFFFFFFFFFFFFE
|
// NULL column value = 0xFFFFFFFFFFFFFFFE
|
||||||
EXPORT dateTime( ) { year = 0xFFFF; month = 0xF; day = 0x3F; hour = 0x3F; minute = 0x3F; second = 0x3F;
|
EXPORT dateTime( )
|
||||||
msecond = 0xFFFFE; }
|
{
|
||||||
|
year = 0xFFFF;
|
||||||
|
month = 0xF;
|
||||||
|
day = 0x3F;
|
||||||
|
hour = 0x3F;
|
||||||
|
minute = 0x3F;
|
||||||
|
second = 0x3F;
|
||||||
|
msecond = 0xFFFFE;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
struct dateTime
|
struct dateTime
|
||||||
{
|
{
|
||||||
int year : 16;
|
int year : 16;
|
||||||
int month : 4;
|
int month : 4;
|
||||||
int day : 6;
|
int day : 6;
|
||||||
int hour : 6;
|
int hour : 6;
|
||||||
int minute : 6;
|
int minute : 6;
|
||||||
int second : 6;
|
int second : 6;
|
||||||
int msecond : 20;
|
int msecond : 20;
|
||||||
dateTime( ) { year = 0; month = 0; day = 0; hour = 0; minute = 0; second = 0; msecond = 0; }
|
dateTime( ) { year = 0; month = 0; day = 0; hour = 0; minute = 0; second = 0; msecond = 0; }
|
||||||
}
|
}
|
||||||
; */
|
; */
|
||||||
/** @brief a vector of dictionary object ids
|
/** @brief a vector of dictionary object ids
|
||||||
*/
|
*/
|
||||||
typedef std::vector<DictOID> DictionaryOIDList;
|
typedef std::vector<DictOID> DictionaryOIDList;
|
||||||
|
|
||||||
/** the type of a list of ColumnResult as returned from getSysData
|
/** the type of a list of ColumnResult as returned from getSysData
|
||||||
*/
|
*/
|
||||||
typedef std::vector <execplan::ColumnResult*> NJLSysDataVector;
|
typedef std::vector <execplan::ColumnResult*> NJLSysDataVector;
|
||||||
struct NJLSysDataList
|
struct NJLSysDataList
|
||||||
{
|
{
|
||||||
NJLSysDataVector sysDataVec;
|
NJLSysDataVector sysDataVec;
|
||||||
EXPORT NJLSysDataList(){};
|
EXPORT NJLSysDataList() {};
|
||||||
EXPORT ~NJLSysDataList();
|
EXPORT ~NJLSysDataList();
|
||||||
NJLSysDataVector::const_iterator begin() {return sysDataVec.begin();}
|
NJLSysDataVector::const_iterator begin()
|
||||||
NJLSysDataVector::const_iterator end() {return sysDataVec.end();}
|
{
|
||||||
void push_back(execplan::ColumnResult* cr) {sysDataVec.push_back(cr);}
|
return sysDataVec.begin();
|
||||||
unsigned int size() {return static_cast<unsigned int>(sysDataVec.size());}
|
}
|
||||||
int findColumn(const execplan::CalpontSystemCatalog::OID& columnOID)
|
NJLSysDataVector::const_iterator end()
|
||||||
{
|
{
|
||||||
for(uint32_t i = 0; i < sysDataVec.size(); i++) {
|
return sysDataVec.end();
|
||||||
if(sysDataVec[i]->ColumnOID() == columnOID) {
|
}
|
||||||
return i;
|
void push_back(execplan::ColumnResult* cr)
|
||||||
}
|
{
|
||||||
}
|
sysDataVec.push_back(cr);
|
||||||
return -1;
|
}
|
||||||
}
|
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
|
/** @brief constructor
|
||||||
*/
|
*/
|
||||||
DDLPackageProcessor(BRM::DBRM* aDbrm) : fStartingColOID(0), fDDLLoggingId(23), fDebugLevel( NONE )
|
DDLPackageProcessor(BRM::DBRM* aDbrm) : fStartingColOID(0), fDDLLoggingId(23), fDebugLevel( NONE )
|
||||||
{
|
{
|
||||||
fWEClient = new WriteEngine::WEClients(WriteEngine::WEClients::DDLPROC);
|
fWEClient = new WriteEngine::WEClients(WriteEngine::WEClients::DDLPROC);
|
||||||
fPMCount = fWEClient->getPmCount();
|
fPMCount = fWEClient->getPmCount();
|
||||||
fDbrm = aDbrm;
|
fDbrm = aDbrm;
|
||||||
//std::cout << "in DDLPackageProcessor constructor " << this << std::endl;
|
//std::cout << "in DDLPackageProcessor constructor " << this << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief destructor
|
/** @brief destructor
|
||||||
*/
|
*/
|
||||||
@@ -250,56 +281,77 @@ public:
|
|||||||
|
|
||||||
/** @brief Is it required to debug
|
/** @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
|
/** @brief Get debug level
|
||||||
*/
|
*/
|
||||||
const DebugLevel getDebugLevel() const { return fDebugLevel; }
|
const DebugLevel getDebugLevel() const
|
||||||
|
{
|
||||||
|
return fDebugLevel;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Set debug level
|
/** @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
|
/** @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
|
/** @brief Get starting column oid that was allocated during table
|
||||||
* creation.
|
* creation.
|
||||||
*/
|
*/
|
||||||
int getStartingColumnOID() const { return fStartingColOID; }
|
int getStartingColumnOID() const
|
||||||
|
{
|
||||||
/** @brief access and mutator of fPKName */
|
return fStartingColOID;
|
||||||
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
|
|
||||||
*/
|
|
||||||
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);
|
|
||||||
|
|
||||||
/** @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
|
|
||||||
*/
|
|
||||||
EXPORT void removePartitionFiles(std::vector<execplan::CalpontSystemCatalog::OID>& oidList,
|
|
||||||
const PartitionNums& partitions,
|
|
||||||
uint64_t uniqueId);
|
|
||||||
|
|
||||||
/** @brief remove the extents from extent map
|
/** @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
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
|
||||||
|
/** @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
|
||||||
|
*/
|
||||||
|
EXPORT void removePartitionFiles(std::vector<execplan::CalpontSystemCatalog::OID>& oidList,
|
||||||
|
const PartitionNums& partitions,
|
||||||
|
uint64_t uniqueId);
|
||||||
|
|
||||||
|
/** @brief remove the extents from extent map
|
||||||
*
|
*
|
||||||
* @param txnID the transaction id
|
* @param txnID the transaction id
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
@@ -309,47 +361,47 @@ public:
|
|||||||
EXPORT void removeExtents(std::vector<execplan::CalpontSystemCatalog::OID>& oidList);
|
EXPORT void removeExtents(std::vector<execplan::CalpontSystemCatalog::OID>& oidList);
|
||||||
|
|
||||||
|
|
||||||
/** @brief create and open log file to log a table information
|
/** @brief create and open log file to log a table information
|
||||||
*
|
*
|
||||||
* @param tableOid the oid of the table
|
* @param tableOid the oid of the table
|
||||||
* @param tableName the shcema, table name
|
* @param tableName the shcema, table name
|
||||||
*/
|
*/
|
||||||
EXPORT void createWriteDropLogFile(execplan::CalpontSystemCatalog::OID tableOid,
|
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 tableOid the oid of the table
|
||||||
* @param tableName the shcema, table name
|
* @param tableName the shcema, table name
|
||||||
* @param partition the partition number to be dropped
|
* @param partition the partition number to be dropped
|
||||||
*/
|
*/
|
||||||
EXPORT void createWritePartitionLogFile(execplan::CalpontSystemCatalog::OID tableOid,
|
EXPORT void createWritePartitionLogFile(execplan::CalpontSystemCatalog::OID tableOid,
|
||||||
const PartitionNums& partitionNums,
|
const PartitionNums& partitionNums,
|
||||||
std::vector<execplan::CalpontSystemCatalog::OID>& oidList,
|
std::vector<execplan::CalpontSystemCatalog::OID>& oidList,
|
||||||
uint64_t uniqueId);
|
uint64_t uniqueId);
|
||||||
|
|
||||||
// EXPORT void createOpenTruncateTableLogFile(execplan::CalpontSystemCatalog::OID tableOid, execplan::CalpontSystemCatalog::TableName tableName);
|
// 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 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);
|
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);
|
EXPORT void deleteLogFile(LogFileType fileType, execplan::CalpontSystemCatalog::OID tableOid, uint64_t uniqueId);
|
||||||
|
|
||||||
/** @brief fetch log file infomation
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
EXPORT void fetchLogFile(TableLogInfo & tableLogInfos, uint64_t uniqueId);
|
|
||||||
|
|
||||||
BRM::TxnID fTxnid;
|
/** @brief fetch log file infomation
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
EXPORT void fetchLogFile(TableLogInfo& tableLogInfos, uint64_t uniqueId);
|
||||||
|
|
||||||
|
BRM::TxnID fTxnid;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** @brief get a list of DDLColumns for the given schema.table
|
/** @brief get a list of DDLColumns for the given schema.table
|
||||||
*
|
*
|
||||||
@@ -357,8 +409,8 @@ protected:
|
|||||||
* @param table the table name
|
* @param table the table name
|
||||||
* @param colList will contain the list of columns on return
|
* @param colList will contain the list of columns on return
|
||||||
*/
|
*/
|
||||||
EXPORT void getColumnsForTable( uint32_t sessionID, std::string schema,std::string table,
|
EXPORT void getColumnsForTable( uint32_t sessionID, std::string schema, std::string table,
|
||||||
ColumnList& colList );
|
ColumnList& colList );
|
||||||
|
|
||||||
/** @brief convert parsed ddl data type to a system catalog data type
|
/** @brief convert parsed ddl data type to a system catalog data type
|
||||||
*
|
*
|
||||||
@@ -407,7 +459,7 @@ protected:
|
|||||||
* @param schema the schema the table belongs to
|
* @param schema the schema the table belongs to
|
||||||
* @param table the name of the table
|
* @param table the name of the table
|
||||||
* @param constraintNumber the constraint number
|
* @param constraintNumber the constraint number
|
||||||
* @param type the constraint type
|
* @param type the constraint type
|
||||||
*/
|
*/
|
||||||
std::string buildTableConstraintName(int oid,
|
std::string buildTableConstraintName(int oid,
|
||||||
ddlpackage::DDL_CONSTRAINTS type);
|
ddlpackage::DDL_CONSTRAINTS type);
|
||||||
@@ -417,7 +469,7 @@ protected:
|
|||||||
* @param schema the schema the table belongs to
|
* @param schema the schema the table belongs to
|
||||||
* @param table the name of the table
|
* @param table the name of the table
|
||||||
* @param column the column name
|
* @param column the column name
|
||||||
* @param type the constraint type
|
* @param type the constraint type
|
||||||
*/
|
*/
|
||||||
std::string buildColumnConstraintName(const std::string& schema,
|
std::string buildColumnConstraintName(const std::string& schema,
|
||||||
const std::string& table,
|
const std::string& table,
|
||||||
@@ -452,19 +504,19 @@ protected:
|
|||||||
* @param constraintList the table constrain list
|
* @param constraintList the table constrain list
|
||||||
* @param qualifiedName the name of catalog, schema, object names
|
* @param qualifiedName the name of catalog, schema, object names
|
||||||
*/
|
*/
|
||||||
// void writeTableSysConstraintMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
// void writeTableSysConstraintMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
// ddlpackage::TableConstraintDefList& constraintList, ddlpackage::QualifiedName&
|
// ddlpackage::TableConstraintDefList& constraintList, ddlpackage::QualifiedName&
|
||||||
// qualifiedName, bool alterFlag=false );
|
// qualifiedName, bool alterFlag=false );
|
||||||
/** @brief write the table constraint meta data to the SYSCONSTRAINTCOL table
|
/** @brief write the table constraint meta data to the SYSCONSTRAINTCOL table
|
||||||
*
|
*
|
||||||
* @param txnID the transaction id
|
* @param txnID the transaction id
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param constraintList the table constrain list
|
* @param constraintList the table constrain list
|
||||||
* @param qualifiedName the name of catalog, schema, object names
|
* @param qualifiedName the name of catalog, schema, object names
|
||||||
*/
|
*/
|
||||||
// void writeTableSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
// void writeTableSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||||
// const DDLResult& result, ddlpackage::TableConstraintDefList& constraintList,
|
// const DDLResult& result, ddlpackage::TableConstraintDefList& constraintList,
|
||||||
// ddlpackage::QualifiedName& qualifiedName, bool alterFlag=false );
|
// ddlpackage::QualifiedName& qualifiedName, bool alterFlag=false );
|
||||||
|
|
||||||
/** @brief write the column constraint meta data to the SYSCONTRAINT table
|
/** @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,
|
// void writeColumnSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||||
// const DDLResult& result, ddlpackage::ColumnDefList& tableDefCols,
|
// const DDLResult& result, ddlpackage::ColumnDefList& tableDefCols,
|
||||||
// ddlpackage::QualifiedName& qualifiedName);
|
// ddlpackage::QualifiedName& qualifiedName);
|
||||||
|
|
||||||
|
|
||||||
/** @brief write the index meta data to the SYSINDEX table
|
/** @brief write the index meta data to the SYSINDEX table
|
||||||
@@ -496,10 +548,10 @@ protected:
|
|||||||
* @param consDef the table constraint
|
* @param consDef the table constraint
|
||||||
* @param indexName name of the index
|
* @param indexName name of the index
|
||||||
*/
|
*/
|
||||||
// void writeSysIndexMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
// void writeSysIndexMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||||
// ddlpackage::QualifiedName& qualifiedName,
|
// ddlpackage::QualifiedName& qualifiedName,
|
||||||
// ddlpackage::DDL_CONSTRAINTS type,
|
// ddlpackage::DDL_CONSTRAINTS type,
|
||||||
// std::string& indexName, bool multicol, bool alterFlag=false);
|
// std::string& indexName, bool multicol, bool alterFlag=false);
|
||||||
|
|
||||||
/** @brief write the index meta data to the SYSINDEXCOL table
|
/** @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 constraintCols the list of columns in this index
|
||||||
* @param indexName name of the 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::QualifiedName& qualifiedName,
|
||||||
// ddlpackage::ColumnNameList& constraintCols,
|
// ddlpackage::ColumnNameList& constraintCols,
|
||||||
// std::string& indexName, bool alterFlag=false);
|
// std::string& indexName, bool alterFlag=false);
|
||||||
|
|
||||||
/** @brief remove all indexes for the supplied table from the SYSINDEX table
|
/** @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
|
* @param tableName the qualified name of the table
|
||||||
*/
|
*/
|
||||||
//void removeSysIndexMetaDataForTable(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
//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
|
/** @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 result the result of the operation
|
||||||
* @param tableName the qualified name of the table
|
* @param tableName the qualified name of the table
|
||||||
*/
|
*/
|
||||||
// void removeSysIndexColMetaDataForTable(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
// void removeSysIndexColMetaDataForTable(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||||
// DDLResult& result, ddlpackage::QualifiedName& tableName);
|
// DDLResult& result, ddlpackage::QualifiedName& tableName);
|
||||||
|
|
||||||
/** @brief remove an index from the SYSINDEX table
|
/** @brief remove an index from the SYSINDEX table
|
||||||
*
|
*
|
||||||
@@ -538,7 +590,7 @@ protected:
|
|||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param indexName the qualified name of the index
|
* @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);
|
// ddlpackage::QualifiedName& indexName);
|
||||||
|
|
||||||
/** @brief remove index columns from the SYSINDEXCOL table
|
/** @brief remove index columns from the SYSINDEXCOL table
|
||||||
@@ -547,8 +599,8 @@ protected:
|
|||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param indexName the qualified name of the index
|
* @param indexName the qualified name of the index
|
||||||
*/
|
*/
|
||||||
// void removeSysIndexColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
// void removeSysIndexColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
// ddlpackage::QualifiedName& indexName);
|
// ddlpackage::QualifiedName& indexName);
|
||||||
|
|
||||||
/** @brief remove the table meta data from the SYSTABLE table
|
/** @brief remove the table meta data from the SYSTABLE table
|
||||||
*
|
*
|
||||||
@@ -556,29 +608,29 @@ protected:
|
|||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param tableName the qualified name of the table to remove
|
* @param tableName the qualified name of the table to remove
|
||||||
*/
|
*/
|
||||||
// void removeSysTableMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
// void removeSysTableMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
// ddlpackage::QualifiedName& tableName);
|
// ddlpackage::QualifiedName& tableName);
|
||||||
|
|
||||||
/** @brief remove the column meta data from the SYSCOLUMN table
|
/** @brief remove the column meta data from the SYSCOLUMN table
|
||||||
*
|
*
|
||||||
* @param txnID the transaction id
|
* @param txnID the transaction id
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param tableName the qualified name of the table whose columns
|
* @param tableName the qualified name of the table whose columns
|
||||||
* are to be removed
|
* are to be removed
|
||||||
*/
|
*/
|
||||||
// void removeSysColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
// void removeSysColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
// ddlpackage::QualifiedName& tableName);
|
// ddlpackage::QualifiedName& tableName);
|
||||||
|
|
||||||
/** @brief remove the column meta data from the SYSCOLUMN table
|
/** @brief remove the column meta data from the SYSCOLUMN table
|
||||||
*
|
*
|
||||||
* @param txnID the transaction id
|
* @param txnID the transaction id
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param columnInfo the qualified name of the column
|
* @param columnInfo the qualified name of the column
|
||||||
* to be removed
|
* to be removed
|
||||||
*/
|
*/
|
||||||
// void removeColSysColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
// void removeColSysColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
// ddlpackage::QualifiedName& columnInfo);
|
// ddlpackage::QualifiedName& columnInfo);
|
||||||
|
|
||||||
/** @brief remove the constraint meta data from the SYSCONSTRAINT table
|
/** @brief remove the constraint meta data from the SYSCONSTRAINT table
|
||||||
*
|
*
|
||||||
* @param txnID the transaction id
|
* @param txnID the transaction id
|
||||||
@@ -586,18 +638,18 @@ protected:
|
|||||||
* @param tableName the qualified name of the table whose constraints
|
* @param tableName the qualified name of the table whose constraints
|
||||||
* are to be removed
|
* are to be removed
|
||||||
*/
|
*/
|
||||||
// void removeSysContraintMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
// void removeSysContraintMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
// ddlpackage::QualifiedName& tableName);
|
// ddlpackage::QualifiedName& tableName);
|
||||||
|
|
||||||
/** @brief remove the constraint meta data from the SYSCONSTRAINT table
|
/** @brief remove the constraint meta data from the SYSCONSTRAINT table
|
||||||
*
|
*
|
||||||
* @param txnID the transaction id
|
* @param txnID the transaction id
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param indexName the index name to be removed
|
* @param indexName the index name to be removed
|
||||||
*/
|
*/
|
||||||
// void removeSysIndexMetaDataForIndex(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
// void removeSysIndexMetaDataForIndex(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||||
// DDLResult& result,
|
// DDLResult& result,
|
||||||
// execplan::CalpontSystemCatalog::IndexNameList& indexNameList);
|
// execplan::CalpontSystemCatalog::IndexNameList& indexNameList);
|
||||||
|
|
||||||
/** @brief remove the column constraint meta data from the SYSCONSTRAINTCOL table
|
/** @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
|
* @param tableName the qualified name of the table whose column constraints
|
||||||
* are to be removed
|
* are to be removed
|
||||||
*/
|
*/
|
||||||
// void removeSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
// void removeSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
// ddlpackage::QualifiedName& tableName);
|
// ddlpackage::QualifiedName& tableName);
|
||||||
/** @brief remove the column constraint meta data from the SYSCONSTRAINT table
|
/** @brief remove the column constraint meta data from the SYSCONSTRAINT table
|
||||||
*
|
*
|
||||||
* @param txnID the transaction id
|
* @param txnID the transaction id
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param constrintNames the names of the constraints
|
* @param constrintNames the names of the constraints
|
||||||
* are to be removed
|
* are to be removed
|
||||||
*/
|
*/
|
||||||
#if 0
|
#if 0
|
||||||
void removeSysContraintMetaDataForConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
void removeSysContraintMetaDataForConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||||
DDLResult& result,
|
DDLResult& result,
|
||||||
execplan::CalpontSystemCatalog::IndexNameList& constrintNames);
|
execplan::CalpontSystemCatalog::IndexNameList& constrintNames);
|
||||||
/** @brief remove the column constraint meta data from the SYSCONSTRAINTCOL table
|
/** @brief remove the column constraint meta data from the SYSCONSTRAINTCOL table
|
||||||
*
|
*
|
||||||
* @param txnID the transaction id
|
* @param txnID the transaction id
|
||||||
@@ -627,10 +679,10 @@ protected:
|
|||||||
* are to be removed
|
* are to be removed
|
||||||
*/
|
*/
|
||||||
void removeColSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
void removeColSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
ddlpackage::QualifiedName& columnInfo);
|
ddlpackage::QualifiedName& columnInfo);
|
||||||
|
|
||||||
/** @brief create the physical dictionary files
|
/** @brief create the physical dictionary files
|
||||||
*
|
*
|
||||||
* @param txnID the transaction id
|
* @param txnID the transaction id
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
*/
|
*/
|
||||||
@@ -643,7 +695,7 @@ protected:
|
|||||||
* @param tableDefCols the table column definition list
|
* @param tableDefCols the table column definition list
|
||||||
*/
|
*/
|
||||||
void createColumnFiles(execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
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
|
/** @brief update the SYSCOLUMN table
|
||||||
*
|
*
|
||||||
@@ -651,12 +703,12 @@ protected:
|
|||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @param ridList the list of OIDs for
|
* @param ridList the list of OIDs for
|
||||||
* which the column file should be removed
|
* which the column file should be removed
|
||||||
*/
|
*/
|
||||||
void updateSyscolumns( execplan::CalpontSystemCatalog::SCN txnID,
|
void updateSyscolumns( execplan::CalpontSystemCatalog::SCN txnID,
|
||||||
DDLResult& result, WriteEngine::RIDList& ridList,
|
DDLResult& result, WriteEngine::RIDList& ridList,
|
||||||
WriteEngine::ColValueList& colValuesList,
|
WriteEngine::ColValueList& colValuesList,
|
||||||
WriteEngine::ColValueList& colOldValuesList);
|
WriteEngine::ColValueList& colOldValuesList);
|
||||||
|
|
||||||
/** @brief remove the physical index files
|
/** @brief remove the physical index files
|
||||||
*
|
*
|
||||||
* @param txnID the transaction id
|
* @param txnID the transaction id
|
||||||
@@ -666,7 +718,7 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void removeIndexFiles(execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
void removeIndexFiles(execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||||
execplan::CalpontSystemCatalog::IndexOIDList& idxOIDList);
|
execplan::CalpontSystemCatalog::IndexOIDList& idxOIDList);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @brief return the OIDs used by the database objects
|
/** @brief return the OIDs used by the database objects
|
||||||
*
|
*
|
||||||
@@ -705,7 +757,7 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void removeRowFromSysCatalog(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
void removeRowFromSysCatalog(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||||
ddlpackage::QualifiedName& sysCatalogTableName, WriteEngine::RID& rid);
|
ddlpackage::QualifiedName& sysCatalogTableName, WriteEngine::RID& rid);
|
||||||
|
|
||||||
/** @brief validate reference constraint for altering existing table
|
/** @brief validate reference constraint for altering existing table
|
||||||
*
|
*
|
||||||
* @param sessionID session ID
|
* @param sessionID session ID
|
||||||
@@ -713,12 +765,12 @@ protected:
|
|||||||
* @param tcn the column which has the foreign key constraint
|
* @param tcn the column which has the foreign key constraint
|
||||||
* @param refIndexName the index name of the referenced primary key constraint
|
* @param refIndexName the index name of the referenced primary key constraint
|
||||||
* @return true if violation
|
* @return true if violation
|
||||||
*/
|
*/
|
||||||
bool referenceConstraintViolation(uint32_t sessionID,
|
bool referenceConstraintViolation(uint32_t sessionID,
|
||||||
DDLResult& result,
|
DDLResult& result,
|
||||||
execplan::CalpontSystemCatalog::TableColName tcn,
|
execplan::CalpontSystemCatalog::TableColName tcn,
|
||||||
execplan::CalpontSystemCatalog::IndexName refIndexName);
|
execplan::CalpontSystemCatalog::IndexName refIndexName);
|
||||||
|
|
||||||
/** @brief validate PK constraint (not null part) for altering existing table
|
/** @brief validate PK constraint (not null part) for altering existing table
|
||||||
*
|
*
|
||||||
* @param sessionID session ID
|
* @param sessionID session ID
|
||||||
@@ -727,7 +779,7 @@ protected:
|
|||||||
* @param constraintCols the columns associated with the primary key
|
* @param constraintCols the columns associated with the primary key
|
||||||
* @return true if violation
|
* @return true if violation
|
||||||
*/
|
*/
|
||||||
bool PKConstraintViolation(uint32_t sessionID,
|
bool PKConstraintViolation(uint32_t sessionID,
|
||||||
DDLResult& result,
|
DDLResult& result,
|
||||||
ddlpackage::QualifiedName& qualifiedName,
|
ddlpackage::QualifiedName& qualifiedName,
|
||||||
ddlpackage::ColumnNameList& constraintCols);
|
ddlpackage::ColumnNameList& constraintCols);
|
||||||
@@ -738,13 +790,13 @@ protected:
|
|||||||
* @param qualifiedName schema.table name
|
* @param qualifiedName schema.table name
|
||||||
* @param checkConstraint the constraint text string
|
* @param checkConstraint the constraint text string
|
||||||
* @return true if violation
|
* @return true if violation
|
||||||
*/
|
*/
|
||||||
bool checkConstraintViolation(uint32_t sessionID,
|
bool checkConstraintViolation(uint32_t sessionID,
|
||||||
DDLResult& result,
|
DDLResult& result,
|
||||||
ddlpackage::QualifiedName& qualifiedName,
|
ddlpackage::QualifiedName& qualifiedName,
|
||||||
std::string& checkConstraint);
|
std::string& checkConstraint);
|
||||||
|
|
||||||
|
|
||||||
/** @brief remove the supplied rows from the supplied system catalog table
|
/** @brief remove the supplied rows from the supplied system catalog table
|
||||||
*
|
*
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
@@ -757,12 +809,12 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
WriteEngine::WriteEngineWrapper fWriteEngine;
|
WriteEngine::WriteEngineWrapper fWriteEngine;
|
||||||
|
|
||||||
BRM::DBRM* fDbrm;
|
BRM::DBRM* fDbrm;
|
||||||
|
|
||||||
execplan::SessionManager fSessionManager;
|
execplan::SessionManager fSessionManager;
|
||||||
uint32_t fPMCount;
|
uint32_t fPMCount;
|
||||||
WriteEngine::WEClients* fWEClient;
|
WriteEngine::WEClients* fWEClient;
|
||||||
|
|
||||||
|
|
||||||
DictionaryOIDList fDictionaryOIDList;
|
DictionaryOIDList fDictionaryOIDList;
|
||||||
@@ -773,49 +825,49 @@ protected:
|
|||||||
int fStartingColOID;
|
int fStartingColOID;
|
||||||
int fColumnNum;
|
int fColumnNum;
|
||||||
IndexOID fIdxOID;
|
IndexOID fIdxOID;
|
||||||
std::ofstream fDDLLogFile;
|
std::ofstream fDDLLogFile;
|
||||||
std::string fDDLLogFileName;
|
std::string fDDLLogFileName;
|
||||||
|
|
||||||
std::string fPKName; // primary key name supplied by Oracle. Oracle will issue
|
std::string fPKName; // primary key name supplied by Oracle. Oracle will issue
|
||||||
// two separate DDL statements for a create table with primary
|
// two separate DDL statements for a create table with primary
|
||||||
// key DDL, with the 1st one being create index and the 2nd
|
// key DDL, with the 1st one being create index and the 2nd
|
||||||
// one being create table. This PK name will be stored here
|
// one being create table. This PK name will be stored here
|
||||||
// when creatindexprocessor gets the create index statement. This
|
// when creatindexprocessor gets the create index statement. This
|
||||||
// is to make sure Calpont use the same system primary key name as Oracle
|
// is to make sure Calpont use the same system primary key name as Oracle
|
||||||
unsigned const fDDLLoggingId;
|
unsigned const fDDLLoggingId;
|
||||||
|
|
||||||
//std::ofstream fDDLLogFile;
|
//std::ofstream fDDLLogFile;
|
||||||
//std::string fDDLLogFileName;
|
//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 rid in:the absolute rid out: relative rid in a segement file
|
||||||
* @param dbRoot,partition, segment the extent information obtained from rid
|
* @param dbRoot,partition, segment the extent information obtained from rid
|
||||||
* @param filesPerColumnPartition,extentRows, extentsPerSegmentFile the extent map parameters
|
* @param filesPerColumnPartition,extentRows, extentsPerSegmentFile the extent map parameters
|
||||||
* @param startDBRoot the dbroot this table starts
|
* @param startDBRoot the dbroot this table starts
|
||||||
* @param dbrootCnt the number of dbroot in db
|
* @param dbrootCnt the number of dbroot in db
|
||||||
*/
|
*/
|
||||||
void convertRidToColumn(uint64_t& rid, unsigned& dbRoot, unsigned& partition,
|
void convertRidToColumn(uint64_t& rid, unsigned& dbRoot, unsigned& partition,
|
||||||
unsigned& segment, unsigned filesPerColumnPartition,
|
unsigned& segment, unsigned filesPerColumnPartition,
|
||||||
unsigned extentsPerSegmentFile, unsigned extentRows,
|
unsigned extentsPerSegmentFile, unsigned extentRows,
|
||||||
unsigned startDBRoot, unsigned dbrootCnt);
|
unsigned startDBRoot, unsigned dbrootCnt);
|
||||||
|
|
||||||
int rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID);
|
int rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID);
|
||||||
int commitTransaction(uint64_t uniqueId, BRM::TxnID txnID);
|
int commitTransaction(uint64_t uniqueId, BRM::TxnID txnID);
|
||||||
|
|
||||||
// MCOL-66 The DBRM can't handle concurrent DDL
|
// MCOL-66 The DBRM can't handle concurrent DDL
|
||||||
static boost::mutex dbrmMutex;
|
static boost::mutex dbrmMutex;
|
||||||
private:
|
private:
|
||||||
/** @brief clean beginning and ending glitches and spaces from string
|
/** @brief clean beginning and ending glitches and spaces from string
|
||||||
*
|
*
|
||||||
* @param s string to be cleaned
|
* @param s string to be cleaned
|
||||||
*/
|
*/
|
||||||
void cleanString(std::string& s);
|
void cleanString(std::string& s);
|
||||||
//std::string fDDLLogFileName;
|
//std::string fDDLLogFileName;
|
||||||
DebugLevel fDebugLevel; // internal use debug level
|
DebugLevel fDebugLevel; // internal use debug level
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
/** @brief helper template function to do safe from string to type conversions
|
/** @brief helper template function to do safe from string to type conversions
|
||||||
*
|
*
|
||||||
@@ -823,7 +875,7 @@ private:
|
|||||||
template <class T>
|
template <class T>
|
||||||
bool from_string(T& t,
|
bool from_string(T& t,
|
||||||
const std::string& s,
|
const std::string& s,
|
||||||
std::ios_base& (*f)(std::ios_base&))
|
std::ios_base & (*f)(std::ios_base&))
|
||||||
{
|
{
|
||||||
std::istringstream iss(s);
|
std::istringstream iss(s);
|
||||||
return !(iss >> f >> t).fail();
|
return !(iss >> f >> t).fail();
|
||||||
|
|||||||
@@ -28,30 +28,31 @@
|
|||||||
|
|
||||||
using namespace ddlpackage;
|
using namespace ddlpackage;
|
||||||
|
|
||||||
namespace ddlpackageprocessor {
|
namespace ddlpackageprocessor
|
||||||
|
{
|
||||||
|
|
||||||
DDLPackageProcessor* DDLPackageProcessorFactory::
|
DDLPackageProcessor* DDLPackageProcessorFactory::
|
||||||
makePackageProcessor(int packageType, ddlpackage::CalpontDDLPackage& cpackage)
|
makePackageProcessor(int packageType, ddlpackage::CalpontDDLPackage& cpackage)
|
||||||
{
|
{
|
||||||
DDLPackageProcessor* ddlProcPtr = 0;
|
DDLPackageProcessor* ddlProcPtr = 0;
|
||||||
|
|
||||||
switch( packageType )
|
switch ( packageType )
|
||||||
{
|
{
|
||||||
case DDL_CREATE:
|
case DDL_CREATE:
|
||||||
ddlProcPtr = new CreatePackageProcessor();
|
ddlProcPtr = new CreatePackageProcessor();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DDL_ALTER:
|
|
||||||
ddlProcPtr = new AlterPackageProcessor();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DDL_DROP:
|
case DDL_ALTER:
|
||||||
ddlProcPtr = new DropPackageProcessor();
|
ddlProcPtr = new AlterPackageProcessor();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
case DDL_DROP:
|
||||||
|
ddlProcPtr = new DropPackageProcessor();
|
||||||
|
break;
|
||||||
|
|
||||||
return ddlProcPtr;
|
}
|
||||||
|
|
||||||
|
return ddlProcPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ddlpackageprocessor
|
} // namespace ddlpackageprocessor
|
||||||
|
|||||||
@@ -28,28 +28,30 @@
|
|||||||
#include "ddlpackageprocessor.h"
|
#include "ddlpackageprocessor.h"
|
||||||
|
|
||||||
|
|
||||||
namespace ddlpackageprocessor {
|
namespace ddlpackageprocessor
|
||||||
|
{
|
||||||
|
|
||||||
/** @brief create a ddlPackageProcessor object from a CalpontddlPackage object
|
/** @brief create a ddlPackageProcessor object from a CalpontddlPackage object
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class DDLPackageProcessorFactory {
|
class DDLPackageProcessorFactory
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** @brief static ddlPackageProcessor constructor method
|
/** @brief static ddlPackageProcessor constructor method
|
||||||
*
|
*
|
||||||
* @param packageType the ddl Package type
|
* @param packageType the ddl Package type
|
||||||
* @param cpackage the CalpontddlPackage from which the ddlPackageProcessor is constructed
|
* @param cpackage the CalpontddlPackage from which the ddlPackageProcessor is constructed
|
||||||
*/
|
*/
|
||||||
static DDLPackageProcessor*
|
static DDLPackageProcessor*
|
||||||
makePackageProcessor( int packageType, ddlpackage::CalpontDDLPackage& cpackage );
|
makePackageProcessor( int packageType, ddlpackage::CalpontDDLPackage& cpackage );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif //DDLPACKAGEPROCESSORFACTORY_H
|
#endif //DDLPACKAGEPROCESSORFACTORY_H
|
||||||
|
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
|||||||
CalpontSystemCatalog::IndexOID indexOID;
|
CalpontSystemCatalog::IndexOID indexOID;
|
||||||
|
|
||||||
BRM::TxnID txnID;
|
BRM::TxnID txnID;
|
||||||
txnID.id= fTxnid.id;
|
txnID.id = fTxnid.id;
|
||||||
txnID.valid= fTxnid.valid;
|
txnID.valid = fTxnid.valid;
|
||||||
|
|
||||||
DDLResult result;
|
DDLResult result;
|
||||||
result.result = NO_ERROR;
|
result.result = NO_ERROR;
|
||||||
|
|
||||||
@@ -49,17 +49,18 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
|||||||
|
|
||||||
VERBOSE_INFO(dropIndexStmt);
|
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;
|
indexName.index = dropIndexStmt.fIndexName->fName;
|
||||||
//Look up table name from indexname. Oracle will error out if same constraintname or indexname exists.
|
//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 );
|
CalpontSystemCatalog::TableName tableName = sysCatalogPtr->lookupTableForIndex (dropIndexStmt.fIndexName->fName, dropIndexStmt.fIndexName->fSchema );
|
||||||
indexName.table = tableName.table;
|
indexName.table = tableName.table;
|
||||||
indexOID = sysCatalogPtr->lookupIndexNbr(indexName);
|
indexOID = sysCatalogPtr->lookupIndexNbr(indexName);
|
||||||
|
|
||||||
VERBOSE_INFO("Removing the SYSINDEX meta data");
|
VERBOSE_INFO("Removing the SYSINDEX meta data");
|
||||||
removeSysIndexMetaData(dropIndexStmt.fSessionID, txnID.id, result, *dropIndexStmt.fIndexName);
|
removeSysIndexMetaData(dropIndexStmt.fSessionID, txnID.id, result, *dropIndexStmt.fIndexName);
|
||||||
|
|
||||||
if (result.result != NO_ERROR)
|
if (result.result != NO_ERROR)
|
||||||
{
|
{
|
||||||
DETAIL_INFO("writeSysIndexMetaData failed");
|
DETAIL_INFO("writeSysIndexMetaData failed");
|
||||||
@@ -68,6 +69,7 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
|||||||
|
|
||||||
VERBOSE_INFO("Removing the SYSINDEXCOL meta data");
|
VERBOSE_INFO("Removing the SYSINDEXCOL meta data");
|
||||||
removeSysIndexColMetaData(dropIndexStmt.fSessionID, txnID.id, result, *dropIndexStmt.fIndexName);
|
removeSysIndexColMetaData(dropIndexStmt.fSessionID, txnID.id, result, *dropIndexStmt.fIndexName);
|
||||||
|
|
||||||
if (result.result != NO_ERROR)
|
if (result.result != NO_ERROR)
|
||||||
{
|
{
|
||||||
DETAIL_INFO("writeSysIndexMetaData failed");
|
DETAIL_INFO("writeSysIndexMetaData failed");
|
||||||
@@ -76,7 +78,8 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
|||||||
|
|
||||||
|
|
||||||
VERBOSE_INFO("Removing the index files");
|
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)
|
if (err)
|
||||||
{
|
{
|
||||||
DETAIL_INFO("WriteEngine dropIndex failed");
|
DETAIL_INFO("WriteEngine dropIndex failed");
|
||||||
@@ -88,11 +91,13 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
|||||||
|
|
||||||
// register the changes
|
// register the changes
|
||||||
err = fWriteEngine.commit( txnID.id );
|
err = fWriteEngine.commit( txnID.id );
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
DETAIL_INFO("Failed to commit the drop index transaction");
|
DETAIL_INFO("Failed to commit the drop index transaction");
|
||||||
goto rollback;
|
goto rollback;
|
||||||
}
|
}
|
||||||
|
|
||||||
fSessionManager.committed(txnID);
|
fSessionManager.committed(txnID);
|
||||||
//fObjectIDManager.returnOID(indexOID.objnum);
|
//fObjectIDManager.returnOID(indexOID.objnum);
|
||||||
//fObjectIDManager.returnOID(indexOID.listOID);
|
//fObjectIDManager.returnOID(indexOID.listOID);
|
||||||
|
|||||||
@@ -28,24 +28,24 @@
|
|||||||
|
|
||||||
namespace ddlpackageprocessor
|
namespace ddlpackageprocessor
|
||||||
{
|
{
|
||||||
/** @brief specialization of a DDLPacakageProcessor
|
/** @brief specialization of a DDLPacakageProcessor
|
||||||
* for interaction with the Write Engine to process
|
* for interaction with the Write Engine to process
|
||||||
* drop index statements.
|
* drop index statements.
|
||||||
|
*/
|
||||||
|
class DropIndexProcessor : public DDLPackageProcessor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief process a drop index statement
|
||||||
|
*
|
||||||
|
* @param dropIndexStmt the drop index statement
|
||||||
*/
|
*/
|
||||||
class DropIndexProcessor : public DDLPackageProcessor
|
DDLResult processPackage(ddlpackage::DropIndexStatement& dropIndexStmt);
|
||||||
{
|
|
||||||
public:
|
|
||||||
/** @brief process a drop index statement
|
|
||||||
*
|
|
||||||
* @param dropIndexStmt the drop index statement
|
|
||||||
*/
|
|
||||||
DDLResult processPackage(ddlpackage::DropIndexStatement& dropIndexStmt);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace ddlpackageprocessor
|
} //namespace ddlpackageprocessor
|
||||||
#endif //DROPINDEXPROCESSOR_H
|
#endif //DROPINDEXPROCESSOR_H
|
||||||
|
|||||||
@@ -38,316 +38,343 @@ using namespace oam;
|
|||||||
namespace ddlpackageprocessor
|
namespace ddlpackageprocessor
|
||||||
{
|
{
|
||||||
|
|
||||||
DropPartitionProcessor::DDLResult DropPartitionProcessor::processPackage(ddlpackage::DropPartitionStatement& dropPartitionStmt)
|
DropPartitionProcessor::DDLResult DropPartitionProcessor::processPackage(ddlpackage::DropPartitionStatement& dropPartitionStmt)
|
||||||
{
|
{
|
||||||
SUMMARY_INFO("DropPartitionProcessor::processPackage");
|
SUMMARY_INFO("DropPartitionProcessor::processPackage");
|
||||||
|
|
||||||
DDLResult result;
|
DDLResult result;
|
||||||
result.result = NO_ERROR;
|
result.result = NO_ERROR;
|
||||||
std::string err;
|
std::string err;
|
||||||
VERBOSE_INFO(dropPartitionStmt);
|
VERBOSE_INFO(dropPartitionStmt);
|
||||||
|
|
||||||
// Commit current transaction.
|
// Commit current transaction.
|
||||||
// all DDL statements cause an implicit commit
|
// all DDL statements cause an implicit commit
|
||||||
VERBOSE_INFO("Getting current txnID");
|
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;
|
||||||
std::vector <CalpontSystemCatalog::OID> oidList;
|
rc = fDbrm->isReadWrite();
|
||||||
CalpontSystemCatalog::RIDList tableColRidList;
|
BRM::TxnID txnID;
|
||||||
CalpontSystemCatalog::DictOIDList dictOIDList;
|
txnID.id = fTxnid.id;
|
||||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
txnID.valid = fTxnid.valid;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
string stmt = dropPartitionStmt.fSql + "|" + dropPartitionStmt.fTableName->fSchema +"|";
|
|
||||||
SQLLogger logger(stmt, fDDLLoggingId, sessionID, txnID.id);
|
|
||||||
|
|
||||||
try
|
if (rc != 0 )
|
||||||
{
|
{
|
||||||
//check table lock
|
logging::Message::Args args;
|
||||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(dropPartitionStmt.fSessionID);
|
logging::Message message(9);
|
||||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
args.add("Unable to execute the statement due to DBRM is read only");
|
||||||
systemCatalogPtr->sessionID(dropPartitionStmt.fSessionID);
|
message.format(args);
|
||||||
CalpontSystemCatalog::TableName tableName;
|
result.result = DROP_ERROR;
|
||||||
tableName.schema = dropPartitionStmt.fTableName->fSchema;
|
result.message = message;
|
||||||
tableName.table = dropPartitionStmt.fTableName->fName;
|
fSessionManager.rolledback(txnID);
|
||||||
roPair = systemCatalogPtr->tableRID( tableName );
|
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.");
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
// 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++)
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
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
|
#ifdef _MSC_VER
|
||||||
Sleep(rm_ts.tv_sec * 1000);
|
Sleep(rm_ts.tv_sec * 1000);
|
||||||
#else
|
#else
|
||||||
struct timespec abs_ts;
|
struct timespec abs_ts;
|
||||||
do
|
|
||||||
{
|
do
|
||||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
{
|
||||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||||
}
|
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||||
while(nanosleep(&abs_ts,&rm_ts) < 0);
|
}
|
||||||
|
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// reset
|
// reset
|
||||||
sessionID = dropPartitionStmt.fSessionID;
|
sessionID = dropPartitionStmt.fSessionID;
|
||||||
txnID.id= fTxnid.id;
|
txnID.id = fTxnid.id;
|
||||||
txnID.valid= fTxnid.valid;
|
txnID.valid = fTxnid.valid;
|
||||||
processID = ::getpid();
|
processID = ::getpid();
|
||||||
processName = "DDLProc";
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uniqueID > 0)
|
try
|
||||||
break;
|
{
|
||||||
}
|
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
|
if (uniqueID > 0)
|
||||||
{
|
break;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. Get the OIDs for the columns
|
if (i >= numTries) //error out
|
||||||
// 2. Get the OIDs for the dictionaries
|
{
|
||||||
// 3. Save the OIDs to a log file
|
result.result = DROP_ERROR;
|
||||||
// 4. Disable the extents from extentmap for the partition
|
logging::Message::Args args;
|
||||||
// 5. Remove the column and dictionary files for the partition
|
string strOp("drop partition");
|
||||||
// 6. Flush PrimProc Cache
|
args.add(strOp);
|
||||||
// 7. Remove the extents from extentmap for the partition
|
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;
|
// 1. Get the OIDs for the columns
|
||||||
userTableName.schema = dropPartitionStmt.fTableName->fSchema;
|
// 2. Get the OIDs for the dictionaries
|
||||||
userTableName.table = dropPartitionStmt.fTableName->fName;
|
// 3. Save the OIDs to a log file
|
||||||
|
// 4. Disable the extents from extentmap for the partition
|
||||||
tableColRidList = systemCatalogPtr->columnRIDs( userTableName );
|
// 5. Remove the column and dictionary files for the partition
|
||||||
|
// 6. Flush PrimProc Cache
|
||||||
dictOIDList = systemCatalogPtr->dictOIDs( userTableName );
|
// 7. Remove the extents from extentmap for the partition
|
||||||
|
|
||||||
//Save qualified tablename, all column, dictionary OIDs, and transaction ID into a file in ASCII format
|
CalpontSystemCatalog::TableName userTableName;
|
||||||
for ( unsigned i=0; i < tableColRidList.size(); i++ )
|
userTableName.schema = dropPartitionStmt.fTableName->fSchema;
|
||||||
{
|
userTableName.table = dropPartitionStmt.fTableName->fName;
|
||||||
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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
//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);
|
|
||||||
}
|
|
||||||
|
|
||||||
set<BRM::LogicalPartition> markedPartitions;
|
|
||||||
set<BRM::LogicalPartition> outOfServicePartitions;
|
|
||||||
|
|
||||||
// only log partitions that are successfully marked disabled.
|
|
||||||
rc = fDbrm->getOutOfServicePartitions(oidList[0], outOfServicePartitions);
|
|
||||||
|
|
||||||
if (rc != 0)
|
|
||||||
{
|
|
||||||
string errorMsg;
|
|
||||||
BRM::errString(rc, errorMsg);
|
|
||||||
ostringstream oss;
|
|
||||||
oss << "getOutOfServicePartitions failed due to " << errorMsg;
|
|
||||||
throw std::runtime_error(oss.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
set<BRM::LogicalPartition>::iterator it;
|
tableColRidList = systemCatalogPtr->columnRIDs( userTableName );
|
||||||
for (it = dropPartitionStmt.fPartitions.begin(); it != dropPartitionStmt.fPartitions.end(); ++it)
|
|
||||||
{
|
|
||||||
if (outOfServicePartitions.find(*it) != outOfServicePartitions.end())
|
|
||||||
markedPartitions.insert(*it);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Save the oids to a file
|
|
||||||
createWritePartitionLogFile( roPair.objnum, markedPartitions, oidList, uniqueId);
|
|
||||||
|
|
||||||
VERBOSE_INFO("Removing files");
|
dictOIDList = systemCatalogPtr->dictOIDs( userTableName );
|
||||||
removePartitionFiles( oidList, markedPartitions, uniqueId );
|
|
||||||
//Flush PrimProc cache for those lbids
|
|
||||||
rc = cacheutils::flushPartition( oidList, markedPartitions );
|
|
||||||
|
|
||||||
//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;
|
//Save qualified tablename, all column, dictionary OIDs, and transaction ID into a file in ASCII format
|
||||||
logging::Message message(ex.what());
|
for ( unsigned i = 0; i < tableColRidList.size(); i++ )
|
||||||
|
{
|
||||||
|
if ( tableColRidList[i].objnum > 3000 )
|
||||||
|
oidList.push_back( tableColRidList[i].objnum );
|
||||||
|
}
|
||||||
|
|
||||||
if (rc == BRM::ERR_TABLE_NOT_LOCKED)
|
for ( unsigned i = 0; i < dictOIDList.size(); i++ )
|
||||||
result.result = USER_ERROR;
|
{
|
||||||
else if (rc == BRM::ERR_NOT_EXIST_PARTITION || rc == BRM::ERR_INVALID_OP_LAST_PARTITION)
|
if ( dictOIDList[i].dictOID > 3000 )
|
||||||
result.result = PARTITION_WARNING;
|
oidList.push_back( dictOIDList[i].dictOID );
|
||||||
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;
|
//Mark the partition disabled from extent map
|
||||||
logging::Message message(1);
|
string emsg;
|
||||||
args.add("Drop partition failed: ");
|
rc = fDbrm->markPartitionForDeletion( oidList, dropPartitionStmt.fPartitions, emsg);
|
||||||
args.add( "encountered unkown exception" );
|
|
||||||
args.add("");
|
if (rc != 0 && rc != BRM::ERR_PARTITION_DISABLED &&
|
||||||
args.add("");
|
rc != BRM::ERR_INVALID_OP_LAST_PARTITION &&
|
||||||
message.format( args );
|
rc != BRM::ERR_NOT_EXIST_PARTITION)
|
||||||
|
{
|
||||||
result.result = DROP_ERROR;
|
throw std::runtime_error(emsg);
|
||||||
result.message = message;
|
}
|
||||||
try {
|
|
||||||
fDbrm->releaseTableLock(uniqueID);
|
set<BRM::LogicalPartition> markedPartitions;
|
||||||
} catch (std::exception&)
|
set<BRM::LogicalPartition> outOfServicePartitions;
|
||||||
{
|
|
||||||
result.result = DROP_ERROR;
|
// only log partitions that are successfully marked disabled.
|
||||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
rc = fDbrm->getOutOfServicePartitions(oidList[0], outOfServicePartitions);
|
||||||
}
|
|
||||||
fSessionManager.rolledback(txnID);
|
if (rc != 0)
|
||||||
return result;
|
{
|
||||||
}
|
string errorMsg;
|
||||||
// Log the DDL statement
|
BRM::errString(rc, errorMsg);
|
||||||
logging::logDDL(dropPartitionStmt.fSessionID, txnID.id, dropPartitionStmt.fSql, dropPartitionStmt.fOwner);
|
ostringstream oss;
|
||||||
//Remove the log file
|
oss << "getOutOfServicePartitions failed due to " << errorMsg;
|
||||||
//release the transaction
|
throw std::runtime_error(oss.str());
|
||||||
try {
|
}
|
||||||
fDbrm->releaseTableLock(uniqueID);
|
|
||||||
deleteLogFile(DROPPART_LOG, roPair.objnum, uniqueId);
|
set<BRM::LogicalPartition>::iterator it;
|
||||||
} catch (std::exception&)
|
|
||||||
{
|
for (it = dropPartitionStmt.fPartitions.begin(); it != dropPartitionStmt.fPartitions.end(); ++it)
|
||||||
result.result = DROP_ERROR;
|
{
|
||||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
if (outOfServicePartitions.find(*it) != outOfServicePartitions.end())
|
||||||
fSessionManager.rolledback(txnID);
|
markedPartitions.insert(*it);
|
||||||
return result;
|
}
|
||||||
}
|
|
||||||
fSessionManager.committed(txnID);
|
//Save the oids to a file
|
||||||
return result;
|
createWritePartitionLogFile( roPair.objnum, markedPartitions, oidList, uniqueId);
|
||||||
}
|
|
||||||
|
VERBOSE_INFO("Removing files");
|
||||||
|
removePartitionFiles( oidList, markedPartitions, uniqueId );
|
||||||
|
//Flush PrimProc cache for those lbids
|
||||||
|
rc = cacheutils::flushPartition( oidList, markedPartitions );
|
||||||
|
|
||||||
|
//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
|
namespace ddlpackageprocessor
|
||||||
{
|
{
|
||||||
/** @brief specialization of a DDLPacakageProcessor
|
/** @brief specialization of a DDLPacakageProcessor
|
||||||
* for interacting with the Write Engine to process
|
* for interacting with the Write Engine to process
|
||||||
* drop table ddl statements.
|
* 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
|
EXPORT DDLResult processPackage(ddlpackage::DropPartitionStatement& dropPartitionStmt);
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace ddlpackageprocessor
|
} // namespace ddlpackageprocessor
|
||||||
|
|
||||||
#undef EXPORT
|
#undef EXPORT
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -34,45 +34,45 @@
|
|||||||
|
|
||||||
namespace ddlpackageprocessor
|
namespace ddlpackageprocessor
|
||||||
{
|
{
|
||||||
/** @brief specialization of a DDLPacakageProcessor
|
/** @brief specialization of a DDLPacakageProcessor
|
||||||
* for interacting with the Write Engine to process
|
* for interacting with the Write Engine to process
|
||||||
* drop table ddl statements.
|
* 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
|
EXPORT DDLResult processPackage(ddlpackage::DropTableStatement& dropTableStmt);
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @brief specialization of a DDLPacakageProcessor
|
/** @brief specialization of a DDLPacakageProcessor
|
||||||
* for interacting with the Write Engine to process
|
* for interacting with the Write Engine to process
|
||||||
* truncate table ddl statements.
|
* 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
|
EXPORT DDLResult processPackage(ddlpackage::TruncTableStatement& truncTableStmt);
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ddlpackageprocessor
|
} // namespace ddlpackageprocessor
|
||||||
|
|
||||||
|
|||||||
@@ -37,237 +37,261 @@ namespace ddlpackageprocessor
|
|||||||
|
|
||||||
MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpackage::MarkPartitionStatement& markPartitionStmt)
|
MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpackage::MarkPartitionStatement& markPartitionStmt)
|
||||||
{
|
{
|
||||||
SUMMARY_INFO("RestorePartitionProcessor::processPackage");
|
SUMMARY_INFO("RestorePartitionProcessor::processPackage");
|
||||||
|
|
||||||
DDLResult result;
|
DDLResult result;
|
||||||
result.result = NO_ERROR;
|
result.result = NO_ERROR;
|
||||||
std::string err;
|
std::string err;
|
||||||
VERBOSE_INFO(markPartitionStmt);
|
VERBOSE_INFO(markPartitionStmt);
|
||||||
|
|
||||||
BRM::TxnID txnID;
|
BRM::TxnID txnID;
|
||||||
txnID.id= fTxnid.id;
|
txnID.id = fTxnid.id;
|
||||||
txnID.valid= fTxnid.valid;
|
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");
|
|
||||||
|
|
||||||
string stmt = markPartitionStmt.fSql + "|" + markPartitionStmt.fTableName->fSchema +"|";
|
|
||||||
SQLLogger logger(stmt, fDDLLoggingId, markPartitionStmt.fSessionID, txnID.id);
|
|
||||||
|
|
||||||
uint32_t processID = 0;
|
|
||||||
uint64_t uniqueID = 0;
|
|
||||||
uint32_t sessionID = markPartitionStmt.fSessionID;
|
|
||||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
|
||||||
|
|
||||||
try
|
int rc = 0;
|
||||||
{
|
rc = fDbrm->isReadWrite();
|
||||||
//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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
if (rc != 0 )
|
||||||
rm_ts.tv_nsec = sleepTime%1000 *1000000;
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
for (; i < numTries; i++)
|
std::vector <CalpontSystemCatalog::OID> oidList;
|
||||||
{
|
CalpontSystemCatalog::RIDList tableColRidList;
|
||||||
|
CalpontSystemCatalog::DictOIDList dictOIDList;
|
||||||
|
std::string processName("DDLProc");
|
||||||
|
|
||||||
|
string stmt = markPartitionStmt.fSql + "|" + markPartitionStmt.fTableName->fSchema + "|";
|
||||||
|
SQLLogger logger(stmt, fDDLLoggingId, markPartitionStmt.fSessionID, txnID.id);
|
||||||
|
|
||||||
|
uint32_t processID = 0;
|
||||||
|
uint64_t uniqueID = 0;
|
||||||
|
uint32_t sessionID = markPartitionStmt.fSessionID;
|
||||||
|
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||||
|
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
#ifdef _MSC_VER
|
||||||
Sleep(rm_ts.tv_sec * 1000);
|
Sleep(rm_ts.tv_sec * 1000);
|
||||||
#else
|
#else
|
||||||
struct timespec abs_ts;
|
struct timespec abs_ts;
|
||||||
do
|
|
||||||
{
|
do
|
||||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
{
|
||||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||||
}
|
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||||
while(nanosleep(&abs_ts,&rm_ts) < 0);
|
}
|
||||||
|
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// reset
|
// reset
|
||||||
sessionID = markPartitionStmt.fSessionID;
|
sessionID = markPartitionStmt.fSessionID;
|
||||||
txnID.id= fTxnid.id;
|
txnID.id = fTxnid.id;
|
||||||
txnID.valid= fTxnid.valid;
|
txnID.valid = fTxnid.valid;
|
||||||
processID = ::getpid();
|
processID = ::getpid();
|
||||||
processName = "DDLProc";
|
processName = "DDLProc";
|
||||||
|
|
||||||
try {
|
try
|
||||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
{
|
||||||
}
|
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||||
catch (std::exception&)
|
}
|
||||||
{
|
catch (std::exception&)
|
||||||
result.result = DROP_ERROR;
|
{
|
||||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
result.result = DROP_ERROR;
|
||||||
fSessionManager.rolledback(txnID);
|
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||||
return result;
|
fSessionManager.rolledback(txnID);
|
||||||
}
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if (uniqueID > 0)
|
if (uniqueID > 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= numTries) //error out
|
if (i >= numTries) //error out
|
||||||
{
|
{
|
||||||
result.result = DROP_ERROR;
|
result.result = DROP_ERROR;
|
||||||
logging::Message::Args args;
|
logging::Message::Args args;
|
||||||
args.add(processName);
|
args.add(processName);
|
||||||
args.add((uint64_t)processID);
|
args.add((uint64_t)processID);
|
||||||
args.add((uint64_t)sessionID);
|
args.add((uint64_t)sessionID);
|
||||||
result.message = Message(IDBErrorInfo::instance()->errorMsg(ERR_TABLE_LOCKED,args));
|
result.message = Message(IDBErrorInfo::instance()->errorMsg(ERR_TABLE_LOCKED, args));
|
||||||
fSessionManager.rolledback(txnID);
|
fSessionManager.rolledback(txnID);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Get the OIDs for the columns
|
// 1. Get the OIDs for the columns
|
||||||
// 2. Get the OIDs for the dictionaries
|
// 2. Get the OIDs for the dictionaries
|
||||||
// 3. Save the OIDs to a log file
|
// 3. Save the OIDs to a log file
|
||||||
// 4. Remove the extents from extentmap
|
// 4. Remove the extents from extentmap
|
||||||
// 5. Flush PrimProc Cache
|
// 5. Flush PrimProc Cache
|
||||||
// 6. Remove the column and dictionary files for the partition
|
// 6. Remove the column and dictionary files for the partition
|
||||||
|
|
||||||
CalpontSystemCatalog::TableName userTableName;
|
CalpontSystemCatalog::TableName userTableName;
|
||||||
userTableName.schema = markPartitionStmt.fTableName->fSchema;
|
userTableName.schema = markPartitionStmt.fTableName->fSchema;
|
||||||
userTableName.table = markPartitionStmt.fTableName->fName;
|
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
|
//Save qualified tablename, all column, dictionary OIDs, and transaction ID into a file in ASCII format
|
||||||
for ( unsigned i=0; i < tableColRidList.size(); i++ )
|
for ( unsigned i = 0; i < tableColRidList.size(); i++ )
|
||||||
{
|
{
|
||||||
if ( tableColRidList[i].objnum > 3000 )
|
if ( tableColRidList[i].objnum > 3000 )
|
||||||
oidList.push_back( tableColRidList[i].objnum );
|
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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
//Remove the partition from extent map
|
for ( unsigned i = 0; i < dictOIDList.size(); i++ )
|
||||||
string emsg;
|
{
|
||||||
rc = fDbrm->markPartitionForDeletion( oidList, markPartitionStmt.fPartitions, emsg);
|
if ( dictOIDList[i].dictOID > 3000 )
|
||||||
if ( rc != 0 )
|
oidList.push_back( dictOIDList[i].dictOID );
|
||||||
{
|
}
|
||||||
throw std::runtime_error(emsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (exception& ex)
|
|
||||||
{
|
|
||||||
logging::Message::Args args;
|
|
||||||
logging::Message message(ex.what());
|
|
||||||
|
|
||||||
if (rc == BRM::ERR_TABLE_NOT_LOCKED)
|
//Remove the partition from extent map
|
||||||
result.result = USER_ERROR;
|
string emsg;
|
||||||
else if (rc == BRM::ERR_PARTITION_DISABLED || rc == BRM::ERR_INVALID_OP_LAST_PARTITION ||
|
rc = fDbrm->markPartitionForDeletion( oidList, markPartitionStmt.fPartitions, emsg);
|
||||||
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.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;
|
if ( rc != 0 )
|
||||||
logging::Message message(1);
|
{
|
||||||
args.add("Disable partition failed: ");
|
throw std::runtime_error(emsg);
|
||||||
args.add( "encountered unkown exception" );
|
}
|
||||||
args.add("");
|
}
|
||||||
args.add("");
|
catch (exception& ex)
|
||||||
message.format( args );
|
{
|
||||||
|
logging::Message::Args args;
|
||||||
|
logging::Message message(ex.what());
|
||||||
|
|
||||||
result.result = DROP_ERROR;
|
if (rc == BRM::ERR_TABLE_NOT_LOCKED)
|
||||||
result.message = message;
|
result.result = USER_ERROR;
|
||||||
try {
|
else if (rc == BRM::ERR_PARTITION_DISABLED || rc == BRM::ERR_INVALID_OP_LAST_PARTITION ||
|
||||||
fDbrm->releaseTableLock(uniqueID);
|
rc == BRM::ERR_NOT_EXIST_PARTITION)
|
||||||
} catch (std::exception&)
|
result.result = PARTITION_WARNING;
|
||||||
{
|
else if (rc == BRM::ERR_NO_PARTITION_PERFORMED)
|
||||||
result.result = DROP_ERROR;
|
result.result = WARN_NO_PARTITION;
|
||||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
else
|
||||||
}
|
result.result = DROP_ERROR;
|
||||||
fSessionManager.rolledback(txnID);
|
|
||||||
return result;
|
result.message = message;
|
||||||
}
|
|
||||||
// Log the DDL statement
|
try
|
||||||
logging::logDDL(markPartitionStmt.fSessionID, 0, markPartitionStmt.fSql, markPartitionStmt.fOwner);
|
{
|
||||||
try {
|
fDbrm->releaseTableLock(uniqueID);
|
||||||
fDbrm->releaseTableLock(uniqueID);
|
}
|
||||||
} catch (std::exception&)
|
catch (std::exception&)
|
||||||
{
|
{
|
||||||
result.result = DROP_ERROR;
|
result.result = DROP_ERROR;
|
||||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||||
fSessionManager.rolledback(txnID);
|
}
|
||||||
return result;
|
|
||||||
}
|
fSessionManager.rolledback(txnID);
|
||||||
fSessionManager.committed(txnID);
|
return result;
|
||||||
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
|
class MarkPartitionProcessor : public DDLPackageProcessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkPartitionProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm){}
|
MarkPartitionProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||||
/** @brief process a create table statement
|
/** @brief process a create table statement
|
||||||
*
|
*
|
||||||
* @param createTableStmt the CreateTableStatement
|
* @param createTableStmt the CreateTableStatement
|
||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
EXPORT DDLResult processPackage(ddlpackage::MarkPartitionStatement& MarkPartitionStmt);
|
EXPORT DDLResult processPackage(ddlpackage::MarkPartitionStatement& MarkPartitionStmt);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -62,532 +62,543 @@ class PopulateIndexTest
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PopulateIndexTest(DistributedEngineComm* ec) : fEC(ec) { }
|
PopulateIndexTest(DistributedEngineComm* ec) : fEC(ec) { }
|
||||||
DistributedEngineComm *fEC;
|
DistributedEngineComm* fEC;
|
||||||
|
|
||||||
void test_createindex()
|
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)
|
|
||||||
{
|
{
|
||||||
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;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
cout << ptree.fSqlText << endl;
|
|
||||||
|
cout << "Parser succeeded." << endl;
|
||||||
|
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
||||||
|
cout << ptree.fSqlText << endl;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CreateTableProcessor processor;
|
CreateIndexProcessor processor;
|
||||||
processor.setDebugLevel(CreateTableProcessor::VERBOSE);
|
processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
||||||
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
|
CreateIndexProcessor::DDLResult result;
|
||||||
|
DISPLAY(stmt.fSessionID);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||||
CreateTableProcessor::DDLResult result;
|
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<CreateTableStatement&>(stmt));
|
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_altertable_addtableconstraint(std::string& sqlbuf)
|
void test_createuniqueindex()
|
||||||
{
|
{
|
||||||
cout << "Begining Alter Table add table constraint test ... " << endl;
|
cout << "Begining create unique index test ..." << endl;
|
||||||
cout << sqlbuf << endl;
|
std::string sqlbuf = "CREATE UNIQUE INDEX test2_idx ON tpch.nation (n_name)";
|
||||||
|
cout << sqlbuf << endl;
|
||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
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];
|
if (parser.Good())
|
||||||
AlterTableProcessor::DDLResult result;
|
{
|
||||||
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
cout << ptree.fSqlText << endl;
|
||||||
std::cout << "return: " << result.result << std::endl;
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_altertable_addtablenullconstraint()
|
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)
|
||||||
|
{
|
||||||
|
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.)
|
//sql syntax error? (Does not build index test.)
|
||||||
cout << "Begining Alter Table add table not null constraint test ... " << 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);";
|
std::string sqlbuf = "ALTER TABLE tpch.region add CONSTRAINT not null(r_regionkey);";
|
||||||
cout << sqlbuf << endl;
|
cout << sqlbuf << endl;
|
||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
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];
|
if (parser.Good())
|
||||||
AlterTableProcessor::DDLResult result;
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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 DoAll = 0;
|
||||||
int Do1 = 0;
|
int Do1 = 0;
|
||||||
int Do2 = 0;
|
int Do2 = 0;
|
||||||
int Do3 = 0;
|
int Do3 = 0;
|
||||||
int Do4 = 0;
|
int Do4 = 0;
|
||||||
int Do5 = 0;
|
int Do5 = 0;
|
||||||
int Do6 = 0;
|
int Do6 = 0;
|
||||||
int Do7 = 0;
|
int Do7 = 0;
|
||||||
int Do8 = 0;
|
int Do8 = 0;
|
||||||
int Do9 = 0;
|
int Do9 = 0;
|
||||||
int Do10 = 0;
|
int Do10 = 0;
|
||||||
int Do11 = 0;
|
int Do11 = 0;
|
||||||
int Do12 = 0;
|
int Do12 = 0;
|
||||||
int Do13 = 0;
|
int Do13 = 0;
|
||||||
int Do14 = 0;
|
int Do14 = 0;
|
||||||
int Do15 = 0;
|
int Do15 = 0;
|
||||||
int Do16 = 0;
|
int Do16 = 0;
|
||||||
int Do17 = 0;
|
int Do17 = 0;
|
||||||
int Do18 = 0;
|
int Do18 = 0;
|
||||||
int Do19 = 0;
|
int Do19 = 0;
|
||||||
int Do20 = 0;
|
int Do20 = 0;
|
||||||
int Do21 = 0;
|
int Do21 = 0;
|
||||||
int Do22 = 0;
|
int Do22 = 0;
|
||||||
int Do23 = 0;
|
int Do23 = 0;
|
||||||
int Do24 = 0;
|
int Do24 = 0;
|
||||||
int Do25 = 0;
|
int Do25 = 0;
|
||||||
int Do26 = 0;
|
int Do26 = 0;
|
||||||
int Do27 = 0;
|
int Do27 = 0;
|
||||||
int Do28 = 0;
|
int Do28 = 0;
|
||||||
int Do29 = 0;
|
int Do29 = 0;
|
||||||
int Do30 = 0;
|
int Do30 = 0;
|
||||||
int Do31 = 0;
|
int Do31 = 0;
|
||||||
int Do32 = 0;
|
int Do32 = 0;
|
||||||
int Do33 = 0;
|
int Do33 = 0;
|
||||||
int Do34 = 0;
|
int Do34 = 0;
|
||||||
int Do35 = 0;
|
int Do35 = 0;
|
||||||
int Do36 = 0;
|
int Do36 = 0;
|
||||||
|
|
||||||
cout << "Driver Test starting with " << argc << " parameters." << endl;
|
|
||||||
|
|
||||||
for (int i=0; i<argc; i++)
|
cout << "Driver Test starting with " << argc << " parameters." << endl;
|
||||||
|
|
||||||
|
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;
|
if (strcmp(argv[1], "All") == 0) DoAll = 1;
|
||||||
else if (strcmp(argv[1],"t1") == 0) Do1 = 1;
|
else if (strcmp(argv[1], "t1") == 0) Do1 = 1;
|
||||||
else if (strcmp(argv[1],"t2") == 0) Do2 = 1;
|
else if (strcmp(argv[1], "t2") == 0) Do2 = 1;
|
||||||
else if (strcmp(argv[1],"t3") == 0) Do3 = 1;
|
else if (strcmp(argv[1], "t3") == 0) Do3 = 1;
|
||||||
else if (strcmp(argv[1],"t4") == 0) Do4 = 1;
|
else if (strcmp(argv[1], "t4") == 0) Do4 = 1;
|
||||||
else if (strcmp(argv[1],"t5") == 0) Do5 = 1;
|
else if (strcmp(argv[1], "t5") == 0) Do5 = 1;
|
||||||
else if (strcmp(argv[1],"t6") == 0) Do6 = 1;
|
else if (strcmp(argv[1], "t6") == 0) Do6 = 1;
|
||||||
else if (strcmp(argv[1],"t7") == 0) Do7 = 1;
|
else if (strcmp(argv[1], "t7") == 0) Do7 = 1;
|
||||||
else if (strcmp(argv[1],"t8") == 0) Do8 = 1;
|
else if (strcmp(argv[1], "t8") == 0) Do8 = 1;
|
||||||
else if (strcmp(argv[1],"t9") == 0) Do9 = 1;
|
else if (strcmp(argv[1], "t9") == 0) Do9 = 1;
|
||||||
else if (strcmp(argv[1],"t10") == 0) Do10 = 1;
|
else if (strcmp(argv[1], "t10") == 0) Do10 = 1;
|
||||||
else if (strcmp(argv[1],"t11") == 0) Do11= 1;
|
else if (strcmp(argv[1], "t11") == 0) Do11 = 1;
|
||||||
else if (strcmp(argv[1],"t12") == 0) Do12= 1;
|
else if (strcmp(argv[1], "t12") == 0) Do12 = 1;
|
||||||
else if (strcmp(argv[1],"t13") == 0) Do13= 1;
|
else if (strcmp(argv[1], "t13") == 0) Do13 = 1;
|
||||||
else if (strcmp(argv[1],"t14") == 0) Do14= 1;
|
else if (strcmp(argv[1], "t14") == 0) Do14 = 1;
|
||||||
else if (strcmp(argv[1],"t15") == 0) Do15= 1;
|
else if (strcmp(argv[1], "t15") == 0) Do15 = 1;
|
||||||
else if (strcmp(argv[1],"t16") == 0) Do16= 1;
|
else if (strcmp(argv[1], "t16") == 0) Do16 = 1;
|
||||||
else if (strcmp(argv[1],"t17") == 0) Do17= 1;
|
else if (strcmp(argv[1], "t17") == 0) Do17 = 1;
|
||||||
else if (strcmp(argv[1],"t18") == 0) Do18= 1;
|
else if (strcmp(argv[1], "t18") == 0) Do18 = 1;
|
||||||
else if (strcmp(argv[1],"t19") == 0) Do19= 1;
|
else if (strcmp(argv[1], "t19") == 0) Do19 = 1;
|
||||||
else if (strcmp(argv[1],"t20") == 0) Do20= 1;
|
else if (strcmp(argv[1], "t20") == 0) Do20 = 1;
|
||||||
else if (strcmp(argv[1],"t21") == 0) Do21= 1;
|
else if (strcmp(argv[1], "t21") == 0) Do21 = 1;
|
||||||
else if (strcmp(argv[1],"t22") == 0) Do22= 1;
|
else if (strcmp(argv[1], "t22") == 0) Do22 = 1;
|
||||||
else if (strcmp(argv[1],"t23") == 0) Do23= 1;
|
else if (strcmp(argv[1], "t23") == 0) Do23 = 1;
|
||||||
else if (strcmp(argv[1],"t24") == 0) Do24= 1;
|
else if (strcmp(argv[1], "t24") == 0) Do24 = 1;
|
||||||
else if (strcmp(argv[1],"t25") == 0) Do25= 1;
|
else if (strcmp(argv[1], "t25") == 0) Do25 = 1;
|
||||||
else if (strcmp(argv[1],"t26") == 0) Do26= 1;
|
else if (strcmp(argv[1], "t26") == 0) Do26 = 1;
|
||||||
else if (strcmp(argv[1],"t27") == 0) Do27= 1;
|
else if (strcmp(argv[1], "t27") == 0) Do27 = 1;
|
||||||
else if (strcmp(argv[1],"t28") == 0) Do28= 1;
|
else if (strcmp(argv[1], "t28") == 0) Do28 = 1;
|
||||||
else if (strcmp(argv[1],"t29") == 0) Do29= 1;
|
else if (strcmp(argv[1], "t29") == 0) Do29 = 1;
|
||||||
else if (strcmp(argv[1],"t30") == 0) Do30= 1;
|
else if (strcmp(argv[1], "t30") == 0) Do30 = 1;
|
||||||
else if (strcmp(argv[1],"t31") == 0) Do31= 1;
|
else if (strcmp(argv[1], "t31") == 0) Do31 = 1;
|
||||||
else if (strcmp(argv[1],"t32") == 0) Do32= 1;
|
else if (strcmp(argv[1], "t32") == 0) Do32 = 1;
|
||||||
else if (strcmp(argv[1],"t33") == 0) Do33= 1;
|
else if (strcmp(argv[1], "t33") == 0) Do33 = 1;
|
||||||
else if (strcmp(argv[1],"t34") == 0) Do34= 1;
|
else if (strcmp(argv[1], "t34") == 0) Do34 = 1;
|
||||||
else if (strcmp(argv[1],"t35") == 0) Do35= 1;
|
else if (strcmp(argv[1], "t35") == 0) Do35 = 1;
|
||||||
else if (strcmp(argv[1],"t36") == 0) Do35= 1;
|
else if (strcmp(argv[1], "t36") == 0) Do35 = 1;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
PopulateIndexTest pit(DistributedEngineComm::instance());
|
|
||||||
boost::timer theTimer;
|
|
||||||
|
|
||||||
if (DoAll)
|
PopulateIndexTest pit(DistributedEngineComm::instance());
|
||||||
|
boost::timer theTimer;
|
||||||
|
|
||||||
|
if (DoAll)
|
||||||
{
|
{
|
||||||
cout << "Starting all tests" << endl;
|
cout << "Starting all tests" << endl;
|
||||||
|
|
||||||
pit.test_createindex();
|
pit.test_createindex();
|
||||||
pit.test_createuniqueindex();
|
pit.test_createuniqueindex();
|
||||||
std::string altsql = "ALTER TABLE tpch.region add CONSTRAINT test1_cstr unique(r_name);";
|
std::string altsql = "ALTER TABLE tpch.region add CONSTRAINT test1_cstr unique(r_name);";
|
||||||
pit.test_altertable_addtableconstraint(altsql);
|
pit.test_altertable_addtableconstraint(altsql);
|
||||||
pit.test_altertable_addtablenullconstraint();
|
pit.test_altertable_addtablenullconstraint();
|
||||||
|
|
||||||
cout << "Finished all tests" << endl;
|
cout << "Finished all tests" << endl;
|
||||||
}
|
}
|
||||||
else if (Do1)
|
else if (Do1)
|
||||||
{
|
|
||||||
pit.test_createindex();
|
|
||||||
|
|
||||||
cout << "Finished create index test" << endl;
|
|
||||||
}
|
|
||||||
else if (Do2)
|
|
||||||
{
|
|
||||||
pit.test_createuniqueindex();
|
|
||||||
|
|
||||||
cout << "Finished create unique index test" << endl;
|
|
||||||
}
|
|
||||||
else if (Do3)
|
|
||||||
{
|
{
|
||||||
std::string sqlbuf = "ALTER TABLE tpch.region add CONSTRAINT test1r5_cstr unique(r_name);";
|
pit.test_createindex();
|
||||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
|
||||||
cout << "Finished add table constraint test" << endl;
|
cout << "Finished create index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do4)
|
else if (Do2)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX test4_idx ON tpch.part (p_size)");
|
pit.test_createuniqueindex();
|
||||||
pit.test_createindextest(sql);
|
|
||||||
|
cout << "Finished create unique index test" << endl;
|
||||||
cout << "Finished " << sql << endl;
|
|
||||||
}
|
}
|
||||||
else if (Do5)
|
else if (Do3)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX test5_idx ON tpch.part (p_name)");
|
std::string sqlbuf = "ALTER TABLE tpch.region add CONSTRAINT test1r5_cstr unique(r_name);";
|
||||||
pit.test_createindextest(sql);
|
pit.test_altertable_addtableconstraint(sqlbuf);
|
||||||
|
cout << "Finished add table constraint test" << endl;
|
||||||
cout << "Finished " << sql << endl;
|
|
||||||
}
|
}
|
||||||
else if (Do6)
|
else if (Do4)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX test6_idx ON tpch.orders (o_orderkey, o_custkey)");
|
std::string sql("CREATE INDEX test4_idx ON tpch.part (p_size)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
|
|
||||||
cout << "Finished " << sql << endl;
|
cout << "Finished " << sql << endl;
|
||||||
}
|
}
|
||||||
else if (Do7)
|
else if (Do5)
|
||||||
{
|
{
|
||||||
std::string sqlbuf = "ALTER TABLE tpch.supplier add CONSTRAINT tests2_cstr unique(s_name);";
|
std::string sql("CREATE INDEX test5_idx ON tpch.part (p_name)");
|
||||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table constraint test" << endl;
|
|
||||||
|
cout << "Finished " << sql << endl;
|
||||||
}
|
}
|
||||||
else if (Do8)
|
else if (Do6)
|
||||||
{
|
{
|
||||||
std::string sqlbuf = "ALTER TABLE tpch.partsupp add CONSTRAINT testps1_cstr unique(ps_partkey);";
|
std::string sql("CREATE INDEX test6_idx ON tpch.orders (o_orderkey, o_custkey)");
|
||||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table constraint test: should fail ps_partkey is not unique" << endl;
|
|
||||||
|
cout << "Finished " << sql << endl;
|
||||||
|
}
|
||||||
|
else if (Do7)
|
||||||
|
{
|
||||||
|
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)
|
else if (Do9)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX test7_idx ON tpch.customer (c_custkey)");
|
std::string sql("CREATE INDEX test7_idx ON tpch.customer (c_custkey)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do10)
|
else if (Do10)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX test8_idx ON tpch.supplier(s_phone)");
|
std::string sql("CREATE INDEX test8_idx ON tpch.supplier(s_phone)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do11)
|
else if (Do11)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX test9_idx ON tpch.part (p_retailprice)");
|
std::string sql("CREATE INDEX test9_idx ON tpch.part (p_retailprice)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do12)
|
else if (Do12)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX test10_idx ON tpch.customer (c_acctbal)");
|
std::string sql("CREATE INDEX test10_idx ON tpch.customer (c_acctbal)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do13)
|
else if (Do13)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE UNIQUE INDEX test11_idx ON tpch.orders (o_clerk)");
|
std::string sql("CREATE UNIQUE INDEX test11_idx ON tpch.orders (o_clerk)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test: should fail" << endl;
|
cout << "Finished add table index test: should fail" << endl;
|
||||||
}
|
}
|
||||||
else if (Do14)
|
else if (Do14)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX test12_idx ON tpch.lineitem (l_returnflag)");
|
std::string sql("CREATE INDEX test12_idx ON tpch.lineitem (l_returnflag)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do15)
|
else if (Do15)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX test13_idx ON tpch.lineitem (l_linestatus)");
|
std::string sql("CREATE INDEX test13_idx ON tpch.lineitem (l_linestatus)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do16)
|
else if (Do16)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX multi_4idx ON tpch.region (r_regionkey, r_name)");
|
std::string sql("CREATE INDEX multi_4idx ON tpch.region (r_regionkey, r_name)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do17)
|
else if (Do17)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX multi_5idx ON tpch.orders (o_orderkey, o_orderstatus)");
|
std::string sql("CREATE INDEX multi_5idx ON tpch.orders (o_orderkey, o_orderstatus)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do18)
|
else if (Do18)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE UNIQUE INDEX orderkey_idx ON tpch.orders (o_orderkey)");
|
std::string sql("CREATE UNIQUE INDEX orderkey_idx ON tpch.orders (o_orderkey)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do19)
|
else if (Do19)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE UNIQUE INDEX partkey_idx ON tpch.part (p_partkey)");
|
std::string sql("CREATE UNIQUE INDEX partkey_idx ON tpch.part (p_partkey)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do20)
|
else if (Do20)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX lorderkey_idx ON tpch.lineitem (l_orderkey)");
|
std::string sql("CREATE INDEX lorderkey_idx ON tpch.lineitem (l_orderkey)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do21)
|
else if (Do21)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX lpartkey1_idx ON tpch.lineitem (l_partkey)");
|
std::string sql("CREATE INDEX lpartkey1_idx ON tpch.lineitem (l_partkey)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do22)
|
else if (Do22)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX suppkey1_idx ON tpch.lineitem (l_suppkey)");
|
std::string sql("CREATE INDEX suppkey1_idx ON tpch.lineitem (l_suppkey)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
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)");
|
std::string sql("CREATE INDEX n_regionkey_id ON tpch.nation (n_regionkey)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do24)
|
else if (Do24)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX multi_cust_idx ON tpch.customer (c_name, c_address, c_phone, c_mktsegment)");
|
std::string sql("CREATE INDEX multi_cust_idx ON tpch.customer (c_name, c_address, c_phone, c_mktsegment)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test: " << sql << endl;
|
cout << "Finished add table index test: " << sql << endl;
|
||||||
}
|
}
|
||||||
else if (Do25)
|
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)");
|
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);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test: " << sql << endl;
|
cout << "Finished add table index test: " << sql << endl;
|
||||||
}
|
}
|
||||||
else if (Do26)
|
else if (Do26)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX o_date_idx ON tpch.orders (o_orderdate)");
|
std::string sql("CREATE INDEX o_date_idx ON tpch.orders (o_orderdate)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test: " << sql << endl;
|
cout << "Finished add table index test: " << sql << endl;
|
||||||
}
|
}
|
||||||
else if (Do27)
|
else if (Do27)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE INDEX multi_order_idx ON tpch.orders (o_orderkey, o_orderstatus, o_orderdate)");
|
std::string sql("CREATE INDEX multi_order_idx ON tpch.orders (o_orderkey, o_orderstatus, o_orderdate)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test: " << sql << endl;
|
cout << "Finished add table index test: " << sql << endl;
|
||||||
}
|
}
|
||||||
else if (Do28)
|
else if (Do28)
|
||||||
{
|
{
|
||||||
string sql("create table tpch.tablea( c1 integer, c2 char);");
|
string sql("create table tpch.tablea( c1 integer, c2 char);");
|
||||||
pit.test_createtabletest(sql);
|
pit.test_createtabletest(sql);
|
||||||
std::string sqlbuf = "ALTER TABLE tpch.tablea add CONSTRAINT tablea_cstr1 unique(c2);";
|
std::string sqlbuf = "ALTER TABLE tpch.tablea add CONSTRAINT tablea_cstr1 unique(c2);";
|
||||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
pit.test_altertable_addtableconstraint(sqlbuf);
|
||||||
cout << "Finished add table constraint test" << endl;
|
cout << "Finished add table constraint test" << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (Do29)
|
else if (Do29)
|
||||||
{
|
{
|
||||||
std::string sqlbuf = "ALTER TABLE tpch.nation add CONSTRAINT testn1_cstr unique(n_regionkey);";
|
std::string sqlbuf = "ALTER TABLE tpch.nation add CONSTRAINT testn1_cstr unique(n_regionkey);";
|
||||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
pit.test_altertable_addtableconstraint(sqlbuf);
|
||||||
cout << "Finished add table constraint test: should fail n_regionkey is not unique" << endl;
|
cout << "Finished add table constraint test: should fail n_regionkey is not unique" << endl;
|
||||||
}
|
}
|
||||||
else if (Do30)
|
else if (Do30)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE UNIQUE INDEX multicstr_1idx ON tpch.region (r_regionkey, r_name)");
|
std::string sql("CREATE UNIQUE INDEX multicstr_1idx ON tpch.region (r_regionkey, r_name)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do31)
|
else if (Do31)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE UNIQUE INDEX multicsto_1idx ON tpch.orders (o_orderkey, o_orderstatus)");
|
std::string sql("CREATE UNIQUE INDEX multicsto_1idx ON tpch.orders (o_orderkey, o_orderstatus)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
cout << "Finished add table index test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do32)
|
else if (Do32)
|
||||||
{
|
{
|
||||||
std::string sql("CREATE UNIQUE INDEX multicstn_1idx ON tpch.nation (n_nationkey, n_regionkey)");
|
std::string sql("CREATE UNIQUE INDEX multicstn_1idx ON tpch.nation (n_nationkey, n_regionkey)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
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)");
|
std::string sql("CREATE UNIQUE INDEX multicstps_1idx ON tpch.partsupp (ps_partkey, ps_suppkey)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test" << endl;
|
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)");
|
std::string sql("CREATE UNIQUE INDEX multicsto_2idx ON tpch.orders (o_orderstatus, o_orderpriority)");
|
||||||
pit.test_createindextest(sql);
|
pit.test_createindextest(sql);
|
||||||
cout << "Finished add table index test: should fail" << endl;
|
cout << "Finished add table index test: should fail" << endl;
|
||||||
}
|
}
|
||||||
else if (Do35)
|
else if (Do35)
|
||||||
{
|
{
|
||||||
std::string sql("ALTER TABLE tpch.nation add CONSTRAINT testn2_cstr unique(n_nationkey);");
|
std::string sql("ALTER TABLE tpch.nation add CONSTRAINT testn2_cstr unique(n_nationkey);");
|
||||||
pit.test_altertable_addtableconstraint(sql);
|
pit.test_altertable_addtableconstraint(sql);
|
||||||
cout << "Finished add table constraint test" << endl;
|
cout << "Finished add table constraint test" << endl;
|
||||||
}
|
}
|
||||||
else if (Do36)
|
else if (Do36)
|
||||||
{
|
{
|
||||||
pit.test_altertable_addtablenullconstraint();
|
pit.test_altertable_addtablenullconstraint();
|
||||||
|
|
||||||
cout << "Finished add table not null constraint test" << endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cout << "No Test Selected!" << endl << endl;
|
|
||||||
|
|
||||||
cout << "All" << endl;
|
cout << "Finished add table not null constraint test" << endl;
|
||||||
cout << "t1" << endl;
|
|
||||||
cout << "t2" << endl;
|
|
||||||
cout << "t3" << endl;
|
|
||||||
cout << "t4" << endl;
|
|
||||||
cout << endl;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cout << "No Test Selected!" << endl << 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;
|
cout << "Create index test took :" << theTimer.elapsed() << " seconds to complete." << endl;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
//{{NO_DEPENDENCIES}}
|
//{{NO_DEPENDENCIES}}
|
||||||
// Microsoft Visual C++ generated include file.
|
// Microsoft Visual C++ generated include file.
|
||||||
// Used by libddlpackageproc.rc
|
// Used by libddlpackageproc.rc
|
||||||
|
|
||||||
// Next default values for new objects
|
// Next default values for new objects
|
||||||
//
|
//
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
#define _APS_NEXT_SYMED_VALUE 101
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -35,238 +35,262 @@ using namespace WriteEngine;
|
|||||||
namespace ddlpackageprocessor
|
namespace ddlpackageprocessor
|
||||||
{
|
{
|
||||||
|
|
||||||
RestorePartitionProcessor::DDLResult RestorePartitionProcessor::processPackage(ddlpackage::RestorePartitionStatement& restorePartitionStmt)
|
RestorePartitionProcessor::DDLResult RestorePartitionProcessor::processPackage(ddlpackage::RestorePartitionStatement& restorePartitionStmt)
|
||||||
{
|
{
|
||||||
SUMMARY_INFO("RestorePartitionProcessor::processPackage");
|
SUMMARY_INFO("RestorePartitionProcessor::processPackage");
|
||||||
|
|
||||||
DDLResult result;
|
DDLResult result;
|
||||||
result.result = NO_ERROR;
|
result.result = NO_ERROR;
|
||||||
std::string err;
|
std::string err;
|
||||||
VERBOSE_INFO(restorePartitionStmt);
|
VERBOSE_INFO(restorePartitionStmt);
|
||||||
|
|
||||||
BRM::TxnID txnID;
|
BRM::TxnID txnID;
|
||||||
txnID.id= fTxnid.id;
|
txnID.id = fTxnid.id;
|
||||||
txnID.valid= fTxnid.valid;
|
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");
|
|
||||||
|
|
||||||
string stmt = restorePartitionStmt.fSql + "|" + restorePartitionStmt.fTableName->fSchema +"|";
|
int rc = 0;
|
||||||
SQLLogger logger(stmt, fDDLLoggingId, restorePartitionStmt.fSessionID, txnID.id);
|
rc = fDbrm->isReadWrite();
|
||||||
|
|
||||||
uint32_t processID = 0;
|
if (rc != 0 )
|
||||||
uint64_t uniqueID = 0;
|
{
|
||||||
uint32_t sessionID = restorePartitionStmt.fSessionID;
|
logging::Message::Args args;
|
||||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
logging::Message message(9);
|
||||||
|
args.add("Unable to execute the statement due to DBRM is read only");
|
||||||
try
|
message.format(args);
|
||||||
{
|
result.result = DROP_ERROR;
|
||||||
//check table lock
|
result.message = message;
|
||||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(restorePartitionStmt.fSessionID);
|
fSessionManager.rolledback(txnID);
|
||||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
return result;
|
||||||
systemCatalogPtr->sessionID(restorePartitionStmt.fSessionID);
|
}
|
||||||
CalpontSystemCatalog::TableName tableName;
|
|
||||||
tableName.schema = restorePartitionStmt.fTableName->fSchema;
|
std::vector <CalpontSystemCatalog::OID> oidList;
|
||||||
tableName.table = restorePartitionStmt.fTableName->fName;
|
CalpontSystemCatalog::RIDList tableColRidList;
|
||||||
roPair = systemCatalogPtr->tableRID( tableName );
|
CalpontSystemCatalog::DictOIDList dictOIDList;
|
||||||
//@Bug 3054 check for system catalog
|
std::string processName("DDLProc");
|
||||||
if ( roPair.objnum < 3000 )
|
|
||||||
{
|
string stmt = restorePartitionStmt.fSql + "|" + restorePartitionStmt.fTableName->fSchema + "|";
|
||||||
throw std::runtime_error("Drop partition cannot be operated on Calpont system catalog.");
|
SQLLogger logger(stmt, fDDLLoggingId, restorePartitionStmt.fSessionID, txnID.id);
|
||||||
}
|
|
||||||
int i = 0;
|
uint32_t processID = 0;
|
||||||
processID = ::getpid();
|
uint64_t uniqueID = 0;
|
||||||
oam::OamCache * oamcache = oam::OamCache::makeOamCache();
|
uint32_t sessionID = restorePartitionStmt.fSessionID;
|
||||||
std::vector<int> pmList = oamcache->getModuleIds();
|
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||||
std::vector<uint32_t> pms;
|
|
||||||
for (unsigned i=0; i < pmList.size(); i++)
|
try
|
||||||
{
|
{
|
||||||
pms.push_back((uint32_t)pmList[i]);
|
//check table lock
|
||||||
}
|
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(restorePartitionStmt.fSessionID);
|
||||||
|
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||||
try {
|
systemCatalogPtr->sessionID(restorePartitionStmt.fSessionID);
|
||||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
CalpontSystemCatalog::TableName tableName;
|
||||||
}
|
tableName.schema = restorePartitionStmt.fTableName->fSchema;
|
||||||
catch (std::exception&)
|
tableName.table = restorePartitionStmt.fTableName->fName;
|
||||||
{
|
roPair = systemCatalogPtr->tableRID( tableName );
|
||||||
result.result = DROP_ERROR;
|
|
||||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
//@Bug 3054 check for system catalog
|
||||||
fSessionManager.rolledback(txnID);
|
if ( roPair.objnum < 3000 )
|
||||||
return result;
|
{
|
||||||
}
|
throw std::runtime_error("Drop partition cannot be operated on Calpont system catalog.");
|
||||||
|
}
|
||||||
if ( uniqueID == 0 )
|
|
||||||
{
|
int i = 0;
|
||||||
int waitPeriod = 10;
|
processID = ::getpid();
|
||||||
int sleepTime = 100; // sleep 100 milliseconds between checks
|
oam::OamCache* oamcache = oam::OamCache::makeOamCache();
|
||||||
int numTries = 10; // try 10 times per second
|
std::vector<int> pmList = oamcache->getModuleIds();
|
||||||
waitPeriod = Config::getWaitPeriod();
|
std::vector<uint32_t> pms;
|
||||||
numTries = waitPeriod * 10;
|
|
||||||
struct timespec rm_ts;
|
for (unsigned i = 0; i < pmList.size(); i++)
|
||||||
|
{
|
||||||
rm_ts.tv_sec = sleepTime/1000;
|
pms.push_back((uint32_t)pmList[i]);
|
||||||
rm_ts.tv_nsec = sleepTime%1000 *1000000;
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
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
|
#ifdef _MSC_VER
|
||||||
Sleep(rm_ts.tv_sec * 1000);
|
Sleep(rm_ts.tv_sec * 1000);
|
||||||
#else
|
#else
|
||||||
struct timespec abs_ts;
|
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";
|
|
||||||
|
|
||||||
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 (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
|
do
|
||||||
// 2. Get the OIDs for the dictionaries
|
{
|
||||||
// 3. Save the OIDs to a log file
|
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||||
// 4. Remove the extents from extentmap
|
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||||
// 5. Flush PrimProc Cache
|
}
|
||||||
// 6. Remove the column and dictionary files for the partition
|
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||||
|
|
||||||
CalpontSystemCatalog::TableName userTableName;
|
#endif
|
||||||
userTableName.schema = restorePartitionStmt.fTableName->fSchema;
|
// reset
|
||||||
userTableName.table = restorePartitionStmt.fTableName->fName;
|
sessionID = restorePartitionStmt.fSessionID;
|
||||||
|
txnID.id = fTxnid.id;
|
||||||
tableColRidList = systemCatalogPtr->columnRIDs( userTableName );
|
txnID.valid = fTxnid.valid;
|
||||||
|
processID = ::getpid();
|
||||||
dictOIDList = systemCatalogPtr->dictOIDs( userTableName );
|
processName = "DDLProc";
|
||||||
|
|
||||||
//Save qualified tablename, all column, dictionary OIDs, and transaction ID into a file in ASCII format
|
try
|
||||||
for ( unsigned i=0; i < tableColRidList.size(); i++ )
|
{
|
||||||
{
|
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||||
if ( tableColRidList[i].objnum > 3000 )
|
}
|
||||||
oidList.push_back( tableColRidList[i].objnum );
|
catch (std::exception&)
|
||||||
}
|
{
|
||||||
for ( unsigned i=0; i < dictOIDList.size(); i++ )
|
result.result = DROP_ERROR;
|
||||||
{
|
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||||
if ( dictOIDList[i].dictOID > 3000 )
|
fSessionManager.rolledback(txnID);
|
||||||
oidList.push_back( dictOIDList[i].dictOID );
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Remove the partition from extent map
|
if (uniqueID > 0)
|
||||||
string emsg;
|
break;
|
||||||
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());
|
|
||||||
|
|
||||||
if (( rc == BRM::ERR_NOT_EXIST_PARTITION) || (rc == BRM::ERR_INVALID_OP_LAST_PARTITION) ||
|
if (i >= numTries) //error out
|
||||||
(rc == BRM::ERR_PARTITION_DISABLED) || (rc == BRM::ERR_TABLE_NOT_LOCKED))
|
{
|
||||||
result.result = USER_ERROR;
|
result.result = DROP_ERROR;
|
||||||
else if (rc == BRM::ERR_PARTITION_ENABLED)
|
logging::Message::Args args;
|
||||||
result.result = PARTITION_WARNING;
|
string strOp("restore partition");
|
||||||
else
|
args.add(strOp);
|
||||||
result.result = DROP_ERROR;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result.message = message;
|
// 1. Get the OIDs for the columns
|
||||||
try {
|
// 2. Get the OIDs for the dictionaries
|
||||||
fDbrm->releaseTableLock(uniqueID);
|
// 3. Save the OIDs to a log file
|
||||||
} catch (std::exception&)
|
// 4. Remove the extents from extentmap
|
||||||
{
|
// 5. Flush PrimProc Cache
|
||||||
result.result = DROP_ERROR;
|
// 6. Remove the column and dictionary files for the partition
|
||||||
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;
|
CalpontSystemCatalog::TableName userTableName;
|
||||||
logging::Message message(1);
|
userTableName.schema = restorePartitionStmt.fTableName->fSchema;
|
||||||
args.add("Enable partition: ");
|
userTableName.table = restorePartitionStmt.fTableName->fName;
|
||||||
args.add( "encountered unkown exception" );
|
|
||||||
args.add("");
|
tableColRidList = systemCatalogPtr->columnRIDs( userTableName );
|
||||||
args.add("");
|
|
||||||
message.format( args );
|
dictOIDList = systemCatalogPtr->dictOIDs( userTableName );
|
||||||
|
|
||||||
result.result = DROP_ERROR;
|
//Save qualified tablename, all column, dictionary OIDs, and transaction ID into a file in ASCII format
|
||||||
result.message = message;
|
for ( unsigned i = 0; i < tableColRidList.size(); i++ )
|
||||||
try {
|
{
|
||||||
fDbrm->releaseTableLock(uniqueID);
|
if ( tableColRidList[i].objnum > 3000 )
|
||||||
} catch (std::exception&)
|
oidList.push_back( tableColRidList[i].objnum );
|
||||||
{
|
}
|
||||||
result.result = DROP_ERROR;
|
|
||||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
for ( unsigned i = 0; i < dictOIDList.size(); i++ )
|
||||||
}
|
{
|
||||||
fSessionManager.rolledback(txnID);
|
if ( dictOIDList[i].dictOID > 3000 )
|
||||||
return result;
|
oidList.push_back( dictOIDList[i].dictOID );
|
||||||
}
|
}
|
||||||
// Log the DDL statement
|
|
||||||
logging::logDDL(restorePartitionStmt.fSessionID, txnID.id, restorePartitionStmt.fSql, restorePartitionStmt.fOwner);
|
//Remove the partition from extent map
|
||||||
try {
|
string emsg;
|
||||||
fDbrm->releaseTableLock(uniqueID);
|
rc = fDbrm->restorePartition( oidList, restorePartitionStmt.fPartitions, emsg);
|
||||||
} catch (std::exception&)
|
|
||||||
{
|
if ( rc != 0 )
|
||||||
result.result = DROP_ERROR;
|
{
|
||||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
throw std::runtime_error(emsg);
|
||||||
fSessionManager.rolledback(txnID);
|
}
|
||||||
return result;
|
}
|
||||||
}
|
catch (exception& ex)
|
||||||
fSessionManager.committed(txnID);
|
{
|
||||||
return result;
|
logging::Message::Args args;
|
||||||
}
|
logging::Message message(ex.what());
|
||||||
|
|
||||||
|
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.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
|
namespace ddlpackageprocessor
|
||||||
{
|
{
|
||||||
/** @brief specialization of a DDLPacakageProcessor
|
/** @brief specialization of a DDLPacakageProcessor
|
||||||
* for interacting with the Write Engine to process
|
* for interacting with the Write Engine to process
|
||||||
* drop table ddl statements.
|
* 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
|
EXPORT DDLResult processPackage(ddlpackage::RestorePartitionStatement& RestorePartitionStmt);
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace ddlpackageprocessor
|
} // namespace ddlpackageprocessor
|
||||||
|
|
||||||
#undef EXPORT
|
#undef EXPORT
|
||||||
|
|||||||
@@ -404,60 +404,64 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void destroySemaphores()
|
void destroySemaphores()
|
||||||
{
|
{
|
||||||
key_t semkey;
|
key_t semkey;
|
||||||
int sems, err;
|
int sems, err;
|
||||||
|
|
||||||
semkey = 0x2149bdd2;
|
semkey = 0x2149bdd2;
|
||||||
sems = semget(semkey, 2, 0666);
|
sems = semget(semkey, 2, 0666);
|
||||||
if (sems != -1)
|
|
||||||
|
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);
|
perror("tdriver: shmctl");
|
||||||
if (err == -1)
|
return;
|
||||||
perror("tdriver: semctl");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setUp()
|
||||||
|
{
|
||||||
|
destroySemaphores();
|
||||||
|
destroyShmseg();
|
||||||
|
unlink("/tmp/oidbitmap");
|
||||||
|
SystemCatalogBuilder::build();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tearDown()
|
||||||
void destroyShmseg()
|
{
|
||||||
{
|
destroySemaphores();
|
||||||
key_t shmkey;
|
destroyShmseg();
|
||||||
int shms, err;
|
unlink("/tmp/oidbitmap");
|
||||||
|
}
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
class DDLPackageProcessorTest : public CppUnit::TestFixture
|
class DDLPackageProcessorTest : public CppUnit::TestFixture
|
||||||
{
|
{
|
||||||
CPPUNIT_TEST_SUITE(DDLPackageProcessorTest);
|
CPPUNIT_TEST_SUITE(DDLPackageProcessorTest);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CPPUNIT_TEST( test_createtable );
|
CPPUNIT_TEST( test_createtable );
|
||||||
CPPUNIT_TEST( test_createtable_region );
|
CPPUNIT_TEST( test_createtable_region );
|
||||||
@@ -474,10 +478,10 @@ class DDLPackageProcessorTest : public CppUnit::TestFixture
|
|||||||
CPPUNIT_TEST( test_altertable_dropcolumns );
|
CPPUNIT_TEST( test_altertable_dropcolumns );
|
||||||
CPPUNIT_TEST( test_altertable_addcolumns );
|
CPPUNIT_TEST( test_altertable_addcolumns );
|
||||||
CPPUNIT_TEST( test_altertable_addtableconstraint );
|
CPPUNIT_TEST( test_altertable_addtableconstraint );
|
||||||
CPPUNIT_TEST( test_altertable_droptableconstraint );
|
CPPUNIT_TEST( test_altertable_droptableconstraint );
|
||||||
CPPUNIT_TEST( test_altertable_setcolumndefault );
|
CPPUNIT_TEST( test_altertable_setcolumndefault );
|
||||||
CPPUNIT_TEST( test_altertable_dropcolumndefault );
|
CPPUNIT_TEST( test_altertable_dropcolumndefault );
|
||||||
CPPUNIT_TEST( test_altertable_renametable );
|
CPPUNIT_TEST( test_altertable_renametable );
|
||||||
CPPUNIT_TEST( test_dropindex );
|
CPPUNIT_TEST( test_dropindex );
|
||||||
CPPUNIT_TEST( test_droptable ); */
|
CPPUNIT_TEST( test_droptable ); */
|
||||||
|
|
||||||
@@ -492,30 +496,33 @@ public:
|
|||||||
*/
|
*/
|
||||||
void test_createtable_region()
|
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));";
|
std::string sqlbuf = "create table region( r_regionkey integer NOT NULL, r_name char(25) ,r_comment varchar(152));";
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CreateTableProcessor processor;
|
CreateTableProcessor processor;
|
||||||
processor.setDebugLevel(CreateTableProcessor::VERBOSE);
|
processor.setDebugLevel(CreateTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
CreateTableProcessor::DDLResult result;
|
CreateTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<CreateTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<CreateTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -524,36 +531,39 @@ public:
|
|||||||
//setUp();
|
//setUp();
|
||||||
//removeSystemCatalog();
|
//removeSystemCatalog();
|
||||||
//createSystemCatalog();
|
//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) )";
|
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;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CreateTableProcessor processor;
|
CreateTableProcessor processor;
|
||||||
processor.setDebugLevel(CreateTableProcessor::VERBOSE);
|
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 << "Parsed CreateTable:" << endl;
|
||||||
cout << ct << endl;
|
cout << ct << endl;
|
||||||
|
|
||||||
CreateTableProcessor::DDLResult result;
|
CreateTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(ct);
|
result = processor.processPackage(ct);
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,86 +573,93 @@ public:
|
|||||||
std::string sqlbuf = "CREATE INDEX test_idx ON tpch.part (p_size)";
|
std::string sqlbuf = "CREATE INDEX test_idx ON tpch.part (p_size)";
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CreateIndexProcessor processor;
|
CreateIndexProcessor processor;
|
||||||
processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
CreateIndexProcessor::DDLResult result;
|
CreateIndexProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_createuniqueindex()
|
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)";
|
std::string sqlbuf = "CREATE UNIQUE INDEX test_idx ON tpch.part (p_mfgr)";
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CreateIndexProcessor processor;
|
CreateIndexProcessor processor;
|
||||||
processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
CreateIndexProcessor::DDLResult result;
|
CreateIndexProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
void test_altertable_addacolumn()
|
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)";
|
std::string sqlbuf = "ALTER TABLE tpch.part ADD COLUMN c3 char(50)";
|
||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AlterTableProcessor processor;
|
AlterTableProcessor processor;
|
||||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
AlterTableProcessor::DDLResult result;
|
AlterTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,56 +670,62 @@ public:
|
|||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AlterTableProcessor processor;
|
AlterTableProcessor processor;
|
||||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
AlterTableProcessor::DDLResult result;
|
AlterTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_altertable_addacolumnunique()
|
void test_altertable_addacolumnunique()
|
||||||
{
|
{
|
||||||
cout << "Begining Alter Table add column with constraint test ..." << endl;
|
cout << "Begining Alter Table add column with constraint test ..." << endl;
|
||||||
std::string sqlbuf = "ALTER TABLE tpch.part ADD COLUMN c3 char(50) UNIQUE";
|
std::string sqlbuf = "ALTER TABLE tpch.part ADD COLUMN c3 char(50) UNIQUE";
|
||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AlterTableProcessor processor;
|
AlterTableProcessor processor;
|
||||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
AlterTableProcessor::DDLResult result;
|
AlterTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
void test_altertable_dropacolumn()
|
void test_altertable_dropacolumn()
|
||||||
@@ -712,26 +735,29 @@ public:
|
|||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AlterTableProcessor processor;
|
AlterTableProcessor processor;
|
||||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
AlterTableProcessor::DDLResult result;
|
AlterTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -742,26 +768,29 @@ public:
|
|||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AlterTableProcessor processor;
|
AlterTableProcessor processor;
|
||||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
AlterTableProcessor::DDLResult result;
|
AlterTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -772,26 +801,29 @@ public:
|
|||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AlterTableProcessor processor;
|
AlterTableProcessor processor;
|
||||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
AlterTableProcessor::DDLResult result;
|
AlterTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
void test_dropindex()
|
void test_dropindex()
|
||||||
@@ -801,27 +833,29 @@ public:
|
|||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DropIndexProcessor processor;
|
DropIndexProcessor processor;
|
||||||
processor.setDebugLevel(DropIndexProcessor::VERBOSE);
|
processor.setDebugLevel(DropIndexProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
DropIndexProcessor::DDLResult result;
|
DropIndexProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<DropIndexStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<DropIndexStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
void test_altertable_renamecolumn()
|
void test_altertable_renamecolumn()
|
||||||
@@ -831,26 +865,29 @@ public:
|
|||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AlterTableProcessor processor;
|
AlterTableProcessor processor;
|
||||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
AlterTableProcessor::DDLResult result;
|
AlterTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -862,26 +899,29 @@ public:
|
|||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AlterTableProcessor processor;
|
AlterTableProcessor processor;
|
||||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
AlterTableProcessor::DDLResult result;
|
AlterTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
void test_altertable_addtableconstraint()
|
void test_altertable_addtableconstraint()
|
||||||
@@ -891,26 +931,29 @@ public:
|
|||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AlterTableProcessor processor;
|
AlterTableProcessor processor;
|
||||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
AlterTableProcessor::DDLResult result;
|
AlterTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -921,26 +964,29 @@ public:
|
|||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AlterTableProcessor processor;
|
AlterTableProcessor processor;
|
||||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
AlterTableProcessor::DDLResult result;
|
AlterTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -951,26 +997,29 @@ public:
|
|||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AlterTableProcessor processor;
|
AlterTableProcessor processor;
|
||||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
AlterTableProcessor::DDLResult result;
|
AlterTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
void test_altertable_dropcolumndefault()
|
void test_altertable_dropcolumndefault()
|
||||||
@@ -980,26 +1029,29 @@ public:
|
|||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AlterTableProcessor processor;
|
AlterTableProcessor processor;
|
||||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
AlterTableProcessor::DDLResult result;
|
AlterTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1010,26 +1062,29 @@ public:
|
|||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AlterTableProcessor processor;
|
AlterTableProcessor processor;
|
||||||
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
processor.setDebugLevel(AlterTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
AlterTableProcessor::DDLResult result;
|
AlterTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<AlterTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1040,27 +1095,29 @@ public:
|
|||||||
|
|
||||||
SqlParser parser;
|
SqlParser parser;
|
||||||
parser.Parse(sqlbuf.c_str());
|
parser.Parse(sqlbuf.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.GetParseTree();
|
const ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DropTableProcessor processor;
|
DropTableProcessor processor;
|
||||||
processor.setDebugLevel(DropTableProcessor::VERBOSE);
|
processor.setDebugLevel(DropTableProcessor::VERBOSE);
|
||||||
|
|
||||||
SqlStatement &stmt = *ptree.fList[0];
|
SqlStatement& stmt = *ptree.fList[0];
|
||||||
DropTableProcessor::DDLResult result;
|
DropTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<DropTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<DropTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
tearDown();
|
tearDown();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown();
|
tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1071,12 +1128,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION( DDLPackageProcessorTest );
|
|||||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||||
#include <cppunit/ui/text/TestRunner.h>
|
#include <cppunit/ui/text/TestRunner.h>
|
||||||
|
|
||||||
int main( int argc, char **argv)
|
int main( int argc, char** argv)
|
||||||
{
|
{
|
||||||
// Uncomment before running tests
|
// Uncomment before running tests
|
||||||
//setUp();
|
//setUp();
|
||||||
CppUnit::TextUi::TestRunner runner;
|
CppUnit::TextUi::TestRunner runner;
|
||||||
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
|
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||||
runner.addTest( registry.makeTest() );
|
runner.addTest( registry.makeTest() );
|
||||||
bool wasSuccessful = runner.run( "", false );
|
bool wasSuccessful = runner.run( "", false );
|
||||||
return (wasSuccessful ? 0 : 1);
|
return (wasSuccessful ? 0 : 1);
|
||||||
|
|||||||
@@ -50,22 +50,25 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackage(dmlpacka
|
|||||||
std::string defaultSchema /*= ""*/)
|
std::string defaultSchema /*= ""*/)
|
||||||
{
|
{
|
||||||
CalpontDMLPackage* packagePtr = 0;
|
CalpontDMLPackage* packagePtr = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::string dmlStatement = vpackage.get_DMLStatement();
|
std::string dmlStatement = vpackage.get_DMLStatement();
|
||||||
//@Bug 2680. DMLParser is not thread safe.
|
//@Bug 2680. DMLParser is not thread safe.
|
||||||
boost::mutex::scoped_lock lk(fParserLock);
|
boost::mutex::scoped_lock lk(fParserLock);
|
||||||
DMLParser parser;
|
DMLParser parser;
|
||||||
|
|
||||||
if (defaultSchema.size())
|
if (defaultSchema.size())
|
||||||
{
|
{
|
||||||
parser.setDefaultSchema(defaultSchema);
|
parser.setDefaultSchema(defaultSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
parser.parse(dmlStatement.c_str());
|
parser.parse(dmlStatement.c_str());
|
||||||
|
|
||||||
if (parser.good())
|
if (parser.good())
|
||||||
{
|
{
|
||||||
|
|
||||||
const ParseTree &ptree = parser.getParseTree();
|
const ParseTree& ptree = parser.getParseTree();
|
||||||
SqlStatement* statementPtr = ptree[0];
|
SqlStatement* statementPtr = ptree[0];
|
||||||
|
|
||||||
int dmlStatementType = statementPtr->getStatementType();
|
int dmlStatementType = statementPtr->getStatementType();
|
||||||
@@ -75,21 +78,21 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackage(dmlpacka
|
|||||||
case DML_INSERT:
|
case DML_INSERT:
|
||||||
packagePtr = new InsertDMLPackage(statementPtr->getSchemaName(), statementPtr->getTableName(),
|
packagePtr = new InsertDMLPackage(statementPtr->getSchemaName(), statementPtr->getTableName(),
|
||||||
ptree.fSqlText, vpackage.get_SessionID() );
|
ptree.fSqlText, vpackage.get_SessionID() );
|
||||||
packagePtr->set_SQLStatement(dmlStatement);
|
packagePtr->set_SQLStatement(dmlStatement);
|
||||||
(void)packagePtr->buildFromSqlStatement(*statementPtr);
|
(void)packagePtr->buildFromSqlStatement(*statementPtr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DML_UPDATE:
|
case DML_UPDATE:
|
||||||
packagePtr = new UpdateDMLPackage(statementPtr->getSchemaName(), statementPtr->getTableName(),
|
packagePtr = new UpdateDMLPackage(statementPtr->getSchemaName(), statementPtr->getTableName(),
|
||||||
ptree.fSqlText, vpackage.get_SessionID() );
|
ptree.fSqlText, vpackage.get_SessionID() );
|
||||||
packagePtr->set_SQLStatement(dmlStatement);
|
packagePtr->set_SQLStatement(dmlStatement);
|
||||||
(void)packagePtr->buildFromSqlStatement(*statementPtr);
|
(void)packagePtr->buildFromSqlStatement(*statementPtr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DML_DELETE:
|
case DML_DELETE:
|
||||||
packagePtr = new DeleteDMLPackage(statementPtr->getSchemaName(), statementPtr->getTableName(),
|
packagePtr = new DeleteDMLPackage(statementPtr->getSchemaName(), statementPtr->getTableName(),
|
||||||
ptree.fSqlText, vpackage.get_SessionID() );
|
ptree.fSqlText, vpackage.get_SessionID() );
|
||||||
packagePtr->set_SQLStatement(dmlStatement);
|
packagePtr->set_SQLStatement(dmlStatement);
|
||||||
(void)packagePtr->buildFromSqlStatement(*statementPtr);
|
(void)packagePtr->buildFromSqlStatement(*statementPtr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -122,32 +125,38 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackage(dmlpacka
|
|||||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromBuffer(dmlpackage::VendorDMLStatement& vpackage)
|
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromBuffer(dmlpackage::VendorDMLStatement& vpackage)
|
||||||
{
|
{
|
||||||
CalpontDMLPackage* packagePtr = 0;
|
CalpontDMLPackage* packagePtr = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int dmlStatementType = vpackage.get_DMLStatementType();
|
int dmlStatementType = vpackage.get_DMLStatementType();
|
||||||
|
|
||||||
switch (dmlStatementType)
|
switch (dmlStatementType)
|
||||||
{
|
{
|
||||||
case DML_INSERT:
|
case DML_INSERT:
|
||||||
packagePtr = new InsertDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(), vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
packagePtr = new InsertDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(), vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||||
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer
|
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer
|
||||||
(),vpackage.get_Columns(), vpackage.get_Rows());
|
(), vpackage.get_Columns(), vpackage.get_Rows());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DML_UPDATE:
|
case DML_UPDATE:
|
||||||
packagePtr = new UpdateDMLPackage(vpackage.get_SchemaName(),
|
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
|
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer
|
||||||
(),vpackage.get_Columns(), vpackage.get_Rows());
|
(), vpackage.get_Columns(), vpackage.get_Rows());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DML_DELETE:
|
case DML_DELETE:
|
||||||
packagePtr = new DeleteDMLPackage(vpackage.get_SchemaName(),
|
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
|
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer
|
||||||
(),vpackage.get_Columns(), vpackage.get_Rows());
|
(), vpackage.get_Columns(), vpackage.get_Rows());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DML_COMMAND:
|
case DML_COMMAND:
|
||||||
packagePtr = new CommandDMLPackage(vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
packagePtr = new CommandDMLPackage(vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
cerr << "makeCalpontDMLPackage: invalid statement type" << endl;
|
cerr << "makeCalpontDMLPackage: invalid statement type" << endl;
|
||||||
break;
|
break;
|
||||||
@@ -161,34 +170,40 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromBuffe
|
|||||||
{
|
{
|
||||||
cerr << "makeCalpontDMLPackage: caught unknown exception!" << endl;
|
cerr << "makeCalpontDMLPackage: caught unknown exception!" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return packagePtr;
|
return packagePtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage)
|
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage)
|
||||||
{
|
{
|
||||||
CalpontDMLPackage* packagePtr = 0;
|
CalpontDMLPackage* packagePtr = 0;
|
||||||
try
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
int dmlStatementType = vpackage.get_DMLStatementType();
|
int dmlStatementType = vpackage.get_DMLStatementType();
|
||||||
|
|
||||||
switch (dmlStatementType)
|
switch (dmlStatementType)
|
||||||
{
|
{
|
||||||
case DML_INSERT:
|
case DML_INSERT:
|
||||||
packagePtr = new InsertDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(), vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
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());
|
(void)packagePtr->buildFromMysqlBuffer(vpackage.get_ColNames(), vpackage.get_values(), vpackage.get_Columns(), vpackage.get_Rows(), vpackage.get_nullValues());
|
||||||
break;
|
break;
|
||||||
case DML_COMMAND:
|
|
||||||
|
case DML_COMMAND:
|
||||||
packagePtr = new CommandDMLPackage(vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
packagePtr = new CommandDMLPackage(vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
||||||
break;
|
break;
|
||||||
case DML_DELETE:
|
|
||||||
|
case DML_DELETE:
|
||||||
packagePtr = new DeleteDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(),
|
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());
|
(void)packagePtr->buildFromMysqlBuffer(vpackage.get_ColNames(), vpackage.get_values(), vpackage.get_Columns(), vpackage.get_Rows(), vpackage.get_nullValues());
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
|
default:
|
||||||
cerr << "makeCalpontDMLPackage: invalid statement type" << endl;
|
cerr << "makeCalpontDMLPackage: invalid statement type" << endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception& ex)
|
catch (std::exception& ex)
|
||||||
{
|
{
|
||||||
cerr << "makeCalpontDMLPackage:" << ex.what() << endl;
|
cerr << "makeCalpontDMLPackage:" << ex.what() << endl;
|
||||||
@@ -197,16 +212,17 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromMysql
|
|||||||
{
|
{
|
||||||
cerr << "makeCalpontDMLPackage: caught unknown exception!" << endl;
|
cerr << "makeCalpontDMLPackage: caught unknown exception!" << endl;
|
||||||
}
|
}
|
||||||
return packagePtr;
|
|
||||||
|
return packagePtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontUpdatePackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage, dmlpackage::UpdateSqlStatement& updateStmt)
|
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontUpdatePackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage, dmlpackage::UpdateSqlStatement& updateStmt)
|
||||||
{
|
{
|
||||||
CalpontDMLPackage* packagePtr = new UpdateDMLPackage((updateStmt.fNamePtr)->fSchema, (updateStmt.fNamePtr)->fName,
|
CalpontDMLPackage* packagePtr = new UpdateDMLPackage((updateStmt.fNamePtr)->fSchema, (updateStmt.fNamePtr)->fName,
|
||||||
vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
||||||
UpdateDMLPackage* updatePkgPtr = dynamic_cast<UpdateDMLPackage*>(packagePtr);
|
UpdateDMLPackage* updatePkgPtr = dynamic_cast<UpdateDMLPackage*>(packagePtr);
|
||||||
updatePkgPtr->buildUpdateFromMysqlBuffer(updateStmt);
|
updatePkgPtr->buildUpdateFromMysqlBuffer(updateStmt);
|
||||||
packagePtr = dynamic_cast<CalpontDMLPackage*>(updatePkgPtr);
|
packagePtr = dynamic_cast<CalpontDMLPackage*>(updatePkgPtr);
|
||||||
return packagePtr;
|
return packagePtr;
|
||||||
}
|
}
|
||||||
} //namespace dmlpackage
|
} //namespace dmlpackage
|
||||||
|
|||||||
@@ -58,14 +58,14 @@ public:
|
|||||||
* @param vpackage the VendorDMLStatement
|
* @param vpackage the VendorDMLStatement
|
||||||
*/
|
*/
|
||||||
EXPORT static dmlpackage::CalpontDMLPackage* makeCalpontDMLPackageFromBuffer(dmlpackage::VendorDMLStatement& vpackage);
|
EXPORT static dmlpackage::CalpontDMLPackage* makeCalpontDMLPackageFromBuffer(dmlpackage::VendorDMLStatement& vpackage);
|
||||||
|
|
||||||
EXPORT static dmlpackage::CalpontDMLPackage* makeCalpontDMLPackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage);
|
EXPORT static dmlpackage::CalpontDMLPackage* makeCalpontDMLPackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage);
|
||||||
static dmlpackage::CalpontDMLPackage* makeCalpontUpdatePackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage, dmlpackage::UpdateSqlStatement& updateStmt);
|
static dmlpackage::CalpontDMLPackage* makeCalpontUpdatePackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage, dmlpackage::UpdateSqlStatement& updateStmt);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static boost::mutex fParserLock;
|
static boost::mutex fParserLock;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,59 +26,62 @@ using namespace std;
|
|||||||
|
|
||||||
namespace dmlpackage
|
namespace dmlpackage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructors/Destructors
|
* Constructors/Destructors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CalpontDMLPackage::CalpontDMLPackage()
|
CalpontDMLPackage::CalpontDMLPackage()
|
||||||
:fPlan(new messageqcpp::ByteStream()), fTable(0), fHasFilter(0), fLogging(true), fIsInsertSelect(false), fIsBatchInsert(false), fIsAutocommitOn(false), fTableOid(0)
|
: 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);
|
||||||
|
|
||||||
}
|
if (pos == 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);
|
value = value.substr (pos + 1, 10000);
|
||||||
if (pos == 0)
|
|
||||||
{
|
|
||||||
value = value.substr (pos+1,10000);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // no more whitespace
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return value;
|
else
|
||||||
}
|
|
||||||
|
|
||||||
void CalpontDMLPackage::initializeTable()
|
|
||||||
{
|
|
||||||
if (0 == fTable)
|
|
||||||
{
|
{
|
||||||
fTable = new DMLTable();
|
// no more whitespace
|
||||||
fTable->set_SchemaName(fSchemaName);
|
break;
|
||||||
fTable->set_TableName(fTableName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CalpontDMLPackage::initializeTable()
|
||||||
|
{
|
||||||
|
if (0 == fTable)
|
||||||
|
{
|
||||||
|
fTable = new DMLTable();
|
||||||
|
fTable->set_SchemaName(fSchemaName);
|
||||||
|
fTable->set_TableName(fTableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace dmlpackage
|
} // namespace dmlpackage
|
||||||
|
|||||||
@@ -36,231 +36,335 @@
|
|||||||
|
|
||||||
namespace dmlpackage
|
namespace dmlpackage
|
||||||
{
|
{
|
||||||
/** @brief abstract class that defines the general interface and
|
/** @brief abstract class that defines the general interface and
|
||||||
* implemetation of a CalpontDMLPackage
|
* 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 set the DML statement (the parsed statement)
|
||||||
/** @brief ctor
|
*
|
||||||
*/
|
* @param statement the dml statement to set
|
||||||
CalpontDMLPackage();
|
*/
|
||||||
|
void set_DMLStatement( const std::string& statement )
|
||||||
|
{
|
||||||
|
fDMLStatement = statement;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief ctor
|
/** @brief get the DML statement (the parsed statement)
|
||||||
*
|
*/
|
||||||
* @param schemaName the schema of the table being operated on
|
const std::string get_DMLStatement() const
|
||||||
* @param tableName the name of the table being operated on
|
{
|
||||||
* @param dmlStatement the dml statement
|
return fDMLStatement;
|
||||||
* @param sessionID the session id
|
}
|
||||||
*/
|
|
||||||
CalpontDMLPackage( std::string schemaName, std::string tableName,
|
|
||||||
std::string dmlStatement, int sessionID );
|
|
||||||
|
|
||||||
/** @brief dtor
|
/** @brief set the SQL statement (the original SQL statement)
|
||||||
*/
|
*
|
||||||
virtual ~CalpontDMLPackage();
|
* @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
|
/** @brief get the SQL statement (the original SQL statement)
|
||||||
*
|
*/
|
||||||
* @param bytestream the ByteStream to write to
|
const std::string get_SQLStatement() const
|
||||||
*/
|
{
|
||||||
virtual int write( messageqcpp::ByteStream& bytestream ) = 0;
|
return fSQLStatement;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief read a CalpontDMLPackage from a ByteStream
|
/** @brief get the logging flag
|
||||||
*
|
*/
|
||||||
* @param bytestream the ByteStream to read from
|
const bool get_Logging() const
|
||||||
*/
|
{
|
||||||
virtual int read( messageqcpp::ByteStream& bytestream ) = 0;
|
return fLogging;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief build a CalpontDMLPackage from a string buffer
|
/** @brief set the logging flag
|
||||||
*
|
*
|
||||||
* @param buffer the row buffer
|
* @param logging the logging flag to set
|
||||||
* @param columns the number of columns in the buffer
|
*/
|
||||||
* @param rows the number of rows in the buffer
|
void set_Logging( bool logging )
|
||||||
*/
|
{
|
||||||
virtual int buildFromBuffer( std::string& buffer, int columns, int rows ) = 0;
|
fLogging = logging;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief build a CalpontDMLPackage from a parsed SqlStatement
|
/** @brief get the logending flag
|
||||||
*
|
*/
|
||||||
* @param sqlStatement the parsed SqlStatement
|
const bool get_Logending() const
|
||||||
*/
|
{
|
||||||
virtual int buildFromSqlStatement( SqlStatement& sqlStatement ) = 0;
|
return fLogending;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief build a CalpontDMLPackage from valuelist built from mysql table fields
|
/** @brief set the logending flag
|
||||||
*
|
*
|
||||||
* @param tableValuesMap the value list for each column in the table
|
* @param logending the logending flag to set
|
||||||
* @param colNameList the column name for each column
|
*/
|
||||||
* @param columns number of columns in the table
|
void set_Logending( bool logending )
|
||||||
* @param rows number of rows to be touched
|
{
|
||||||
*/
|
fLogending = logending;
|
||||||
virtual int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues) = 0;
|
}
|
||||||
|
|
||||||
/** @brief get the table object
|
/** @brief get the isFromCol flag
|
||||||
*/
|
*/
|
||||||
DMLTable* get_Table() { return fTable; }
|
const bool get_IsFromCol() const
|
||||||
|
{
|
||||||
|
return fIsFromCol;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief set the DML statement (the parsed statement)
|
/** @brief set the update column from column flag
|
||||||
*
|
*
|
||||||
* @param statement the dml statement to set
|
* @param logging the logging flag to set
|
||||||
*/
|
*/
|
||||||
void set_DMLStatement( const std::string& statement ) { fDMLStatement = statement; }
|
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)
|
if (fTable != 0)
|
||||||
*/
|
fTable->set_TableName(tableName);
|
||||||
const std::string get_DMLStatement() const { return fDMLStatement; }
|
}
|
||||||
|
|
||||||
/** @brief set the SQL statement (the original SQL statement)
|
/** @brief get the Table name
|
||||||
*
|
*/
|
||||||
* @param statement the SQL statement to set (the original SQL statement with quotes)
|
const std::string get_TableName() const
|
||||||
*/
|
{
|
||||||
void set_SQLStatement( const std::string& statement ) { fSQLStatement = statement; }
|
return fTableName;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief get the SQL statement (the original SQL statement)
|
/** @brief set the Schema name
|
||||||
*/
|
*
|
||||||
const std::string get_SQLStatement() const { return fSQLStatement; }
|
* @param the schema to set
|
||||||
|
*/
|
||||||
|
void set_SchemaName( std::string& schemaName )
|
||||||
|
{
|
||||||
|
fSchemaName = schemaName;
|
||||||
|
|
||||||
/** @brief get the logging flag
|
if (fTable != 0)
|
||||||
*/
|
fTable->set_SchemaName(schemaName);
|
||||||
const bool get_Logging() const { return fLogging; }
|
}
|
||||||
|
|
||||||
/** @brief set the logging flag
|
/** @brief get the Schema name
|
||||||
*
|
*/
|
||||||
* @param logging the logging flag to set
|
const std::string get_SchemaName() const
|
||||||
*/
|
{
|
||||||
void set_Logging( bool logging ) { fLogging = logging; }
|
return fSchemaName;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief get the logending flag
|
/** @brief does this dml statement have a filter
|
||||||
*/
|
*/
|
||||||
const bool get_Logending() const { return fLogending; }
|
bool HasFilter() const
|
||||||
|
{
|
||||||
|
return fHasFilter;
|
||||||
|
}
|
||||||
|
void HasFilter( bool hasFilter)
|
||||||
|
{
|
||||||
|
fHasFilter = hasFilter;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief set the logending flag
|
/** @brief get the filter statement
|
||||||
*
|
*/
|
||||||
* @param logending the logending flag to set
|
const std::string get_QueryString() const
|
||||||
*/
|
{
|
||||||
void set_Logending( bool logending ) { fLogending = logending; }
|
return fQueryString;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief get the isFromCol flag
|
/** @brief set the sessionID associated with this package
|
||||||
*/
|
*/
|
||||||
const bool get_IsFromCol() const { return fIsFromCol; }
|
void set_SessionID( int sessionID )
|
||||||
|
{
|
||||||
|
fSessionID = sessionID;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief set the update column from column flag
|
/** @brief get the sessionID associated with this package
|
||||||
*
|
*/
|
||||||
* @param logging the logging flag to set
|
int get_SessionID() const
|
||||||
*/
|
{
|
||||||
void set_IsFromCol ( bool isFromCol ) { fIsFromCol = isFromCol; }
|
return fSessionID;
|
||||||
/** @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 Table name
|
/** @brief set the transaction ID associated with this package
|
||||||
*/
|
*/
|
||||||
const std::string get_TableName() const { return fTableName; }
|
void set_TxnID( execplan::CalpontSystemCatalog::SCN txnID )
|
||||||
|
{
|
||||||
|
fTxnId = txnID;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief set the Schema name
|
/** @brief get the transaction ID associated with this package
|
||||||
*
|
*/
|
||||||
* @param the schema to set
|
execplan::CalpontSystemCatalog::SCN get_TxnID() const
|
||||||
*/
|
{
|
||||||
void set_SchemaName( std::string& schemaName )
|
return fTxnId;
|
||||||
{
|
}
|
||||||
fSchemaName = schemaName;
|
/** @brief set the chunkmanager associated with this package
|
||||||
if(fTable != 0)
|
*/
|
||||||
fTable->set_SchemaName(schemaName);
|
void set_ChunkManager( WriteEngine::ChunkManager* cm )
|
||||||
}
|
{
|
||||||
|
fCM = cm;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief get the Schema name
|
/** @brief get the chunkmanager associated with this package
|
||||||
*/
|
*/
|
||||||
const std::string get_SchemaName() const { return fSchemaName; }
|
WriteEngine::ChunkManager* get_ChunkManager() const
|
||||||
|
{
|
||||||
|
return fCM;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief does this dml statement have a filter
|
/** @brief get the ExecutionPlan associated with this package
|
||||||
*/
|
*/
|
||||||
bool HasFilter() const { return fHasFilter; }
|
boost::shared_ptr<messageqcpp::ByteStream> get_ExecutionPlan()
|
||||||
void HasFilter( bool hasFilter) { fHasFilter = hasFilter; }
|
{
|
||||||
|
return fPlan;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief get the filter statement
|
bool get_isInsertSelect()
|
||||||
*/
|
{
|
||||||
const std::string get_QueryString() const { return fQueryString; }
|
return fIsInsertSelect;
|
||||||
|
}
|
||||||
|
void set_isInsertSelect( const bool isInsertSelect )
|
||||||
|
{
|
||||||
|
fIsInsertSelect = isInsertSelect;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief set the sessionID associated with this package
|
bool get_isBatchInsert()
|
||||||
*/
|
{
|
||||||
void set_SessionID( int sessionID ) { fSessionID = sessionID; }
|
return fIsBatchInsert;
|
||||||
|
}
|
||||||
|
void set_isBatchInsert( const bool isBatchInsert )
|
||||||
|
{
|
||||||
|
fIsBatchInsert = isBatchInsert;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief get the sessionID associated with this package
|
bool get_isAutocommitOn()
|
||||||
*/
|
{
|
||||||
int get_SessionID() const { return fSessionID; }
|
return fIsAutocommitOn;
|
||||||
|
}
|
||||||
|
void set_isAutocommitOn( const bool isAutocommitOn )
|
||||||
|
{
|
||||||
|
fIsAutocommitOn = isAutocommitOn;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief set the transaction ID associated with this package
|
bool get_isWarnToError()
|
||||||
*/
|
{
|
||||||
void set_TxnID( execplan::CalpontSystemCatalog::SCN txnID ) { fTxnId = txnID; }
|
return fIsWarnToError;
|
||||||
|
}
|
||||||
|
void set_isWarnToError( const bool isWarnToError )
|
||||||
|
{
|
||||||
|
fIsWarnToError = isWarnToError;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief get the transaction ID associated with this package
|
uint32_t getTableOid()
|
||||||
*/
|
{
|
||||||
execplan::CalpontSystemCatalog::SCN get_TxnID() const { return fTxnId; }
|
return fTableOid;
|
||||||
/** @brief set the chunkmanager associated with this package
|
}
|
||||||
*/
|
void setTableOid( const uint32_t tableOid )
|
||||||
void set_ChunkManager( WriteEngine::ChunkManager* cm ) { fCM = cm; }
|
{
|
||||||
|
fTableOid = tableOid;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief get the chunkmanager associated with this package
|
void uuid(const boost::uuids::uuid& uuid)
|
||||||
*/
|
{
|
||||||
WriteEngine::ChunkManager* get_ChunkManager() const { return fCM; }
|
fUuid = uuid;
|
||||||
|
}
|
||||||
|
const boost::uuids::uuid& uuid() const
|
||||||
|
{
|
||||||
|
return fUuid;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief get the ExecutionPlan associated with this package
|
protected:
|
||||||
*/
|
|
||||||
boost::shared_ptr<messageqcpp::ByteStream> get_ExecutionPlan()
|
|
||||||
{
|
|
||||||
return fPlan;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_isInsertSelect() { return fIsInsertSelect; }
|
void initializeTable();
|
||||||
void set_isInsertSelect( const bool isInsertSelect ) { fIsInsertSelect = isInsertSelect; }
|
|
||||||
|
|
||||||
bool get_isBatchInsert() { return fIsBatchInsert; }
|
std::string fSchemaName;
|
||||||
void set_isBatchInsert( const bool isBatchInsert ) { fIsBatchInsert = isBatchInsert; }
|
std::string fTableName;
|
||||||
|
std::string fDMLStatement;
|
||||||
bool get_isAutocommitOn() { return fIsAutocommitOn; }
|
std::string fSQLStatement;
|
||||||
void set_isAutocommitOn( const bool isAutocommitOn ) { fIsAutocommitOn = isAutocommitOn; }
|
std::string fQueryString;
|
||||||
|
int fSessionID;
|
||||||
bool get_isWarnToError() { return fIsWarnToError; }
|
boost::uuids::uuid fUuid;
|
||||||
void set_isWarnToError( const bool isWarnToError ) { fIsWarnToError = isWarnToError; }
|
execplan::CalpontSystemCatalog::SCN fTxnId;
|
||||||
|
boost::shared_ptr<messageqcpp::ByteStream> fPlan;
|
||||||
uint32_t getTableOid() { return fTableOid; }
|
DMLTable* fTable;
|
||||||
void setTableOid( const uint32_t tableOid ) { fTableOid = tableOid; }
|
bool fHasFilter;
|
||||||
|
bool fLogging;
|
||||||
void uuid(const boost::uuids::uuid& uuid) { fUuid = uuid; }
|
bool fLogending;
|
||||||
const boost::uuids::uuid& uuid() const { return fUuid; }
|
bool fIsFromCol;
|
||||||
|
std::string StripLeadingWhitespace( std::string value );
|
||||||
protected:
|
bool fIsInsertSelect;
|
||||||
|
bool fIsBatchInsert;
|
||||||
void initializeTable();
|
bool fIsAutocommitOn;
|
||||||
|
bool fIsWarnToError;
|
||||||
std::string fSchemaName;
|
uint32_t fTableOid;
|
||||||
std::string fTableName;
|
WriteEngine::ChunkManager* fCM;
|
||||||
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
|
#endif //CALPONTDMLPACKAGE_H
|
||||||
|
|||||||
@@ -32,67 +32,67 @@ using namespace std;
|
|||||||
namespace dmlpackage
|
namespace dmlpackage
|
||||||
{
|
{
|
||||||
|
|
||||||
CommandDMLPackage::CommandDMLPackage()
|
CommandDMLPackage::CommandDMLPackage()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CommandDMLPackage::CommandDMLPackage( std::string dmlStatement, int sessionID)
|
CommandDMLPackage::CommandDMLPackage( std::string dmlStatement, int sessionID)
|
||||||
:CalpontDMLPackage( "", "", dmlStatement, sessionID)
|
: CalpontDMLPackage( "", "", dmlStatement, sessionID)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CommandDMLPackage::~CommandDMLPackage()
|
CommandDMLPackage::~CommandDMLPackage()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
int CommandDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
int CommandDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||||
{
|
{
|
||||||
int retval = 1;
|
int retval = 1;
|
||||||
|
|
||||||
messageqcpp::ByteStream::byte package_type = DML_COMMAND;
|
messageqcpp::ByteStream::byte package_type = DML_COMMAND;
|
||||||
bytestream << package_type;
|
bytestream << package_type;
|
||||||
|
|
||||||
messageqcpp::ByteStream::quadbyte session_id = fSessionID;
|
messageqcpp::ByteStream::quadbyte session_id = fSessionID;
|
||||||
bytestream << session_id;
|
bytestream << session_id;
|
||||||
|
|
||||||
bytestream << fUuid;
|
bytestream << fUuid;
|
||||||
|
|
||||||
bytestream << fDMLStatement;
|
bytestream << fDMLStatement;
|
||||||
bytestream << fSQLStatement; // for cleartablelock, this is table lockID
|
bytestream << fSQLStatement; // for cleartablelock, this is table lockID
|
||||||
bytestream << (uint8_t)fLogging;
|
bytestream << (uint8_t)fLogging;
|
||||||
bytestream << fSchemaName;
|
bytestream << fSchemaName;
|
||||||
bytestream << fTableName;
|
bytestream << fTableName;
|
||||||
bytestream << fTableOid;
|
bytestream << fTableOid;
|
||||||
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsAutocommitOn);
|
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsAutocommitOn);
|
||||||
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsBatchInsert);
|
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsBatchInsert);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CommandDMLPackage::read(messageqcpp::ByteStream& bytestream)
|
int CommandDMLPackage::read(messageqcpp::ByteStream& bytestream)
|
||||||
{
|
{
|
||||||
int retval = 1;
|
int retval = 1;
|
||||||
|
|
||||||
messageqcpp::ByteStream::quadbyte session_id;
|
messageqcpp::ByteStream::quadbyte session_id;
|
||||||
bytestream >> session_id;
|
bytestream >> session_id;
|
||||||
fSessionID = session_id;
|
fSessionID = session_id;
|
||||||
bytestream >> fUuid;
|
bytestream >> fUuid;
|
||||||
|
|
||||||
bytestream >> fDMLStatement;
|
bytestream >> fDMLStatement;
|
||||||
bytestream >> fSQLStatement; // for cleartablelock, this is table lockID
|
bytestream >> fSQLStatement; // for cleartablelock, this is table lockID
|
||||||
uint8_t logging;
|
uint8_t logging;
|
||||||
bytestream >> logging;
|
bytestream >> logging;
|
||||||
fLogging = (logging != 0);
|
fLogging = (logging != 0);
|
||||||
bytestream >> fSchemaName;
|
bytestream >> fSchemaName;
|
||||||
bytestream >> fTableName;
|
bytestream >> fTableName;
|
||||||
bytestream >> fTableOid;
|
bytestream >> fTableOid;
|
||||||
bytestream >> reinterpret_cast< messageqcpp::ByteStream::byte&>(fIsAutocommitOn);
|
bytestream >> reinterpret_cast< messageqcpp::ByteStream::byte&>(fIsAutocommitOn);
|
||||||
bytestream >> reinterpret_cast< messageqcpp::ByteStream::byte&>(fIsBatchInsert);
|
bytestream >> reinterpret_cast< messageqcpp::ByteStream::byte&>(fIsBatchInsert);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CommandDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
int CommandDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||||
{
|
{
|
||||||
CommandSqlStatement& cmdStmt = dynamic_cast<CommandSqlStatement&>(sqlStatement);
|
CommandSqlStatement& cmdStmt = dynamic_cast<CommandSqlStatement&>(sqlStatement);
|
||||||
fDMLStatement = cmdStmt.fCommandText;
|
fDMLStatement = cmdStmt.fCommandText;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dmlpackage
|
} // namespace dmlpackage
|
||||||
|
|||||||
@@ -36,67 +36,67 @@
|
|||||||
|
|
||||||
namespace dmlpackage
|
namespace dmlpackage
|
||||||
{
|
{
|
||||||
/** @brief concrete implementation of a CalpontDMLPackage
|
/** @brief concrete implementation of a CalpontDMLPackage
|
||||||
* Specifically for representing COMMAND DML Statements
|
* 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)
|
||||||
{
|
{
|
||||||
|
return 1;
|
||||||
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:
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @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
|
#undef EXPORT
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ DeleteDMLPackage::DeleteDMLPackage()
|
|||||||
|
|
||||||
DeleteDMLPackage::DeleteDMLPackage(std::string schemaName, std::string tableName,
|
DeleteDMLPackage::DeleteDMLPackage(std::string schemaName, std::string tableName,
|
||||||
std::string dmlStatement, int sessionID)
|
std::string dmlStatement, int sessionID)
|
||||||
:CalpontDMLPackage( schemaName, tableName, dmlStatement, sessionID )
|
: CalpontDMLPackage( schemaName, tableName, dmlStatement, sessionID )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
DeleteDMLPackage::~DeleteDMLPackage()
|
DeleteDMLPackage::~DeleteDMLPackage()
|
||||||
@@ -54,11 +54,11 @@ int DeleteDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
|||||||
messageqcpp::ByteStream::quadbyte session_id = fSessionID;
|
messageqcpp::ByteStream::quadbyte session_id = fSessionID;
|
||||||
bytestream << session_id;
|
bytestream << session_id;
|
||||||
|
|
||||||
/* if(fPlan != 0)
|
/* if(fPlan != 0)
|
||||||
fHasFilter = true;
|
fHasFilter = true;
|
||||||
else
|
else
|
||||||
fHasFilter = false;
|
fHasFilter = false;
|
||||||
*/
|
*/
|
||||||
messageqcpp::ByteStream::quadbyte hasFilter = fHasFilter;
|
messageqcpp::ByteStream::quadbyte hasFilter = fHasFilter;
|
||||||
bytestream << hasFilter;
|
bytestream << hasFilter;
|
||||||
|
|
||||||
@@ -67,11 +67,13 @@ int DeleteDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
|||||||
bytestream << fDMLStatement;
|
bytestream << fDMLStatement;
|
||||||
bytestream << fSQLStatement;
|
bytestream << fSQLStatement;
|
||||||
bytestream << fSchemaName;
|
bytestream << fSchemaName;
|
||||||
|
|
||||||
if (fTable != 0)
|
if (fTable != 0)
|
||||||
{
|
{
|
||||||
retval = fTable->write(bytestream);
|
retval = fTable->write(bytestream);
|
||||||
}
|
}
|
||||||
if(fHasFilter)
|
|
||||||
|
if (fHasFilter)
|
||||||
{
|
{
|
||||||
bytestream += *(fPlan.get());
|
bytestream += *(fPlan.get());
|
||||||
}
|
}
|
||||||
@@ -103,9 +105,10 @@ int DeleteDMLPackage::read(messageqcpp::ByteStream& bytestream)
|
|||||||
|
|
||||||
fTable = new DMLTable();
|
fTable = new DMLTable();
|
||||||
retval = fTable->read(bytestream);
|
retval = fTable->read(bytestream);
|
||||||
if(fHasFilter)
|
|
||||||
|
if (fHasFilter)
|
||||||
{
|
{
|
||||||
fPlan.reset(new messageqcpp::ByteStream(bytestream));
|
fPlan.reset(new messageqcpp::ByteStream(bytestream));
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
@@ -124,6 +127,7 @@ int DeleteDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
|||||||
fHasFilter = true;
|
fHasFilter = true;
|
||||||
fQueryString = deleteStmt.getQueryString();
|
fQueryString = deleteStmt.getQueryString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// else all rows are deleted
|
// else all rows are deleted
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
@@ -146,6 +150,7 @@ int DeleteDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
|||||||
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||||
boost::char_separator<char> sep(":");
|
boost::char_separator<char> sep(":");
|
||||||
tokenizer tokens(buffer, sep);
|
tokenizer tokens(buffer, sep);
|
||||||
|
|
||||||
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
||||||
{
|
{
|
||||||
dataList.push_back(StripLeadingWhitespace(*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;
|
int n = 0;
|
||||||
for (int i=0; i < rows; i++)
|
|
||||||
|
for (int i = 0; i < rows; i++)
|
||||||
{
|
{
|
||||||
//get a new row
|
//get a new row
|
||||||
Row aRow;
|
Row aRow;
|
||||||
@@ -195,21 +201,21 @@ int DeleteDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValues
|
|||||||
|
|
||||||
initializeTable();
|
initializeTable();
|
||||||
//The row already built from MySql parser.
|
//The row already built from MySql parser.
|
||||||
/* Row *aRowPtr = new Row();
|
/* Row *aRowPtr = new Row();
|
||||||
std::string colName;
|
std::string colName;
|
||||||
std::vector<std::string> colValList;
|
std::vector<std::string> colValList;
|
||||||
for (int j = 0; j < columns; j++)
|
for (int j = 0; j < columns; j++)
|
||||||
{
|
{
|
||||||
//Build a column list
|
//Build a column list
|
||||||
colName = colNameList[j];
|
colName = colNameList[j];
|
||||||
|
|
||||||
colValList = tableValuesMap[j];
|
colValList = tableValuesMap[j];
|
||||||
|
|
||||||
DMLColumn* aColumn = new DMLColumn(colName, colValList, false);
|
DMLColumn* aColumn = new DMLColumn(colName, colValList, false);
|
||||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||||
}
|
}
|
||||||
//build a row list for a table
|
//build a row list for a table
|
||||||
fTable->get_RowList().push_back(aRowPtr); */
|
fTable->get_RowList().push_back(aRowPtr); */
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,69 +36,69 @@
|
|||||||
|
|
||||||
namespace dmlpackage
|
namespace dmlpackage
|
||||||
{
|
{
|
||||||
/** @brief concrete implementation of a CalpontDMLPackage
|
/** @brief concrete implementation of a CalpontDMLPackage
|
||||||
* Specifically for representing DELETE DML Statements
|
* 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
|
/** @brief dtor
|
||||||
*/
|
*/
|
||||||
EXPORT DeleteDMLPackage();
|
EXPORT virtual ~DeleteDMLPackage();
|
||||||
|
|
||||||
/** @brief ctor
|
/** @brief write a DeleteDMLPackage to a ByteStream
|
||||||
*
|
*
|
||||||
* @param schemaName the schema of the table being operated on
|
* @param bytestream the ByteStream to write to
|
||||||
* @param tableName the name of the table being operated on
|
*/
|
||||||
* @param dmlStatement the dml statement
|
EXPORT int write(messageqcpp::ByteStream& bytestream);
|
||||||
* @param sessionID the session ID
|
|
||||||
*/
|
|
||||||
EXPORT DeleteDMLPackage( std::string schemaName, std::string tableName,
|
|
||||||
std::string dmlStatement, int sessionID );
|
|
||||||
|
|
||||||
/** @brief dtor
|
/** @brief read a DeleteDMLPackage from a ByteStream
|
||||||
*/
|
*
|
||||||
EXPORT virtual ~DeleteDMLPackage();
|
* @param bytestream the ByteStream to read from
|
||||||
|
*/
|
||||||
|
EXPORT int read(messageqcpp::ByteStream& bytestream);
|
||||||
|
|
||||||
/** @brief write a DeleteDMLPackage to a ByteStream
|
/** @brief build a DeleteDMLPackage from a string buffer
|
||||||
*
|
*
|
||||||
* @param bytestream the ByteStream to write to
|
* @param buffer [rowId, columnName, colValue]
|
||||||
*/
|
* @param columns the number of columns in the buffer
|
||||||
EXPORT int write(messageqcpp::ByteStream& bytestream);
|
* @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
|
/** @brief build a DeleteDMLPackage from a parsed DeleteSqlStatement
|
||||||
*
|
*
|
||||||
* @param bytestream the ByteStream to read from
|
* @param sqlStatement the parsed DeleteSqlStatement
|
||||||
*/
|
*/
|
||||||
EXPORT int read(messageqcpp::ByteStream& bytestream);
|
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
|
protected:
|
||||||
*
|
|
||||||
* @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 build a DeleteDMLPackage from a parsed DeleteSqlStatement
|
private:
|
||||||
*
|
|
||||||
* @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);
|
|
||||||
|
|
||||||
protected:
|
};
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef EXPORT
|
#undef EXPORT
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,182 +1,183 @@
|
|||||||
|
|
||||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||||
|
|
||||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||||
|
|
||||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
/* As a special exception, you may create a larger work that contains
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
part or all of the Bison parser skeleton and distribute that work
|
||||||
under terms of your choice, so long as that work isn't itself a
|
under terms of your choice, so long as that work isn't itself a
|
||||||
parser generator using the skeleton or a modified version thereof
|
parser generator using the skeleton or a modified version thereof
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
the parser skeleton itself, you may (at your option) remove this
|
||||||
special exception, which will cause the skeleton and the resulting
|
special exception, which will cause the skeleton and the resulting
|
||||||
Bison output files to be licensed under the GNU General Public
|
Bison output files to be licensed under the GNU General Public
|
||||||
License without this special exception.
|
License without this special exception.
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
This special exception was added by the Free Software Foundation in
|
||||||
version 2.2 of Bison. */
|
version 2.2 of Bison. */
|
||||||
|
|
||||||
|
|
||||||
/* Tokens. */
|
/* Tokens. */
|
||||||
#ifndef YYTOKENTYPE
|
#ifndef YYTOKENTYPE
|
||||||
# define YYTOKENTYPE
|
# define YYTOKENTYPE
|
||||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||||
know about them. */
|
know about them. */
|
||||||
enum yytokentype {
|
enum yytokentype
|
||||||
NAME = 258,
|
{
|
||||||
STRING = 259,
|
NAME = 258,
|
||||||
INTNUM = 260,
|
STRING = 259,
|
||||||
APPROXNUM = 261,
|
INTNUM = 260,
|
||||||
SELECT = 262,
|
APPROXNUM = 261,
|
||||||
ALL = 263,
|
SELECT = 262,
|
||||||
DISTINCT = 264,
|
ALL = 263,
|
||||||
NULLX = 265,
|
DISTINCT = 264,
|
||||||
USER = 266,
|
NULLX = 265,
|
||||||
INDICATOR = 267,
|
USER = 266,
|
||||||
AMMSC = 268,
|
INDICATOR = 267,
|
||||||
PARAMETER = 269,
|
AMMSC = 268,
|
||||||
ANY = 270,
|
PARAMETER = 269,
|
||||||
SOME = 271,
|
ANY = 270,
|
||||||
OR = 272,
|
SOME = 271,
|
||||||
AND = 273,
|
OR = 272,
|
||||||
NOT = 274,
|
AND = 273,
|
||||||
COMPARISON = 275,
|
NOT = 274,
|
||||||
UMINUS = 276,
|
COMPARISON = 275,
|
||||||
AS = 277,
|
UMINUS = 276,
|
||||||
ASC = 278,
|
AS = 277,
|
||||||
AUTHORIZATION = 279,
|
ASC = 278,
|
||||||
BETWEEN = 280,
|
AUTHORIZATION = 279,
|
||||||
BY = 281,
|
BETWEEN = 280,
|
||||||
CHARACTER = 282,
|
BY = 281,
|
||||||
CHECK = 283,
|
CHARACTER = 282,
|
||||||
CLOSE = 284,
|
CHECK = 283,
|
||||||
COMMIT = 285,
|
CLOSE = 284,
|
||||||
CONTINUE = 286,
|
COMMIT = 285,
|
||||||
CREATE = 287,
|
CONTINUE = 286,
|
||||||
CURRENT = 288,
|
CREATE = 287,
|
||||||
CURSOR = 289,
|
CURRENT = 288,
|
||||||
IDB_DECIMAL = 290,
|
CURSOR = 289,
|
||||||
DECLARE = 291,
|
IDB_DECIMAL = 290,
|
||||||
DEFAULT = 292,
|
DECLARE = 291,
|
||||||
DELETE = 293,
|
DEFAULT = 292,
|
||||||
DESC = 294,
|
DELETE = 293,
|
||||||
IDB_DOUBLE = 295,
|
DESC = 294,
|
||||||
ESCAPE = 296,
|
IDB_DOUBLE = 295,
|
||||||
EXISTS = 297,
|
ESCAPE = 296,
|
||||||
FETCH = 298,
|
EXISTS = 297,
|
||||||
IDB_FLOAT = 299,
|
FETCH = 298,
|
||||||
FOR = 300,
|
IDB_FLOAT = 299,
|
||||||
FOREIGN = 301,
|
FOR = 300,
|
||||||
FOUND = 302,
|
FOREIGN = 301,
|
||||||
FROM = 303,
|
FOUND = 302,
|
||||||
GOTO = 304,
|
FROM = 303,
|
||||||
GRANT = 305,
|
GOTO = 304,
|
||||||
IDB_GROUP = 306,
|
GRANT = 305,
|
||||||
HAVING = 307,
|
IDB_GROUP = 306,
|
||||||
IN = 308,
|
HAVING = 307,
|
||||||
INSERT = 309,
|
IN = 308,
|
||||||
INTEGER = 310,
|
INSERT = 309,
|
||||||
INTO = 311,
|
INTEGER = 310,
|
||||||
IS = 312,
|
INTO = 311,
|
||||||
KEY = 313,
|
IS = 312,
|
||||||
LANGUAGE = 314,
|
KEY = 313,
|
||||||
LIKE = 315,
|
LANGUAGE = 314,
|
||||||
NUMERIC = 316,
|
LIKE = 315,
|
||||||
OF = 317,
|
NUMERIC = 316,
|
||||||
ON = 318,
|
OF = 317,
|
||||||
OPEN = 319,
|
ON = 318,
|
||||||
OPTION = 320,
|
OPEN = 319,
|
||||||
ORDER = 321,
|
OPTION = 320,
|
||||||
PRECISION = 322,
|
ORDER = 321,
|
||||||
PRIMARY = 323,
|
PRECISION = 322,
|
||||||
PRIVILEGES = 324,
|
PRIMARY = 323,
|
||||||
PROCEDURE = 325,
|
PRIVILEGES = 324,
|
||||||
PUBLIC = 326,
|
PROCEDURE = 325,
|
||||||
REAL = 327,
|
PUBLIC = 326,
|
||||||
REFERENCES = 328,
|
REAL = 327,
|
||||||
ROLLBACK = 329,
|
REFERENCES = 328,
|
||||||
SCHEMA = 330,
|
ROLLBACK = 329,
|
||||||
SET = 331,
|
SCHEMA = 330,
|
||||||
SMALLINT = 332,
|
SET = 331,
|
||||||
SQLCODE = 333,
|
SMALLINT = 332,
|
||||||
SQLERROR = 334,
|
SQLCODE = 333,
|
||||||
TABLE = 335,
|
SQLERROR = 334,
|
||||||
TO = 336,
|
TABLE = 335,
|
||||||
UNION = 337,
|
TO = 336,
|
||||||
UNIQUE = 338,
|
UNION = 337,
|
||||||
UPDATE = 339,
|
UNIQUE = 338,
|
||||||
VALUES = 340,
|
UPDATE = 339,
|
||||||
VIEW = 341,
|
VALUES = 340,
|
||||||
WHENEVER = 342,
|
VIEW = 341,
|
||||||
WHERE = 343,
|
WHENEVER = 342,
|
||||||
WITH = 344,
|
WHERE = 343,
|
||||||
WORK = 345
|
WITH = 344,
|
||||||
};
|
WORK = 345
|
||||||
#endif
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
|
||||||
typedef union YYSTYPE
|
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||||
{
|
typedef union YYSTYPE
|
||||||
|
{
|
||||||
|
|
||||||
int intval;
|
|
||||||
double floatval;
|
int intval;
|
||||||
char *strval;
|
double floatval;
|
||||||
int subtok;
|
char* strval;
|
||||||
dmlpackage::SqlStatementList *sqlStmtList;
|
int subtok;
|
||||||
dmlpackage::SqlStatement *sqlStmt;
|
dmlpackage::SqlStatementList* sqlStmtList;
|
||||||
dmlpackage::TableName* tblName;
|
dmlpackage::SqlStatement* sqlStmt;
|
||||||
dmlpackage::ColumnNameList* colNameList;
|
dmlpackage::TableName* tblName;
|
||||||
dmlpackage::ValuesOrQuery* valsOrQuery;
|
dmlpackage::ColumnNameList* colNameList;
|
||||||
dmlpackage::ValuesList* valsList;
|
dmlpackage::ValuesOrQuery* valsOrQuery;
|
||||||
dmlpackage::QuerySpec* querySpec;
|
dmlpackage::ValuesList* valsList;
|
||||||
dmlpackage::TableNameList* tableNameList;
|
dmlpackage::QuerySpec* querySpec;
|
||||||
dmlpackage::TableExpression* tableExpression;
|
dmlpackage::TableNameList* tableNameList;
|
||||||
dmlpackage::WhereClause* whereClause;
|
dmlpackage::TableExpression* tableExpression;
|
||||||
dmlpackage::SearchCondition* searchCondition;
|
dmlpackage::WhereClause* whereClause;
|
||||||
dmlpackage::ExistanceTestPredicate* existPredicate;
|
dmlpackage::SearchCondition* searchCondition;
|
||||||
dmlpackage::AllOrAnyPredicate* allOrAnyPredicate;
|
dmlpackage::ExistanceTestPredicate* existPredicate;
|
||||||
dmlpackage::InPredicate* inPredicate;
|
dmlpackage::AllOrAnyPredicate* allOrAnyPredicate;
|
||||||
dmlpackage::NullTestPredicate* nullTestPredicate;
|
dmlpackage::InPredicate* inPredicate;
|
||||||
dmlpackage::LikePredicate* likePredicate;
|
dmlpackage::NullTestPredicate* nullTestPredicate;
|
||||||
dmlpackage::BetweenPredicate* betweenPredicate;
|
dmlpackage::LikePredicate* likePredicate;
|
||||||
dmlpackage::ComparisonPredicate* comparisonPredicate;
|
dmlpackage::BetweenPredicate* betweenPredicate;
|
||||||
dmlpackage::Predicate* predicate;
|
dmlpackage::ComparisonPredicate* comparisonPredicate;
|
||||||
dmlpackage::FromClause* fromClause;
|
dmlpackage::Predicate* predicate;
|
||||||
dmlpackage::SelectFilter* selectFilter;
|
dmlpackage::FromClause* fromClause;
|
||||||
dmlpackage::GroupByClause* groupByClause;
|
dmlpackage::SelectFilter* selectFilter;
|
||||||
dmlpackage::HavingClause* havingClause;
|
dmlpackage::GroupByClause* groupByClause;
|
||||||
dmlpackage::Escape* escape;
|
dmlpackage::HavingClause* havingClause;
|
||||||
dmlpackage::AtomList* atomList;
|
dmlpackage::Escape* escape;
|
||||||
dmlpackage::ColumnAssignment* colAssignment;
|
dmlpackage::AtomList* atomList;
|
||||||
dmlpackage::ColumnAssignmentList* colAssignmentList;
|
dmlpackage::ColumnAssignment* colAssignment;
|
||||||
|
dmlpackage::ColumnAssignmentList* colAssignmentList;
|
||||||
|
|
||||||
|
|
||||||
} YYSTYPE;
|
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
} YYSTYPE;
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||||
#endif
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
|
#endif
|
||||||
extern YYSTYPE dmllval;
|
|
||||||
|
extern YYSTYPE dmllval;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -40,14 +40,16 @@ DMLColumn::DMLColumn(std::string name, std::string value, bool isFromCol, uint32
|
|||||||
{
|
{
|
||||||
fName = name;
|
fName = name;
|
||||||
fData = value;
|
fData = value;
|
||||||
|
|
||||||
if (( strcasecmp(value.c_str(), "NULL") == 0) || (value.length() == 0) )
|
if (( strcasecmp(value.c_str(), "NULL") == 0) || (value.length() == 0) )
|
||||||
{
|
{
|
||||||
isNULL = true;
|
isNULL = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fisNULL = isNULL;
|
fisNULL = isNULL;
|
||||||
fIsFromCol = isFromCol;
|
fIsFromCol = isFromCol;
|
||||||
fFuncScale = funcScale;
|
fFuncScale = funcScale;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DMLColumn::DMLColumn(std::string name, std::vector<std::string>& valueList, bool isFromCol, uint32_t funcScale, bool isNULL)
|
DMLColumn::DMLColumn(std::string name, std::vector<std::string>& valueList, bool isFromCol, uint32_t funcScale, bool isNULL)
|
||||||
@@ -55,8 +57,8 @@ DMLColumn::DMLColumn(std::string name, std::vector<std::string>& valueList, bool
|
|||||||
fName = name;
|
fName = name;
|
||||||
fColValuesList = valueList;
|
fColValuesList = valueList;
|
||||||
fisNULL = isNULL;
|
fisNULL = isNULL;
|
||||||
fIsFromCol = isFromCol;
|
fIsFromCol = isFromCol;
|
||||||
fFuncScale = funcScale;
|
fFuncScale = funcScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
DMLColumn::~DMLColumn()
|
DMLColumn::~DMLColumn()
|
||||||
@@ -66,30 +68,32 @@ int DMLColumn::read(messageqcpp::ByteStream& bytestream)
|
|||||||
{
|
{
|
||||||
int retval = 1;
|
int retval = 1;
|
||||||
bytestream >> fName;
|
bytestream >> fName;
|
||||||
bytestream >> reinterpret_cast<messageqcpp::ByteStream::byte&>(fisNULL);
|
bytestream >> reinterpret_cast<messageqcpp::ByteStream::byte&>(fisNULL);
|
||||||
uint32_t vectorSize;
|
uint32_t vectorSize;
|
||||||
bytestream >> vectorSize;
|
bytestream >> vectorSize;
|
||||||
if (vectorSize > 0 )
|
|
||||||
{
|
if (vectorSize > 0 )
|
||||||
for ( uint32_t i = 0; i < vectorSize; i++ )
|
{
|
||||||
{
|
for ( uint32_t i = 0; i < vectorSize; i++ )
|
||||||
std::string dataStr;
|
{
|
||||||
bytestream >> dataStr;
|
std::string dataStr;
|
||||||
// if ( !fisNULL && (dataStr.length() == 0 ))
|
bytestream >> dataStr;
|
||||||
// dataStr = (char) 0;
|
// if ( !fisNULL && (dataStr.length() == 0 ))
|
||||||
|
// dataStr = (char) 0;
|
||||||
fColValuesList.push_back( dataStr);
|
|
||||||
}
|
fColValuesList.push_back( dataStr);
|
||||||
|
}
|
||||||
}
|
|
||||||
else
|
}
|
||||||
bytestream >> fData; //deprecated.
|
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&>(fisNULL);
|
||||||
bytestream >> reinterpret_cast<messageqcpp::ByteStream::byte&>(fIsFromCol);
|
bytestream >> reinterpret_cast<messageqcpp::ByteStream::byte&>(fIsFromCol);
|
||||||
bytestream >> (uint32_t&) fFuncScale;
|
bytestream >> (uint32_t&) fFuncScale;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,22 +101,24 @@ int DMLColumn::write(messageqcpp::ByteStream& bytestream)
|
|||||||
{
|
{
|
||||||
int retval = 1;
|
int retval = 1;
|
||||||
bytestream << fName;
|
bytestream << fName;
|
||||||
bytestream << static_cast<uint8_t>(fisNULL);
|
bytestream << static_cast<uint8_t>(fisNULL);
|
||||||
uint32_t vectorSize = fColValuesList.size();
|
uint32_t vectorSize = fColValuesList.size();
|
||||||
bytestream << vectorSize;
|
bytestream << vectorSize;
|
||||||
if (vectorSize > 0 )
|
|
||||||
{
|
if (vectorSize > 0 )
|
||||||
for ( uint32_t i = 0; i < vectorSize; i++ )
|
{
|
||||||
{
|
for ( uint32_t i = 0; i < vectorSize; i++ )
|
||||||
bytestream << fColValuesList[i];
|
{
|
||||||
}
|
bytestream << fColValuesList[i];
|
||||||
|
}
|
||||||
}
|
|
||||||
else
|
}
|
||||||
bytestream << fData; //deprecated.
|
else
|
||||||
|
bytestream << fData; //deprecated.
|
||||||
|
|
||||||
//bytestream << static_cast<uint8_t>(fisNULL);
|
//bytestream << static_cast<uint8_t>(fisNULL);
|
||||||
bytestream << static_cast<uint8_t>(fIsFromCol);
|
bytestream << static_cast<uint8_t>(fIsFromCol);
|
||||||
bytestream <<(uint32_t)fFuncScale;
|
bytestream << (uint32_t)fFuncScale;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,80 +52,110 @@ public:
|
|||||||
/** @brief ctor
|
/** @brief ctor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EXPORT DMLColumn(std::string name, std::string value, bool isFromCol = false, uint32_t funcScale=0, bool isNULL=false);
|
EXPORT DMLColumn(std::string name, std::string value, bool isFromCol = false, uint32_t funcScale = 0, bool isNULL = false);
|
||||||
/** @brief new ctor
|
/** @brief new ctor
|
||||||
* isNUll is currently not in use. It supposed to indicate whether each value is null or not.
|
* 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
|
/** @brief dtor
|
||||||
*/
|
*/
|
||||||
EXPORT ~DMLColumn();
|
EXPORT ~DMLColumn();
|
||||||
|
|
||||||
/** @brief read a DMLColumn from a ByteStream
|
/** @brief read a DMLColumn from a ByteStream
|
||||||
*
|
*
|
||||||
* @param bytestream the ByteStream to read from
|
* @param bytestream the ByteStream to read from
|
||||||
*/
|
*/
|
||||||
EXPORT int read(messageqcpp::ByteStream& bytestream);
|
EXPORT int read(messageqcpp::ByteStream& bytestream);
|
||||||
|
|
||||||
/** @brief write a DML column to a ByteStream
|
/** @brief write a DML column to a ByteStream
|
||||||
*
|
*
|
||||||
* @param bytestream the ByteStream to write to
|
* @param bytestream the ByteStream to write to
|
||||||
*/
|
*/
|
||||||
EXPORT int write(messageqcpp::ByteStream& bytestream);
|
EXPORT int write(messageqcpp::ByteStream& bytestream);
|
||||||
|
|
||||||
/** @brief get the data for the column
|
/** @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; }
|
}
|
||||||
|
|
||||||
/** @brief get the data for the column
|
|
||||||
|
const std::vector<std::string>& get_DataVector() const
|
||||||
|
{
|
||||||
|
return fColValuesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @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; }
|
const bool get_isFromCol() const
|
||||||
/** @brief get the fIsFromCol data for the column
|
{
|
||||||
|
return fIsFromCol;
|
||||||
|
}
|
||||||
|
/** @brief get the fFuncScale data for the column
|
||||||
*/
|
*/
|
||||||
const bool get_isFromCol() const { return fIsFromCol; }
|
const uint32_t get_funcScale() const
|
||||||
/** @brief get the fFuncScale data for the column
|
{
|
||||||
*/
|
return fFuncScale;
|
||||||
const uint32_t get_funcScale() const { return fFuncScale; }
|
}
|
||||||
/** @brief get the column name
|
/** @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
|
/** @brief set the column name
|
||||||
*/
|
*/
|
||||||
EXPORT void set_Name( std::string 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
|
/** @brief set the NULL flag
|
||||||
*/
|
*/
|
||||||
void set_isnull( bool isNULL)
|
void set_isnull( bool isNULL)
|
||||||
{ fisNULL = isNULL; }
|
{
|
||||||
/** @brief set the fIsFromCol flag
|
fisNULL = isNULL;
|
||||||
|
}
|
||||||
|
/** @brief set the fIsFromCol flag
|
||||||
*/
|
*/
|
||||||
void set_isFromCol( bool isFromCol)
|
void set_isFromCol( bool isFromCol)
|
||||||
{ fIsFromCol = isFromCol; }
|
{
|
||||||
/** @brief set the fFuncScale
|
fIsFromCol = isFromCol;
|
||||||
|
}
|
||||||
|
/** @brief set the fFuncScale
|
||||||
*/
|
*/
|
||||||
void set_funcScale( uint32_t funcScale)
|
void set_funcScale( uint32_t funcScale)
|
||||||
{ fFuncScale = funcScale; }
|
{
|
||||||
|
fFuncScale = funcScale;
|
||||||
|
}
|
||||||
void set_Data ( std::string data)
|
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:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string fName;
|
std::string fName;
|
||||||
std::string fData;
|
std::string fData;
|
||||||
std::vector<std::string> fColValuesList;
|
std::vector<std::string> fColValuesList;
|
||||||
bool fisNULL;
|
bool fisNULL;
|
||||||
bool fIsFromCol;
|
bool fIsFromCol;
|
||||||
uint32_t fFuncScale;
|
uint32_t fFuncScale;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,8 @@
|
|||||||
|
|
||||||
#include "dmlobject.h"
|
#include "dmlobject.h"
|
||||||
|
|
||||||
namespace dmlpackage {
|
namespace dmlpackage
|
||||||
|
{
|
||||||
|
|
||||||
DMLObject::DMLObject()
|
DMLObject::DMLObject()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,13 +49,13 @@ public:
|
|||||||
virtual ~DMLObject();
|
virtual ~DMLObject();
|
||||||
|
|
||||||
/** @brief read a DMLObject from a ByteStream
|
/** @brief read a DMLObject from a ByteStream
|
||||||
*
|
*
|
||||||
* @param bytestream the ByteStream to read from
|
* @param bytestream the ByteStream to read from
|
||||||
*/
|
*/
|
||||||
virtual int read(messageqcpp::ByteStream& bytestream) = 0;
|
virtual int read(messageqcpp::ByteStream& bytestream) = 0;
|
||||||
|
|
||||||
/** @brief write a DMLObject to a ByteStream
|
/** @brief write a DMLObject to a ByteStream
|
||||||
*
|
*
|
||||||
* @param bytestream the ByteStream to write to
|
* @param bytestream the ByteStream to write to
|
||||||
*/
|
*/
|
||||||
virtual int write(messageqcpp::ByteStream& bytestream) = 0;
|
virtual int write(messageqcpp::ByteStream& bytestream) = 0;
|
||||||
|
|||||||
@@ -29,10 +29,10 @@
|
|||||||
namespace dmlpackage
|
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 std::string nullValue = "nvl";
|
||||||
//const size_t maxThreads = 100;
|
//const size_t maxThreads = 100;
|
||||||
//const size_t queueSize = 200;
|
//const size_t queueSize = 200;
|
||||||
} // namespace dmlpackage
|
} // namespace dmlpackage
|
||||||
#endif //DMLPACKAGE_H
|
#endif //DMLPACKAGE_H
|
||||||
|
|||||||
@@ -44,119 +44,128 @@ int dmlparse(void* yyscanner);
|
|||||||
|
|
||||||
namespace dmlpackage
|
namespace dmlpackage
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void scanner_finish(void* yyscanner);
|
void scanner_finish(void* yyscanner);
|
||||||
void scanner_init(const char *str, void* yyscanner);
|
void scanner_init(const char* str, void* yyscanner);
|
||||||
void grammar_init(dmlpackage::ParseTree* _ptree, bool);
|
void grammar_init(dmlpackage::ParseTree* _ptree, bool);
|
||||||
valbuf_t get_valbuffer(void);
|
valbuf_t get_valbuffer(void);
|
||||||
|
|
||||||
void free_copybuffer();
|
|
||||||
void set_defaultSchema(std::string schema);
|
|
||||||
|
|
||||||
DMLParser::DMLParser() :
|
void free_copybuffer();
|
||||||
|
void set_defaultSchema(std::string schema);
|
||||||
|
|
||||||
|
DMLParser::DMLParser() :
|
||||||
fStatus(-1), fDebug(false)
|
fStatus(-1), fDebug(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
DMLParser::~DMLParser()
|
DMLParser::~DMLParser()
|
||||||
{
|
{
|
||||||
scanner_finish(scanner);
|
scanner_finish(scanner);
|
||||||
dmllex_destroy(scanner);
|
dmllex_destroy(scanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMLParser::setDebug(bool debug)
|
void DMLParser::setDebug(bool debug)
|
||||||
{
|
{
|
||||||
fDebug = true;
|
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);
|
char* str;
|
||||||
scanner_init(dmltext, scanner);
|
valbuf_t valueBuffer = get_valbuffer();
|
||||||
grammar_init(&fParseTree, fDebug);
|
|
||||||
fStatus = dmlparse(scanner);
|
for (unsigned int i = 0; i < valueBuffer.size(); i++)
|
||||||
if (fStatus == 0)
|
|
||||||
{
|
{
|
||||||
char* str;
|
str = valueBuffer[i];
|
||||||
valbuf_t valueBuffer = get_valbuffer();
|
|
||||||
|
|
||||||
for(unsigned int i=0; i < valueBuffer.size(); i++)
|
if (str)
|
||||||
{
|
{
|
||||||
str = valueBuffer[i];
|
if (i > 0)
|
||||||
if(str)
|
fParseTree.fSqlText += " ";
|
||||||
{
|
|
||||||
if (i > 0)
|
fParseTree.fSqlText += str;
|
||||||
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;
|
return fStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ParseTree& DMLParser::getParseTree()
|
char dmlbuf[1024 * 1024];
|
||||||
{
|
unsigned length;
|
||||||
if (!good())
|
ifdml.seekg(0, ios::end);
|
||||||
{
|
length = ifdml.tellg();
|
||||||
throw logic_error("The ParseTree is invalid");
|
ifdml.seekg(0, ios::beg);
|
||||||
}
|
|
||||||
return fParseTree;
|
|
||||||
|
|
||||||
|
if (length > sizeof(dmlbuf) - 1)
|
||||||
|
{
|
||||||
|
throw length_error("DMLFileParser has file size hard limit of 16K.");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DMLParser::good()
|
unsigned rcount;
|
||||||
{
|
rcount = ifdml.readsome(dmlbuf, sizeof(dmlbuf) - 1);
|
||||||
return fStatus == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DMLParser::setDefaultSchema(std::string schema)
|
if (rcount < 0)
|
||||||
{
|
return fStatus;
|
||||||
set_defaultSchema(schema);
|
|
||||||
}
|
|
||||||
|
|
||||||
DMLFileParser::DMLFileParser()
|
dmlbuf[rcount] = 0;
|
||||||
:DMLParser()
|
|
||||||
{}
|
|
||||||
|
|
||||||
int DMLFileParser::parse(const string& fileName)
|
// cout << endl << fileName << "(" << rcount << ")" << endl;
|
||||||
{
|
//cout << "-----------------------------" << endl;
|
||||||
fStatus = -1;
|
//cout << dmlbuf << endl;
|
||||||
|
|
||||||
ifstream ifdml;
|
return DMLParser::parse(dmlbuf);
|
||||||
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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned rcount;
|
void end_sql(void)
|
||||||
rcount = ifdml.readsome(dmlbuf, sizeof(dmlbuf) - 1);
|
{
|
||||||
if (rcount < 0)
|
|
||||||
return fStatus;
|
|
||||||
|
|
||||||
dmlbuf[rcount] = 0;
|
} /* end_sql */
|
||||||
|
|
||||||
// cout << endl << fileName << "(" << rcount << ")" << endl;
|
|
||||||
//cout << "-----------------------------" << endl;
|
|
||||||
//cout << dmlbuf << endl;
|
|
||||||
|
|
||||||
return DMLParser::parse(dmlbuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void end_sql(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
} /* end_sql */
|
|
||||||
|
|
||||||
} // dmlpackage
|
} // dmlpackage
|
||||||
|
|||||||
@@ -31,90 +31,90 @@
|
|||||||
|
|
||||||
namespace dmlpackage
|
namespace dmlpackage
|
||||||
{
|
{
|
||||||
typedef std::vector<char*> valbuf_t;
|
typedef std::vector<char*> valbuf_t;
|
||||||
|
|
||||||
|
|
||||||
typedef SqlStatementList ParseTree;
|
|
||||||
|
|
||||||
// instance data for the parser
|
typedef SqlStatementList ParseTree;
|
||||||
typedef std::vector<char*> valbuf_t;
|
|
||||||
|
|
||||||
struct scan_data
|
// instance data for the parser
|
||||||
{
|
typedef std::vector<char*> valbuf_t;
|
||||||
/* 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
|
struct scan_data
|
||||||
*/
|
{
|
||||||
class DMLParser
|
/* Handles to the buffer that the lexer uses internally */
|
||||||
{
|
char* scanbuf;
|
||||||
public:
|
void* scanbufhandle; // This is a YY_BUFFER_STATE defined in ddl-scan.cpp
|
||||||
/** @brief ctor
|
valbuf_t valbuf;
|
||||||
*/
|
};
|
||||||
DMLParser();
|
|
||||||
|
|
||||||
/** @brief dtor
|
/** @brief BISON parser wrapper class
|
||||||
*/
|
*/
|
||||||
virtual ~DMLParser();
|
class DMLParser
|
||||||
|
{
|
||||||
/** @brief parse the supplied dml statement
|
public:
|
||||||
*
|
/** @brief ctor
|
||||||
* @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
|
|
||||||
*/
|
*/
|
||||||
class DMLFileParser : public DMLParser
|
DMLParser();
|
||||||
{
|
|
||||||
public:
|
|
||||||
/** @brief ctor
|
|
||||||
*/
|
|
||||||
DMLFileParser();
|
|
||||||
|
|
||||||
/** @brief parse the dml statement contained in the
|
/** @brief dtor
|
||||||
* supplied file
|
*/
|
||||||
*
|
virtual ~DMLParser();
|
||||||
* @param fileName the fully qualified file name to open
|
|
||||||
* and parse the contents of
|
|
||||||
*/
|
|
||||||
int parse(const std::string& fileName);
|
|
||||||
|
|
||||||
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
|
#endif // DMLPARSER_H
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -123,7 +123,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout.
|
/** @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
|
/** @brief get the query string associated with the
|
||||||
* SqlStatement
|
* SqlStatement
|
||||||
@@ -225,7 +225,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get a string representation of the query spec
|
||||||
*/
|
*/
|
||||||
@@ -233,7 +233,10 @@ public:
|
|||||||
|
|
||||||
/** @brief get the statement type - DML_INSERT
|
/** @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;
|
ValuesOrQuery* fValuesOrQueryPtr;
|
||||||
ColumnNameList fColumnList;
|
ColumnNameList fColumnList;
|
||||||
@@ -267,7 +270,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the
|
||||||
* SET assignment_commalist opt_where_clause
|
* SET assignment_commalist opt_where_clause
|
||||||
@@ -277,7 +280,10 @@ public:
|
|||||||
|
|
||||||
/** @brief get the statement type - DML_UPDATE
|
/** @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;
|
ColumnAssignmentList* fColAssignmentListPtr;
|
||||||
WhereClause* fWhereClausePtr;
|
WhereClause* fWhereClausePtr;
|
||||||
@@ -309,7 +315,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the WHERE clause
|
||||||
*/
|
*/
|
||||||
@@ -317,7 +323,10 @@ public:
|
|||||||
|
|
||||||
/** @brief get the statement type - DML_DELETE
|
/** @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;
|
WhereClause* fWhereClausePtr;
|
||||||
};
|
};
|
||||||
@@ -344,11 +353,14 @@ public:
|
|||||||
|
|
||||||
/** @brief get the statement type - DML_COMMAND
|
/** @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
|
/** @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
|
/** @brief get the COMMIT or ROLLBACK string
|
||||||
*/
|
*/
|
||||||
@@ -382,7 +394,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @brief dump to stdout
|
||||||
*/
|
*/
|
||||||
std::ostream& put(std::ostream &os) const;
|
std::ostream& put(std::ostream& os) const;
|
||||||
|
|
||||||
std::string fName;
|
std::string fName;
|
||||||
std::string fSchema;
|
std::string fSchema;
|
||||||
@@ -399,7 +411,7 @@ class ColumnAssignment
|
|||||||
public:
|
public:
|
||||||
/** @brief dump to stdout
|
/** @brief dump to stdout
|
||||||
*/
|
*/
|
||||||
std::ostream& put(std::ostream &os) const;
|
std::ostream& put(std::ostream& os) const;
|
||||||
|
|
||||||
/** @brief get the string representation of
|
/** @brief get the string representation of
|
||||||
* the column assignment
|
* the column assignment
|
||||||
@@ -409,8 +421,8 @@ public:
|
|||||||
std::string fColumn;
|
std::string fColumn;
|
||||||
std::string fOperator;
|
std::string fOperator;
|
||||||
std::string fScalarExpression;
|
std::string fScalarExpression;
|
||||||
bool fFromCol;
|
bool fFromCol;
|
||||||
uint32_t fFuncScale;
|
uint32_t fFuncScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @brief Stores a value list or a query specification
|
/** @brief Stores a value list or a query specification
|
||||||
@@ -444,7 +456,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @brief dump to stdout
|
||||||
*/
|
*/
|
||||||
std::ostream& put(std::ostream &os) const;
|
std::ostream& put(std::ostream& os) const;
|
||||||
|
|
||||||
/** @brief get the string reperesentation of
|
/** @brief get the string reperesentation of
|
||||||
* the ValuesList or the QuerySpec
|
* the ValuesList or the QuerySpec
|
||||||
@@ -480,7 +492,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string represntation of the SELECT statement
|
||||||
*/
|
*/
|
||||||
@@ -513,7 +525,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the FROM clause
|
||||||
*/
|
*/
|
||||||
@@ -540,7 +552,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the WHERE clause
|
||||||
*/
|
*/
|
||||||
@@ -569,7 +581,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the GROUP BY clause
|
||||||
*/
|
*/
|
||||||
@@ -597,7 +609,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the HAVING clause
|
||||||
*/
|
*/
|
||||||
@@ -618,7 +630,7 @@ class Escape
|
|||||||
public:
|
public:
|
||||||
/** @brief dump to stdout
|
/** @brief dump to stdout
|
||||||
*/
|
*/
|
||||||
std::ostream& put(std::ostream &os) const;
|
std::ostream& put(std::ostream& os) const;
|
||||||
|
|
||||||
std::string fEscapeChar;
|
std::string fEscapeChar;
|
||||||
};
|
};
|
||||||
@@ -653,7 +665,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @param get the string representation of the predicate
|
||||||
*/
|
*/
|
||||||
@@ -682,7 +694,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the COMPARISON
|
||||||
* predicate
|
* predicate
|
||||||
@@ -717,7 +729,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the BETWEEN
|
||||||
* predicate
|
* predicate
|
||||||
@@ -752,7 +764,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the LIKE
|
||||||
* predicate
|
* predicate
|
||||||
@@ -786,7 +798,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the NULL test
|
||||||
* predicate
|
* predicate
|
||||||
@@ -820,7 +832,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the IN
|
||||||
* predicate
|
* predicate
|
||||||
@@ -853,7 +865,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the
|
||||||
* ALL or ANY predicate
|
* ALL or ANY predicate
|
||||||
@@ -886,7 +898,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the EXISTS
|
||||||
* predicate
|
* predicate
|
||||||
@@ -919,7 +931,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the striong representation of the
|
||||||
* search condition
|
* search condition
|
||||||
@@ -965,7 +977,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the
|
||||||
* table expression
|
* table expression
|
||||||
@@ -1013,7 +1025,7 @@ public:
|
|||||||
|
|
||||||
/** @brief dump to stdout
|
/** @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
|
/** @brief get the string representation of the
|
||||||
* query specification
|
* query specification
|
||||||
|
|||||||
@@ -31,21 +31,22 @@ DMLTable::DMLTable()
|
|||||||
|
|
||||||
DMLTable::~DMLTable()
|
DMLTable::~DMLTable()
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RowList::iterator it = fRows.begin();
|
RowList::iterator it = fRows.begin();
|
||||||
while(it != fRows.end())
|
|
||||||
|
while (it != fRows.end())
|
||||||
{
|
{
|
||||||
delete *it;
|
delete *it;
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
cout << "failed to delete the table rows" << endl;
|
cout << "failed to delete the table rows" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int DMLTable::read(messageqcpp::ByteStream& bytestream)
|
int DMLTable::read(messageqcpp::ByteStream& bytestream)
|
||||||
@@ -67,6 +68,7 @@ int DMLTable::read(messageqcpp::ByteStream& bytestream)
|
|||||||
retval = aRow->read(bytestream);
|
retval = aRow->read(bytestream);
|
||||||
fRows.push_back(aRow);
|
fRows.push_back(aRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,6 +84,7 @@ int DMLTable::write(messageqcpp::ByteStream& bytestream)
|
|||||||
//write the row list
|
//write the row list
|
||||||
RowList::iterator rowListPtr;
|
RowList::iterator rowListPtr;
|
||||||
rowListPtr = fRows.begin();
|
rowListPtr = fRows.begin();
|
||||||
|
|
||||||
for (; rowListPtr != fRows.end(); ++rowListPtr)
|
for (; rowListPtr != fRows.end(); ++rowListPtr)
|
||||||
{
|
{
|
||||||
retval = (*rowListPtr)->write(bytestream);
|
retval = (*rowListPtr)->write(bytestream);
|
||||||
|
|||||||
@@ -51,23 +51,38 @@ public:
|
|||||||
|
|
||||||
/** @brief get the schema name
|
/** @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
|
/** @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
|
/** @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
|
/** @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
|
/** @brief get the row list
|
||||||
*/
|
*/
|
||||||
inline RowList& get_RowList() { return fRows; }
|
inline RowList& get_RowList()
|
||||||
|
{
|
||||||
|
return fRows;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief read a DMLTable from a ByteStream
|
/** @brief read a DMLTable from a ByteStream
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -37,13 +37,14 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
po::options_description desc ("Allowed options");
|
po::options_description desc ("Allowed options");
|
||||||
desc.add_options ()
|
desc.add_options ()
|
||||||
("help", "produce help message")
|
("help", "produce help message")
|
||||||
("bisond", /* po::value <string>(),*/ "Have bison produce debug output")
|
("bisond", /* po::value <string>(),*/ "Have bison produce debug output")
|
||||||
("count", po::value <int>(), "number of runs")
|
("count", po::value <int>(), "number of runs")
|
||||||
("sql", po::value < string > (), "sql file");
|
("sql", po::value < string > (), "sql file");
|
||||||
po::variables_map vm;
|
po::variables_map vm;
|
||||||
po::store (po::parse_command_line (argc, argv, desc), vm);
|
po::store (po::parse_command_line (argc, argv, desc), vm);
|
||||||
po::notify (vm);
|
po::notify (vm);
|
||||||
|
|
||||||
if (vm.count ("sql"))
|
if (vm.count ("sql"))
|
||||||
sqlfile = vm["sql"].as <string> ();
|
sqlfile = vm["sql"].as <string> ();
|
||||||
|
|
||||||
@@ -51,14 +52,15 @@ int main(int argc, char* argv[])
|
|||||||
count = vm["count"].as<int>();
|
count = vm["count"].as<int>();
|
||||||
|
|
||||||
DMLFileParser parser;
|
DMLFileParser parser;
|
||||||
|
|
||||||
if (vm.count ("bisond"))
|
if (vm.count ("bisond"))
|
||||||
parser.setDebug(true);
|
parser.setDebug(true);
|
||||||
|
|
||||||
parser.parse(sqlfile);
|
parser.parse(sqlfile);
|
||||||
|
|
||||||
if(parser.good())
|
if (parser.good())
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.getParseTree();
|
const ParseTree& ptree = parser.getParseTree();
|
||||||
|
|
||||||
cout << "Parser succeeded." << endl;
|
cout << "Parser succeeded." << endl;
|
||||||
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
||||||
@@ -66,8 +68,10 @@ int main(int argc, char* argv[])
|
|||||||
cout << ptree;
|
cout << ptree;
|
||||||
|
|
||||||
SqlStatement* statementPtr = ptree[0];
|
SqlStatement* statementPtr = ptree[0];
|
||||||
|
|
||||||
if (statementPtr)
|
if (statementPtr)
|
||||||
cout << statementPtr->getQueryString();
|
cout << statementPtr->getQueryString();
|
||||||
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ InsertDMLPackage::InsertDMLPackage()
|
|||||||
|
|
||||||
InsertDMLPackage::InsertDMLPackage( std::string schemaName, std::string tableName,
|
InsertDMLPackage::InsertDMLPackage( std::string schemaName, std::string tableName,
|
||||||
std::string dmlStatement, int sessionID )
|
std::string dmlStatement, int sessionID )
|
||||||
:CalpontDMLPackage( schemaName, tableName, dmlStatement, sessionID )
|
: CalpontDMLPackage( schemaName, tableName, dmlStatement, sessionID )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
InsertDMLPackage::~InsertDMLPackage()
|
InsertDMLPackage::~InsertDMLPackage()
|
||||||
@@ -64,10 +64,12 @@ int InsertDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
|||||||
bytestream << fSchemaName;
|
bytestream << fSchemaName;
|
||||||
bytestream << (uint8_t)fLogging;
|
bytestream << (uint8_t)fLogging;
|
||||||
bytestream << (uint8_t)fLogending;
|
bytestream << (uint8_t)fLogending;
|
||||||
|
|
||||||
if (fTable != 0)
|
if (fTable != 0)
|
||||||
{
|
{
|
||||||
retval = fTable->write(bytestream);
|
retval = fTable->write(bytestream);
|
||||||
}
|
}
|
||||||
|
|
||||||
bytestream << fTableOid;
|
bytestream << fTableOid;
|
||||||
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsInsertSelect);
|
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsInsertSelect);
|
||||||
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsBatchInsert);
|
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)
|
int InsertDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows)
|
||||||
{
|
{
|
||||||
#ifdef DML_PACKAGE_DEBUG
|
#ifdef DML_PACKAGE_DEBUG
|
||||||
// cout << "The data buffer received: " << buffer << endl;
|
// cout << "The data buffer received: " << buffer << endl;
|
||||||
#endif
|
#endif
|
||||||
int retval = 1;
|
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;
|
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||||
boost::char_separator<char> sep(",");
|
boost::char_separator<char> sep(",");
|
||||||
tokenizer tokens(buffer, sep);
|
tokenizer tokens(buffer, sep);
|
||||||
|
|
||||||
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
||||||
{
|
{
|
||||||
dataList.push_back(StripLeadingWhitespace(*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;
|
int n = 0;
|
||||||
for (int i=0; i < rows; i++)
|
|
||||||
|
for (int i = 0; i < rows; i++)
|
||||||
{
|
{
|
||||||
//get a new row
|
//get a new row
|
||||||
Row *aRowPtr = new Row();
|
Row* aRowPtr = new Row();
|
||||||
std::string colName;
|
std::string colName;
|
||||||
std::string colValue;
|
std::string colValue;
|
||||||
|
|
||||||
for (int j = 0; j < columns; j++)
|
for (int j = 0; j < columns; j++)
|
||||||
{
|
{
|
||||||
//Build a column list
|
//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);
|
DMLColumn* aColumn = new DMLColumn(colName, colValue, false);
|
||||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
//build a row list for a table
|
//build a row list for a table
|
||||||
fTable->get_RowList().push_back(aRowPtr);
|
fTable->get_RowList().push_back(aRowPtr);
|
||||||
}
|
}
|
||||||
@@ -156,19 +162,21 @@ int InsertDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValues
|
|||||||
int retval = 1;
|
int retval = 1;
|
||||||
|
|
||||||
initializeTable();
|
initializeTable();
|
||||||
Row *aRowPtr = new Row();
|
Row* aRowPtr = new Row();
|
||||||
std::string colName;
|
std::string colName;
|
||||||
std::vector<std::string> colValList;
|
std::vector<std::string> colValList;
|
||||||
|
|
||||||
for (int j = 0; j < columns; j++)
|
for (int j = 0; j < columns; j++)
|
||||||
{
|
{
|
||||||
//Build a column list
|
//Build a column list
|
||||||
colName = colNameList[j];
|
colName = colNameList[j];
|
||||||
|
|
||||||
colValList = tableValuesMap[j];
|
colValList = tableValuesMap[j];
|
||||||
|
|
||||||
DMLColumn* aColumn = new DMLColumn(colName, colValList, false, 0, nullValues[j]);
|
DMLColumn* aColumn = new DMLColumn(colName, colValList, false, 0, nullValues[j]);
|
||||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
//build a row list for a table
|
//build a row list for a table
|
||||||
fTable->get_RowList().push_back(aRowPtr);
|
fTable->get_RowList().push_back(aRowPtr);
|
||||||
aRowPtr = NULL;
|
aRowPtr = NULL;
|
||||||
@@ -188,6 +196,7 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
|||||||
|
|
||||||
initializeTable();
|
initializeTable();
|
||||||
bool isNULL = false;
|
bool isNULL = false;
|
||||||
|
|
||||||
// only if we don't have a select statement
|
// only if we don't have a select statement
|
||||||
if (0 == insertStmt.fValuesOrQueryPtr->fQuerySpecPtr)
|
if (0 == insertStmt.fValuesOrQueryPtr->fQuerySpecPtr)
|
||||||
{
|
{
|
||||||
@@ -198,16 +207,20 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
|||||||
{
|
{
|
||||||
|
|
||||||
ValuesList valuesList = insertStmt.fValuesOrQueryPtr->fValuesList;
|
ValuesList valuesList = insertStmt.fValuesOrQueryPtr->fValuesList;
|
||||||
|
|
||||||
if (columnNameList.size() != valuesList.size())
|
if (columnNameList.size() != valuesList.size())
|
||||||
{
|
{
|
||||||
throw logic_error("Column names and values count mismatch!");
|
throw logic_error("Column names and values count mismatch!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Row* aRow = new Row();
|
Row* aRow = new Row();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < columnNameList.size(); i++)
|
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);
|
(aRow->get_ColumnList()).push_back(aColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
fTable->get_RowList().push_back(aRow);
|
fTable->get_RowList().push_back(aRow);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -218,9 +231,11 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
|||||||
Row* aRow = new Row();
|
Row* aRow = new Row();
|
||||||
std::string colName = "";
|
std::string colName = "";
|
||||||
std::string colValue;
|
std::string colValue;
|
||||||
|
|
||||||
while (iter != valuesList.end())
|
while (iter != valuesList.end())
|
||||||
{
|
{
|
||||||
colValue = *iter;
|
colValue = *iter;
|
||||||
|
|
||||||
if ( strcasecmp(colValue.c_str(), "NULL") == 0)
|
if ( strcasecmp(colValue.c_str(), "NULL") == 0)
|
||||||
{
|
{
|
||||||
isNULL = true;
|
isNULL = true;
|
||||||
@@ -229,11 +244,13 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
|||||||
{
|
{
|
||||||
isNULL = false;
|
isNULL = false;
|
||||||
}
|
}
|
||||||
DMLColumn *aColumn = new DMLColumn(colName,colValue, isNULL);
|
|
||||||
|
DMLColumn* aColumn = new DMLColumn(colName, colValue, isNULL);
|
||||||
(aRow->get_ColumnList()).push_back(aColumn);
|
(aRow->get_ColumnList()).push_back(aColumn);
|
||||||
|
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
fTable->get_RowList().push_back(aRow);
|
fTable->get_RowList().push_back(aRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
* @param sessionID the session id
|
* @param sessionID the session id
|
||||||
*/
|
*/
|
||||||
EXPORT InsertDMLPackage(std::string schemaName, std::string tableName,
|
EXPORT InsertDMLPackage(std::string schemaName, std::string tableName,
|
||||||
std::string dmlStatement, int sessionID );
|
std::string dmlStatement, int sessionID );
|
||||||
|
|
||||||
/** @brief dtor
|
/** @brief dtor
|
||||||
*/
|
*/
|
||||||
@@ -80,13 +80,13 @@ public:
|
|||||||
* @param rows the number of rows in the buffer
|
* @param rows the number of rows in the buffer
|
||||||
*/
|
*/
|
||||||
EXPORT int buildFromBuffer(std::string& buffer, int columns, int rows);
|
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 tableValuesMap the value list for each column in the table
|
||||||
* @param colNameList the column name for each column
|
* @param colNameList the column name for each column
|
||||||
* @param columns number of columns in the table
|
* @param columns number of columns in the table
|
||||||
* @param rows number of rows to be touched
|
* @param rows number of rows to be touched
|
||||||
*/
|
*/
|
||||||
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues);
|
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues);
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class MySQLDMLStatement : public VendorDMLStatement
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MySQLDMLStatement() : VendorDMLStatement("", 0) {}
|
MySQLDMLStatement() : VendorDMLStatement("", 0) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class OracleDMLStatement : public VendorDMLStatement
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OracleDMLStatement() : VendorDMLStatement("", 0) {}
|
OracleDMLStatement() : VendorDMLStatement("", 0) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace dmlpackage
|
|||||||
{
|
{
|
||||||
|
|
||||||
Row::Row()
|
Row::Row()
|
||||||
:fRowID(std::numeric_limits<WriteEngine::RID>::max())
|
: fRowID(std::numeric_limits<WriteEngine::RID>::max())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Row::~Row()
|
Row::~Row()
|
||||||
@@ -39,17 +39,19 @@ Row::~Row()
|
|||||||
{
|
{
|
||||||
delete fColumnList[i];
|
delete fColumnList[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
fColumnList.clear();
|
fColumnList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Row::Row(const Row& row)
|
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);
|
const DMLColumn* aColumn = row.get_ColumnAt(i);
|
||||||
DMLColumn* newColumn = new DMLColumn(aColumn->get_Name(), aColumn->get_Data());
|
DMLColumn* newColumn = new DMLColumn(aColumn->get_Name(), aColumn->get_Data());
|
||||||
fColumnList.push_back(newColumn);
|
fColumnList.push_back(newColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
fRowID = row.fRowID;
|
fRowID = row.fRowID;
|
||||||
}
|
}
|
||||||
int Row::read(messageqcpp::ByteStream& bytestream)
|
int Row::read(messageqcpp::ByteStream& bytestream)
|
||||||
@@ -60,12 +62,14 @@ int Row::read(messageqcpp::ByteStream& bytestream)
|
|||||||
set_RowID(rowID);
|
set_RowID(rowID);
|
||||||
messageqcpp::ByteStream::quadbyte col_count;
|
messageqcpp::ByteStream::quadbyte col_count;
|
||||||
bytestream >> col_count;
|
bytestream >> col_count;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < col_count; i++)
|
for (unsigned int i = 0; i < col_count; i++)
|
||||||
{
|
{
|
||||||
DMLColumn* aColumn = new DMLColumn();
|
DMLColumn* aColumn = new DMLColumn();
|
||||||
retval = aColumn->read(bytestream);
|
retval = aColumn->read(bytestream);
|
||||||
fColumnList.push_back(aColumn);
|
fColumnList.push_back(aColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +83,7 @@ int Row::write(messageqcpp::ByteStream& bytestream)
|
|||||||
colListPtr = fColumnList.begin();
|
colListPtr = fColumnList.begin();
|
||||||
messageqcpp::ByteStream::quadbyte col_count = fColumnList.size();
|
messageqcpp::ByteStream::quadbyte col_count = fColumnList.size();
|
||||||
bytestream << col_count;
|
bytestream << col_count;
|
||||||
|
|
||||||
for (; colListPtr != fColumnList.end(); ++colListPtr)
|
for (; colListPtr != fColumnList.end(); ++colListPtr)
|
||||||
{
|
{
|
||||||
retval = (*colListPtr)->write(bytestream);
|
retval = (*colListPtr)->write(bytestream);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
/** @brief copy constructor
|
/** @brief copy constructor
|
||||||
*/
|
*/
|
||||||
EXPORT Row(const Row&);
|
EXPORT Row(const Row&);
|
||||||
|
|
||||||
/** @brief read a Row from a ByteStream
|
/** @brief read a Row from a ByteStream
|
||||||
*
|
*
|
||||||
* @param bytestream the ByteStream to read from
|
* @param bytestream the ByteStream to read from
|
||||||
@@ -64,26 +64,38 @@ public:
|
|||||||
EXPORT int read(messageqcpp::ByteStream& bytestream);
|
EXPORT int read(messageqcpp::ByteStream& bytestream);
|
||||||
|
|
||||||
/** @brief write a Row to a ByteStream
|
/** @brief write a Row to a ByteStream
|
||||||
*
|
*
|
||||||
* @param bytestream the ByteStream to write to
|
* @param bytestream the ByteStream to write to
|
||||||
*/
|
*/
|
||||||
EXPORT int write(messageqcpp::ByteStream& bytestream);
|
EXPORT int write(messageqcpp::ByteStream& bytestream);
|
||||||
|
|
||||||
/** @brief get the list of columns in the row
|
/** @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
|
/** @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
|
/** @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
|
/** @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
|
/** @brief get the column at the specified index
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -46,9 +46,10 @@ bool parse_file(char* fileName)
|
|||||||
DMLFileParser parser;
|
DMLFileParser parser;
|
||||||
parser.parse(fileName);
|
parser.parse(fileName);
|
||||||
bool good = parser.good();
|
bool good = parser.good();
|
||||||
|
|
||||||
if (good)
|
if (good)
|
||||||
{
|
{
|
||||||
const ParseTree &ptree = parser.getParseTree();
|
const ParseTree& ptree = parser.getParseTree();
|
||||||
|
|
||||||
cout << "Parser succeeded." << endl;
|
cout << "Parser succeeded." << endl;
|
||||||
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
||||||
@@ -56,8 +57,10 @@ bool parse_file(char* fileName)
|
|||||||
cout << ptree;
|
cout << ptree;
|
||||||
|
|
||||||
SqlStatement* statementPtr = ptree[0];
|
SqlStatement* statementPtr = ptree[0];
|
||||||
|
|
||||||
if (statementPtr)
|
if (statementPtr)
|
||||||
cout << statementPtr->getQueryString();
|
cout << statementPtr->getQueryString();
|
||||||
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,39 +90,69 @@ public:
|
|||||||
|
|
||||||
void tearDown() {}
|
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
|
class DMLTest : public CppUnit::TestFixture
|
||||||
{
|
{
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE( DMLTest );
|
CPPUNIT_TEST_SUITE( DMLTest );
|
||||||
// CPPUNIT_TEST( test_direct_insert );
|
// CPPUNIT_TEST( test_direct_insert );
|
||||||
// CPPUNIT_TEST( test_query_insert );
|
// CPPUNIT_TEST( test_query_insert );
|
||||||
CPPUNIT_TEST( test_direct_update );
|
CPPUNIT_TEST( test_direct_update );
|
||||||
// CPPUNIT_TEST( test_query_update );
|
// CPPUNIT_TEST( test_query_update );
|
||||||
// CPPUNIT_TEST( test_delete_all );
|
// CPPUNIT_TEST( test_delete_all );
|
||||||
// CPPUNIT_TEST( test_delete_query );
|
// CPPUNIT_TEST( test_delete_query );
|
||||||
// CPPUNIT_TEST( test_commit );
|
// CPPUNIT_TEST( test_commit );
|
||||||
// CPPUNIT_TEST( test_rollback );
|
// CPPUNIT_TEST( test_rollback );
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -154,6 +187,7 @@ public:
|
|||||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||||
|
|
||||||
if ( pDMLPackage->HasFilter() )
|
if ( pDMLPackage->HasFilter() )
|
||||||
{
|
{
|
||||||
cout << "This INSERT statement has a filter:" << endl;
|
cout << "This INSERT statement has a filter:" << endl;
|
||||||
@@ -180,7 +214,7 @@ public:
|
|||||||
|
|
||||||
CPPUNIT_ASSERT( DML_INSERT == package_type );
|
CPPUNIT_ASSERT( DML_INSERT == package_type );
|
||||||
|
|
||||||
InsertDMLPackage *pObject = new InsertDMLPackage();
|
InsertDMLPackage* pObject = new InsertDMLPackage();
|
||||||
|
|
||||||
pObject->read( bs );
|
pObject->read( bs );
|
||||||
|
|
||||||
@@ -196,7 +230,7 @@ public:
|
|||||||
|
|
||||||
cout << dmlStatement << endl;
|
cout << dmlStatement << endl;
|
||||||
|
|
||||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||||
|
|
||||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||||
@@ -212,15 +246,17 @@ public:
|
|||||||
|
|
||||||
cout << dmlStatement << endl;
|
cout << dmlStatement << endl;
|
||||||
|
|
||||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||||
|
|
||||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||||
|
|
||||||
if (pDMLPackage->HasFilter())
|
if (pDMLPackage->HasFilter())
|
||||||
{
|
{
|
||||||
cout << "This DELETE statement has a filter:" << endl;
|
cout << "This DELETE statement has a filter:" << endl;
|
||||||
cout << pDMLPackage->get_QueryString() << endl;
|
cout << pDMLPackage->get_QueryString() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
write_DML_object(bytestream, pDMLPackage);
|
write_DML_object(bytestream, pDMLPackage);
|
||||||
delete pDMLPackage;
|
delete pDMLPackage;
|
||||||
read_delete_object(bytestream);
|
read_delete_object(bytestream);
|
||||||
@@ -235,7 +271,7 @@ public:
|
|||||||
|
|
||||||
CPPUNIT_ASSERT( DML_DELETE == package_type );
|
CPPUNIT_ASSERT( DML_DELETE == package_type );
|
||||||
|
|
||||||
DeleteDMLPackage *pObject = new DeleteDMLPackage();
|
DeleteDMLPackage* pObject = new DeleteDMLPackage();
|
||||||
|
|
||||||
pObject->read( bs );
|
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;";
|
std::string dmlStatement = "UPDATE tpch.part SET p_partno = 1, p_name = 'joe' where p_partno=2;";
|
||||||
cout << dmlStatement << endl;
|
cout << dmlStatement << endl;
|
||||||
|
|
||||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||||
write_DML_object(bytestream, pDMLPackage);
|
write_DML_object(bytestream, pDMLPackage);
|
||||||
@@ -267,6 +303,7 @@ public:
|
|||||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||||
|
|
||||||
if (pDMLPackage->HasFilter())
|
if (pDMLPackage->HasFilter())
|
||||||
{
|
{
|
||||||
cout << "This UPDATE statement has a filter:" << endl;
|
cout << "This UPDATE statement has a filter:" << endl;
|
||||||
@@ -286,7 +323,7 @@ public:
|
|||||||
|
|
||||||
CPPUNIT_ASSERT( DML_UPDATE == package_type );
|
CPPUNIT_ASSERT( DML_UPDATE == package_type );
|
||||||
|
|
||||||
UpdateDMLPackage *pObject = new UpdateDMLPackage();
|
UpdateDMLPackage* pObject = new UpdateDMLPackage();
|
||||||
|
|
||||||
pObject->read( bs );
|
pObject->read( bs );
|
||||||
|
|
||||||
@@ -300,7 +337,7 @@ public:
|
|||||||
std::string dmlStatement = "COMMIT;";
|
std::string dmlStatement = "COMMIT;";
|
||||||
cout << dmlStatement << endl;
|
cout << dmlStatement << endl;
|
||||||
|
|
||||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||||
write_DML_object(bytestream, pDMLPackage);
|
write_DML_object(bytestream, pDMLPackage);
|
||||||
@@ -315,7 +352,7 @@ public:
|
|||||||
std::string dmlStatement = "ROLLBACK;";
|
std::string dmlStatement = "ROLLBACK;";
|
||||||
cout << dmlStatement << endl;
|
cout << dmlStatement << endl;
|
||||||
|
|
||||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||||
write_DML_object(bytestream, pDMLPackage);
|
write_DML_object(bytestream, pDMLPackage);
|
||||||
@@ -331,7 +368,7 @@ public:
|
|||||||
|
|
||||||
CPPUNIT_ASSERT( DML_COMMAND == package_type );
|
CPPUNIT_ASSERT( DML_COMMAND == package_type );
|
||||||
|
|
||||||
CommandDMLPackage *pObject = new CommandDMLPackage();
|
CommandDMLPackage* pObject = new CommandDMLPackage();
|
||||||
|
|
||||||
pObject->read( bs );
|
pObject->read( bs );
|
||||||
|
|
||||||
@@ -346,10 +383,10 @@ CPPUNIT_TEST_SUITE_REGISTRATION( DMLTest );
|
|||||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||||
#include <cppunit/ui/text/TestRunner.h>
|
#include <cppunit/ui/text/TestRunner.h>
|
||||||
|
|
||||||
int main( int argc, char **argv)
|
int main( int argc, char** argv)
|
||||||
{
|
{
|
||||||
CppUnit::TextUi::TestRunner runner;
|
CppUnit::TextUi::TestRunner runner;
|
||||||
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
|
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||||
runner.addTest( registry.makeTest() );
|
runner.addTest( registry.makeTest() );
|
||||||
bool wasSuccessful = runner.run( "", false );
|
bool wasSuccessful = runner.run( "", false );
|
||||||
return (wasSuccessful ? 0 : 1);
|
return (wasSuccessful ? 0 : 1);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ UpdateDMLPackage::UpdateDMLPackage()
|
|||||||
|
|
||||||
UpdateDMLPackage::UpdateDMLPackage(std::string schemaName, std::string tableName,
|
UpdateDMLPackage::UpdateDMLPackage(std::string schemaName, std::string tableName,
|
||||||
std::string dmlStatement, int sessionID)
|
std::string dmlStatement, int sessionID)
|
||||||
:CalpontDMLPackage( schemaName, tableName, dmlStatement, sessionID)
|
: CalpontDMLPackage( schemaName, tableName, dmlStatement, sessionID)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
UpdateDMLPackage::~UpdateDMLPackage()
|
UpdateDMLPackage::~UpdateDMLPackage()
|
||||||
@@ -52,12 +52,12 @@ int UpdateDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
|||||||
|
|
||||||
messageqcpp::ByteStream::quadbyte session_id = fSessionID;
|
messageqcpp::ByteStream::quadbyte session_id = fSessionID;
|
||||||
bytestream << session_id;
|
bytestream << session_id;
|
||||||
/*
|
/*
|
||||||
if(fPlan != 0)
|
if(fPlan != 0)
|
||||||
fHasFilter = true;
|
fHasFilter = true;
|
||||||
else
|
else
|
||||||
fHasFilter = false;
|
fHasFilter = false;
|
||||||
*/
|
*/
|
||||||
messageqcpp::ByteStream::quadbyte hasFilter = fHasFilter;
|
messageqcpp::ByteStream::quadbyte hasFilter = fHasFilter;
|
||||||
bytestream << hasFilter;
|
bytestream << hasFilter;
|
||||||
|
|
||||||
@@ -67,11 +67,13 @@ int UpdateDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
|||||||
bytestream << fSQLStatement;
|
bytestream << fSQLStatement;
|
||||||
bytestream << fSchemaName;
|
bytestream << fSchemaName;
|
||||||
bytestream << (uint8_t)fIsFromCol;
|
bytestream << (uint8_t)fIsFromCol;
|
||||||
|
|
||||||
if (fTable != 0)
|
if (fTable != 0)
|
||||||
{
|
{
|
||||||
retval = fTable->write(bytestream);
|
retval = fTable->write(bytestream);
|
||||||
}
|
}
|
||||||
if(fHasFilter)
|
|
||||||
|
if (fHasFilter)
|
||||||
{
|
{
|
||||||
bytestream += *(fPlan.get());
|
bytestream += *(fPlan.get());
|
||||||
}
|
}
|
||||||
@@ -105,7 +107,8 @@ int UpdateDMLPackage::read(messageqcpp::ByteStream& bytestream)
|
|||||||
fIsFromCol = (isFromCol != 0);
|
fIsFromCol = (isFromCol != 0);
|
||||||
fTable = new DMLTable();
|
fTable = new DMLTable();
|
||||||
retval = fTable->read(bytestream);
|
retval = fTable->read(bytestream);
|
||||||
if(fHasFilter)
|
|
||||||
|
if (fHasFilter)
|
||||||
{
|
{
|
||||||
fPlan.reset(new messageqcpp::ByteStream(bytestream));
|
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.
|
// Push one row always and let the filter happen on the proc side.
|
||||||
Row* rowPtr = new Row();
|
Row* rowPtr = new Row();
|
||||||
ColumnAssignmentList::const_iterator iter = updateStmt.fColAssignmentListPtr->begin();
|
ColumnAssignmentList::const_iterator iter = updateStmt.fColAssignmentListPtr->begin();
|
||||||
|
|
||||||
while (iter != updateStmt.fColAssignmentListPtr->end())
|
while (iter != updateStmt.fColAssignmentListPtr->end())
|
||||||
{
|
{
|
||||||
ColumnAssignment* colaPtr = *iter;
|
ColumnAssignment* colaPtr = *iter;
|
||||||
@@ -138,7 +142,9 @@ int UpdateDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
|||||||
|
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
fTable->get_RowList().push_back(rowPtr);
|
fTable->get_RowList().push_back(rowPtr);
|
||||||
|
|
||||||
if (0 != updateStmt.fWhereClausePtr)
|
if (0 != updateStmt.fWhereClausePtr)
|
||||||
{
|
{
|
||||||
// We need to filter the rows...get row ids
|
// 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;
|
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||||
boost::char_separator<char> sep(":,");
|
boost::char_separator<char> sep(":,");
|
||||||
tokenizer tokens(buffer, sep);
|
tokenizer tokens(buffer, sep);
|
||||||
|
|
||||||
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
||||||
{
|
{
|
||||||
dataList.push_back(StripLeadingWhitespace(*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;
|
int n = 0;
|
||||||
for (int i=0; i < rows; i++)
|
|
||||||
|
for (int i = 0; i < rows; i++)
|
||||||
{
|
{
|
||||||
//get a new row
|
//get a new row
|
||||||
Row *aRowPtr = new Row();
|
Row* aRowPtr = new Row();
|
||||||
std::string colName;
|
std::string colName;
|
||||||
std::string colValue;
|
std::string colValue;
|
||||||
//get row ID from the buffer
|
//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);
|
DMLColumn* aColumn = new DMLColumn(colName, colValue);
|
||||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
//build a row list for a table
|
//build a row list for a table
|
||||||
fTable->get_RowList().push_back(aRowPtr);
|
fTable->get_RowList().push_back(aRowPtr);
|
||||||
}
|
}
|
||||||
@@ -211,19 +220,21 @@ int UpdateDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValues
|
|||||||
int retval = 1;
|
int retval = 1;
|
||||||
|
|
||||||
initializeTable();
|
initializeTable();
|
||||||
Row *aRowPtr = new Row();
|
Row* aRowPtr = new Row();
|
||||||
std::string colName;
|
std::string colName;
|
||||||
std::vector<std::string> colValList;
|
std::vector<std::string> colValList;
|
||||||
|
|
||||||
for (int j = 0; j < columns; j++)
|
for (int j = 0; j < columns; j++)
|
||||||
{
|
{
|
||||||
//Build a column list
|
//Build a column list
|
||||||
colName = colNameList[j];
|
colName = colNameList[j];
|
||||||
|
|
||||||
colValList = tableValuesMap[j];
|
colValList = tableValuesMap[j];
|
||||||
|
|
||||||
DMLColumn* aColumn = new DMLColumn(colName, colValList, false, 0, nullValues[j]);
|
DMLColumn* aColumn = new DMLColumn(colName, colValList, false, 0, nullValues[j]);
|
||||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
//build a row list for a table
|
//build a row list for a table
|
||||||
fTable->get_RowList().push_back(aRowPtr);
|
fTable->get_RowList().push_back(aRowPtr);
|
||||||
return retval;
|
return retval;
|
||||||
@@ -242,6 +253,7 @@ void UpdateDMLPackage::buildUpdateFromMysqlBuffer(UpdateSqlStatement& updateStm
|
|||||||
// Push one row always and let the filter happen on the proc side.
|
// Push one row always and let the filter happen on the proc side.
|
||||||
Row* rowPtr = new Row();
|
Row* rowPtr = new Row();
|
||||||
ColumnAssignmentList::const_iterator iter = updateStmt.fColAssignmentListPtr->begin();
|
ColumnAssignmentList::const_iterator iter = updateStmt.fColAssignmentListPtr->begin();
|
||||||
|
|
||||||
while (iter != updateStmt.fColAssignmentListPtr->end())
|
while (iter != updateStmt.fColAssignmentListPtr->end())
|
||||||
{
|
{
|
||||||
ColumnAssignment* colaPtr = *iter;
|
ColumnAssignment* colaPtr = *iter;
|
||||||
@@ -250,6 +262,7 @@ void UpdateDMLPackage::buildUpdateFromMysqlBuffer(UpdateSqlStatement& updateStm
|
|||||||
|
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
fTable->get_RowList().push_back(rowPtr);
|
fTable->get_RowList().push_back(rowPtr);
|
||||||
}
|
}
|
||||||
} // namespace dmlpackage
|
} // namespace dmlpackage
|
||||||
|
|||||||
@@ -36,71 +36,71 @@
|
|||||||
|
|
||||||
namespace dmlpackage
|
namespace dmlpackage
|
||||||
{
|
{
|
||||||
/** @brief concrete implementation of a CalpontDMLPackage
|
/** @brief concrete implementation of a CalpontDMLPackage
|
||||||
* Specifically for representing UPDATE DML Statements
|
* Specifically for representing UPDATE DML Statements
|
||||||
|
*/
|
||||||
|
class UpdateDMLPackage : public CalpontDMLPackage
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
/** @brief ctor
|
||||||
*/
|
*/
|
||||||
class UpdateDMLPackage : public CalpontDMLPackage
|
EXPORT UpdateDMLPackage();
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
/** @brief ctor
|
||||||
/** @brief ctor
|
*
|
||||||
*/
|
* @param schemaName the schema of the table being operated on
|
||||||
EXPORT UpdateDMLPackage();
|
* @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
|
/** @brief dtor
|
||||||
*
|
*/
|
||||||
* @param schemaName the schema of the table being operated on
|
EXPORT virtual ~UpdateDMLPackage();
|
||||||
* @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
|
/** @brief write a UpdateDMLPackage to a ByteStream
|
||||||
*/
|
*
|
||||||
EXPORT virtual ~UpdateDMLPackage();
|
* @param bytestream the ByteStream to write to
|
||||||
|
*/
|
||||||
|
EXPORT int write(messageqcpp::ByteStream& bytestream);
|
||||||
|
|
||||||
/** @brief write a UpdateDMLPackage to a ByteStream
|
/** @brief read a UpdateDMLPackage from a ByteStream
|
||||||
*
|
*
|
||||||
* @param bytestream the ByteStream to write to
|
* @param bytestream the ByteStream to read from
|
||||||
*/
|
*/
|
||||||
EXPORT int write(messageqcpp::ByteStream& bytestream);
|
EXPORT int read(messageqcpp::ByteStream& bytestream);
|
||||||
|
|
||||||
/** @brief read a UpdateDMLPackage from a ByteStream
|
/** @brief build a UpdateDMLPackage from a string buffer
|
||||||
*
|
*
|
||||||
* @param bytestream the ByteStream to read from
|
* @param buffer
|
||||||
*/
|
* @param columns the number of columns in the buffer
|
||||||
EXPORT int read(messageqcpp::ByteStream& bytestream);
|
* @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
|
/** @brief build a UpdateDMLPackage from a parsed UpdateSqlStatement
|
||||||
*
|
*
|
||||||
* @param buffer
|
* @param sqlStatement the parsed UpdateSqlStatement
|
||||||
* @param columns the number of columns in the buffer
|
*/
|
||||||
* @param rows the number of rows in the buffer
|
EXPORT int buildFromSqlStatement(SqlStatement& sqlStatement);
|
||||||
*/
|
|
||||||
EXPORT int buildFromBuffer(std::string& buffer, int columns, int rows);
|
|
||||||
|
|
||||||
/** @brief build a UpdateDMLPackage from a parsed UpdateSqlStatement
|
/** @brief build a InsertDMLPackage from MySQL buffer
|
||||||
*
|
*
|
||||||
* @param sqlStatement the parsed UpdateSqlStatement
|
* @param colNameList, tableValuesMap
|
||||||
*/
|
* @param rows the number of rows in the buffer
|
||||||
EXPORT int buildFromSqlStatement(SqlStatement& sqlStatement);
|
*/
|
||||||
|
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues);
|
||||||
/** @brief build a InsertDMLPackage from MySQL buffer
|
void buildUpdateFromMysqlBuffer(UpdateSqlStatement& updateStmt );
|
||||||
*
|
|
||||||
* @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
|
#undef EXPORT
|
||||||
|
|||||||
@@ -30,30 +30,30 @@ using namespace std;
|
|||||||
namespace dmlpackage
|
namespace dmlpackage
|
||||||
{
|
{
|
||||||
|
|
||||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int sessionID)
|
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int sessionID)
|
||||||
:fDMLStatement(dmlstatement),fSessionID(sessionID), fLogging(true),fLogending(true)
|
: fDMLStatement(dmlstatement), fSessionID(sessionID), fLogging(true), fLogending(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int stmttype, int sessionID)
|
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int stmttype, int sessionID)
|
||||||
:fDMLStatement(dmlstatement), fDMLStatementType(stmttype), fSessionID(sessionID),fLogging(true),fLogending(true)
|
: 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,
|
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int stmttype,
|
||||||
ColNameList& colNameList, TableValuesMap& tableValuesMap, NullValuesBitset& nullValues, int sessionID)
|
std::string tName, std::string schema,
|
||||||
:fDMLStatement(dmlstatement), fDMLStatementType(stmttype),
|
int rows, int columns, std::string buf,
|
||||||
fTableName(tName), fSchema(schema), fRows(rows), fColumns(columns),
|
int sessionID)
|
||||||
fColNameList(colNameList), fTableValuesMap(tableValuesMap), fNullValues(nullValues), fSessionID(sessionID), fLogging(true),fLogending(true)
|
: fDMLStatement(dmlstatement), fDMLStatementType(stmttype),
|
||||||
{}
|
fTableName(tName), fSchema(schema), fRows(rows), fColumns(columns),
|
||||||
|
fDataBuffer(buf), fSessionID(sessionID), fLogging(true), fLogending(true)
|
||||||
VendorDMLStatement::~VendorDMLStatement()
|
{}
|
||||||
{}
|
|
||||||
|
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()
|
||||||
|
{}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,152 +36,215 @@
|
|||||||
#endif
|
#endif
|
||||||
namespace dmlpackage
|
namespace dmlpackage
|
||||||
{
|
{
|
||||||
typedef std::vector<std::string> ColValuesList;
|
typedef std::vector<std::string> ColValuesList;
|
||||||
typedef std::vector<std::string> ColNameList;
|
typedef std::vector<std::string> ColNameList;
|
||||||
typedef std::map<uint32_t, ColValuesList> TableValuesMap;
|
typedef std::map<uint32_t, ColValuesList> TableValuesMap;
|
||||||
typedef std::bitset<4096> NullValuesBitset;
|
typedef std::bitset<4096> NullValuesBitset;
|
||||||
|
|
||||||
/** @brief describes the general interface
|
/** @brief describes the general interface
|
||||||
* and implementation of a Vendor DML Statement
|
* 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 Set the table name
|
||||||
/** @brief ctor
|
*/
|
||||||
*/
|
inline void set_TableName( std::string value )
|
||||||
EXPORT VendorDMLStatement(std::string dmlstatement, int sessionID);
|
{
|
||||||
|
fTableName = value;
|
||||||
/** @brief ctor
|
}
|
||||||
*/
|
|
||||||
EXPORT VendorDMLStatement(std::string dmlstatement, int stmttype, int sessionID);
|
|
||||||
|
|
||||||
/** @brief old ctor!
|
/** @brief Get the schema name
|
||||||
*/
|
*/
|
||||||
EXPORT VendorDMLStatement(std::string dmlstatement, int stmttype, std::string tName,
|
inline std::string get_SchemaName() const
|
||||||
std::string schema, int rows, int columns, std::string buf,
|
{
|
||||||
int sessionID);
|
return fSchema;
|
||||||
|
}
|
||||||
/** @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
|
/** @brief Set the schema name
|
||||||
*/
|
*/
|
||||||
inline std::string get_TableName() const { return fTableName; }
|
inline void set_SchemaName( std::string value )
|
||||||
|
{
|
||||||
|
fSchema = value;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Set the table name
|
/** @brief Get the DML statVendorDMLStatement classement type
|
||||||
*/
|
*/
|
||||||
inline void set_TableName( std::string value ) { fTableName = value; }
|
inline int get_DMLStatementType() const
|
||||||
|
{
|
||||||
|
return fDMLStatementType;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Get the schema name
|
/** @brief Set the DML statement type
|
||||||
*/
|
*/
|
||||||
inline std::string get_SchemaName() const { return fSchema; }
|
inline void set_DMLStatementType( int value )
|
||||||
|
{
|
||||||
|
fDMLStatementType = value;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Set the schema name
|
/** @brief Get the DML statement
|
||||||
*/
|
*/
|
||||||
inline void set_SchemaName( std::string value ) { fSchema = value; }
|
inline const std::string get_DMLStatement() const
|
||||||
|
{
|
||||||
|
return fDMLStatement;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Get the DML statVendorDMLStatement classement type
|
/** @brief Set the DML statVendorDMLStatement classement
|
||||||
*/
|
*/
|
||||||
inline int get_DMLStatementType() const { return fDMLStatementType; }
|
inline void set_DMLStatement( std::string dmlStatement )
|
||||||
|
{
|
||||||
|
fDMLStatement = dmlStatement;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Set the DML statement type
|
/** @brief Get the number of rows
|
||||||
*/
|
*/
|
||||||
inline void set_DMLStatementType( int value ) { fDMLStatementType = value; }
|
inline int get_Rows() const
|
||||||
|
{
|
||||||
|
return fRows;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Get the DML statement
|
/** @brief Set the number of rows
|
||||||
*/
|
*/
|
||||||
inline const std::string get_DMLStatement() const { return fDMLStatement; }
|
inline void set_Rows( int value )
|
||||||
|
{
|
||||||
|
fRows = value;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Set the DML statVendorDMLStatement classement
|
/** @brief Get the number of columns
|
||||||
*/
|
*/
|
||||||
inline void set_DMLStatement( std::string dmlStatement ) { fDMLStatement = dmlStatement; }
|
inline int get_Columns() const
|
||||||
|
{
|
||||||
|
return fColumns;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Get the number of rows
|
/** @brief Set the number of columns
|
||||||
*/
|
*/
|
||||||
inline int get_Rows() const { return fRows; }
|
inline void set_Columns( int value )
|
||||||
|
{
|
||||||
|
fColumns = value;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Set the number of rows
|
/** @brief Get the data buffer
|
||||||
*/
|
*/
|
||||||
inline void set_Rows( int value ) { fRows = value; }
|
inline std::string& get_DataBuffer()
|
||||||
|
{
|
||||||
|
return fDataBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Get the number of columns
|
/** @brief Set the data buffer
|
||||||
*/
|
*/
|
||||||
inline int get_Columns() const { return fColumns; }
|
inline void set_DataBuffer( std::string value )
|
||||||
|
{
|
||||||
|
fDataBuffer = value;
|
||||||
|
}
|
||||||
|
/** @brief Get the session ID
|
||||||
|
*/
|
||||||
|
inline int get_SessionID()
|
||||||
|
{
|
||||||
|
return fSessionID;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Set the number of columns
|
inline NullValuesBitset& get_nullValues()
|
||||||
*/
|
{
|
||||||
inline void set_Columns( int value ) { fColumns = value; }
|
return fNullValues;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Get the data buffer
|
/** @brief Set the session ID
|
||||||
*/
|
*/
|
||||||
inline std::string& get_DataBuffer() { return fDataBuffer; }
|
inline void set_SessionID( int value )
|
||||||
|
{
|
||||||
|
fSessionID = value;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Set the data buffer
|
inline ColNameList& get_ColNames()
|
||||||
*/
|
{
|
||||||
inline void set_DataBuffer( std::string value ) { fDataBuffer= value; }
|
return fColNameList;
|
||||||
/** @brief Get the session ID
|
}
|
||||||
*/
|
inline TableValuesMap& get_values()
|
||||||
inline int get_SessionID() { return fSessionID; }
|
{
|
||||||
|
return fTableValuesMap;
|
||||||
|
}
|
||||||
|
/** @brief get the logging flag
|
||||||
|
*/
|
||||||
|
inline const bool get_Logging() const
|
||||||
|
{
|
||||||
|
return fLogging;
|
||||||
|
}
|
||||||
|
|
||||||
inline NullValuesBitset& get_nullValues() { return fNullValues; }
|
/** @brief set the logging flag
|
||||||
|
*
|
||||||
|
* @param logging the logging flag to set
|
||||||
|
*/
|
||||||
|
inline void set_Logging( bool logging )
|
||||||
|
{
|
||||||
|
fLogging = logging;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Set the session ID
|
/** @brief get the logging flag
|
||||||
*/
|
*/
|
||||||
inline void set_SessionID( int value ) { fSessionID = value; }
|
inline const bool get_Logending() const
|
||||||
|
{
|
||||||
|
return fLogending;
|
||||||
|
}
|
||||||
|
|
||||||
inline ColNameList& get_ColNames() { return fColNameList; }
|
/** @brief set the logending flag
|
||||||
inline TableValuesMap& get_values() { return fTableValuesMap; }
|
*
|
||||||
/** @brief get the logging flag
|
* @param logending the logending flag to set
|
||||||
*/
|
*/
|
||||||
inline const bool get_Logging() const { return fLogging; }
|
inline void set_Logending( bool logending )
|
||||||
|
{
|
||||||
/** @brief set the logging flag
|
fLogending = logending;
|
||||||
*
|
}
|
||||||
* @param logging the logging flag to set
|
|
||||||
*/
|
|
||||||
inline void set_Logging( bool logging )
|
|
||||||
{
|
|
||||||
fLogging = logging;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @brief get the logging flag
|
protected:
|
||||||
*/
|
|
||||||
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:
|
private:
|
||||||
std::string fDMLStatement;
|
std::string fDMLStatement;
|
||||||
int fDMLStatementType;
|
int fDMLStatementType;
|
||||||
std::string fTableName;
|
std::string fTableName;
|
||||||
std::string fSchema;
|
std::string fSchema;
|
||||||
int fRows;
|
int fRows;
|
||||||
int fColumns;
|
int fColumns;
|
||||||
std::string fDataBuffer;
|
std::string fDataBuffer;
|
||||||
ColNameList fColNameList;
|
ColNameList fColNameList;
|
||||||
TableValuesMap fTableValuesMap;
|
TableValuesMap fTableValuesMap;
|
||||||
NullValuesBitset fNullValues;
|
NullValuesBitset fNullValues;
|
||||||
int fSessionID;
|
int fSessionID;
|
||||||
bool fLogging;
|
bool fLogging;
|
||||||
bool fLogending;
|
bool fLogending;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,97 +1,100 @@
|
|||||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
as published by the Free Software Foundation; version 2 of
|
as published by the Free Software Foundation; version 2 of
|
||||||
the License.
|
the License.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
MA 02110-1301, USA. */
|
MA 02110-1301, USA. */
|
||||||
|
|
||||||
// $Id: autoincrementdata.h 525 2010-01-19 23:18:05Z xlou $
|
// $Id: autoincrementdata.h 525 2010-01-19 23:18:05Z xlou $
|
||||||
//
|
//
|
||||||
/** @file */
|
/** @file */
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
#include <boost/scoped_array.hpp>
|
#include <boost/scoped_array.hpp>
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
|
|
||||||
#include "autoincrementdata.h"
|
#include "autoincrementdata.h"
|
||||||
|
|
||||||
/*static*/
|
/*static*/
|
||||||
boost::mutex AutoincrementData::map_mutex;
|
boost::mutex AutoincrementData::map_mutex;
|
||||||
/*static*/
|
/*static*/
|
||||||
AutoincrementData::AutoincDataMap AutoincrementData::fAutoincDataMap;
|
AutoincrementData::AutoincDataMap AutoincrementData::fAutoincDataMap;
|
||||||
/* static */
|
/* static */
|
||||||
AutoincrementData* AutoincrementData::makeAutoincrementData(uint32_t sessionID)
|
AutoincrementData* AutoincrementData::makeAutoincrementData(uint32_t sessionID)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(map_mutex);
|
boost::mutex::scoped_lock lock(map_mutex);
|
||||||
AutoincrementData* instance;
|
AutoincrementData* instance;
|
||||||
AutoincDataMap::const_iterator it = fAutoincDataMap.find(sessionID);
|
AutoincDataMap::const_iterator it = fAutoincDataMap.find(sessionID);
|
||||||
|
|
||||||
if (it == fAutoincDataMap.end())
|
if (it == fAutoincDataMap.end())
|
||||||
{
|
{
|
||||||
instance = new AutoincrementData();
|
instance = new AutoincrementData();
|
||||||
fAutoincDataMap[sessionID] = instance;
|
fAutoincDataMap[sessionID] = instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
void AutoincrementData::removeAutoincrementData(uint32_t sessionID)
|
void AutoincrementData::removeAutoincrementData(uint32_t sessionID)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(map_mutex);
|
boost::mutex::scoped_lock lock(map_mutex);
|
||||||
AutoincDataMap::iterator it = fAutoincDataMap.find(sessionID);
|
AutoincDataMap::iterator it = fAutoincDataMap.find(sessionID);
|
||||||
if (it != fAutoincDataMap.end())
|
|
||||||
{
|
if (it != fAutoincDataMap.end())
|
||||||
delete (*it).second;
|
{
|
||||||
fAutoincDataMap.erase(it);
|
delete (*it).second;
|
||||||
}
|
fAutoincDataMap.erase(it);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
AutoincrementData::AutoincrementData()
|
|
||||||
{
|
AutoincrementData::AutoincrementData()
|
||||||
}
|
{
|
||||||
AutoincrementData::~AutoincrementData()
|
}
|
||||||
{
|
AutoincrementData::~AutoincrementData()
|
||||||
}
|
{
|
||||||
|
}
|
||||||
void AutoincrementData::setNextValue(uint32_t columnOid, long long nextValue)
|
|
||||||
{
|
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)
|
|
||||||
{
|
long long AutoincrementData::getNextValue(uint32_t columnOid)
|
||||||
boost::mutex::scoped_lock lk(fOIDnextvalLock);
|
{
|
||||||
long long nextValue = 0;
|
boost::mutex::scoped_lock lk(fOIDnextvalLock);
|
||||||
OIDNextValue::iterator it = fOidNextValueMap.find(columnOid);
|
long long nextValue = 0;
|
||||||
if (it != fOidNextValueMap.end())
|
OIDNextValue::iterator it = fOidNextValueMap.find(columnOid);
|
||||||
{
|
|
||||||
nextValue = it->second;
|
if (it != fOidNextValueMap.end())
|
||||||
}
|
{
|
||||||
return nextValue;
|
nextValue = it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoincrementData::OIDNextValue & AutoincrementData::getOidNextValueMap()
|
return nextValue;
|
||||||
{
|
}
|
||||||
boost::mutex::scoped_lock lk(fOIDnextvalLock);
|
|
||||||
|
AutoincrementData::OIDNextValue& AutoincrementData::getOidNextValueMap()
|
||||||
return fOidNextValueMap;
|
{
|
||||||
}
|
boost::mutex::scoped_lock lk(fOIDnextvalLock);
|
||||||
// vim:ts=4 sw=4:
|
|
||||||
|
return fOidNextValueMap;
|
||||||
|
}
|
||||||
|
// vim:ts=4 sw=4:
|
||||||
|
|||||||
@@ -14,42 +14,42 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
MA 02110-1301, USA. */
|
MA 02110-1301, USA. */
|
||||||
|
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
/** @file */
|
/** @file */
|
||||||
|
|
||||||
#ifndef AUTOINCREMENTDATA_H__
|
#ifndef AUTOINCREMENTDATA_H__
|
||||||
#define AUTOINCREMENTDATA_H__
|
#define AUTOINCREMENTDATA_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#include <boost/thread/condition.hpp>
|
#include <boost/thread/condition.hpp>
|
||||||
|
|
||||||
|
|
||||||
class AutoincrementData
|
class AutoincrementData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::map <uint32_t, AutoincrementData*> AutoincDataMap;
|
typedef std::map <uint32_t, AutoincrementData*> AutoincDataMap;
|
||||||
typedef std::map<uint32_t, long long> OIDNextValue;
|
typedef std::map<uint32_t, long long> OIDNextValue;
|
||||||
static AutoincrementData* makeAutoincrementData(uint32_t sessionID = 0);
|
static AutoincrementData* makeAutoincrementData(uint32_t sessionID = 0);
|
||||||
static void removeAutoincrementData(uint32_t sessionID = 0);
|
static void removeAutoincrementData(uint32_t sessionID = 0);
|
||||||
void setNextValue(uint32_t columnOid, long long nextValue);
|
void setNextValue(uint32_t columnOid, long long nextValue);
|
||||||
long long getNextValue(uint32_t columnOid);
|
long long getNextValue(uint32_t columnOid);
|
||||||
OIDNextValue & getOidNextValueMap();
|
OIDNextValue& getOidNextValueMap();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Constuctors */
|
/** Constuctors */
|
||||||
explicit AutoincrementData();
|
explicit AutoincrementData();
|
||||||
explicit AutoincrementData(const AutoincrementData& rhs);
|
explicit AutoincrementData(const AutoincrementData& rhs);
|
||||||
~AutoincrementData();
|
~AutoincrementData();
|
||||||
|
|
||||||
static boost::mutex map_mutex;
|
static boost::mutex map_mutex;
|
||||||
static AutoincDataMap fAutoincDataMap;
|
static AutoincDataMap fAutoincDataMap;
|
||||||
OIDNextValue fOidNextValueMap;
|
OIDNextValue fOidNextValueMap;
|
||||||
boost::mutex fOIDnextvalLock;
|
boost::mutex fOIDnextvalLock;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim:ts=4 sw=4:
|
// vim:ts=4 sw=4:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -50,7 +50,7 @@ class CommandPackageProcessor : public DMLPackageProcessor
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
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
|
/** @brief process an CommandDMLPackage
|
||||||
*
|
*
|
||||||
* @param cpackage the CommandDMLPackage to process
|
* @param cpackage the CommandDMLPackage to process
|
||||||
@@ -60,17 +60,17 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void viewTableLock(const dmlpackage::CalpontDMLPackage& cpackage,
|
void viewTableLock(const dmlpackage::CalpontDMLPackage& cpackage,
|
||||||
DMLResult& result );
|
DMLResult& result );
|
||||||
void clearTableLock(uint64_t uniqueId,
|
void clearTableLock(uint64_t uniqueId,
|
||||||
const dmlpackage::CalpontDMLPackage& cpackage,
|
const dmlpackage::CalpontDMLPackage& cpackage,
|
||||||
DMLResult& result );
|
DMLResult& result );
|
||||||
void establishTableLockToClear(uint64_t tableLockID,
|
void establishTableLockToClear(uint64_t tableLockID,
|
||||||
BRM::TableLockInfo& lockInfo);
|
BRM::TableLockInfo& lockInfo);
|
||||||
|
|
||||||
// Tracks active cleartablelock commands by storing set of table lock IDs
|
// Tracks active cleartablelock commands by storing set of table lock IDs
|
||||||
static std::set<uint64_t> fActiveClearTableLockCmds;
|
static std::set<uint64_t> fActiveClearTableLockCmds;
|
||||||
static boost::mutex fActiveClearTableLockCmdMutex;
|
static boost::mutex fActiveClearTableLockCmdMutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
1560
dbcon/dmlpackageproc/deletepackageprocessor.cpp
Executable file → Normal file
1560
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:
|
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
|
/** @brief process a DeleteDMLPackage
|
||||||
*
|
*
|
||||||
* @param cpackage the delete dml package to process
|
* @param cpackage the delete dml package to process
|
||||||
*/
|
*/
|
||||||
EXPORT DMLResult processPackage(dmlpackage::CalpontDMLPackage& cpackage);
|
EXPORT DMLResult processPackage(dmlpackage::CalpontDMLPackage& cpackage);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/** @brief delete a row
|
/** @brief delete a row
|
||||||
*
|
*
|
||||||
* @param txnID the transaction id
|
* @param txnID the transaction id
|
||||||
* @param tablePtr a pointer to the table that is being operated on
|
* @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 rowIDList upon return containts the row ids of the rows deleted
|
||||||
* @param colOldValuesList upon return contains the values the were delete
|
* @param colOldValuesList upon return contains the values the were delete
|
||||||
* @param result upon return will containt the result of the operation
|
* @param result upon return will containt the result of the operation
|
||||||
bool deleteRows(execplan::CalpontSystemCatalog::SCN txnID, dmlpackage::DMLTable* tablePtr,
|
bool deleteRows(execplan::CalpontSystemCatalog::SCN txnID, dmlpackage::DMLTable* tablePtr,
|
||||||
WriteEngine::RIDList& rowIDList, WriteEngine::ColValueList& colOldValuesList,
|
WriteEngine::RIDList& rowIDList, WriteEngine::ColValueList& colOldValuesList,
|
||||||
DMLResult& result);
|
DMLResult& result);
|
||||||
*/
|
*/
|
||||||
bool processRowgroup(messageqcpp::ByteStream & aRowGroup, DMLResult& result, const uint64_t uniqueId, dmlpackage::CalpontDMLPackage& cpackage, std::map<unsigned, bool>& pmStateDel,
|
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);
|
bool isMeta = false, uint32_t dbroot = 1);
|
||||||
|
|
||||||
|
|
||||||
/** @brief add all rows if we have no filter for the delete
|
/** @brief add all rows if we have no filter for the delete
|
||||||
*
|
*
|
||||||
* @param tablePtr a pointer to the table that is being operated on
|
* @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);
|
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);
|
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
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#ifndef DMLPACKAGEPROCESSOR_H
|
#ifndef DMLPACKAGEPROCESSOR_H
|
||||||
#define DMLPACKAGEPROCESSOR_H
|
#define DMLPACKAGEPROCESSOR_H
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -111,65 +111,80 @@ public:
|
|||||||
logging::Message message;
|
logging::Message message;
|
||||||
/** @brief the rowCount
|
/** @brief the rowCount
|
||||||
*/
|
*/
|
||||||
long long rowCount;
|
long long rowCount;
|
||||||
std::string tableLockInfo;
|
std::string tableLockInfo;
|
||||||
// query stats;
|
// query stats;
|
||||||
std::string queryStats;
|
std::string queryStats;
|
||||||
std::string extendedStats;
|
std::string extendedStats;
|
||||||
std::string miniStats;
|
std::string miniStats;
|
||||||
querystats::QueryStats stats;
|
querystats::QueryStats stats;
|
||||||
|
|
||||||
DMLResult():result(NO_ERROR),rowCount(0){};
|
DMLResult(): result(NO_ERROR), rowCount(0) {};
|
||||||
};
|
};
|
||||||
/** @brief a structure to hold a date
|
/** @brief a structure to hold a date
|
||||||
*/
|
*/
|
||||||
struct Date
|
struct Date
|
||||||
{
|
{
|
||||||
unsigned spare : 6;
|
unsigned spare : 6;
|
||||||
unsigned day : 6;
|
unsigned day : 6;
|
||||||
unsigned month : 4;
|
unsigned month : 4;
|
||||||
unsigned year : 16;
|
unsigned year : 16;
|
||||||
// NULL column value = 0xFFFFFFFE
|
// NULL column value = 0xFFFFFFFE
|
||||||
Date( ) { year = 0xFFFF; month = 0xF; day = 0x3F; spare = 0x3E;}
|
Date( )
|
||||||
|
{
|
||||||
|
year = 0xFFFF;
|
||||||
|
month = 0xF;
|
||||||
|
day = 0x3F;
|
||||||
|
spare = 0x3E;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
/** @brief a structure to hold a datetime
|
/** @brief a structure to hold a datetime
|
||||||
*/
|
*/
|
||||||
struct dateTime
|
struct dateTime
|
||||||
{
|
{
|
||||||
unsigned msecond : 20;
|
unsigned msecond : 20;
|
||||||
unsigned second : 6;
|
unsigned second : 6;
|
||||||
unsigned minute : 6;
|
unsigned minute : 6;
|
||||||
unsigned hour : 6;
|
unsigned hour : 6;
|
||||||
unsigned day : 6;
|
unsigned day : 6;
|
||||||
unsigned month : 4;
|
unsigned month : 4;
|
||||||
unsigned year : 16;
|
unsigned year : 16;
|
||||||
// NULL column value = 0xFFFFFFFFFFFFFFFE
|
// NULL column value = 0xFFFFFFFFFFFFFFFE
|
||||||
dateTime( ) { year = 0xFFFF; month = 0xF; day = 0x3F; hour = 0x3F; minute = 0x3F; second = 0x3F;
|
dateTime( )
|
||||||
msecond = 0xFFFFE; }
|
{
|
||||||
|
year = 0xFFFF;
|
||||||
|
month = 0xF;
|
||||||
|
day = 0x3F;
|
||||||
|
hour = 0x3F;
|
||||||
|
minute = 0x3F;
|
||||||
|
second = 0x3F;
|
||||||
|
msecond = 0xFFFFE;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @brief ctor
|
/** @brief ctor
|
||||||
*/
|
*/
|
||||||
DMLPackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : fEC(0), DMLLoggingId(21), fRollbackPending(false), fDebugLevel(NONE)
|
DMLPackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : fEC(0), DMLLoggingId(21), fRollbackPending(false), fDebugLevel(NONE)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
fWEClient = new WriteEngine::WEClients(WriteEngine::WEClients::DMLPROC);
|
{
|
||||||
//std::cout << "In DMLPackageProcessor constructor " << this << std::endl;
|
fWEClient = new WriteEngine::WEClients(WriteEngine::WEClients::DMLPROC);
|
||||||
fPMCount = fWEClient->getPmCount();
|
//std::cout << "In DMLPackageProcessor constructor " << this << std::endl;
|
||||||
}
|
fPMCount = fWEClient->getPmCount();
|
||||||
catch (...)
|
}
|
||||||
{
|
catch (...)
|
||||||
std::cout << "Cannot make connection to WES" << std::endl;
|
{
|
||||||
}
|
std::cout << "Cannot make connection to WES" << std::endl;
|
||||||
|
}
|
||||||
oam::OamCache * oamCache = oam::OamCache::makeOamCache();
|
|
||||||
fDbRootPMMap = oamCache->getDBRootToPMMap();
|
oam::OamCache* oamCache = oam::OamCache::makeOamCache();
|
||||||
fDbrm = aDbrm;
|
fDbRootPMMap = oamCache->getDBRootToPMMap();
|
||||||
fSessionID = sid;
|
fDbrm = aDbrm;
|
||||||
fExeMgr = new execplan::ClientRotator(fSessionID, "ExeMgr");
|
fSessionID = sid;
|
||||||
//std::cout << " fSessionID is " << fSessionID << std::endl;
|
fExeMgr = new execplan::ClientRotator(fSessionID, "ExeMgr");
|
||||||
fExeMgr->connect(0.005);
|
//std::cout << " fSessionID is " << fSessionID << std::endl;
|
||||||
}
|
fExeMgr->connect(0.005);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -179,34 +194,49 @@ public:
|
|||||||
|
|
||||||
/** @brief Is it required to debug
|
/** @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
|
* @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);
|
//int rollBackTransaction(uint64_t uniqueId, uint32_t txnID, uint32_t sessionID, std::string & errorMsg);
|
||||||
/**
|
/**
|
||||||
* @brief Set debug level
|
* @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
|
* @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
|
/** @brief process the dml package
|
||||||
*
|
*
|
||||||
* @param cpackage the CalpontDMLPackage to process
|
* @param cpackage the CalpontDMLPackage to process
|
||||||
*/
|
*/
|
||||||
virtual DMLResult processPackage(dmlpackage::CalpontDMLPackage& cpackage) = 0;
|
virtual DMLResult processPackage(dmlpackage::CalpontDMLPackage& cpackage) = 0;
|
||||||
|
|
||||||
inline void setRM ( joblist::ResourceManager* frm) { fRM = frm; };
|
|
||||||
|
|
||||||
EXPORT int rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, std::string & errorMsg);
|
inline void setRM ( joblist::ResourceManager* frm)
|
||||||
|
{
|
||||||
EXPORT int rollBackBatchAutoOnTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, const uint32_t tableOid, std::string & errorMsg);
|
fRM = frm;
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
/**
|
/**
|
||||||
* @brief convert a columns data, represnted as a string, to it's native
|
* @brief convert a columns data, represnted as a string, to it's native
|
||||||
* data type
|
* data type
|
||||||
@@ -222,7 +252,7 @@ public:
|
|||||||
* @param type the columns database type
|
* @param type the columns database type
|
||||||
* @param data the columns string representation of it's data
|
* @param data the columns string representation of it's data
|
||||||
*/
|
*/
|
||||||
//static std::string dateToString( int datevalue );
|
//static std::string dateToString( int datevalue );
|
||||||
/** @brief validate numerical string
|
/** @brief validate numerical string
|
||||||
*
|
*
|
||||||
* @param result the result structure
|
* @param result the result structure
|
||||||
@@ -262,11 +292,17 @@ public:
|
|||||||
|
|
||||||
/** @brief Access the rollback pending flag
|
/** @brief Access the rollback pending flag
|
||||||
*/
|
*/
|
||||||
bool getRollbackPending() {return fRollbackPending;}
|
bool getRollbackPending()
|
||||||
|
{
|
||||||
|
return fRollbackPending;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Set the rollback pending flag
|
/** @brief Set the rollback pending flag
|
||||||
*/
|
*/
|
||||||
void setRollbackPending(bool rollback) {fRollbackPending = rollback;}
|
void setRollbackPending(bool rollback)
|
||||||
|
{
|
||||||
|
fRollbackPending = rollback;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** @brief update the indexes on the target table
|
/** @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
|
* @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,
|
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,
|
std::vector<WriteEngine::RID> ridList,
|
||||||
WriteEngine::ColValueList& colValuesList, std::vector<std::string>& colNameList, const char updateFlag,
|
WriteEngine::ColValueList& colValuesList, std::vector<std::string>& colNameList, const char updateFlag,
|
||||||
std::vector<dicStrValues>& dicStrValCols );
|
std::vector<dicStrValues>& dicStrValCols );
|
||||||
@@ -311,19 +347,19 @@ protected:
|
|||||||
* @param result the result structure
|
* @param result the result structure
|
||||||
*/
|
*/
|
||||||
bool violatesUniqueConstraint( const dmlpackage::RowList& rows,
|
bool violatesUniqueConstraint( const dmlpackage::RowList& rows,
|
||||||
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
||||||
unsigned int sessionID,
|
unsigned int sessionID,
|
||||||
DMLResult& result);
|
DMLResult& result);
|
||||||
|
|
||||||
/** @brief validate that the column does not violate a check constraint
|
/** @brief validate that the column does not violate a check constraint
|
||||||
*
|
*
|
||||||
* @param column the column to validate
|
* @param column the column to validate
|
||||||
* @param result the result structure
|
* @param result the result structure
|
||||||
*/
|
*/
|
||||||
bool violatesCheckConstraint( const dmlpackage::RowList& rows,
|
bool violatesCheckConstraint( const dmlpackage::RowList& rows,
|
||||||
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
||||||
unsigned int sessionID, unsigned int colOffset,
|
unsigned int sessionID, unsigned int colOffset,
|
||||||
DMLResult& result );
|
DMLResult& result );
|
||||||
|
|
||||||
/** @brief validate that the column does not violate a not null constraint
|
/** @brief validate that the column does not violate a not null constraint
|
||||||
*
|
*
|
||||||
@@ -333,19 +369,19 @@ protected:
|
|||||||
*/
|
*/
|
||||||
bool violatesNotNullConstraint( const dmlpackage::RowList& rows, unsigned int colOffset,
|
bool violatesNotNullConstraint( const dmlpackage::RowList& rows, unsigned int colOffset,
|
||||||
DMLResult& result );
|
DMLResult& result );
|
||||||
|
|
||||||
/** @brief validate that the column does not violate a reference (foreign key) constraint
|
/** @brief validate that the column does not violate a reference (foreign key) constraint
|
||||||
*
|
*
|
||||||
* @param rows the row set to validate
|
* @param rows the row set to validate
|
||||||
* @param colOffset the offset of this column in the row
|
* @param colOffset the offset of this column in the row
|
||||||
* @param constraintInfo the column constraint infomation
|
* @param constraintInfo the column constraint infomation
|
||||||
* @param result the result structure
|
* @param result the result structure
|
||||||
*/
|
*/
|
||||||
bool violatesReferenceConstraint( const dmlpackage::RowList& rows,
|
bool violatesReferenceConstraint( const dmlpackage::RowList& rows,
|
||||||
unsigned int colOffset,
|
unsigned int colOffset,
|
||||||
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
||||||
DMLResult& result );
|
DMLResult& result );
|
||||||
|
|
||||||
/** @brief validate that non of the rows deleted from this table violate a reference
|
/** @brief validate that non of the rows deleted from this table violate a reference
|
||||||
* (foreign key) constraint of the reference table.
|
* (foreign key) constraint of the reference table.
|
||||||
*
|
*
|
||||||
@@ -353,53 +389,53 @@ protected:
|
|||||||
* @param table the table name
|
* @param table the table name
|
||||||
* @param rows the lists of rows to check column constraints on
|
* @param rows the lists of rows to check column constraints on
|
||||||
* @param result the result structure
|
* @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,
|
|
||||||
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
|
|
||||||
*/
|
*/
|
||||||
bool violatesReferenceConstraint_PK( const WriteEngine::ColValueList& oldValueList,
|
bool violatesPKRefConnstraint ( uint32_t sessionID,
|
||||||
const execplan::CalpontSystemCatalog::ColType& colType,
|
const std::string& schema,
|
||||||
unsigned int colOffset,
|
const std::string& table,
|
||||||
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
const dmlpackage::RowList& rows,
|
||||||
DMLResult& result );
|
const WriteEngine::ColValueList& oldValueList,
|
||||||
|
DMLResult& result );
|
||||||
|
|
||||||
bool violatesReferenceConstraint_PK( std::vector<void *>& oldValueList,
|
bool violatesPKRefConnstraint ( uint32_t sessionID,
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
bool violatesReferenceConstraint_PK( const WriteEngine::ColValueList& oldValueList,
|
||||||
|
const execplan::CalpontSystemCatalog::ColType& colType,
|
||||||
|
unsigned int colOffset,
|
||||||
|
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
||||||
|
DMLResult& result );
|
||||||
|
|
||||||
|
bool violatesReferenceConstraint_PK( std::vector<void*>& oldValueList,
|
||||||
const int totalRows,
|
const int totalRows,
|
||||||
const execplan::CalpontSystemCatalog::ColType& colType,
|
const execplan::CalpontSystemCatalog::ColType& colType,
|
||||||
unsigned int colOffset,
|
unsigned int colOffset,
|
||||||
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
||||||
DMLResult& result );
|
DMLResult& result );
|
||||||
|
|
||||||
/** @brief validate that none of the columns in the update row(s) violate
|
/** @brief validate that none of the columns in the update row(s) violate
|
||||||
* any reference constraints of the foreign key table
|
* any reference constraints of the foreign key table
|
||||||
*
|
*
|
||||||
* @param schema the schema name
|
* @param schema the schema name
|
||||||
* @param table the table name
|
* @param table the table name
|
||||||
* @param rows the lists of rows to check column constraints on
|
* @param rows the lists of rows to check column constraints on
|
||||||
* @param result the result structure
|
* @param result the result structure
|
||||||
*/
|
*/
|
||||||
bool violatesUpdtRefConstraints( uint32_t sessionID,
|
bool violatesUpdtRefConstraints( uint32_t sessionID,
|
||||||
const std::string& schema,
|
const std::string& schema,
|
||||||
const std::string& table,
|
const std::string& table,
|
||||||
const dmlpackage::RowList& rows,
|
const dmlpackage::RowList& rows,
|
||||||
DMLResult& result );
|
DMLResult& result );
|
||||||
|
|
||||||
|
|
||||||
@@ -409,13 +445,13 @@ protected:
|
|||||||
* @param colOffset the offset of this column in the row
|
* @param colOffset the offset of this column in the row
|
||||||
* @param constraintInfo the column constraint infomation
|
* @param constraintInfo the column constraint infomation
|
||||||
* @param result the result structure
|
* @param result the result structure
|
||||||
*/
|
*/
|
||||||
bool violatesReferenceConstraint_updt( const dmlpackage::RowList& rows,
|
bool violatesReferenceConstraint_updt( const dmlpackage::RowList& rows,
|
||||||
unsigned int colOffset,
|
unsigned int colOffset,
|
||||||
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
|
||||||
DMLResult& result );
|
DMLResult& result );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief get the column list for the supplied table
|
/** @brief get the column list for the supplied table
|
||||||
*
|
*
|
||||||
* @param schema the schema name
|
* @param schema the schema name
|
||||||
@@ -423,8 +459,8 @@ protected:
|
|||||||
* @param colList ColumnList to fill with the columns for the supplied table
|
* @param colList ColumnList to fill with the columns for the supplied table
|
||||||
*/
|
*/
|
||||||
void getColumnsForTable( uint32_t sessionID, std::string schema, std::string table, dmlpackage::ColumnList& colList );
|
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 rid in:the absolute rid out: relative rid in a segement file
|
||||||
* @param dbRoot,partition, segment the extent information obtained from rid
|
* @param dbRoot,partition, segment the extent information obtained from rid
|
||||||
@@ -432,25 +468,25 @@ protected:
|
|||||||
* @param startDBRoot the dbroot this table starts
|
* @param startDBRoot the dbroot this table starts
|
||||||
* @param dbrootCnt the number of dbroot in db
|
* @param dbrootCnt the number of dbroot in db
|
||||||
*/
|
*/
|
||||||
void convertRidToColumn(uint64_t& rid, unsigned& dbRoot, unsigned& partition,
|
void convertRidToColumn(uint64_t& rid, unsigned& dbRoot, unsigned& partition,
|
||||||
unsigned& segment, unsigned filesPerColumnPartition,
|
unsigned& segment, unsigned filesPerColumnPartition,
|
||||||
unsigned extentsPerSegmentFile, unsigned extentRows,
|
unsigned extentsPerSegmentFile, unsigned extentRows,
|
||||||
unsigned startDBRoot, unsigned dbrootCnt,
|
unsigned startDBRoot, unsigned dbrootCnt,
|
||||||
const unsigned startPartitionNum );
|
const unsigned startPartitionNum );
|
||||||
|
|
||||||
inline bool isDictCol ( execplan::CalpontSystemCatalog::ColType colType )
|
inline bool isDictCol ( execplan::CalpontSystemCatalog::ColType colType )
|
||||||
{
|
{
|
||||||
if (((colType.colDataType == execplan::CalpontSystemCatalog::CHAR) && (colType.colWidth > 8))
|
if (((colType.colDataType == execplan::CalpontSystemCatalog::CHAR) && (colType.colWidth > 8))
|
||||||
|| ((colType.colDataType == execplan::CalpontSystemCatalog::VARCHAR) && (colType.colWidth > 7))
|
|| ((colType.colDataType == execplan::CalpontSystemCatalog::VARCHAR) && (colType.colWidth > 7))
|
||||||
|| ((colType.colDataType == execplan::CalpontSystemCatalog::DECIMAL) && (colType.precision > 18))
|
|| ((colType.colDataType == execplan::CalpontSystemCatalog::DECIMAL) && (colType.precision > 18))
|
||||||
|| (colType.colDataType == execplan::CalpontSystemCatalog::VARBINARY)
|
|| (colType.colDataType == execplan::CalpontSystemCatalog::VARBINARY)
|
||||||
|| (colType.colDataType == execplan::CalpontSystemCatalog::BLOB)
|
|| (colType.colDataType == execplan::CalpontSystemCatalog::BLOB)
|
||||||
|| (colType.colDataType == execplan::CalpontSystemCatalog::TEXT))
|
|| (colType.colDataType == execplan::CalpontSystemCatalog::TEXT))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -460,21 +496,21 @@ protected:
|
|||||||
* @returns error string
|
* @returns error string
|
||||||
*/
|
*/
|
||||||
std::string projectTableErrCodeToMsg(uint32_t ec);
|
std::string projectTableErrCodeToMsg(uint32_t ec);
|
||||||
|
|
||||||
// bool validateNextValue(execplan::CalpontSystemCatalog::ColType colType, int64_t value, bool & offByOne);
|
// 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 commitTransaction(uint64_t uniqueId, BRM::TxnID txnID);
|
||||||
int commitBatchAutoOnTransaction(uint64_t uniqueId, BRM::TxnID txnID, const uint32_t tableOid, std::string & errorMsg);
|
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 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 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 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 endTransaction (uint64_t uniqueId, BRM::TxnID txnID, bool success);
|
||||||
|
|
||||||
/** @brief the Session Manager interface
|
/** @brief the Session Manager interface
|
||||||
*/
|
*/
|
||||||
execplan::SessionManager fSessionManager;
|
execplan::SessionManager fSessionManager;
|
||||||
joblist::DistributedEngineComm *fEC;
|
joblist::DistributedEngineComm* fEC;
|
||||||
joblist::ResourceManager* fRM;
|
joblist::ResourceManager* fRM;
|
||||||
char* strlower(char* in);
|
char* strlower(char* in);
|
||||||
uint32_t fSessionID;
|
uint32_t fSessionID;
|
||||||
@@ -485,14 +521,14 @@ protected:
|
|||||||
boost::shared_ptr<std::map<int, int> > fDbRootPMMap;
|
boost::shared_ptr<std::map<int, int> > fDbRootPMMap;
|
||||||
oam::Oam fOam;
|
oam::Oam fOam;
|
||||||
bool fRollbackPending; // When set, any derived object should stop what it's doing and cleanup in preparation for a Rollback
|
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:
|
private:
|
||||||
|
|
||||||
/** @brief clean beginning and ending glitches and spaces from string
|
/** @brief clean beginning and ending glitches and spaces from string
|
||||||
*
|
*
|
||||||
* @param s string to be cleaned
|
* @param s string to be cleaned
|
||||||
*/
|
*/
|
||||||
void cleanString(std::string& s);
|
void cleanString(std::string& s);
|
||||||
|
|
||||||
DebugLevel fDebugLevel; // internal use debug level
|
DebugLevel fDebugLevel; // internal use debug level
|
||||||
@@ -505,7 +541,7 @@ private:
|
|||||||
template <class T>
|
template <class T>
|
||||||
bool from_string(T& t,
|
bool from_string(T& t,
|
||||||
const std::string& s,
|
const std::string& s,
|
||||||
std::ios_base& (*f)(std::ios_base&))
|
std::ios_base & (*f)(std::ios_base&))
|
||||||
{
|
{
|
||||||
std::istringstream iss(s);
|
std::istringstream iss(s);
|
||||||
return !(iss >> f >> t).fail();
|
return !(iss >> f >> t).fail();
|
||||||
|
|||||||
@@ -31,34 +31,35 @@
|
|||||||
|
|
||||||
using namespace dmlpackage;
|
using namespace dmlpackage;
|
||||||
|
|
||||||
namespace dmlpackageprocessor {
|
namespace dmlpackageprocessor
|
||||||
|
{
|
||||||
|
|
||||||
DMLPackageProcessor* DMLPackageProcessorFactory::
|
DMLPackageProcessor* DMLPackageProcessorFactory::
|
||||||
makePackageProcessor(int packageType, dmlpackage::CalpontDMLPackage& cpackage)
|
makePackageProcessor(int packageType, dmlpackage::CalpontDMLPackage& cpackage)
|
||||||
{
|
{
|
||||||
DMLPackageProcessor* dmlProcPtr = 0;
|
DMLPackageProcessor* dmlProcPtr = 0;
|
||||||
|
|
||||||
switch( packageType )
|
switch ( packageType )
|
||||||
{
|
{
|
||||||
case DML_INSERT:
|
case DML_INSERT:
|
||||||
dmlProcPtr = new InsertPackageProcessor();
|
dmlProcPtr = new InsertPackageProcessor();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DML_DELETE:
|
|
||||||
dmlProcPtr = new DeletePackageProcessor();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DML_UPDATE:
|
case DML_DELETE:
|
||||||
dmlProcPtr = new UpdatePackageProcessor();
|
dmlProcPtr = new DeletePackageProcessor();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DML_COMMAND:
|
|
||||||
dmlProcPtr = new CommandPackageProcessor();
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return dmlProcPtr;
|
case DML_UPDATE:
|
||||||
|
dmlProcPtr = new UpdatePackageProcessor();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DML_COMMAND:
|
||||||
|
dmlProcPtr = new CommandPackageProcessor();
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return dmlProcPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dmlpackageprocessor
|
} // namespace dmlpackageprocessor
|
||||||
|
|||||||
@@ -33,22 +33,24 @@
|
|||||||
#define EXPORT
|
#define EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace dmlpackageprocessor {
|
namespace dmlpackageprocessor
|
||||||
|
{
|
||||||
|
|
||||||
/** @brief create a DMLPackageProcessor object from a CalpontDMLPackage object
|
/** @brief create a DMLPackageProcessor object from a CalpontDMLPackage object
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class DMLPackageProcessorFactory {
|
class DMLPackageProcessorFactory
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** @brief static DMLPackageProcessor constructor method
|
/** @brief static DMLPackageProcessor constructor method
|
||||||
*
|
*
|
||||||
* @param packageType the DML Package type
|
* @param packageType the DML Package type
|
||||||
* @param cpackage the CalpontDMLPackage from which the DMLPackageProcessor is constructed
|
* @param cpackage the CalpontDMLPackage from which the DMLPackageProcessor is constructed
|
||||||
*/
|
*/
|
||||||
EXPORT static DMLPackageProcessor*
|
EXPORT static DMLPackageProcessor*
|
||||||
makePackageProcessor( int packageType, dmlpackage::CalpontDMLPackage& cpackage );
|
makePackageProcessor( int packageType, dmlpackage::CalpontDMLPackage& cpackage );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@@ -56,7 +58,7 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef EXPORT
|
#undef EXPORT
|
||||||
|
|
||||||
|
|||||||
@@ -51,362 +51,383 @@ using namespace messageqcpp;
|
|||||||
namespace dmlpackageprocessor
|
namespace dmlpackageprocessor
|
||||||
{
|
{
|
||||||
|
|
||||||
DMLPackageProcessor::DMLResult InsertPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage & cpackage)
|
DMLPackageProcessor::DMLResult InsertPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||||
{
|
{
|
||||||
SUMMARY_INFO("InsertPackageProcessor::processPackage");
|
SUMMARY_INFO("InsertPackageProcessor::processPackage");
|
||||||
|
|
||||||
DMLResult result;
|
DMLResult result;
|
||||||
result.result = NO_ERROR;
|
result.result = NO_ERROR;
|
||||||
BRM::TxnID txnid;
|
BRM::TxnID txnid;
|
||||||
// set-up the transaction
|
// set-up the transaction
|
||||||
txnid.id = cpackage.get_TxnID();
|
txnid.id = cpackage.get_TxnID();
|
||||||
txnid.valid = true;
|
txnid.valid = true;
|
||||||
fSessionID = cpackage.get_SessionID();
|
fSessionID = cpackage.get_SessionID();
|
||||||
DMLTable *tablePtr = cpackage.get_Table();
|
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());
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
for (unsigned int i=0; i <moduleIds.size(); i++)
|
|
||||||
{
|
|
||||||
pms.push_back((uint32_t)moduleIds[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//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 );
|
|
||||||
|
|
||||||
tableLockId = tablelockData->getTablelockId(roPair.objnum); //check whether this table is locked already for this session
|
LoggingID logid( DMLLoggingId, fSessionID, txnid.id);
|
||||||
if (tableLockId == 0)
|
logging::Message::Args args1;
|
||||||
{
|
logging::Message msg(1);
|
||||||
//cout << "tablelock is not found in cache, getting from dbrm" << endl;
|
args1.add("Start SQL statement: ");
|
||||||
uint32_t processID = ::getpid();
|
ostringstream oss;
|
||||||
int32_t txnId = txnid.id;
|
oss << cpackage.get_SQLStatement() << "; |" << tablePtr->get_SchemaName() << "|";
|
||||||
int32_t sessionId = fSessionID;
|
args1.add(oss.str());
|
||||||
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;
|
msg.format( args1 );
|
||||||
rm_ts.tv_nsec = sleepTime%1000 *1000000;
|
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;
|
||||||
|
|
||||||
for (; i < numTries; 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < moduleIds.size(); i++)
|
||||||
|
{
|
||||||
|
pms.push_back((uint32_t)moduleIds[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//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 );
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
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
|
#ifdef _MSC_VER
|
||||||
Sleep(rm_ts.tv_sec * 1000);
|
Sleep(rm_ts.tv_sec * 1000);
|
||||||
#else
|
#else
|
||||||
struct timespec abs_ts;
|
struct timespec abs_ts;
|
||||||
do
|
|
||||||
{
|
do
|
||||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
{
|
||||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||||
}
|
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||||
while(nanosleep(&abs_ts,&rm_ts) < 0);
|
}
|
||||||
|
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||||
|
|
||||||
#endif
|
#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)
|
try
|
||||||
break;
|
{
|
||||||
}
|
processID = ::getpid();
|
||||||
if (i >= numTries) //error out
|
txnId = txnid.id;
|
||||||
{
|
sessionId = fSessionID;
|
||||||
result.result = INSERT_ERROR;
|
processName = "DMLProc";
|
||||||
logging::Message::Args args;
|
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnId, BRM::LOADING );
|
||||||
string strOp("insert");
|
}
|
||||||
args.add(strOp);
|
catch (std::exception&)
|
||||||
args.add(processName);
|
{
|
||||||
args.add((uint64_t)processID);
|
throw std::runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE));
|
||||||
args.add(sessionId);
|
}
|
||||||
throw std::runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_TABLE_LOCKED,args));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//cout << " tablelock is obtained with id " << tableLockId << endl;
|
if (tableLockId > 0)
|
||||||
tablelockData->setTablelock(roPair.objnum, tableLockId);
|
break;
|
||||||
|
}
|
||||||
int pmNum = 0;
|
|
||||||
|
|
||||||
// Select PM to receive the row.
|
if (i >= numTries) //error out
|
||||||
// 1. Get BRM information
|
{
|
||||||
// 2. Find the DBRoot with the fewest in-service blocks.
|
result.result = INSERT_ERROR;
|
||||||
// DBRoots having no blocks are excluded
|
logging::Message::Args args;
|
||||||
// 3. Map the selected DBRoot to the corresponding PM
|
string strOp("insert");
|
||||||
CalpontSystemCatalog::RIDList ridList = systemCatalogPtr->columnRIDs(tableName, true);
|
args.add(strOp);
|
||||||
std::vector<BRM::EmDbRootHWMInfo_v> allInfo (pms.size());
|
args.add(processName);
|
||||||
for (unsigned i = 0; i < pms.size(); i++)
|
args.add((uint64_t)processID);
|
||||||
{
|
args.add(sessionId);
|
||||||
rc = fDbrm->getDbRootHWMInfo((ridList[0].objnum), pms[i], allInfo[i]);
|
throw std::runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_TABLE_LOCKED, args));
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find DBRoot with fewest blocks; if all DBRoots
|
//cout << " tablelock is obtained with id " << tableLockId << endl;
|
||||||
// have 0 blocks, then we select the first DBRoot
|
tablelockData->setTablelock(roPair.objnum, tableLockId);
|
||||||
BRM::EmDbRootHWMInfo tmp;
|
|
||||||
bool tmpSet = false;
|
|
||||||
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
|
int pmNum = 0;
|
||||||
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.
|
// Select PM to receive the row.
|
||||||
//cout << "fWEClient = " << fWEClient << endl;
|
// 1. Get BRM information
|
||||||
fWEClient->addQueue(uniqueId);
|
// 2. Find the DBRoot with the fewest in-service blocks.
|
||||||
ByteStream bytestream;
|
// DBRoots having no blocks are excluded
|
||||||
bytestream << (uint8_t)WE_SVR_SINGLE_INSERT;
|
// 3. Map the selected DBRoot to the corresponding PM
|
||||||
bytestream << uniqueId;
|
CalpontSystemCatalog::RIDList ridList = systemCatalogPtr->columnRIDs(tableName, true);
|
||||||
bytestream << (uint32_t)txnid.id;
|
std::vector<BRM::EmDbRootHWMInfo_v> allInfo (pms.size());
|
||||||
bytestream << dbroot;
|
|
||||||
cpackage.write(bytestream);
|
for (unsigned i = 0; i < pms.size(); i++)
|
||||||
boost::shared_ptr<messageqcpp::ByteStream> bsIn;
|
{
|
||||||
|
rc = fDbrm->getDbRootHWMInfo((ridList[0].objnum), pms[i], allInfo[i]);
|
||||||
ByteStream::byte rc1;
|
|
||||||
try
|
if ( rc != 0 ) //@Bug 4760.
|
||||||
{
|
{
|
||||||
fWEClient->write(bytestream, (uint32_t)pmNum);
|
result.result = INSERT_ERROR;
|
||||||
|
ostringstream oss;
|
||||||
|
oss << "Error getting extent information for table " << tableName.table;
|
||||||
|
throw std::runtime_error(oss.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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];
|
||||||
|
|
||||||
|
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
|
#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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (runtime_error& ex) //write error
|
|
||||||
{
|
|
||||||
#ifdef IDB_DML_DEBUG
|
|
||||||
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;
|
|
||||||
#ifdef IDB_DML_DEBUG
|
|
||||||
cout << "Single insert got unknown exception" << endl;
|
|
||||||
#endif
|
#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;
|
bsIn.reset(new ByteStream());
|
||||||
logging::Message message(1);
|
fWEClient->read(uniqueId, bsIn);
|
||||||
args.add("Insert Failed: ");
|
|
||||||
args.add(ex.what());
|
|
||||||
args.add("");
|
|
||||||
args.add("");
|
|
||||||
message.format(args);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
result.result = INSERT_ERROR;
|
if ( bsIn->length() == 0 ) //read error
|
||||||
result.message = message;
|
{
|
||||||
}
|
rc = NETWORK_ERROR;
|
||||||
|
errorMsg = "Lost connection to Write Engine Server while updating SYSTABLES";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*bsIn >> rc1;
|
||||||
|
|
||||||
if (( rc !=0) && (rc != IDBRANGE_WARNING))
|
if (rc1 != 0)
|
||||||
{
|
{
|
||||||
logging::Message::Args args;
|
*bsIn >> errorMsg;
|
||||||
logging::Message message(1);
|
rc = rc1;
|
||||||
args.add("Insert Failed: ");
|
}
|
||||||
args.add(errorMsg);
|
}
|
||||||
args.add("");
|
|
||||||
args.add("");
|
}
|
||||||
message.format(args);
|
catch (runtime_error& ex) //write error
|
||||||
result.result = INSERT_ERROR;
|
{
|
||||||
result.message = message;
|
#ifdef IDB_DML_DEBUG
|
||||||
}
|
cout << "Single insert got exception" << ex.what() << endl;
|
||||||
else if (rc == IDBRANGE_WARNING)
|
#endif
|
||||||
{
|
rc = NETWORK_ERROR;
|
||||||
logging::Message::Args args;
|
errorMsg = ex.what();
|
||||||
logging::Message message(1);
|
}
|
||||||
args.add(errorMsg);
|
catch (...)
|
||||||
args.add("");
|
{
|
||||||
args.add("");
|
errorMsg = "Caught ... exception during single row insert";
|
||||||
message.format(args);
|
rc = NETWORK_ERROR;
|
||||||
result.result = IDBRANGE_WARNING;
|
#ifdef IDB_DML_DEBUG
|
||||||
result.message = message;
|
cout << "Single insert got unknown exception" << endl;
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
fWEClient->removeQueue(uniqueId);
|
|
||||||
VERBOSE_INFO("Finished Processing Insert DML Package");
|
// Log the insert statement.
|
||||||
return result;
|
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
result.result = INSERT_ERROR;
|
||||||
|
result.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
} // namespace dmlpackageprocessor
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,9 @@ class InsertPackageProcessor : public DMLPackageProcessor
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
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
|
/** @brief process an InsertDMLPackage
|
||||||
*
|
*
|
||||||
* @param cpackage the InsertDMLPackage to process
|
* @param cpackage the InsertDMLPackage to process
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
//{{NO_DEPENDENCIES}}
|
//{{NO_DEPENDENCIES}}
|
||||||
// Microsoft Visual C++ generated include file.
|
// Microsoft Visual C++ generated include file.
|
||||||
// Used by libdmlpackageproc.rc
|
// Used by libdmlpackageproc.rc
|
||||||
|
|
||||||
// Next default values for new objects
|
// Next default values for new objects
|
||||||
//
|
//
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
#define _APS_NEXT_SYMED_VALUE 101
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ void TablelockData::removeTablelockData(uint32_t sessionID)
|
|||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(map_mutex);
|
boost::mutex::scoped_lock lock(map_mutex);
|
||||||
TablelockDataMap::iterator it = fTablelockDataMap.find(sessionID);
|
TablelockDataMap::iterator it = fTablelockDataMap.find(sessionID);
|
||||||
|
|
||||||
if (it != fTablelockDataMap.end())
|
if (it != fTablelockDataMap.end())
|
||||||
{
|
{
|
||||||
delete (*it).second;
|
delete (*it).second;
|
||||||
@@ -75,27 +76,29 @@ TablelockData::~TablelockData()
|
|||||||
|
|
||||||
void TablelockData::setTablelock(uint32_t tableOid, uint64_t tablelockId)
|
void TablelockData::setTablelock(uint32_t tableOid, uint64_t tablelockId)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lk(fOIDTablelock);
|
boost::mutex::scoped_lock lk(fOIDTablelock);
|
||||||
fOIDTablelockMap[tableOid] = tablelockId;
|
fOIDTablelockMap[tableOid] = tablelockId;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t TablelockData::getTablelockId(uint32_t tableOid)
|
uint64_t TablelockData::getTablelockId(uint32_t tableOid)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lk(fOIDTablelock);
|
boost::mutex::scoped_lock lk(fOIDTablelock);
|
||||||
uint64_t tablelockId = 0;
|
uint64_t tablelockId = 0;
|
||||||
OIDTablelock::iterator it = fOIDTablelockMap.find(tableOid);
|
OIDTablelock::iterator it = fOIDTablelockMap.find(tableOid);
|
||||||
if (it != fOIDTablelockMap.end())
|
|
||||||
{
|
if (it != fOIDTablelockMap.end())
|
||||||
tablelockId = it->second;
|
{
|
||||||
}
|
tablelockId = it->second;
|
||||||
return tablelockId;
|
}
|
||||||
|
|
||||||
|
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
|
class TablelockData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::map <uint32_t, TablelockData*> TablelockDataMap;
|
typedef std::map <uint32_t, TablelockData*> TablelockDataMap;
|
||||||
typedef std::map<uint32_t, uint64_t> OIDTablelock;
|
typedef std::map<uint32_t, uint64_t> OIDTablelock;
|
||||||
EXPORT static TablelockData* makeTablelockData(uint32_t sessionID = 0);
|
EXPORT static TablelockData* makeTablelockData(uint32_t sessionID = 0);
|
||||||
EXPORT static void removeTablelockData(uint32_t sessionID = 0);
|
EXPORT static void removeTablelockData(uint32_t sessionID = 0);
|
||||||
EXPORT void setTablelock(uint32_t tableOid, uint64_t tablelockId);
|
EXPORT void setTablelock(uint32_t tableOid, uint64_t tablelockId);
|
||||||
EXPORT uint64_t getTablelockId(uint32_t tableOid);
|
EXPORT uint64_t getTablelockId(uint32_t tableOid);
|
||||||
OIDTablelock & getOidTablelockMap();
|
OIDTablelock& getOidTablelockMap();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Constuctors */
|
/** Constuctors */
|
||||||
explicit TablelockData();
|
explicit TablelockData();
|
||||||
explicit TablelockData(const TablelockData& rhs);
|
explicit TablelockData(const TablelockData& rhs);
|
||||||
~TablelockData();
|
~TablelockData();
|
||||||
|
|
||||||
static boost::mutex map_mutex;
|
static boost::mutex map_mutex;
|
||||||
static TablelockDataMap fTablelockDataMap;
|
static TablelockDataMap fTablelockDataMap;
|
||||||
OIDTablelock fOIDTablelockMap;
|
OIDTablelock fOIDTablelockMap;
|
||||||
boost::mutex fOIDTablelock;
|
boost::mutex fOIDTablelock;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -446,9 +446,9 @@ public:
|
|||||||
buildTable(createStmt);
|
buildTable(createStmt);
|
||||||
|
|
||||||
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))";
|
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);
|
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);
|
buildTable(createStmt);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -458,21 +458,23 @@ public:
|
|||||||
|
|
||||||
ddlpackage::SqlParser parser;
|
ddlpackage::SqlParser parser;
|
||||||
parser.Parse(createText.c_str());
|
parser.Parse(createText.c_str());
|
||||||
|
|
||||||
if (parser.Good())
|
if (parser.Good())
|
||||||
{
|
{
|
||||||
const ddlpackage::ParseTree &ptree = parser.GetParseTree();
|
const ddlpackage::ParseTree& ptree = parser.GetParseTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ddlpackageprocessor::CreateTableProcessor processor;
|
ddlpackageprocessor::CreateTableProcessor processor;
|
||||||
processor.setDebugLevel(ddlpackageprocessor::CreateTableProcessor::VERBOSE);
|
processor.setDebugLevel(ddlpackageprocessor::CreateTableProcessor::VERBOSE);
|
||||||
|
|
||||||
ddlpackage::SqlStatement &stmt = *ptree.fList[0];
|
ddlpackage::SqlStatement& stmt = *ptree.fList[0];
|
||||||
ddlpackageprocessor::CreateTableProcessor::DDLResult result;
|
ddlpackageprocessor::CreateTableProcessor::DDLResult result;
|
||||||
|
|
||||||
result = processor.processPackage(dynamic_cast<ddlpackage::CreateTableStatement&>(stmt));
|
result = processor.processPackage(dynamic_cast<ddlpackage::CreateTableStatement&>(stmt));
|
||||||
std::cout << "return: " << result.result << std::endl;
|
std::cout << "return: " << result.result << std::endl;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
@@ -493,9 +495,11 @@ void destroySemaphores()
|
|||||||
|
|
||||||
semkey = 0x2149bdd2;
|
semkey = 0x2149bdd2;
|
||||||
sems = semget(semkey, 2, 0666);
|
sems = semget(semkey, 2, 0666);
|
||||||
|
|
||||||
if (sems != -1)
|
if (sems != -1)
|
||||||
{
|
{
|
||||||
err = semctl(sems, 0, IPC_RMID);
|
err = semctl(sems, 0, IPC_RMID);
|
||||||
|
|
||||||
if (err == -1)
|
if (err == -1)
|
||||||
perror("tdriver: semctl");
|
perror("tdriver: semctl");
|
||||||
}
|
}
|
||||||
@@ -508,9 +512,11 @@ void destroyShmseg()
|
|||||||
|
|
||||||
shmkey = 0x2149bdd2;
|
shmkey = 0x2149bdd2;
|
||||||
shms = shmget(shmkey, 0, 0666);
|
shms = shmget(shmkey, 0, 0666);
|
||||||
|
|
||||||
if (shms != -1)
|
if (shms != -1)
|
||||||
{
|
{
|
||||||
err = shmctl(shms, IPC_RMID, NULL);
|
err = shmctl(shms, IPC_RMID, NULL);
|
||||||
|
|
||||||
if (err == -1 && errno != EINVAL)
|
if (err == -1 && errno != EINVAL)
|
||||||
{
|
{
|
||||||
perror("tdriver: shmctl");
|
perror("tdriver: shmctl");
|
||||||
@@ -555,7 +561,7 @@ class DMLPackageProcessorTest : public CppUnit::TestFixture
|
|||||||
CPPUNIT_TEST( test_insert_package_fail);
|
CPPUNIT_TEST( test_insert_package_fail);
|
||||||
CPPUNIT_TEST( test_update_package_fail);
|
CPPUNIT_TEST( test_update_package_fail);
|
||||||
CPPUNIT_TEST( test_delete_package_fail);
|
CPPUNIT_TEST( test_delete_package_fail);
|
||||||
CPPUNIT_TEST( test_command_package );
|
CPPUNIT_TEST( test_command_package );
|
||||||
*/
|
*/
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
@@ -650,7 +656,7 @@ public:
|
|||||||
|
|
||||||
cout << "\nDML statement:" << dmlStatement.c_str() << endl;
|
cout << "\nDML statement:" << dmlStatement.c_str() << endl;
|
||||||
|
|
||||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||||
|
|
||||||
@@ -676,7 +682,7 @@ public:
|
|||||||
|
|
||||||
cout << "\nDML statement:" << dmlStatement.c_str() << endl;
|
cout << "\nDML statement:" << dmlStatement.c_str() << endl;
|
||||||
|
|
||||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||||
|
|
||||||
@@ -708,7 +714,7 @@ public:
|
|||||||
|
|
||||||
CPPUNIT_ASSERT( DML_INSERT == package_type );
|
CPPUNIT_ASSERT( DML_INSERT == package_type );
|
||||||
|
|
||||||
InsertDMLPackage *pObject = new InsertDMLPackage();
|
InsertDMLPackage* pObject = new InsertDMLPackage();
|
||||||
|
|
||||||
pObject->read( bs );
|
pObject->read( bs );
|
||||||
|
|
||||||
@@ -720,6 +726,7 @@ public:
|
|||||||
|
|
||||||
pkgProcPtr->setDebugLevel(DMLPackageProcessor::VERBOSE);
|
pkgProcPtr->setDebugLevel(DMLPackageProcessor::VERBOSE);
|
||||||
DMLPackageProcessor::DMLResult result = pkgProcPtr->processPackage( *pObject );
|
DMLPackageProcessor::DMLResult result = pkgProcPtr->processPackage( *pObject );
|
||||||
|
|
||||||
if ( DMLPackageProcessor::NO_ERROR != result.result )
|
if ( DMLPackageProcessor::NO_ERROR != result.result )
|
||||||
{
|
{
|
||||||
cout << "Insert failed!" << endl;
|
cout << "Insert failed!" << endl;
|
||||||
@@ -770,7 +777,7 @@ public:
|
|||||||
|
|
||||||
cout << "\nDML statement:" << dmlStatement.c_str() << endl;
|
cout << "\nDML statement:" << dmlStatement.c_str() << endl;
|
||||||
|
|
||||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||||
|
|
||||||
@@ -801,7 +808,7 @@ public:
|
|||||||
|
|
||||||
CPPUNIT_ASSERT( DML_DELETE == package_type );
|
CPPUNIT_ASSERT( DML_DELETE == package_type );
|
||||||
|
|
||||||
DeleteDMLPackage *pObject = new DeleteDMLPackage();
|
DeleteDMLPackage* pObject = new DeleteDMLPackage();
|
||||||
|
|
||||||
pObject->read( bs );
|
pObject->read( bs );
|
||||||
|
|
||||||
@@ -822,6 +829,7 @@ public:
|
|||||||
|
|
||||||
ml.logDebugMessage( result.message );
|
ml.logDebugMessage( result.message );
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pkgProcPtr;
|
delete pkgProcPtr;
|
||||||
delete pObject;
|
delete pObject;
|
||||||
|
|
||||||
@@ -837,7 +845,7 @@ public:
|
|||||||
|
|
||||||
cout << "\nDML statement:" << dmlStatement.c_str() << endl;
|
cout << "\nDML statement:" << dmlStatement.c_str() << endl;
|
||||||
|
|
||||||
VendorDMLStatement dmlStmt(dmlStatement,1);
|
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||||
|
|
||||||
@@ -866,6 +874,7 @@ public:
|
|||||||
ByteStream bytestream;
|
ByteStream bytestream;
|
||||||
|
|
||||||
std::vector<std::string>::const_iterator iter = commands.begin();
|
std::vector<std::string>::const_iterator iter = commands.begin();
|
||||||
|
|
||||||
while (iter != commands.end())
|
while (iter != commands.end())
|
||||||
{
|
{
|
||||||
std::string command = *iter;
|
std::string command = *iter;
|
||||||
@@ -873,6 +882,7 @@ public:
|
|||||||
|
|
||||||
VendorDMLStatement dml_command(command, 1);
|
VendorDMLStatement dml_command(command, 1);
|
||||||
CalpontDMLPackage* dmlCommandPkgPtr = CalpontDMLFactory::makeCalpontDMLPackage(dml_command);
|
CalpontDMLPackage* dmlCommandPkgPtr = CalpontDMLFactory::makeCalpontDMLPackage(dml_command);
|
||||||
|
|
||||||
if (dmlCommandPkgPtr)
|
if (dmlCommandPkgPtr)
|
||||||
{
|
{
|
||||||
cout << "CalpontDMLFactory::makeCalpontDMLPackage: success" << endl;
|
cout << "CalpontDMLFactory::makeCalpontDMLPackage: success" << endl;
|
||||||
@@ -900,7 +910,7 @@ public:
|
|||||||
|
|
||||||
CPPUNIT_ASSERT( DML_COMMAND == package_type );
|
CPPUNIT_ASSERT( DML_COMMAND == package_type );
|
||||||
|
|
||||||
CommandDMLPackage *pObject = new CommandDMLPackage();
|
CommandDMLPackage* pObject = new CommandDMLPackage();
|
||||||
|
|
||||||
pObject->read( bs );
|
pObject->read( bs );
|
||||||
|
|
||||||
@@ -921,6 +931,7 @@ public:
|
|||||||
|
|
||||||
ml.logDebugMessage( result.message );
|
ml.logDebugMessage( result.message );
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pkgProcPtr;
|
delete pkgProcPtr;
|
||||||
delete pObject;
|
delete pObject;
|
||||||
}
|
}
|
||||||
@@ -967,7 +978,7 @@ public:
|
|||||||
|
|
||||||
CPPUNIT_ASSERT( DML_UPDATE == package_type );
|
CPPUNIT_ASSERT( DML_UPDATE == package_type );
|
||||||
|
|
||||||
UpdateDMLPackage *pObject = new UpdateDMLPackage();
|
UpdateDMLPackage* pObject = new UpdateDMLPackage();
|
||||||
|
|
||||||
pObject->read( bs );
|
pObject->read( bs );
|
||||||
|
|
||||||
@@ -1002,13 +1013,13 @@ CPPUNIT_TEST_SUITE_REGISTRATION( DMLPackageProcessorTest );
|
|||||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||||
#include <cppunit/ui/text/TestRunner.h>
|
#include <cppunit/ui/text/TestRunner.h>
|
||||||
|
|
||||||
int main( int argc, char **argv)
|
int main( int argc, char** argv)
|
||||||
{
|
{
|
||||||
// Uncomment before running tests
|
// Uncomment before running tests
|
||||||
//setUp();
|
//setUp();
|
||||||
|
|
||||||
CppUnit::TextUi::TestRunner runner;
|
CppUnit::TextUi::TestRunner runner;
|
||||||
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
|
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||||
runner.addTest( registry.makeTest() );
|
runner.addTest( registry.makeTest() );
|
||||||
bool wasSuccessful = runner.run( "", false );
|
bool wasSuccessful = runner.run( "", false );
|
||||||
|
|
||||||
|
|||||||
1667
dbcon/dmlpackageproc/updatepackageprocessor.cpp
Executable file → Normal file
1667
dbcon/dmlpackageproc/updatepackageprocessor.cpp
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
@@ -45,21 +45,22 @@ class UpdatePackageProcessor : public DMLPackageProcessor
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
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
|
/** @brief process an UpdateDMLPackage
|
||||||
*
|
*
|
||||||
* @param cpackage the UpdateDMLPackage to process
|
* @param cpackage the UpdateDMLPackage to process
|
||||||
*/
|
*/
|
||||||
EXPORT DMLResult processPackage(dmlpackage::CalpontDMLPackage& cpackage);
|
EXPORT DMLResult processPackage(dmlpackage::CalpontDMLPackage& cpackage);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** @brief send execution plan to ExeMgr and fetch rows
|
/** @brief send execution plan to ExeMgr and fetch rows
|
||||||
*
|
*
|
||||||
* @param cpackage the UpdateDMLPackage to process
|
* @param cpackage the UpdateDMLPackage to process
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @return rows processed
|
* @return rows processed
|
||||||
*/
|
*/
|
||||||
uint64_t fixUpRows(dmlpackage::CalpontDMLPackage& cpackage, DMLResult& result, const uint64_t uniqueId, const uint32_t tableOid);
|
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
|
/** @brief send row group to the PM to process
|
||||||
*
|
*
|
||||||
* @param aRowGroup the row group to be sent
|
* @param aRowGroup the row group to be sent
|
||||||
* @param result the result of the operation
|
* @param result the result of the operation
|
||||||
* @return the error code
|
* @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 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 receiveAll(DMLResult& result, const uint64_t uniqueId, std::vector<int>& fPMs, std::map<unsigned, bool>& pmState, const uint32_t tableOid);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user