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,7 +25,8 @@
|
||||
#include "ddlpkg.h"
|
||||
#undef DDLPKG_DLLEXPORT
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
AlterTableStatement::AlterTableStatement(QualifiedName* qName, AlterTableActionList* ataList):
|
||||
@@ -39,7 +40,9 @@ namespace ddlpackage {
|
||||
{
|
||||
delete fTableName;
|
||||
AlterTableActionList::iterator itr;
|
||||
for(itr=fActions.begin(); itr != fActions.end(); ++itr) {
|
||||
|
||||
for (itr = fActions.begin(); itr != fActions.end(); ++itr)
|
||||
{
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
@@ -49,9 +52,11 @@ namespace ddlpackage {
|
||||
AlterTableActionList::const_iterator itr;
|
||||
os << "Alter Table " << *fTableName << endl;
|
||||
|
||||
for(itr = fActions.begin(); itr != fActions.end(); ++itr) {
|
||||
for (itr = fActions.begin(); itr != fActions.end(); ++itr)
|
||||
{
|
||||
os << **itr << endl;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -205,6 +210,7 @@ namespace ddlpackage {
|
||||
AtaAddColumns::~AtaAddColumns()
|
||||
{
|
||||
ColumnDefList::iterator itr;
|
||||
|
||||
for (itr = fColumns.begin(); itr != fColumns.end(); itr++)
|
||||
delete *itr;
|
||||
}
|
||||
@@ -219,15 +225,19 @@ namespace ddlpackage {
|
||||
*/
|
||||
ColumnDef* column;
|
||||
TableElementList::const_iterator itr;
|
||||
|
||||
for (itr = tableElements->begin();
|
||||
itr != tableElements->end();
|
||||
++itr)
|
||||
{
|
||||
column = dynamic_cast<ColumnDef*>(*itr);
|
||||
if(0 != column) {
|
||||
|
||||
if (0 != column)
|
||||
{
|
||||
fColumns.push_back(column);
|
||||
}
|
||||
}
|
||||
|
||||
delete tableElements;
|
||||
}
|
||||
|
||||
@@ -235,6 +245,7 @@ namespace ddlpackage {
|
||||
{
|
||||
os << "Add Columns: " << endl;
|
||||
ColumnDefList::const_iterator itr;
|
||||
|
||||
for (itr = fColumns.begin();
|
||||
itr != fColumns.end();
|
||||
++itr)
|
||||
@@ -261,6 +272,7 @@ namespace ddlpackage {
|
||||
{
|
||||
os << "Drop Columns: " << endl;
|
||||
ColumnNameList::const_iterator itr;
|
||||
|
||||
for (itr = fColumns.begin();
|
||||
itr != fColumns.end();
|
||||
++itr)
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
#include "ddlpkg.h"
|
||||
#undef DDLPKG_DLLEXPORT
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -37,7 +38,9 @@ namespace ddlpackage {
|
||||
delete fType;
|
||||
delete fDefaultValue;
|
||||
ColumnConstraintList::iterator itr;
|
||||
for(itr=fConstraints.begin(); itr != fConstraints.end(); ++itr) {
|
||||
|
||||
for (itr = fConstraints.begin(); itr != fConstraints.end(); ++itr)
|
||||
{
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
@@ -48,10 +51,12 @@ namespace ddlpackage {
|
||||
fType(columnType),
|
||||
fDefaultValue(defaultValue)
|
||||
{
|
||||
if(constraints) {
|
||||
if (constraints)
|
||||
{
|
||||
fConstraints = *constraints;
|
||||
delete constraints;
|
||||
}
|
||||
|
||||
if ( comment )
|
||||
fComment = comment;
|
||||
}
|
||||
@@ -74,7 +79,8 @@ namespace ddlpackage {
|
||||
{
|
||||
os << "Column: " << column.fName << " " << *column.fType;
|
||||
|
||||
if(column.fDefaultValue) {
|
||||
if (column.fDefaultValue)
|
||||
{
|
||||
os << " def=";
|
||||
|
||||
if (column.fDefaultValue->fNull)
|
||||
@@ -87,9 +93,11 @@ namespace ddlpackage {
|
||||
<< " constraints ";
|
||||
|
||||
ColumnConstraintList::const_iterator itr;
|
||||
|
||||
for (itr = column.fConstraints.begin();
|
||||
itr != column.fConstraints.end();
|
||||
++itr) {
|
||||
++itr)
|
||||
{
|
||||
ColumnConstraintDef* con = *itr;
|
||||
os << *con;
|
||||
}
|
||||
@@ -107,6 +115,7 @@ namespace ddlpackage {
|
||||
<< ConstraintString[con.fConstraintType] << " "
|
||||
<< "defer=" << con.fDeferrable << " "
|
||||
<< ConstraintAttrStrings[con.fCheckTime] << " ";
|
||||
|
||||
if (!con.fCheck.empty())
|
||||
os << "check=" << "\"" << con.fCheck << "\"";
|
||||
|
||||
@@ -116,9 +125,12 @@ namespace ddlpackage {
|
||||
std::ostream& operator<<(std::ostream& os, const ColumnDefList& clist)
|
||||
{
|
||||
ColumnDefList::const_iterator itr;
|
||||
for(itr = clist.begin(); itr != clist.end(); ++itr){
|
||||
|
||||
for (itr = clist.begin(); itr != clist.end(); ++itr)
|
||||
{
|
||||
os << **itr;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -141,6 +153,7 @@ namespace ddlpackage {
|
||||
os << "NULL";
|
||||
else
|
||||
os << defaultValue.fValue;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
|
||||
#include "ddlpkg.h"
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
CreateIndexStatement::CreateIndexStatement():
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
#include "ddlpkg.h"
|
||||
#undef DDLPKG_DLLEXPORT
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,8 @@
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
enum yytokentype
|
||||
{
|
||||
ACTION = 258,
|
||||
ADD = 259,
|
||||
ALTER = 260,
|
||||
|
||||
@@ -305,7 +305,8 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
|
||||
#define YY_NUM_RULES 85
|
||||
#define YY_END_OF_BUFFER 86
|
||||
static yyconst short int yy_accept[393] =
|
||||
{ 0,
|
||||
{
|
||||
0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
86, 85, 81, 80, 83, 13, 83, 83, 83, 16,
|
||||
82, 84, 82, 82, 82, 82, 82, 82, 82, 82,
|
||||
@@ -353,7 +354,8 @@ static yyconst short int yy_accept[393] =
|
||||
} ;
|
||||
|
||||
static yyconst int yy_ec[256] =
|
||||
{ 0,
|
||||
{
|
||||
0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
|
||||
1, 2, 4, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
@@ -385,7 +387,8 @@ static yyconst int yy_ec[256] =
|
||||
} ;
|
||||
|
||||
static yyconst int yy_meta[41] =
|
||||
{ 0,
|
||||
{
|
||||
0,
|
||||
1, 1, 2, 2, 3, 1, 1, 1, 1, 1,
|
||||
1, 1, 3, 3, 1, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
@@ -393,7 +396,8 @@ static yyconst int yy_meta[41] =
|
||||
} ;
|
||||
|
||||
static yyconst short int yy_base[400] =
|
||||
{ 0,
|
||||
{
|
||||
0,
|
||||
0, 0, 33, 35, 428, 427, 428, 427, 426, 425,
|
||||
431, 438, 43, 46, 438, 438, 39, 42, 417, 44,
|
||||
0, 438, 40, 405, 45, 49, 31, 36, 56, 408,
|
||||
@@ -441,7 +445,8 @@ static yyconst short int yy_base[400] =
|
||||
} ;
|
||||
|
||||
static yyconst short int yy_def[400] =
|
||||
{ 0,
|
||||
{
|
||||
0,
|
||||
392, 1, 393, 393, 394, 394, 395, 395, 393, 393,
|
||||
392, 392, 392, 392, 392, 392, 392, 392, 392, 392,
|
||||
396, 392, 396, 396, 396, 396, 396, 396, 396, 396,
|
||||
@@ -489,7 +494,8 @@ static yyconst short int yy_def[400] =
|
||||
} ;
|
||||
|
||||
static yyconst short int yy_nxt[479] =
|
||||
{ 0,
|
||||
{
|
||||
0,
|
||||
12, 13, 14, 13, 12, 15, 16, 15, 15, 17,
|
||||
18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
|
||||
28, 21, 21, 29, 21, 30, 21, 31, 32, 33,
|
||||
@@ -545,7 +551,8 @@ static yyconst short int yy_nxt[479] =
|
||||
} ;
|
||||
|
||||
static yyconst short int yy_chk[479] =
|
||||
{ 0,
|
||||
{
|
||||
0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
@@ -850,20 +857,25 @@ YY_DECL
|
||||
|
||||
yy_current_state = yy_start;
|
||||
yy_match:
|
||||
|
||||
do
|
||||
{
|
||||
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
|
||||
|
||||
if ( yy_accept[yy_current_state] )
|
||||
{
|
||||
yy_last_accepting_state = yy_current_state;
|
||||
yy_last_accepting_cpos = yy_cp;
|
||||
}
|
||||
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
|
||||
if ( yy_current_state >= 393 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
++yy_cp;
|
||||
}
|
||||
@@ -871,8 +883,10 @@ yy_match:
|
||||
|
||||
yy_find_action:
|
||||
yy_act = yy_accept[yy_current_state];
|
||||
|
||||
if ( yy_act == 0 )
|
||||
{ /* have to back up */
|
||||
{
|
||||
/* have to back up */
|
||||
yy_cp = yy_last_accepting_cpos;
|
||||
yy_current_state = yy_last_accepting_state;
|
||||
yy_act = yy_accept[yy_current_state];
|
||||
@@ -885,7 +899,8 @@ do_action: /* This label is used only to access EOF actions. */
|
||||
|
||||
|
||||
switch ( yy_act )
|
||||
{ /* beginning of action switch */
|
||||
{
|
||||
/* beginning of action switch */
|
||||
case 0: /* must back up */
|
||||
/* undo the effects of YY_DO_BEFORE_ACTION */
|
||||
*yy_cp = yy_hold_char;
|
||||
@@ -897,42 +912,52 @@ case 1:
|
||||
YY_RULE_SETUP
|
||||
{return ACTION;}
|
||||
YY_BREAK
|
||||
|
||||
case 2:
|
||||
YY_RULE_SETUP
|
||||
{return ADD;}
|
||||
YY_BREAK
|
||||
|
||||
case 3:
|
||||
YY_RULE_SETUP
|
||||
{return ALTER;}
|
||||
YY_BREAK
|
||||
|
||||
case 4:
|
||||
YY_RULE_SETUP
|
||||
{return AUTO_INCREMENT;}
|
||||
YY_BREAK
|
||||
|
||||
case 5:
|
||||
YY_RULE_SETUP
|
||||
{return CASCADE;}
|
||||
YY_BREAK
|
||||
|
||||
case 6:
|
||||
YY_RULE_SETUP
|
||||
{return IDB_CHAR;}
|
||||
YY_BREAK
|
||||
|
||||
case 7:
|
||||
YY_RULE_SETUP
|
||||
{return IDB_CHAR;}
|
||||
YY_BREAK
|
||||
|
||||
case 8:
|
||||
YY_RULE_SETUP
|
||||
{return BIGINT;}
|
||||
YY_BREAK
|
||||
|
||||
case 9:
|
||||
YY_RULE_SETUP
|
||||
{BEGIN(check1); return CHECK;}
|
||||
YY_BREAK
|
||||
|
||||
case 10:
|
||||
YY_RULE_SETUP
|
||||
{BEGIN(check2); return '(';}
|
||||
YY_BREAK
|
||||
|
||||
case 11:
|
||||
*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
|
||||
yy_c_buf_p = yy_cp -= 1;
|
||||
@@ -940,14 +965,17 @@ YY_DO_BEFORE_ACTION; /* set up yytext again */
|
||||
YY_RULE_SETUP
|
||||
{BEGIN(check1); ddllval.str = scanner_copy(ddltext); return CP_SEARCH_CONDITION_TEXT;}
|
||||
YY_BREAK
|
||||
|
||||
case 12:
|
||||
YY_RULE_SETUP
|
||||
{BEGIN(0); return ')';}
|
||||
YY_BREAK
|
||||
|
||||
case 13:
|
||||
YY_RULE_SETUP
|
||||
{BEGIN(inquote); return yytext[0];}
|
||||
YY_BREAK
|
||||
|
||||
case 14:
|
||||
*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
|
||||
yy_c_buf_p = yy_cp -= 1;
|
||||
@@ -955,296 +983,368 @@ YY_DO_BEFORE_ACTION; /* set up yytext again */
|
||||
YY_RULE_SETUP
|
||||
{BEGIN(endquote); ddllval.str = scanner_copy(ddltext); return SCONST;}
|
||||
YY_BREAK
|
||||
|
||||
case 15:
|
||||
YY_RULE_SETUP
|
||||
{BEGIN(0); return yytext[0];}
|
||||
YY_BREAK
|
||||
|
||||
case 16:
|
||||
YY_RULE_SETUP
|
||||
{ddllval.str = scanner_copy(ddltext); return ICONST;}
|
||||
YY_BREAK
|
||||
|
||||
case 17:
|
||||
YY_RULE_SETUP
|
||||
{ddllval.str = scanner_copy(ddltext); return FCONST;}
|
||||
YY_BREAK
|
||||
|
||||
case 18:
|
||||
YY_RULE_SETUP
|
||||
{ddllval.str = scanner_copy(ddltext); return FCONST;}
|
||||
YY_BREAK
|
||||
|
||||
case 19:
|
||||
YY_RULE_SETUP
|
||||
{return COMMENT;}
|
||||
YY_BREAK
|
||||
|
||||
case 20:
|
||||
YY_RULE_SETUP
|
||||
{return COLUMN;}
|
||||
YY_BREAK
|
||||
|
||||
case 21:
|
||||
YY_RULE_SETUP
|
||||
{return COLUMNS;}
|
||||
YY_BREAK
|
||||
|
||||
case 22:
|
||||
YY_RULE_SETUP
|
||||
{return CONSTRAINT;}
|
||||
YY_BREAK
|
||||
|
||||
case 23:
|
||||
YY_RULE_SETUP
|
||||
{return CONSTRAINTS;}
|
||||
YY_BREAK
|
||||
|
||||
case 24:
|
||||
YY_RULE_SETUP
|
||||
{return CREATE;}
|
||||
YY_BREAK
|
||||
|
||||
case 25:
|
||||
YY_RULE_SETUP
|
||||
{return CURRENT_USER;}
|
||||
YY_BREAK
|
||||
|
||||
case 26:
|
||||
YY_RULE_SETUP
|
||||
{ddllval.str = strdup("date"); return DATE;}
|
||||
YY_BREAK
|
||||
|
||||
case 27:
|
||||
YY_RULE_SETUP
|
||||
{return DATETIME;}
|
||||
YY_BREAK
|
||||
|
||||
case 28:
|
||||
YY_RULE_SETUP
|
||||
{return DECIMAL;}
|
||||
YY_BREAK
|
||||
|
||||
case 29:
|
||||
YY_RULE_SETUP
|
||||
{return DECIMAL;}
|
||||
YY_BREAK
|
||||
|
||||
case 30:
|
||||
YY_RULE_SETUP
|
||||
{return DEFAULT;}
|
||||
YY_BREAK
|
||||
|
||||
case 31:
|
||||
YY_RULE_SETUP
|
||||
{return DEFERRABLE;}
|
||||
YY_BREAK
|
||||
|
||||
case 32:
|
||||
YY_RULE_SETUP
|
||||
{return DEFERRED;}
|
||||
YY_BREAK
|
||||
|
||||
case 33:
|
||||
YY_RULE_SETUP
|
||||
{return IDB_DELETE;}
|
||||
YY_BREAK
|
||||
|
||||
case 34:
|
||||
YY_RULE_SETUP
|
||||
{return DROP;}
|
||||
YY_BREAK
|
||||
|
||||
case 35:
|
||||
YY_RULE_SETUP
|
||||
{return ENGINE;}
|
||||
YY_BREAK
|
||||
|
||||
case 36:
|
||||
YY_RULE_SETUP
|
||||
{return FOREIGN;}
|
||||
YY_BREAK
|
||||
|
||||
case 37:
|
||||
YY_RULE_SETUP
|
||||
{return FULL;}
|
||||
YY_BREAK
|
||||
|
||||
case 38:
|
||||
YY_RULE_SETUP
|
||||
{return IMMEDIATE;}
|
||||
YY_BREAK
|
||||
|
||||
case 39:
|
||||
YY_RULE_SETUP
|
||||
{return INDEX;}
|
||||
YY_BREAK
|
||||
|
||||
case 40:
|
||||
YY_RULE_SETUP
|
||||
{return INITIALLY;}
|
||||
YY_BREAK
|
||||
|
||||
case 41:
|
||||
YY_RULE_SETUP
|
||||
{return IDB_INT;}
|
||||
YY_BREAK
|
||||
|
||||
case 42:
|
||||
YY_RULE_SETUP
|
||||
{return INTEGER;}
|
||||
YY_BREAK
|
||||
|
||||
case 43:
|
||||
YY_RULE_SETUP
|
||||
{return KEY;}
|
||||
YY_BREAK
|
||||
|
||||
case 44:
|
||||
YY_RULE_SETUP
|
||||
{return MATCH;}
|
||||
YY_BREAK
|
||||
|
||||
case 45:
|
||||
YY_RULE_SETUP
|
||||
{return MAX_ROWS;}
|
||||
YY_BREAK
|
||||
|
||||
case 46:
|
||||
YY_RULE_SETUP
|
||||
{return MIN_ROWS;}
|
||||
YY_BREAK
|
||||
|
||||
case 47:
|
||||
YY_RULE_SETUP
|
||||
{return MODIFY;}
|
||||
YY_BREAK
|
||||
|
||||
case 48:
|
||||
YY_RULE_SETUP
|
||||
{return NO;}
|
||||
YY_BREAK
|
||||
|
||||
case 49:
|
||||
YY_RULE_SETUP
|
||||
{return NOT;}
|
||||
YY_BREAK
|
||||
|
||||
case 50:
|
||||
YY_RULE_SETUP
|
||||
{return NULL_TOK;}
|
||||
YY_BREAK
|
||||
|
||||
case 51:
|
||||
YY_RULE_SETUP
|
||||
{return NUMERIC;}
|
||||
YY_BREAK
|
||||
|
||||
case 52:
|
||||
YY_RULE_SETUP
|
||||
{return ON;}
|
||||
YY_BREAK
|
||||
|
||||
case 53:
|
||||
YY_RULE_SETUP
|
||||
{return PARTIAL;}
|
||||
YY_BREAK
|
||||
|
||||
case 54:
|
||||
YY_RULE_SETUP
|
||||
{return PRECISION;}
|
||||
YY_BREAK
|
||||
|
||||
case 55:
|
||||
YY_RULE_SETUP
|
||||
{return PRIMARY;}
|
||||
YY_BREAK
|
||||
|
||||
case 56:
|
||||
YY_RULE_SETUP
|
||||
{return REFERENCES;}
|
||||
YY_BREAK
|
||||
|
||||
case 57:
|
||||
YY_RULE_SETUP
|
||||
{return RENAME;}
|
||||
YY_BREAK
|
||||
|
||||
case 58:
|
||||
YY_RULE_SETUP
|
||||
{return RESTRICT;}
|
||||
YY_BREAK
|
||||
|
||||
case 59:
|
||||
YY_RULE_SETUP
|
||||
{return SESSION_USER;}
|
||||
YY_BREAK
|
||||
|
||||
case 60:
|
||||
YY_RULE_SETUP
|
||||
{return SYSTEM_USER;}
|
||||
YY_BREAK
|
||||
|
||||
case 61:
|
||||
YY_RULE_SETUP
|
||||
{return SET;}
|
||||
YY_BREAK
|
||||
|
||||
case 62:
|
||||
YY_RULE_SETUP
|
||||
{return SMALLINT;}
|
||||
YY_BREAK
|
||||
|
||||
case 63:
|
||||
YY_RULE_SETUP
|
||||
{return TABLE;}
|
||||
YY_BREAK
|
||||
|
||||
case 64:
|
||||
YY_RULE_SETUP
|
||||
{return TINYINT;}
|
||||
YY_BREAK
|
||||
|
||||
case 65:
|
||||
YY_RULE_SETUP
|
||||
{return TO;}
|
||||
YY_BREAK
|
||||
|
||||
case 66:
|
||||
YY_RULE_SETUP
|
||||
{return UNIQUE;}
|
||||
YY_BREAK
|
||||
|
||||
case 67:
|
||||
YY_RULE_SETUP
|
||||
{return UNSIGNED;}
|
||||
YY_BREAK
|
||||
|
||||
case 68:
|
||||
YY_RULE_SETUP
|
||||
{return UPDATE;}
|
||||
YY_BREAK
|
||||
|
||||
case 69:
|
||||
YY_RULE_SETUP
|
||||
{return USER;}
|
||||
YY_BREAK
|
||||
|
||||
case 70:
|
||||
YY_RULE_SETUP
|
||||
{return VARCHAR;}
|
||||
YY_BREAK
|
||||
|
||||
case 71:
|
||||
YY_RULE_SETUP
|
||||
{return IDB_FLOAT;}
|
||||
YY_BREAK
|
||||
|
||||
case 72:
|
||||
YY_RULE_SETUP
|
||||
{return DOUBLE;}
|
||||
YY_BREAK
|
||||
|
||||
case 73:
|
||||
YY_RULE_SETUP
|
||||
{return REAL;}
|
||||
YY_BREAK
|
||||
|
||||
case 74:
|
||||
YY_RULE_SETUP
|
||||
{return CHARSET;}
|
||||
YY_BREAK
|
||||
|
||||
case 75:
|
||||
YY_RULE_SETUP
|
||||
{return IDB_IF;}
|
||||
YY_BREAK
|
||||
|
||||
case 76:
|
||||
YY_RULE_SETUP
|
||||
{return EXISTS;}
|
||||
YY_BREAK
|
||||
|
||||
case 77:
|
||||
YY_RULE_SETUP
|
||||
{return CHANGE;}
|
||||
YY_BREAK
|
||||
|
||||
case 78:
|
||||
YY_RULE_SETUP
|
||||
{return TRUNCATE;}
|
||||
YY_BREAK
|
||||
|
||||
case 79:
|
||||
YY_RULE_SETUP
|
||||
{return VARBINARY;}
|
||||
YY_BREAK
|
||||
|
||||
case 80:
|
||||
YY_RULE_SETUP
|
||||
{ lineno++;}
|
||||
YY_BREAK
|
||||
|
||||
case 81:
|
||||
YY_RULE_SETUP
|
||||
{
|
||||
/* ignore */
|
||||
}
|
||||
YY_BREAK
|
||||
|
||||
case 82:
|
||||
YY_RULE_SETUP
|
||||
{ddllval.str = scanner_copy(ddltext); return IDENT;}
|
||||
YY_BREAK
|
||||
|
||||
case 83:
|
||||
YY_RULE_SETUP
|
||||
{
|
||||
return ddltext[0];
|
||||
}
|
||||
YY_BREAK
|
||||
|
||||
case 84:
|
||||
YY_RULE_SETUP
|
||||
{
|
||||
/* ignore */
|
||||
}
|
||||
YY_BREAK
|
||||
|
||||
case 85:
|
||||
YY_RULE_SETUP
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
case YY_STATE_EOF(check1):
|
||||
case YY_STATE_EOF(check2):
|
||||
@@ -1285,7 +1385,8 @@ case YY_STATE_EOF(endquote):
|
||||
* in input().
|
||||
*/
|
||||
if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
|
||||
{ /* This was really a NUL. */
|
||||
{
|
||||
/* This was really a NUL. */
|
||||
yy_state_type yy_next_state;
|
||||
|
||||
yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
|
||||
@@ -1348,6 +1449,7 @@ case YY_STATE_EOF(endquote):
|
||||
if ( ! yy_did_buffer_switch_on_eof )
|
||||
YY_NEW_FILE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1371,6 +1473,7 @@ case YY_STATE_EOF(endquote):
|
||||
yy_bp = yytext_ptr + YY_MORE_ADJ;
|
||||
goto yy_find_action;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1402,7 +1505,8 @@ static int yy_get_next_buffer()
|
||||
"fatal flex scanner internal error--end of buffer missed" );
|
||||
|
||||
if ( yy_current_buffer->yy_fill_buffer == 0 )
|
||||
{ /* Don't try to fill the buffer, so this is an EOF. */
|
||||
{
|
||||
/* Don't try to fill the buffer, so this is an EOF. */
|
||||
if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
|
||||
{
|
||||
/* We matched a single character, the EOB, so
|
||||
@@ -1440,7 +1544,8 @@ static int yy_get_next_buffer()
|
||||
yy_current_buffer->yy_buf_size - number_to_move - 1;
|
||||
|
||||
while ( num_to_read <= 0 )
|
||||
{ /* Not enough room in the buffer - grow it. */
|
||||
{
|
||||
/* Not enough room in the buffer - grow it. */
|
||||
#ifdef YY_USES_REJECT
|
||||
YY_FATAL_ERROR(
|
||||
"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
|
||||
@@ -1532,17 +1637,21 @@ static yy_state_type yy_get_previous_state()
|
||||
for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
|
||||
{
|
||||
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
|
||||
|
||||
if ( yy_accept[yy_current_state] )
|
||||
{
|
||||
yy_last_accepting_state = yy_current_state;
|
||||
yy_last_accepting_cpos = yy_cp;
|
||||
}
|
||||
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
|
||||
if ( yy_current_state >= 393 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
}
|
||||
|
||||
@@ -1567,17 +1676,21 @@ yy_state_type yy_current_state;
|
||||
register char* yy_cp = yy_c_buf_p;
|
||||
|
||||
register YY_CHAR yy_c = 1;
|
||||
|
||||
if ( yy_accept[yy_current_state] )
|
||||
{
|
||||
yy_last_accepting_state = yy_current_state;
|
||||
yy_last_accepting_cpos = yy_cp;
|
||||
}
|
||||
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
|
||||
if ( yy_current_state >= 393 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_is_jam = (yy_current_state == 392);
|
||||
|
||||
@@ -1600,7 +1713,8 @@ register char *yy_bp;
|
||||
*yy_cp = yy_hold_char;
|
||||
|
||||
if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
|
||||
{ /* need to shift things up to make room */
|
||||
{
|
||||
/* need to shift things up to make room */
|
||||
/* +2 for EOB chars. */
|
||||
register int number_to_move = yy_n_chars + 2;
|
||||
register char* dest = &yy_current_buffer->yy_ch_buf[
|
||||
@@ -1651,7 +1765,8 @@ static int input()
|
||||
*yy_c_buf_p = '\0';
|
||||
|
||||
else
|
||||
{ /* need more input */
|
||||
{
|
||||
/* need more input */
|
||||
int offset = yy_c_buf_p - yytext_ptr;
|
||||
++yy_c_buf_p;
|
||||
|
||||
@@ -1680,6 +1795,7 @@ static int input()
|
||||
|
||||
if ( ! yy_did_buffer_switch_on_eof )
|
||||
YY_NEW_FILE;
|
||||
|
||||
#ifdef __cplusplus
|
||||
return yyinput();
|
||||
#else
|
||||
@@ -1772,6 +1888,7 @@ int size;
|
||||
YY_BUFFER_STATE b;
|
||||
|
||||
b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
|
||||
|
||||
if ( ! b )
|
||||
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
|
||||
|
||||
@@ -1781,6 +1898,7 @@ int size;
|
||||
* we need to put in 2 end-of-buffer characters.
|
||||
*/
|
||||
b->yy_ch_buf = (char*) yy_flex_alloc( b->yy_buf_size + 2 );
|
||||
|
||||
if ( ! b->yy_ch_buf )
|
||||
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
|
||||
|
||||
@@ -1893,6 +2011,7 @@ yy_size_t size;
|
||||
return 0;
|
||||
|
||||
b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
|
||||
|
||||
if ( ! b )
|
||||
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
|
||||
|
||||
@@ -1922,6 +2041,7 @@ yyconst char *yy_str;
|
||||
#endif
|
||||
{
|
||||
int len;
|
||||
|
||||
for ( len = 0; yy_str[len]; ++len )
|
||||
;
|
||||
|
||||
@@ -1947,6 +2067,7 @@ int len;
|
||||
/* Get memory for full buffer, including space for trailing EOB's. */
|
||||
n = len + 2;
|
||||
buf = (char*) yy_flex_alloc( n );
|
||||
|
||||
if ( ! buf )
|
||||
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
|
||||
|
||||
@@ -1956,6 +2077,7 @@ int len;
|
||||
buf[len] = buf[len + 1] = YY_END_OF_BUFFER_CHAR;
|
||||
|
||||
b = yy_scan_buffer( buf, n );
|
||||
|
||||
if ( ! b )
|
||||
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
|
||||
|
||||
@@ -2067,6 +2189,7 @@ int n;
|
||||
#endif
|
||||
{
|
||||
register int i;
|
||||
|
||||
for ( i = 0; i < n; ++i )
|
||||
s1[i] = s2[i];
|
||||
}
|
||||
@@ -2081,6 +2204,7 @@ yyconst char *s;
|
||||
#endif
|
||||
{
|
||||
register int n;
|
||||
|
||||
for ( n = 0; s[n]; ++n )
|
||||
;
|
||||
|
||||
@@ -2184,20 +2308,27 @@ void scanner_finish(void)
|
||||
yy_delete_buffer(scanbufhandle);
|
||||
free(scanbuf);
|
||||
unsigned int i;
|
||||
for(i=0; i<valbuf.size(); i++) {
|
||||
|
||||
for (i = 0; i < valbuf.size(); i++)
|
||||
{
|
||||
str = valbuf[i];
|
||||
if(str) {
|
||||
|
||||
if (str)
|
||||
{
|
||||
// std::cout << "valbuf:(" << str << ")" << std::endl;
|
||||
free(valbuf[i]);
|
||||
}
|
||||
}
|
||||
|
||||
valbuf.clear();
|
||||
}
|
||||
|
||||
char* scanner_copy (char* str)
|
||||
{
|
||||
char* nv = strdup(str);
|
||||
|
||||
if (nv)
|
||||
valbuf.push_back(nv);
|
||||
|
||||
return nv;
|
||||
}
|
||||
|
||||
@@ -53,8 +53,10 @@ namespace ddlpackage
|
||||
{
|
||||
if (!qname.fCatalog.empty())
|
||||
os << qname.fCatalog << ".";
|
||||
|
||||
if (!qname.fSchema.empty())
|
||||
os << qname.fSchema << ".";
|
||||
|
||||
os << qname.fName;
|
||||
return os;
|
||||
}
|
||||
@@ -68,15 +70,18 @@ namespace ddlpackage
|
||||
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;
|
||||
}
|
||||
@@ -104,20 +109,25 @@ namespace ddlpackage
|
||||
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;
|
||||
|
||||
@@ -103,7 +103,8 @@ std::ostream& operator<<(std::ostream& os, const TableDef& tableDef);
|
||||
/** @brief Verb List
|
||||
* Make sure to keep the enum and string list in-sync
|
||||
*/
|
||||
enum DDL_VERBS {
|
||||
enum DDL_VERBS
|
||||
{
|
||||
DDL_CREATE,
|
||||
DDL_ALTER,
|
||||
DDL_DROP,
|
||||
@@ -112,7 +113,8 @@ enum DDL_VERBS {
|
||||
/** @brief Subject List
|
||||
* Make sure to keep the enum and string list in-sync
|
||||
*/
|
||||
enum DDL_SUBJECTS {
|
||||
enum DDL_SUBJECTS
|
||||
{
|
||||
DDL_TABLE,
|
||||
DDL_INDEX,
|
||||
DDL_INVALID_SUBJECT
|
||||
@@ -137,7 +139,8 @@ const std::string ConstraintAttrStrings[] =
|
||||
};
|
||||
|
||||
|
||||
enum DDL_REFERENTIAL_ACTION {
|
||||
enum DDL_REFERENTIAL_ACTION
|
||||
{
|
||||
DDL_CASCADE,
|
||||
DDL_SET_NULL,
|
||||
DDL_SET_DEFAULT,
|
||||
@@ -155,7 +158,8 @@ const std::string ReferentialActionStrings[] =
|
||||
"invalid_action"
|
||||
};
|
||||
|
||||
enum DDL_MATCH_TYPE {
|
||||
enum DDL_MATCH_TYPE
|
||||
{
|
||||
DDL_FULL,
|
||||
DDL_PARTIAL,
|
||||
DDL_INVALID_MATCH_TYPE
|
||||
@@ -172,7 +176,8 @@ const std::string MatchTypeStrings[] =
|
||||
/** @brief Constraint List
|
||||
* Make sure to keep the enum and string list in-sync
|
||||
*/
|
||||
enum DDL_CONSTRAINTS {
|
||||
enum DDL_CONSTRAINTS
|
||||
{
|
||||
DDL_PRIMARY_KEY,
|
||||
DDL_FOREIGN_KEY,
|
||||
DDL_CHECK,
|
||||
@@ -199,7 +204,8 @@ const std::string ConstraintString[] =
|
||||
/** @brief Datatype List
|
||||
* Make sure to keep the enum, string, and length list in-sync
|
||||
*/
|
||||
enum DDL_DATATYPES {
|
||||
enum DDL_DATATYPES
|
||||
{
|
||||
DDL_BIT,
|
||||
DDL_TINYINT,
|
||||
DDL_CHAR,
|
||||
@@ -325,7 +331,8 @@ const int DDLDatatypeLength[] =
|
||||
-1 // INVALID LENGTH
|
||||
};
|
||||
|
||||
enum DDL_SERIAL_TYPE {
|
||||
enum DDL_SERIAL_TYPE
|
||||
{
|
||||
DDL_TABLE_DEF,
|
||||
DDL_COLUMN_DEF,
|
||||
DDL_COLUMN_CONSTRAINT_DEF,
|
||||
@@ -579,6 +586,7 @@ struct CreateTableStatement : public SqlStatement
|
||||
std::string schemaName() const
|
||||
{
|
||||
if (!fTableDef || !fTableDef->fQualifiedName) return "UNKNOWN";
|
||||
|
||||
return fTableDef->fQualifiedName->fSchema;
|
||||
}
|
||||
|
||||
@@ -935,6 +943,7 @@ struct AtaRenameColumn : public AlterTableAction
|
||||
{
|
||||
if (comment)
|
||||
fComment = comment;
|
||||
|
||||
fDefaultValue = 0;
|
||||
}
|
||||
|
||||
@@ -1378,6 +1387,7 @@ struct AlterTableStatement : public SqlStatement
|
||||
std::string schemaName() const
|
||||
{
|
||||
if (!fTableName) return "UNKNOWN";
|
||||
|
||||
return fTableName->fSchema;
|
||||
}
|
||||
|
||||
@@ -1495,6 +1505,7 @@ struct DropTableStatement : public SqlStatement
|
||||
std::string schemaName() const
|
||||
{
|
||||
if (!fTableName) return "UNKNOWN";
|
||||
|
||||
return fTableName->fSchema;
|
||||
}
|
||||
|
||||
@@ -1528,6 +1539,7 @@ struct TruncTableStatement : public SqlStatement
|
||||
std::string schemaName() const
|
||||
{
|
||||
if (!fTableName) return "UNKNOWN";
|
||||
|
||||
return fTableName->fSchema;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
|
||||
#include "ddlpkg.h"
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
DropIndexStatement::~DropIndexStatement()
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
DropPartitionStatement::DropPartitionStatement(QualifiedName* qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
@@ -39,8 +40,10 @@ ostream& DropPartitionStatement::put(ostream& os) const
|
||||
os << "Mark partitions out of service: " << *fTableName << endl;
|
||||
os << " partitions: ";
|
||||
set<BRM::LogicalPartition>::const_iterator it;
|
||||
|
||||
for (it = fPartitions.begin(); it != fPartitions.end(); ++it)
|
||||
os << (*it) << " ";
|
||||
|
||||
os << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
DropTableStatement::DropTableStatement(QualifiedName* qualifiedName, bool cascade) :
|
||||
fTableName(qualifiedName),
|
||||
|
||||
@@ -43,6 +43,7 @@ int main(int argc, char* argv[])
|
||||
po::variables_map vm;
|
||||
po::store (po::parse_command_line (argc, argv, desc), vm);
|
||||
po::notify (vm);
|
||||
|
||||
if (vm.count ("sql"))
|
||||
sqlfile = vm["sql"].as <string> ();
|
||||
|
||||
@@ -51,12 +52,14 @@ int main(int argc, char* argv[])
|
||||
count = vm["count"].as<int>();
|
||||
|
||||
SqlFileParser parser;
|
||||
|
||||
if (vm.count ("bisond"))
|
||||
parser.SetDebug(true);
|
||||
|
||||
parser.Parse(sqlfile);
|
||||
|
||||
if(parser.Good()) {
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
cout << "Parser succeeded." << endl;
|
||||
@@ -64,7 +67,8 @@ int main(int argc, char* argv[])
|
||||
cout << ptree;
|
||||
cout << endl;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
cout << "Parser failed." << endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
MarkPartitionStatement::MarkPartitionStatement(QualifiedName* qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
@@ -39,8 +40,10 @@ ostream& MarkPartitionStatement::put(ostream& os) const
|
||||
os << "Mark partition out of service: " << *fTableName;
|
||||
os << " partitions: ";
|
||||
set<BRM::LogicalPartition>::const_iterator it;
|
||||
|
||||
for (it = fPartitions.begin(); it != fPartitions.end(); ++it)
|
||||
os << (*it) << " ";
|
||||
|
||||
os << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,8 @@ std::string itoa(const int i);
|
||||
|
||||
// READ & WRITE STATEMENT TESTS
|
||||
|
||||
class DDLWriteReadTest : public CppUnit::TestFixture {
|
||||
class DDLWriteReadTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE( DDLWriteReadTest );
|
||||
|
||||
@@ -336,7 +337,8 @@ public:
|
||||
// PARSE STATEMENT TESTS
|
||||
|
||||
|
||||
class DDLCreateTableParserTest : public CppUnit::TestFixture {
|
||||
class DDLCreateTableParserTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE( DDLCreateTableParserTest );
|
||||
|
||||
@@ -401,11 +403,13 @@ public:
|
||||
|
||||
delete pDDLPackage;
|
||||
}
|
||||
|
||||
fin.close();
|
||||
}
|
||||
};
|
||||
|
||||
class DDLCreateIndexParserTest : public CppUnit::TestFixture {
|
||||
class DDLCreateIndexParserTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE( DDLCreateIndexParserTest );
|
||||
|
||||
@@ -470,13 +474,15 @@ public:
|
||||
|
||||
delete pDDLPackage;
|
||||
}
|
||||
|
||||
fin.close();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class DDLAlterTableParserTest : public CppUnit::TestFixture {
|
||||
class DDLAlterTableParserTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE( DDLAlterTableParserTest );
|
||||
|
||||
@@ -541,12 +547,14 @@ public:
|
||||
|
||||
delete pDDLPackage;
|
||||
}
|
||||
|
||||
fin.close();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class DDLDropTableParserTest : public CppUnit::TestFixture {
|
||||
class DDLDropTableParserTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE( DDLDropTableParserTest );
|
||||
|
||||
@@ -612,12 +620,14 @@ public:
|
||||
|
||||
delete pDDLPackage;
|
||||
}
|
||||
|
||||
fin.close();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class DDLDropIndexParserTest : public CppUnit::TestFixture {
|
||||
class DDLDropIndexParserTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE( DDLDropIndexParserTest );
|
||||
|
||||
@@ -683,6 +693,7 @@ public:
|
||||
|
||||
delete pDDLPackage;
|
||||
}
|
||||
|
||||
fin.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
RestorePartitionStatement::RestorePartitionStatement(QualifiedName* qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
@@ -39,8 +40,10 @@ ostream& RestorePartitionStatement::put(ostream& os) const
|
||||
os << "Mark partition out of service: " << *fTableName;
|
||||
os << " partitions: ";
|
||||
set<BRM::LogicalPartition>::const_iterator it;
|
||||
|
||||
for (it = fPartitions.begin(); it != fPartitions.end(); ++it)
|
||||
os << (*it) << " ";
|
||||
|
||||
os << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,9 @@ void read_vec(vector<T*>& v, ByteStream& bs)
|
||||
T* x;
|
||||
quadbyte count;
|
||||
bs >> count;
|
||||
while(count--) {
|
||||
|
||||
while (count--)
|
||||
{
|
||||
x = new T;
|
||||
x->unserialize(bs);
|
||||
v.push_back(x);
|
||||
@@ -122,6 +124,7 @@ int AlterTableStatement::unserialize(ByteStream& bytestream)
|
||||
// read alter action list
|
||||
quadbyte action_count;
|
||||
bytestream >> action_count;
|
||||
|
||||
for ( unsigned int i = 0; i < action_count; i++ )
|
||||
{
|
||||
// read action type
|
||||
@@ -134,65 +137,78 @@ int AlterTableStatement::unserialize(ByteStream& bytestream)
|
||||
ata->unserialize(bytestream);
|
||||
fActions.push_back( ata );
|
||||
break;
|
||||
|
||||
case DDL_ATA_ADD_COLUMNS:
|
||||
ata = new AtaAddColumns();
|
||||
ata->unserialize(bytestream);
|
||||
fActions.push_back( ata );
|
||||
break;
|
||||
|
||||
case DDL_ATA_DROP_COLUMN:
|
||||
ata = new AtaDropColumn();
|
||||
ata->unserialize(bytestream);
|
||||
fActions.push_back( ata );
|
||||
break;
|
||||
|
||||
case DDL_ATA_DROP_COLUMNS:
|
||||
ata = new AtaDropColumns();
|
||||
ata->unserialize(bytestream);
|
||||
fActions.push_back( ata );
|
||||
break;
|
||||
|
||||
case DDL_ATA_ADD_TABLE_CONSTRAINT:
|
||||
ata = new AtaAddTableConstraint();
|
||||
ata->unserialize(bytestream);
|
||||
fActions.push_back( ata );
|
||||
break;
|
||||
|
||||
case DDL_ATA_SET_COLUMN_DEFAULT:
|
||||
ata = new AtaSetColumnDefault();
|
||||
ata->unserialize(bytestream);
|
||||
fActions.push_back( ata );
|
||||
break;
|
||||
|
||||
case DDL_ATA_DROP_COLUMN_DEFAULT:
|
||||
ata = new AtaDropColumnDefault();
|
||||
ata->unserialize(bytestream);
|
||||
fActions.push_back( ata );
|
||||
break;
|
||||
|
||||
case DDL_ATA_DROP_TABLE_CONSTRAINT:
|
||||
ata = new AtaDropTableConstraint();
|
||||
ata->unserialize(bytestream);
|
||||
fActions.push_back( ata );
|
||||
break;
|
||||
|
||||
case DDL_ATA_RENAME_TABLE:
|
||||
ata = new AtaRenameTable();
|
||||
ata->unserialize(bytestream);
|
||||
fActions.push_back( ata );
|
||||
break;
|
||||
|
||||
case DDL_ATA_RENAME_COLUMN:
|
||||
ata = new AtaRenameColumn();
|
||||
ata->unserialize(bytestream);
|
||||
fActions.push_back( ata );
|
||||
break;
|
||||
|
||||
case DDL_ATA_MODIFY_COLUMN_TYPE:
|
||||
ata = new AtaModifyColumnType();
|
||||
ata->unserialize(bytestream);
|
||||
fActions.push_back( ata );
|
||||
break;
|
||||
|
||||
case DDL_ATA_TABLE_COMMENT:
|
||||
ata = new AtaTableComment();
|
||||
ata->unserialize(bytestream);
|
||||
fActions.push_back( ata );
|
||||
break;
|
||||
|
||||
default:
|
||||
throw ("Bad typecode for AlterTableAction");
|
||||
break;
|
||||
}
|
||||
|
||||
bytestream >> fSessionID;
|
||||
bytestream >> fSql;
|
||||
bytestream >> fOwner;
|
||||
@@ -253,6 +269,7 @@ int CreateIndexStatement::unserialize(ByteStream& bytestream)
|
||||
|
||||
|
||||
std::string columnname;
|
||||
|
||||
for ( unsigned int i = 0; i < column_count; i++ )
|
||||
{
|
||||
bytestream >> columnname;
|
||||
@@ -286,6 +303,7 @@ int CreateIndexStatement::serialize(ByteStream& bytestream)
|
||||
// write column name list
|
||||
bytestream << (quadbyte) fColumnNames.size();
|
||||
ColumnNameList::const_iterator itr;
|
||||
|
||||
for (itr = fColumnNames.begin();
|
||||
itr != fColumnNames.end();
|
||||
++itr)
|
||||
@@ -494,6 +512,7 @@ int MarkPartitionStatement::unserialize(ByteStream& bytestream)
|
||||
uint32_t size = 0;
|
||||
bytestream >> size;
|
||||
BRM::LogicalPartition part;
|
||||
|
||||
for (uint32_t i = 0; i < size; i++)
|
||||
{
|
||||
part.unserialize(bytestream);
|
||||
@@ -525,6 +544,7 @@ int MarkPartitionStatement::serialize(ByteStream& bytestream)
|
||||
|
||||
bytestream << (uint32_t)fPartitions.size();
|
||||
set<BRM::LogicalPartition>::iterator it;
|
||||
|
||||
for (it = fPartitions.begin(); it != fPartitions.end(); ++it)
|
||||
(*it).serialize(bytestream);
|
||||
|
||||
@@ -555,6 +575,7 @@ int DropPartitionStatement::unserialize(ByteStream& bytestream)
|
||||
uint32_t size = 0;
|
||||
bytestream >> size;
|
||||
BRM::LogicalPartition part;
|
||||
|
||||
for (uint32_t i = 0; i < size; i++)
|
||||
{
|
||||
part.unserialize(bytestream);
|
||||
@@ -584,6 +605,7 @@ int DropPartitionStatement::serialize(ByteStream& bytestream)
|
||||
bytestream << fOwner;
|
||||
bytestream << (uint32_t)fPartitions.size();
|
||||
set<BRM::LogicalPartition>::iterator it;
|
||||
|
||||
for (it = fPartitions.begin(); it != fPartitions.end(); ++it)
|
||||
(*it).serialize(bytestream);
|
||||
|
||||
@@ -614,6 +636,7 @@ int RestorePartitionStatement::unserialize(ByteStream& bytestream)
|
||||
uint32_t size = 0;
|
||||
bytestream >> size;
|
||||
BRM::LogicalPartition part;
|
||||
|
||||
for (uint32_t i = 0; i < size; i++)
|
||||
{
|
||||
part.unserialize(bytestream);
|
||||
@@ -644,6 +667,7 @@ int RestorePartitionStatement::serialize(ByteStream& bytestream)
|
||||
|
||||
bytestream << (uint32_t)fPartitions.size();
|
||||
set<BRM::LogicalPartition>::iterator it;
|
||||
|
||||
for (it = fPartitions.begin(); it != fPartitions.end(); ++it)
|
||||
(*it).serialize(bytestream);
|
||||
|
||||
@@ -722,6 +746,7 @@ int AtaDropColumns::unserialize(ByteStream& bytestream)
|
||||
quadbyte count;
|
||||
bytestream >> count;
|
||||
string colName;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
bytestream >> colName;
|
||||
@@ -742,6 +767,7 @@ int AtaDropColumns::serialize(ByteStream& bytestream)
|
||||
bytestream << (quadbyte) fColumns.size();
|
||||
|
||||
ColumnNameList::const_iterator itr;
|
||||
|
||||
for (itr = fColumns.begin(); itr != fColumns.end(); itr++)
|
||||
{
|
||||
bytestream << *itr;
|
||||
@@ -771,14 +797,17 @@ int AtaAddTableConstraint::unserialize(ByteStream& bytestream)
|
||||
fTableConstraint = new TableUniqueConstraintDef;
|
||||
fTableConstraint->unserialize(bytestream);
|
||||
break;
|
||||
|
||||
case DDL_TABLE_PRIMARY_CONSTRAINT_DEF:
|
||||
fTableConstraint = new TablePrimaryKeyConstraintDef;
|
||||
fTableConstraint->unserialize(bytestream);
|
||||
break;
|
||||
|
||||
case DDL_TABLE_CHECK_CONSTRAINT_DEF:
|
||||
fTableConstraint = new TableCheckConstraintDef;
|
||||
fTableConstraint->unserialize(bytestream);
|
||||
break;
|
||||
|
||||
case DDL_TABLE_REFERENCES_CONSTRAINT_DEF:
|
||||
fTableConstraint = new TableReferencesConstraintDef;
|
||||
fTableConstraint->unserialize(bytestream);
|
||||
@@ -1032,8 +1061,10 @@ int AtaRenameColumn::unserialize(ByteStream& bytestream)
|
||||
// read column names
|
||||
bytestream >> fName;
|
||||
bytestream >> fNewName;
|
||||
|
||||
if (!fNewType)
|
||||
fNewType = new ColumnType(DDL_INT);
|
||||
|
||||
fNewType->unserialize(bytestream);
|
||||
|
||||
read_vec<ColumnConstraintDef>(fConstraints, bytestream);
|
||||
@@ -1044,13 +1075,16 @@ int AtaRenameColumn::unserialize(ByteStream& bytestream)
|
||||
quadbyte type;
|
||||
bytestream >> type;
|
||||
|
||||
if(type == DDL_NULL) {
|
||||
if (type == DDL_NULL)
|
||||
{
|
||||
fDefaultValue = 0;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
fDefaultValue = new ColumnDefaultValue();
|
||||
fDefaultValue->unserialize(bytestream);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1062,20 +1096,25 @@ int AtaRenameColumn::serialize(ByteStream& bytestream)
|
||||
bytestream << (quadbyte) DDL_ATA_RENAME_COLUMN;
|
||||
bytestream << fName;
|
||||
bytestream << fNewName;
|
||||
|
||||
if (!fNewType)
|
||||
fNewType = new ColumnType(DDL_INT);
|
||||
|
||||
fNewType->serialize(bytestream);
|
||||
|
||||
// serialize column constraints.
|
||||
write_vec<ColumnConstraintDef>(fConstraints, bytestream);
|
||||
|
||||
if(0 == fDefaultValue) {
|
||||
if (0 == fDefaultValue)
|
||||
{
|
||||
bytestream << (quadbyte)DDL_NULL;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
bytestream << (quadbyte)DDL_COLUMN_DEFAULT_VALUE;
|
||||
fDefaultValue->serialize( bytestream );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1259,10 +1298,12 @@ int ColumnDef::unserialize(ByteStream& bytestream)
|
||||
quadbyte type;
|
||||
bytestream >> type;
|
||||
|
||||
if(type == DDL_NULL) {
|
||||
if (type == DDL_NULL)
|
||||
{
|
||||
fDefaultValue = 0;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
fDefaultValue = new ColumnDefaultValue();
|
||||
fDefaultValue->unserialize(bytestream);
|
||||
}
|
||||
@@ -1284,10 +1325,12 @@ int ColumnDef::serialize(ByteStream& bytestream)
|
||||
// serialize column constraints.
|
||||
write_vec<ColumnConstraintDef>(fConstraints, bytestream);
|
||||
|
||||
if(0 == fDefaultValue) {
|
||||
if (0 == fDefaultValue)
|
||||
{
|
||||
bytestream << (quadbyte)DDL_NULL;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
bytestream << (quadbyte)DDL_COLUMN_DEFAULT_VALUE;
|
||||
fDefaultValue->serialize( bytestream );
|
||||
}
|
||||
@@ -1371,6 +1414,7 @@ int TableUniqueConstraintDef::serialize(ByteStream& bytestream)
|
||||
bytestream << (quadbyte) fColumnNameList.size();
|
||||
|
||||
ColumnNameList::const_iterator itr;
|
||||
|
||||
for (itr = fColumnNameList.begin(); itr != fColumnNameList.end(); ++itr)
|
||||
{
|
||||
bytestream << *itr;
|
||||
@@ -1415,6 +1459,7 @@ int TablePrimaryKeyConstraintDef::serialize(ByteStream& bytestream)
|
||||
bytestream << (quadbyte) fColumnNameList.size();
|
||||
|
||||
ColumnNameList::const_iterator itr;
|
||||
|
||||
for (itr = fColumnNameList.begin(); itr != fColumnNameList.end(); ++itr)
|
||||
{
|
||||
bytestream << *itr;
|
||||
@@ -1482,7 +1527,9 @@ int TableReferencesConstraintDef::unserialize(ByteStream& bytestream)
|
||||
|
||||
// Local columns
|
||||
bytestream >> count;
|
||||
while(count-- > 0) {
|
||||
|
||||
while (count-- > 0)
|
||||
{
|
||||
bytestream >> str;
|
||||
fColumns.push_back(str);
|
||||
}
|
||||
@@ -1493,7 +1540,9 @@ int TableReferencesConstraintDef::unserialize(ByteStream& bytestream)
|
||||
|
||||
// Foreign columns
|
||||
bytestream >> count;
|
||||
while(count-- > 0) {
|
||||
|
||||
while (count-- > 0)
|
||||
{
|
||||
bytestream >> str;
|
||||
fForeignColumns.push_back(str);
|
||||
}
|
||||
@@ -1506,10 +1555,13 @@ int TableReferencesConstraintDef::unserialize(ByteStream& bytestream)
|
||||
// Ref Action
|
||||
quadbyte sertype;
|
||||
bytestream >> sertype;
|
||||
if(sertype == DDL_NULL) {
|
||||
|
||||
if (sertype == DDL_NULL)
|
||||
{
|
||||
fRefAction = 0;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
fRefAction = new ReferentialAction();
|
||||
fRefAction->unserialize(bytestream);
|
||||
}
|
||||
@@ -1528,6 +1580,7 @@ int TableReferencesConstraintDef::serialize(ByteStream& bytestream)
|
||||
size = fColumns.size();
|
||||
bytestream << size;
|
||||
ColumnNameList::const_iterator itr;
|
||||
|
||||
for (itr = fColumns.begin(); itr != fColumns.end(); ++itr)
|
||||
bytestream << *itr;
|
||||
|
||||
@@ -1537,6 +1590,7 @@ int TableReferencesConstraintDef::serialize(ByteStream& bytestream)
|
||||
// Foreign columns
|
||||
size = fForeignColumns.size();
|
||||
bytestream << size;
|
||||
|
||||
for (itr = fForeignColumns.begin(); itr != fForeignColumns.end(); ++itr)
|
||||
bytestream << *itr;
|
||||
|
||||
@@ -1544,10 +1598,12 @@ int TableReferencesConstraintDef::serialize(ByteStream& bytestream)
|
||||
bytestream << (quadbyte) fMatchType;
|
||||
|
||||
// Ref action
|
||||
if(0 == fRefAction) {
|
||||
if (0 == fRefAction)
|
||||
{
|
||||
bytestream << (quadbyte) DDL_NULL;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
bytestream << (quadbyte) DDL_REF_ACTION;
|
||||
fRefAction->serialize(bytestream);
|
||||
}
|
||||
@@ -1618,21 +1674,25 @@ int TableDef::unserialize(ByteStream& bytestream)
|
||||
constraint->unserialize(bytestream);
|
||||
fConstraints.push_back( constraint );
|
||||
break;
|
||||
|
||||
case DDL_TABLE_PRIMARY_CONSTRAINT_DEF:
|
||||
constraint = new TablePrimaryKeyConstraintDef();
|
||||
constraint->unserialize(bytestream);
|
||||
fConstraints.push_back( constraint );
|
||||
break;
|
||||
|
||||
case DDL_TABLE_REFERENCES_CONSTRAINT_DEF:
|
||||
constraint = new TableReferencesConstraintDef();
|
||||
constraint->unserialize(bytestream);
|
||||
fConstraints.push_back( constraint );
|
||||
break;
|
||||
|
||||
case DDL_TABLE_CHECK_CONSTRAINT_DEF:
|
||||
constraint = new TableCheckConstraintDef();
|
||||
constraint->unserialize(bytestream);
|
||||
fConstraints.push_back( constraint );
|
||||
break;
|
||||
|
||||
default:
|
||||
throw ("Bad typecode for TableConstraintDef");
|
||||
break;
|
||||
@@ -1641,6 +1701,7 @@ int TableDef::unserialize(ByteStream& bytestream)
|
||||
|
||||
// read option maps list
|
||||
bytestream >> count;
|
||||
|
||||
for ( unsigned int i = 0; i < count; i++ )
|
||||
{
|
||||
// read option map
|
||||
@@ -1669,6 +1730,7 @@ int TableDef::serialize(ByteStream& bytestream)
|
||||
bytestream << size;
|
||||
|
||||
TableConstraintDefList::const_iterator itr;
|
||||
|
||||
for (itr = fConstraints.begin();
|
||||
itr != fConstraints.end();
|
||||
++itr)
|
||||
@@ -1683,6 +1745,7 @@ int TableDef::serialize(ByteStream& bytestream)
|
||||
|
||||
pair<string, string> oval;
|
||||
TableOptionMap::const_iterator itr2;
|
||||
|
||||
for (itr2 = fOptions.begin();
|
||||
itr2 != fOptions.end();
|
||||
++itr2)
|
||||
|
||||
@@ -41,7 +41,8 @@ int ddllex_init_extra(void* user_defined,void** yyscanner);
|
||||
int ddllex_destroy(void* yyscanner);
|
||||
int ddlparse(ddlpackage::pass_to_bison* x);
|
||||
void set_schema(std::string schema);
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
SqlParser::SqlParser() :
|
||||
@@ -73,9 +74,11 @@ namespace ddlpackage {
|
||||
|
||||
const ParseTree& SqlParser::GetParseTree(void)
|
||||
{
|
||||
if(!Good()) {
|
||||
if (!Good())
|
||||
{
|
||||
throw logic_error("The ParseTree is invalid");
|
||||
}
|
||||
|
||||
return fParseTree;
|
||||
}
|
||||
|
||||
@@ -105,7 +108,9 @@ namespace ddlpackage {
|
||||
|
||||
ifstream ifsql;
|
||||
ifsql.open(sqlfile.c_str());
|
||||
if(!ifsql.is_open()) {
|
||||
|
||||
if (!ifsql.is_open())
|
||||
{
|
||||
perror(sqlfile.c_str());
|
||||
return fStatus;
|
||||
}
|
||||
@@ -116,7 +121,8 @@ namespace ddlpackage {
|
||||
length = ifsql.tellg();
|
||||
ifsql.seekg (0, ios::beg);
|
||||
|
||||
if(length > sizeof(sqlbuf) - 1) {
|
||||
if (length > sizeof(sqlbuf) - 1)
|
||||
{
|
||||
throw length_error("SqlFileParser has file size hard limit of 16K.");
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,8 @@ struct scan_data
|
||||
valbuf_t valbuf;
|
||||
};
|
||||
|
||||
struct pass_to_bison {
|
||||
struct pass_to_bison
|
||||
{
|
||||
ParseTree* fParseTree;
|
||||
std::string fDBSchema;
|
||||
void* scanner;
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
#include "ddlpkg.h"
|
||||
#undef DDLPKG_DLLEXPORT
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
static uint32_t sessionID = 1;
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
#include "ddlpkg.h"
|
||||
#undef DDLPKG_DLLEXPORT
|
||||
|
||||
namespace ddlpackage {
|
||||
namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -33,10 +34,12 @@ namespace ddlpackage {
|
||||
{
|
||||
vector<SqlStatement*>::const_iterator itr;
|
||||
|
||||
for(itr = ssl.fList.begin(); itr != ssl.fList.end(); ++itr) {
|
||||
for (itr = ssl.fList.begin(); itr != ssl.fList.end(); ++itr)
|
||||
{
|
||||
SqlStatement& stmt = **itr;
|
||||
os << stmt;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -50,7 +53,9 @@ namespace ddlpackage {
|
||||
SqlStatementList::~SqlStatementList()
|
||||
{
|
||||
vector<SqlStatement*>::iterator itr;
|
||||
for(itr = fList.begin(); itr != fList.end(); ++itr) {
|
||||
|
||||
for (itr = fList.begin(); itr != fList.end(); ++itr)
|
||||
{
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,13 +35,17 @@ namespace ddlpackage
|
||||
{
|
||||
{
|
||||
ColumnDefList::iterator itr;
|
||||
for(itr=fColumns.begin(); itr != fColumns.end(); itr++) {
|
||||
|
||||
for (itr = fColumns.begin(); itr != fColumns.end(); itr++)
|
||||
{
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
{
|
||||
TableConstraintDefList::iterator itr;
|
||||
for(itr=fConstraints.begin(); itr != fConstraints.end(); itr++) {
|
||||
|
||||
for (itr = fConstraints.begin(); itr != fConstraints.end(); itr++)
|
||||
{
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
@@ -53,7 +57,8 @@ namespace ddlpackage
|
||||
TableDef::TableDef(QualifiedName* name, TableElementList* elements, TableOptionMap* options) :
|
||||
fQualifiedName(name)
|
||||
{
|
||||
if(options) {
|
||||
if (options)
|
||||
{
|
||||
fOptions = *options;
|
||||
delete options;
|
||||
}
|
||||
@@ -66,14 +71,21 @@ namespace ddlpackage
|
||||
them out into separately typed lists.
|
||||
*/
|
||||
TableElementList::iterator itr;
|
||||
for(itr = elements->begin(); itr != elements->end(); ++itr) {
|
||||
|
||||
for (itr = elements->begin(); itr != elements->end(); ++itr)
|
||||
{
|
||||
column = dynamic_cast<ColumnDef*>(*itr);
|
||||
if(column) {
|
||||
|
||||
if (column)
|
||||
{
|
||||
fColumns.push_back(column);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
constraint = dynamic_cast<TableConstraintDef*>(*itr);
|
||||
if(constraint) {
|
||||
|
||||
if (constraint)
|
||||
{
|
||||
fConstraints.push_back(constraint);
|
||||
}
|
||||
}
|
||||
@@ -87,6 +99,7 @@ namespace ddlpackage
|
||||
ostream& operator<<(ostream& os, const TableDef& tableDef)
|
||||
{
|
||||
os << "CreateTable ";
|
||||
|
||||
if (tableDef.fQualifiedName->fSchema != "")
|
||||
//cout << tableDef.fQualifiedName->fSchema << ".";
|
||||
os << tableDef.fQualifiedName->fName
|
||||
@@ -96,6 +109,7 @@ namespace ddlpackage
|
||||
|
||||
{
|
||||
ColumnDefList::const_iterator itr;
|
||||
|
||||
for (itr = tableDef.fColumns.begin();
|
||||
itr != tableDef.fColumns.end(); ++itr)
|
||||
{
|
||||
@@ -107,6 +121,7 @@ namespace ddlpackage
|
||||
|
||||
{
|
||||
TableConstraintDefList::const_iterator itr;
|
||||
|
||||
for (itr = tableDef.fConstraints.begin();
|
||||
itr != tableDef.fConstraints.end();
|
||||
++itr)
|
||||
@@ -118,10 +133,14 @@ namespace ddlpackage
|
||||
pair<string, string> oval;
|
||||
TableOptionMap::const_iterator oitr;
|
||||
os << "Table Options" << endl;
|
||||
if(!tableDef.fOptions.empty()) {
|
||||
|
||||
if (!tableDef.fOptions.empty())
|
||||
{
|
||||
TableOptionMap::const_iterator oitr;
|
||||
|
||||
for (oitr = tableDef.fOptions.begin();
|
||||
oitr != tableDef.fOptions.end(); ++oitr) {
|
||||
oitr != tableDef.fOptions.end(); ++oitr)
|
||||
{
|
||||
oval = *oitr;
|
||||
os << " " << oval.first << "=" << oval.second << endl;
|
||||
}
|
||||
@@ -186,12 +205,14 @@ namespace ddlpackage
|
||||
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << "(";
|
||||
|
||||
for (itr = fColumnNameList.begin();
|
||||
itr != fColumnNameList.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
|
||||
os << ")";
|
||||
return os;
|
||||
}
|
||||
@@ -210,12 +231,14 @@ namespace ddlpackage
|
||||
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << "(";
|
||||
|
||||
for (itr = fColumnNameList.begin();
|
||||
itr != fColumnNameList.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
|
||||
os << ")";
|
||||
|
||||
return os;
|
||||
@@ -245,12 +268,14 @@ namespace ddlpackage
|
||||
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << "lcols (";
|
||||
|
||||
for (itr = fColumns.begin();
|
||||
itr != fColumns.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
|
||||
os << ")";
|
||||
|
||||
os << " ftable=" << *fTableName;
|
||||
@@ -258,12 +283,14 @@ namespace ddlpackage
|
||||
os << " ";
|
||||
|
||||
os << "fcols (";
|
||||
|
||||
for (itr = fForeignColumns.begin();
|
||||
itr != fForeignColumns.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
|
||||
os << ")";
|
||||
|
||||
return os;
|
||||
@@ -272,12 +299,14 @@ namespace ddlpackage
|
||||
{
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << '(';
|
||||
|
||||
for (itr = columnNames.begin();
|
||||
itr != columnNames.end();
|
||||
++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
|
||||
os << ')';
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,8 @@ bool parse_file(char* fileName)
|
||||
return parser.Good();
|
||||
}
|
||||
|
||||
class ParserTest : public CppUnit::TestFixture {
|
||||
class ParserTest : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(ParserTest);
|
||||
CPPUNIT_TEST(atac01);
|
||||
CPPUNIT_TEST(atac05);
|
||||
@@ -319,7 +320,8 @@ void t_sertest(T* x)
|
||||
}
|
||||
|
||||
|
||||
class SerializeTest : public CppUnit::TestFixture {
|
||||
class SerializeTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE(SerializeTest);
|
||||
CPPUNIT_TEST(qname);
|
||||
@@ -375,6 +377,7 @@ public:
|
||||
{
|
||||
SqlFileParser p;
|
||||
p.Parse("sql/atrc01.sql");
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -389,6 +392,7 @@ public:
|
||||
{
|
||||
SqlFileParser p;
|
||||
p.Parse("sql/atmct01.sql");
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -403,6 +407,7 @@ public:
|
||||
{
|
||||
SqlFileParser p;
|
||||
p.Parse("sql/atrt01.sql");
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -416,6 +421,7 @@ public:
|
||||
{
|
||||
SqlFileParser p;
|
||||
p.Parse("sql/atdtc01.sql");
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -429,6 +435,7 @@ public:
|
||||
{
|
||||
SqlFileParser p;
|
||||
p.Parse("sql/atmcdd01.sql");
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -442,6 +449,7 @@ public:
|
||||
{
|
||||
SqlFileParser p;
|
||||
p.Parse("sql/atmcsd01.sql");
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -456,6 +464,7 @@ public:
|
||||
{
|
||||
SqlFileParser p;
|
||||
p.Parse("sql/atdc01.sql");
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -469,6 +478,7 @@ public:
|
||||
{
|
||||
SqlFileParser p;
|
||||
p.Parse("sql/atatc01.sql");
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -498,10 +508,12 @@ public:
|
||||
files.push_back("sql/ct11.sql");
|
||||
|
||||
vector<string>::const_iterator itr;
|
||||
|
||||
for (itr = files.begin(); itr != files.end(); ++itr)
|
||||
{
|
||||
SqlFileParser p;
|
||||
p.Parse(*itr);
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -511,6 +523,7 @@ public:
|
||||
ColumnDefList* columns = &(ct->fTableDef->fColumns);
|
||||
|
||||
ColumnDefList::const_iterator itr;
|
||||
|
||||
for (itr = columns->begin();
|
||||
itr != columns->end();
|
||||
++itr)
|
||||
@@ -544,10 +557,12 @@ public:
|
||||
files.push_back("sql/ct11.sql");
|
||||
|
||||
vector<string>::const_iterator itr;
|
||||
|
||||
for (itr = files.begin(); itr != files.end(); ++itr)
|
||||
{
|
||||
SqlFileParser p;
|
||||
p.Parse(*itr);
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -647,11 +662,13 @@ public:
|
||||
files.push_back("sql/ct11.sql");
|
||||
|
||||
vector<string>::const_iterator itr;
|
||||
|
||||
for (itr = files.begin(); itr != files.end(); ++itr)
|
||||
{
|
||||
cout << "* * * Checking columndef serialization for " << *itr << endl;
|
||||
SqlFileParser p;
|
||||
p.Parse(*itr);
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -664,6 +681,7 @@ public:
|
||||
ColumnDefList* columns = &(ct->fTableDef->fColumns);
|
||||
|
||||
ColumnDefList::const_iterator itr;
|
||||
|
||||
for (itr = columns->begin();
|
||||
itr != columns->end();
|
||||
++itr)
|
||||
@@ -764,11 +782,13 @@ public:
|
||||
files.push_back("sql/ct11.sql");
|
||||
|
||||
vector<string>::const_iterator itr;
|
||||
|
||||
for (itr = files.begin(); itr != files.end(); ++itr)
|
||||
{
|
||||
cout << "* * * Checking tabledef serialization for " << *itr << endl;
|
||||
SqlFileParser p;
|
||||
p.Parse(*itr);
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -801,12 +821,14 @@ public:
|
||||
files.push_back("sql/ct11.sql");
|
||||
|
||||
vector<string>::const_iterator itr;
|
||||
|
||||
for (itr = files.begin(); itr != files.end(); ++itr)
|
||||
{
|
||||
cout << "* * * Checking CreateTableStatement serialization for " << *itr << endl;
|
||||
SqlFileParser p;
|
||||
p.setDefaultSchema("tpch");
|
||||
p.Parse(*itr);
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -828,11 +850,13 @@ public:
|
||||
files.push_back("sql/dt02.sql");
|
||||
|
||||
vector<string>::const_iterator itr;
|
||||
|
||||
for (itr = files.begin(); itr != files.end(); ++itr)
|
||||
{
|
||||
cout << "* * * Checking DropTableStatement serialization for " << *itr << endl;
|
||||
SqlFileParser p;
|
||||
p.Parse(*itr);
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -853,11 +877,13 @@ public:
|
||||
files.push_back("sql/ci02.sql");
|
||||
|
||||
vector<string>::const_iterator itr;
|
||||
|
||||
for (itr = files.begin(); itr != files.end(); ++itr)
|
||||
{
|
||||
cout << "* * * Checking Create Index serialization for " << *itr << endl;
|
||||
SqlFileParser p;
|
||||
p.Parse(*itr);
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
@@ -877,11 +903,13 @@ public:
|
||||
files.push_back("sql/di01.sql");
|
||||
|
||||
vector<string>::const_iterator itr;
|
||||
|
||||
for (itr = files.begin(); itr != files.end(); ++itr)
|
||||
{
|
||||
cout << "* * * Checking Drop Index serialization for " << *itr << endl;
|
||||
SqlFileParser p;
|
||||
p.Parse(*itr);
|
||||
|
||||
if (p.Good())
|
||||
{
|
||||
const ParseTree& stmts = p.GetParseTree();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -66,7 +66,9 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
tableName.table = (createIndexStmt.fTableName)->fName;
|
||||
CalpontSystemCatalog::ROPair roPair;
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog( createIndexStmt.fSessionID );
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
roPair = systemCatalogPtr->tableRID( tableName );
|
||||
}
|
||||
catch (exception& ex)
|
||||
@@ -80,10 +82,12 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if ( roPair.objnum < 3000 )
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
fPKName = createIndexStmt.fIndexName->fName;
|
||||
int err = 0;
|
||||
|
||||
@@ -103,10 +107,12 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
|
||||
VERBOSE_INFO("Writing meta data to SYSINDEX");
|
||||
bool multicol = false;
|
||||
|
||||
if ( createIndexStmt.fColumnNames.size() > 1 )
|
||||
{
|
||||
multicol = true;
|
||||
}
|
||||
|
||||
//validate index columns
|
||||
CalpontSystemCatalog::TableColName tableColName;
|
||||
tableColName.schema = (createIndexStmt.fTableName)->fSchema;
|
||||
@@ -118,6 +124,7 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
DDLIndexPopulator pop(&fWriteEngine, &fSessionManager, createIndexStmt.fSessionID, txnID.id, result,
|
||||
fIdxOID, createIndexStmt.fColumnNames, *createIndexStmt.fTableName,
|
||||
type, getDebugLevel());
|
||||
|
||||
if ( multicol)
|
||||
{
|
||||
for ( colIter = createIndexStmt.fColumnNames.begin(); colIter != createIndexStmt.fColumnNames.end(); colIter++)
|
||||
@@ -129,6 +136,7 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
colType = systemCatalogPtr->colType (oid );
|
||||
totalWidth += (pop.isDictionaryType(colType)) ? 8 : colType.colWidth;
|
||||
}
|
||||
|
||||
if ( totalWidth > 32 )
|
||||
{
|
||||
stringstream ss;
|
||||
@@ -182,11 +190,13 @@ try
|
||||
getColumnsForTable(createIndexStmt.fSessionID, sysConsTableName.schema, sysConsTableName.table, sysConsColumns);
|
||||
sysCons_iterator = sysConsColumns.begin();
|
||||
std::string idxData;
|
||||
|
||||
while ( sysCons_iterator != sysConsColumns.end() )
|
||||
{
|
||||
column = *sysCons_iterator;
|
||||
boost::algorithm::to_lower(column.tableColName.column);
|
||||
isNull = false;
|
||||
|
||||
if (CONSTRAINTNAME_COL == column.tableColName.column)
|
||||
{
|
||||
idxData = createIndexStmt.fIndexName->fName;
|
||||
@@ -245,6 +255,7 @@ try
|
||||
{
|
||||
colTuple.data = tokenizeData(txnID.id, result, column.colType, colTuple.data);
|
||||
}
|
||||
|
||||
colStructs.push_back( colStruct );
|
||||
|
||||
colTuples.push_back( colTuple );
|
||||
@@ -300,6 +311,7 @@ try
|
||||
// write sysconstraintcol
|
||||
sysConsCol_iterator = sysConsColColumns.begin();
|
||||
std::string colData;
|
||||
|
||||
while ( sysConsCol_iterator != sysConsColColumns.end() )
|
||||
{
|
||||
column = *sysConsCol_iterator;
|
||||
@@ -388,12 +400,15 @@ try
|
||||
|
||||
VERBOSE_INFO("Creating index files");
|
||||
err = fWriteEngine.createIndex( txnID.id, fIdxOID.treeOID, fIdxOID.listOID );
|
||||
|
||||
if (err)
|
||||
{
|
||||
return rollBackCreateIndex(errorString("Write engine failed to create the new index. ", err), txnID, createIndexStmt.fSessionID);
|
||||
}
|
||||
|
||||
// new if BULK_LOAD close
|
||||
err = pop.populateIndex(result);
|
||||
|
||||
if ( err )
|
||||
{
|
||||
return rollBackCreateIndex(errorString("Failed to populate index with current data. ", err), txnID, createIndexStmt.fSessionID);
|
||||
@@ -405,6 +420,7 @@ try
|
||||
|
||||
DETAIL_INFO("Commiting transaction");
|
||||
err = fWriteEngine.commit( txnID.id );
|
||||
|
||||
if (err)
|
||||
{
|
||||
return rollBackCreateIndex(errorString("Failed to commit the create index transaction. ", err), txnID, createIndexStmt.fSessionID);
|
||||
@@ -456,7 +472,9 @@ void CreateIndexProcessor::rollBackIndex(BRM::TxnID& txnID, int sessionId)
|
||||
{
|
||||
fWriteEngine.rollbackTran(txnID.id, sessionId);
|
||||
fWriteEngine.dropIndex(txnID.id, fIdxOID.listOID, fIdxOID.treeOID);
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
//execplan::ObjectIDManager fObjectIDManager;
|
||||
//fObjectIDManager.returnOIDs(fIdxOID.treeOID, fIdxOID.listOID);
|
||||
}
|
||||
@@ -466,6 +484,7 @@ void CreateIndexProcessor::rollBackIndex(BRM::TxnID& txnID, int sessionId)
|
||||
}
|
||||
catch (... )
|
||||
{ }
|
||||
|
||||
fSessionManager.rolledback(txnID);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ CreateTableProcessor::DDLResult CreateTableProcessor::processPackage(
|
||||
result.result = NO_ERROR;
|
||||
int rc1 = 0;
|
||||
rc1 = fDbrm->isReadWrite();
|
||||
|
||||
if (rc1 != 0 )
|
||||
{
|
||||
Message::Args args;
|
||||
@@ -71,16 +72,19 @@ CreateTableProcessor::DDLResult CreateTableProcessor::processPackage(
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
DETAIL_INFO(createTableStmt);
|
||||
ddlpackage::TableDef& tableDef = *createTableStmt.fTableDef;
|
||||
//If schema = CALPONTSYS, do not create table
|
||||
boost::algorithm::to_lower(tableDef.fQualifiedName->fSchema);
|
||||
|
||||
if (tableDef.fQualifiedName->fSchema == CALPONT_SCHEMA)
|
||||
{
|
||||
//release the transaction
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Commit current transaction.
|
||||
// all DDL statements cause an implicut commit
|
||||
VERBOSE_INFO("Getting current txnID");
|
||||
@@ -94,6 +98,7 @@ CreateTableProcessor::DDLResult CreateTableProcessor::processPackage(
|
||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||
roPair.objnum = 0;
|
||||
ByteStream::byte rc = 0;
|
||||
|
||||
/** @Bug 217 */
|
||||
/** @Bug 225 */
|
||||
try
|
||||
@@ -167,10 +172,19 @@ CreateTableProcessor::DDLResult CreateTableProcessor::processPackage(
|
||||
#ifdef _MSC_VER
|
||||
//FIXME: Why do we need to do this???
|
||||
systemCatalogPtr->flushCache();
|
||||
try { roPair = systemCatalogPtr->tableRID(tableName); }
|
||||
catch (...) { roPair.objnum = 0; }
|
||||
|
||||
try
|
||||
{
|
||||
roPair = systemCatalogPtr->tableRID(tableName);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
roPair.objnum = 0;
|
||||
}
|
||||
|
||||
if (roPair.objnum < 3000)
|
||||
goto keepGoing;
|
||||
|
||||
#endif
|
||||
Message::Args args;
|
||||
Message message(9);
|
||||
@@ -186,6 +200,7 @@ CreateTableProcessor::DDLResult CreateTableProcessor::processPackage(
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
keepGoing:
|
||||
#endif
|
||||
@@ -202,8 +217,10 @@ keepGoing:
|
||||
string errorMsg;
|
||||
//get a unique number
|
||||
uint64_t uniqueId = 0;
|
||||
|
||||
//Bug 5070. Added exception handling
|
||||
try {
|
||||
try
|
||||
{
|
||||
uniqueId = fDbrm->getUnique64();
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
@@ -230,6 +247,7 @@ keepGoing:
|
||||
}
|
||||
|
||||
fWEClient->addQueue(uniqueId);
|
||||
|
||||
try
|
||||
{
|
||||
//Allocate tableoid table identification
|
||||
@@ -238,10 +256,12 @@ keepGoing:
|
||||
VERBOSE_INFO("Allocating object IDs for columns");
|
||||
uint32_t numColumns = tableDef.fColumns.size();
|
||||
uint32_t numDictCols = 0;
|
||||
|
||||
for (unsigned i = 0; i < numColumns; i++)
|
||||
{
|
||||
int dataType;
|
||||
dataType = convertDataType(tableDef.fColumns[i]->fType->fType);
|
||||
|
||||
if ( (dataType == CalpontSystemCatalog::CHAR && tableDef.fColumns[i]->fType->fLength > 8) ||
|
||||
(dataType == CalpontSystemCatalog::VARCHAR && tableDef.fColumns[i]->fType->fLength > 7) ||
|
||||
(dataType == CalpontSystemCatalog::VARBINARY && tableDef.fColumns[i]->fType->fLength > 7) ||
|
||||
@@ -249,10 +269,12 @@ keepGoing:
|
||||
(dataType == CalpontSystemCatalog::TEXT && tableDef.fColumns[i]->fType->fLength > 7) )
|
||||
numDictCols++;
|
||||
}
|
||||
|
||||
fStartingColOID = fObjectIDManager.allocOIDs(numColumns + numDictCols + 1); //include column, oids,dictionary oids and tableoid
|
||||
#ifdef IDB_DDL_DEBUG
|
||||
cout << fTxnid.id << " Create table allocOIDs got the starting oid " << fStartingColOID << endl;
|
||||
#endif
|
||||
|
||||
if (fStartingColOID < 0)
|
||||
{
|
||||
result.result = CREATE_ERROR;
|
||||
@@ -280,6 +302,7 @@ cout << fTxnid.id << " Create table allocOIDs got the starting oid " << fStartin
|
||||
BRM::OID_t sysOid = 1001;
|
||||
//Find out where systable is
|
||||
rc = fDbrm->getSysCatDBRoot(sysOid, dbRoot);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
result.result = (ResultCode) rc;
|
||||
@@ -302,31 +325,38 @@ cout << fTxnid.id << " Create table allocOIDs got the starting oid " << fStartin
|
||||
pmNum = (*dbRootPMMap)[dbRoot];
|
||||
// MCOL-66 The DBRM can't handle concurrent DDL
|
||||
boost::mutex::scoped_lock lk(dbrmMutex);
|
||||
|
||||
try
|
||||
{
|
||||
#ifdef IDB_DDL_DEBUG
|
||||
cout << fTxnid.id << " create table sending We_SVR_WRITE_SYSTABLE to pm " << pmNum << endl;
|
||||
#endif
|
||||
fWEClient->write(bytestream, (unsigned)pmNum);
|
||||
|
||||
while (1)
|
||||
{
|
||||
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";
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> rc;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
errorMsg.clear();
|
||||
*bsIn >> errorMsg;
|
||||
#ifdef IDB_DDL_DEBUG
|
||||
cout << fTxnid.id << "Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -359,10 +389,12 @@ cout << fTxnid.id << " Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg
|
||||
args.add(errorMsg);
|
||||
message.format( args );
|
||||
result.message = message;
|
||||
|
||||
if (rc != NETWORK_ERROR)
|
||||
{
|
||||
rollBackTransaction( uniqueId, txnID, createTableStmt.fSessionID ); //What to do with the error code
|
||||
}
|
||||
|
||||
//release transaction
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
@@ -375,11 +407,16 @@ cout << fTxnid.id << " Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg
|
||||
bytestream << (uint32_t) createTableStmt.fSessionID;
|
||||
bytestream << (uint32_t)txnID.id;
|
||||
bytestream << numColumns;
|
||||
for (unsigned i = 0; i <numColumns; ++i) {
|
||||
|
||||
for (unsigned i = 0; i < numColumns; ++i)
|
||||
{
|
||||
bytestream << (uint32_t)(fStartingColOID + i + 1);
|
||||
}
|
||||
|
||||
bytestream << numDictCols;
|
||||
for (unsigned i = 0; i <numDictCols; ++i) {
|
||||
|
||||
for (unsigned i = 0; i < numDictCols; ++i)
|
||||
{
|
||||
bytestream << (uint32_t)(fStartingColOID + numColumns + i + 1);
|
||||
}
|
||||
|
||||
@@ -391,6 +428,7 @@ cout << fTxnid.id << " Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg
|
||||
sysOid = 1021;
|
||||
//Find out where syscolumn is
|
||||
rc = fDbrm->getSysCatDBRoot(sysOid, dbRoot);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
result.result = (ResultCode) rc;
|
||||
@@ -408,31 +446,38 @@ cout << fTxnid.id << " Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg
|
||||
bytestream << (uint32_t)dbRoot;
|
||||
tableDef.serialize(bytestream);
|
||||
pmNum = (*dbRootPMMap)[dbRoot];
|
||||
|
||||
try
|
||||
{
|
||||
#ifdef IDB_DDL_DEBUG
|
||||
cout << fTxnid.id << " create table sending WE_SVR_WRITE_CREATE_SYSCOLUMN to pm " << pmNum << endl;
|
||||
#endif
|
||||
fWEClient->write(bytestream, (uint32_t)pmNum);
|
||||
|
||||
while (1)
|
||||
{
|
||||
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";
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> rc;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
errorMsg.clear();
|
||||
*bsIn >> errorMsg;
|
||||
#ifdef IDB_DDL_DEBUG
|
||||
cout << fTxnid.id << "Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -465,10 +510,12 @@ cout << fTxnid.id << " Create table WE_SVR_WRITE_CREATE_SYSCOLUMN: " << errorMsg
|
||||
args.add(errorMsg);
|
||||
message.format( args );
|
||||
result.message = message;
|
||||
|
||||
if (rc != NETWORK_ERROR)
|
||||
{
|
||||
rollBackTransaction( uniqueId, txnID, createTableStmt.fSessionID ); //What to do with the error code
|
||||
}
|
||||
|
||||
//release transaction
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
@@ -496,11 +543,13 @@ cout << fTxnid.id << " Create table WE_SVR_WRITE_CREATE_SYSCOLUMN: " << errorMsg
|
||||
bytestream << (numColumns + numDictCols);
|
||||
unsigned colNum = 0;
|
||||
unsigned dictNum = 0;
|
||||
|
||||
while (iter != tableDefCols.end())
|
||||
{
|
||||
colDefPtr = *iter;
|
||||
|
||||
CalpontSystemCatalog::ColDataType dataType = convertDataType(colDefPtr->fType->fType);
|
||||
|
||||
if (dataType == CalpontSystemCatalog::DECIMAL ||
|
||||
dataType == CalpontSystemCatalog::UDECIMAL)
|
||||
{
|
||||
@@ -526,6 +575,7 @@ cout << fTxnid.id << " Create table WE_SVR_WRITE_CREATE_SYSCOLUMN: " << errorMsg
|
||||
colDefPtr->fType->fLength = 8;
|
||||
}
|
||||
}
|
||||
|
||||
bytestream << (fStartingColOID + (colNum++) + 1);
|
||||
bytestream << (uint8_t) dataType;
|
||||
bytestream << (uint8_t) false;
|
||||
@@ -533,6 +583,7 @@ cout << fTxnid.id << " Create table WE_SVR_WRITE_CREATE_SYSCOLUMN: " << errorMsg
|
||||
bytestream << (uint32_t) colDefPtr->fType->fLength;
|
||||
bytestream << (uint16_t) useDBRoot;
|
||||
bytestream << (uint32_t) colDefPtr->fType->fCompressiontype;
|
||||
|
||||
if ( (dataType == CalpontSystemCatalog::CHAR && colDefPtr->fType->fLength > 8) ||
|
||||
(dataType == CalpontSystemCatalog::VARCHAR && colDefPtr->fType->fLength > 7) ||
|
||||
(dataType == CalpontSystemCatalog::VARBINARY && colDefPtr->fType->fLength > 7) ||
|
||||
@@ -546,21 +597,27 @@ cout << fTxnid.id << " Create table WE_SVR_WRITE_CREATE_SYSCOLUMN: " << errorMsg
|
||||
bytestream << (uint16_t) useDBRoot;
|
||||
bytestream << (uint32_t) colDefPtr->fType->fCompressiontype;
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
//@Bug 4176. save oids to a log file for cleanup after fail over.
|
||||
std::vector <CalpontSystemCatalog::OID> oidList;
|
||||
|
||||
for (unsigned i = 0; i < numColumns; ++i)
|
||||
{
|
||||
oidList.push_back(fStartingColOID + i + 1);
|
||||
}
|
||||
|
||||
bytestream << numDictCols;
|
||||
|
||||
for (unsigned i = 0; i < numDictCols; ++i)
|
||||
{
|
||||
oidList.push_back(fStartingColOID + numColumns + i + 1);
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
createWriteDropLogFile( fStartingColOID, uniqueId, oidList );
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
@@ -572,68 +629,84 @@ cout << fTxnid.id << " Create table WE_SVR_WRITE_CREATE_SYSCOLUMN: " << errorMsg
|
||||
args.add(ex.what());
|
||||
message.format( args );
|
||||
result.message = message;
|
||||
|
||||
if (rc != NETWORK_ERROR)
|
||||
{
|
||||
rollBackTransaction( uniqueId, txnID, createTableStmt.fSessionID ); //What to do with the error code
|
||||
}
|
||||
|
||||
//release transaction
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
pmNum = (*dbRootPMMap)[useDBRoot];
|
||||
|
||||
try
|
||||
{
|
||||
#ifdef IDB_DDL_DEBUG
|
||||
cout << fTxnid.id << " create table sending WE_SVR_WRITE_CREATETABLEFILES to pm " << pmNum << endl;
|
||||
#endif
|
||||
fWEClient->write(bytestream, pmNum);
|
||||
|
||||
while (1)
|
||||
{
|
||||
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";
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> rc;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
errorMsg.clear();
|
||||
*bsIn >> errorMsg;
|
||||
#ifdef IDB_DDL_DEBUG
|
||||
cout << "Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rc != 0) {
|
||||
if (rc != 0)
|
||||
{
|
||||
//drop the newly created files
|
||||
bytestream.restart();
|
||||
bytestream << (ByteStream::byte) WE_SVR_WRITE_DROPFILES;
|
||||
bytestream << uniqueId;
|
||||
bytestream << (uint32_t)(numColumns + numDictCols);
|
||||
|
||||
for (unsigned i = 0; i < (numColumns + numDictCols); i++)
|
||||
{
|
||||
bytestream << (uint32_t)(fStartingColOID + i + 1);
|
||||
}
|
||||
|
||||
fWEClient->write(bytestream, pmNum);
|
||||
|
||||
while (1)
|
||||
{
|
||||
bsIn.reset(new ByteStream());
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//@Bug 5464. Delete from extent map.
|
||||
fDbrm->deleteOIDs(oidList);
|
||||
|
||||
@@ -676,6 +749,7 @@ cout << fTxnid.id << " Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
return result;
|
||||
}
|
||||
|
||||
//fWEClient->removeQueue(uniqueId);
|
||||
if (rc != 0)
|
||||
{
|
||||
@@ -687,6 +761,7 @@ cout << fTxnid.id << " Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg
|
||||
message.format( args );
|
||||
result.message = message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -709,6 +784,7 @@ void CreateTableProcessor::rollBackCreateTable(const string& error, BRM::TxnID t
|
||||
fWriteEngine.rollbackTran(txnID.id, sessionId);
|
||||
|
||||
size_t size = tableDef.fColumns.size();
|
||||
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
{
|
||||
fWriteEngine.dropColumn(txnID.id, fStartingColOID + i);
|
||||
@@ -742,6 +818,7 @@ void CreateTableProcessor::rollBackCreateTable(const string& error, BRM::TxnID t
|
||||
}
|
||||
|
||||
DictionaryOIDList::const_iterator dictoid_iter = fDictionaryOIDList.begin();
|
||||
|
||||
while (dictoid_iter != fDictionaryOIDList.end())
|
||||
{
|
||||
DictOID dictOID = *dictoid_iter;
|
||||
@@ -750,6 +827,7 @@ void CreateTableProcessor::rollBackCreateTable(const string& error, BRM::TxnID t
|
||||
|
||||
++dictoid_iter;
|
||||
}
|
||||
|
||||
fSessionManager.rolledback(txnID);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace ddlpackageprocessor
|
||||
{
|
||||
if (makeIndexStructs() )
|
||||
insertIndex();
|
||||
|
||||
result = fResult;
|
||||
return NO_ERROR != fResult.result;
|
||||
}
|
||||
@@ -66,6 +67,7 @@ namespace ddlpackageprocessor
|
||||
CalpontSelectExecutionPlan csep;
|
||||
makeCsep(csep);
|
||||
ResourceManager* rm;
|
||||
|
||||
if (! fEC)
|
||||
{
|
||||
fEC = DistributedEngineComm::instance(rm);
|
||||
@@ -90,15 +92,18 @@ namespace ddlpackageprocessor
|
||||
|
||||
CalpontSystemCatalog::OID tableOid = (csc->tableRID ( tableName )).objnum;
|
||||
CalpontSystemCatalog::NJLSysDataList sysDataList;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
TableBand band;
|
||||
band = jbl->projectTable(tableOid);
|
||||
|
||||
if (band.getRowCount() == 0)
|
||||
{
|
||||
// No more bands, table is done
|
||||
break;
|
||||
}
|
||||
|
||||
band.convertToSysDataList(sysDataList, csc);
|
||||
break;
|
||||
}
|
||||
@@ -107,10 +112,12 @@ namespace ddlpackageprocessor
|
||||
size_t i = 0;
|
||||
vector<ColumnResult*>::const_iterator it;
|
||||
vector<int>::const_iterator oid_iter;
|
||||
|
||||
for (it = sysDataList.begin(); it != sysDataList.end(); it++)
|
||||
{
|
||||
if (isUnique())
|
||||
fUniqueColResultList.push_back(*it);
|
||||
|
||||
for ( oid_iter = fOidList.begin(); oid_iter != fOidList.end(); oid_iter++ )
|
||||
{
|
||||
if ( (*it)->ColumnOID() == *oid_iter )
|
||||
@@ -119,6 +126,7 @@ namespace ddlpackageprocessor
|
||||
addColumnData(*it, coltype, i);
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -146,6 +154,7 @@ namespace ddlpackageprocessor
|
||||
string tableName(fTable.fSchema + "." + fTable.fName + ".");
|
||||
|
||||
ColumnNameList::const_iterator cend = fColNames.end();
|
||||
|
||||
for (ColumnNameList::const_iterator cname = fColNames.begin(); cname != cend; ++cname)
|
||||
{
|
||||
string fullColName(tableName + *cname);
|
||||
@@ -156,6 +165,7 @@ namespace ddlpackageprocessor
|
||||
fOidList.push_back( oid );
|
||||
colMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(fullColName, srcp));
|
||||
}
|
||||
|
||||
csep.columnMap (colMap);
|
||||
csep.returnedCols (colList);
|
||||
}
|
||||
@@ -179,6 +189,7 @@ namespace ddlpackageprocessor
|
||||
{
|
||||
if (1 == coltype.colWidth) idx.idxWidth = 1;
|
||||
else idx.idxWidth = (coltype.colWidth > 4) ? 8 : 4;
|
||||
|
||||
idx.idxType = WR_CHAR;
|
||||
}
|
||||
else
|
||||
@@ -202,12 +213,14 @@ namespace ddlpackageprocessor
|
||||
if (checkConstraints( tuple, colType, i, added))
|
||||
{
|
||||
tupleList.push_back(tuple);
|
||||
|
||||
if (! added )
|
||||
fRidList.push_back(cr->GetRid(i));
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (tupleList.size())
|
||||
fIdxValueList.push_back(tupleList);
|
||||
}
|
||||
@@ -241,6 +254,7 @@ namespace ddlpackageprocessor
|
||||
{
|
||||
FileOp fileOp;
|
||||
char fileName[WriteEngine::FILE_NAME_SIZE];
|
||||
|
||||
if (WriteEngine::NO_ERROR == fileOp.getFileName(oid, fileName) )
|
||||
{
|
||||
fColumnFile.open(fileName);
|
||||
@@ -285,11 +299,13 @@ namespace ddlpackageprocessor
|
||||
dictTuple.sigValue = data.c_str();
|
||||
dictTuple.sigSize = data.length();
|
||||
int error = NO_ERROR;
|
||||
|
||||
if ( NO_ERROR != (error = fWriteEngine->tokenize( fTxnID, dictStruct, dictTuple)) )
|
||||
{
|
||||
logError("Tokenization failed", error);
|
||||
}
|
||||
}
|
||||
|
||||
return dictTuple.token;
|
||||
}
|
||||
|
||||
@@ -298,16 +314,25 @@ namespace ddlpackageprocessor
|
||||
boost::any DDLIndexPopulator::convertData(const CalpontSystemCatalog::ColType& colType, const execplan::ColumnResult* cr, int idx )
|
||||
{
|
||||
uint64_t data = cr->GetData(idx);
|
||||
|
||||
switch ( colType.colDataType )
|
||||
{
|
||||
case CalpontSystemCatalog::BIT:
|
||||
case execplan::CalpontSystemCatalog::TINYINT: return *reinterpret_cast<char*>(&data);
|
||||
case execplan::CalpontSystemCatalog::SMALLINT: return *reinterpret_cast<short*>(&data);
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
return *reinterpret_cast<char*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
return *reinterpret_cast<short*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATE: // @bug 375
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::INT: return *reinterpret_cast<int*>(&data);
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
return *reinterpret_cast<int*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATETIME: // @bug 375
|
||||
case execplan::CalpontSystemCatalog::BIGINT: return *reinterpret_cast<long long*>(&data);
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
return *reinterpret_cast<long long*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
{
|
||||
if (colType.colWidth <= CalpontSystemCatalog::FOUR_BYTE) return *reinterpret_cast<short*>(&data);
|
||||
@@ -317,16 +342,23 @@ namespace ddlpackageprocessor
|
||||
else return *reinterpret_cast<long long*>(&data);
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::FLOAT: return *reinterpret_cast<float*>(&data);
|
||||
case execplan::CalpontSystemCatalog::DOUBLE: return *reinterpret_cast<double*>(&data);
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
return *reinterpret_cast<float*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
return *reinterpret_cast<double*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
{
|
||||
string strData(cr->GetStringData(idx) );
|
||||
return *reinterpret_cast<string*>(&strData);
|
||||
}
|
||||
default: break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
logError("Invalid column type");
|
||||
throw std::runtime_error("Invalid data");
|
||||
|
||||
@@ -341,6 +373,7 @@ namespace ddlpackageprocessor
|
||||
int rc = (1 < fIdxStructList.size()) ?
|
||||
(void)0
|
||||
: (void)0;
|
||||
|
||||
if (rc)
|
||||
logError("Error inserting index values", rc );
|
||||
|
||||
@@ -366,6 +399,7 @@ namespace ddlpackageprocessor
|
||||
case DDL_PRIMARY_KEY:
|
||||
if ((size_t)column + 1 < fColNames.size() )
|
||||
return true;
|
||||
|
||||
return checkUnique( i, ctype );
|
||||
|
||||
case DDL_NOT_NULL:
|
||||
@@ -386,6 +420,7 @@ namespace ddlpackageprocessor
|
||||
{
|
||||
if (0 == idx)
|
||||
return true;
|
||||
|
||||
//Get row of data as each column result data at idx
|
||||
size_t indexSize = fColNames.size();
|
||||
vector <uint64_t> rowIntData(indexSize);
|
||||
@@ -399,12 +434,15 @@ namespace ddlpackageprocessor
|
||||
else
|
||||
rowIntData[i] = fUniqueColResultList[i]->GetData(idx);
|
||||
}
|
||||
|
||||
//check if each value in the idx row is equal to each value in a previous row
|
||||
// i is the row; j is the column.
|
||||
bool unique = true;
|
||||
|
||||
for (int i = 0; i < idx && unique; ++i)
|
||||
{
|
||||
bool equal = true;
|
||||
|
||||
for (size_t j = 0; j < indexSize && equal; ++j)
|
||||
{
|
||||
if ( isStringType(colType.colDataType) )
|
||||
@@ -416,14 +454,17 @@ namespace ddlpackageprocessor
|
||||
equal = (static_cast<uint64_t>(fUniqueColResultList[j]->GetData(i)) == rowIntData[j]);
|
||||
}
|
||||
}
|
||||
|
||||
unique = ! equal;
|
||||
}
|
||||
|
||||
if (! unique)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << idx;
|
||||
logError("Unique Constraint violated on row: " + ss.str() );
|
||||
}
|
||||
|
||||
return unique;
|
||||
}
|
||||
|
||||
@@ -466,8 +507,10 @@ namespace ddlpackageprocessor
|
||||
isNull = any_cast<long long>(data.data) == any_cast<long long>(nullvalue);
|
||||
else
|
||||
isNull = compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
isNull = any_cast<float>(data.data) == any_cast<float>(nullvalue);
|
||||
break;
|
||||
@@ -494,9 +537,11 @@ namespace ddlpackageprocessor
|
||||
isNull = any_cast<string>(data.data) == any_cast<string>(nullvalue);
|
||||
else
|
||||
isNull = compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
{
|
||||
if (colType.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
|
||||
@@ -505,13 +550,17 @@ namespace ddlpackageprocessor
|
||||
isNull = any_cast<string>(data.data) == any_cast<string>(nullvalue);
|
||||
else
|
||||
isNull = compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw std::runtime_error("getNullValueForType: unkown column data type");
|
||||
}
|
||||
|
||||
if (isNull)
|
||||
logError("Null value not allowed in index");
|
||||
|
||||
return ! isNull;
|
||||
|
||||
}
|
||||
@@ -523,6 +572,7 @@ namespace ddlpackageprocessor
|
||||
Message message(9);
|
||||
args.add((string)__FILE__ + ": ");
|
||||
args.add(msg);
|
||||
|
||||
if (error)
|
||||
{
|
||||
args.add("Error number: ");
|
||||
|
||||
@@ -43,7 +43,8 @@
|
||||
|
||||
#include "joblistfactory.h"
|
||||
|
||||
namespace joblist {
|
||||
namespace joblist
|
||||
{
|
||||
class DistributedEngineComm;
|
||||
}
|
||||
|
||||
@@ -85,20 +86,35 @@ public:
|
||||
|
||||
/** @brief Is it required to debug
|
||||
*/
|
||||
const bool isDebug( const DDLPackageProcessor::DebugLevel level ) const { return level <= fDebugLevel; }
|
||||
const bool isDebug( const DDLPackageProcessor::DebugLevel level ) const
|
||||
{
|
||||
return level <= fDebugLevel;
|
||||
}
|
||||
|
||||
/** @brief Get debug level
|
||||
*/
|
||||
const DDLPackageProcessor::DebugLevel getDebugLevel() const { return fDebugLevel; }
|
||||
const DDLPackageProcessor::DebugLevel getDebugLevel() const
|
||||
{
|
||||
return fDebugLevel;
|
||||
}
|
||||
|
||||
|
||||
/** @brief set distributedEngineComm pointer ( for
|
||||
* loading index).
|
||||
*/
|
||||
void setEngineComm(joblist::DistributedEngineComm* ec) { fEC = ec; }
|
||||
void setIdxOID(const DDLPackageProcessor::IndexOID& idxOID) { fIdxOID = idxOID; }
|
||||
void setEngineComm(joblist::DistributedEngineComm* ec)
|
||||
{
|
||||
fEC = ec;
|
||||
}
|
||||
void setIdxOID(const DDLPackageProcessor::IndexOID& idxOID)
|
||||
{
|
||||
fIdxOID = idxOID;
|
||||
}
|
||||
|
||||
DDLPackageProcessor::DDLResult getResult() const { return fResult; }
|
||||
DDLPackageProcessor::DDLResult getResult() const
|
||||
{
|
||||
return fResult;
|
||||
}
|
||||
|
||||
|
||||
/** @brief add data to the index from the statement
|
||||
@@ -229,9 +245,15 @@ public:
|
||||
*/
|
||||
bool checkUnique(int i, const execplan::CalpontSystemCatalog::ColType& colType );
|
||||
|
||||
bool checkCheck( const WriteEngine::IdxTuple& data, const execplan::CalpontSystemCatalog::ColType& ctype) const { return true; }
|
||||
bool checkCheck( const WriteEngine::IdxTuple& data, const execplan::CalpontSystemCatalog::ColType& ctype) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isUnique() { return ddlpackage::DDL_PRIMARY_KEY == fConstraint || ddlpackage::DDL_UNIQUE == fConstraint; }
|
||||
bool isUnique()
|
||||
{
|
||||
return ddlpackage::DDL_PRIMARY_KEY == fConstraint || ddlpackage::DDL_UNIQUE == fConstraint;
|
||||
}
|
||||
/** @brief logs error and message
|
||||
*
|
||||
* Updates result with message and sets it to CREATE_ERROR
|
||||
|
||||
@@ -94,6 +94,7 @@ void DDLPackageProcessor::getColumnsForTable(uint32_t sessionID, std::string sc
|
||||
tableName.schema = schema;
|
||||
tableName.table = table;
|
||||
std::string err;
|
||||
|
||||
try
|
||||
{
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
|
||||
@@ -102,6 +103,7 @@ void DDLPackageProcessor::getColumnsForTable(uint32_t sessionID, std::string sc
|
||||
const CalpontSystemCatalog::RIDList ridList = systemCatalogPtr->columnRIDs(tableName);
|
||||
|
||||
CalpontSystemCatalog::RIDList::const_iterator rid_iterator = ridList.begin();
|
||||
|
||||
while (rid_iterator != ridList.end())
|
||||
{
|
||||
CalpontSystemCatalog::ROPair roPair = *rid_iterator;
|
||||
@@ -266,16 +268,20 @@ std::string DDLPackageProcessor::buildTableConstraintName(const int oid,
|
||||
// generated by Oracle. Use Oracle's PK name instead of making up our own
|
||||
indexName = fPKName;
|
||||
break;
|
||||
|
||||
case ddlpackage::DDL_FOREIGN_KEY:
|
||||
case ddlpackage::DDL_REFERENCES:
|
||||
prefix = "fk_";
|
||||
break;
|
||||
|
||||
case ddlpackage::DDL_UNIQUE:
|
||||
prefix = "uk_";
|
||||
break;
|
||||
|
||||
case ddlpackage::DDL_CHECK:
|
||||
prefix = "ck_";
|
||||
break;
|
||||
|
||||
case ddlpackage::DDL_NOT_NULL:
|
||||
prefix = "nk_";
|
||||
break;
|
||||
@@ -287,6 +293,7 @@ std::string DDLPackageProcessor::buildTableConstraintName(const int oid,
|
||||
|
||||
if (type != ddlpackage::DDL_PRIMARY_KEY)
|
||||
indexName = prefix + oid_number.str();
|
||||
|
||||
boost::to_lower(indexName);
|
||||
|
||||
return indexName;
|
||||
@@ -306,16 +313,20 @@ std::string DDLPackageProcessor::buildColumnConstraintName(const std::string& sc
|
||||
case ddlpackage::DDL_PRIMARY_KEY:
|
||||
prefix = "pk_";
|
||||
break;
|
||||
|
||||
case ddlpackage::DDL_FOREIGN_KEY:
|
||||
case ddlpackage::DDL_REFERENCES:
|
||||
prefix = "fk_";
|
||||
break;
|
||||
|
||||
case ddlpackage::DDL_UNIQUE:
|
||||
prefix = "uk_";
|
||||
break;
|
||||
|
||||
case ddlpackage::DDL_CHECK:
|
||||
prefix = "ck_";
|
||||
break;
|
||||
|
||||
case ddlpackage::DDL_NOT_NULL:
|
||||
prefix = "nk_";
|
||||
break;
|
||||
@@ -371,6 +382,7 @@ boost::any
|
||||
DDLPackageProcessor::getNullValueForType(const execplan::CalpontSystemCatalog::ColType& colType)
|
||||
{
|
||||
boost::any value;
|
||||
|
||||
switch (colType.colDataType)
|
||||
{
|
||||
case execplan::CalpontSystemCatalog::BIT:
|
||||
@@ -431,6 +443,7 @@ DDLPackageProcessor::getNullValueForType(const execplan::CalpontSystemCatalog::C
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
case execplan::CalpontSystemCatalog::UFLOAT:
|
||||
{
|
||||
@@ -466,6 +479,7 @@ DDLPackageProcessor::getNullValueForType(const execplan::CalpontSystemCatalog::C
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
{
|
||||
std::string charnull;
|
||||
|
||||
if (colType.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
|
||||
{
|
||||
//charnull = joblist::CHAR1NULL;
|
||||
@@ -496,6 +510,7 @@ DDLPackageProcessor::getNullValueForType(const execplan::CalpontSystemCatalog::C
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
{
|
||||
std::string charnull;
|
||||
|
||||
if (colType.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
|
||||
{
|
||||
//charnull = joblist::CHAR2NULL;
|
||||
@@ -520,6 +535,7 @@ DDLPackageProcessor::getNullValueForType(const execplan::CalpontSystemCatalog::C
|
||||
case execplan::CalpontSystemCatalog::VARBINARY:
|
||||
{
|
||||
std::string charnull;
|
||||
|
||||
if (colType.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
|
||||
{
|
||||
//charnull = joblist::CHAR2NULL;
|
||||
@@ -587,6 +603,7 @@ bool DDLPackageProcessor::isIndexConstraint(ddlpackage::DDL_CONSTRAINTS type)
|
||||
switch (type)
|
||||
{
|
||||
case ddlpackage::DDL_PRIMARY_KEY:
|
||||
|
||||
// @bug fix for #418, #416. Do not insert into sysindex
|
||||
//case ddlpackage::DDL_REFERENCES:
|
||||
case ddlpackage::DDL_UNIQUE:
|
||||
@@ -647,6 +664,7 @@ boost::any DDLPackageProcessor::tokenizeData(execplan::CalpontSystemCatalog::SCN
|
||||
std::string err("DDLPackageProcessor::tokenizeData ");
|
||||
SUMMARY_INFO(err);
|
||||
boost::any value;
|
||||
|
||||
if (result.result == NO_ERROR)
|
||||
{
|
||||
|
||||
@@ -680,11 +698,13 @@ boost::any DDLPackageProcessor::tokenizeData(execplan::CalpontSystemCatalog::SCN
|
||||
dictTuple.sigValue = (unsigned char*)str.c_str();
|
||||
dictTuple.sigSize = str.length();
|
||||
int error = NO_ERROR;
|
||||
|
||||
if (NO_ERROR != (error = fWriteEngine.tokenize(txnID, dictStruct, dictTuple, false))) // @bug 5572 HDFS tmp file
|
||||
{
|
||||
WErrorCodes ec;
|
||||
throw std::runtime_error("WE: Tokenization failed " + ec.errorString(error));
|
||||
}
|
||||
|
||||
WriteEngine::Token aToken = dictTuple.token;
|
||||
|
||||
value = aToken;
|
||||
@@ -702,6 +722,7 @@ boost::any DDLPackageProcessor::tokenizeData(execplan::CalpontSystemCatalog::SCN
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -718,24 +739,30 @@ void DDLPackageProcessor::flushPrimprocCache(std::vector<execplan::CalpontSystem
|
||||
LBIDRange_v::iterator it;
|
||||
BRM::BlockList_t blockList;
|
||||
execplan::CalpontSystemCatalog::SCN verID = 0;
|
||||
|
||||
try
|
||||
{
|
||||
while (iter != oidList.end())
|
||||
{
|
||||
WriteEngine::OID oid = *iter;
|
||||
|
||||
if (oid < 3000)
|
||||
{
|
||||
++iter;
|
||||
continue;
|
||||
}
|
||||
|
||||
//@Bug 1708 Flush primproc cache for associated lbids.
|
||||
err = dbrm.lookup(oid, lbidRanges);
|
||||
|
||||
if (err)
|
||||
{
|
||||
error = "DBRM lookUp error.";
|
||||
throw std::runtime_error(error);
|
||||
}
|
||||
|
||||
blockList.clear();
|
||||
|
||||
for (it = lbidRanges.begin(); it != lbidRanges.end(); it++)
|
||||
{
|
||||
for (LBID_t lbid = it->start; lbid < (it->start + it->size); lbid++)
|
||||
@@ -743,6 +770,7 @@ void DDLPackageProcessor::flushPrimprocCache(std::vector<execplan::CalpontSystem
|
||||
blockList.push_back(BRM::LVP_t(lbid, verID));
|
||||
}
|
||||
}
|
||||
|
||||
//Need find a more efficient way to do this.
|
||||
err = cacheutils::flushPrimProcBlocks (blockList);
|
||||
//No need to handle this error as the error comes from timeout, not real error
|
||||
@@ -774,6 +802,7 @@ void DDLPackageProcessor::removeFiles(const uint64_t uniqueId, std::vector<execp
|
||||
bytestream << (ByteStream::byte)WE_SVR_WRITE_DROPFILES;
|
||||
bytestream << uniqueId;
|
||||
bytestream << (uint32_t) oidList.size();
|
||||
|
||||
for (unsigned i = 0; i < oidList.size(); i++)
|
||||
{
|
||||
bytestream << (uint32_t) oidList[i];
|
||||
@@ -783,7 +812,9 @@ void DDLPackageProcessor::removeFiles(const uint64_t uniqueId, std::vector<execp
|
||||
ByteStream::byte rc = 0;
|
||||
ByteStream::byte tmp8;
|
||||
string errorMsg;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->write_to_all(bytestream);
|
||||
|
||||
bsIn.reset(new ByteStream());
|
||||
@@ -792,7 +823,9 @@ void DDLPackageProcessor::removeFiles(const uint64_t uniqueId, std::vector<execp
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = NETWORK_ERROR;
|
||||
@@ -800,10 +833,13 @@ void DDLPackageProcessor::removeFiles(const uint64_t uniqueId, std::vector<execp
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = tmp8;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
@@ -823,7 +859,9 @@ void DDLPackageProcessor::removeFiles(const uint64_t uniqueId, std::vector<execp
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
throw std::runtime_error("Unknown error caught while deleting files.");
|
||||
}
|
||||
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
|
||||
if ( rc != 0)
|
||||
{
|
||||
throw std::runtime_error(errorMsg);
|
||||
@@ -844,6 +882,7 @@ void DDLPackageProcessor::createFiles(CalpontSystemCatalog::TableName aTableName
|
||||
bytestream << (uint32_t)1;
|
||||
bytestream << uniqueId;
|
||||
bytestream << numOids;
|
||||
|
||||
for (unsigned col = 0; col < ridList.size(); col++)
|
||||
{
|
||||
colType = systemCatalogPtr->colType(ridList[col].objnum);
|
||||
@@ -853,6 +892,7 @@ void DDLPackageProcessor::createFiles(CalpontSystemCatalog::TableName aTableName
|
||||
bytestream << (uint32_t) colType.colWidth;
|
||||
bytestream << (uint16_t) useDBRoot;
|
||||
bytestream << (uint32_t) colType.compressionType;
|
||||
|
||||
if (colType.ddn.dictOID > 3000)
|
||||
{
|
||||
bytestream << (uint32_t) colType.ddn.dictOID;
|
||||
@@ -863,10 +903,13 @@ void DDLPackageProcessor::createFiles(CalpontSystemCatalog::TableName aTableName
|
||||
bytestream << (uint32_t) colType.compressionType;
|
||||
}
|
||||
}
|
||||
|
||||
ByteStream::byte rc = 0;
|
||||
ByteStream::byte tmp8;
|
||||
string errorMsg;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
OamCache* oamcache = OamCache::makeOamCache();
|
||||
boost::shared_ptr<std::map<int, int> > dbRootPMMap = oamcache->getDBRootToPMMap();
|
||||
int pmNum = (*dbRootPMMap)[useDBRoot];
|
||||
@@ -877,6 +920,7 @@ void DDLPackageProcessor::createFiles(CalpontSystemCatalog::TableName aTableName
|
||||
while (1)
|
||||
{
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = NETWORK_ERROR;
|
||||
@@ -884,12 +928,16 @@ void DDLPackageProcessor::createFiles(CalpontSystemCatalog::TableName aTableName
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = tmp8;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -904,7 +952,9 @@ void DDLPackageProcessor::createFiles(CalpontSystemCatalog::TableName aTableName
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
throw std::runtime_error("Unknown error caught while creating files.");
|
||||
}
|
||||
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
|
||||
if ( rc != 0)
|
||||
throw std::runtime_error(errorMsg);
|
||||
}
|
||||
@@ -932,6 +982,7 @@ void DDLPackageProcessor::removePartitionFiles(std::vector<execplan::CalpontSyst
|
||||
for (uint32_t i = 0; i < oidList.size(); i++)
|
||||
{
|
||||
bs << (uint32_t)oidList[i];
|
||||
|
||||
// add oid to LogicalPartition to form PartitionInfo
|
||||
for (partIt = partitions.begin(); partIt != partitions.end(); ++partIt)
|
||||
{
|
||||
@@ -943,6 +994,7 @@ void DDLPackageProcessor::removePartitionFiles(std::vector<execplan::CalpontSyst
|
||||
}
|
||||
|
||||
bs << (uint32_t)partInfos.size();
|
||||
|
||||
for (uint32_t i = 0; i < partInfos.size(); i++)
|
||||
partInfos[i].serialize(bs);
|
||||
|
||||
@@ -955,6 +1007,7 @@ void DDLPackageProcessor::removePartitionFiles(std::vector<execplan::CalpontSyst
|
||||
{
|
||||
bsIn->restart();
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = NETWORK_ERROR;
|
||||
@@ -964,11 +1017,13 @@ void DDLPackageProcessor::removePartitionFiles(std::vector<execplan::CalpontSyst
|
||||
else
|
||||
{
|
||||
*bsIn >> rc;
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
break;
|
||||
}
|
||||
|
||||
pmCount--;
|
||||
}
|
||||
}
|
||||
@@ -981,6 +1036,7 @@ void DDLPackageProcessor::removePartitionFiles(std::vector<execplan::CalpontSyst
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
throw std::runtime_error(errorMsg);
|
||||
}
|
||||
|
||||
//@Bug 2171,3327. Drop PrimProc fd cache
|
||||
rc = cacheutils::dropPrimProcFdCache();
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
@@ -991,6 +1047,7 @@ void DDLPackageProcessor::removeExtents(std::vector<execplan::CalpontSystemCatal
|
||||
SUMMARY_INFO("DDLPackageProcessor::removeExtents");
|
||||
int err = 0;
|
||||
err = fDbrm->deleteOIDs(oidList);
|
||||
|
||||
if (err)
|
||||
{
|
||||
string errMsg;
|
||||
@@ -1017,27 +1074,36 @@ void DDLPackageProcessor::createWriteDropLogFile(execplan::CalpontSystemCatalog:
|
||||
bytestream << uniqueId;
|
||||
bytestream << (uint32_t)tableOid;
|
||||
bytestream << (uint32_t) oidList.size();
|
||||
|
||||
for (uint32_t i = 0; i < oidList.size(); i++)
|
||||
{
|
||||
bytestream << (uint32_t)oidList[i];
|
||||
}
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->write(bytestream, (uint32_t)parentId);
|
||||
|
||||
while (1)
|
||||
{
|
||||
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 writting drop table Log";
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> rc;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1073,23 +1139,31 @@ void DDLPackageProcessor::deleteLogFile(LogFileType fileType, execplan::CalpontS
|
||||
bytestream << uniqueId;
|
||||
bytestream << (uint32_t) fileType;
|
||||
bytestream << (uint32_t)tableOid;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->write(bytestream, (uint32_t)parentId);
|
||||
|
||||
while (1)
|
||||
{
|
||||
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 deleting DDL log";
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> rc;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1104,7 +1178,9 @@ void DDLPackageProcessor::deleteLogFile(LogFileType fileType, execplan::CalpontS
|
||||
rc = NETWORK_ERROR;
|
||||
errorMsg = "Got unknown exception while deleting DDL Log." ;
|
||||
}
|
||||
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
|
||||
if ( rc != 0)
|
||||
{
|
||||
throw std::runtime_error(errorMsg);
|
||||
@@ -1116,9 +1192,11 @@ void DDLPackageProcessor::fetchLogFile(TableLogInfo & tableLogInfos, uint64_t un
|
||||
SUMMARY_INFO("DDLPackageProcessor::fetchLogFile");
|
||||
OamCache* oamcache = OamCache::makeOamCache();
|
||||
std::string OAMParentModuleName = oamcache->getOAMParentModuleName();
|
||||
|
||||
//Use a sensible default so that substr doesn't throw...
|
||||
if (OAMParentModuleName.empty())
|
||||
OAMParentModuleName = "pm1";
|
||||
|
||||
int parentId = atoi(OAMParentModuleName.substr(2, OAMParentModuleName.length()).c_str());
|
||||
ByteStream bytestream;
|
||||
uint8_t rc = 0;
|
||||
@@ -1129,21 +1207,27 @@ void DDLPackageProcessor::fetchLogFile(TableLogInfo & tableLogInfos, uint64_t un
|
||||
boost::shared_ptr<messageqcpp::ByteStream> bsIn;
|
||||
bytestream << (ByteStream::byte)WE_SVR_FETCH_DDL_LOGS;
|
||||
bytestream << uniqueId;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->write(bytestream, (uint32_t)parentId);
|
||||
|
||||
while (1)
|
||||
{
|
||||
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 deleting DDL log";
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> rc;
|
||||
*bsIn >> errorMsg;
|
||||
|
||||
while ( bsIn->length() > 0 )
|
||||
{
|
||||
*bsIn >> tmp32;
|
||||
@@ -1154,19 +1238,23 @@ void DDLPackageProcessor::fetchLogFile(TableLogInfo & tableLogInfos, uint64_t un
|
||||
numOids = tmp32;
|
||||
OidList oidsList;
|
||||
PartitionNums partitionNums;
|
||||
|
||||
for (unsigned i = 0; i < numOids; i++)
|
||||
{
|
||||
*bsIn >> tmp32;
|
||||
oidsList.push_back(tmp32);
|
||||
}
|
||||
|
||||
*bsIn >> tmp32;
|
||||
numPartitions = tmp32;
|
||||
BRM::LogicalPartition lp;
|
||||
|
||||
for (unsigned i = 0; i < numPartitions; i++)
|
||||
{
|
||||
lp.unserialize(*bsIn);
|
||||
partitionNums.insert(lp);
|
||||
}
|
||||
|
||||
//build the tableloginfo
|
||||
LogInfo aLog;
|
||||
aLog.fileType = logFileType;
|
||||
@@ -1174,6 +1262,7 @@ void DDLPackageProcessor::fetchLogFile(TableLogInfo & tableLogInfos, uint64_t un
|
||||
aLog.partitionNums = partitionNums;
|
||||
tableLogInfos[tableOid] = aLog;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1188,7 +1277,9 @@ void DDLPackageProcessor::fetchLogFile(TableLogInfo & tableLogInfos, uint64_t un
|
||||
rc = NETWORK_ERROR;
|
||||
errorMsg = "Got unknown exception while fetching DDL Log." ;
|
||||
}
|
||||
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
|
||||
if ( rc != 0)
|
||||
throw std::runtime_error(errorMsg);
|
||||
|
||||
@@ -1218,27 +1309,36 @@ void DDLPackageProcessor::createWritePartitionLogFile(execplan::CalpontSystemCat
|
||||
(*it).serialize(bytestream);
|
||||
|
||||
bytestream << (uint32_t) oidList.size();
|
||||
|
||||
for (uint32_t i = 0; i < oidList.size(); i++)
|
||||
{
|
||||
bytestream << (uint32_t)oidList[i];
|
||||
}
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->write(bytestream, (uint32_t)parentId);
|
||||
|
||||
while (1)
|
||||
{
|
||||
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 writing DDL drop partition log";
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> rc;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1253,7 +1353,9 @@ void DDLPackageProcessor::createWritePartitionLogFile(execplan::CalpontSystemCat
|
||||
rc = NETWORK_ERROR;
|
||||
errorMsg = "Got unknown exception while writting truncate Log." ;
|
||||
}
|
||||
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
|
||||
if ( rc != 0)
|
||||
throw std::runtime_error(errorMsg);
|
||||
}
|
||||
@@ -1274,27 +1376,36 @@ void DDLPackageProcessor::createWriteTruncateTableLogFile(execplan::CalpontSyste
|
||||
bytestream << uniqueId;
|
||||
bytestream << (uint32_t)tableOid;
|
||||
bytestream << (uint32_t) oidList.size();
|
||||
|
||||
for (uint32_t i = 0; i < oidList.size(); i++)
|
||||
{
|
||||
bytestream << (uint32_t)oidList[i];
|
||||
}
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->write(bytestream, (uint32_t)parentId);
|
||||
|
||||
while (1)
|
||||
{
|
||||
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 writing truncate table log";
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> rc;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1322,12 +1433,15 @@ void DDLPackageProcessor::createOpenTruncateTableLogFile(execplan::CalpontSystem
|
||||
string prefix, error;
|
||||
config::Config* config = config::Config::makeConfig();
|
||||
prefix = config->getConfig("SystemConfig", "DBRMRoot");
|
||||
if (prefix.length() == 0) {
|
||||
|
||||
if (prefix.length() == 0)
|
||||
{
|
||||
error = "Need a valid DBRMRoot entry in Calpont configuation file";
|
||||
throw std::runtime_error(error);
|
||||
}
|
||||
|
||||
uint64_t pos = prefix.find_last_of ("/") ;
|
||||
|
||||
if (pos != string::npos)
|
||||
{
|
||||
fDDLLogFileName = prefix.substr(0, pos + 1); //Get the file path
|
||||
@@ -1338,6 +1452,7 @@ void DDLPackageProcessor::createOpenTruncateTableLogFile(execplan::CalpontSystem
|
||||
throw std::runtime_error(error);
|
||||
|
||||
}
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << tableOid;
|
||||
fDDLLogFileName += "DDL_TRUNCATETABLE_Log_" + oss.str();
|
||||
@@ -1455,12 +1570,15 @@ void DDLPackageProcessor::returnOIDs(execplan::CalpontSystemCatalog::RIDList& ri
|
||||
CalpontSystemCatalog::ROPair roPair;
|
||||
CalpontSystemCatalog::RIDList::const_iterator col_iter = ridList.begin();
|
||||
std::string err;
|
||||
|
||||
try
|
||||
{
|
||||
execplan::ObjectIDManager fObjectIDManager;
|
||||
|
||||
while (col_iter != ridList.end())
|
||||
{
|
||||
roPair = *col_iter;
|
||||
|
||||
if (roPair.objnum < 3000)
|
||||
{
|
||||
++col_iter;
|
||||
@@ -1473,14 +1591,17 @@ void DDLPackageProcessor::returnOIDs(execplan::CalpontSystemCatalog::RIDList& ri
|
||||
|
||||
CalpontSystemCatalog::DictOID dictOID;
|
||||
CalpontSystemCatalog::DictOIDList::const_iterator dict_iter = dictOIDList.begin();
|
||||
|
||||
while (dict_iter != dictOIDList.end())
|
||||
{
|
||||
dictOID = *dict_iter;
|
||||
|
||||
if (dictOID.dictOID < 3000)
|
||||
{
|
||||
++dict_iter;
|
||||
continue;
|
||||
}
|
||||
|
||||
fObjectIDManager.returnOID(dictOID.dictOID);
|
||||
++dict_iter;
|
||||
}
|
||||
@@ -1504,10 +1625,12 @@ void DDLPackageProcessor::findColumnData(uint32_t sessionID, execplan::CalpontSy
|
||||
ColumnList columns;
|
||||
ColumnList::const_iterator column_iterator;
|
||||
std::string err;
|
||||
|
||||
try
|
||||
{
|
||||
getColumnsForTable(sessionID, systableName.schema, systableName.table, columns);
|
||||
column_iterator = columns.begin();
|
||||
|
||||
while (column_iterator != columns.end())
|
||||
{
|
||||
sysCol = *column_iterator;
|
||||
@@ -1517,6 +1640,7 @@ void DDLPackageProcessor::findColumnData(uint32_t sessionID, execplan::CalpontSy
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
++column_iterator;
|
||||
}
|
||||
}
|
||||
@@ -1535,19 +1659,23 @@ void DDLPackageProcessor::findColumnData(uint32_t sessionID, execplan::CalpontSy
|
||||
void DDLPackageProcessor::cleanString(string& s)
|
||||
{
|
||||
string::size_type pos = s.find_first_not_of(" ");
|
||||
|
||||
//stripe off space and ' or '' at beginning and end
|
||||
if (pos < s.length())
|
||||
{
|
||||
s = s.substr(pos, s.length() - pos);
|
||||
|
||||
if ((pos = s.find_last_of(" ")) < s.length())
|
||||
{
|
||||
s = s.substr(0, pos);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (s[0] == '\'')
|
||||
{
|
||||
s = s.substr(1, s.length() - 2);
|
||||
|
||||
if (s[0] == '\'')
|
||||
s = s.substr(1, s.length() - 2);
|
||||
}
|
||||
@@ -1587,21 +1715,27 @@ int DDLPackageProcessor::rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID
|
||||
int rc = 0;
|
||||
ByteStream::byte tmp8;
|
||||
std::string errorMsg;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = NETWORK_ERROR;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = tmp8;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
@@ -1621,20 +1755,26 @@ int DDLPackageProcessor::rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID
|
||||
fWEClient->write_to_all(bytestream);
|
||||
bsIn.reset(new ByteStream());
|
||||
msgRecived = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = tmp8;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
@@ -1645,6 +1785,7 @@ int DDLPackageProcessor::rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,9 +88,11 @@ public:
|
||||
*/
|
||||
enum ResultCode { NO_ERROR, CREATE_ERROR, ALTER_ERROR, DROP_ERROR, TRUNC_ERROR,
|
||||
TOKENIZATION_ERROR, NOT_ACCEPTING_PACKAGES, PK_NOTNULL_ERROR, WARNING, USER_ERROR, NETWORK_ERROR, PARTITION_WARNING,
|
||||
WARN_NO_PARTITION};
|
||||
WARN_NO_PARTITION
|
||||
};
|
||||
|
||||
enum DebugLevel { /** @brief Debug level type enumeration */
|
||||
enum DebugLevel /** @brief Debug level type enumeration */
|
||||
{
|
||||
NONE = 0, /** @brief No debug info */
|
||||
SUMMARY = 1, /** @brief Summary level debug info */
|
||||
DETAIL = 2, /** @brief A little detail debug info */
|
||||
@@ -166,7 +168,13 @@ public:
|
||||
unsigned month : 4;
|
||||
unsigned year : 16;
|
||||
// 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
|
||||
@@ -189,8 +197,16 @@ public:
|
||||
unsigned month : 4;
|
||||
unsigned year : 16;
|
||||
// NULL column value = 0xFFFFFFFFFFFFFFFE
|
||||
EXPORT dateTime( ) { year = 0xFFFF; month = 0xF; day = 0x3F; hour = 0x3F; minute = 0x3F; second = 0x3F;
|
||||
msecond = 0xFFFFE; }
|
||||
EXPORT dateTime( )
|
||||
{
|
||||
year = 0xFFFF;
|
||||
month = 0xF;
|
||||
day = 0x3F;
|
||||
hour = 0x3F;
|
||||
minute = 0x3F;
|
||||
second = 0x3F;
|
||||
msecond = 0xFFFFE;
|
||||
}
|
||||
};
|
||||
/*
|
||||
struct dateTime
|
||||
@@ -217,17 +233,32 @@ public:
|
||||
NJLSysDataVector sysDataVec;
|
||||
EXPORT NJLSysDataList() {};
|
||||
EXPORT ~NJLSysDataList();
|
||||
NJLSysDataVector::const_iterator begin() {return sysDataVec.begin();}
|
||||
NJLSysDataVector::const_iterator end() {return sysDataVec.end();}
|
||||
void push_back(execplan::ColumnResult* cr) {sysDataVec.push_back(cr);}
|
||||
unsigned int size() {return static_cast<unsigned int>(sysDataVec.size());}
|
||||
NJLSysDataVector::const_iterator begin()
|
||||
{
|
||||
return sysDataVec.begin();
|
||||
}
|
||||
NJLSysDataVector::const_iterator end()
|
||||
{
|
||||
return sysDataVec.end();
|
||||
}
|
||||
void push_back(execplan::ColumnResult* cr)
|
||||
{
|
||||
sysDataVec.push_back(cr);
|
||||
}
|
||||
unsigned int size()
|
||||
{
|
||||
return static_cast<unsigned int>(sysDataVec.size());
|
||||
}
|
||||
int findColumn(const execplan::CalpontSystemCatalog::OID& columnOID)
|
||||
{
|
||||
for(uint32_t i = 0; i < sysDataVec.size(); i++) {
|
||||
if(sysDataVec[i]->ColumnOID() == columnOID) {
|
||||
for (uint32_t i = 0; i < sysDataVec.size(); i++)
|
||||
{
|
||||
if (sysDataVec[i]->ColumnOID() == columnOID)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
@@ -250,28 +281,49 @@ public:
|
||||
|
||||
/** @brief Is it required to debug
|
||||
*/
|
||||
const bool isDebug( const DebugLevel level ) const { return level <= fDebugLevel; }
|
||||
const bool isDebug( const DebugLevel level ) const
|
||||
{
|
||||
return level <= fDebugLevel;
|
||||
}
|
||||
|
||||
/** @brief Get debug level
|
||||
*/
|
||||
const DebugLevel getDebugLevel() const { return fDebugLevel; }
|
||||
const DebugLevel getDebugLevel() const
|
||||
{
|
||||
return fDebugLevel;
|
||||
}
|
||||
|
||||
/** @brief Set debug level
|
||||
*/
|
||||
void setDebugLevel( const DebugLevel level ) { fDebugLevel = level; }
|
||||
void setDebugLevel( const DebugLevel level )
|
||||
{
|
||||
fDebugLevel = level;
|
||||
}
|
||||
|
||||
/** @brief Get index oid that was allocated during index creation
|
||||
*/
|
||||
IndexOID getIndexOID() const { return fIdxOID; }
|
||||
IndexOID getIndexOID() const
|
||||
{
|
||||
return fIdxOID;
|
||||
}
|
||||
|
||||
/** @brief Get starting column oid that was allocated during table
|
||||
* creation.
|
||||
*/
|
||||
int getStartingColumnOID() const { return fStartingColOID; }
|
||||
int getStartingColumnOID() const
|
||||
{
|
||||
return fStartingColOID;
|
||||
}
|
||||
|
||||
/** @brief access and mutator of fPKName */
|
||||
const std::string PKName() const {return fPKName;}
|
||||
void PKName (const std::string PKName) {fPKName = PKName;}
|
||||
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
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
|
||||
using namespace ddlpackage;
|
||||
|
||||
namespace ddlpackageprocessor {
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
DDLPackageProcessor* DDLPackageProcessorFactory::
|
||||
makePackageProcessor(int packageType, ddlpackage::CalpontDDLPackage& cpackage)
|
||||
|
||||
@@ -28,12 +28,14 @@
|
||||
#include "ddlpackageprocessor.h"
|
||||
|
||||
|
||||
namespace ddlpackageprocessor {
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
/** @brief create a ddlPackageProcessor object from a CalpontddlPackage object
|
||||
*
|
||||
*/
|
||||
class DDLPackageProcessorFactory {
|
||||
class DDLPackageProcessorFactory
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
||||
|
||||
VERBOSE_INFO("Removing the SYSINDEX meta data");
|
||||
removeSysIndexMetaData(dropIndexStmt.fSessionID, txnID.id, result, *dropIndexStmt.fIndexName);
|
||||
|
||||
if (result.result != NO_ERROR)
|
||||
{
|
||||
DETAIL_INFO("writeSysIndexMetaData failed");
|
||||
@@ -68,6 +69,7 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
||||
|
||||
VERBOSE_INFO("Removing the SYSINDEXCOL meta data");
|
||||
removeSysIndexColMetaData(dropIndexStmt.fSessionID, txnID.id, result, *dropIndexStmt.fIndexName);
|
||||
|
||||
if (result.result != NO_ERROR)
|
||||
{
|
||||
DETAIL_INFO("writeSysIndexMetaData failed");
|
||||
@@ -77,6 +79,7 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
||||
|
||||
VERBOSE_INFO("Removing the index files");
|
||||
err = fWriteEngine.dropIndex(txnID.id, indexOID.objnum, indexOID.listOID);
|
||||
|
||||
if (err)
|
||||
{
|
||||
DETAIL_INFO("WriteEngine dropIndex failed");
|
||||
@@ -88,11 +91,13 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
||||
|
||||
// register the changes
|
||||
err = fWriteEngine.commit( txnID.id );
|
||||
|
||||
if (err)
|
||||
{
|
||||
DETAIL_INFO("Failed to commit the drop index transaction");
|
||||
goto rollback;
|
||||
}
|
||||
|
||||
fSessionManager.committed(txnID);
|
||||
//fObjectIDManager.returnOID(indexOID.objnum);
|
||||
//fObjectIDManager.returnOID(indexOID.listOID);
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace ddlpackageprocessor
|
||||
BRM::TxnID txnID;
|
||||
txnID.id = fTxnid.id;
|
||||
txnID.valid = fTxnid.valid;
|
||||
|
||||
if (rc != 0 )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
@@ -80,7 +81,8 @@ namespace ddlpackageprocessor
|
||||
uint64_t uniqueId = 0;
|
||||
|
||||
//Bug 5070. Added exception handling
|
||||
try {
|
||||
try
|
||||
{
|
||||
uniqueId = fDbrm->getUnique64();
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
@@ -119,22 +121,26 @@ namespace ddlpackageprocessor
|
||||
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 {
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -164,12 +170,14 @@ namespace ddlpackageprocessor
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
#else
|
||||
struct timespec abs_ts;
|
||||
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
// reset
|
||||
sessionID = dropPartitionStmt.fSessionID;
|
||||
@@ -177,6 +185,7 @@ namespace ddlpackageprocessor
|
||||
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 );
|
||||
@@ -230,6 +239,7 @@ namespace ddlpackageprocessor
|
||||
if ( tableColRidList[i].objnum > 3000 )
|
||||
oidList.push_back( tableColRidList[i].objnum );
|
||||
}
|
||||
|
||||
for ( unsigned i = 0; i < dictOIDList.size(); i++ )
|
||||
{
|
||||
if ( dictOIDList[i].dictOID > 3000 )
|
||||
@@ -239,6 +249,7 @@ namespace ddlpackageprocessor
|
||||
//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)
|
||||
@@ -262,6 +273,7 @@ namespace ddlpackageprocessor
|
||||
}
|
||||
|
||||
set<BRM::LogicalPartition>::iterator it;
|
||||
|
||||
for (it = dropPartitionStmt.fPartitions.begin(); it != dropPartitionStmt.fPartitions.end(); ++it)
|
||||
{
|
||||
if (outOfServicePartitions.find(*it) != outOfServicePartitions.end())
|
||||
@@ -279,6 +291,7 @@ namespace ddlpackageprocessor
|
||||
//Remove the partition from extent map
|
||||
emsg.clear();
|
||||
rc = fDbrm->deletePartition( oidList, dropPartitionStmt.fPartitions, emsg);
|
||||
|
||||
if ( rc != 0 )
|
||||
throw std::runtime_error(emsg);
|
||||
}
|
||||
@@ -297,14 +310,19 @@ namespace ddlpackageprocessor
|
||||
result.result = WARN_NO_PARTITION;
|
||||
else
|
||||
result.result = DROP_ERROR;
|
||||
|
||||
result.message = message;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
@@ -322,30 +340,39 @@ namespace ddlpackageprocessor
|
||||
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
}
|
||||
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 {
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
deleteLogFile(DROPPART_LOG, roPair.objnum, uniqueId);
|
||||
} catch (std::exception&)
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro
|
||||
txnID.valid = fTxnid.valid;
|
||||
int rc1 = 0;
|
||||
rc1 = fDbrm->isReadWrite();
|
||||
|
||||
if (rc1 != 0 )
|
||||
{
|
||||
Message::Args args;
|
||||
@@ -91,8 +92,10 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro
|
||||
std::string errorMsg;
|
||||
ByteStream bytestream;
|
||||
uint64_t uniqueId = 0;
|
||||
|
||||
//Bug 5070. Added exception handling
|
||||
try {
|
||||
try
|
||||
{
|
||||
uniqueId = fDbrm->getUnique64();
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
@@ -179,12 +182,14 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro
|
||||
int i = 0;
|
||||
|
||||
std::vector<uint32_t> pms;
|
||||
|
||||
for (unsigned i = 0; i < moduleIds.size(); i++)
|
||||
{
|
||||
pms.push_back((uint32_t)moduleIds[i]);
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnid, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -210,14 +215,18 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
#else
|
||||
struct timespec abs_ts;
|
||||
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
processID = ::getpid();
|
||||
txnid = txnID.id;
|
||||
sessionId = dropTableStmt.fSessionID;;
|
||||
@@ -232,6 +241,7 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro
|
||||
if (tableLockId > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i >= numTries) //error out
|
||||
{
|
||||
Message::Args args;
|
||||
@@ -270,6 +280,7 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro
|
||||
if ( tableColRidList[i].objnum > 3000 )
|
||||
oidList.push_back( tableColRidList[i].objnum );
|
||||
}
|
||||
|
||||
for ( unsigned i = 0; i < dictOIDList.size(); i++ )
|
||||
{
|
||||
if ( dictOIDList[i].dictOID > 3000 )
|
||||
@@ -294,6 +305,7 @@ cout << fTxnid.id << " Removing the SYSTABLEs meta data" << endl;
|
||||
|
||||
uint16_t dbRoot;
|
||||
rc = fDbrm->getSysCatDBRoot(sysOid, dbRoot);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
result.result = (ResultCode) rc;
|
||||
@@ -309,6 +321,7 @@ cout << fTxnid.id << " Removing the SYSTABLEs meta data" << endl;
|
||||
|
||||
boost::shared_ptr<std::map<int, int> > dbRootPMMap = oamcache->getDBRootToPMMap();
|
||||
pmNum = (*dbRootPMMap)[dbRoot];
|
||||
|
||||
try
|
||||
{
|
||||
// #ifdef IDB_DDL_DEBUG
|
||||
@@ -316,21 +329,27 @@ cout << fTxnid.id << " Drop table sending WE_SVR_DELETE_SYSTABLES to pm " << pmN
|
||||
//#endif
|
||||
//cout << "deleting systable entries with txnid " << txnID.id << endl;
|
||||
fWEClient->write(bytestream, (uint32_t)pmNum);
|
||||
|
||||
while (1)
|
||||
{
|
||||
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";
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> rc;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -380,6 +399,7 @@ cout << fTxnid.id << " Drop table got unknown exception" << endl;
|
||||
//Find out where syscolumn is
|
||||
sysOid = 1021;
|
||||
rc = fDbrm->getSysCatDBRoot(sysOid, dbRoot);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
result.result = (ResultCode) rc;
|
||||
@@ -394,27 +414,34 @@ cout << fTxnid.id << " Drop table got unknown exception" << endl;
|
||||
}
|
||||
|
||||
pmNum = (*dbRootPMMap)[dbRoot];
|
||||
|
||||
try
|
||||
{
|
||||
//#ifdef IDB_DDL_DEBUG
|
||||
cout << fTxnid.id << " Drop table sending WE_SVR_DELETE_SYSCOLUMN to pm " << pmNum << endl;
|
||||
//#endif
|
||||
fWEClient->write(bytestream, (unsigned)pmNum);
|
||||
|
||||
while (1)
|
||||
{
|
||||
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";
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> rc;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -453,6 +480,7 @@ cout << fTxnid.id << " Drop table got unknown exception" << endl;
|
||||
}
|
||||
|
||||
rc = commitTransaction(uniqueId, txnID);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
cout << txnID.id << " rolledback transaction " << " and valid is " << txnID.valid << endl;
|
||||
@@ -491,13 +519,16 @@ cout << fTxnid.id << " Drop table got unknown exception" << endl;
|
||||
args.add("Drop table failed due to ");
|
||||
args.add(ex.what());
|
||||
fSessionManager.rolledback(txnID);
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
(void)fDbrm->releaseTableLock(tableLockId);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
args.add(IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE));
|
||||
}
|
||||
|
||||
message.format( args );
|
||||
result.message = message;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
@@ -512,20 +543,24 @@ cout << fTxnid.id << " Drop table got unknown exception" << endl;
|
||||
args.add("Drop table failed due to ");
|
||||
args.add(errorMsg);
|
||||
fSessionManager.rolledback(txnID);
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
(void)fDbrm->releaseTableLock(tableLockId);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
args.add(IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE));
|
||||
}
|
||||
|
||||
message.format( args );
|
||||
result.message = message;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
(void)fDbrm->releaseTableLock(tableLockId);
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -543,7 +578,8 @@ cout << fTxnid.id << " Drop table got unknown exception" << endl;
|
||||
}
|
||||
|
||||
//Save the oids to a file
|
||||
try {
|
||||
try
|
||||
{
|
||||
createWriteDropLogFile( roPair.objnum, uniqueId, oidList );
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
@@ -559,6 +595,7 @@ cout << fTxnid.id << " Drop table got unknown exception" << endl;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Bug 4208 Drop the PrimProcFDCache before droping the column files
|
||||
// FOr Windows, this ensures (most likely) that the column files have
|
||||
// no open handles to hinder the deletion of the files.
|
||||
@@ -569,34 +606,44 @@ cout << fTxnid.id << " Drop table got unknown exception" << endl;
|
||||
bytestream << (ByteStream::byte)WE_SVR_WRITE_DROPFILES;
|
||||
bytestream << uniqueId;
|
||||
bytestream << (uint32_t) oidList.size();
|
||||
|
||||
for (unsigned i = 0; i < oidList.size(); i++)
|
||||
{
|
||||
bytestream << (uint32_t) oidList[i];
|
||||
}
|
||||
|
||||
//#ifdef IDB_DDL_DEBUG
|
||||
cout << fTxnid.id << " Drop table removing column files" << endl;
|
||||
//#endif
|
||||
uint32_t msgRecived = 0;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->write_to_all(bytestream);
|
||||
|
||||
bsIn.reset(new ByteStream());
|
||||
ByteStream::byte tmp8;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = NETWORK_ERROR;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = tmp8;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
@@ -633,6 +680,7 @@ cout << fTxnid.id << " Drop table removing column files" << endl;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
return result;
|
||||
}
|
||||
|
||||
//Drop PrimProc FD cache
|
||||
rc = cacheutils::dropPrimProcFdCache();
|
||||
//Flush primProc cache
|
||||
@@ -695,6 +743,7 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
BRM::TxnID txnID;
|
||||
txnID.id = fTxnid.id;
|
||||
txnID.valid = fTxnid.valid;
|
||||
|
||||
if (rc != 0 )
|
||||
{
|
||||
Message::Args args;
|
||||
@@ -724,8 +773,10 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
systemCatalogPtr->sessionID(truncTableStmt.fSessionID);
|
||||
CalpontSystemCatalog::TableInfo tableInfo;
|
||||
uint64_t uniqueId = 0;
|
||||
|
||||
//Bug 5070. Added exception handling
|
||||
try {
|
||||
try
|
||||
{
|
||||
uniqueId = fDbrm->getUnique64();
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
@@ -750,6 +801,7 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
fWEClient->addQueue(uniqueId);
|
||||
int pmNum = 1;
|
||||
boost::shared_ptr<messageqcpp::ByteStream> bsIn;
|
||||
@@ -758,6 +810,7 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
uint64_t tableLockId = 0;
|
||||
OamCache* oamcache = OamCache::makeOamCache();
|
||||
std::vector<int> moduleIds = oamcache->getModuleIds();
|
||||
|
||||
try
|
||||
{
|
||||
//check table lock
|
||||
@@ -771,11 +824,14 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
int i = 0;
|
||||
|
||||
std::vector<uint32_t> pms;
|
||||
|
||||
for (unsigned i = 0; i < moduleIds.size(); i++)
|
||||
{
|
||||
pms.push_back((uint32_t)moduleIds[i]);
|
||||
}
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnid, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -801,14 +857,18 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
#else
|
||||
struct timespec abs_ts;
|
||||
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
processID = ::getpid();
|
||||
txnid = txnID.id;
|
||||
sessionId = truncTableStmt.fSessionID;
|
||||
@@ -823,6 +883,7 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
if (tableLockId > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i >= numTries) //error out
|
||||
{
|
||||
Message::Args args;
|
||||
@@ -832,6 +893,7 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
throw std::runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_TABLE_LOCKED, args));
|
||||
}
|
||||
}
|
||||
|
||||
CalpontSystemCatalog::TableName userTableName;
|
||||
userTableName.schema = truncTableStmt.fTableName->fSchema;
|
||||
userTableName.table = truncTableStmt.fTableName->fName;
|
||||
@@ -839,6 +901,7 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
tableColRidList = systemCatalogPtr->columnRIDs( userTableName );
|
||||
|
||||
dictOIDList = systemCatalogPtr->dictOIDs( userTableName );
|
||||
|
||||
for ( unsigned i = 0; i < tableColRidList.size(); i++ )
|
||||
{
|
||||
if ( tableColRidList[i].objnum > 3000 )
|
||||
@@ -847,11 +910,13 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
allOidList.push_back( tableColRidList[i].objnum );
|
||||
}
|
||||
}
|
||||
|
||||
for ( unsigned i = 0; i < dictOIDList.size(); i++ )
|
||||
{
|
||||
if ( dictOIDList[i].dictOID > 3000 )
|
||||
allOidList.push_back( dictOIDList[i].dictOID );
|
||||
}
|
||||
|
||||
//Check whether the table has autoincrement column
|
||||
tableInfo = systemCatalogPtr->tableInfo(userTableName);
|
||||
}
|
||||
@@ -865,13 +930,16 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
args.add( ex.what() );
|
||||
args.add("");
|
||||
fSessionManager.rolledback(txnID);
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
(void)fDbrm->releaseTableLock(tableLockId);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
args.add(IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE));
|
||||
}
|
||||
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
message.format( args );
|
||||
|
||||
@@ -888,13 +956,16 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
args.add("Truncate table failed: ");
|
||||
args.add( "encountered unkown exception" );
|
||||
args.add("");
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
(void)fDbrm->releaseTableLock(tableLockId);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
args.add(IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE));
|
||||
}
|
||||
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
message.format( args );
|
||||
|
||||
@@ -904,7 +975,8 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
}
|
||||
|
||||
//Save the oids to a file
|
||||
try {
|
||||
try
|
||||
{
|
||||
createWriteTruncateTableLogFile( roPair.objnum, uniqueId, allOidList);
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
@@ -916,11 +988,14 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
fSessionManager.rolledback(txnID);
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
message.format( args );
|
||||
|
||||
//@bug 4515 Release the tablelock as nothing has done to this table.
|
||||
try {
|
||||
try
|
||||
{
|
||||
(void)fDbrm->releaseTableLock(tableLockId);
|
||||
}
|
||||
catch (std::exception&) {}
|
||||
|
||||
result.result = TRUNC_ERROR;
|
||||
result.message = message;
|
||||
return result;
|
||||
@@ -932,9 +1007,11 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
// MCOL-66 The DBRM can't handle concurrent DDL
|
||||
boost::mutex::scoped_lock lk(dbrmMutex);
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
//Disable extents first
|
||||
int rc1 = fDbrm->markAllPartitionForDeletion( allOidList);
|
||||
|
||||
if (rc1 != 0)
|
||||
{
|
||||
string errMsg;
|
||||
@@ -951,13 +1028,16 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
bytestream << (ByteStream::byte)WE_SVR_WRITE_DROPFILES;
|
||||
bytestream << uniqueId;
|
||||
bytestream << (uint32_t) allOidList.size();
|
||||
|
||||
for (unsigned i = 0; i < allOidList.size(); i++)
|
||||
{
|
||||
bytestream << (uint32_t) allOidList[i];
|
||||
}
|
||||
|
||||
uint32_t msgRecived = 0;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->write_to_all(bytestream);
|
||||
|
||||
bsIn.reset(new ByteStream());
|
||||
@@ -966,17 +1046,22 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = NETWORK_ERROR;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = tmp8;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
@@ -1018,6 +1103,7 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
deleteLogFile(TRUNCATE_LOG, roPair.objnum, uniqueId);
|
||||
return result;
|
||||
}
|
||||
|
||||
//Drop PrimProc FD cache
|
||||
rc = cacheutils::dropPrimProcFdCache();
|
||||
//Flush primProc cache
|
||||
@@ -1063,8 +1149,10 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
for (unsigned col = 0; col < columnOidList.size(); col++)
|
||||
{
|
||||
colType = systemCatalogPtr->colType(columnOidList[col]);
|
||||
|
||||
if (colType.autoincrement)
|
||||
autoIncColOid = colType.columnOID;
|
||||
|
||||
bytestream << (uint32_t)columnOidList[col];
|
||||
bytestream << (uint8_t) colType.colDataType;
|
||||
bytestream << (uint8_t) false;
|
||||
@@ -1086,57 +1174,71 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
|
||||
boost::shared_ptr<std::map<int, int> > dbRootPMMap = oamcache->getDBRootToPMMap();
|
||||
pmNum = (*dbRootPMMap)[useDBRoot];
|
||||
|
||||
try
|
||||
{
|
||||
#ifdef IDB_DDL_DEBUG
|
||||
cout << "Truncate table sending We_SVR_WRITE_CREATETABLEFILES to pm " << pmNum << endl;
|
||||
#endif
|
||||
fWEClient->write(bytestream, pmNum);
|
||||
|
||||
while (1)
|
||||
{
|
||||
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";
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = tmp8;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rc != 0) {
|
||||
if (rc != 0)
|
||||
{
|
||||
//drop the newly created files
|
||||
bytestream.restart();
|
||||
bytestream << (ByteStream::byte) WE_SVR_WRITE_DROPFILES;
|
||||
bytestream << uniqueId;
|
||||
bytestream << (uint32_t)(allOidList.size());
|
||||
|
||||
for (unsigned i = 0; i < (allOidList.size()); i++)
|
||||
{
|
||||
bytestream << (uint32_t)(allOidList[i]);
|
||||
}
|
||||
|
||||
fWEClient->write(bytestream, pmNum);
|
||||
|
||||
while (1)
|
||||
{
|
||||
bsIn.reset(new ByteStream());
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
//rc = tmp8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Message::Args args;
|
||||
Message message(1);
|
||||
args.add( "Truncate table failed." );
|
||||
@@ -1157,11 +1259,13 @@ cout << "Truncate table sending We_SVR_WRITE_CREATETABLEFILES to pm " << pmNum <
|
||||
errorMsg = "Lost connection to Write Engine Server";
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
catch (std::exception&)
|
||||
{
|
||||
//FIXME: Windows can't delete a file that's still open by another process
|
||||
}
|
||||
|
||||
#else
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
@@ -1178,6 +1282,7 @@ cout << "Truncate table sending We_SVR_WRITE_CREATETABLEFILES to pm " << pmNum <
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
catch ( ... )
|
||||
{
|
||||
@@ -1195,6 +1300,7 @@ cout << "Truncate table sending We_SVR_WRITE_CREATETABLEFILES to pm " << pmNum <
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
rollBackTransaction( uniqueId, txnID, truncTableStmt.fSessionID); //What to do with the error code
|
||||
@@ -1208,9 +1314,12 @@ cout << "Truncate table sending We_SVR_WRITE_CREATETABLEFILES to pm " << pmNum <
|
||||
WE_DDLCommandClient commandClient;
|
||||
rc = commandClient.UpdateSyscolumnNextval(autoIncColOid, 1);
|
||||
}
|
||||
|
||||
// Log the DDL statement
|
||||
logDDL(truncTableStmt.fSessionID, txnID.id, truncTableStmt.fSql, truncTableStmt.fOwner);
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
(void)fDbrm->releaseTableLock(tableLockId);
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -1228,11 +1337,14 @@ cout << "Truncate table sending We_SVR_WRITE_CREATETABLEFILES to pm " << pmNum <
|
||||
fSessionManager.rolledback(txnID);
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
}
|
||||
|
||||
//release the transaction
|
||||
fSessionManager.committed(txnID);
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
|
||||
//Remove the log file
|
||||
try {
|
||||
try
|
||||
{
|
||||
deleteLogFile(TRUNCATE_LOG, roPair.objnum, uniqueId);
|
||||
}
|
||||
catch ( ... )
|
||||
|
||||
@@ -50,6 +50,7 @@ MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpack
|
||||
|
||||
int rc = 0;
|
||||
rc = fDbrm->isReadWrite();
|
||||
|
||||
if (rc != 0 )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
@@ -61,6 +62,7 @@ MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpack
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector <CalpontSystemCatalog::OID> oidList;
|
||||
CalpontSystemCatalog::RIDList tableColRidList;
|
||||
CalpontSystemCatalog::DictOIDList dictOIDList;
|
||||
@@ -84,22 +86,26 @@ MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpack
|
||||
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 {
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -128,12 +134,14 @@ MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpack
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
#else
|
||||
struct timespec abs_ts;
|
||||
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
// reset
|
||||
sessionID = markPartitionStmt.fSessionID;
|
||||
@@ -142,7 +150,8 @@ MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpack
|
||||
processID = ::getpid();
|
||||
processName = "DDLProc";
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -191,6 +200,7 @@ MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpack
|
||||
if ( tableColRidList[i].objnum > 3000 )
|
||||
oidList.push_back( tableColRidList[i].objnum );
|
||||
}
|
||||
|
||||
for ( unsigned i = 0; i < dictOIDList.size(); i++ )
|
||||
{
|
||||
if ( dictOIDList[i].dictOID > 3000 )
|
||||
@@ -200,6 +210,7 @@ MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpack
|
||||
//Remove the partition from extent map
|
||||
string emsg;
|
||||
rc = fDbrm->markPartitionForDeletion( oidList, markPartitionStmt.fPartitions, emsg);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
throw std::runtime_error(emsg);
|
||||
@@ -221,13 +232,17 @@ MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpack
|
||||
result.result = DROP_ERROR;
|
||||
|
||||
result.message = message;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
@@ -245,27 +260,36 @@ MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpack
|
||||
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
}
|
||||
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 {
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
@@ -108,6 +109,7 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
@@ -138,6 +140,7 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
@@ -165,10 +168,12 @@ public:
|
||||
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;
|
||||
@@ -194,10 +199,12 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
cout << ptree.fSqlText << endl;
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -225,10 +232,12 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
cout << ptree.fSqlText << endl;
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -340,6 +349,7 @@ int main( int argc, char **argv)
|
||||
|
||||
|
||||
}
|
||||
|
||||
PopulateIndexTest pit(DistributedEngineComm::instance());
|
||||
boost::timer theTimer;
|
||||
|
||||
@@ -588,6 +598,7 @@ int main( int argc, char **argv)
|
||||
cout << "t4" << endl;
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
cout << "Create index test took :" << theTimer.elapsed() << " seconds to complete." << endl;
|
||||
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace ddlpackageprocessor
|
||||
|
||||
int rc = 0;
|
||||
rc = fDbrm->isReadWrite();
|
||||
|
||||
if (rc != 0 )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
@@ -61,6 +62,7 @@ namespace ddlpackageprocessor
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector <CalpontSystemCatalog::OID> oidList;
|
||||
CalpontSystemCatalog::RIDList tableColRidList;
|
||||
CalpontSystemCatalog::DictOIDList dictOIDList;
|
||||
@@ -84,22 +86,26 @@ namespace ddlpackageprocessor
|
||||
tableName.schema = restorePartitionStmt.fTableName->fSchema;
|
||||
tableName.table = restorePartitionStmt.fTableName->fName;
|
||||
roPair = systemCatalogPtr->tableRID( tableName );
|
||||
|
||||
//@Bug 3054 check for system catalog
|
||||
if ( roPair.objnum < 3000 )
|
||||
{
|
||||
throw std::runtime_error("Drop partition cannot be operated on Calpont system catalog.");
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
processID = ::getpid();
|
||||
oam::OamCache* oamcache = oam::OamCache::makeOamCache();
|
||||
std::vector<int> pmList = oamcache->getModuleIds();
|
||||
std::vector<uint32_t> pms;
|
||||
|
||||
for (unsigned i = 0; i < pmList.size(); i++)
|
||||
{
|
||||
pms.push_back((uint32_t)pmList[i]);
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -128,12 +134,14 @@ namespace ddlpackageprocessor
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
#else
|
||||
struct timespec abs_ts;
|
||||
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
// reset
|
||||
sessionID = restorePartitionStmt.fSessionID;
|
||||
@@ -142,7 +150,8 @@ namespace ddlpackageprocessor
|
||||
processID = ::getpid();
|
||||
processName = "DDLProc";
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -193,6 +202,7 @@ namespace ddlpackageprocessor
|
||||
if ( tableColRidList[i].objnum > 3000 )
|
||||
oidList.push_back( tableColRidList[i].objnum );
|
||||
}
|
||||
|
||||
for ( unsigned i = 0; i < dictOIDList.size(); i++ )
|
||||
{
|
||||
if ( dictOIDList[i].dictOID > 3000 )
|
||||
@@ -202,6 +212,7 @@ namespace ddlpackageprocessor
|
||||
//Remove the partition from extent map
|
||||
string emsg;
|
||||
rc = fDbrm->restorePartition( oidList, restorePartitionStmt.fPartitions, emsg);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
throw std::runtime_error(emsg);
|
||||
@@ -221,13 +232,17 @@ namespace ddlpackageprocessor
|
||||
result.result = DROP_ERROR;
|
||||
|
||||
result.message = message;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
result.result = DROP_ERROR;
|
||||
result.message = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
}
|
||||
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
@@ -245,27 +260,36 @@ namespace ddlpackageprocessor
|
||||
|
||||
result.result = DROP_ERROR;
|
||||
result.message = message;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
}
|
||||
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 {
|
||||
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(uniqueID);
|
||||
} catch (std::exception&)
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -411,9 +411,11 @@ public:
|
||||
|
||||
semkey = 0x2149bdd2;
|
||||
sems = semget(semkey, 2, 0666);
|
||||
|
||||
if (sems != -1)
|
||||
{
|
||||
err = semctl(sems, 0, IPC_RMID);
|
||||
|
||||
if (err == -1)
|
||||
perror("tdriver: semctl");
|
||||
}
|
||||
@@ -428,9 +430,11 @@ public:
|
||||
|
||||
shmkey = 0x2149bdd2;
|
||||
shms = shmget(shmkey, 0, 0666);
|
||||
|
||||
if (shms != -1)
|
||||
{
|
||||
err = shmctl(shms, IPC_RMID, NULL);
|
||||
|
||||
if (err == -1 && errno != EINVAL)
|
||||
{
|
||||
perror("tdriver: shmctl");
|
||||
@@ -496,9 +500,11 @@ public:
|
||||
std::string sqlbuf = "create table region( r_regionkey integer NOT NULL, r_name char(25) ,r_comment varchar(152));";
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
CreateTableProcessor processor;
|
||||
@@ -516,6 +522,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -528,9 +535,11 @@ public:
|
||||
std::string sqlbuf = "create table tpch.part( p_partkey integer NOT NULL ,p_name varchar(55) default 'helloworld', p_mfgr char(6), p_brand char(10) , p_type varchar(25) default 'foobar' , p_size integer , p_container char(10) ,p_retailprice integer , p_comment varchar(23), CONSTRAINT PK_PART PRIMARY KEY(p_partkey) )";
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
CreateTableProcessor processor;
|
||||
@@ -554,6 +563,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -563,6 +573,7 @@ public:
|
||||
std::string sqlbuf = "CREATE INDEX test_idx ON tpch.part (p_size)";
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
@@ -584,6 +595,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -593,6 +605,7 @@ public:
|
||||
std::string sqlbuf = "CREATE UNIQUE INDEX test_idx ON tpch.part (p_mfgr)";
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
@@ -614,6 +627,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
void test_altertable_addacolumn()
|
||||
@@ -623,9 +637,11 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -643,6 +659,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -653,9 +670,11 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -673,6 +692,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -683,9 +703,11 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -703,6 +725,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
void test_altertable_dropacolumn()
|
||||
@@ -712,9 +735,11 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -732,6 +757,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -742,9 +768,11 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -762,6 +790,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -772,9 +801,11 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -792,6 +823,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
void test_dropindex()
|
||||
@@ -801,6 +833,7 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
@@ -822,6 +855,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
void test_altertable_renamecolumn()
|
||||
@@ -831,9 +865,11 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -851,6 +887,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -862,9 +899,11 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -882,6 +921,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
void test_altertable_addtableconstraint()
|
||||
@@ -891,9 +931,11 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -911,6 +953,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -921,9 +964,11 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -941,6 +986,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -951,9 +997,11 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -971,6 +1019,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
void test_altertable_dropcolumndefault()
|
||||
@@ -980,9 +1029,11 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -1000,6 +1051,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -1010,9 +1062,11 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
AlterTableProcessor processor;
|
||||
@@ -1030,6 +1084,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@@ -1040,6 +1095,7 @@ public:
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
@@ -1061,6 +1117,7 @@ public:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,16 +50,19 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackage(dmlpacka
|
||||
std::string defaultSchema /*= ""*/)
|
||||
{
|
||||
CalpontDMLPackage* packagePtr = 0;
|
||||
|
||||
try
|
||||
{
|
||||
std::string dmlStatement = vpackage.get_DMLStatement();
|
||||
//@Bug 2680. DMLParser is not thread safe.
|
||||
boost::mutex::scoped_lock lk(fParserLock);
|
||||
DMLParser parser;
|
||||
|
||||
if (defaultSchema.size())
|
||||
{
|
||||
parser.setDefaultSchema(defaultSchema);
|
||||
}
|
||||
|
||||
parser.parse(dmlStatement.c_str());
|
||||
|
||||
if (parser.good())
|
||||
@@ -122,9 +125,11 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackage(dmlpacka
|
||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromBuffer(dmlpackage::VendorDMLStatement& vpackage)
|
||||
{
|
||||
CalpontDMLPackage* packagePtr = 0;
|
||||
|
||||
try
|
||||
{
|
||||
int dmlStatementType = vpackage.get_DMLStatementType();
|
||||
|
||||
switch (dmlStatementType)
|
||||
{
|
||||
case DML_INSERT:
|
||||
@@ -132,22 +137,26 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromBuffe
|
||||
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer
|
||||
(), vpackage.get_Columns(), vpackage.get_Rows());
|
||||
break;
|
||||
|
||||
case DML_UPDATE:
|
||||
packagePtr = new UpdateDMLPackage(vpackage.get_SchemaName(),
|
||||
vpackage.get_TableName(), vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer
|
||||
(), vpackage.get_Columns(), vpackage.get_Rows());
|
||||
break;
|
||||
|
||||
case DML_DELETE:
|
||||
packagePtr = new DeleteDMLPackage(vpackage.get_SchemaName(),
|
||||
vpackage.get_TableName(), vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer
|
||||
(), vpackage.get_Columns(), vpackage.get_Rows());
|
||||
break;
|
||||
|
||||
case DML_COMMAND:
|
||||
packagePtr = new CommandDMLPackage(vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
cerr << "makeCalpontDMLPackage: invalid statement type" << endl;
|
||||
break;
|
||||
@@ -161,29 +170,35 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromBuffe
|
||||
{
|
||||
cerr << "makeCalpontDMLPackage: caught unknown exception!" << endl;
|
||||
}
|
||||
|
||||
return packagePtr;
|
||||
}
|
||||
|
||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage)
|
||||
{
|
||||
CalpontDMLPackage* packagePtr = 0;
|
||||
|
||||
try
|
||||
{
|
||||
int dmlStatementType = vpackage.get_DMLStatementType();
|
||||
|
||||
switch (dmlStatementType)
|
||||
{
|
||||
case DML_INSERT:
|
||||
packagePtr = new InsertDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(), vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromMysqlBuffer(vpackage.get_ColNames(), vpackage.get_values(), vpackage.get_Columns(), vpackage.get_Rows(), vpackage.get_nullValues());
|
||||
break;
|
||||
|
||||
case DML_COMMAND:
|
||||
packagePtr = new CommandDMLPackage(vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
||||
break;
|
||||
|
||||
case DML_DELETE:
|
||||
packagePtr = new DeleteDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(),
|
||||
vpackage.get_DMLStatement(), vpackage.get_SessionID() );
|
||||
(void)packagePtr->buildFromMysqlBuffer(vpackage.get_ColNames(), vpackage.get_values(), vpackage.get_Columns(), vpackage.get_Rows(), vpackage.get_nullValues());
|
||||
break;
|
||||
|
||||
default:
|
||||
cerr << "makeCalpontDMLPackage: invalid statement type" << endl;
|
||||
break;
|
||||
@@ -197,6 +212,7 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromMysql
|
||||
{
|
||||
cerr << "makeCalpontDMLPackage: caught unknown exception!" << endl;
|
||||
}
|
||||
|
||||
return packagePtr;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,15 +59,18 @@ namespace dmlpackage
|
||||
for (;;)
|
||||
{
|
||||
string::size_type pos = value.find (' ', 0);
|
||||
|
||||
if (pos == 0)
|
||||
{
|
||||
value = value.substr (pos + 1, 10000);
|
||||
}
|
||||
else
|
||||
{ // no more whitespace
|
||||
{
|
||||
// no more whitespace
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@@ -98,57 +98,90 @@ namespace dmlpackage
|
||||
|
||||
/** @brief get the table object
|
||||
*/
|
||||
DMLTable* get_Table() { return fTable; }
|
||||
DMLTable* get_Table()
|
||||
{
|
||||
return fTable;
|
||||
}
|
||||
|
||||
/** @brief set the DML statement (the parsed statement)
|
||||
*
|
||||
* @param statement the dml statement to set
|
||||
*/
|
||||
void set_DMLStatement( const std::string& statement ) { fDMLStatement = statement; }
|
||||
void set_DMLStatement( const std::string& statement )
|
||||
{
|
||||
fDMLStatement = statement;
|
||||
}
|
||||
|
||||
/** @brief get the DML statement (the parsed statement)
|
||||
*/
|
||||
const std::string get_DMLStatement() const { return fDMLStatement; }
|
||||
const std::string get_DMLStatement() const
|
||||
{
|
||||
return fDMLStatement;
|
||||
}
|
||||
|
||||
/** @brief set the SQL statement (the original SQL statement)
|
||||
*
|
||||
* @param statement the SQL statement to set (the original SQL statement with quotes)
|
||||
*/
|
||||
void set_SQLStatement( const std::string& statement ) { fSQLStatement = statement; }
|
||||
void set_SQLStatement( const std::string& statement )
|
||||
{
|
||||
fSQLStatement = statement;
|
||||
}
|
||||
|
||||
/** @brief get the SQL statement (the original SQL statement)
|
||||
*/
|
||||
const std::string get_SQLStatement() const { return fSQLStatement; }
|
||||
const std::string get_SQLStatement() const
|
||||
{
|
||||
return fSQLStatement;
|
||||
}
|
||||
|
||||
/** @brief get the logging flag
|
||||
*/
|
||||
const bool get_Logging() const { return fLogging; }
|
||||
const bool get_Logging() const
|
||||
{
|
||||
return fLogging;
|
||||
}
|
||||
|
||||
/** @brief set the logging flag
|
||||
*
|
||||
* @param logging the logging flag to set
|
||||
*/
|
||||
void set_Logging( bool logging ) { fLogging = logging; }
|
||||
void set_Logging( bool logging )
|
||||
{
|
||||
fLogging = logging;
|
||||
}
|
||||
|
||||
/** @brief get the logending flag
|
||||
*/
|
||||
const bool get_Logending() const { return fLogending; }
|
||||
const bool get_Logending() const
|
||||
{
|
||||
return fLogending;
|
||||
}
|
||||
|
||||
/** @brief set the logending flag
|
||||
*
|
||||
* @param logending the logending flag to set
|
||||
*/
|
||||
void set_Logending( bool logending ) { fLogending = logending; }
|
||||
void set_Logending( bool logending )
|
||||
{
|
||||
fLogending = logending;
|
||||
}
|
||||
|
||||
/** @brief get the isFromCol flag
|
||||
*/
|
||||
const bool get_IsFromCol() const { return fIsFromCol; }
|
||||
const bool get_IsFromCol() const
|
||||
{
|
||||
return fIsFromCol;
|
||||
}
|
||||
|
||||
/** @brief set the update column from column flag
|
||||
*
|
||||
* @param logging the logging flag to set
|
||||
*/
|
||||
void set_IsFromCol ( bool isFromCol ) { fIsFromCol = isFromCol; }
|
||||
void set_IsFromCol ( bool isFromCol )
|
||||
{
|
||||
fIsFromCol = isFromCol;
|
||||
}
|
||||
/** @brief set the Table name
|
||||
*
|
||||
* @param tableName the name to set
|
||||
@@ -156,13 +189,17 @@ namespace dmlpackage
|
||||
void set_TableName( std::string& tableName )
|
||||
{
|
||||
fTableName = tableName;
|
||||
|
||||
if (fTable != 0)
|
||||
fTable->set_TableName(tableName);
|
||||
}
|
||||
|
||||
/** @brief get the Table name
|
||||
*/
|
||||
const std::string get_TableName() const { return fTableName; }
|
||||
const std::string get_TableName() const
|
||||
{
|
||||
return fTableName;
|
||||
}
|
||||
|
||||
/** @brief set the Schema name
|
||||
*
|
||||
@@ -171,45 +208,76 @@ namespace dmlpackage
|
||||
void set_SchemaName( std::string& schemaName )
|
||||
{
|
||||
fSchemaName = schemaName;
|
||||
|
||||
if (fTable != 0)
|
||||
fTable->set_SchemaName(schemaName);
|
||||
}
|
||||
|
||||
/** @brief get the Schema name
|
||||
*/
|
||||
const std::string get_SchemaName() const { return fSchemaName; }
|
||||
const std::string get_SchemaName() const
|
||||
{
|
||||
return fSchemaName;
|
||||
}
|
||||
|
||||
/** @brief does this dml statement have a filter
|
||||
*/
|
||||
bool HasFilter() const { return fHasFilter; }
|
||||
void HasFilter( bool hasFilter) { fHasFilter = hasFilter; }
|
||||
bool HasFilter() const
|
||||
{
|
||||
return fHasFilter;
|
||||
}
|
||||
void HasFilter( bool hasFilter)
|
||||
{
|
||||
fHasFilter = hasFilter;
|
||||
}
|
||||
|
||||
/** @brief get the filter statement
|
||||
*/
|
||||
const std::string get_QueryString() const { return fQueryString; }
|
||||
const std::string get_QueryString() const
|
||||
{
|
||||
return fQueryString;
|
||||
}
|
||||
|
||||
/** @brief set the sessionID associated with this package
|
||||
*/
|
||||
void set_SessionID( int sessionID ) { fSessionID = sessionID; }
|
||||
void set_SessionID( int sessionID )
|
||||
{
|
||||
fSessionID = sessionID;
|
||||
}
|
||||
|
||||
/** @brief get the sessionID associated with this package
|
||||
*/
|
||||
int get_SessionID() const { return fSessionID; }
|
||||
int get_SessionID() const
|
||||
{
|
||||
return fSessionID;
|
||||
}
|
||||
|
||||
/** @brief set the transaction ID associated with this package
|
||||
*/
|
||||
void set_TxnID( execplan::CalpontSystemCatalog::SCN txnID ) { fTxnId = txnID; }
|
||||
void set_TxnID( execplan::CalpontSystemCatalog::SCN txnID )
|
||||
{
|
||||
fTxnId = txnID;
|
||||
}
|
||||
|
||||
/** @brief get the transaction ID associated with this package
|
||||
*/
|
||||
execplan::CalpontSystemCatalog::SCN get_TxnID() const { return fTxnId; }
|
||||
execplan::CalpontSystemCatalog::SCN get_TxnID() const
|
||||
{
|
||||
return fTxnId;
|
||||
}
|
||||
/** @brief set the chunkmanager associated with this package
|
||||
*/
|
||||
void set_ChunkManager( WriteEngine::ChunkManager* cm ) { fCM = cm; }
|
||||
void set_ChunkManager( WriteEngine::ChunkManager* cm )
|
||||
{
|
||||
fCM = cm;
|
||||
}
|
||||
|
||||
/** @brief get the chunkmanager associated with this package
|
||||
*/
|
||||
WriteEngine::ChunkManager* get_ChunkManager() const { return fCM; }
|
||||
WriteEngine::ChunkManager* get_ChunkManager() const
|
||||
{
|
||||
return fCM;
|
||||
}
|
||||
|
||||
/** @brief get the ExecutionPlan associated with this package
|
||||
*/
|
||||
@@ -218,23 +286,59 @@ namespace dmlpackage
|
||||
return fPlan;
|
||||
}
|
||||
|
||||
bool get_isInsertSelect() { return fIsInsertSelect; }
|
||||
void set_isInsertSelect( const bool isInsertSelect ) { fIsInsertSelect = isInsertSelect; }
|
||||
bool get_isInsertSelect()
|
||||
{
|
||||
return fIsInsertSelect;
|
||||
}
|
||||
void set_isInsertSelect( const bool isInsertSelect )
|
||||
{
|
||||
fIsInsertSelect = isInsertSelect;
|
||||
}
|
||||
|
||||
bool get_isBatchInsert() { return fIsBatchInsert; }
|
||||
void set_isBatchInsert( const bool isBatchInsert ) { fIsBatchInsert = isBatchInsert; }
|
||||
bool get_isBatchInsert()
|
||||
{
|
||||
return fIsBatchInsert;
|
||||
}
|
||||
void set_isBatchInsert( const bool isBatchInsert )
|
||||
{
|
||||
fIsBatchInsert = isBatchInsert;
|
||||
}
|
||||
|
||||
bool get_isAutocommitOn() { return fIsAutocommitOn; }
|
||||
void set_isAutocommitOn( const bool isAutocommitOn ) { fIsAutocommitOn = isAutocommitOn; }
|
||||
bool get_isAutocommitOn()
|
||||
{
|
||||
return fIsAutocommitOn;
|
||||
}
|
||||
void set_isAutocommitOn( const bool isAutocommitOn )
|
||||
{
|
||||
fIsAutocommitOn = isAutocommitOn;
|
||||
}
|
||||
|
||||
bool get_isWarnToError() { return fIsWarnToError; }
|
||||
void set_isWarnToError( const bool isWarnToError ) { fIsWarnToError = isWarnToError; }
|
||||
bool get_isWarnToError()
|
||||
{
|
||||
return fIsWarnToError;
|
||||
}
|
||||
void set_isWarnToError( const bool isWarnToError )
|
||||
{
|
||||
fIsWarnToError = isWarnToError;
|
||||
}
|
||||
|
||||
uint32_t getTableOid() { return fTableOid; }
|
||||
void setTableOid( const uint32_t tableOid ) { fTableOid = tableOid; }
|
||||
uint32_t getTableOid()
|
||||
{
|
||||
return fTableOid;
|
||||
}
|
||||
void setTableOid( const uint32_t tableOid )
|
||||
{
|
||||
fTableOid = tableOid;
|
||||
}
|
||||
|
||||
void uuid(const boost::uuids::uuid& uuid) { fUuid = uuid; }
|
||||
const boost::uuids::uuid& uuid() const { return fUuid; }
|
||||
void uuid(const boost::uuids::uuid& uuid)
|
||||
{
|
||||
fUuid = uuid;
|
||||
}
|
||||
const boost::uuids::uuid& uuid() const
|
||||
{
|
||||
return fUuid;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -67,10 +67,12 @@ int DeleteDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||
bytestream << fDMLStatement;
|
||||
bytestream << fSQLStatement;
|
||||
bytestream << fSchemaName;
|
||||
|
||||
if (fTable != 0)
|
||||
{
|
||||
retval = fTable->write(bytestream);
|
||||
}
|
||||
|
||||
if (fHasFilter)
|
||||
{
|
||||
bytestream += *(fPlan.get());
|
||||
@@ -103,6 +105,7 @@ int DeleteDMLPackage::read(messageqcpp::ByteStream& bytestream)
|
||||
|
||||
fTable = new DMLTable();
|
||||
retval = fTable->read(bytestream);
|
||||
|
||||
if (fHasFilter)
|
||||
{
|
||||
fPlan.reset(new messageqcpp::ByteStream(bytestream));
|
||||
@@ -124,6 +127,7 @@ int DeleteDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
fHasFilter = true;
|
||||
fQueryString = deleteStmt.getQueryString();
|
||||
}
|
||||
|
||||
// else all rows are deleted
|
||||
|
||||
return retval;
|
||||
@@ -146,6 +150,7 @@ int DeleteDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||
boost::char_separator<char> sep(":");
|
||||
tokenizer tokens(buffer, sep);
|
||||
|
||||
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
||||
{
|
||||
dataList.push_back(StripLeadingWhitespace(*tok_iter));
|
||||
@@ -153,6 +158,7 @@ int DeleteDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
//get a new row
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,8 @@
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
enum yytokentype
|
||||
{
|
||||
NAME = 258,
|
||||
STRING = 259,
|
||||
INTNUM = 260,
|
||||
|
||||
@@ -305,7 +305,8 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
|
||||
#define YY_NUM_RULES 103
|
||||
#define YY_END_OF_BUFFER 104
|
||||
static yyconst short int yy_accept[394] =
|
||||
{ 0,
|
||||
{
|
||||
0,
|
||||
0, 0, 0, 0, 0, 0, 104, 103, 101, 100,
|
||||
97, 90, 90, 90, 90, 93, 103, 86, 84, 87,
|
||||
91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
|
||||
@@ -353,7 +354,8 @@ static yyconst short int yy_accept[394] =
|
||||
} ;
|
||||
|
||||
static yyconst int yy_ec[256] =
|
||||
{ 0,
|
||||
{
|
||||
0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
|
||||
1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
@@ -385,7 +387,8 @@ static yyconst int yy_ec[256] =
|
||||
} ;
|
||||
|
||||
static yyconst int yy_meta[42] =
|
||||
{ 0,
|
||||
{
|
||||
0,
|
||||
1, 1, 2, 1, 1, 1, 1, 1, 1, 3,
|
||||
1, 1, 1, 1, 3, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
@@ -394,7 +397,8 @@ static yyconst int yy_meta[42] =
|
||||
} ;
|
||||
|
||||
static yyconst short int yy_base[401] =
|
||||
{ 0,
|
||||
{
|
||||
0,
|
||||
0, 0, 425, 424, 423, 422, 426, 431, 40, 431,
|
||||
431, 431, 36, 39, 415, 41, 0, 39, 431, 411,
|
||||
28, 23, 43, 47, 20, 48, 39, 407, 51, 0,
|
||||
@@ -442,7 +446,8 @@ static yyconst short int yy_base[401] =
|
||||
} ;
|
||||
|
||||
static yyconst short int yy_def[401] =
|
||||
{ 0,
|
||||
{
|
||||
0,
|
||||
393, 1, 394, 394, 395, 395, 393, 393, 393, 393,
|
||||
393, 393, 393, 393, 393, 393, 396, 393, 393, 393,
|
||||
397, 397, 397, 397, 397, 397, 397, 397, 397, 397,
|
||||
@@ -490,7 +495,8 @@ static yyconst short int yy_def[401] =
|
||||
} ;
|
||||
|
||||
static yyconst short int yy_nxt[473] =
|
||||
{ 0,
|
||||
{
|
||||
0,
|
||||
8, 9, 10, 9, 11, 12, 13, 14, 15, 16,
|
||||
17, 18, 19, 20, 8, 21, 22, 23, 24, 25,
|
||||
26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
|
||||
@@ -546,7 +552,8 @@ static yyconst short int yy_nxt[473] =
|
||||
} ;
|
||||
|
||||
static yyconst short int yy_chk[473] =
|
||||
{ 0,
|
||||
{
|
||||
0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
@@ -644,7 +651,8 @@ using namespace dmlpackage;
|
||||
|
||||
void dmlerror(char const* s);
|
||||
|
||||
namespace dmlpackage {
|
||||
namespace dmlpackage
|
||||
{
|
||||
int lineno = 1;
|
||||
|
||||
|
||||
@@ -855,20 +863,25 @@ YY_DECL
|
||||
|
||||
yy_current_state = yy_start;
|
||||
yy_match:
|
||||
|
||||
do
|
||||
{
|
||||
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
|
||||
|
||||
if ( yy_accept[yy_current_state] )
|
||||
{
|
||||
yy_last_accepting_state = yy_current_state;
|
||||
yy_last_accepting_cpos = yy_cp;
|
||||
}
|
||||
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
|
||||
if ( yy_current_state >= 394 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
++yy_cp;
|
||||
}
|
||||
@@ -876,8 +889,10 @@ yy_match:
|
||||
|
||||
yy_find_action:
|
||||
yy_act = yy_accept[yy_current_state];
|
||||
|
||||
if ( yy_act == 0 )
|
||||
{ /* have to back up */
|
||||
{
|
||||
/* have to back up */
|
||||
yy_cp = yy_last_accepting_cpos;
|
||||
yy_current_state = yy_last_accepting_state;
|
||||
yy_act = yy_accept[yy_current_state];
|
||||
@@ -890,7 +905,8 @@ do_action: /* This label is used only to access EOF actions. */
|
||||
|
||||
|
||||
switch ( yy_act )
|
||||
{ /* beginning of action switch */
|
||||
{
|
||||
/* beginning of action switch */
|
||||
case 0: /* must back up */
|
||||
/* undo the effects of YY_DO_BEFORE_ACTION */
|
||||
*yy_cp = yy_hold_char;
|
||||
@@ -1230,6 +1246,7 @@ case 83:
|
||||
YY_RULE_SETUP
|
||||
TOK(WORK)
|
||||
YY_BREAK
|
||||
|
||||
/* punctuation */
|
||||
case 84:
|
||||
case 85:
|
||||
@@ -1244,11 +1261,13 @@ case 90:
|
||||
YY_RULE_SETUP
|
||||
{ TOK(yytext[0]) }
|
||||
YY_BREAK
|
||||
|
||||
/* names */
|
||||
case 91:
|
||||
YY_RULE_SETUP
|
||||
{ TOK(NAME) }
|
||||
YY_BREAK
|
||||
|
||||
/* parameters */
|
||||
case 92:
|
||||
YY_RULE_SETUP
|
||||
@@ -1256,6 +1275,7 @@ YY_RULE_SETUP
|
||||
return PARAMETER;
|
||||
}
|
||||
YY_BREAK
|
||||
|
||||
/* numbers */
|
||||
case 93:
|
||||
case 94:
|
||||
@@ -1263,14 +1283,17 @@ case 95:
|
||||
YY_RULE_SETUP
|
||||
{ TOK(INTNUM) }
|
||||
YY_BREAK
|
||||
|
||||
case 96:
|
||||
YY_RULE_SETUP
|
||||
{ TOK(APPROXNUM) }
|
||||
YY_BREAK
|
||||
|
||||
case 97:
|
||||
YY_RULE_SETUP
|
||||
{BEGIN(inquote);}
|
||||
YY_BREAK
|
||||
|
||||
case 98:
|
||||
*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
|
||||
yy_c_buf_p = yy_cp -= 1;
|
||||
@@ -1278,28 +1301,34 @@ YY_DO_BEFORE_ACTION; /* set up yytext again */
|
||||
YY_RULE_SETUP
|
||||
{BEGIN(endquote); TOK(STRING) }
|
||||
YY_BREAK
|
||||
|
||||
case 99:
|
||||
YY_RULE_SETUP
|
||||
{BEGIN(0);}
|
||||
YY_BREAK
|
||||
|
||||
/* @bug 1870. Since MySQL parser will error out all the unterminated string, we don't actually need it here. */
|
||||
/* '[^'\n]*$ { dmlerror("Unterminated string"); } */
|
||||
case 100:
|
||||
YY_RULE_SETUP
|
||||
{ lineno++;}
|
||||
YY_BREAK
|
||||
|
||||
case 101:
|
||||
YY_RULE_SETUP
|
||||
; /* white space */
|
||||
YY_BREAK
|
||||
|
||||
case 102:
|
||||
YY_RULE_SETUP
|
||||
; /* comment */
|
||||
YY_BREAK
|
||||
|
||||
case 103:
|
||||
YY_RULE_SETUP
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
case YY_STATE_EOF(inquote):
|
||||
case YY_STATE_EOF(endquote):
|
||||
@@ -1338,7 +1367,8 @@ case YY_STATE_EOF(endquote):
|
||||
* in input().
|
||||
*/
|
||||
if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
|
||||
{ /* This was really a NUL. */
|
||||
{
|
||||
/* This was really a NUL. */
|
||||
yy_state_type yy_next_state;
|
||||
|
||||
yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
|
||||
@@ -1401,6 +1431,7 @@ case YY_STATE_EOF(endquote):
|
||||
if ( ! yy_did_buffer_switch_on_eof )
|
||||
YY_NEW_FILE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1424,6 +1455,7 @@ case YY_STATE_EOF(endquote):
|
||||
yy_bp = yytext_ptr + YY_MORE_ADJ;
|
||||
goto yy_find_action;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1455,7 +1487,8 @@ static int yy_get_next_buffer()
|
||||
"fatal flex scanner internal error--end of buffer missed" );
|
||||
|
||||
if ( yy_current_buffer->yy_fill_buffer == 0 )
|
||||
{ /* Don't try to fill the buffer, so this is an EOF. */
|
||||
{
|
||||
/* Don't try to fill the buffer, so this is an EOF. */
|
||||
if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
|
||||
{
|
||||
/* We matched a single character, the EOB, so
|
||||
@@ -1493,7 +1526,8 @@ static int yy_get_next_buffer()
|
||||
yy_current_buffer->yy_buf_size - number_to_move - 1;
|
||||
|
||||
while ( num_to_read <= 0 )
|
||||
{ /* Not enough room in the buffer - grow it. */
|
||||
{
|
||||
/* Not enough room in the buffer - grow it. */
|
||||
#ifdef YY_USES_REJECT
|
||||
YY_FATAL_ERROR(
|
||||
"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
|
||||
@@ -1585,17 +1619,21 @@ static yy_state_type yy_get_previous_state()
|
||||
for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
|
||||
{
|
||||
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
|
||||
|
||||
if ( yy_accept[yy_current_state] )
|
||||
{
|
||||
yy_last_accepting_state = yy_current_state;
|
||||
yy_last_accepting_cpos = yy_cp;
|
||||
}
|
||||
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
|
||||
if ( yy_current_state >= 394 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
}
|
||||
|
||||
@@ -1620,17 +1658,21 @@ yy_state_type yy_current_state;
|
||||
register char* yy_cp = yy_c_buf_p;
|
||||
|
||||
register YY_CHAR yy_c = 1;
|
||||
|
||||
if ( yy_accept[yy_current_state] )
|
||||
{
|
||||
yy_last_accepting_state = yy_current_state;
|
||||
yy_last_accepting_cpos = yy_cp;
|
||||
}
|
||||
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
|
||||
if ( yy_current_state >= 394 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_is_jam = (yy_current_state == 393);
|
||||
|
||||
@@ -1653,7 +1695,8 @@ register char *yy_bp;
|
||||
*yy_cp = yy_hold_char;
|
||||
|
||||
if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
|
||||
{ /* need to shift things up to make room */
|
||||
{
|
||||
/* need to shift things up to make room */
|
||||
/* +2 for EOB chars. */
|
||||
register int number_to_move = yy_n_chars + 2;
|
||||
register char* dest = &yy_current_buffer->yy_ch_buf[
|
||||
@@ -1704,7 +1747,8 @@ static int input()
|
||||
*yy_c_buf_p = '\0';
|
||||
|
||||
else
|
||||
{ /* need more input */
|
||||
{
|
||||
/* need more input */
|
||||
int offset = yy_c_buf_p - yytext_ptr;
|
||||
++yy_c_buf_p;
|
||||
|
||||
@@ -1733,6 +1777,7 @@ static int input()
|
||||
|
||||
if ( ! yy_did_buffer_switch_on_eof )
|
||||
YY_NEW_FILE;
|
||||
|
||||
#ifdef __cplusplus
|
||||
return yyinput();
|
||||
#else
|
||||
@@ -1825,6 +1870,7 @@ int size;
|
||||
YY_BUFFER_STATE b;
|
||||
|
||||
b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
|
||||
|
||||
if ( ! b )
|
||||
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
|
||||
|
||||
@@ -1834,6 +1880,7 @@ int size;
|
||||
* we need to put in 2 end-of-buffer characters.
|
||||
*/
|
||||
b->yy_ch_buf = (char*) yy_flex_alloc( b->yy_buf_size + 2 );
|
||||
|
||||
if ( ! b->yy_ch_buf )
|
||||
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
|
||||
|
||||
@@ -1946,6 +1993,7 @@ yy_size_t size;
|
||||
return 0;
|
||||
|
||||
b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
|
||||
|
||||
if ( ! b )
|
||||
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
|
||||
|
||||
@@ -1975,6 +2023,7 @@ yyconst char *yy_str;
|
||||
#endif
|
||||
{
|
||||
int len;
|
||||
|
||||
for ( len = 0; yy_str[len]; ++len )
|
||||
;
|
||||
|
||||
@@ -2000,6 +2049,7 @@ int len;
|
||||
/* Get memory for full buffer, including space for trailing EOB's. */
|
||||
n = len + 2;
|
||||
buf = (char*) yy_flex_alloc( n );
|
||||
|
||||
if ( ! buf )
|
||||
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
|
||||
|
||||
@@ -2009,6 +2059,7 @@ int len;
|
||||
buf[len] = buf[len + 1] = YY_END_OF_BUFFER_CHAR;
|
||||
|
||||
b = yy_scan_buffer( buf, n );
|
||||
|
||||
if ( ! b )
|
||||
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
|
||||
|
||||
@@ -2120,6 +2171,7 @@ int n;
|
||||
#endif
|
||||
{
|
||||
register int i;
|
||||
|
||||
for ( i = 0; i < n; ++i )
|
||||
s1[i] = s2[i];
|
||||
}
|
||||
@@ -2134,6 +2186,7 @@ yyconst char *s;
|
||||
#endif
|
||||
{
|
||||
register int n;
|
||||
|
||||
for ( n = 0; s[n]; ++n )
|
||||
;
|
||||
|
||||
@@ -2195,7 +2248,8 @@ void dmlerror(char const *s)
|
||||
printf("yyerror: %d: %s at %s\n", lineno, s, yytext);
|
||||
}
|
||||
|
||||
namespace dmlpackage {
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
static valbuf_t valbuf;
|
||||
|
||||
@@ -2244,21 +2298,28 @@ void scanner_finish(void)
|
||||
yy_delete_buffer(scanbufhandle);
|
||||
free(scanbuf);
|
||||
unsigned int i;
|
||||
for(i=0; i<valbuf.size(); i++) {
|
||||
|
||||
for (i = 0; i < valbuf.size(); i++)
|
||||
{
|
||||
str = valbuf[i];
|
||||
if(str) {
|
||||
|
||||
if (str)
|
||||
{
|
||||
//std::cout << "valbuf:(" << str << ")" << std::endl;
|
||||
free(valbuf[i]);
|
||||
}
|
||||
}
|
||||
|
||||
valbuf.clear();
|
||||
}
|
||||
|
||||
char* scanner_copy (char* str)
|
||||
{
|
||||
char* nv = strdup(str);
|
||||
|
||||
if (nv)
|
||||
valbuf.push_back(nv);
|
||||
|
||||
return nv;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,10 +40,12 @@ DMLColumn::DMLColumn(std::string name, std::string value, bool isFromCol, uint32
|
||||
{
|
||||
fName = name;
|
||||
fData = value;
|
||||
|
||||
if (( strcasecmp(value.c_str(), "NULL") == 0) || (value.length() == 0) )
|
||||
{
|
||||
isNULL = true;
|
||||
}
|
||||
|
||||
fisNULL = isNULL;
|
||||
fIsFromCol = isFromCol;
|
||||
fFuncScale = funcScale;
|
||||
@@ -69,6 +71,7 @@ int DMLColumn::read(messageqcpp::ByteStream& bytestream)
|
||||
bytestream >> reinterpret_cast<messageqcpp::ByteStream::byte&>(fisNULL);
|
||||
uint32_t vectorSize;
|
||||
bytestream >> vectorSize;
|
||||
|
||||
if (vectorSize > 0 )
|
||||
{
|
||||
for ( uint32_t i = 0; i < vectorSize; i++ )
|
||||
@@ -87,6 +90,7 @@ int DMLColumn::read(messageqcpp::ByteStream& bytestream)
|
||||
|
||||
if ( (fColValuesList.size() < 1) && (fColValuesList.size() > 0) ) //deprecated.
|
||||
fData = fColValuesList[0] ; //deprecated.
|
||||
|
||||
//bytestream >> reinterpret_cast<messageqcpp::ByteStream::byte&>(fisNULL);
|
||||
bytestream >> reinterpret_cast<messageqcpp::ByteStream::byte&>(fIsFromCol);
|
||||
bytestream >> (uint32_t&) fFuncScale;
|
||||
@@ -100,6 +104,7 @@ int DMLColumn::write(messageqcpp::ByteStream& bytestream)
|
||||
bytestream << static_cast<uint8_t>(fisNULL);
|
||||
uint32_t vectorSize = fColValuesList.size();
|
||||
bytestream << vectorSize;
|
||||
|
||||
if (vectorSize > 0 )
|
||||
{
|
||||
for ( uint32_t i = 0; i < vectorSize; i++ )
|
||||
@@ -110,6 +115,7 @@ int DMLColumn::write(messageqcpp::ByteStream& bytestream)
|
||||
}
|
||||
else
|
||||
bytestream << fData; //deprecated.
|
||||
|
||||
//bytestream << static_cast<uint8_t>(fisNULL);
|
||||
bytestream << static_cast<uint8_t>(fIsFromCol);
|
||||
bytestream << (uint32_t)fFuncScale;
|
||||
|
||||
@@ -77,45 +77,75 @@ public:
|
||||
|
||||
/** @brief get the data for the column
|
||||
*/
|
||||
const std::string get_Data() const { return fData; }
|
||||
const std::string get_Data() const
|
||||
{
|
||||
return fData;
|
||||
}
|
||||
|
||||
|
||||
const std::vector<std::string>& get_DataVector() const { return fColValuesList; }
|
||||
const std::vector<std::string>& get_DataVector() const
|
||||
{
|
||||
return fColValuesList;
|
||||
}
|
||||
|
||||
/** @brief get the data for the column
|
||||
*/
|
||||
const bool get_isnull() const { return fisNULL; }
|
||||
const bool get_isnull() const
|
||||
{
|
||||
return fisNULL;
|
||||
}
|
||||
/** @brief get the fIsFromCol data for the column
|
||||
*/
|
||||
const bool get_isFromCol() const { return fIsFromCol; }
|
||||
const bool get_isFromCol() const
|
||||
{
|
||||
return fIsFromCol;
|
||||
}
|
||||
/** @brief get the fFuncScale data for the column
|
||||
*/
|
||||
const uint32_t get_funcScale() const { return fFuncScale; }
|
||||
const uint32_t get_funcScale() const
|
||||
{
|
||||
return fFuncScale;
|
||||
}
|
||||
/** @brief get the column name
|
||||
*/
|
||||
const std::string get_Name() const { return fName; }
|
||||
const std::string get_Name() const
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
/** @brief set the column name
|
||||
*/
|
||||
EXPORT void set_Name( std::string name)
|
||||
{ boost::algorithm::to_lower(name);
|
||||
fName = name; }
|
||||
{
|
||||
boost::algorithm::to_lower(name);
|
||||
fName = name;
|
||||
}
|
||||
/** @brief set the NULL flag
|
||||
*/
|
||||
void set_isnull( bool isNULL)
|
||||
{ fisNULL = isNULL; }
|
||||
{
|
||||
fisNULL = isNULL;
|
||||
}
|
||||
/** @brief set the fIsFromCol flag
|
||||
*/
|
||||
void set_isFromCol( bool isFromCol)
|
||||
{ fIsFromCol = isFromCol; }
|
||||
{
|
||||
fIsFromCol = isFromCol;
|
||||
}
|
||||
/** @brief set the fFuncScale
|
||||
*/
|
||||
void set_funcScale( uint32_t funcScale)
|
||||
{ fFuncScale = funcScale; }
|
||||
{
|
||||
fFuncScale = funcScale;
|
||||
}
|
||||
void set_Data ( std::string data)
|
||||
{ fData = data; }
|
||||
{
|
||||
fData = data;
|
||||
}
|
||||
|
||||
void set_DataVector ( std::vector<std::string>& dataVec)
|
||||
{ fColValuesList = dataVec; }
|
||||
{
|
||||
fColValuesList = dataVec;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
|
||||
#include "dmlobject.h"
|
||||
|
||||
namespace dmlpackage {
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
DMLObject::DMLObject()
|
||||
{
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace dmlpackage
|
||||
scanner_init(dmltext, scanner);
|
||||
grammar_init(&fParseTree, fDebug);
|
||||
fStatus = dmlparse(scanner);
|
||||
|
||||
if (fStatus == 0)
|
||||
{
|
||||
char* str;
|
||||
@@ -83,14 +84,17 @@ namespace dmlpackage
|
||||
for (unsigned int i = 0; i < valueBuffer.size(); i++)
|
||||
{
|
||||
str = valueBuffer[i];
|
||||
|
||||
if (str)
|
||||
{
|
||||
if (i > 0)
|
||||
fParseTree.fSqlText += " ";
|
||||
|
||||
fParseTree.fSqlText += str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free_copybuffer();
|
||||
return fStatus;
|
||||
}
|
||||
@@ -101,6 +105,7 @@ namespace dmlpackage
|
||||
{
|
||||
throw logic_error("The ParseTree is invalid");
|
||||
}
|
||||
|
||||
return fParseTree;
|
||||
|
||||
}
|
||||
@@ -125,16 +130,19 @@ namespace dmlpackage
|
||||
|
||||
ifstream ifdml;
|
||||
ifdml.open(fileName.c_str());
|
||||
|
||||
if (!ifdml.is_open())
|
||||
{
|
||||
perror(fileName.c_str());
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
char dmlbuf[1024 * 1024];
|
||||
unsigned length;
|
||||
ifdml.seekg(0, ios::end);
|
||||
length = ifdml.tellg();
|
||||
ifdml.seekg(0, ios::beg);
|
||||
|
||||
if (length > sizeof(dmlbuf) - 1)
|
||||
{
|
||||
throw length_error("DMLFileParser has file size hard limit of 16K.");
|
||||
@@ -142,6 +150,7 @@ namespace dmlpackage
|
||||
|
||||
unsigned rcount;
|
||||
rcount = ifdml.readsome(dmlbuf, sizeof(dmlbuf) - 1);
|
||||
|
||||
if (rcount < 0)
|
||||
return fStatus;
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace dmlpackage
|
||||
SqlStatement& stmt = **itr;
|
||||
os << stmt;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -48,6 +49,7 @@ namespace dmlpackage
|
||||
SqlStatementList::~SqlStatementList()
|
||||
{
|
||||
vector<SqlStatement*>::iterator itr;
|
||||
|
||||
for (itr = fList.begin(); itr != fList.end(); ++itr)
|
||||
{
|
||||
delete *itr;
|
||||
@@ -132,6 +134,7 @@ namespace dmlpackage
|
||||
}
|
||||
|
||||
ColumnNameList::const_iterator itr;
|
||||
|
||||
for (itr = fColumnList.begin(); itr != fColumnList.end(); ++itr)
|
||||
{
|
||||
os << *itr << endl;
|
||||
@@ -142,6 +145,7 @@ namespace dmlpackage
|
||||
fValuesOrQueryPtr->put(os);
|
||||
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -178,14 +182,17 @@ namespace dmlpackage
|
||||
if (0 != fColAssignmentListPtr)
|
||||
{
|
||||
ColumnAssignmentList::iterator iter = fColAssignmentListPtr->begin();
|
||||
|
||||
while (iter != fColAssignmentListPtr->end())
|
||||
{
|
||||
delete *iter;
|
||||
++iter;
|
||||
}
|
||||
|
||||
fColAssignmentListPtr->clear();
|
||||
delete fColAssignmentListPtr;
|
||||
}
|
||||
|
||||
if (0 != fWhereClausePtr)
|
||||
{
|
||||
delete fWhereClausePtr;
|
||||
@@ -195,14 +202,17 @@ namespace dmlpackage
|
||||
ostream& UpdateSqlStatement::put(ostream& os) const
|
||||
{
|
||||
os << "Update " << endl;
|
||||
|
||||
if (0 != fNamePtr)
|
||||
{
|
||||
fNamePtr->put(os);
|
||||
}
|
||||
|
||||
if (0 != fColAssignmentListPtr)
|
||||
{
|
||||
os << "SET " << endl;
|
||||
ColumnAssignmentList::const_iterator iter = fColAssignmentListPtr->begin();
|
||||
|
||||
while (iter != fColAssignmentListPtr->end())
|
||||
{
|
||||
ColumnAssignment* cola = *iter;
|
||||
@@ -210,10 +220,12 @@ namespace dmlpackage
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != fWhereClausePtr)
|
||||
{
|
||||
fWhereClausePtr->put(os);
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -225,16 +237,19 @@ namespace dmlpackage
|
||||
{
|
||||
query_string += "SET ";
|
||||
ColumnAssignmentList::const_iterator iter = fColAssignmentListPtr->begin();
|
||||
|
||||
while (iter != fColAssignmentListPtr->end())
|
||||
{
|
||||
ColumnAssignment* cola = *iter;
|
||||
query_string += cola->getColumnAssignmentString();
|
||||
|
||||
++iter;
|
||||
|
||||
if (iter != fColAssignmentListPtr->end())
|
||||
query_string += ",";
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != fWhereClausePtr)
|
||||
{
|
||||
query_string += " ";
|
||||
@@ -276,10 +291,12 @@ namespace dmlpackage
|
||||
{
|
||||
fNamePtr->put(os);
|
||||
}
|
||||
|
||||
if (0 != fWhereClausePtr)
|
||||
{
|
||||
fWhereClausePtr->put(os);
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -338,6 +355,7 @@ namespace dmlpackage
|
||||
{
|
||||
if (fSchema != "")
|
||||
os << fSchema << ".";
|
||||
|
||||
os << fName << endl;
|
||||
return os;
|
||||
}
|
||||
@@ -391,6 +409,7 @@ namespace dmlpackage
|
||||
ostream& ValuesOrQuery::put(ostream& os) const
|
||||
{
|
||||
ValuesList::const_iterator iter = fValuesList.begin();
|
||||
|
||||
while ( iter != fValuesList.end() )
|
||||
{
|
||||
os << *iter << endl;
|
||||
@@ -441,6 +460,7 @@ namespace dmlpackage
|
||||
{
|
||||
if (0 != fSelectFilterPtr)
|
||||
delete fSelectFilterPtr;
|
||||
|
||||
if (0 != fTableExpressionPtr)
|
||||
delete fTableExpressionPtr;
|
||||
}
|
||||
@@ -451,6 +471,7 @@ namespace dmlpackage
|
||||
{
|
||||
fSelectFilterPtr->put(os);
|
||||
}
|
||||
|
||||
if (0 != fTableExpressionPtr)
|
||||
{
|
||||
fTableExpressionPtr->put(os);
|
||||
@@ -467,15 +488,18 @@ namespace dmlpackage
|
||||
string QuerySpec::getQueryString() const
|
||||
{
|
||||
std::string query_string;
|
||||
|
||||
if (0 != fSelectFilterPtr)
|
||||
{
|
||||
query_string += fSelectFilterPtr->getSelectString();
|
||||
}
|
||||
|
||||
if (0 != fTableExpressionPtr)
|
||||
{
|
||||
query_string += " ";
|
||||
query_string += fTableExpressionPtr->getTableExpressionString();
|
||||
}
|
||||
|
||||
if (fOptionAllOrDistinct != "")
|
||||
{
|
||||
query_string += " ";
|
||||
@@ -508,13 +532,16 @@ namespace dmlpackage
|
||||
{
|
||||
os << "SELECT" << endl;
|
||||
ColumnNameList::const_iterator iter = fColumnList.begin();
|
||||
|
||||
while ( iter != fColumnList.end() )
|
||||
{
|
||||
os << *iter << endl;
|
||||
++iter;
|
||||
}
|
||||
|
||||
if (0 == fColumnList.size())
|
||||
os << "*" << endl;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -522,13 +549,16 @@ namespace dmlpackage
|
||||
{
|
||||
std::string select_filter = "SELECT ";
|
||||
ColumnNameList::const_iterator iter = fColumnList.begin();
|
||||
|
||||
while ( iter != fColumnList.end() )
|
||||
{
|
||||
select_filter += *iter;
|
||||
++iter;
|
||||
|
||||
if (iter != fColumnList.end())
|
||||
select_filter += ",";
|
||||
}
|
||||
|
||||
if (0 == fColumnList.size())
|
||||
select_filter += "*";
|
||||
|
||||
@@ -556,10 +586,13 @@ namespace dmlpackage
|
||||
{
|
||||
if (0 != fFromClausePtr)
|
||||
delete fFromClausePtr;
|
||||
|
||||
if (0 != fWhereClausePtr)
|
||||
delete fWhereClausePtr;
|
||||
|
||||
if (0 != fGroupByPtr)
|
||||
delete fGroupByPtr;
|
||||
|
||||
if (0 != fHavingPtr)
|
||||
delete fHavingPtr;
|
||||
|
||||
@@ -571,14 +604,17 @@ namespace dmlpackage
|
||||
{
|
||||
fFromClausePtr->put(os);
|
||||
}
|
||||
|
||||
if (0 != fWhereClausePtr)
|
||||
{
|
||||
fWhereClausePtr->put(os);
|
||||
}
|
||||
|
||||
if (0 != fGroupByPtr)
|
||||
{
|
||||
fGroupByPtr->put(os);
|
||||
}
|
||||
|
||||
if (0 != fHavingPtr)
|
||||
{
|
||||
fHavingPtr->put(os);
|
||||
@@ -590,20 +626,24 @@ namespace dmlpackage
|
||||
string TableExpression::getTableExpressionString() const
|
||||
{
|
||||
std::string table_expression;
|
||||
|
||||
if (0 != fFromClausePtr)
|
||||
{
|
||||
table_expression += fFromClausePtr->getFromClauseString();
|
||||
}
|
||||
|
||||
if (0 != fWhereClausePtr)
|
||||
{
|
||||
table_expression += " ";
|
||||
table_expression += fWhereClausePtr->getWhereClauseString();
|
||||
}
|
||||
|
||||
if (0 != fGroupByPtr)
|
||||
{
|
||||
table_expression += " ";
|
||||
table_expression += fGroupByPtr->getGroupByClauseString();
|
||||
}
|
||||
|
||||
if (0 != fHavingPtr)
|
||||
{
|
||||
table_expression += " ";
|
||||
@@ -630,12 +670,14 @@ namespace dmlpackage
|
||||
if (0 != fTableListPtr)
|
||||
{
|
||||
TableNameList::iterator iter = fTableListPtr->begin();
|
||||
|
||||
while ( iter != fTableListPtr->end() )
|
||||
{
|
||||
TableName* tableNamePtr = *iter;
|
||||
delete tableNamePtr;
|
||||
++iter;
|
||||
}
|
||||
|
||||
fTableListPtr->clear();
|
||||
delete fTableListPtr;
|
||||
}
|
||||
@@ -648,6 +690,7 @@ namespace dmlpackage
|
||||
if (0 != fTableListPtr)
|
||||
{
|
||||
TableNameList::const_iterator iter = fTableListPtr->begin();
|
||||
|
||||
while ( iter != fTableListPtr->end() )
|
||||
{
|
||||
TableName* tableNamePtr = *iter;
|
||||
@@ -655,30 +698,37 @@ namespace dmlpackage
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
string FromClause::getFromClauseString() const
|
||||
{
|
||||
std::string from_clause = "FROM ";
|
||||
|
||||
if (0 != fTableListPtr)
|
||||
{
|
||||
TableNameList::const_iterator iter = fTableListPtr->begin();
|
||||
|
||||
while (iter != fTableListPtr->end())
|
||||
{
|
||||
TableName* tableNamePtr = *iter;
|
||||
|
||||
if (tableNamePtr->fSchema != "")
|
||||
{
|
||||
from_clause += tableNamePtr->fSchema;
|
||||
from_clause += ".";
|
||||
}
|
||||
|
||||
from_clause += tableNamePtr->fName;
|
||||
|
||||
++iter;
|
||||
|
||||
if (iter != fTableListPtr->end())
|
||||
from_clause += ",";
|
||||
}
|
||||
}
|
||||
|
||||
return from_clause;
|
||||
}
|
||||
|
||||
@@ -701,6 +751,7 @@ namespace dmlpackage
|
||||
ostream& WhereClause::put(ostream& os) const
|
||||
{
|
||||
os << "WHERE" << endl;
|
||||
|
||||
if (0 != fSearchConditionPtr)
|
||||
{
|
||||
fSearchConditionPtr->put(os);
|
||||
@@ -712,11 +763,13 @@ namespace dmlpackage
|
||||
string WhereClause::getWhereClauseString() const
|
||||
{
|
||||
std::string where_clause = "WHERE";
|
||||
|
||||
if (0 != fSearchConditionPtr)
|
||||
{
|
||||
where_clause += " ";
|
||||
where_clause += fSearchConditionPtr->getSearchConditionString();
|
||||
}
|
||||
|
||||
return where_clause;
|
||||
}
|
||||
|
||||
@@ -738,16 +791,19 @@ namespace dmlpackage
|
||||
ostream& HavingClause::put(ostream& os) const
|
||||
{
|
||||
os << "HAVING" << endl;
|
||||
|
||||
if (0 != fSearchConditionPtr)
|
||||
{
|
||||
fSearchConditionPtr->put(os);
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
string HavingClause::getHavingClauseString() const
|
||||
{
|
||||
std::string having_clause = "HAVING";
|
||||
|
||||
if (0 != fSearchConditionPtr)
|
||||
{
|
||||
having_clause += " ";
|
||||
@@ -776,28 +832,34 @@ namespace dmlpackage
|
||||
ostream& GroupByClause::put(ostream& os) const
|
||||
{
|
||||
os << "GROUP BY" << endl;
|
||||
|
||||
if (0 != fColumnNamesListPtr)
|
||||
{
|
||||
ColumnNameList::const_iterator iter = fColumnNamesListPtr->begin();
|
||||
|
||||
if (iter != fColumnNamesListPtr->end())
|
||||
{
|
||||
os << *iter << endl;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
string GroupByClause::getGroupByClauseString() const
|
||||
{
|
||||
std::string group_by_clause = "GROUP BY ";
|
||||
|
||||
if (0 != fColumnNamesListPtr)
|
||||
{
|
||||
ColumnNameList::const_iterator iter = fColumnNamesListPtr->begin();
|
||||
|
||||
if (iter != fColumnNamesListPtr->end())
|
||||
{
|
||||
group_by_clause += *iter;
|
||||
++iter;
|
||||
|
||||
if (iter != fColumnNamesListPtr->end())
|
||||
group_by_clause += ",";
|
||||
}
|
||||
@@ -830,10 +892,12 @@ namespace dmlpackage
|
||||
{
|
||||
delete fPredicatePtr;
|
||||
}
|
||||
|
||||
if (0 != fLHSearchConditionPtr)
|
||||
{
|
||||
delete fLHSearchConditionPtr;
|
||||
}
|
||||
|
||||
if (0 != fRHSearchConditionPtr)
|
||||
{
|
||||
delete fRHSearchConditionPtr;
|
||||
@@ -852,6 +916,7 @@ namespace dmlpackage
|
||||
{
|
||||
fLHSearchConditionPtr->put(os);
|
||||
}
|
||||
|
||||
if (0 != fRHSearchConditionPtr)
|
||||
{
|
||||
os << fOperator << endl;
|
||||
@@ -864,15 +929,18 @@ namespace dmlpackage
|
||||
string SearchCondition::getSearchConditionString() const
|
||||
{
|
||||
std::string search_condition;
|
||||
|
||||
if (0 != fPredicatePtr)
|
||||
{
|
||||
search_condition += fPredicatePtr->getPredicateString();
|
||||
}
|
||||
|
||||
if (0 != fLHSearchConditionPtr)
|
||||
{
|
||||
search_condition += fLHSearchConditionPtr->getSearchConditionString();
|
||||
search_condition += " ";
|
||||
}
|
||||
|
||||
if (0 != fRHSearchConditionPtr)
|
||||
{
|
||||
search_condition += fOperator;
|
||||
@@ -906,6 +974,7 @@ namespace dmlpackage
|
||||
{
|
||||
fSubQuerySpecPtr->put(os);
|
||||
}
|
||||
|
||||
//cout << ")" << endl;
|
||||
return os;
|
||||
}
|
||||
@@ -914,11 +983,13 @@ namespace dmlpackage
|
||||
{
|
||||
std::string exists_predicate = "EXISTS";
|
||||
exists_predicate += "(";
|
||||
|
||||
if (0 != fSubQuerySpecPtr)
|
||||
{
|
||||
exists_predicate += " ";
|
||||
exists_predicate += fSubQuerySpecPtr->getQueryString();
|
||||
}
|
||||
|
||||
exists_predicate += ")";
|
||||
return exists_predicate;
|
||||
}
|
||||
@@ -949,6 +1020,7 @@ namespace dmlpackage
|
||||
{
|
||||
fSubQuerySpecPtr->put(os);
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -991,6 +1063,7 @@ namespace dmlpackage
|
||||
|
||||
os << "(" << endl;
|
||||
AtomList::const_iterator iter = fAtomList.begin();
|
||||
|
||||
while (iter != fAtomList.end())
|
||||
{
|
||||
os << *iter << endl;
|
||||
@@ -1016,13 +1089,16 @@ namespace dmlpackage
|
||||
in_predicate += "(";
|
||||
|
||||
AtomList::const_iterator iter = fAtomList.begin();
|
||||
|
||||
while (iter != fAtomList.end())
|
||||
{
|
||||
in_predicate += *iter;
|
||||
++iter;
|
||||
|
||||
if (iter != fAtomList.end())
|
||||
in_predicate += ",";
|
||||
}
|
||||
|
||||
if (0 != fSubQuerySpecPtr)
|
||||
{
|
||||
in_predicate += fSubQuerySpecPtr->getQueryString();
|
||||
|
||||
@@ -233,7 +233,10 @@ public:
|
||||
|
||||
/** @brief get the statement type - DML_INSERT
|
||||
*/
|
||||
inline virtual int getStatementType() const { return DML_INSERT; }
|
||||
inline virtual int getStatementType() const
|
||||
{
|
||||
return DML_INSERT;
|
||||
}
|
||||
|
||||
ValuesOrQuery* fValuesOrQueryPtr;
|
||||
ColumnNameList fColumnList;
|
||||
@@ -277,7 +280,10 @@ public:
|
||||
|
||||
/** @brief get the statement type - DML_UPDATE
|
||||
*/
|
||||
inline virtual int getStatementType() const { return DML_UPDATE; }
|
||||
inline virtual int getStatementType() const
|
||||
{
|
||||
return DML_UPDATE;
|
||||
}
|
||||
|
||||
ColumnAssignmentList* fColAssignmentListPtr;
|
||||
WhereClause* fWhereClausePtr;
|
||||
@@ -317,7 +323,10 @@ public:
|
||||
|
||||
/** @brief get the statement type - DML_DELETE
|
||||
*/
|
||||
inline virtual int getStatementType() const { return DML_DELETE; }
|
||||
inline virtual int getStatementType() const
|
||||
{
|
||||
return DML_DELETE;
|
||||
}
|
||||
|
||||
WhereClause* fWhereClausePtr;
|
||||
};
|
||||
@@ -344,7 +353,10 @@ public:
|
||||
|
||||
/** @brief get the statement type - DML_COMMAND
|
||||
*/
|
||||
inline virtual int getStatementType() const { return DML_COMMAND; }
|
||||
inline virtual int getStatementType() const
|
||||
{
|
||||
return DML_COMMAND;
|
||||
}
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
|
||||
@@ -35,6 +35,7 @@ DMLTable::~DMLTable()
|
||||
try
|
||||
{
|
||||
RowList::iterator it = fRows.begin();
|
||||
|
||||
while (it != fRows.end())
|
||||
{
|
||||
delete *it;
|
||||
@@ -67,6 +68,7 @@ int DMLTable::read(messageqcpp::ByteStream& bytestream)
|
||||
retval = aRow->read(bytestream);
|
||||
fRows.push_back(aRow);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -82,6 +84,7 @@ int DMLTable::write(messageqcpp::ByteStream& bytestream)
|
||||
//write the row list
|
||||
RowList::iterator rowListPtr;
|
||||
rowListPtr = fRows.begin();
|
||||
|
||||
for (; rowListPtr != fRows.end(); ++rowListPtr)
|
||||
{
|
||||
retval = (*rowListPtr)->write(bytestream);
|
||||
|
||||
@@ -51,23 +51,38 @@ public:
|
||||
|
||||
/** @brief get the schema name
|
||||
*/
|
||||
inline const std::string get_SchemaName() const { return fSchema; }
|
||||
inline const std::string get_SchemaName() const
|
||||
{
|
||||
return fSchema;
|
||||
}
|
||||
|
||||
/** @brief set the schema name
|
||||
*/
|
||||
inline void set_SchemaName( std::string& sName ) { fSchema = sName; }
|
||||
inline void set_SchemaName( std::string& sName )
|
||||
{
|
||||
fSchema = sName;
|
||||
}
|
||||
|
||||
/** @brief get the table name
|
||||
*/
|
||||
inline const std::string get_TableName() const { return fName; }
|
||||
inline const std::string get_TableName() const
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
|
||||
/** @brief set the table name
|
||||
*/
|
||||
inline void set_TableName( std::string& tName ) { fName = tName; }
|
||||
inline void set_TableName( std::string& tName )
|
||||
{
|
||||
fName = tName;
|
||||
}
|
||||
|
||||
/** @brief get the row list
|
||||
*/
|
||||
inline RowList& get_RowList() { return fRows; }
|
||||
inline RowList& get_RowList()
|
||||
{
|
||||
return fRows;
|
||||
}
|
||||
|
||||
/** @brief read a DMLTable from a ByteStream
|
||||
*
|
||||
|
||||
@@ -44,6 +44,7 @@ int main(int argc, char* argv[])
|
||||
po::variables_map vm;
|
||||
po::store (po::parse_command_line (argc, argv, desc), vm);
|
||||
po::notify (vm);
|
||||
|
||||
if (vm.count ("sql"))
|
||||
sqlfile = vm["sql"].as <string> ();
|
||||
|
||||
@@ -51,6 +52,7 @@ int main(int argc, char* argv[])
|
||||
count = vm["count"].as<int>();
|
||||
|
||||
DMLFileParser parser;
|
||||
|
||||
if (vm.count ("bisond"))
|
||||
parser.setDebug(true);
|
||||
|
||||
@@ -66,8 +68,10 @@ int main(int argc, char* argv[])
|
||||
cout << ptree;
|
||||
|
||||
SqlStatement* statementPtr = ptree[0];
|
||||
|
||||
if (statementPtr)
|
||||
cout << statementPtr->getQueryString();
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -64,10 +64,12 @@ int InsertDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||
bytestream << fSchemaName;
|
||||
bytestream << (uint8_t)fLogging;
|
||||
bytestream << (uint8_t)fLogending;
|
||||
|
||||
if (fTable != 0)
|
||||
{
|
||||
retval = fTable->write(bytestream);
|
||||
}
|
||||
|
||||
bytestream << fTableOid;
|
||||
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsInsertSelect);
|
||||
bytestream << static_cast<const messageqcpp::ByteStream::byte>(fIsBatchInsert);
|
||||
@@ -118,6 +120,7 @@ int InsertDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||
boost::char_separator<char> sep(",");
|
||||
tokenizer tokens(buffer, sep);
|
||||
|
||||
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
||||
{
|
||||
dataList.push_back(StripLeadingWhitespace(*tok_iter));
|
||||
@@ -125,12 +128,14 @@ int InsertDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
//get a new row
|
||||
Row* aRowPtr = new Row();
|
||||
std::string colName;
|
||||
std::string colValue;
|
||||
|
||||
for (int j = 0; j < columns; j++)
|
||||
{
|
||||
//Build a column list
|
||||
@@ -144,6 +149,7 @@ int InsertDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
DMLColumn* aColumn = new DMLColumn(colName, colValue, false);
|
||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||
}
|
||||
|
||||
//build a row list for a table
|
||||
fTable->get_RowList().push_back(aRowPtr);
|
||||
}
|
||||
@@ -159,6 +165,7 @@ int InsertDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValues
|
||||
Row* aRowPtr = new Row();
|
||||
std::string colName;
|
||||
std::vector<std::string> colValList;
|
||||
|
||||
for (int j = 0; j < columns; j++)
|
||||
{
|
||||
//Build a column list
|
||||
@@ -169,6 +176,7 @@ int InsertDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValues
|
||||
DMLColumn* aColumn = new DMLColumn(colName, colValList, false, 0, nullValues[j]);
|
||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||
}
|
||||
|
||||
//build a row list for a table
|
||||
fTable->get_RowList().push_back(aRowPtr);
|
||||
aRowPtr = NULL;
|
||||
@@ -188,6 +196,7 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
|
||||
initializeTable();
|
||||
bool isNULL = false;
|
||||
|
||||
// only if we don't have a select statement
|
||||
if (0 == insertStmt.fValuesOrQueryPtr->fQuerySpecPtr)
|
||||
{
|
||||
@@ -198,16 +207,20 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
{
|
||||
|
||||
ValuesList valuesList = insertStmt.fValuesOrQueryPtr->fValuesList;
|
||||
|
||||
if (columnNameList.size() != valuesList.size())
|
||||
{
|
||||
throw logic_error("Column names and values count mismatch!");
|
||||
}
|
||||
|
||||
Row* aRow = new Row();
|
||||
|
||||
for (unsigned int i = 0; i < columnNameList.size(); i++)
|
||||
{
|
||||
DMLColumn* aColumn = new DMLColumn(columnNameList[i], valuesList[i], isNULL);
|
||||
(aRow->get_ColumnList()).push_back(aColumn);
|
||||
}
|
||||
|
||||
fTable->get_RowList().push_back(aRow);
|
||||
|
||||
}
|
||||
@@ -218,9 +231,11 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
Row* aRow = new Row();
|
||||
std::string colName = "";
|
||||
std::string colValue;
|
||||
|
||||
while (iter != valuesList.end())
|
||||
{
|
||||
colValue = *iter;
|
||||
|
||||
if ( strcasecmp(colValue.c_str(), "NULL") == 0)
|
||||
{
|
||||
isNULL = true;
|
||||
@@ -229,11 +244,13 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
{
|
||||
isNULL = false;
|
||||
}
|
||||
|
||||
DMLColumn* aColumn = new DMLColumn(colName, colValue, isNULL);
|
||||
(aRow->get_ColumnList()).push_back(aColumn);
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
fTable->get_RowList().push_back(aRow);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ Row::~Row()
|
||||
{
|
||||
delete fColumnList[i];
|
||||
}
|
||||
|
||||
fColumnList.clear();
|
||||
}
|
||||
|
||||
@@ -50,6 +51,7 @@ Row::Row(const Row& row)
|
||||
DMLColumn* newColumn = new DMLColumn(aColumn->get_Name(), aColumn->get_Data());
|
||||
fColumnList.push_back(newColumn);
|
||||
}
|
||||
|
||||
fRowID = row.fRowID;
|
||||
}
|
||||
int Row::read(messageqcpp::ByteStream& bytestream)
|
||||
@@ -60,12 +62,14 @@ int Row::read(messageqcpp::ByteStream& bytestream)
|
||||
set_RowID(rowID);
|
||||
messageqcpp::ByteStream::quadbyte col_count;
|
||||
bytestream >> col_count;
|
||||
|
||||
for (unsigned int i = 0; i < col_count; i++)
|
||||
{
|
||||
DMLColumn* aColumn = new DMLColumn();
|
||||
retval = aColumn->read(bytestream);
|
||||
fColumnList.push_back(aColumn);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -79,6 +83,7 @@ int Row::write(messageqcpp::ByteStream& bytestream)
|
||||
colListPtr = fColumnList.begin();
|
||||
messageqcpp::ByteStream::quadbyte col_count = fColumnList.size();
|
||||
bytestream << col_count;
|
||||
|
||||
for (; colListPtr != fColumnList.end(); ++colListPtr)
|
||||
{
|
||||
retval = (*colListPtr)->write(bytestream);
|
||||
|
||||
@@ -71,19 +71,31 @@ public:
|
||||
|
||||
/** @brief get the list of columns in the row
|
||||
*/
|
||||
inline ColumnList& get_ColumnList() { return fColumnList; }
|
||||
inline ColumnList& get_ColumnList()
|
||||
{
|
||||
return fColumnList;
|
||||
}
|
||||
|
||||
/** @brief get the row id
|
||||
*/
|
||||
inline WriteEngine::RID get_RowID() const { return fRowID; }
|
||||
inline WriteEngine::RID get_RowID() const
|
||||
{
|
||||
return fRowID;
|
||||
}
|
||||
|
||||
/** @brief set the row id
|
||||
*/
|
||||
inline void set_RowID(WriteEngine::RID rowId) { fRowID = rowId; }
|
||||
inline void set_RowID(WriteEngine::RID rowId)
|
||||
{
|
||||
fRowID = rowId;
|
||||
}
|
||||
|
||||
/** @brief get the number of columns
|
||||
*/
|
||||
inline unsigned int get_NumberOfColumns() const { return static_cast<unsigned int>(fColumnList.size()); }
|
||||
inline unsigned int get_NumberOfColumns() const
|
||||
{
|
||||
return static_cast<unsigned int>(fColumnList.size());
|
||||
}
|
||||
|
||||
/** @brief get the column at the specified index
|
||||
*
|
||||
|
||||
@@ -46,6 +46,7 @@ bool parse_file(char* fileName)
|
||||
DMLFileParser parser;
|
||||
parser.parse(fileName);
|
||||
bool good = parser.good();
|
||||
|
||||
if (good)
|
||||
{
|
||||
const ParseTree& ptree = parser.getParseTree();
|
||||
@@ -56,8 +57,10 @@ bool parse_file(char* fileName)
|
||||
cout << ptree;
|
||||
|
||||
SqlStatement* statementPtr = ptree[0];
|
||||
|
||||
if (statementPtr)
|
||||
cout << statementPtr->getQueryString();
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
@@ -87,25 +90,55 @@ public:
|
||||
|
||||
void tearDown() {}
|
||||
|
||||
void test_i01() { CPPUNIT_ASSERT(parse_file("sql/i01.sql")); }
|
||||
void test_i01()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/i01.sql"));
|
||||
}
|
||||
|
||||
void test_i02() { CPPUNIT_ASSERT(parse_file("sql/i02.sql")); }
|
||||
void test_i02()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/i02.sql"));
|
||||
}
|
||||
|
||||
void test_i03() { CPPUNIT_ASSERT(parse_file("sql/i03.sql")); }
|
||||
void test_i03()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/i03.sql"));
|
||||
}
|
||||
|
||||
void test_i04() { CPPUNIT_ASSERT(parse_file("sql/i04.sql")); }
|
||||
void test_i04()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/i04.sql"));
|
||||
}
|
||||
|
||||
void test_u01() { CPPUNIT_ASSERT(parse_file("sql/u01.sql")); }
|
||||
void test_u01()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/u01.sql"));
|
||||
}
|
||||
|
||||
void test_u02() { CPPUNIT_ASSERT(parse_file("sql/u02.sql")); }
|
||||
void test_u02()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/u02.sql"));
|
||||
}
|
||||
|
||||
void test_d01() { CPPUNIT_ASSERT(parse_file("sql/d01.sql")); }
|
||||
void test_d01()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/d01.sql"));
|
||||
}
|
||||
|
||||
void test_d02() { CPPUNIT_ASSERT(parse_file("sql/d02.sql")); }
|
||||
void test_d02()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/d02.sql"));
|
||||
}
|
||||
|
||||
void test_d03() { CPPUNIT_ASSERT(parse_file("sql/d03.sql")); }
|
||||
void test_d03()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/d03.sql"));
|
||||
}
|
||||
|
||||
void test_d04() { CPPUNIT_ASSERT(parse_file("sql/d04.sql")); }
|
||||
void test_d04()
|
||||
{
|
||||
CPPUNIT_ASSERT(parse_file("sql/d04.sql"));
|
||||
}
|
||||
};
|
||||
|
||||
class DMLTest : public CppUnit::TestFixture
|
||||
@@ -154,6 +187,7 @@ public:
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||
|
||||
if ( pDMLPackage->HasFilter() )
|
||||
{
|
||||
cout << "This INSERT statement has a filter:" << endl;
|
||||
@@ -216,11 +250,13 @@ public:
|
||||
|
||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||
|
||||
if (pDMLPackage->HasFilter())
|
||||
{
|
||||
cout << "This DELETE statement has a filter:" << endl;
|
||||
cout << pDMLPackage->get_QueryString() << endl;
|
||||
}
|
||||
|
||||
write_DML_object(bytestream, pDMLPackage);
|
||||
delete pDMLPackage;
|
||||
read_delete_object(bytestream);
|
||||
@@ -267,6 +303,7 @@ public:
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
CPPUNIT_ASSERT( 0 != pDMLPackage );
|
||||
|
||||
if (pDMLPackage->HasFilter())
|
||||
{
|
||||
cout << "This UPDATE statement has a filter:" << endl;
|
||||
|
||||
@@ -67,10 +67,12 @@ int UpdateDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||
bytestream << fSQLStatement;
|
||||
bytestream << fSchemaName;
|
||||
bytestream << (uint8_t)fIsFromCol;
|
||||
|
||||
if (fTable != 0)
|
||||
{
|
||||
retval = fTable->write(bytestream);
|
||||
}
|
||||
|
||||
if (fHasFilter)
|
||||
{
|
||||
bytestream += *(fPlan.get());
|
||||
@@ -105,6 +107,7 @@ int UpdateDMLPackage::read(messageqcpp::ByteStream& bytestream)
|
||||
fIsFromCol = (isFromCol != 0);
|
||||
fTable = new DMLTable();
|
||||
retval = fTable->read(bytestream);
|
||||
|
||||
if (fHasFilter)
|
||||
{
|
||||
fPlan.reset(new messageqcpp::ByteStream(bytestream));
|
||||
@@ -130,6 +133,7 @@ int UpdateDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
// Push one row always and let the filter happen on the proc side.
|
||||
Row* rowPtr = new Row();
|
||||
ColumnAssignmentList::const_iterator iter = updateStmt.fColAssignmentListPtr->begin();
|
||||
|
||||
while (iter != updateStmt.fColAssignmentListPtr->end())
|
||||
{
|
||||
ColumnAssignment* colaPtr = *iter;
|
||||
@@ -138,7 +142,9 @@ int UpdateDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
fTable->get_RowList().push_back(rowPtr);
|
||||
|
||||
if (0 != updateStmt.fWhereClausePtr)
|
||||
{
|
||||
// We need to filter the rows...get row ids
|
||||
@@ -166,6 +172,7 @@ int UpdateDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||
boost::char_separator<char> sep(":,");
|
||||
tokenizer tokens(buffer, sep);
|
||||
|
||||
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
||||
{
|
||||
dataList.push_back(StripLeadingWhitespace(*tok_iter));
|
||||
@@ -173,6 +180,7 @@ int UpdateDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
//get a new row
|
||||
@@ -200,6 +208,7 @@ int UpdateDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
DMLColumn* aColumn = new DMLColumn(colName, colValue);
|
||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||
}
|
||||
|
||||
//build a row list for a table
|
||||
fTable->get_RowList().push_back(aRowPtr);
|
||||
}
|
||||
@@ -214,6 +223,7 @@ int UpdateDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValues
|
||||
Row* aRowPtr = new Row();
|
||||
std::string colName;
|
||||
std::vector<std::string> colValList;
|
||||
|
||||
for (int j = 0; j < columns; j++)
|
||||
{
|
||||
//Build a column list
|
||||
@@ -224,6 +234,7 @@ int UpdateDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValues
|
||||
DMLColumn* aColumn = new DMLColumn(colName, colValList, false, 0, nullValues[j]);
|
||||
(aRowPtr->get_ColumnList()).push_back(aColumn);
|
||||
}
|
||||
|
||||
//build a row list for a table
|
||||
fTable->get_RowList().push_back(aRowPtr);
|
||||
return retval;
|
||||
@@ -242,6 +253,7 @@ void UpdateDMLPackage::buildUpdateFromMysqlBuffer(UpdateSqlStatement& updateStm
|
||||
// Push one row always and let the filter happen on the proc side.
|
||||
Row* rowPtr = new Row();
|
||||
ColumnAssignmentList::const_iterator iter = updateStmt.fColAssignmentListPtr->begin();
|
||||
|
||||
while (iter != updateStmt.fColAssignmentListPtr->end())
|
||||
{
|
||||
ColumnAssignment* colaPtr = *iter;
|
||||
@@ -250,6 +262,7 @@ void UpdateDMLPackage::buildUpdateFromMysqlBuffer(UpdateSqlStatement& updateStm
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
fTable->get_RowList().push_back(rowPtr);
|
||||
}
|
||||
} // namespace dmlpackage
|
||||
|
||||
@@ -73,74 +73,134 @@ namespace dmlpackage
|
||||
|
||||
/** @brief Get the table name
|
||||
*/
|
||||
inline std::string get_TableName() const { return fTableName; }
|
||||
inline std::string get_TableName() const
|
||||
{
|
||||
return fTableName;
|
||||
}
|
||||
|
||||
/** @brief Set the table name
|
||||
*/
|
||||
inline void set_TableName( std::string value ) { fTableName = value; }
|
||||
inline void set_TableName( std::string value )
|
||||
{
|
||||
fTableName = value;
|
||||
}
|
||||
|
||||
/** @brief Get the schema name
|
||||
*/
|
||||
inline std::string get_SchemaName() const { return fSchema; }
|
||||
inline std::string get_SchemaName() const
|
||||
{
|
||||
return fSchema;
|
||||
}
|
||||
|
||||
/** @brief Set the schema name
|
||||
*/
|
||||
inline void set_SchemaName( std::string value ) { fSchema = value; }
|
||||
inline void set_SchemaName( std::string value )
|
||||
{
|
||||
fSchema = value;
|
||||
}
|
||||
|
||||
/** @brief Get the DML statVendorDMLStatement classement type
|
||||
*/
|
||||
inline int get_DMLStatementType() const { return fDMLStatementType; }
|
||||
inline int get_DMLStatementType() const
|
||||
{
|
||||
return fDMLStatementType;
|
||||
}
|
||||
|
||||
/** @brief Set the DML statement type
|
||||
*/
|
||||
inline void set_DMLStatementType( int value ) { fDMLStatementType = value; }
|
||||
inline void set_DMLStatementType( int value )
|
||||
{
|
||||
fDMLStatementType = value;
|
||||
}
|
||||
|
||||
/** @brief Get the DML statement
|
||||
*/
|
||||
inline const std::string get_DMLStatement() const { return fDMLStatement; }
|
||||
inline const std::string get_DMLStatement() const
|
||||
{
|
||||
return fDMLStatement;
|
||||
}
|
||||
|
||||
/** @brief Set the DML statVendorDMLStatement classement
|
||||
*/
|
||||
inline void set_DMLStatement( std::string dmlStatement ) { fDMLStatement = dmlStatement; }
|
||||
inline void set_DMLStatement( std::string dmlStatement )
|
||||
{
|
||||
fDMLStatement = dmlStatement;
|
||||
}
|
||||
|
||||
/** @brief Get the number of rows
|
||||
*/
|
||||
inline int get_Rows() const { return fRows; }
|
||||
inline int get_Rows() const
|
||||
{
|
||||
return fRows;
|
||||
}
|
||||
|
||||
/** @brief Set the number of rows
|
||||
*/
|
||||
inline void set_Rows( int value ) { fRows = value; }
|
||||
inline void set_Rows( int value )
|
||||
{
|
||||
fRows = value;
|
||||
}
|
||||
|
||||
/** @brief Get the number of columns
|
||||
*/
|
||||
inline int get_Columns() const { return fColumns; }
|
||||
inline int get_Columns() const
|
||||
{
|
||||
return fColumns;
|
||||
}
|
||||
|
||||
/** @brief Set the number of columns
|
||||
*/
|
||||
inline void set_Columns( int value ) { fColumns = value; }
|
||||
inline void set_Columns( int value )
|
||||
{
|
||||
fColumns = value;
|
||||
}
|
||||
|
||||
/** @brief Get the data buffer
|
||||
*/
|
||||
inline std::string& get_DataBuffer() { return fDataBuffer; }
|
||||
inline std::string& get_DataBuffer()
|
||||
{
|
||||
return fDataBuffer;
|
||||
}
|
||||
|
||||
/** @brief Set the data buffer
|
||||
*/
|
||||
inline void set_DataBuffer( std::string value ) { fDataBuffer= value; }
|
||||
inline void set_DataBuffer( std::string value )
|
||||
{
|
||||
fDataBuffer = value;
|
||||
}
|
||||
/** @brief Get the session ID
|
||||
*/
|
||||
inline int get_SessionID() { return fSessionID; }
|
||||
inline int get_SessionID()
|
||||
{
|
||||
return fSessionID;
|
||||
}
|
||||
|
||||
inline NullValuesBitset& get_nullValues() { return fNullValues; }
|
||||
inline NullValuesBitset& get_nullValues()
|
||||
{
|
||||
return fNullValues;
|
||||
}
|
||||
|
||||
/** @brief Set the session ID
|
||||
*/
|
||||
inline void set_SessionID( int value ) { fSessionID = value; }
|
||||
inline void set_SessionID( int value )
|
||||
{
|
||||
fSessionID = value;
|
||||
}
|
||||
|
||||
inline ColNameList& get_ColNames() { return fColNameList; }
|
||||
inline TableValuesMap& get_values() { return fTableValuesMap; }
|
||||
inline ColNameList& get_ColNames()
|
||||
{
|
||||
return fColNameList;
|
||||
}
|
||||
inline TableValuesMap& get_values()
|
||||
{
|
||||
return fTableValuesMap;
|
||||
}
|
||||
/** @brief get the logging flag
|
||||
*/
|
||||
inline const bool get_Logging() const { return fLogging; }
|
||||
inline const bool get_Logging() const
|
||||
{
|
||||
return fLogging;
|
||||
}
|
||||
|
||||
/** @brief set the logging flag
|
||||
*
|
||||
@@ -153,7 +213,10 @@ namespace dmlpackage
|
||||
|
||||
/** @brief get the logging flag
|
||||
*/
|
||||
inline const bool get_Logending() const { return fLogending; }
|
||||
inline const bool get_Logending() const
|
||||
{
|
||||
return fLogending;
|
||||
}
|
||||
|
||||
/** @brief set the logending flag
|
||||
*
|
||||
|
||||
@@ -56,6 +56,7 @@ void AutoincrementData::removeAutoincrementData(uint32_t sessionID)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(map_mutex);
|
||||
AutoincDataMap::iterator it = fAutoincDataMap.find(sessionID);
|
||||
|
||||
if (it != fAutoincDataMap.end())
|
||||
{
|
||||
delete (*it).second;
|
||||
@@ -81,10 +82,12 @@ long long AutoincrementData::getNextValue(uint32_t columnOid)
|
||||
boost::mutex::scoped_lock lk(fOIDnextvalLock);
|
||||
long long nextValue = 0;
|
||||
OIDNextValue::iterator it = fOidNextValueMap.find(columnOid);
|
||||
|
||||
if (it != fOidNextValueMap.end())
|
||||
{
|
||||
nextValue = it->second;
|
||||
}
|
||||
|
||||
return nextValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,8 +70,10 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
fSessionID = cpackage.get_SessionID();
|
||||
BRM::TxnID txnid = fSessionManager.getTxnID(cpackage.get_SessionID());
|
||||
uint64_t uniqueId = 0;
|
||||
|
||||
//Bug 5070. Added exception handling
|
||||
try {
|
||||
try
|
||||
{
|
||||
uniqueId = fDbrm->getUnique64();
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
@@ -105,6 +107,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
logging::Message::Args args1;
|
||||
logging::Message msg(1);
|
||||
Logger logger(logid.fSubsysID);
|
||||
|
||||
if (stmt != "CLEANUP")
|
||||
{
|
||||
args1.add("Start SQL statement: ");
|
||||
@@ -112,6 +115,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
msg.format( args1 );
|
||||
logger.logMessage(LOG_TYPE_DEBUG, msg, logid);
|
||||
}
|
||||
|
||||
//fWEClient->addQueue(uniqueId);
|
||||
try
|
||||
{
|
||||
@@ -125,6 +129,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
vector<LBID_t> lbidList;
|
||||
fDbrm->getUncommittedExtentLBIDs(static_cast<VER_t>(txnid.id), lbidList);
|
||||
bool cpInvalidated = false;
|
||||
|
||||
//cout << "get a valid txnid " << txnid.id << " and stmt is " << stmt << " and isBachinsert is " << cpackage.get_isBatchInsert() << endl;
|
||||
if ((stmt == "COMMIT") && (cpackage.get_isBatchInsert()))
|
||||
{
|
||||
@@ -132,9 +137,11 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(fSessionID);
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
tableName = systemCatalogPtr->tableName(cpackage.getTableOid());
|
||||
|
||||
try
|
||||
{
|
||||
uint64_t nextVal = systemCatalogPtr->nextAutoIncrValue(tableName);
|
||||
|
||||
if (nextVal != AUTOINCR_SATURATED) //need to update syscolumn
|
||||
{
|
||||
//get autoincrement column oid
|
||||
@@ -146,6 +153,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
aDbrm->getAILock(columnOid);
|
||||
nextVal = systemCatalogPtr->nextAutoIncrValue(tableName); //in case it has changed
|
||||
validNextVal = aDbrm->getAIValue(columnOid, &nextValInController);
|
||||
|
||||
if ((validNextVal) && (nextValInController > nextVal))
|
||||
{
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
@@ -154,6 +162,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
uint8_t rc = ddlClient.UpdateSyscolumnNextval(columnOid, nextValInController);
|
||||
//@bug 5894. Need release lock.
|
||||
aDbrm->releaseAILock(columnOid);
|
||||
|
||||
if (rc != 0)
|
||||
throw std::runtime_error("Error in UpdateSyscolumnNextval");
|
||||
}
|
||||
@@ -168,20 +177,26 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
fSessionManager.rolledback( txnid );
|
||||
throw std::runtime_error(ex.what());
|
||||
}
|
||||
|
||||
//systemCatalogPtr->updateColinfoCache(nextValMap);
|
||||
int weRc = 0;
|
||||
|
||||
if (cpackage.get_isAutocommitOn())
|
||||
{
|
||||
weRc = commitBatchAutoOnTransaction(uniqueId, txnid, cpackage.getTableOid(), errorMsg);
|
||||
|
||||
if (weRc != 0)
|
||||
BRM::errString(weRc, errorMsg);
|
||||
|
||||
cpInvalidated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
weRc = fDbrm->vbCommit(txnid.id);
|
||||
|
||||
if (weRc != 0)
|
||||
BRM::errString(weRc, errorMsg);
|
||||
|
||||
//weRc = commitBatchAutoOffTransaction(uniqueId, txnid, cpackage.getTableOid(), errorMsg);
|
||||
}
|
||||
|
||||
@@ -189,6 +204,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
{
|
||||
throw std::runtime_error(errorMsg);
|
||||
}
|
||||
|
||||
logging::logCommand(cpackage.get_SessionID(), txnid.id, "COMMIT;");
|
||||
fSessionManager.committed( txnid );
|
||||
//cout << "releasing transaction id for batchinsert" << txnid.id << endl;
|
||||
@@ -201,22 +217,27 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
uint32_t tableOid = cpackage.getTableOid();
|
||||
std::vector<TableLockInfo> tableLocks = fDbrm->getAllTableLocks();
|
||||
|
||||
if (tableOid == 0) //special case: transaction commit for autocommit off and not following a dml statement immediately
|
||||
{
|
||||
TablelockData* tablelockData = TablelockData::makeTablelockData(fSessionID);
|
||||
TablelockData::OIDTablelock tablelockMap = tablelockData->getOidTablelockMap();
|
||||
TablelockData::OIDTablelock::iterator iter;
|
||||
|
||||
if (!tablelockMap.empty())
|
||||
{
|
||||
for ( unsigned k = 0; k < tableLocks.size(); k++)
|
||||
{
|
||||
iter = tablelockMap.find(tableLocks[k].tableOID);
|
||||
|
||||
if ( iter != tablelockMap.end() )
|
||||
{
|
||||
tableName = systemCatalogPtr->tableName(tableLocks[k].tableOID);
|
||||
|
||||
try
|
||||
{
|
||||
uint64_t nextVal = systemCatalogPtr->nextAutoIncrValue(tableName);
|
||||
|
||||
if (nextVal != AUTOINCR_SATURATED) //neet to update syscolumn
|
||||
{
|
||||
//get autoincrement column oid
|
||||
@@ -237,6 +258,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
WE_DDLCommandClient ddlClient;
|
||||
uint8_t rc = ddlClient.UpdateSyscolumnNextval(columnOid, nextValInController, fSessionID);
|
||||
aDbrm->releaseAILock(columnOid);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
//for now
|
||||
@@ -266,9 +288,11 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
if (tableOid >= 3000)
|
||||
{
|
||||
tableName = systemCatalogPtr->tableName(tableOid);
|
||||
|
||||
try
|
||||
{
|
||||
uint64_t nextVal = systemCatalogPtr->nextAutoIncrValue(tableName);
|
||||
|
||||
if (nextVal != AUTOINCR_SATURATED) //need to update syscolumn
|
||||
{
|
||||
//get autoincrement column oid
|
||||
@@ -280,6 +304,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
aDbrm->getAILock(columnOid);
|
||||
nextVal = systemCatalogPtr->nextAutoIncrValue(tableName); //in case it has changed
|
||||
validNextVal = aDbrm->getAIValue(columnOid, &nextValInController);
|
||||
|
||||
if ((validNextVal) && (nextValInController > (uint64_t)nextVal))
|
||||
{
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
@@ -288,6 +313,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
WE_DDLCommandClient ddlClient;
|
||||
uint8_t rc = ddlClient.UpdateSyscolumnNextval(columnOid, nextValInController, fSessionID);
|
||||
aDbrm->releaseAILock(columnOid);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
//for now
|
||||
@@ -303,22 +329,26 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
{
|
||||
//Rollback transaction, release tablelock
|
||||
rollBackTransaction(uniqueId, txnid, fSessionID, errorMsg);
|
||||
|
||||
for ( unsigned k = 0; k < tableLocks.size(); k++)
|
||||
{
|
||||
if ( tableLocks[k].tableOID == tableOid )
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
fDbrm->releaseTableLock(tableLocks[k].id);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
fSessionManager.rolledback( txnid );
|
||||
throw std::runtime_error(ex.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int weRc = commitTransaction(uniqueId, txnid );
|
||||
logging::logCommand(cpackage.get_SessionID(), txnid.id, "COMMIT;");
|
||||
|
||||
@@ -330,6 +360,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
oss << "COMMIT failed: " << ec.errorString(weRc);
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
|
||||
fSessionManager.committed( txnid );
|
||||
//cout << "commit releasing transaction id " << txnid.id << endl;
|
||||
}
|
||||
@@ -340,6 +371,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
|
||||
//version rollback, Bulkrollback
|
||||
weRc = rollBackTransaction(uniqueId, txnid, fSessionID, errorMsg);
|
||||
|
||||
if (weRc == 0)
|
||||
{
|
||||
//@Bug 4560 invalidate cp first as bulkrollback will truncate the newly added lbids.
|
||||
@@ -354,6 +386,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
}
|
||||
|
||||
logging::logCommand(cpackage.get_SessionID(), txnid.id, "ROLLBACK;");
|
||||
|
||||
if (weRc != 0)
|
||||
{
|
||||
//@Bug 4524. Don't set to readonly. Just error out.
|
||||
@@ -368,6 +401,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
ml.logErrorMessage( message1 );
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
|
||||
fSessionManager.rolledback( txnid );
|
||||
//cout << "batch rollback releasing transaction id " << txnid.id << endl;
|
||||
}
|
||||
@@ -376,6 +410,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
std::string errorMsg("");
|
||||
logging::logCommand(cpackage.get_SessionID(), txnid.id, "ROLLBACK;");
|
||||
int weRc = rollBackTransaction(uniqueId, txnid, fSessionID, errorMsg);
|
||||
|
||||
if (weRc != 0)
|
||||
{
|
||||
//cout << "Rollback failed" << endl;
|
||||
@@ -390,6 +425,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
ml.logErrorMessage( message2 );
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
|
||||
fSessionManager.rolledback( txnid );
|
||||
//cout << "Rollback releasing transaction id " << txnid.id << endl;
|
||||
}
|
||||
@@ -465,6 +501,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
result.result = COMMAND_ERROR;
|
||||
result.message = message;
|
||||
}
|
||||
|
||||
if (!queRemoved)
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
|
||||
@@ -478,10 +515,12 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
if (!tablelockMap.empty())
|
||||
{
|
||||
TablelockData::OIDTablelock::iterator it = tablelockMap.begin();
|
||||
|
||||
while (it != tablelockMap.end())
|
||||
{
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
lockReleased = fDbrm->releaseTableLock(it->second);
|
||||
//cout << "releasing tablelock " << it->second << endl;
|
||||
}
|
||||
@@ -497,6 +536,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
result.result = COMMAND_ERROR;
|
||||
result.message = message;
|
||||
}
|
||||
|
||||
if (!lockReleased) //log an error
|
||||
{
|
||||
ostringstream os;
|
||||
@@ -512,18 +552,22 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
|
||||
ml.logErrorMessage(message);
|
||||
}
|
||||
|
||||
//cout << "tablelock " << it->second << " is released" << endl;
|
||||
it++;
|
||||
}
|
||||
|
||||
//@Bug 3557. Clean tablelock cache after commit/rollback.
|
||||
TablelockData::removeTablelockData(cpackage.get_SessionID());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
VERBOSE_INFO("Finished processing Command DML Package");
|
||||
//LoggingID logid( DMLLoggingId, fSessionID, txnid.id);
|
||||
logging::Message::Args args2;
|
||||
logging::Message msg1(1);
|
||||
|
||||
if (stmt != "CLEANUP")
|
||||
{
|
||||
args2.add("End SQL statement");
|
||||
@@ -531,6 +575,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
//Logger logger(logid.fSubsysID);
|
||||
logger.logMessage(LOG_TYPE_DEBUG, msg1, logid);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -581,65 +626,85 @@ void CommandPackageProcessor::viewTableLock(
|
||||
{
|
||||
if (tableLocks[idx].id > maxLockID)
|
||||
maxLockID = tableLocks[idx].id;
|
||||
|
||||
if (tableLocks[idx].ownerName.length() > ownerColumnWidth)
|
||||
ownerColumnWidth = tableLocks[idx].ownerName.length();
|
||||
|
||||
if (tableLocks[idx].ownerPID > maxPID)
|
||||
maxPID = tableLocks[idx].ownerPID;
|
||||
|
||||
if (tableLocks[idx].ownerSessionID > maxSessionID)
|
||||
maxSessionID = tableLocks[idx].ownerSessionID;
|
||||
|
||||
if (tableLocks[idx].ownerSessionID < minSessionID)
|
||||
minSessionID = tableLocks[idx].ownerSessionID;
|
||||
|
||||
if (tableLocks[idx].ownerTxnID > maxTxnID)
|
||||
maxTxnID = tableLocks[idx].ownerTxnID;
|
||||
|
||||
ctime_r( &tableLocks[idx].creationTime, cTimeBuffer );
|
||||
cTimeBuffer[ strlen(cTimeBuffer) - 1 ] = '\0'; // strip trailing '\n'
|
||||
std::string cTimeStr( cTimeBuffer );
|
||||
|
||||
if (cTimeStr.length() > createTimeColumnWidth)
|
||||
createTimeColumnWidth = cTimeStr.length();
|
||||
|
||||
createTimes.push_back( cTimeStr );
|
||||
|
||||
std::ostringstream pms; //It is dbroots now
|
||||
|
||||
for (unsigned k = 0; k < tableLocks[idx].dbrootList.size(); k++)
|
||||
{
|
||||
if (k > 0)
|
||||
pms << ',';
|
||||
|
||||
pms << tableLocks[idx].dbrootList[k];
|
||||
}
|
||||
|
||||
if (pms.str().length() > pmColumnWidth)
|
||||
pmColumnWidth = pms.str().length();
|
||||
}
|
||||
|
||||
ownerColumnWidth += 2;
|
||||
pmColumnWidth += 2;
|
||||
createTimeColumnWidth += 2;
|
||||
|
||||
std::ostringstream idString;
|
||||
idString << maxLockID;
|
||||
|
||||
if (idString.str().length() > lockIDColumnWidth)
|
||||
lockIDColumnWidth = idString.str().length();
|
||||
|
||||
lockIDColumnWidth += 2;
|
||||
|
||||
std::ostringstream pidString;
|
||||
pidString << maxPID;
|
||||
|
||||
if (pidString.str().length() > pidColumnWidth)
|
||||
pidColumnWidth = pidString.str().length();
|
||||
|
||||
pidColumnWidth += 2;
|
||||
|
||||
const std::string sessionNoneStr("BulkLoad");
|
||||
std::ostringstream sessionString;
|
||||
sessionString << maxSessionID;
|
||||
|
||||
if (sessionString.str().length() > sessionIDColumnWidth)
|
||||
sessionIDColumnWidth = sessionString.str().length();
|
||||
|
||||
if ((minSessionID < 0) &&
|
||||
(sessionNoneStr.length() > sessionIDColumnWidth))
|
||||
sessionIDColumnWidth = sessionNoneStr.length();
|
||||
|
||||
sessionIDColumnWidth += 2;
|
||||
|
||||
const std::string txnNoneStr("n/a");
|
||||
std::ostringstream txnString;
|
||||
txnString << maxTxnID;
|
||||
|
||||
if (txnString.str().length() > txnIDColumnWidth)
|
||||
txnIDColumnWidth = txnString.str().length();
|
||||
|
||||
txnIDColumnWidth += 2;
|
||||
|
||||
// Make second pass through the table locks to build our result.
|
||||
@@ -647,16 +712,19 @@ void CommandPackageProcessor::viewTableLock(
|
||||
// (on different PMs), so we don't exit loop after "first" match.
|
||||
bool found = false;
|
||||
ostringstream os;
|
||||
|
||||
for (unsigned idx = 0; idx < tableLocks.size(); idx++)
|
||||
{
|
||||
if (roPair.objnum == (CalpontSystemCatalog::OID)
|
||||
tableLocks[idx].tableOID)
|
||||
{
|
||||
std::ostringstream pms;
|
||||
|
||||
for (unsigned k = 0; k < tableLocks[idx].dbrootList.size(); k++)
|
||||
{
|
||||
if (k > 0)
|
||||
pms << ',';
|
||||
|
||||
pms << tableLocks[idx].dbrootList[k];
|
||||
}
|
||||
|
||||
@@ -759,9 +827,11 @@ void CommandPackageProcessor::clearTableLock( uint64_t uniqueId,
|
||||
bool bRemoveMetaErrFlag = false;
|
||||
std::ostringstream combinedErrMsg;
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
// Make sure BRM is in READ-WRITE state before starting
|
||||
int brmRc = fDbrm->isReadWrite( );
|
||||
|
||||
if (brmRc != BRM::ERR_OK)
|
||||
{
|
||||
std::string brmErrMsg;
|
||||
@@ -785,6 +855,7 @@ void CommandPackageProcessor::clearTableLock( uint64_t uniqueId,
|
||||
for (unsigned int k = 0; k < lockInfo.dbrootList.size(); k++)
|
||||
{
|
||||
mapIter = dbRootPmMap->find( lockInfo.dbrootList[k] );
|
||||
|
||||
if (mapIter != dbRootPmMap->end())
|
||||
{
|
||||
int pm = mapIter->second;
|
||||
@@ -800,6 +871,7 @@ void CommandPackageProcessor::clearTableLock( uint64_t uniqueId,
|
||||
}
|
||||
|
||||
std::vector<int> pmList;
|
||||
|
||||
for (std::set<int>::const_iterator setIter = pmSet.begin();
|
||||
setIter != pmSet.end();
|
||||
++setIter)
|
||||
@@ -809,12 +881,15 @@ void CommandPackageProcessor::clearTableLock( uint64_t uniqueId,
|
||||
|
||||
std::cout << "cleartablelock rollback for table lock " << tableLockID <<
|
||||
" being forwarded to PM(s): ";
|
||||
|
||||
for (unsigned int k = 0; k < pmList.size(); k++)
|
||||
{
|
||||
if (k > 0)
|
||||
std::cout << ", ";
|
||||
|
||||
std::cout << pmList[k];
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
// Perform bulk rollback if state is in LOADING state
|
||||
@@ -839,6 +914,7 @@ void CommandPackageProcessor::clearTableLock( uint64_t uniqueId,
|
||||
bsOut << lockInfo.tableOID;
|
||||
bsOut << tableName.toString();
|
||||
bsOut << APPLNAME;
|
||||
|
||||
for (unsigned j = 0; j < pmList.size(); j++)
|
||||
{
|
||||
fWEClient->write(bsOut, pmList[j]);
|
||||
@@ -846,16 +922,20 @@ void CommandPackageProcessor::clearTableLock( uint64_t uniqueId,
|
||||
|
||||
// Wait for "all" the responses, and accumulate any/all errors
|
||||
unsigned int pmMsgCnt = 0;
|
||||
|
||||
while (pmMsgCnt < pmList.size())
|
||||
{
|
||||
std::string rollbackErrMsg;
|
||||
bsIn.reset(new messageqcpp::ByteStream());
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if (bsIn->length() == 0)
|
||||
{
|
||||
bRemoveMetaErrFlag = true;
|
||||
|
||||
if (combinedErrMsg.str().length() > 0)
|
||||
combinedErrMsg << std::endl;
|
||||
|
||||
combinedErrMsg << "Network error, PM rollback; ";
|
||||
}
|
||||
else
|
||||
@@ -873,14 +953,17 @@ void CommandPackageProcessor::clearTableLock( uint64_t uniqueId,
|
||||
if (rc != 0)
|
||||
{
|
||||
bRemoveMetaErrFlag = true;
|
||||
|
||||
if (combinedErrMsg.str().empty())
|
||||
combinedErrMsg << "Rollback error; ";
|
||||
else
|
||||
combinedErrMsg << std::endl;
|
||||
|
||||
combinedErrMsg << "[PM" << pmNum << "] " <<
|
||||
rollbackErrMsg;
|
||||
}
|
||||
}
|
||||
|
||||
pmMsgCnt++;
|
||||
} // end of while loop to process all responses to bulk rollback
|
||||
|
||||
@@ -909,6 +992,7 @@ void CommandPackageProcessor::clearTableLock( uint64_t uniqueId,
|
||||
WE_SVR_DML_BULKROLLBACK_CLEANUP;
|
||||
bsOut << uniqueId;
|
||||
bsOut << lockInfo.tableOID;
|
||||
|
||||
for (unsigned j = 0; j < pmList.size(); j++)
|
||||
{
|
||||
fWEClient->write(bsOut, pmList[j]);
|
||||
@@ -916,16 +1000,20 @@ void CommandPackageProcessor::clearTableLock( uint64_t uniqueId,
|
||||
|
||||
// Wait for "all" the responses, and accumulate any/all errors
|
||||
unsigned int pmMsgCnt = 0;
|
||||
|
||||
while (pmMsgCnt < pmList.size())
|
||||
{
|
||||
std::string fileDeleteErrMsg;
|
||||
bsIn.reset(new messageqcpp::ByteStream());
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if (bsIn->length() == 0)
|
||||
{
|
||||
bRemoveMetaErrFlag = true;
|
||||
|
||||
if (combinedErrMsg.str().length() > 0)
|
||||
combinedErrMsg << std::endl;
|
||||
|
||||
combinedErrMsg << "Network error, PM rollback cleanup; ";
|
||||
}
|
||||
else
|
||||
@@ -943,14 +1031,17 @@ void CommandPackageProcessor::clearTableLock( uint64_t uniqueId,
|
||||
if (rc != 0)
|
||||
{
|
||||
bRemoveMetaErrFlag = true;
|
||||
|
||||
if (combinedErrMsg.str().empty())
|
||||
combinedErrMsg << "Cleanup error; ";
|
||||
else
|
||||
combinedErrMsg << std::endl;
|
||||
|
||||
combinedErrMsg << "[PM" << pmNum << "] " <<
|
||||
fileDeleteErrMsg;
|
||||
}
|
||||
}
|
||||
|
||||
pmMsgCnt++;
|
||||
} // end of while loop to process all responses to rollback cleanup
|
||||
|
||||
@@ -972,11 +1063,13 @@ void CommandPackageProcessor::clearTableLock( uint64_t uniqueId,
|
||||
std::ostringstream oss;
|
||||
oss << "Table lock " << tableLockID << " for table " <<
|
||||
tableName.toString() << " is cleared.";
|
||||
|
||||
//@Bug 4517. Release tablelock if remove meta files failed.
|
||||
if (bRemoveMetaErrFlag)
|
||||
{
|
||||
oss << " Warning: " << combinedErrMsg.str();
|
||||
}
|
||||
|
||||
result.tableLockInfo = oss.str();
|
||||
}
|
||||
else
|
||||
@@ -1006,6 +1099,7 @@ void CommandPackageProcessor::clearTableLock( uint64_t uniqueId,
|
||||
msgArgs.add( tableName.toString() );
|
||||
msgArgs.add( tableLockID );
|
||||
std::string finalStatus;
|
||||
|
||||
if (!bErrFlag)
|
||||
{
|
||||
finalStatus = "Completed successfully";
|
||||
@@ -1015,6 +1109,7 @@ void CommandPackageProcessor::clearTableLock( uint64_t uniqueId,
|
||||
finalStatus = "Encountered errors: ";
|
||||
finalStatus += combinedErrMsg.str();
|
||||
}
|
||||
|
||||
msgArgs.add( finalStatus );
|
||||
logMsg2.format( msgArgs );
|
||||
ml.logInfoMessage( logMsg2 );
|
||||
@@ -1048,6 +1143,7 @@ void CommandPackageProcessor::establishTableLockToClear( uint64_t tableLockID,
|
||||
{
|
||||
std::set<uint64_t>::const_iterator it =
|
||||
fActiveClearTableLockCmds.find( tableLockID );
|
||||
|
||||
if (it != fActiveClearTableLockCmds.end())
|
||||
{
|
||||
throw std::runtime_error( std::string( "Lock in use. "
|
||||
@@ -1063,6 +1159,7 @@ void CommandPackageProcessor::establishTableLockToClear( uint64_t tableLockID,
|
||||
int32_t txnid = -1;
|
||||
bool ownerChanged = fDbrm->changeOwner(
|
||||
tableLockID, processName, processID, sessionID, txnid);
|
||||
|
||||
if (!ownerChanged)
|
||||
{
|
||||
throw std::runtime_error( std::string(
|
||||
|
||||
90
dbcon/dmlpackageproc/deletepackageprocessor.cpp
Executable file → Normal file
90
dbcon/dmlpackageproc/deletepackageprocessor.cpp
Executable file → Normal file
@@ -73,8 +73,10 @@ namespace dmlpackageprocessor
|
||||
VERBOSE_INFO("DeletePackageProcessor is processing CalpontDMLPackage ...");
|
||||
TablelockData* tablelockData = TablelockData::makeTablelockData(fSessionID);
|
||||
uint64_t uniqueId = 0;
|
||||
|
||||
//Bug 5070. Added exception handling
|
||||
try {
|
||||
try
|
||||
{
|
||||
uniqueId = fDbrm->getUnique64();
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
@@ -111,6 +113,7 @@ namespace dmlpackageprocessor
|
||||
aTableName.schema = schemaName;
|
||||
fWEClient->addQueue(uniqueId);
|
||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||
|
||||
try
|
||||
{
|
||||
string stmt = cpackage.get_SQLStatement() + "|" + schemaName + "|";
|
||||
@@ -122,6 +125,7 @@ namespace dmlpackageprocessor
|
||||
roPair = csc->tableRID(aTableName);
|
||||
|
||||
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 " << endl;
|
||||
@@ -133,12 +137,14 @@ namespace dmlpackageprocessor
|
||||
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 {
|
||||
try
|
||||
{
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnId, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -164,14 +170,18 @@ namespace dmlpackageprocessor
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
#else
|
||||
struct timespec abs_ts;
|
||||
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
processID = ::getpid();
|
||||
txnId = txnid.id;
|
||||
sessionId = fSessionID;
|
||||
@@ -207,6 +217,7 @@ namespace dmlpackageprocessor
|
||||
const CalpontSystemCatalog::RIDList ridList = csc->columnRIDs(aTableName);
|
||||
CalpontSystemCatalog::RIDList::const_iterator rid_iterator = ridList.begin();
|
||||
CalpontSystemCatalog::ColType colType;
|
||||
|
||||
while (rid_iterator != ridList.end())
|
||||
{
|
||||
// If user hit ctrl+c in the mysql console, fRollbackPending will be true.
|
||||
@@ -215,8 +226,10 @@ namespace dmlpackageprocessor
|
||||
result.result = JOB_CANCELED;
|
||||
break;
|
||||
}
|
||||
|
||||
CalpontSystemCatalog::ROPair roPair = *rid_iterator;
|
||||
colType = csc->colType(roPair.objnum);
|
||||
|
||||
if (colType.autoincrement)
|
||||
{
|
||||
try
|
||||
@@ -231,12 +244,14 @@ namespace dmlpackageprocessor
|
||||
throw std::runtime_error(ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
++rid_iterator;
|
||||
}
|
||||
|
||||
uint64_t rowsProcessed = 0;
|
||||
|
||||
rowsProcessed = fixUpRows(cpackage, result, uniqueId, roPair.objnum);
|
||||
|
||||
//@Bug 4994 Cancelled job is not error
|
||||
if (result.result == JOB_CANCELED)
|
||||
throw std::runtime_error("Query execution was interrupted");
|
||||
@@ -259,6 +274,7 @@ namespace dmlpackageprocessor
|
||||
{
|
||||
result.result = DELETE_ERROR;
|
||||
}
|
||||
|
||||
result.message = Message(ex.what());
|
||||
}
|
||||
catch (...)
|
||||
@@ -275,16 +291,20 @@ namespace dmlpackageprocessor
|
||||
result.result = DELETE_ERROR;
|
||||
result.message = message;
|
||||
}
|
||||
|
||||
//timer.finish();
|
||||
//@Bug 1886,2870 Flush VM cache only once per statement.
|
||||
std::map<uint32_t, uint32_t> oids;
|
||||
int rc = 0;
|
||||
|
||||
if (result.result == NO_ERROR)
|
||||
{
|
||||
rc = flushDataFiles( result.result, oids, uniqueId, txnid, roPair.objnum);
|
||||
|
||||
if (rc != NO_ERROR)
|
||||
{
|
||||
cerr << "UpdatePackageProcessor::processPackage: write data to disk failed" << endl;
|
||||
|
||||
if (!fRollbackPending)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
@@ -298,8 +318,10 @@ namespace dmlpackageprocessor
|
||||
result.result = UPDATE_ERROR;
|
||||
result.message = message;
|
||||
}
|
||||
|
||||
result.rowCount = 0;
|
||||
rc = endTransaction(uniqueId, txnid, false);
|
||||
|
||||
if ( (rc != NO_ERROR) && (!fRollbackPending))
|
||||
{
|
||||
logging::Message::Args args;
|
||||
@@ -362,22 +384,27 @@ namespace dmlpackageprocessor
|
||||
string emsg;
|
||||
string emsgStr;
|
||||
bool err = false;
|
||||
|
||||
//boost::scoped_ptr<messageqcpp::MessageQueueClient> fExeMgr;
|
||||
//fExeMgr.reset( new messageqcpp::MessageQueueClient("ExeMgr1"));
|
||||
try {
|
||||
try
|
||||
{
|
||||
for (unsigned i = 0; i < fPMs.size(); i++)
|
||||
{
|
||||
pmStateDel[fPMs[i]] = true;
|
||||
}
|
||||
|
||||
fExeMgr->write(msg);
|
||||
fExeMgr->write(*(cpackage.get_ExecutionPlan()));
|
||||
//cout << "sending to ExeMgr plan with length " << (cpackage.get_ExecutionPlan())->length() << endl;
|
||||
msg.restart();
|
||||
emsgBs.restart();
|
||||
msg = fExeMgr->read(); //error handling
|
||||
|
||||
if (msg.length() == 4)
|
||||
{
|
||||
msg >> qb;
|
||||
|
||||
if (qb != 0)
|
||||
err = true;
|
||||
}
|
||||
@@ -386,6 +413,7 @@ namespace dmlpackageprocessor
|
||||
qb = 999;
|
||||
err = true;
|
||||
}
|
||||
|
||||
if (err)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
@@ -422,10 +450,12 @@ namespace dmlpackageprocessor
|
||||
err = true;
|
||||
break;
|
||||
}
|
||||
|
||||
msg.restart();
|
||||
msgBk.restart();
|
||||
msg = fExeMgr->read();
|
||||
msgBk = msg;
|
||||
|
||||
if ( msg.length() == 0 )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
@@ -462,6 +492,7 @@ namespace dmlpackageprocessor
|
||||
rowGroup->setData(&rgData);
|
||||
//rowGroup->setData(const_cast<uint8_t*>(msg.buf()));
|
||||
err = (rowGroup->getStatus() != 0);
|
||||
|
||||
if (err)
|
||||
{
|
||||
//msgBk.advance(rowGroup->getDataSize());
|
||||
@@ -483,22 +514,27 @@ namespace dmlpackageprocessor
|
||||
//return rowsProcessed;
|
||||
break;
|
||||
}
|
||||
|
||||
if (rowGroup->getRGData() == NULL)
|
||||
{
|
||||
msg.restart();
|
||||
}
|
||||
|
||||
if (rowGroup->getRowCount() == 0) //done fetching
|
||||
{
|
||||
err = receiveAll( result, uniqueId, fPMs, pmStateDel, tableOid);
|
||||
//return rowsProcessed;
|
||||
break;
|
||||
}
|
||||
|
||||
if (rowGroup->getBaseRid() == (uint64_t) (-1))
|
||||
{
|
||||
continue; // @bug4247, not valid row ids, may from small side outer
|
||||
}
|
||||
|
||||
dbroot = rowGroup->getDBRoot();
|
||||
err = processRowgroup(msgBk, result, uniqueId, cpackage, pmStateDel, metaData, dbroot);
|
||||
|
||||
if (err)
|
||||
{
|
||||
DMLResult tmpResult;
|
||||
@@ -510,9 +546,11 @@ namespace dmlpackageprocessor
|
||||
//return rowsProcessed;
|
||||
break;
|
||||
}
|
||||
|
||||
rowsProcessed += rowGroup->getRowCount();
|
||||
}
|
||||
}
|
||||
|
||||
if (fRollbackPending)
|
||||
{
|
||||
err = true;
|
||||
@@ -556,6 +594,7 @@ namespace dmlpackageprocessor
|
||||
msg << qb;
|
||||
fExeMgr->write(msg);
|
||||
}
|
||||
|
||||
return rowsProcessed;
|
||||
}
|
||||
catch (runtime_error& ex)
|
||||
@@ -622,20 +661,26 @@ bool DeletePackageProcessor::processRowgroup(ByteStream & aRowGroup, DMLResult&
|
||||
if (isMeta) //send to all PMs
|
||||
{
|
||||
fWEClient->write_to_all(bytestream);
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = true;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = (tmp8 != 0);
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
break;
|
||||
}
|
||||
@@ -643,12 +688,14 @@ bool DeletePackageProcessor::processRowgroup(ByteStream & aRowGroup, DMLResult&
|
||||
msgRecived++;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (pmStateDel[pmNum])
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
fWEClient->write(bytestream, (uint32_t)pmNum);
|
||||
//cout << "sent tp pm " << pmNum<<endl;
|
||||
pmStateDel[pmNum] = false;
|
||||
@@ -681,15 +728,19 @@ bool DeletePackageProcessor::processRowgroup(ByteStream & aRowGroup, DMLResult&
|
||||
while (1)
|
||||
{
|
||||
bsIn.reset(new ByteStream());
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = true;
|
||||
errorMsg = "Lost connection to Write Engine Server while deleting";
|
||||
throw std::runtime_error(errorMsg);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = (tmp8 != 0);
|
||||
*bsIn >> errorMsg;
|
||||
@@ -700,9 +751,12 @@ bool DeletePackageProcessor::processRowgroup(ByteStream & aRowGroup, DMLResult&
|
||||
|
||||
//cout << "received from pm " << (uint32_t)tmp32 << " and rc = " << rc << endl;
|
||||
pmStateDel[tmp32] = true;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
throw std::runtime_error(errorMsg);
|
||||
}
|
||||
|
||||
if ( tmp32 == (uint32_t)pmNum )
|
||||
{
|
||||
fWEClient->write(bytestream, (uint32_t)pmNum);
|
||||
@@ -737,6 +791,7 @@ bool DeletePackageProcessor::processRowgroup(ByteStream & aRowGroup, DMLResult&
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -746,6 +801,7 @@ bool DeletePackageProcessor::receiveAll(DMLResult& result, const uint64_t unique
|
||||
//check how many message we need to receive
|
||||
uint32_t messagesNotReceived = 0;
|
||||
bool err = false;
|
||||
|
||||
for (unsigned i = 0; i < fPMs.size(); i++)
|
||||
{
|
||||
if (!pmStateDel[fPMs[i]])
|
||||
@@ -756,9 +812,11 @@ bool DeletePackageProcessor::receiveAll(DMLResult& result, const uint64_t unique
|
||||
uint32_t msgReceived = 0;
|
||||
ByteStream::byte tmp8;
|
||||
string errorMsg;
|
||||
|
||||
if (messagesNotReceived > 0)
|
||||
{
|
||||
LoggingID logid( DMLLoggingId, fSessionID, fSessionID);
|
||||
|
||||
if ( messagesNotReceived > fWEClient->getPmCount())
|
||||
{
|
||||
logging::Message::Args args1;
|
||||
@@ -791,15 +849,19 @@ bool DeletePackageProcessor::receiveAll(DMLResult& result, const uint64_t unique
|
||||
break;
|
||||
|
||||
bsIn.reset(new ByteStream());
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
err = true;
|
||||
errorMsg = "Lost connection to Write Engine Server while deleting";
|
||||
throw std::runtime_error(errorMsg);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
err = (tmp8 != 0);
|
||||
*bsIn >> errorMsg;
|
||||
@@ -808,9 +870,11 @@ bool DeletePackageProcessor::receiveAll(DMLResult& result, const uint64_t unique
|
||||
//cout << "Received response from pm " << tmp32 << endl;
|
||||
pmStateDel[tmp32] = true;
|
||||
|
||||
if (err) {
|
||||
if (err)
|
||||
{
|
||||
throw std::runtime_error(errorMsg);
|
||||
}
|
||||
|
||||
msgReceived++;
|
||||
result.stats.fBlocksChanged += blocksChanged;
|
||||
result.stats.fErrorNo = tmp8;
|
||||
|
||||
@@ -71,6 +71,7 @@ namespace dmlpackageprocessor
|
||||
//cout << "In DMLPackageProcessor destructor " << this << endl;
|
||||
if (fWEClient)
|
||||
delete fWEClient;
|
||||
|
||||
if (fExeMgr)
|
||||
delete fExeMgr;
|
||||
}
|
||||
@@ -79,18 +80,22 @@ namespace dmlpackageprocessor
|
||||
void DMLPackageProcessor::cleanString(string& s)
|
||||
{
|
||||
string::size_type pos = s.find_first_not_of(" ");
|
||||
|
||||
//stripe off space and ' or '' at beginning and end
|
||||
if ( pos < s.length() )
|
||||
{
|
||||
s = s.substr( pos, s.length() - pos );
|
||||
|
||||
if ( (pos = s.find_last_of(" ")) < s.length())
|
||||
{
|
||||
s = s.substr(0, pos );
|
||||
}
|
||||
}
|
||||
|
||||
if ( s[0] == '\'')
|
||||
{
|
||||
s = s.substr(1, s.length() - 2);
|
||||
|
||||
if ( s[0] == '\'')
|
||||
s = s.substr(1, s.length() - 2);
|
||||
}
|
||||
@@ -134,6 +139,7 @@ boost::any DMLPackageProcessor::tokenizeData( execplan::CalpontSystemCatalog::SC
|
||||
dictTuple.sigValue = data.c_str();
|
||||
dictTuple.sigSize = data.length();
|
||||
int error = NO_ERROR;
|
||||
|
||||
if ( NO_ERROR != (error = fWriteEngine.tokenize( txnID, dictStruct, dictTuple)) )
|
||||
{
|
||||
retval = false;
|
||||
@@ -150,10 +156,12 @@ boost::any DMLPackageProcessor::tokenizeData( execplan::CalpontSystemCatalog::SC
|
||||
result.result = TOKEN_ERROR;
|
||||
result.message = message;
|
||||
}
|
||||
|
||||
WriteEngine::Token aToken = dictTuple.token;
|
||||
value = aToken;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
@@ -169,6 +177,7 @@ void DMLPackageProcessor::getColumnsForTable(uint32_t sessionID, std::string sch
|
||||
CalpontSystemCatalog::RIDList ridList = systemCatalogPtr->columnRIDs(tableName, true);
|
||||
|
||||
CalpontSystemCatalog::RIDList::const_iterator rid_iterator = ridList.begin();
|
||||
|
||||
while (rid_iterator != ridList.end())
|
||||
{
|
||||
CalpontSystemCatalog::ROPair roPair = *rid_iterator;
|
||||
@@ -186,6 +195,7 @@ void DMLPackageProcessor::getColumnsForTable(uint32_t sessionID, std::string sch
|
||||
char* DMLPackageProcessor::strlower(char* in)
|
||||
{
|
||||
char* p = in;
|
||||
|
||||
if (p)
|
||||
{
|
||||
while (*p)
|
||||
@@ -194,6 +204,7 @@ char* DMLPackageProcessor::strlower(char* in)
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
@@ -237,6 +248,7 @@ string DMLPackageProcessor::projectTableErrCodeToMsg(uint32_t ec)
|
||||
bool DMLPackageProcessor::validateVarbinaryVal( std::string& inStr)
|
||||
{
|
||||
bool invalid = false;
|
||||
|
||||
for (unsigned i = 0; i < inStr.length(); i++)
|
||||
{
|
||||
if (!isxdigit(inStr[i]))
|
||||
@@ -246,6 +258,7 @@ bool DMLPackageProcessor::validateVarbinaryVal( std::string & inStr)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return invalid;
|
||||
}
|
||||
|
||||
@@ -264,6 +277,7 @@ int DMLPackageProcessor::rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID
|
||||
int rc = 0;
|
||||
//Check BRM status before processing.
|
||||
rc = fDbrm->isReadWrite();
|
||||
|
||||
if (rc != 0 )
|
||||
{
|
||||
std::string brmMsg;
|
||||
@@ -282,16 +296,21 @@ int DMLPackageProcessor::rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID
|
||||
bytestream << sessionID;
|
||||
bytestream << (uint32_t)txnID.id;
|
||||
uint32_t msgRecived = 0;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->write_to_all(bytestream);
|
||||
boost::shared_ptr<messageqcpp::ByteStream> bsIn;
|
||||
bsIn.reset(new ByteStream());
|
||||
ByteStream::byte tmp8;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = NETWORK_ERROR;
|
||||
@@ -300,10 +319,13 @@ int DMLPackageProcessor::rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID
|
||||
//cout << "erroring out remove queue id " << uniqueId << endl;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = tmp8;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
char szrc[20];
|
||||
*bsIn >> errorMsg;
|
||||
errorMsg += " (WriteEngine returns error ";
|
||||
@@ -349,6 +371,7 @@ int DMLPackageProcessor::rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID
|
||||
//delete fWEClient;
|
||||
// cout << "success. remove queue id " << uniqueId << endl;
|
||||
rc = fDbrm->getUncommittedLBIDs(txnID.id, lbidList);
|
||||
|
||||
if (rc != 0 )
|
||||
{
|
||||
std::string brmMsg;
|
||||
@@ -359,11 +382,13 @@ int DMLPackageProcessor::rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID
|
||||
return rc;
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < lbidList.size(); i++) {
|
||||
for (size_t i = 0; i < lbidList.size(); i++)
|
||||
{
|
||||
range.start = lbidList[i];
|
||||
range.size = 1;
|
||||
lbidRangeList.push_back(range);
|
||||
}
|
||||
|
||||
rc = fDbrm->vbRollback(txnID.id, lbidRangeList);
|
||||
|
||||
if (rc != 0 )
|
||||
@@ -398,21 +423,27 @@ int DMLPackageProcessor::commitBatchAutoOnTransaction(uint64_t uniqueId, BRM::Tx
|
||||
ByteStream::byte tmp8;
|
||||
typedef std::vector<BRM::BulkSetHWMArg> BulkSetHWMArgs;
|
||||
std::vector<BulkSetHWMArgs> hwmArgsAllPms;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = NETWORK_ERROR;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = tmp8;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
@@ -430,16 +461,19 @@ int DMLPackageProcessor::commitBatchAutoOnTransaction(uint64_t uniqueId, BRM::Tx
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
//set hwm
|
||||
std::vector<BRM::BulkSetHWMArg> allHwm;
|
||||
BulkSetHWMArgs::const_iterator itor;
|
||||
|
||||
//cout << "total hwmArgsAllPms size " << hwmArgsAllPms.size() << endl;
|
||||
for (unsigned i = 0; i < fWEClient->getPmCount(); i++)
|
||||
{
|
||||
itor = hwmArgsAllPms[i].begin();
|
||||
|
||||
while (itor != hwmArgsAllPms[i].end())
|
||||
{
|
||||
allHwm.push_back(*itor);
|
||||
@@ -447,13 +481,16 @@ int DMLPackageProcessor::commitBatchAutoOnTransaction(uint64_t uniqueId, BRM::Tx
|
||||
itor++;
|
||||
}
|
||||
}
|
||||
|
||||
//set CP data before hwm.
|
||||
|
||||
//cout << "setting hwm allHwm size " << allHwm.size() << endl;
|
||||
vector<BRM::LBID_t> lbidList;
|
||||
|
||||
if (idbdatafile::IDBPolicy::useHdfs())
|
||||
{
|
||||
BRM::LBID_t startLbid;
|
||||
|
||||
for ( unsigned i = 0; i < allHwm.size(); i++)
|
||||
{
|
||||
rc = fDbrm->lookupLocalStartLbid(allHwm[i].oid, allHwm[i].partNum, allHwm[i].segNum, allHwm[i].hwm, startLbid);
|
||||
@@ -462,10 +499,12 @@ int DMLPackageProcessor::commitBatchAutoOnTransaction(uint64_t uniqueId, BRM::Tx
|
||||
}
|
||||
else
|
||||
fDbrm->getUncommittedExtentLBIDs(static_cast<BRM::VER_t>(txnID.id), lbidList);
|
||||
|
||||
vector<BRM::LBID_t>::const_iterator iter = lbidList.begin();
|
||||
vector<BRM::LBID_t>::const_iterator end = lbidList.end();
|
||||
BRM::CPInfoList_t cpInfos;
|
||||
BRM::CPInfo aInfo;
|
||||
|
||||
while (iter != end)
|
||||
{
|
||||
aInfo.firstLbid = *iter;
|
||||
@@ -475,6 +514,7 @@ int DMLPackageProcessor::commitBatchAutoOnTransaction(uint64_t uniqueId, BRM::Tx
|
||||
cpInfos.push_back(aInfo);
|
||||
++iter;
|
||||
}
|
||||
|
||||
std::vector<BRM::CPInfoMerge> mergeCPDataArgs;
|
||||
rc = fDbrm->bulkSetHWMAndCP(allHwm, cpInfos, mergeCPDataArgs, txnID.id);
|
||||
fDbrm->takeSnapshot();
|
||||
@@ -487,7 +527,8 @@ int DMLPackageProcessor::commitBatchAutoOnTransaction(uint64_t uniqueId, BRM::Tx
|
||||
TablelockData* tablelockData = TablelockData::makeTablelockData(fSessionID);
|
||||
uint64_t tablelockId = tablelockData->getTablelockId(tableOid);
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
stateChanged = fDbrm->changeState(tablelockId, BRM::CLEANUP);
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -506,17 +547,21 @@ int DMLPackageProcessor::commitBatchAutoOnTransaction(uint64_t uniqueId, BRM::Tx
|
||||
bytestream << tableOid;
|
||||
msgRecived = 0;
|
||||
fWEClient->write_to_all(bytestream);
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
msgRecived++;
|
||||
}
|
||||
@@ -539,6 +584,7 @@ int DMLPackageProcessor::rollBackBatchAutoOnTransaction(uint64_t uniqueId, BRM::
|
||||
string ownerName ("DMLProc batchinsert");
|
||||
uint64_t tableLockId = 0;
|
||||
int rc = 0;
|
||||
|
||||
for (; idx < tableLocks.size(); idx++)
|
||||
{
|
||||
if ((tableLocks[idx].ownerName == ownerName) && (tableLocks[idx].tableOID == tableOid))
|
||||
@@ -555,6 +601,7 @@ int DMLPackageProcessor::rollBackBatchAutoOnTransaction(uint64_t uniqueId, BRM::
|
||||
// want to do anything.
|
||||
return rc;
|
||||
}
|
||||
|
||||
//cout << "sending to WES" << endl;
|
||||
ByteStream bytestream;
|
||||
fWEClient->addQueue(uniqueId);
|
||||
@@ -569,12 +616,15 @@ int DMLPackageProcessor::rollBackBatchAutoOnTransaction(uint64_t uniqueId, BRM::
|
||||
boost::shared_ptr<messageqcpp::ByteStream> bsIn;
|
||||
bsIn.reset(new ByteStream());
|
||||
ByteStream::byte tmp8;
|
||||
|
||||
//cout << "waiting for reply from WES" << endl;
|
||||
while (1)
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = NETWORK_ERROR;
|
||||
@@ -582,10 +632,13 @@ int DMLPackageProcessor::rollBackBatchAutoOnTransaction(uint64_t uniqueId, BRM::
|
||||
//cout << "erroring out remove queue id " << uniqueId << endl;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = tmp8;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
//cout << "erroring out remove queue id " << uniqueId << endl;
|
||||
@@ -595,11 +648,14 @@ int DMLPackageProcessor::rollBackBatchAutoOnTransaction(uint64_t uniqueId, BRM::
|
||||
msgRecived++;
|
||||
}
|
||||
}
|
||||
|
||||
if (rc == 0) //change table lock state
|
||||
{
|
||||
bool stateChanged = true;
|
||||
|
||||
//cout << "changing tablelock state" << endl;
|
||||
try {
|
||||
try
|
||||
{
|
||||
stateChanged = fDbrm->changeState(tableLockId, BRM::CLEANUP);
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -607,6 +663,7 @@ int DMLPackageProcessor::rollBackBatchAutoOnTransaction(uint64_t uniqueId, BRM::
|
||||
errorMsg = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
stateChanged = false;
|
||||
}
|
||||
|
||||
if (!stateChanged)
|
||||
{
|
||||
rc = 1;
|
||||
@@ -615,28 +672,34 @@ int DMLPackageProcessor::rollBackBatchAutoOnTransaction(uint64_t uniqueId, BRM::
|
||||
|
||||
if ( rc != 0 )
|
||||
return rc;
|
||||
|
||||
bytestream.restart();
|
||||
bytestream << (ByteStream::byte)WE_SVR_BATCH_AUTOON_REMOVE_META;
|
||||
bytestream << uniqueId;
|
||||
bytestream << tableOid;
|
||||
msgRecived = 0;
|
||||
fWEClient->write_to_all(bytestream);
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
//cout << "erroring out remove queue id " << uniqueId << endl;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
msgRecived++;
|
||||
}
|
||||
}
|
||||
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
return rc;
|
||||
}
|
||||
@@ -653,6 +716,7 @@ int DMLPackageProcessor::commitBatchAutoOffTransaction(uint64_t uniqueId, BRM::T
|
||||
boost::shared_ptr<messageqcpp::ByteStream> bsIn;
|
||||
bsIn.reset(new ByteStream());
|
||||
ByteStream::byte tmp8;
|
||||
|
||||
for (; idx < tableLocks.size(); idx++)
|
||||
{
|
||||
if ((tableLocks[idx].ownerName == ownerName) && (tableLocks[idx].tableOID == tableOid))
|
||||
@@ -671,8 +735,10 @@ int DMLPackageProcessor::commitBatchAutoOffTransaction(uint64_t uniqueId, BRM::T
|
||||
}
|
||||
|
||||
bool stateChanged = true;
|
||||
|
||||
//cout << "changing tablelock state" << endl;
|
||||
try {
|
||||
try
|
||||
{
|
||||
stateChanged = fDbrm->changeState(tableLockId, BRM::CLEANUP);
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -680,10 +746,12 @@ int DMLPackageProcessor::commitBatchAutoOffTransaction(uint64_t uniqueId, BRM::T
|
||||
errorMsg = IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE);
|
||||
stateChanged = false;
|
||||
}
|
||||
|
||||
if (!stateChanged)
|
||||
{
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
if ( rc != 0 )
|
||||
return rc;
|
||||
|
||||
@@ -694,21 +762,26 @@ int DMLPackageProcessor::commitBatchAutoOffTransaction(uint64_t uniqueId, BRM::T
|
||||
bytestream << tableOid;
|
||||
uint32_t msgRecived = 0;
|
||||
fWEClient->write_to_all(bytestream);
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
msgRecived++;
|
||||
}
|
||||
}
|
||||
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
return rc;
|
||||
}
|
||||
@@ -734,17 +807,22 @@ int DMLPackageProcessor::rollBackBatchAutoOffTransaction(uint64_t uniqueId, BRM:
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = NETWORK_ERROR;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = tmp8;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
break;
|
||||
@@ -773,21 +851,28 @@ int DMLPackageProcessor::flushDataFiles (int rcIn, std::map<FID,FID> & columnOid
|
||||
int rc = 0;
|
||||
ByteStream::byte tmp8;
|
||||
std::string errorMsg;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = NETWORK_ERROR;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = tmp8;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
break;
|
||||
}
|
||||
@@ -796,7 +881,8 @@ int DMLPackageProcessor::flushDataFiles (int rcIn, std::map<FID,FID> & columnOid
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception&) {
|
||||
catch (std::exception&)
|
||||
{
|
||||
}
|
||||
|
||||
return rc;
|
||||
@@ -817,21 +903,28 @@ int DMLPackageProcessor::endTransaction (uint64_t uniqueId, BRM::TxnID txnID, bo
|
||||
int rc = 0;
|
||||
ByteStream::byte tmp8;
|
||||
std::string errorMsg;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = NETWORK_ERROR;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
rc = tmp8;
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
break;
|
||||
}
|
||||
@@ -840,7 +933,8 @@ int DMLPackageProcessor::endTransaction (uint64_t uniqueId, BRM::TxnID txnID, bo
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception&) {
|
||||
catch (std::exception&)
|
||||
{
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
@@ -130,7 +130,13 @@ public:
|
||||
unsigned month : 4;
|
||||
unsigned year : 16;
|
||||
// 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
|
||||
*/
|
||||
@@ -144,15 +150,24 @@ public:
|
||||
unsigned month : 4;
|
||||
unsigned year : 16;
|
||||
// NULL column value = 0xFFFFFFFFFFFFFFFE
|
||||
dateTime( ) { year = 0xFFFF; month = 0xF; day = 0x3F; hour = 0x3F; minute = 0x3F; second = 0x3F;
|
||||
msecond = 0xFFFFE; }
|
||||
dateTime( )
|
||||
{
|
||||
year = 0xFFFF;
|
||||
month = 0xF;
|
||||
day = 0x3F;
|
||||
hour = 0x3F;
|
||||
minute = 0x3F;
|
||||
second = 0x3F;
|
||||
msecond = 0xFFFFE;
|
||||
}
|
||||
};
|
||||
|
||||
/** @brief ctor
|
||||
*/
|
||||
DMLPackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : fEC(0), DMLLoggingId(21), fRollbackPending(false), fDebugLevel(NONE)
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
fWEClient = new WriteEngine::WEClients(WriteEngine::WEClients::DMLPROC);
|
||||
//std::cout << "In DMLPackageProcessor constructor " << this << std::endl;
|
||||
fPMCount = fWEClient->getPmCount();
|
||||
@@ -179,22 +194,34 @@ public:
|
||||
|
||||
/** @brief Is it required to debug
|
||||
*/
|
||||
inline const bool isDebug( const DebugLevel level ) const { return level <= fDebugLevel; }
|
||||
inline const bool isDebug( const DebugLevel level ) const
|
||||
{
|
||||
return level <= fDebugLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get debug level
|
||||
*/
|
||||
inline const DebugLevel getDebugLevel() const { return fDebugLevel; }
|
||||
inline const DebugLevel getDebugLevel() const
|
||||
{
|
||||
return fDebugLevel;
|
||||
}
|
||||
//int rollBackTransaction(uint64_t uniqueId, uint32_t txnID, uint32_t sessionID, std::string & errorMsg);
|
||||
/**
|
||||
* @brief Set debug level
|
||||
*/
|
||||
inline void setDebugLevel( const DebugLevel level ) { fDebugLevel = level; }
|
||||
inline void setDebugLevel( const DebugLevel level )
|
||||
{
|
||||
fDebugLevel = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Distributed Engine Comm object
|
||||
*/
|
||||
inline void setEngineComm(joblist::DistributedEngineComm* ec) { fEC = ec; }
|
||||
inline void setEngineComm(joblist::DistributedEngineComm* ec)
|
||||
{
|
||||
fEC = ec;
|
||||
}
|
||||
|
||||
/** @brief process the dml package
|
||||
*
|
||||
@@ -202,7 +229,10 @@ public:
|
||||
*/
|
||||
virtual DMLResult processPackage(dmlpackage::CalpontDMLPackage& cpackage) = 0;
|
||||
|
||||
inline void setRM ( joblist::ResourceManager* frm) { fRM = frm; };
|
||||
inline void setRM ( joblist::ResourceManager* frm)
|
||||
{
|
||||
fRM = frm;
|
||||
};
|
||||
|
||||
EXPORT int rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, std::string& errorMsg);
|
||||
|
||||
@@ -262,11 +292,17 @@ public:
|
||||
|
||||
/** @brief Access the rollback pending flag
|
||||
*/
|
||||
bool getRollbackPending() {return fRollbackPending;}
|
||||
bool getRollbackPending()
|
||||
{
|
||||
return fRollbackPending;
|
||||
}
|
||||
|
||||
/** @brief Set the rollback pending flag
|
||||
*/
|
||||
void setRollbackPending(bool rollback) {fRollbackPending = rollback;}
|
||||
void setRollbackPending(bool rollback)
|
||||
{
|
||||
fRollbackPending = rollback;
|
||||
}
|
||||
|
||||
protected:
|
||||
/** @brief update the indexes on the target table
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
|
||||
using namespace dmlpackage;
|
||||
|
||||
namespace dmlpackageprocessor {
|
||||
namespace dmlpackageprocessor
|
||||
{
|
||||
|
||||
DMLPackageProcessor* DMLPackageProcessorFactory::
|
||||
makePackageProcessor(int packageType, dmlpackage::CalpontDMLPackage& cpackage)
|
||||
|
||||
@@ -33,12 +33,14 @@
|
||||
#define EXPORT
|
||||
#endif
|
||||
|
||||
namespace dmlpackageprocessor {
|
||||
namespace dmlpackageprocessor
|
||||
{
|
||||
|
||||
/** @brief create a DMLPackageProcessor object from a CalpontDMLPackage object
|
||||
*
|
||||
*/
|
||||
class DMLPackageProcessorFactory {
|
||||
class DMLPackageProcessorFactory
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@@ -80,8 +80,10 @@ namespace dmlpackageprocessor
|
||||
//std::map<uint32_t,uint32_t> oids;
|
||||
VERBOSE_INFO("Processing Insert DML Package...");
|
||||
uint64_t uniqueId = 0;
|
||||
|
||||
//Bug 5070. Added exception handling
|
||||
try {
|
||||
try
|
||||
{
|
||||
uniqueId = fDbrm->getUnique64();
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
@@ -106,6 +108,7 @@ namespace dmlpackageprocessor
|
||||
fSessionManager.rolledback(txnid);
|
||||
return result;
|
||||
}
|
||||
|
||||
uint64_t tableLockId = 0;
|
||||
int rc = 0;
|
||||
std::string errorMsg;
|
||||
@@ -127,6 +130,7 @@ namespace dmlpackageprocessor
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||
TablelockData* tablelockData = TablelockData::makeTablelockData(fSessionID);
|
||||
|
||||
if (0 != tablePtr)
|
||||
{
|
||||
//check table lock
|
||||
@@ -137,6 +141,7 @@ namespace dmlpackageprocessor
|
||||
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;
|
||||
@@ -146,7 +151,8 @@ namespace dmlpackageprocessor
|
||||
std::string processName("DMLProc");
|
||||
int i = 0;
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnId, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -172,14 +178,18 @@ namespace dmlpackageprocessor
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
#else
|
||||
struct timespec abs_ts;
|
||||
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
processID = ::getpid();
|
||||
txnId = txnid.id;
|
||||
sessionId = fSessionID;
|
||||
@@ -194,6 +204,7 @@ namespace dmlpackageprocessor
|
||||
if (tableLockId > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i >= numTries) //error out
|
||||
{
|
||||
result.result = INSERT_ERROR;
|
||||
@@ -220,9 +231,11 @@ namespace dmlpackageprocessor
|
||||
// 3. Map the selected DBRoot to the corresponding PM
|
||||
CalpontSystemCatalog::RIDList ridList = systemCatalogPtr->columnRIDs(tableName, true);
|
||||
std::vector<BRM::EmDbRootHWMInfo_v> allInfo (pms.size());
|
||||
|
||||
for (unsigned i = 0; i < pms.size(); i++)
|
||||
{
|
||||
rc = fDbrm->getDbRootHWMInfo((ridList[0].objnum), pms[i], allInfo[i]);
|
||||
|
||||
if ( rc != 0 ) //@Bug 4760.
|
||||
{
|
||||
result.result = INSERT_ERROR;
|
||||
@@ -236,6 +249,7 @@ namespace dmlpackageprocessor
|
||||
// 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];
|
||||
@@ -260,6 +274,7 @@ namespace dmlpackageprocessor
|
||||
|
||||
// Select the PM to receive the row
|
||||
uint32_t dbroot;
|
||||
|
||||
if (tmpSet)
|
||||
{
|
||||
dbroot = tmp.dbRoot;
|
||||
@@ -295,6 +310,7 @@ namespace dmlpackageprocessor
|
||||
boost::shared_ptr<messageqcpp::ByteStream> bsIn;
|
||||
|
||||
ByteStream::byte rc1;
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->write(bytestream, (uint32_t)pmNum);
|
||||
@@ -304,14 +320,18 @@ cout << "Single insert sending WE_SVR_SINGLE_INSERT to pm " << pmNum << endl;
|
||||
|
||||
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 {
|
||||
else
|
||||
{
|
||||
*bsIn >> rc1;
|
||||
if (rc1 != 0) {
|
||||
|
||||
if (rc1 != 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
rc = rc1;
|
||||
}
|
||||
@@ -334,6 +354,7 @@ cout << "Single insert got exception" << ex.what() << endl;
|
||||
cout << "Single insert got unknown exception" << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Log the insert statement.
|
||||
LoggingID logid( DMLLoggingId, fSessionID, txnid.id);
|
||||
logging::Message::Args args1;
|
||||
|
||||
@@ -48,7 +48,8 @@ class InsertPackageProcessor : public DMLPackageProcessor
|
||||
{
|
||||
|
||||
public:
|
||||
InsertPackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : DMLPackageProcessor(aDbrm, sid) {
|
||||
InsertPackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : DMLPackageProcessor(aDbrm, sid)
|
||||
{
|
||||
}
|
||||
/** @brief process an InsertDMLPackage
|
||||
*
|
||||
|
||||
@@ -59,6 +59,7 @@ void TablelockData::removeTablelockData(uint32_t sessionID)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(map_mutex);
|
||||
TablelockDataMap::iterator it = fTablelockDataMap.find(sessionID);
|
||||
|
||||
if (it != fTablelockDataMap.end())
|
||||
{
|
||||
delete (*it).second;
|
||||
@@ -84,10 +85,12 @@ uint64_t TablelockData::getTablelockId(uint32_t tableOid)
|
||||
boost::mutex::scoped_lock lk(fOIDTablelock);
|
||||
uint64_t tablelockId = 0;
|
||||
OIDTablelock::iterator it = fOIDTablelockMap.find(tableOid);
|
||||
|
||||
if (it != fOIDTablelockMap.end())
|
||||
{
|
||||
tablelockId = it->second;
|
||||
}
|
||||
|
||||
return tablelockId;
|
||||
}
|
||||
|
||||
|
||||
@@ -458,9 +458,11 @@ public:
|
||||
|
||||
ddlpackage::SqlParser parser;
|
||||
parser.Parse(createText.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ddlpackage::ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
ddlpackageprocessor::CreateTableProcessor processor;
|
||||
@@ -493,9 +495,11 @@ void destroySemaphores()
|
||||
|
||||
semkey = 0x2149bdd2;
|
||||
sems = semget(semkey, 2, 0666);
|
||||
|
||||
if (sems != -1)
|
||||
{
|
||||
err = semctl(sems, 0, IPC_RMID);
|
||||
|
||||
if (err == -1)
|
||||
perror("tdriver: semctl");
|
||||
}
|
||||
@@ -508,9 +512,11 @@ void destroyShmseg()
|
||||
|
||||
shmkey = 0x2149bdd2;
|
||||
shms = shmget(shmkey, 0, 0666);
|
||||
|
||||
if (shms != -1)
|
||||
{
|
||||
err = shmctl(shms, IPC_RMID, NULL);
|
||||
|
||||
if (err == -1 && errno != EINVAL)
|
||||
{
|
||||
perror("tdriver: shmctl");
|
||||
@@ -720,6 +726,7 @@ public:
|
||||
|
||||
pkgProcPtr->setDebugLevel(DMLPackageProcessor::VERBOSE);
|
||||
DMLPackageProcessor::DMLResult result = pkgProcPtr->processPackage( *pObject );
|
||||
|
||||
if ( DMLPackageProcessor::NO_ERROR != result.result )
|
||||
{
|
||||
cout << "Insert failed!" << endl;
|
||||
@@ -822,6 +829,7 @@ public:
|
||||
|
||||
ml.logDebugMessage( result.message );
|
||||
}
|
||||
|
||||
delete pkgProcPtr;
|
||||
delete pObject;
|
||||
|
||||
@@ -866,6 +874,7 @@ public:
|
||||
ByteStream bytestream;
|
||||
|
||||
std::vector<std::string>::const_iterator iter = commands.begin();
|
||||
|
||||
while (iter != commands.end())
|
||||
{
|
||||
std::string command = *iter;
|
||||
@@ -873,6 +882,7 @@ public:
|
||||
|
||||
VendorDMLStatement dml_command(command, 1);
|
||||
CalpontDMLPackage* dmlCommandPkgPtr = CalpontDMLFactory::makeCalpontDMLPackage(dml_command);
|
||||
|
||||
if (dmlCommandPkgPtr)
|
||||
{
|
||||
cout << "CalpontDMLFactory::makeCalpontDMLPackage: success" << endl;
|
||||
@@ -921,6 +931,7 @@ public:
|
||||
|
||||
ml.logDebugMessage( result.message );
|
||||
}
|
||||
|
||||
delete pkgProcPtr;
|
||||
delete pObject;
|
||||
}
|
||||
|
||||
99
dbcon/dmlpackageproc/updatepackageprocessor.cpp
Executable file → Normal file
99
dbcon/dmlpackageproc/updatepackageprocessor.cpp
Executable file → Normal file
@@ -80,8 +80,10 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
VERBOSE_INFO("Processing Update DML Package...");
|
||||
TablelockData* tablelockData = TablelockData::makeTablelockData(fSessionID);
|
||||
uint64_t uniqueId = 0;
|
||||
|
||||
//Bug 5070. Added exception handling
|
||||
try {
|
||||
try
|
||||
{
|
||||
uniqueId = fDbrm->getUnique64();
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
@@ -116,6 +118,7 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
tableName.table = tablePtr->get_TableName();
|
||||
fWEClient->addQueue(uniqueId);
|
||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||
|
||||
//#ifdef PROFILE
|
||||
// StopWatch timer;
|
||||
//#endif
|
||||
@@ -134,10 +137,12 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
|
||||
VERBOSE_INFO("The table name is:");
|
||||
VERBOSE_INFO(tablePtr->get_TableName());
|
||||
|
||||
if (0 != tablePtr)
|
||||
{
|
||||
// get the row(s) from the table
|
||||
RowList rows = tablePtr->get_RowList();
|
||||
|
||||
if (rows.size() == 0)
|
||||
{
|
||||
SUMMARY_INFO("No row to update!");
|
||||
@@ -147,6 +152,7 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
|
||||
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;
|
||||
@@ -158,12 +164,14 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
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 {
|
||||
try
|
||||
{
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnId, BRM::LOADING );
|
||||
}
|
||||
catch (std::exception&)
|
||||
@@ -189,14 +197,18 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
Sleep(rm_ts.tv_sec * 1000);
|
||||
#else
|
||||
struct timespec abs_ts;
|
||||
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
processID = ::getpid();
|
||||
txnId = txnid.id;
|
||||
sessionId = fSessionID;
|
||||
@@ -211,6 +223,7 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
if (tableLockId > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i >= numTries) //error out
|
||||
{
|
||||
result.result = UPDATE_ERROR;
|
||||
@@ -224,12 +237,14 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//cout << " tablelock is obtained with id " << tableLockId << endl;
|
||||
tablelockData->setTablelock(roPair.objnum, tableLockId);
|
||||
//@Bug 4491 start AI sequence for autoincrement column
|
||||
const CalpontSystemCatalog::RIDList ridList = systemCatalogPtr->columnRIDs(tableName);
|
||||
CalpontSystemCatalog::RIDList::const_iterator rid_iterator = ridList.begin();
|
||||
CalpontSystemCatalog::ColType colType;
|
||||
|
||||
while (rid_iterator != ridList.end())
|
||||
{
|
||||
// If user hit ctrl+c in the mysql console, this will be true.
|
||||
@@ -238,8 +253,10 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
result.result = JOB_CANCELED;
|
||||
break;
|
||||
}
|
||||
|
||||
CalpontSystemCatalog::ROPair roPair = *rid_iterator;
|
||||
colType = systemCatalogPtr->colType(roPair.objnum);
|
||||
|
||||
if (colType.autoincrement)
|
||||
{
|
||||
try
|
||||
@@ -254,10 +271,12 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
throw std::runtime_error(ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
++rid_iterator;
|
||||
}
|
||||
|
||||
uint64_t rowsProcessed = 0;
|
||||
|
||||
if (!fRollbackPending)
|
||||
{
|
||||
rowsProcessed = fixUpRows(cpackage, result, uniqueId, roPair.objnum);
|
||||
@@ -291,6 +310,7 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
{
|
||||
result.result = UPDATE_ERROR;
|
||||
}
|
||||
|
||||
result.message = Message(ex.what());
|
||||
result.rowCount = 0;
|
||||
LoggingID logid( DMLLoggingId, fSessionID, txnid.id);
|
||||
@@ -323,16 +343,19 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
logging::Logger logger(logid.fSubsysID);
|
||||
logger.logMessage(LOG_TYPE_DEBUG, msg, logid);
|
||||
}
|
||||
|
||||
// timer.finish();
|
||||
//@Bug 1886,2870 Flush VM cache only once per statement. send to all PMs.
|
||||
//WriteEngineWrapper writeEngine;
|
||||
std::map<uint32_t, uint32_t> oids;
|
||||
int rc = 0;
|
||||
|
||||
if (result.result == NO_ERROR || result.result == IDBRANGE_WARNING)
|
||||
{
|
||||
if ((rc = flushDataFiles(NO_ERROR, oids, uniqueId, txnid, roPair.objnum)) != NO_ERROR)
|
||||
{
|
||||
cerr << "UpdatePackageProcessor::processPackage: write data to disk failed" << endl;
|
||||
|
||||
if (!fRollbackPending)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
@@ -347,6 +370,7 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
result.message = message;
|
||||
result.rowCount = 0;
|
||||
}
|
||||
|
||||
rc = endTransaction(uniqueId, txnid, false);
|
||||
}
|
||||
else
|
||||
@@ -355,6 +379,7 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
rc = endTransaction(uniqueId, txnid, false);
|
||||
else
|
||||
rc = endTransaction(uniqueId, txnid, true);
|
||||
|
||||
if (( rc != NO_ERROR) && (!fRollbackPending))
|
||||
{
|
||||
logging::Message::Args args;
|
||||
@@ -378,6 +403,7 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage)
|
||||
rc = flushDataFiles(result.result, oids, uniqueId, txnid, roPair.objnum);
|
||||
rc = endTransaction(uniqueId, txnid, false);
|
||||
}
|
||||
|
||||
//timer.finish();
|
||||
|
||||
/* if (result.result != IDBRANGE_WARNING)
|
||||
@@ -415,14 +441,17 @@ uint64_t UpdatePackageProcessor::fixUpRows(dmlpackage::CalpontDMLPackage& cpacka
|
||||
string emsg;
|
||||
string emsgStr;
|
||||
bool err = false;
|
||||
|
||||
//boost::scoped_ptr<messageqcpp::MessageQueueClient> fExeMgr;
|
||||
//fExeMgr.reset( new messageqcpp::MessageQueueClient("ExeMgr1"));
|
||||
try {
|
||||
try
|
||||
{
|
||||
|
||||
for (unsigned i = 0; i < fPMs.size(); i++)
|
||||
{
|
||||
pmState[fPMs[i]] = true;
|
||||
}
|
||||
|
||||
//timer.start("ExeMgr");
|
||||
fExeMgr->write(msg);
|
||||
fExeMgr->write(*(cpackage.get_ExecutionPlan()));
|
||||
@@ -430,9 +459,11 @@ uint64_t UpdatePackageProcessor::fixUpRows(dmlpackage::CalpontDMLPackage& cpacka
|
||||
msg.restart();
|
||||
emsgBs.restart();
|
||||
msg = fExeMgr->read(); //error handling
|
||||
|
||||
if (msg.length() == 4)
|
||||
{
|
||||
msg >> qb;
|
||||
|
||||
if (qb != 0)
|
||||
err = true;
|
||||
}
|
||||
@@ -441,6 +472,7 @@ uint64_t UpdatePackageProcessor::fixUpRows(dmlpackage::CalpontDMLPackage& cpacka
|
||||
qb = 999;
|
||||
err = true;
|
||||
}
|
||||
|
||||
if (err)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
@@ -455,6 +487,7 @@ uint64_t UpdatePackageProcessor::fixUpRows(dmlpackage::CalpontDMLPackage& cpacka
|
||||
}
|
||||
|
||||
emsgBs = fExeMgr->read();
|
||||
|
||||
if (emsgBs.length() == 0)
|
||||
{
|
||||
logging::Message::Args args;
|
||||
@@ -469,16 +502,19 @@ uint64_t UpdatePackageProcessor::fixUpRows(dmlpackage::CalpontDMLPackage& cpacka
|
||||
}
|
||||
|
||||
emsgBs >> emsgStr;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (fRollbackPending)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
msg.restart();
|
||||
msgBk.restart();
|
||||
msg = fExeMgr->read();
|
||||
msgBk = msg;
|
||||
|
||||
if ( msg.length() == 0 )
|
||||
{
|
||||
cerr << "UpdatePackageProcessor::processPackage::fixupRows" << endl;
|
||||
@@ -512,10 +548,12 @@ uint64_t UpdatePackageProcessor::fixUpRows(dmlpackage::CalpontDMLPackage& cpacka
|
||||
//timer.stop("Meta");
|
||||
continue;
|
||||
}
|
||||
|
||||
rgData.deserialize(msg, true);
|
||||
rowGroup->setData(&rgData);
|
||||
//rowGroup->setData(const_cast<uint8_t*>(msg.buf()));
|
||||
err = (rowGroup->getStatus() != 0);
|
||||
|
||||
if (err)
|
||||
{
|
||||
//msgBk.advance(rowGroup->getDataSize());
|
||||
@@ -540,10 +578,12 @@ uint64_t UpdatePackageProcessor::fixUpRows(dmlpackage::CalpontDMLPackage& cpacka
|
||||
//err = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (rowGroup->getRGData() == NULL)
|
||||
{
|
||||
msg.restart();
|
||||
}
|
||||
|
||||
if (rowGroup->getRowCount() == 0) //done fetching
|
||||
{
|
||||
//timer.finish();
|
||||
@@ -552,16 +592,20 @@ uint64_t UpdatePackageProcessor::fixUpRows(dmlpackage::CalpontDMLPackage& cpacka
|
||||
//return rowsProcessed;
|
||||
break;
|
||||
}
|
||||
|
||||
if (rowGroup->getBaseRid() == (uint64_t) (-1))
|
||||
{
|
||||
continue; // @bug4247, not valid row ids, may from small side outer
|
||||
}
|
||||
|
||||
dbroot = rowGroup->getDBRoot();
|
||||
//cout << "dbroot in the rowgroup is " << dbroot << endl;
|
||||
//timer.start("processRowgroup");
|
||||
err = processRowgroup(msgBk, result, uniqueId, cpackage, pmState, metaData, dbroot);
|
||||
|
||||
//timer.stop("processRowgroup");
|
||||
if (err) {
|
||||
if (err)
|
||||
{
|
||||
//timer.finish();
|
||||
LoggingID logid( DMLLoggingId, fSessionID, cpackage.get_TxnID());
|
||||
logging::Message::Args args1;
|
||||
@@ -586,9 +630,11 @@ uint64_t UpdatePackageProcessor::fixUpRows(dmlpackage::CalpontDMLPackage& cpacka
|
||||
//err = true;
|
||||
break;
|
||||
}
|
||||
|
||||
rowsProcessed += rowGroup->getRowCount();
|
||||
}
|
||||
}
|
||||
|
||||
if (fRollbackPending)
|
||||
{
|
||||
err = true;
|
||||
@@ -610,6 +656,7 @@ uint64_t UpdatePackageProcessor::fixUpRows(dmlpackage::CalpontDMLPackage& cpacka
|
||||
DMLResult tmpResult;
|
||||
receiveAll( tmpResult, uniqueId, fPMs, pmState, tableOid);
|
||||
}
|
||||
|
||||
// get stats from ExeMgr
|
||||
if (!err)
|
||||
{
|
||||
@@ -631,6 +678,7 @@ uint64_t UpdatePackageProcessor::fixUpRows(dmlpackage::CalpontDMLPackage& cpacka
|
||||
msg << qb;
|
||||
fExeMgr->write(msg);
|
||||
}
|
||||
|
||||
return rowsProcessed;
|
||||
//stats.insert();
|
||||
}
|
||||
@@ -666,6 +714,7 @@ uint64_t UpdatePackageProcessor::fixUpRows(dmlpackage::CalpontDMLPackage& cpacka
|
||||
fExeMgr->write(msg);
|
||||
return rowsProcessed;
|
||||
}
|
||||
|
||||
//timer.finish();
|
||||
return rowsProcessed;
|
||||
}
|
||||
@@ -696,18 +745,23 @@ bool UpdatePackageProcessor::processRowgroup(ByteStream & aRowGroup, DMLResult&
|
||||
{
|
||||
cpackage.write(bytestream);
|
||||
fWEClient->write_to_all(bytestream);
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (msgRecived == fWEClient->getPmCount())
|
||||
break;
|
||||
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = true;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
|
||||
if (tmp8 > 0)
|
||||
{
|
||||
*bsIn >> errorMsg;
|
||||
@@ -725,12 +779,14 @@ bool UpdatePackageProcessor::processRowgroup(ByteStream & aRowGroup, DMLResult&
|
||||
msgRecived++;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (pmState[pmNum])
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
//cout << "sending rows to pm " << pmNum << " with msg length " << bytestream.length() << endl;
|
||||
fWEClient->write(bytestream, (uint32_t)pmNum);
|
||||
pmState[pmNum] = false;
|
||||
@@ -763,8 +819,11 @@ bool UpdatePackageProcessor::processRowgroup(ByteStream & aRowGroup, DMLResult&
|
||||
while (1)
|
||||
{
|
||||
bsIn.reset(new ByteStream());
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
rc = true;
|
||||
@@ -775,6 +834,7 @@ bool UpdatePackageProcessor::processRowgroup(ByteStream & aRowGroup, DMLResult&
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
*bsIn >> errorMsg;
|
||||
|
||||
if (tmp8 == IDBRANGE_WARNING)
|
||||
{
|
||||
result.result = IDBRANGE_WARNING;
|
||||
@@ -789,15 +849,18 @@ bool UpdatePackageProcessor::processRowgroup(ByteStream & aRowGroup, DMLResult&
|
||||
result.stats.fErrorNo = tmp8;
|
||||
rc = (tmp8 != 0);
|
||||
}
|
||||
|
||||
*bsIn >> tmp32;
|
||||
//cout << "Received response from pm " << tmp32 << endl;
|
||||
pmState[tmp32] = true;
|
||||
*bsIn >> blocksChanged;
|
||||
result.stats.fBlocksChanged += blocksChanged;
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
throw std::runtime_error(errorMsg);
|
||||
}
|
||||
|
||||
if (tmp32 == (uint32_t)pmNum)
|
||||
{
|
||||
//cout << "sending rows to pm " << pmNum << " with msg length " << bytestream.length() << endl;
|
||||
@@ -833,6 +896,7 @@ bool UpdatePackageProcessor::processRowgroup(ByteStream & aRowGroup, DMLResult&
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -842,6 +906,7 @@ bool UpdatePackageProcessor::receiveAll(DMLResult& result, const uint64_t unique
|
||||
//check how many message we need to receive
|
||||
uint32_t messagesNotReceived = 0;
|
||||
bool err = false;
|
||||
|
||||
for (unsigned i = 0; i < fPMs.size(); i++)
|
||||
{
|
||||
if (!pmState[fPMs[i]])
|
||||
@@ -852,9 +917,11 @@ bool UpdatePackageProcessor::receiveAll(DMLResult& result, const uint64_t unique
|
||||
ByteStream::byte tmp8;
|
||||
string errorMsg;
|
||||
uint32_t msgReceived = 0;
|
||||
|
||||
if (messagesNotReceived > 0)
|
||||
{
|
||||
LoggingID logid( DMLLoggingId, fSessionID, fSessionID);
|
||||
|
||||
if ( messagesNotReceived > fWEClient->getPmCount())
|
||||
{
|
||||
logging::Message::Args args1;
|
||||
@@ -887,17 +954,22 @@ bool UpdatePackageProcessor::receiveAll(DMLResult& result, const uint64_t unique
|
||||
break;
|
||||
|
||||
bsIn.reset(new ByteStream());
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
fWEClient->read(uniqueId, bsIn);
|
||||
|
||||
if ( bsIn->length() == 0 ) //read error
|
||||
{
|
||||
err = true;
|
||||
errorMsg = "Lost connection to Write Engine Server while updating";
|
||||
throw std::runtime_error(errorMsg);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
*bsIn >> tmp8;
|
||||
*bsIn >> errorMsg;
|
||||
|
||||
if (tmp8 == IDBRANGE_WARNING)
|
||||
{
|
||||
result.result = IDBRANGE_WARNING;
|
||||
@@ -912,13 +984,17 @@ bool UpdatePackageProcessor::receiveAll(DMLResult& result, const uint64_t unique
|
||||
result.stats.fErrorNo = tmp8;
|
||||
err = (tmp8 != 0);
|
||||
}
|
||||
|
||||
*bsIn >> tmp32;
|
||||
*bsIn >> blocksChanged;
|
||||
//cout << "Received response from pm " << tmp32 << endl;
|
||||
pmState[tmp32] = true;
|
||||
if (err) {
|
||||
|
||||
if (err)
|
||||
{
|
||||
throw std::runtime_error(errorMsg);
|
||||
}
|
||||
|
||||
msgReceived++;
|
||||
result.stats.fBlocksChanged += blocksChanged;
|
||||
}
|
||||
@@ -949,6 +1025,7 @@ bool UpdatePackageProcessor::receiveAll(DMLResult& result, const uint64_t unique
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
} // namespace dmlpackageprocessor
|
||||
|
||||
@@ -45,7 +45,8 @@ class UpdatePackageProcessor : public DMLPackageProcessor
|
||||
{
|
||||
|
||||
public:
|
||||
UpdatePackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : DMLPackageProcessor(aDbrm, sid) {
|
||||
UpdatePackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : DMLPackageProcessor(aDbrm, sid)
|
||||
{
|
||||
}
|
||||
/** @brief process an UpdateDMLPackage
|
||||
*
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
#ifndef DBCON_CALPONTSYSTEMCATALOG_H
|
||||
#define DBCON_CALPONTSYSTEMCATALOG_H
|
||||
|
||||
namespace dbcon {
|
||||
namespace dbcon
|
||||
{
|
||||
|
||||
class CalpontSystemCatalog
|
||||
{
|
||||
|
||||
@@ -43,7 +43,8 @@ using namespace joblist;
|
||||
#include "functioncolumn.h"
|
||||
#include "objectreader.h"
|
||||
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
|
||||
void getAggCols(execplan::ParseTree* n, void* obj)
|
||||
{
|
||||
@@ -54,6 +55,7 @@ void getAggCols(execplan::ParseTree* n, void* obj)
|
||||
ArithmeticColumn* ac = dynamic_cast<ArithmeticColumn*>(tn);
|
||||
SimpleFilter* sf = dynamic_cast<SimpleFilter*>(tn);
|
||||
ConstantFilter* cf = dynamic_cast<ConstantFilter*>(tn);
|
||||
|
||||
if (sc)
|
||||
{
|
||||
list->push_back(sc);
|
||||
@@ -161,13 +163,17 @@ const string AggregateColumn::toString() const
|
||||
output << "AggregateColumn " << data() << endl;
|
||||
output << "func/distinct: " << (int)fAggOp << "/" << fDistinct << endl;
|
||||
output << "expressionId=" << fExpressionId << endl;
|
||||
|
||||
if (fAlias.length() > 0) output << "/Alias: " << fAlias << endl;
|
||||
|
||||
if (fFunctionParms == 0)
|
||||
output << "No arguments" << endl;
|
||||
else
|
||||
output << *fFunctionParms << endl;
|
||||
|
||||
if (fConstCol)
|
||||
output << *fConstCol;
|
||||
|
||||
return output.str();
|
||||
}
|
||||
|
||||
@@ -184,20 +190,27 @@ void AggregateColumn::serialize(messageqcpp::ByteStream& b) const
|
||||
ReturnedColumn::serialize(b);
|
||||
b << fFunctionName;
|
||||
b << static_cast<uint8_t>(fAggOp);
|
||||
|
||||
if (fFunctionParms == 0)
|
||||
b << (uint8_t) ObjectReader::NULL_CLASS;
|
||||
else
|
||||
fFunctionParms->serialize(b);
|
||||
|
||||
b << static_cast<uint32_t>(fGroupByColList.size());
|
||||
|
||||
for (rcit = fGroupByColList.begin(); rcit != fGroupByColList.end(); ++rcit)
|
||||
(*rcit)->serialize(b);
|
||||
|
||||
b << static_cast<uint32_t>(fProjectColList.size());
|
||||
|
||||
for (rcit = fProjectColList.begin(); rcit != fProjectColList.end(); ++rcit)
|
||||
(*rcit)->serialize(b);
|
||||
|
||||
b << fData;
|
||||
//b << fAlias;
|
||||
b << fTableAlias;
|
||||
b << static_cast<const ByteStream::doublebyte>(fAsc);
|
||||
|
||||
if (fConstCol.get() == 0)
|
||||
b << (uint8_t) ObjectReader::NULL_CLASS;
|
||||
else
|
||||
@@ -221,17 +234,23 @@ void AggregateColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
ReturnedColumn* rc;
|
||||
|
||||
b >> size;
|
||||
for (i = 0; i < size; i++) {
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
rc = dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b));
|
||||
SRCP srcp(rc);
|
||||
fGroupByColList.push_back(srcp);
|
||||
}
|
||||
|
||||
b >> size;
|
||||
for (i = 0; i < size; i++) {
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
rc = dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b));
|
||||
SRCP srcp(rc);
|
||||
fProjectColList.push_back(srcp);
|
||||
}
|
||||
|
||||
b >> fData;
|
||||
//b >> fAlias;
|
||||
b >> fTableAlias;
|
||||
@@ -245,14 +264,19 @@ bool AggregateColumn::operator==(const AggregateColumn& t) const
|
||||
|
||||
rc1 = static_cast<const ReturnedColumn*>(this);
|
||||
rc2 = static_cast<const ReturnedColumn*>(&t);
|
||||
|
||||
if (*rc1 != *rc2)
|
||||
return false;
|
||||
|
||||
if (fFunctionName != t.fFunctionName)
|
||||
return false;
|
||||
|
||||
if (fAggOp == COUNT_ASTERISK && t.fAggOp == COUNT_ASTERISK)
|
||||
return true;
|
||||
|
||||
if (fAggOp != t.fAggOp)
|
||||
return false;
|
||||
|
||||
if (fFunctionParms.get() != NULL && t.fFunctionParms.get() != NULL)
|
||||
{
|
||||
if (*fFunctionParms.get() != t.fFunctionParms.get())
|
||||
@@ -260,19 +284,24 @@ bool AggregateColumn::operator==(const AggregateColumn& t) const
|
||||
}
|
||||
else if (fFunctionParms.get() != NULL || t.fFunctionParms.get() != NULL)
|
||||
return false;
|
||||
|
||||
//if (fAlias != t.fAlias)
|
||||
// return false;
|
||||
if (fTableAlias != t.fTableAlias)
|
||||
return false;
|
||||
|
||||
if (fData != t.fData)
|
||||
return false;
|
||||
|
||||
if (fAsc != t.fAsc)
|
||||
return false;
|
||||
|
||||
if ((fConstCol.get() != NULL && t.fConstCol.get() == NULL) ||
|
||||
(fConstCol.get() == NULL && t.fConstCol.get() != NULL) ||
|
||||
(fConstCol.get() != NULL && t.fConstCol.get() != NULL &&
|
||||
*(fConstCol.get()) != t.fConstCol.get()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -281,8 +310,10 @@ bool AggregateColumn::operator==(const TreeNode* t) const
|
||||
const AggregateColumn* ac;
|
||||
|
||||
ac = dynamic_cast<const AggregateColumn*>(t);
|
||||
|
||||
if (ac == NULL)
|
||||
return false;
|
||||
|
||||
return *this == *ac;
|
||||
}
|
||||
|
||||
@@ -311,13 +342,17 @@ void AggregateColumn::evaluate(Row& row, bool& isNull)
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getUintField<4>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::DATETIME:
|
||||
if (row.equals<8>(DATETIMENULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getUintField<8>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::CHAR:
|
||||
case CalpontSystemCatalog::VARCHAR:
|
||||
case CalpontSystemCatalog::STRINT:
|
||||
@@ -329,20 +364,26 @@ void AggregateColumn::evaluate(Row& row, bool& isNull)
|
||||
isNull = true;
|
||||
else
|
||||
fResult.origIntVal = row.getUintField<1>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (row.equals<2>(CHAR2NULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.origIntVal = row.getUintField<2>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case 4:
|
||||
if (row.equals<4>(CHAR4NULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.origIntVal = row.getUintField<4>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
@@ -351,72 +392,95 @@ void AggregateColumn::evaluate(Row& row, bool& isNull)
|
||||
isNull = true;
|
||||
else
|
||||
fResult.origIntVal = row.getUintField<8>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if (row.equals(CPNULLSTRMARK, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.strVal = row.getStringField(fInputIndex);
|
||||
|
||||
// stringColVal is padded with '\0' to colWidth so can't use str.length()
|
||||
if (strlen(fResult.strVal.c_str()) == 0)
|
||||
isNull = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (fResultType.colDataType == CalpontSystemCatalog::STRINT)
|
||||
fResult.intVal = uint64ToStr(fResult.origIntVal);
|
||||
else
|
||||
fResult.intVal = atoll((char*)&fResult.origIntVal);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::BIGINT:
|
||||
if (row.equals<8>(BIGINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getIntField<8>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::UBIGINT:
|
||||
if (row.equals<8>(UBIGINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.uintVal = row.getUintField<8>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::INT:
|
||||
case CalpontSystemCatalog::MEDINT:
|
||||
if (row.equals<4>(INTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getIntField<4>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::UINT:
|
||||
case CalpontSystemCatalog::UMEDINT:
|
||||
if (row.equals<4>(UINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.uintVal = row.getUintField<4>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::SMALLINT:
|
||||
if (row.equals<2>(SMALLINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getIntField<2>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::USMALLINT:
|
||||
if (row.equals<2>(USMALLINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.uintVal = row.getUintField<2>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::TINYINT:
|
||||
if (row.equals<1>(TINYINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getIntField<1>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::UTINYINT:
|
||||
if (row.equals<1>(UTINYINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.uintVal = row.getUintField<1>(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
//In this case, we're trying to load a double output column with float data. This is the
|
||||
// case when you do sum(floatcol), e.g.
|
||||
case CalpontSystemCatalog::FLOAT:
|
||||
@@ -425,14 +489,18 @@ void AggregateColumn::evaluate(Row& row, bool& isNull)
|
||||
isNull = true;
|
||||
else
|
||||
fResult.floatVal = row.getFloatField(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::DOUBLE:
|
||||
case CalpontSystemCatalog::UDOUBLE:
|
||||
if (row.equals<8>(DOUBLENULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.doubleVal = row.getDoubleField(fInputIndex);
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
switch (fResultType.colWidth)
|
||||
@@ -445,7 +513,9 @@ void AggregateColumn::evaluate(Row& row, bool& isNull)
|
||||
fResult.decimalVal.value = row.getIntField<1>(fInputIndex);
|
||||
fResult.decimalVal.scale = (unsigned)fResultType.scale;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (row.equals<2>(SMALLINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
@@ -454,7 +524,9 @@ void AggregateColumn::evaluate(Row& row, bool& isNull)
|
||||
fResult.decimalVal.value = row.getIntField<2>(fInputIndex);
|
||||
fResult.decimalVal.scale = (unsigned)fResultType.scale;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (row.equals<4>(INTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
@@ -463,7 +535,9 @@ void AggregateColumn::evaluate(Row& row, bool& isNull)
|
||||
fResult.decimalVal.value = row.getIntField<4>(fInputIndex);
|
||||
fResult.decimalVal.scale = (unsigned)fResultType.scale;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if (row.equals<8>(BIGINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
@@ -472,18 +546,23 @@ void AggregateColumn::evaluate(Row& row, bool& isNull)
|
||||
fResult.decimalVal.value = (int64_t)row.getUintField<8>(fInputIndex);
|
||||
fResult.decimalVal.scale = (unsigned)fResultType.scale;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::VARBINARY:
|
||||
case CalpontSystemCatalog::BLOB:
|
||||
isNull = true;
|
||||
break;
|
||||
|
||||
default: // treat as int64
|
||||
if (row.equals<8>(BIGINTNULL, fInputIndex))
|
||||
isNull = true;
|
||||
else
|
||||
fResult.intVal = row.getUintField<8>(fInputIndex);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -514,32 +593,46 @@ AggregateColumn::AggOp AggregateColumn::agname2num(const string& agname)
|
||||
*/
|
||||
string lfn(agname);
|
||||
algorithm::to_lower(lfn);
|
||||
|
||||
if (lfn == "count(*)")
|
||||
return COUNT_ASTERISK;
|
||||
|
||||
if (lfn == "count")
|
||||
return COUNT;
|
||||
|
||||
if (lfn == "sum")
|
||||
return SUM;
|
||||
|
||||
if (lfn == "avg")
|
||||
return AVG;
|
||||
|
||||
if (lfn == "min")
|
||||
return MIN;
|
||||
|
||||
if (lfn == "max")
|
||||
return MAX;
|
||||
|
||||
if (lfn == "std")
|
||||
return STDDEV_POP;
|
||||
|
||||
if (lfn == "stddev_pop")
|
||||
return STDDEV_POP;
|
||||
|
||||
if (lfn == "stddev_samp")
|
||||
return STDDEV_SAMP;
|
||||
|
||||
if (lfn == "stddev")
|
||||
return STDDEV_POP;
|
||||
|
||||
if (lfn == "var_pop")
|
||||
return VAR_POP;
|
||||
|
||||
if (lfn == "var_samp")
|
||||
return VAR_SAMP;
|
||||
|
||||
if (lfn == "variance")
|
||||
return VAR_POP;
|
||||
|
||||
return NOOP;
|
||||
}
|
||||
|
||||
|
||||
84
dbcon/execplan/aggregatecolumn.h
Executable file → Normal file
84
dbcon/execplan/aggregatecolumn.h
Executable file → Normal file
@@ -29,14 +29,16 @@
|
||||
#include "calpontselectexecutionplan.h"
|
||||
#include "returnedcolumn.h"
|
||||
|
||||
namespace messageqcpp {
|
||||
namespace messageqcpp
|
||||
{
|
||||
class ByteStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Namespace
|
||||
*/
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief A class to represent a aggregate return column
|
||||
@@ -44,7 +46,8 @@ namespace execplan {
|
||||
* This class is a specialization of class ReturnedColumn that
|
||||
* handles an aggregate function call (e.g., SUM, COUNT, MIN, MAX).
|
||||
*/
|
||||
class AggregateColumn : public ReturnedColumn {
|
||||
class AggregateColumn : public ReturnedColumn
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -140,11 +143,17 @@ public:
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual const uint8_t aggOp() const {return fAggOp;}
|
||||
virtual const uint8_t aggOp() const
|
||||
{
|
||||
return fAggOp;
|
||||
}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual void aggOp(const uint8_t aggOp) {fAggOp = aggOp;}
|
||||
virtual void aggOp(const uint8_t aggOp)
|
||||
{
|
||||
fAggOp = aggOp;
|
||||
}
|
||||
|
||||
/** get function parms
|
||||
*
|
||||
@@ -176,29 +185,47 @@ public:
|
||||
/**
|
||||
* table alias name
|
||||
*/
|
||||
virtual const std::string tableAlias() const { return fTableAlias; }
|
||||
virtual const std::string tableAlias() const
|
||||
{
|
||||
return fTableAlias;
|
||||
}
|
||||
/**
|
||||
* table alias name
|
||||
*/
|
||||
virtual void tableAlias (const std::string& tableAlias) { fTableAlias = tableAlias; }
|
||||
virtual void tableAlias (const std::string& tableAlias)
|
||||
{
|
||||
fTableAlias = tableAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* ASC flag
|
||||
*/
|
||||
inline virtual const bool asc() const { return fAsc; }
|
||||
inline virtual const bool asc() const
|
||||
{
|
||||
return fAsc;
|
||||
}
|
||||
/**
|
||||
* ASC flag
|
||||
*/
|
||||
inline virtual void asc(const bool asc) { fAsc = asc; }
|
||||
inline virtual void asc(const bool asc)
|
||||
{
|
||||
fAsc = asc;
|
||||
}
|
||||
|
||||
/**
|
||||
* fData: SQL representation of this object
|
||||
*/
|
||||
virtual const std::string data() const { return fData; }
|
||||
virtual const std::string data() const
|
||||
{
|
||||
return fData;
|
||||
}
|
||||
/**
|
||||
* fData: SQL representation of this object
|
||||
*/
|
||||
virtual void data(const std::string& data) { fData = data; }
|
||||
virtual void data(const std::string& data)
|
||||
{
|
||||
fData = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded stream operator
|
||||
@@ -243,26 +270,44 @@ public:
|
||||
virtual bool operator!=(const AggregateColumn& t) const;
|
||||
|
||||
/** @brief push back arg to group by column list*/
|
||||
virtual void addGroupByCol(SRCP ac) {fGroupByColList.push_back(ac);}
|
||||
virtual void addGroupByCol(SRCP ac)
|
||||
{
|
||||
fGroupByColList.push_back(ac);
|
||||
}
|
||||
|
||||
/** @brief push back arg to project by column list*/
|
||||
virtual void addProjectCol(SRCP ac) {fProjectColList.push_back(ac);}
|
||||
virtual void addProjectCol(SRCP ac)
|
||||
{
|
||||
fProjectColList.push_back(ac);
|
||||
}
|
||||
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual const ColumnList& groupByColList() const { return fGroupByColList;}
|
||||
virtual const ColumnList& groupByColList() const
|
||||
{
|
||||
return fGroupByColList;
|
||||
}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual const ColumnList& projectColList() const { return fProjectColList;}
|
||||
virtual const ColumnList& projectColList() const
|
||||
{
|
||||
return fProjectColList;
|
||||
}
|
||||
|
||||
/** @brief constant argument for aggregate with constant */
|
||||
inline const SRCP constCol() const { return fConstCol; }
|
||||
inline const SRCP constCol() const
|
||||
{
|
||||
return fConstCol;
|
||||
}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
inline void constCol(const SRCP& constCol) { fConstCol = constCol; }
|
||||
inline void constCol(const SRCP& constCol)
|
||||
{
|
||||
fConstCol = constCol;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert an aggregate name to an AggOp enum
|
||||
@@ -270,7 +315,10 @@ public:
|
||||
static AggOp agname2num(const std::string&);
|
||||
|
||||
virtual bool hasAggregate();
|
||||
virtual bool hasWindowFunc() {return false;}
|
||||
virtual bool hasWindowFunc()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string fFunctionName; // deprecated field
|
||||
|
||||
@@ -41,7 +41,8 @@ using namespace messageqcpp;
|
||||
#include "aggregatecolumn.h"
|
||||
#include "windowfunctioncolumn.h"
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
/** print the tree
|
||||
*
|
||||
* this function is mostly for debug purpose
|
||||
@@ -53,7 +54,8 @@ void walkfn(const execplan::ParseTree* n, ostream& output)
|
||||
|
||||
}
|
||||
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructors/Destructors
|
||||
@@ -91,6 +93,7 @@ ArithmeticColumn::~ArithmeticColumn()
|
||||
{
|
||||
if (fExpression != NULL)
|
||||
delete fExpression;
|
||||
|
||||
fExpression = NULL;
|
||||
}
|
||||
|
||||
@@ -102,6 +105,7 @@ void ArithmeticColumn::expression(ParseTree*& expression)
|
||||
{
|
||||
if (fExpression != NULL)
|
||||
delete fExpression;
|
||||
|
||||
fExpression = expression;
|
||||
expression = 0;
|
||||
}
|
||||
@@ -116,12 +120,14 @@ void ArithmeticColumn::buildTree()
|
||||
|
||||
//string fData = ReturnedColumn::data();
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
while (fData[i])
|
||||
{
|
||||
if (isdigit(fData[i]) || fData[i] == '.')
|
||||
{
|
||||
string num;
|
||||
|
||||
while (isdigit(fData[i]) || fData[i] == '.')
|
||||
{
|
||||
num.push_back(fData[i++]);
|
||||
@@ -173,6 +179,7 @@ void ArithmeticColumn::buildTree()
|
||||
op = "||";
|
||||
else
|
||||
op.push_back(fData[i]);
|
||||
|
||||
Operator* oper = new Operator(op);
|
||||
t.value = oper;
|
||||
|
||||
@@ -197,12 +204,14 @@ void ArithmeticColumn::buildTree()
|
||||
t.value = oper;
|
||||
tokens.push_back(t);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
else if (isalpha(fData[i]) || fData[i] == '_' )
|
||||
{
|
||||
string identifier;
|
||||
|
||||
while (isalnum(fData[i]) ||
|
||||
fData[i] == '_' ||
|
||||
fData[i] == '.' )
|
||||
@@ -226,6 +235,7 @@ void ArithmeticColumn::buildTree()
|
||||
tokens.push_back(t);
|
||||
continue;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
@@ -239,6 +249,7 @@ void ArithmeticColumn::buildTree()
|
||||
delete tokens[i].value;
|
||||
tokens[i].value = 0;
|
||||
}
|
||||
|
||||
throw runtime_error(e.what());
|
||||
}
|
||||
}
|
||||
@@ -251,6 +262,7 @@ const string ArithmeticColumn::nextToken(string::size_type &pos, char end) const
|
||||
// increment num when get '(' and decrement when get ')'
|
||||
// to find the mathing ')' when num = 0
|
||||
int num = 1;
|
||||
|
||||
for (; pos < fData.length(); )
|
||||
{
|
||||
if (end == ')')
|
||||
@@ -259,6 +271,7 @@ const string ArithmeticColumn::nextToken(string::size_type &pos, char end) const
|
||||
num++;
|
||||
else if (fData[pos] == ')')
|
||||
num--;
|
||||
|
||||
if (num == 0)
|
||||
{
|
||||
pos++;
|
||||
@@ -273,6 +286,7 @@ const string ArithmeticColumn::nextToken(string::size_type &pos, char end) const
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
token.push_back(fData[pos++]);
|
||||
}
|
||||
|
||||
@@ -293,8 +307,11 @@ const string ArithmeticColumn::toString() const
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << "ArithmeticColumn: ";
|
||||
|
||||
if (fAlias.length() > 0) oss << "Alias: " << fAlias << endl;
|
||||
|
||||
if (fExpression != 0) fExpression->walk(walkfn, oss);
|
||||
|
||||
oss << "expressionId=" << fExpressionId << endl;
|
||||
oss << "joinInfo=" << fJoinInfo << " returnAll=" << fReturnAll << " sequence#=" << fSequence << endl;
|
||||
oss << "resultType=" << colDataTypeToString(fResultType.colDataType) << "|" << fResultType.colWidth <<
|
||||
@@ -316,8 +333,10 @@ void ArithmeticColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
{
|
||||
ObjectReader::checkType(b, ObjectReader::ARITHMETICCOLUMN);
|
||||
ReturnedColumn::unserialize(b);
|
||||
|
||||
if (fExpression != NULL)
|
||||
delete fExpression;
|
||||
|
||||
fExpression = ObjectReader::createParseTree(b);
|
||||
b >> fTableAlias;
|
||||
b >> fData;
|
||||
@@ -337,20 +356,27 @@ bool ArithmeticColumn::operator==(const ArithmeticColumn& t) const
|
||||
|
||||
rc1 = static_cast<const ReturnedColumn*>(this);
|
||||
rc2 = static_cast<const ReturnedColumn*>(&t);
|
||||
|
||||
if (*rc1 != *rc2)
|
||||
return false;
|
||||
if (fExpression != NULL && t.fExpression != NULL) {
|
||||
|
||||
if (fExpression != NULL && t.fExpression != NULL)
|
||||
{
|
||||
if (*fExpression != *t.fExpression)
|
||||
return false;
|
||||
}
|
||||
else if (fExpression != NULL || t.fExpression != NULL)
|
||||
return false;
|
||||
|
||||
if (fAlias != t.fAlias)
|
||||
return false;
|
||||
|
||||
if (fTableAlias != t.fTableAlias)
|
||||
return false;
|
||||
|
||||
if (fData != t.fData)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -359,8 +385,10 @@ bool ArithmeticColumn::operator==(const TreeNode* t) const
|
||||
const ArithmeticColumn* o;
|
||||
|
||||
o = dynamic_cast<const ArithmeticColumn*>(t);
|
||||
|
||||
if (o == NULL)
|
||||
return false;
|
||||
|
||||
return *this == *o;
|
||||
}
|
||||
|
||||
@@ -377,10 +405,13 @@ bool ArithmeticColumn::operator!=(const TreeNode* t) const
|
||||
bool ArithmeticColumn::hasAggregate()
|
||||
{
|
||||
if (fHasAggregate) return true;
|
||||
|
||||
fAggColumnList.clear();
|
||||
fExpression->walk(getAggCols, &fAggColumnList);
|
||||
|
||||
if (!fAggColumnList.empty())
|
||||
fHasAggregate = true;
|
||||
|
||||
return fHasAggregate;
|
||||
}
|
||||
|
||||
@@ -388,8 +419,10 @@ bool ArithmeticColumn::hasWindowFunc()
|
||||
{
|
||||
fWindowFunctionColumnList.clear();
|
||||
fExpression->walk(getWindowFunctionCols, &fWindowFunctionColumnList);
|
||||
|
||||
if (fWindowFunctionColumnList.empty())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -400,6 +433,7 @@ void ArithmeticColumn::setDerivedTable()
|
||||
fDerivedTable = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (fExpression)
|
||||
{
|
||||
fExpression->setDerivedTable();
|
||||
@@ -423,17 +457,20 @@ bool ArithmeticColumn::singleTable(CalpontSystemCatalog::TableAliasName& tan)
|
||||
{
|
||||
tan.clear();
|
||||
setSimpleColumnList();
|
||||
|
||||
for (uint32_t i = 0; i < fSimpleColumnList.size(); i++)
|
||||
{
|
||||
CalpontSystemCatalog::TableAliasName stan(fSimpleColumnList[i]->schemaName(),
|
||||
fSimpleColumnList[i]->tableName(),
|
||||
fSimpleColumnList[i]->tableAlias(),
|
||||
fSimpleColumnList[i]->viewName());
|
||||
|
||||
if (tan.table.empty())
|
||||
tan = stan;
|
||||
else if (stan != tan)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@
|
||||
/**
|
||||
* Namespace
|
||||
*/
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
class SimpleColumn;
|
||||
class AggregateColumn;
|
||||
|
||||
@@ -44,7 +45,8 @@ namespace execplan {
|
||||
* This class is a specialization of class ReturnedColumn that
|
||||
* handles an arithmetic expression.
|
||||
*/
|
||||
class ArithmeticColumn : public ReturnedColumn {
|
||||
class ArithmeticColumn : public ReturnedColumn
|
||||
{
|
||||
public:
|
||||
ArithmeticColumn();
|
||||
ArithmeticColumn( const std::string& sql, const uint32_t sessionID = 0 );
|
||||
@@ -84,22 +86,34 @@ public:
|
||||
/**
|
||||
* get asc flag
|
||||
*/
|
||||
inline const bool asc() const { return fAsc; }
|
||||
inline const bool asc() const
|
||||
{
|
||||
return fAsc;
|
||||
}
|
||||
|
||||
/**
|
||||
* set asc flag
|
||||
*/
|
||||
inline void asc(const bool asc) { fAsc = asc; }
|
||||
inline void asc(const bool asc)
|
||||
{
|
||||
fAsc = asc;
|
||||
}
|
||||
|
||||
/**
|
||||
* get SQL representation of this object
|
||||
*/
|
||||
virtual const std::string data() const { return fData; }
|
||||
virtual const std::string data() const
|
||||
{
|
||||
return fData;
|
||||
}
|
||||
|
||||
/**
|
||||
* set SQL representation of this object
|
||||
*/
|
||||
virtual void data(const std::string data) { fData = data; }
|
||||
virtual void data(const std::string data)
|
||||
{
|
||||
fData = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* virtual stream method
|
||||
@@ -155,7 +169,9 @@ public:
|
||||
virtual void setDerivedTable();
|
||||
virtual void replaceRealCol(std::vector<SRCP>&);
|
||||
virtual const std::vector<SimpleColumn*>& simpleColumnList() const
|
||||
{ return fSimpleColumnList; }
|
||||
{
|
||||
return fSimpleColumnList;
|
||||
}
|
||||
virtual void setSimpleColumnList();
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,12 +28,16 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
/**@brief util struct for converting string to lower case */
|
||||
struct to_lower
|
||||
{
|
||||
char operator() (char c) const { return tolower(c); }
|
||||
char operator() (char c) const
|
||||
{
|
||||
return tolower(c);
|
||||
}
|
||||
};
|
||||
|
||||
//Trim any leading/trailing ws
|
||||
@@ -41,16 +45,21 @@ const string lrtrim(const string& in)
|
||||
{
|
||||
string::size_type p1;
|
||||
p1 = in.find_first_not_of(" \t\n");
|
||||
|
||||
if (p1 == string::npos) p1 = 0;
|
||||
|
||||
string::size_type p2;
|
||||
p2 = in.find_last_not_of(" \t\n");
|
||||
|
||||
if (p2 == string::npos) p2 = in.size() - 1;
|
||||
|
||||
return string(in, p1, (p2 - p1 + 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructors/Destructors
|
||||
@@ -104,6 +113,7 @@ bool ArithmeticOperator::operator==(const ArithmeticOperator& t) const
|
||||
{
|
||||
if (fData == t.fData)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -112,8 +122,10 @@ bool ArithmeticOperator::operator==(const TreeNode* t) const
|
||||
const ArithmeticOperator* o;
|
||||
|
||||
o = dynamic_cast<const ArithmeticOperator*>(t);
|
||||
|
||||
if (o == NULL)
|
||||
return false;
|
||||
|
||||
return *this == *o;
|
||||
}
|
||||
|
||||
@@ -140,6 +152,7 @@ void ArithmeticOperator::operationType(const Type& l, const Type& r)
|
||||
fOperationType = fResultType;
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
@@ -147,6 +160,7 @@ void ArithmeticOperator::operationType(const Type& l, const Type& r)
|
||||
fOperationType.colDataType = execplan::CalpontSystemCatalog::DECIMAL;
|
||||
fOperationType.scale = l.scale;
|
||||
break;
|
||||
|
||||
default:
|
||||
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
|
||||
}
|
||||
@@ -162,6 +176,7 @@ void ArithmeticOperator::operationType(const Type& l, const Type& r)
|
||||
fOperationType = fResultType;
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
@@ -169,6 +184,7 @@ void ArithmeticOperator::operationType(const Type& l, const Type& r)
|
||||
fOperationType.colDataType = execplan::CalpontSystemCatalog::DECIMAL;
|
||||
fOperationType.scale = r.scale;
|
||||
break;
|
||||
|
||||
default:
|
||||
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
|
||||
}
|
||||
|
||||
@@ -32,13 +32,16 @@
|
||||
#include "operator.h"
|
||||
#include "parsetree.h"
|
||||
|
||||
namespace messageqcpp {
|
||||
namespace messageqcpp
|
||||
{
|
||||
class ByteStream;
|
||||
}
|
||||
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
|
||||
class ArithmeticOperator : public Operator {
|
||||
class ArithmeticOperator : public Operator
|
||||
{
|
||||
|
||||
public:
|
||||
ArithmeticOperator();
|
||||
@@ -175,6 +178,7 @@ inline void ArithmeticOperator::evaluate(rowgroup::Row& row, bool& isNull, Parse
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
fResult.intVal = execute(lop->getIntVal(row, isNull), rop->getIntVal(row, isNull), isNull);
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::UBIGINT:
|
||||
case execplan::CalpontSystemCatalog::UINT:
|
||||
case execplan::CalpontSystemCatalog::UMEDINT:
|
||||
@@ -182,14 +186,17 @@ inline void ArithmeticOperator::evaluate(rowgroup::Row& row, bool& isNull, Parse
|
||||
case execplan::CalpontSystemCatalog::UTINYINT:
|
||||
fResult.uintVal = execute(lop->getUintVal(row, isNull), rop->getUintVal(row, isNull), isNull);
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
fResult.doubleVal = execute(lop->getDoubleVal(row, isNull), rop->getDoubleVal(row, isNull), isNull);
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
execute (fResult.decimalVal, lop->getDecimalVal(row, isNull), rop->getDecimalVal(row, isNull), isNull);
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@@ -206,16 +213,21 @@ inline result_t ArithmeticOperator::execute(result_t op1, result_t op2, bool& is
|
||||
{
|
||||
case OP_ADD:
|
||||
return op1 + op2;
|
||||
|
||||
case OP_SUB:
|
||||
return op1 - op2;
|
||||
|
||||
case OP_MUL:
|
||||
return op1 * op2;
|
||||
|
||||
case OP_DIV:
|
||||
if (op2)
|
||||
return op1 / op2;
|
||||
else
|
||||
isNull = true;
|
||||
|
||||
return 0;
|
||||
|
||||
default:
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@@ -235,40 +247,48 @@ inline void ArithmeticOperator::execute(IDB_Decimal& result, IDB_Decimal op1, ID
|
||||
result.value = op1.value + op2.value;
|
||||
break;
|
||||
}
|
||||
|
||||
if (result.scale >= op1.scale)
|
||||
op1.value *= IDB_pow[result.scale - op1.scale];
|
||||
else
|
||||
op1.value = (int64_t)(op1.value > 0 ?
|
||||
(double)op1.value / IDB_pow[op1.scale - result.scale] + 0.5 :
|
||||
(double)op1.value / IDB_pow[op1.scale - result.scale] - 0.5);
|
||||
|
||||
if (result.scale >= op2.scale)
|
||||
op2.value *= IDB_pow[result.scale - op2.scale];
|
||||
else
|
||||
op2.value = (int64_t)(op2.value > 0 ?
|
||||
(double)op2.value / IDB_pow[op2.scale - result.scale] + 0.5 :
|
||||
(double)op2.value / IDB_pow[op2.scale - result.scale] - 0.5);
|
||||
|
||||
result.value = op1.value + op2.value;
|
||||
break;
|
||||
|
||||
case OP_SUB:
|
||||
if (result.scale == op1.scale && result.scale == op2.scale)
|
||||
{
|
||||
result.value = op1.value - op2.value;
|
||||
break;
|
||||
}
|
||||
|
||||
if (result.scale >= op1.scale)
|
||||
op1.value *= IDB_pow[result.scale - op1.scale];
|
||||
else
|
||||
op1.value = (int64_t)(op1.value > 0 ?
|
||||
(double)op1.value / IDB_pow[op1.scale - result.scale] + 0.5 :
|
||||
(double)op1.value / IDB_pow[op1.scale - result.scale] - 0.5);
|
||||
|
||||
if (result.scale >= op2.scale)
|
||||
op2.value *= IDB_pow[result.scale - op2.scale];
|
||||
else
|
||||
op2.value = (int64_t)(op2.value > 0 ?
|
||||
(double)op2.value / IDB_pow[op2.scale - result.scale] + 0.5 :
|
||||
(double)op2.value / IDB_pow[op2.scale - result.scale] - 0.5);
|
||||
|
||||
result.value = op1.value - op2.value;
|
||||
break;
|
||||
|
||||
case OP_MUL:
|
||||
if (result.scale >= op1.scale + op2.scale)
|
||||
result.value = op1.value * op2.value * IDB_pow[result.scale - (op1.scale + op2.scale)];
|
||||
@@ -276,13 +296,16 @@ inline void ArithmeticOperator::execute(IDB_Decimal& result, IDB_Decimal op1, ID
|
||||
result.value = (int64_t)(( (op1.value > 0 && op2.value > 0) || (op1.value < 0 && op2.value < 0) ?
|
||||
(double)op1.value * op2.value / IDB_pow[op1.scale + op2.scale - result.scale] + 0.5 :
|
||||
(double)op1.value * op2.value / IDB_pow[op1.scale + op2.scale - result.scale] - 0.5));
|
||||
|
||||
break;
|
||||
|
||||
case OP_DIV:
|
||||
if (op2.value == 0)
|
||||
{
|
||||
isNull = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (result.scale >= op1.scale - op2.scale)
|
||||
result.value = (int64_t)(( (op1.value > 0 && op2.value > 0) || (op1.value < 0 && op2.value < 0) ?
|
||||
(long double)op1.value / op2.value * IDB_pow[result.scale - (op1.scale - op2.scale)] + 0.5 :
|
||||
@@ -291,7 +314,9 @@ inline void ArithmeticOperator::execute(IDB_Decimal& result, IDB_Decimal op1, ID
|
||||
result.value = (int64_t)(( (op1.value > 0 && op2.value > 0) || (op1.value < 0 && op2.value < 0) ?
|
||||
(long double)op1.value / op2.value / IDB_pow[op1.scale - op2.scale - result.scale] + 0.5 :
|
||||
(long double)op1.value / op2.value / IDB_pow[op1.scale - op2.scale - result.scale] - 0.5));
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
@@ -45,7 +45,8 @@ extern "C" void init_demangler(int, int, int);
|
||||
|
||||
using namespace execplan;
|
||||
|
||||
class ExecPlanTest : public CppUnit::TestFixture {
|
||||
class ExecPlanTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE( ExecPlanTest );
|
||||
|
||||
@@ -61,17 +62,21 @@ public:
|
||||
char* r;
|
||||
static bool is_init = false;
|
||||
const char* mname = typeid(*(n->data())).name();
|
||||
|
||||
if (!is_init)
|
||||
{
|
||||
::init_demangler(0, 0, 0);
|
||||
is_init = true;
|
||||
}
|
||||
|
||||
r = ::cplus_demangle_with_style(mname, 7, 27);
|
||||
|
||||
if (r != 0)
|
||||
{
|
||||
//cout << "mangle: " << mname << " demangle: " << r << endl;
|
||||
::free(r);
|
||||
}
|
||||
|
||||
if (typeid(*(n->data())) == typeid(SimpleFilter))
|
||||
{
|
||||
cout << "SimpleFilter: " << endl;
|
||||
@@ -81,6 +86,7 @@ public:
|
||||
const Operator* op = sf->op();
|
||||
cout << '\t' << lhs->data() << ' ' << op->data() << ' ' << rhs->data();
|
||||
cout << endl << "\t\t";
|
||||
|
||||
if (typeid(*lhs) == typeid(SimpleColumn))
|
||||
{
|
||||
cout << "SimpleColumn: " << lhs->data() << " / ";
|
||||
@@ -93,7 +99,9 @@ public:
|
||||
{
|
||||
cout << "UNK: " << lhs->data() << " / ";
|
||||
}
|
||||
|
||||
cout << "Operator: " << op->data() << " / ";
|
||||
|
||||
if (typeid(*rhs) == typeid(SimpleColumn))
|
||||
{
|
||||
cout << "SimpleColumn: " << rhs->data();
|
||||
@@ -117,16 +125,20 @@ public:
|
||||
{
|
||||
cout << mname << " -x-: ";
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
void setUp() {
|
||||
void setUp()
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown() {
|
||||
void tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void selectExecutionPlan_1() {
|
||||
void selectExecutionPlan_1()
|
||||
{
|
||||
cout << "SQL: select r_regionkey from region, nation where n_regionkey = r_regionkey and n_regionkey = 2;" << endl;
|
||||
CalpontSelectExecutionPlan csep;
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList colList;
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
|
||||
#include "calpontexecutionplan.h"
|
||||
|
||||
namespace execplan{
|
||||
namespace execplan
|
||||
{
|
||||
/**
|
||||
* Constructors/Destructors
|
||||
*/
|
||||
|
||||
@@ -27,14 +27,16 @@
|
||||
#include <string>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace messageqcpp {
|
||||
namespace messageqcpp
|
||||
{
|
||||
class ByteStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Namespace
|
||||
*/
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
/**
|
||||
* ******************************* Abstract Class ****************************
|
||||
* CalpontExecutionPlan does not have any pure virtual methods, but its author
|
||||
@@ -42,7 +44,8 @@ namespace execplan {
|
||||
* Inherit from it instead and create only objects from the derived classes
|
||||
* *****************************************************************************
|
||||
*/
|
||||
class CalpontExecutionPlan {
|
||||
class CalpontExecutionPlan
|
||||
{
|
||||
/**
|
||||
* Public stuff
|
||||
*/
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
#include "vendorexecutionplan.h"
|
||||
#include "calpontselectexecutionplan.h"
|
||||
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
|
||||
//CalpontExecutionPlan* CalpontExecutionPlanFactory::makeCalpontExecutionPlan(const VendorExecutionPlan* vplan)
|
||||
//{
|
||||
|
||||
@@ -28,9 +28,11 @@
|
||||
#include "calpontexecutionplan.h"
|
||||
#include "vendorexecutionplan.h"
|
||||
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
|
||||
class CalpontExecutionPlanFactory {
|
||||
class CalpontExecutionPlanFactory
|
||||
{
|
||||
|
||||
public:
|
||||
//static CalpontExecutionPlan* makeCalpontExecutionPlan(const VendorExecutionPlan* vplan);
|
||||
|
||||
@@ -39,11 +39,16 @@ using namespace messageqcpp;
|
||||
#include "querytele.h"
|
||||
using namespace querytele;
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
template<class T> struct deleter : public unary_function<T&, void>
|
||||
{
|
||||
void operator()(T& x) { delete x; x = 0; }
|
||||
void operator()(T& x)
|
||||
{
|
||||
delete x;
|
||||
x = 0;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -159,8 +164,10 @@ CalpontSelectExecutionPlan::~CalpontSelectExecutionPlan()
|
||||
{
|
||||
if (fFilters != NULL)
|
||||
delete fFilters;
|
||||
|
||||
if (fHaving != NULL)
|
||||
delete fHaving;
|
||||
|
||||
fFilters = NULL;
|
||||
fHaving = NULL;
|
||||
}
|
||||
@@ -182,6 +189,7 @@ void CalpontSelectExecutionPlan::filterTokenList( FilterTokenList& filterTokenLi
|
||||
t.value = filterTokenList[i];
|
||||
tokens.push_back(t);
|
||||
}
|
||||
|
||||
if (tokens.size() > 0)
|
||||
filters(parser.parse(tokens.begin(), tokens.end()));
|
||||
}
|
||||
@@ -199,6 +207,7 @@ void CalpontSelectExecutionPlan::havingTokenList( const FilterTokenList& havingT
|
||||
t.value = havingTokenList[i];
|
||||
tokens.push_back(t);
|
||||
}
|
||||
|
||||
if (tokens.size() > 0)
|
||||
having(parser.parse(tokens.begin(), tokens.end()));
|
||||
}
|
||||
@@ -208,8 +217,10 @@ string CalpontSelectExecutionPlan::toString() const
|
||||
ostringstream output;
|
||||
|
||||
output << ">SELECT " ;
|
||||
|
||||
if (distinct())
|
||||
output << "DISTINCT ";
|
||||
|
||||
output << "limit: " << limitStart() << " - " << limitNum() << endl;
|
||||
|
||||
switch (location())
|
||||
@@ -217,12 +228,15 @@ string CalpontSelectExecutionPlan::toString() const
|
||||
case CalpontSelectExecutionPlan::MAIN:
|
||||
output << "MAIN" << endl;
|
||||
break;
|
||||
|
||||
case CalpontSelectExecutionPlan::FROM:
|
||||
output << "FROM" << endl;
|
||||
break;
|
||||
|
||||
case CalpontSelectExecutionPlan::WHERE:
|
||||
output << "WHERE" << endl;
|
||||
break;
|
||||
|
||||
case CalpontSelectExecutionPlan::HAVING:
|
||||
output << "HAVING" << endl;
|
||||
break;
|
||||
@@ -232,13 +246,16 @@ string CalpontSelectExecutionPlan::toString() const
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList retCols = returnedCols();
|
||||
output << ">>Returned Columns" << endl;
|
||||
uint32_t seq = 0;
|
||||
|
||||
for (unsigned int i = 0; i < retCols.size(); i++)
|
||||
{
|
||||
output << *retCols[i] << endl;
|
||||
|
||||
if (retCols[i]->colSource() & SELECT_SUB)
|
||||
{
|
||||
output << "select sub -- " << endl;
|
||||
CalpontSelectExecutionPlan* plan = dynamic_cast<CalpontSelectExecutionPlan*>(fSelectSubList[seq++].get());
|
||||
|
||||
if (plan)
|
||||
output << "{" << *plan << "}" << endl;
|
||||
}
|
||||
@@ -248,6 +265,7 @@ string CalpontSelectExecutionPlan::toString() const
|
||||
CalpontSelectExecutionPlan::TableList tables = tableList();
|
||||
output << ">>From Tables" << endl;
|
||||
seq = 0;
|
||||
|
||||
for (unsigned int i = 0; i < tables.size(); i++)
|
||||
{
|
||||
// derived table
|
||||
@@ -255,6 +273,7 @@ string CalpontSelectExecutionPlan::toString() const
|
||||
{
|
||||
output << "derived table - " << tables[i].alias << endl;
|
||||
CalpontSelectExecutionPlan* plan = dynamic_cast<CalpontSelectExecutionPlan*>(fDerivedTableList[seq++].get());
|
||||
|
||||
if (plan)
|
||||
output << "{" << *plan << "}" << endl;
|
||||
}
|
||||
@@ -266,6 +285,7 @@ string CalpontSelectExecutionPlan::toString() const
|
||||
|
||||
// Filters
|
||||
output << ">>Filters" << endl;
|
||||
|
||||
if (filters() != 0)
|
||||
filters()->walk (ParseTree::print, output);
|
||||
else
|
||||
@@ -273,9 +293,11 @@ string CalpontSelectExecutionPlan::toString() const
|
||||
|
||||
// Group by columns
|
||||
const CalpontSelectExecutionPlan::GroupByColumnList& gbc = groupByCols();
|
||||
|
||||
if (gbc.size() > 0)
|
||||
{
|
||||
output << ">>Group By Columns" << endl;
|
||||
|
||||
for (unsigned int i = 0; i < gbc.size(); i++)
|
||||
output << *gbc[i] << endl;
|
||||
}
|
||||
@@ -289,12 +311,15 @@ string CalpontSelectExecutionPlan::toString() const
|
||||
|
||||
// Order by columns
|
||||
const CalpontSelectExecutionPlan::OrderByColumnList& obc = orderByCols();
|
||||
|
||||
if (obc.size() > 0)
|
||||
{
|
||||
output << ">>Order By Columns" << endl;
|
||||
|
||||
for (unsigned int i = 0; i < obc.size(); i++)
|
||||
output << *obc[i] << endl;
|
||||
}
|
||||
|
||||
output << "SessionID: " << fSessionID << endl;
|
||||
output << "TxnID: " << fTxnID << endl;
|
||||
output << "VerID: " << fVerID << endl;
|
||||
@@ -306,17 +331,21 @@ string CalpontSelectExecutionPlan::toString() const
|
||||
|
||||
output << "--- Column Map ---" << endl;
|
||||
CalpontSelectExecutionPlan::ColumnMap::const_iterator iter;
|
||||
|
||||
for (iter = columnMap().begin(); iter != columnMap().end(); iter++)
|
||||
output << (*iter).first << " : " << (*iter).second << endl;
|
||||
|
||||
output << "UUID: " << fUuid << endl;
|
||||
output << "QueryType: " << queryType() << endl;
|
||||
|
||||
if (!unionVec().empty())
|
||||
output << "\n--- Union Unit ---" << endl;
|
||||
|
||||
for (unsigned i = 0; i < unionVec().size(); i++)
|
||||
{
|
||||
CalpontSelectExecutionPlan* plan =
|
||||
dynamic_cast<CalpontSelectExecutionPlan*>(unionVec()[i].get());
|
||||
|
||||
if (plan)
|
||||
output << "{" << *plan << "}\n" << endl;
|
||||
}
|
||||
@@ -330,23 +359,32 @@ string CalpontSelectExecutionPlan::queryTypeToString(const uint32_t queryType)
|
||||
{
|
||||
case SELECT:
|
||||
return "SELECT";
|
||||
|
||||
case UPDATE:
|
||||
return "UPDATE";
|
||||
|
||||
case DELETE:
|
||||
return "DELETE";
|
||||
|
||||
case INSERT_SELECT:
|
||||
return "INSERT_SELECT";
|
||||
|
||||
case CREATE_TABLE:
|
||||
return "CREATE_TABLE";
|
||||
|
||||
case DROP_TABLE:
|
||||
return "DROP_TABLE";
|
||||
|
||||
case ALTER_TABLE:
|
||||
return "ALTER_TABLE";
|
||||
|
||||
case INSERT:
|
||||
return "INSERT";
|
||||
|
||||
case LOAD_DATA_INFILE:
|
||||
return "LOAD_DATA_INFILE";
|
||||
}
|
||||
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
@@ -360,10 +398,12 @@ void CalpontSelectExecutionPlan::serialize(messageqcpp::ByteStream& b) const
|
||||
b << static_cast<ObjectReader::id_t>(ObjectReader::CALPONTSELECTEXECUTIONPLAN);
|
||||
|
||||
b << static_cast<uint32_t>(fReturnedCols.size());
|
||||
|
||||
for (rcit = fReturnedCols.begin(); rcit != fReturnedCols.end(); ++rcit)
|
||||
(*rcit)->serialize(b);
|
||||
|
||||
b << static_cast<uint32_t>(fTableList.size());
|
||||
|
||||
for (tit = fTableList.begin(); tit != fTableList.end(); ++tit)
|
||||
{
|
||||
(*tit).serialize(b);
|
||||
@@ -372,20 +412,24 @@ void CalpontSelectExecutionPlan::serialize(messageqcpp::ByteStream& b) const
|
||||
ObjectReader::writeParseTree(fFilters, b);
|
||||
|
||||
b << static_cast<uint32_t>(fSubSelects.size());
|
||||
|
||||
for (uint32_t i = 0; i < fSubSelects.size(); i++)
|
||||
fSubSelects[i]->serialize(b);
|
||||
|
||||
b << static_cast<uint32_t>(fGroupByCols.size());
|
||||
|
||||
for (rcit = fGroupByCols.begin(); rcit != fGroupByCols.end(); ++rcit)
|
||||
(*rcit)->serialize(b);
|
||||
|
||||
ObjectReader::writeParseTree(fHaving, b);
|
||||
|
||||
b << static_cast<uint32_t>(fOrderByCols.size());
|
||||
|
||||
for (rcit = fOrderByCols.begin(); rcit != fOrderByCols.end(); ++rcit)
|
||||
(*rcit)->serialize(b);
|
||||
|
||||
b << static_cast<uint32_t>(fColumnMap.size());
|
||||
|
||||
for (mapiter = fColumnMap.begin(); mapiter != fColumnMap.end(); ++mapiter)
|
||||
{
|
||||
b << (*mapiter).first;
|
||||
@@ -393,6 +437,7 @@ void CalpontSelectExecutionPlan::serialize(messageqcpp::ByteStream& b) const
|
||||
}
|
||||
|
||||
b << static_cast<uint32_t>(frmParms.size());
|
||||
|
||||
for (RMParmVec::const_iterator it = frmParms.begin(); it != frmParms.end(); ++it)
|
||||
{
|
||||
b << it->sessionId;
|
||||
@@ -418,6 +463,7 @@ void CalpontSelectExecutionPlan::serialize(messageqcpp::ByteStream& b) const
|
||||
// for union
|
||||
b << (uint8_t)fDistinctUnionNum;
|
||||
b << (uint32_t)fUnionVec.size();
|
||||
|
||||
for (uint32_t i = 0; i < fUnionVec.size(); i++)
|
||||
fUnionVec[i]->serialize(b);
|
||||
|
||||
@@ -425,6 +471,7 @@ void CalpontSelectExecutionPlan::serialize(messageqcpp::ByteStream& b) const
|
||||
|
||||
// for FROM subquery
|
||||
b << static_cast<uint32_t>(fDerivedTableList.size());
|
||||
|
||||
for (uint32_t i = 0; i < fDerivedTableList.size(); i++)
|
||||
fDerivedTableList[i]->serialize(b);
|
||||
|
||||
@@ -433,6 +480,7 @@ void CalpontSelectExecutionPlan::serialize(messageqcpp::ByteStream& b) const
|
||||
b << static_cast<const ByteStream::byte>(fHasOrderBy);
|
||||
|
||||
b << static_cast<uint32_t>(fSelectSubList.size());
|
||||
|
||||
for (uint32_t i = 0; i < fSelectSubList.size(); i++)
|
||||
fSelectSubList[i]->serialize(b);
|
||||
|
||||
@@ -471,11 +519,14 @@ void CalpontSelectExecutionPlan::unserialize(messageqcpp::ByteStream& b)
|
||||
fDerivedTableList.clear();
|
||||
fSelectSubList.clear();
|
||||
|
||||
if (fFilters != 0) {
|
||||
if (fFilters != 0)
|
||||
{
|
||||
delete fFilters;
|
||||
fFilters = 0;
|
||||
}
|
||||
if (fHaving != 0) {
|
||||
|
||||
if (fHaving != 0)
|
||||
{
|
||||
delete fHaving;
|
||||
fHaving = 0;
|
||||
}
|
||||
@@ -484,7 +535,9 @@ void CalpontSelectExecutionPlan::unserialize(messageqcpp::ByteStream& b)
|
||||
messageqcpp::ByteStream::quadbyte i;
|
||||
|
||||
b >> size;
|
||||
for (i = 0; i < size; i++) {
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
rc = dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b));
|
||||
SRCP srcp(rc);
|
||||
fReturnedCols.push_back(srcp);
|
||||
@@ -492,6 +545,7 @@ void CalpontSelectExecutionPlan::unserialize(messageqcpp::ByteStream& b)
|
||||
|
||||
b >> size;
|
||||
CalpontSystemCatalog::TableAliasName tan;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
tan.unserialize(b);
|
||||
@@ -501,13 +555,17 @@ void CalpontSelectExecutionPlan::unserialize(messageqcpp::ByteStream& b)
|
||||
fFilters = ObjectReader::createParseTree(b);
|
||||
|
||||
b >> size;
|
||||
for (i = 0; i < size; i++) {
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
cep = ObjectReader::createExecutionPlan(b);
|
||||
fSubSelects.push_back(SCEP(cep));
|
||||
}
|
||||
|
||||
b >> size;
|
||||
for (i = 0; i < size; i++) {
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
rc = dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b));
|
||||
SRCP srcp(rc);
|
||||
fGroupByCols.push_back(srcp);
|
||||
@@ -516,14 +574,18 @@ void CalpontSelectExecutionPlan::unserialize(messageqcpp::ByteStream& b)
|
||||
fHaving = ObjectReader::createParseTree(b);
|
||||
|
||||
b >> size;
|
||||
for (i = 0; i < size; i++) {
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
rc = dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b));
|
||||
SRCP srcp(rc);
|
||||
fOrderByCols.push_back(srcp);
|
||||
}
|
||||
|
||||
b >> size;
|
||||
for (i = 0; i < size; i++) {
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
b >> colName;
|
||||
rc = dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b));
|
||||
SRCP srcp(rc);
|
||||
@@ -534,7 +596,9 @@ void CalpontSelectExecutionPlan::unserialize(messageqcpp::ByteStream& b)
|
||||
messageqcpp::ByteStream::doublebyte id;
|
||||
messageqcpp::ByteStream::quadbyte sessionId;
|
||||
messageqcpp::ByteStream::octbyte memory;
|
||||
for (i = 0; i < size; i++) {
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
b >> sessionId;
|
||||
b >> id;
|
||||
b >> memory;
|
||||
@@ -560,15 +624,18 @@ void CalpontSelectExecutionPlan::unserialize(messageqcpp::ByteStream& b)
|
||||
// for union
|
||||
b >> (uint8_t&)(fDistinctUnionNum);
|
||||
b >> size;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
cep = ObjectReader::createExecutionPlan(b);
|
||||
fUnionVec.push_back(SCEP(cep));
|
||||
}
|
||||
|
||||
b >> (uint64_t&)fSubType;
|
||||
|
||||
// for FROM subquery
|
||||
b >> size;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
cep = ObjectReader::createExecutionPlan(b);
|
||||
@@ -581,6 +648,7 @@ void CalpontSelectExecutionPlan::unserialize(messageqcpp::ByteStream& b)
|
||||
|
||||
// for SELECT subquery
|
||||
b >> size;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
cep = ObjectReader::createExecutionPlan(b);
|
||||
@@ -617,13 +685,15 @@ bool CalpontSelectExecutionPlan::operator==(const CalpontSelectExecutionPlan& t)
|
||||
//fReturnedCols
|
||||
if (fReturnedCols.size() != t.fReturnedCols.size())
|
||||
return false;
|
||||
|
||||
for (rcit = fReturnedCols.begin(), rcit2 = t.fReturnedCols.begin();
|
||||
rcit != fReturnedCols.end(); ++rcit, ++rcit2)
|
||||
if (**rcit != **rcit2)
|
||||
return false;
|
||||
|
||||
//fFilters
|
||||
if (fFilters != NULL && t.fFilters != NULL) {
|
||||
if (fFilters != NULL && t.fFilters != NULL)
|
||||
{
|
||||
if (*fFilters != *t.fFilters)
|
||||
return false;
|
||||
}
|
||||
@@ -633,6 +703,7 @@ bool CalpontSelectExecutionPlan::operator==(const CalpontSelectExecutionPlan& t)
|
||||
//fSubSelects
|
||||
if (fSubSelects.size() != t.fSubSelects.size())
|
||||
return false;
|
||||
|
||||
for (sit = fSubSelects.begin(), sit2 = t.fSubSelects.begin();
|
||||
sit != fSubSelects.end(); ++sit, ++sit2)
|
||||
if (*((*sit).get()) != (*sit2).get())
|
||||
@@ -641,13 +712,15 @@ bool CalpontSelectExecutionPlan::operator==(const CalpontSelectExecutionPlan& t)
|
||||
//fGroupByCols
|
||||
if (fGroupByCols.size() != t.fGroupByCols.size())
|
||||
return false;
|
||||
|
||||
for (rcit = fGroupByCols.begin(), rcit2 = t.fGroupByCols.begin();
|
||||
rcit != fGroupByCols.end(); ++rcit, ++rcit2)
|
||||
if (**rcit != **rcit2)
|
||||
return false;
|
||||
|
||||
//fHaving
|
||||
if (fHaving != NULL && t.fHaving != NULL) {
|
||||
if (fHaving != NULL && t.fHaving != NULL)
|
||||
{
|
||||
if (*fHaving != *t.fHaving)
|
||||
return false;
|
||||
}
|
||||
@@ -657,6 +730,7 @@ bool CalpontSelectExecutionPlan::operator==(const CalpontSelectExecutionPlan& t)
|
||||
//fOrderByCols
|
||||
if (fOrderByCols.size() != t.fOrderByCols.size())
|
||||
return false;
|
||||
|
||||
for (rcit = fOrderByCols.begin(), rcit2 = t.fOrderByCols.begin();
|
||||
rcit != fOrderByCols.end(); ++rcit, ++rcit2)
|
||||
if (**rcit != **rcit2)
|
||||
@@ -665,6 +739,7 @@ bool CalpontSelectExecutionPlan::operator==(const CalpontSelectExecutionPlan& t)
|
||||
//fColumnMap
|
||||
if (fColumnMap.size() != t.fColumnMap.size())
|
||||
return false;
|
||||
|
||||
for (map_it = fColumnMap.begin(), map_it2 = t.fColumnMap.begin();
|
||||
map_it != fColumnMap.end(); ++map_it, ++map_it2)
|
||||
if (*(map_it->second) != *(map_it2->second))
|
||||
@@ -672,26 +747,36 @@ bool CalpontSelectExecutionPlan::operator==(const CalpontSelectExecutionPlan& t)
|
||||
|
||||
if (fTableAlias != t.fTableAlias)
|
||||
return false;
|
||||
|
||||
if (fLocation != t.fLocation)
|
||||
return false;
|
||||
|
||||
if (fDependent != t.fDependent)
|
||||
return false;
|
||||
|
||||
// Trace flags don't affect equivalency?
|
||||
//if (fTraceFlags != t.fTraceFlags) return false;
|
||||
if (fStatementID != t.fStatementID)
|
||||
return false;
|
||||
|
||||
if (fSubType != t.fSubType)
|
||||
return false;
|
||||
|
||||
if (fPriority != t.fPriority)
|
||||
return false;
|
||||
|
||||
if (fStringTableThreshold != t.fStringTableThreshold)
|
||||
return false;
|
||||
|
||||
if (fDJSSmallSideLimit != t.fDJSSmallSideLimit)
|
||||
return false;
|
||||
|
||||
if (fDJSLargeSideLimit != t.fDJSLargeSideLimit)
|
||||
return false;
|
||||
|
||||
if (fDJSPartitionSize != t.fDJSPartitionSize)
|
||||
return false;
|
||||
|
||||
if (fUMMemLimit != t.fUMMemLimit)
|
||||
return false;
|
||||
|
||||
@@ -703,8 +788,10 @@ bool CalpontSelectExecutionPlan::operator==(const CalpontExecutionPlan* t) const
|
||||
const CalpontSelectExecutionPlan* ac;
|
||||
|
||||
ac = dynamic_cast<const CalpontSelectExecutionPlan*>(t);
|
||||
|
||||
if (ac == NULL)
|
||||
return false;
|
||||
|
||||
return *this == *ac;
|
||||
}
|
||||
|
||||
@@ -724,6 +811,7 @@ void CalpontSelectExecutionPlan::columnMap (const ColumnMap& columnMap)
|
||||
fColumnMap.erase(fColumnMap.begin(), fColumnMap.end());
|
||||
|
||||
SRCP srcp;
|
||||
|
||||
for (map_it2 = columnMap.begin(); map_it2 != columnMap.end(); ++map_it2)
|
||||
{
|
||||
srcp.reset(map_it2->second->clone());
|
||||
|
||||
@@ -47,7 +47,8 @@
|
||||
/**
|
||||
* Namespace
|
||||
*/
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
|
||||
enum RM_PARMS
|
||||
{
|
||||
@@ -72,7 +73,8 @@ typedef boost::shared_ptr<CalpontSelectExecutionPlan> SCSEP;
|
||||
* This class is a concrete implementation of a CalpontExecutionPlan
|
||||
* specifically describing a SQL select activity.
|
||||
*/
|
||||
class CalpontSelectExecutionPlan : public CalpontExecutionPlan {
|
||||
class CalpontSelectExecutionPlan : public CalpontExecutionPlan
|
||||
{
|
||||
|
||||
/**
|
||||
* Public stuff
|
||||
@@ -191,23 +193,46 @@ public:
|
||||
/**
|
||||
* returned column list
|
||||
*/
|
||||
const ReturnedColumnList& returnedCols() const { return fReturnedCols; }
|
||||
ReturnedColumnList& returnedCols() { return fReturnedCols; }
|
||||
const ReturnedColumnList& returnedCols() const
|
||||
{
|
||||
return fReturnedCols;
|
||||
}
|
||||
ReturnedColumnList& returnedCols()
|
||||
{
|
||||
return fReturnedCols;
|
||||
}
|
||||
void returnedCols (const ReturnedColumnList& returnedCols)
|
||||
{ fReturnedCols = returnedCols; }
|
||||
{
|
||||
fReturnedCols = returnedCols;
|
||||
}
|
||||
|
||||
/**
|
||||
* Are we in local PM only query mode?
|
||||
*/
|
||||
const uint32_t localQuery() const { return fLocalQuery; }
|
||||
void localQuery (const uint32_t localQuery) { fLocalQuery = localQuery; }
|
||||
const uint32_t localQuery() const
|
||||
{
|
||||
return fLocalQuery;
|
||||
}
|
||||
void localQuery (const uint32_t localQuery)
|
||||
{
|
||||
fLocalQuery = localQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* filters parse tree
|
||||
*/
|
||||
const ParseTree* filters() const { return fFilters; }
|
||||
ParseTree* filters() { return fFilters; }
|
||||
void filters (ParseTree* filters) { fFilters = filters; }
|
||||
const ParseTree* filters() const
|
||||
{
|
||||
return fFilters;
|
||||
}
|
||||
ParseTree* filters()
|
||||
{
|
||||
return fFilters;
|
||||
}
|
||||
void filters (ParseTree* filters)
|
||||
{
|
||||
fFilters = filters;
|
||||
}
|
||||
|
||||
/** filter token list
|
||||
* Set filter list field and build filters tree from the filter list
|
||||
@@ -220,186 +245,445 @@ public:
|
||||
/**
|
||||
* sub select list
|
||||
*/
|
||||
const SelectList& subSelects() const { return fSubSelects; }
|
||||
void subSelects (const SelectList& subSelects){ fSubSelects = subSelects; }
|
||||
const SelectList& subSelects() const
|
||||
{
|
||||
return fSubSelects;
|
||||
}
|
||||
void subSelects (const SelectList& subSelects)
|
||||
{
|
||||
fSubSelects = subSelects;
|
||||
}
|
||||
|
||||
/**
|
||||
* group by column list
|
||||
*/
|
||||
const GroupByColumnList& groupByCols() const { return fGroupByCols; }
|
||||
GroupByColumnList& groupByCols() { return fGroupByCols; }
|
||||
const GroupByColumnList& groupByCols() const
|
||||
{
|
||||
return fGroupByCols;
|
||||
}
|
||||
GroupByColumnList& groupByCols()
|
||||
{
|
||||
return fGroupByCols;
|
||||
}
|
||||
void groupByCols( const GroupByColumnList& groupByCols)
|
||||
{ fGroupByCols = groupByCols; }
|
||||
{
|
||||
fGroupByCols = groupByCols;
|
||||
}
|
||||
|
||||
/**
|
||||
* order by column list
|
||||
*/
|
||||
const OrderByColumnList& orderByCols() const { return fOrderByCols; }
|
||||
OrderByColumnList& orderByCols() { return fOrderByCols; }
|
||||
const OrderByColumnList& orderByCols() const
|
||||
{
|
||||
return fOrderByCols;
|
||||
}
|
||||
OrderByColumnList& orderByCols()
|
||||
{
|
||||
return fOrderByCols;
|
||||
}
|
||||
void orderByCols( const OrderByColumnList& orderByCols)
|
||||
{ fOrderByCols = orderByCols; }
|
||||
{
|
||||
fOrderByCols = orderByCols;
|
||||
}
|
||||
|
||||
/**
|
||||
* table alias
|
||||
*/
|
||||
const std::string& tableAlias() const { return fTableAlias; }
|
||||
void tableAlias (const std::string& tableAlias) { fTableAlias = tableAlias; }
|
||||
const std::string& tableAlias() const
|
||||
{
|
||||
return fTableAlias;
|
||||
}
|
||||
void tableAlias (const std::string& tableAlias)
|
||||
{
|
||||
fTableAlias = tableAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* location of this select
|
||||
*/
|
||||
const int location () const { return fLocation; }
|
||||
void location (const int location) { fLocation = location; }
|
||||
const int location () const
|
||||
{
|
||||
return fLocation;
|
||||
}
|
||||
void location (const int location)
|
||||
{
|
||||
fLocation = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* dependence of this select
|
||||
*/
|
||||
const bool dependent() const { return fDependent; }
|
||||
void dependent (const bool dependent) { fDependent = dependent; }
|
||||
const bool dependent() const
|
||||
{
|
||||
return fDependent;
|
||||
}
|
||||
void dependent (const bool dependent)
|
||||
{
|
||||
fDependent = dependent;
|
||||
}
|
||||
|
||||
/**
|
||||
* having filter parse tree
|
||||
*/
|
||||
inline const ParseTree* having() const { return fHaving; }
|
||||
inline ParseTree* having() { return fHaving; }
|
||||
inline void having (ParseTree* having) { fHaving = having; }
|
||||
inline const ParseTree* having() const
|
||||
{
|
||||
return fHaving;
|
||||
}
|
||||
inline ParseTree* having()
|
||||
{
|
||||
return fHaving;
|
||||
}
|
||||
inline void having (ParseTree* having)
|
||||
{
|
||||
fHaving = having;
|
||||
}
|
||||
|
||||
/** having filter token list
|
||||
* Set filter list field and build filters tree from the filter list
|
||||
* This is an alternative way to build filter tree. Hide the parser
|
||||
* from the user
|
||||
*/
|
||||
const FilterTokenList& havingTokenList() const { return fHavingTokenList; }
|
||||
const FilterTokenList& havingTokenList() const
|
||||
{
|
||||
return fHavingTokenList;
|
||||
}
|
||||
void havingTokenList (const FilterTokenList& havingTokenList);
|
||||
|
||||
/** column map
|
||||
* all the columns appeared on query
|
||||
*/
|
||||
const ColumnMap& columnMap() const {return fColumnMap;}
|
||||
const ColumnMap& columnMap() const
|
||||
{
|
||||
return fColumnMap;
|
||||
}
|
||||
|
||||
/** assign the static fColMap to non-static fColumnMap. map-wise copy */
|
||||
void columnMap (const ColumnMap& columnMap);
|
||||
|
||||
/** assign a regular map object to non-static fColumnMap. pure assignment */
|
||||
// @note this is to fix memory leak in CSC, becasue no static map is needed there.
|
||||
inline void columnMapNonStatic (const ColumnMap& columnMap) {fColumnMap = columnMap;}
|
||||
inline void columnMapNonStatic (const ColumnMap& columnMap)
|
||||
{
|
||||
fColumnMap = columnMap;
|
||||
}
|
||||
|
||||
/** sql representation of this select query
|
||||
*
|
||||
*/
|
||||
const std::string data() const { return fData; }
|
||||
void data ( const std::string data ) { fData = data; }
|
||||
const std::string data() const
|
||||
{
|
||||
return fData;
|
||||
}
|
||||
void data ( const std::string data )
|
||||
{
|
||||
fData = data;
|
||||
}
|
||||
|
||||
/** session id
|
||||
*
|
||||
*/
|
||||
const uint32_t sessionID() const { return fSessionID; }
|
||||
void sessionID ( const uint32_t sessionID ) { fSessionID = sessionID; }
|
||||
const uint32_t sessionID() const
|
||||
{
|
||||
return fSessionID;
|
||||
}
|
||||
void sessionID ( const uint32_t sessionID )
|
||||
{
|
||||
fSessionID = sessionID;
|
||||
}
|
||||
|
||||
/** transaction id
|
||||
*
|
||||
*/
|
||||
const int txnID() const { return fTxnID; }
|
||||
void txnID ( const int txnID ) { fTxnID = txnID; }
|
||||
const int txnID() const
|
||||
{
|
||||
return fTxnID;
|
||||
}
|
||||
void txnID ( const int txnID )
|
||||
{
|
||||
fTxnID = txnID;
|
||||
}
|
||||
|
||||
/** version id
|
||||
*
|
||||
*/
|
||||
const BRM::QueryContext verID() const { return fVerID; }
|
||||
void verID ( const BRM::QueryContext verID ) { fVerID = verID; }
|
||||
const BRM::QueryContext verID() const
|
||||
{
|
||||
return fVerID;
|
||||
}
|
||||
void verID ( const BRM::QueryContext verID )
|
||||
{
|
||||
fVerID = verID;
|
||||
}
|
||||
|
||||
inline static ColumnMap& colMap() {return fColMap;}
|
||||
inline static ColumnMap& colMap()
|
||||
{
|
||||
return fColMap;
|
||||
}
|
||||
|
||||
inline std::string& schemaName() { return fSchemaName; }
|
||||
inline void schemaName(const std::string& schemaName) { fSchemaName = schemaName; }
|
||||
inline std::string& schemaName()
|
||||
{
|
||||
return fSchemaName;
|
||||
}
|
||||
inline void schemaName(const std::string& schemaName)
|
||||
{
|
||||
fSchemaName = schemaName;
|
||||
}
|
||||
|
||||
inline std::string& tableName() { return fTableName; }
|
||||
inline void tableName(const std::string& tableName) { fTableName = tableName; }
|
||||
inline std::string& tableName()
|
||||
{
|
||||
return fTableName;
|
||||
}
|
||||
inline void tableName(const std::string& tableName)
|
||||
{
|
||||
fTableName = tableName;
|
||||
}
|
||||
|
||||
inline void traceOn(bool traceOn) __attribute__((deprecated))
|
||||
{ if (traceOn) fTraceFlags |= TRACE_LOG; else fTraceFlags &= ~TRACE_LOG; }
|
||||
inline bool traceOn() const { return (traceFlags() & TRACE_LOG); }
|
||||
{
|
||||
if (traceOn) fTraceFlags |= TRACE_LOG;
|
||||
else fTraceFlags &= ~TRACE_LOG;
|
||||
}
|
||||
inline bool traceOn() const
|
||||
{
|
||||
return (traceFlags() & TRACE_LOG);
|
||||
}
|
||||
|
||||
inline uint32_t traceFlags() const { return fTraceFlags; }
|
||||
inline void traceFlags(uint32_t traceFlags) { fTraceFlags = traceFlags; }
|
||||
inline uint32_t traceFlags() const
|
||||
{
|
||||
return fTraceFlags;
|
||||
}
|
||||
inline void traceFlags(uint32_t traceFlags)
|
||||
{
|
||||
fTraceFlags = traceFlags;
|
||||
}
|
||||
|
||||
const uint32_t statementID() const { return fStatementID; }
|
||||
void statementID (const uint32_t statementID) {fStatementID = statementID;}
|
||||
const uint32_t statementID() const
|
||||
{
|
||||
return fStatementID;
|
||||
}
|
||||
void statementID (const uint32_t statementID)
|
||||
{
|
||||
fStatementID = statementID;
|
||||
}
|
||||
|
||||
const RMParmVec& rmParms() { return frmParms; }
|
||||
const RMParmVec& rmParms()
|
||||
{
|
||||
return frmParms;
|
||||
}
|
||||
void rmParms (const RMParmVec& parms);
|
||||
|
||||
const TableList& tableList() const { return fTableList; }
|
||||
void tableList (const TableList& tableList) { fTableList = tableList; }
|
||||
const TableList& tableList() const
|
||||
{
|
||||
return fTableList;
|
||||
}
|
||||
void tableList (const TableList& tableList)
|
||||
{
|
||||
fTableList = tableList;
|
||||
}
|
||||
|
||||
const SelectList& derivedTableList() const { return fDerivedTableList; }
|
||||
void derivedTableList(SelectList& derivedTableList) { fDerivedTableList = derivedTableList; }
|
||||
const SelectList& derivedTableList() const
|
||||
{
|
||||
return fDerivedTableList;
|
||||
}
|
||||
void derivedTableList(SelectList& derivedTableList)
|
||||
{
|
||||
fDerivedTableList = derivedTableList;
|
||||
}
|
||||
|
||||
const bool distinct() const {return fDistinct;}
|
||||
void distinct(const bool distinct) {fDistinct = distinct;}
|
||||
const bool distinct() const
|
||||
{
|
||||
return fDistinct;
|
||||
}
|
||||
void distinct(const bool distinct)
|
||||
{
|
||||
fDistinct = distinct;
|
||||
}
|
||||
|
||||
void overrideLargeSideEstimate (const bool over) {fOverrideLargeSideEstimate = over;}
|
||||
const bool overrideLargeSideEstimate() const { return fOverrideLargeSideEstimate; }
|
||||
void overrideLargeSideEstimate (const bool over)
|
||||
{
|
||||
fOverrideLargeSideEstimate = over;
|
||||
}
|
||||
const bool overrideLargeSideEstimate() const
|
||||
{
|
||||
return fOverrideLargeSideEstimate;
|
||||
}
|
||||
|
||||
void unionVec(const SelectList& unionVec) { fUnionVec = unionVec; }
|
||||
const SelectList& unionVec() const { return fUnionVec; }
|
||||
SelectList& unionVec() { return fUnionVec; }
|
||||
void unionVec(const SelectList& unionVec)
|
||||
{
|
||||
fUnionVec = unionVec;
|
||||
}
|
||||
const SelectList& unionVec() const
|
||||
{
|
||||
return fUnionVec;
|
||||
}
|
||||
SelectList& unionVec()
|
||||
{
|
||||
return fUnionVec;
|
||||
}
|
||||
|
||||
void distinctUnionNum(const uint8_t distinctUnionNum) { fDistinctUnionNum = distinctUnionNum; }
|
||||
const uint8_t distinctUnionNum() const { return fDistinctUnionNum; }
|
||||
void distinctUnionNum(const uint8_t distinctUnionNum)
|
||||
{
|
||||
fDistinctUnionNum = distinctUnionNum;
|
||||
}
|
||||
const uint8_t distinctUnionNum() const
|
||||
{
|
||||
return fDistinctUnionNum;
|
||||
}
|
||||
|
||||
void subType(const uint64_t subType) { fSubType = subType; }
|
||||
const uint64_t subType() const { return fSubType; }
|
||||
void subType(const uint64_t subType)
|
||||
{
|
||||
fSubType = subType;
|
||||
}
|
||||
const uint64_t subType() const
|
||||
{
|
||||
return fSubType;
|
||||
}
|
||||
|
||||
void derivedTbAlias(const std::string derivedTbAlias) { fDerivedTbAlias = derivedTbAlias; }
|
||||
const std::string derivedTbAlias() const { return fDerivedTbAlias; }
|
||||
void derivedTbAlias(const std::string derivedTbAlias)
|
||||
{
|
||||
fDerivedTbAlias = derivedTbAlias;
|
||||
}
|
||||
const std::string derivedTbAlias() const
|
||||
{
|
||||
return fDerivedTbAlias;
|
||||
}
|
||||
|
||||
void limitStart(const uint64_t limitStart) { fLimitStart = limitStart; }
|
||||
const uint64_t limitStart() const { return fLimitStart; }
|
||||
void limitStart(const uint64_t limitStart)
|
||||
{
|
||||
fLimitStart = limitStart;
|
||||
}
|
||||
const uint64_t limitStart() const
|
||||
{
|
||||
return fLimitStart;
|
||||
}
|
||||
|
||||
void limitNum(const uint64_t limitNum) { fLimitNum = limitNum; }
|
||||
const uint64_t limitNum() const { return fLimitNum; }
|
||||
void limitNum(const uint64_t limitNum)
|
||||
{
|
||||
fLimitNum = limitNum;
|
||||
}
|
||||
const uint64_t limitNum() const
|
||||
{
|
||||
return fLimitNum;
|
||||
}
|
||||
|
||||
void hasOrderBy(const bool hasOrderBy) { fHasOrderBy = hasOrderBy; }
|
||||
const bool hasOrderBy() const { return fHasOrderBy; }
|
||||
void hasOrderBy(const bool hasOrderBy)
|
||||
{
|
||||
fHasOrderBy = hasOrderBy;
|
||||
}
|
||||
const bool hasOrderBy() const
|
||||
{
|
||||
return fHasOrderBy;
|
||||
}
|
||||
|
||||
void selectSubList(const SelectList& selectSubList) { fSelectSubList = selectSubList; }
|
||||
const SelectList& selectSubList() const { return fSelectSubList; }
|
||||
void selectSubList(const SelectList& selectSubList)
|
||||
{
|
||||
fSelectSubList = selectSubList;
|
||||
}
|
||||
const SelectList& selectSubList() const
|
||||
{
|
||||
return fSelectSubList;
|
||||
}
|
||||
|
||||
void subSelectList(const std::vector<execplan::SCSEP>& subSelectList) { fSubSelectList = subSelectList; }
|
||||
const std::vector<execplan::SCSEP>& subSelectList() const { return fSubSelectList; }
|
||||
void subSelectList(const std::vector<execplan::SCSEP>& subSelectList)
|
||||
{
|
||||
fSubSelectList = subSelectList;
|
||||
}
|
||||
const std::vector<execplan::SCSEP>& subSelectList() const
|
||||
{
|
||||
return fSubSelectList;
|
||||
}
|
||||
|
||||
void stringScanThreshold(uint64_t n) { fStringScanThreshold = n; }
|
||||
uint64_t stringScanThreshold() const { return fStringScanThreshold; }
|
||||
void stringScanThreshold(uint64_t n)
|
||||
{
|
||||
fStringScanThreshold = n;
|
||||
}
|
||||
uint64_t stringScanThreshold() const
|
||||
{
|
||||
return fStringScanThreshold;
|
||||
}
|
||||
|
||||
// query type. return string for easy stats insert
|
||||
void queryType(const uint32_t queryType) { fQueryType = queryType; }
|
||||
const std::string queryType() const { return queryTypeToString(fQueryType); }
|
||||
void queryType(const uint32_t queryType)
|
||||
{
|
||||
fQueryType = queryType;
|
||||
}
|
||||
const std::string queryType() const
|
||||
{
|
||||
return queryTypeToString(fQueryType);
|
||||
}
|
||||
static std::string queryTypeToString(const uint32_t queryType);
|
||||
|
||||
void priority(uint32_t p) { fPriority = p; }
|
||||
uint32_t priority() const { return fPriority; }
|
||||
void priority(uint32_t p)
|
||||
{
|
||||
fPriority = p;
|
||||
}
|
||||
uint32_t priority() const
|
||||
{
|
||||
return fPriority;
|
||||
}
|
||||
|
||||
void stringTableThreshold(uint32_t t) { fStringTableThreshold = t; }
|
||||
uint32_t stringTableThreshold() const { return fStringTableThreshold; }
|
||||
void stringTableThreshold(uint32_t t)
|
||||
{
|
||||
fStringTableThreshold = t;
|
||||
}
|
||||
uint32_t stringTableThreshold() const
|
||||
{
|
||||
return fStringTableThreshold;
|
||||
}
|
||||
|
||||
void uuid(const boost::uuids::uuid& uuid) { fUuid = uuid; }
|
||||
const boost::uuids::uuid& uuid() const { return fUuid; }
|
||||
void uuid(const boost::uuids::uuid& uuid)
|
||||
{
|
||||
fUuid = uuid;
|
||||
}
|
||||
const boost::uuids::uuid& uuid() const
|
||||
{
|
||||
return fUuid;
|
||||
}
|
||||
|
||||
void djsSmallSideLimit(uint64_t l) { fDJSSmallSideLimit = l; }
|
||||
uint64_t djsSmallSideLimit() { return fDJSSmallSideLimit; }
|
||||
void djsSmallSideLimit(uint64_t l)
|
||||
{
|
||||
fDJSSmallSideLimit = l;
|
||||
}
|
||||
uint64_t djsSmallSideLimit()
|
||||
{
|
||||
return fDJSSmallSideLimit;
|
||||
}
|
||||
|
||||
void djsLargeSideLimit(uint64_t l) { fDJSLargeSideLimit = l; }
|
||||
uint64_t djsLargeSideLimit() { return fDJSLargeSideLimit; }
|
||||
void djsLargeSideLimit(uint64_t l)
|
||||
{
|
||||
fDJSLargeSideLimit = l;
|
||||
}
|
||||
uint64_t djsLargeSideLimit()
|
||||
{
|
||||
return fDJSLargeSideLimit;
|
||||
}
|
||||
|
||||
void djsPartitionSize(uint64_t l) { fDJSPartitionSize = l; }
|
||||
uint64_t djsPartitionSize() { return fDJSPartitionSize; }
|
||||
void djsPartitionSize(uint64_t l)
|
||||
{
|
||||
fDJSPartitionSize = l;
|
||||
}
|
||||
uint64_t djsPartitionSize()
|
||||
{
|
||||
return fDJSPartitionSize;
|
||||
}
|
||||
|
||||
void umMemLimit(uint64_t l) { fUMMemLimit = l; }
|
||||
int64_t umMemLimit() { return fUMMemLimit; }
|
||||
void umMemLimit(uint64_t l)
|
||||
{
|
||||
fUMMemLimit = l;
|
||||
}
|
||||
int64_t umMemLimit()
|
||||
{
|
||||
return fUMMemLimit;
|
||||
}
|
||||
|
||||
void isDML(bool b) { fIsDML = b; }
|
||||
bool isDML() { return fIsDML; }
|
||||
void isDML(bool b)
|
||||
{
|
||||
fIsDML = b;
|
||||
}
|
||||
bool isDML()
|
||||
{
|
||||
return fIsDML;
|
||||
}
|
||||
|
||||
/**
|
||||
* The serialization interface
|
||||
@@ -451,7 +735,10 @@ public:
|
||||
* FIXME: add a setter and make this work for really big session ids
|
||||
* @return true/false
|
||||
*/
|
||||
virtual bool isInternal() const { return ((fSessionID & 0x80000000) != 0); }
|
||||
virtual bool isInternal() const
|
||||
{
|
||||
return ((fSessionID & 0x80000000) != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Protected stuff
|
||||
@@ -603,7 +890,10 @@ private:
|
||||
*/
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const CalpontSelectExecutionPlan& rhs)
|
||||
{ os << rhs.toString(); return os; }
|
||||
{
|
||||
os << rhs.toString();
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
#endif //CALPONTSELECTEXECUTIONPLAN_H
|
||||
|
||||
411
dbcon/execplan/calpontsystemcatalog.cpp
Executable file → Normal file
411
dbcon/execplan/calpontsystemcatalog.cpp
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
128
dbcon/execplan/calpontsystemcatalog.h
Executable file → Normal file
128
dbcon/execplan/calpontsystemcatalog.h
Executable file → Normal file
@@ -207,12 +207,16 @@ public:
|
||||
{
|
||||
if (dictOID != t.dictOID)
|
||||
return false;
|
||||
|
||||
if (listOID != t.listOID)
|
||||
return false;
|
||||
|
||||
if (treeOID != t.treeOID)
|
||||
return false;
|
||||
|
||||
if (compressionType != t.compressionType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
bool operator!=(const DictOID& t) const
|
||||
@@ -231,15 +235,28 @@ public:
|
||||
NJLSysDataVector sysDataVec;
|
||||
NJLSysDataList() {};
|
||||
~NJLSysDataList();
|
||||
NJLSysDataVector::const_iterator begin() const {return sysDataVec.begin();}
|
||||
NJLSysDataVector::const_iterator end() const {return sysDataVec.end();}
|
||||
void push_back(ColumnResult* cr) {sysDataVec.push_back(cr);}
|
||||
NJLSysDataVector::size_type size() const {return sysDataVec.size();}
|
||||
NJLSysDataVector::const_iterator begin() const
|
||||
{
|
||||
return sysDataVec.begin();
|
||||
}
|
||||
NJLSysDataVector::const_iterator end() const
|
||||
{
|
||||
return sysDataVec.end();
|
||||
}
|
||||
void push_back(ColumnResult* cr)
|
||||
{
|
||||
sysDataVec.push_back(cr);
|
||||
}
|
||||
NJLSysDataVector::size_type size() const
|
||||
{
|
||||
return sysDataVec.size();
|
||||
}
|
||||
NJLSysDataVector::size_type findColumn(const OID& columnOID) const
|
||||
{
|
||||
for (NJLSysDataVector::size_type i = 0; i < sysDataVec.size(); i++)
|
||||
if (sysDataVec[i]->ColumnOID() == columnOID)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
@@ -314,18 +331,25 @@ public:
|
||||
//order these with the most likely first
|
||||
if (columnOID != t.columnOID)
|
||||
return false;
|
||||
|
||||
if (colPosition != t.colPosition)
|
||||
return false;
|
||||
|
||||
if (ddn != t.ddn)
|
||||
return false;
|
||||
|
||||
if (colWidth != t.colWidth)
|
||||
return false;
|
||||
|
||||
if (scale != t.scale)
|
||||
return false;
|
||||
|
||||
if (precision != t.precision)
|
||||
return false;
|
||||
|
||||
if (constraintType != t.constraintType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -409,14 +433,22 @@ public:
|
||||
bool fIsInfiniDB;
|
||||
void clear();
|
||||
bool operator<(const TableAliasName& rhs) const;
|
||||
bool operator>=(const TableAliasName& rhs) const { return !(*this < rhs); }
|
||||
bool operator>=(const TableAliasName& rhs) const
|
||||
{
|
||||
return !(*this < rhs);
|
||||
}
|
||||
bool operator==(const TableAliasName& rhs) const
|
||||
{ return (schema == rhs.schema &&
|
||||
{
|
||||
return (schema == rhs.schema &&
|
||||
table == rhs.table &&
|
||||
alias == rhs.alias &&
|
||||
view == rhs.view &&
|
||||
fIsInfiniDB == rhs.fIsInfiniDB); }
|
||||
bool operator!=(const TableAliasName& rhs) const { return !(*this == rhs); }
|
||||
fIsInfiniDB == rhs.fIsInfiniDB);
|
||||
}
|
||||
bool operator!=(const TableAliasName& rhs) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
void serialize(messageqcpp::ByteStream&) const;
|
||||
void unserialize(messageqcpp::ByteStream&);
|
||||
friend std::ostream& operator<<(std::ostream& os, const TableAliasName& rhs);
|
||||
@@ -435,13 +467,24 @@ public:
|
||||
std::string table;
|
||||
int64_t create_date;
|
||||
bool operator<(const TableName& rhs) const;
|
||||
bool operator>=(const TableName& rhs) const { return !(*this < rhs); }
|
||||
bool operator>=(const TableName& rhs) const
|
||||
{
|
||||
return !(*this < rhs);
|
||||
}
|
||||
bool operator==(const TableName& rhs) const
|
||||
{ return (schema == rhs.schema && table == rhs.table); }
|
||||
bool operator!=(const TableName& rhs) const { return !(*this == rhs); }
|
||||
{
|
||||
return (schema == rhs.schema && table == rhs.table);
|
||||
}
|
||||
bool operator!=(const TableName& rhs) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
const std::string toString() const;
|
||||
friend std::ostream& operator<<(std::ostream& os, const TableName& rhs)
|
||||
{ os << rhs.toString(); return os; }
|
||||
{
|
||||
os << rhs.toString();
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
/** the structure passed into get RID for Index values
|
||||
@@ -766,13 +809,25 @@ public:
|
||||
/** sessionid access and mutator methods
|
||||
*
|
||||
*/
|
||||
const uint32_t sessionID() const { return fSessionID; }
|
||||
void sessionID (uint32_t sessionID) { fSessionID = sessionID; }
|
||||
const uint32_t sessionID() const
|
||||
{
|
||||
return fSessionID;
|
||||
}
|
||||
void sessionID (uint32_t sessionID)
|
||||
{
|
||||
fSessionID = sessionID;
|
||||
}
|
||||
/** identity access and mutator methods
|
||||
*
|
||||
*/
|
||||
const int identity() const { return fIdentity; }
|
||||
void identity (int identity) { fIdentity = identity; }
|
||||
const int identity() const
|
||||
{
|
||||
return fIdentity;
|
||||
}
|
||||
void identity (int identity)
|
||||
{
|
||||
fIdentity = identity;
|
||||
}
|
||||
|
||||
/** return the column position
|
||||
*
|
||||
@@ -937,6 +992,7 @@ inline bool isNumeric(const execplan::CalpontSystemCatalog::ColDataType type)
|
||||
case execplan::CalpontSystemCatalog::UDOUBLE:
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -952,6 +1008,7 @@ inline bool isUnsigned(const execplan::CalpontSystemCatalog::ColDataType type)
|
||||
case execplan::CalpontSystemCatalog::UINT:
|
||||
case execplan::CalpontSystemCatalog::UBIGINT:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -967,6 +1024,7 @@ inline bool isSignedInteger(const execplan::CalpontSystemCatalog::ColDataType ty
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -981,11 +1039,14 @@ inline bool isNull(int64_t val, const execplan::CalpontSystemCatalog::ColType& c
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
{
|
||||
if ((int8_t) joblist::TINYINTNULL == val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
{
|
||||
int colWidth = ct.colWidth;
|
||||
|
||||
if (colWidth <= 8)
|
||||
{
|
||||
if ((colWidth == 1) && ((int8_t) joblist::CHAR1NULL == val)) ret = true ;
|
||||
@@ -997,13 +1058,17 @@ inline bool isNull(int64_t val, const execplan::CalpontSystemCatalog::ColType& c
|
||||
{
|
||||
throw std::logic_error("Not a int column.");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
{
|
||||
if ((int16_t) joblist::SMALLINTNULL == val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
@@ -1012,61 +1077,82 @@ inline bool isNull(int64_t val, const execplan::CalpontSystemCatalog::ColType& c
|
||||
case 1:
|
||||
{
|
||||
if ((int8_t)joblist::TINYINTNULL == val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
if ((int16_t)joblist::SMALLINTNULL == val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
if ((int32_t)joblist::INTNULL == val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
if ((int64_t)joblist::BIGINTNULL == val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
case execplan::CalpontSystemCatalog::UDOUBLE:
|
||||
{
|
||||
if ((int64_t)joblist::DOUBLENULL == val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
{
|
||||
if ((int32_t)joblist::INTNULL == val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
case execplan::CalpontSystemCatalog::UFLOAT:
|
||||
{
|
||||
if ((int32_t)joblist::FLOATNULL == val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATE:
|
||||
{
|
||||
if ((int32_t) joblist::DATENULL == val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
{
|
||||
if ((int64_t)joblist::BIGINTNULL == val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATETIME:
|
||||
{
|
||||
if ((int64_t)joblist::DATETIMENULL == val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
{
|
||||
int colWidth = ct.colWidth;
|
||||
|
||||
if (colWidth <= 8)
|
||||
{
|
||||
if ((colWidth < 3) && ((int16_t) joblist::CHAR2NULL == val)) ret = true;
|
||||
@@ -1077,29 +1163,39 @@ inline bool isNull(int64_t val, const execplan::CalpontSystemCatalog::ColType& c
|
||||
{
|
||||
throw std::logic_error("Not a int column.");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::UTINYINT:
|
||||
{
|
||||
if (joblist::UTINYINTNULL == (uint8_t)val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::USMALLINT:
|
||||
{
|
||||
if (joblist::USMALLINTNULL == (uint16_t)val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::UMEDINT:
|
||||
case execplan::CalpontSystemCatalog::UINT:
|
||||
{
|
||||
if (joblist::UINTNULL == (uint32_t)val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::UBIGINT:
|
||||
{
|
||||
if (joblist::UBIGINTNULL == (uint64_t)val) ret = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ string ClientRotator::getModule()
|
||||
|
||||
if (moduleFile.is_open())
|
||||
getline (moduleFile, module);
|
||||
|
||||
moduleFile.close();
|
||||
return module;
|
||||
}
|
||||
@@ -82,6 +83,7 @@ ClientRotator::ClientRotator(uint32_t sid, const std::string& name, bool localQu
|
||||
{
|
||||
if (! fCf)
|
||||
throw runtime_error((string)__FILE__ + ": No configuration file");
|
||||
|
||||
fDebug = static_cast<int>(Config::fromText(fCf->getConfig("CalpontConnector", "DebugLevel")));
|
||||
}
|
||||
|
||||
@@ -98,6 +100,7 @@ void ClientRotator::loadClients()
|
||||
if (!fLocalQuery && pmWithUM)
|
||||
{
|
||||
string module = getModule();
|
||||
|
||||
if (!module.empty() && (module[0] == 'P' || module[0] == 'p'))
|
||||
fLocalQuery = true;
|
||||
}
|
||||
@@ -113,20 +116,25 @@ void ClientRotator::loadClients()
|
||||
size_t pos = fName.length();
|
||||
string str;
|
||||
int i = 1;
|
||||
|
||||
do
|
||||
{
|
||||
ss.seekp(pos);
|
||||
ss << i++;
|
||||
str = fCf->getConfig(ss.str(), "Port");
|
||||
|
||||
if (str.length() )
|
||||
{
|
||||
string moduleStr = fCf->getConfig(ss.str(), "Module");
|
||||
|
||||
// "if the system is not running in a 'PM with UM' config, the module type is unspecified, or the
|
||||
// module is specified as a UM, use it"
|
||||
if (!pmWithUM || moduleStr.empty() || moduleStr[0] == 'u' || moduleStr[0] == 'U')
|
||||
fClients.push_back(ss.str());
|
||||
}
|
||||
} while ( str.length() );
|
||||
}
|
||||
while ( str.length() );
|
||||
|
||||
if (fClients.empty())
|
||||
throw runtime_error((string)__FILE__ + ": No configuration tags for " + fName + "\n");
|
||||
}
|
||||
@@ -155,6 +163,7 @@ void ClientRotator::write(const ByteStream& msg)
|
||||
{
|
||||
if (!fClient)
|
||||
connect();
|
||||
|
||||
try
|
||||
{
|
||||
fClient->write(msg);
|
||||
@@ -181,6 +190,7 @@ ByteStream ClientRotator::read()
|
||||
mutex::scoped_lock lk(fClientLock);
|
||||
|
||||
ByteStream bs;
|
||||
|
||||
if (!fClient)
|
||||
connect();
|
||||
|
||||
@@ -205,6 +215,7 @@ ByteStream ClientRotator::read()
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
try //one more time...
|
||||
{
|
||||
delete fClient;
|
||||
@@ -222,6 +233,7 @@ ByteStream ClientRotator::read()
|
||||
#endif
|
||||
throw;
|
||||
}
|
||||
|
||||
#endif
|
||||
return bs;
|
||||
}
|
||||
@@ -270,7 +282,8 @@ bool ClientRotator::exeConnect( const string& clientName )
|
||||
writeToLog( __LINE__, "Connecting to " + clientName + " with sessionId " + ss.str(), 0);
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
if (!fClient->connect())
|
||||
{
|
||||
delete fClient;
|
||||
@@ -278,11 +291,13 @@ bool ClientRotator::exeConnect( const string& clientName )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(...) {
|
||||
catch (...)
|
||||
{
|
||||
delete fClient;
|
||||
fClient = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -297,21 +312,26 @@ void ClientRotator::connectList(double timeout)
|
||||
|
||||
idbassert(!fClients.empty());
|
||||
uint16_t idx = fSessionId % fClients.size();
|
||||
|
||||
if (++idx >= fClients.size() )
|
||||
idx = 0;
|
||||
|
||||
timer runTime;
|
||||
|
||||
while ( runTime.elapsed() < timeout)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (exeConnect(fClients.at(idx++)))
|
||||
return;
|
||||
|
||||
if (fClients.size() == idx)
|
||||
idx = 0;
|
||||
}
|
||||
catch (... )
|
||||
{ }
|
||||
}
|
||||
|
||||
#ifdef LOG_TO_CERR
|
||||
cerr << "Could not get a " << fName << " connection.\n";
|
||||
#endif
|
||||
@@ -330,6 +350,7 @@ void ClientRotator::writeToLog(int line, const string& msg, bool critical) const
|
||||
args.add(line);
|
||||
args.add(msg);
|
||||
m.format(args);
|
||||
|
||||
if (critical)
|
||||
ml.logCriticalMessage(m);
|
||||
else if (fDebug)
|
||||
|
||||
@@ -91,23 +91,38 @@ public:
|
||||
|
||||
/** @brief getClient
|
||||
*/
|
||||
messageqcpp::MessageQueueClient* getClient() const { return fClient; }
|
||||
messageqcpp::MessageQueueClient* getClient() const
|
||||
{
|
||||
return fClient;
|
||||
}
|
||||
|
||||
/** @brief getSessionId
|
||||
*/
|
||||
uint32_t getSessionId() const { return fSessionId; }
|
||||
uint32_t getSessionId() const
|
||||
{
|
||||
return fSessionId;
|
||||
}
|
||||
|
||||
/** @brief setSessionId
|
||||
*/
|
||||
void setSessionId(uint32_t sid) { fSessionId = sid; }
|
||||
void setSessionId(uint32_t sid)
|
||||
{
|
||||
fSessionId = sid;
|
||||
}
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& output, const ClientRotator& rhs);
|
||||
|
||||
/** @brief reset fClient */
|
||||
void resetClient();
|
||||
|
||||
bool localQuery() { return fLocalQuery; }
|
||||
void localQuery(bool localQuery) { fLocalQuery = localQuery; }
|
||||
bool localQuery()
|
||||
{
|
||||
return fLocalQuery;
|
||||
}
|
||||
void localQuery(bool localQuery)
|
||||
{
|
||||
fLocalQuery = localQuery;
|
||||
}
|
||||
static std::string getModule();
|
||||
|
||||
private:
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
|
||||
/** @file
|
||||
This serves as a bridge between the new and old joblist code.
|
||||
@@ -47,34 +48,57 @@ public:
|
||||
// the other defaults are OK.
|
||||
|
||||
int64_t GetData(uint32_t index) const
|
||||
{ return intData[index]; }
|
||||
{
|
||||
return intData[index];
|
||||
}
|
||||
|
||||
void PutData(int64_t d)
|
||||
{ intData.push_back(d); dcount++; }
|
||||
{
|
||||
intData.push_back(d);
|
||||
dcount++;
|
||||
}
|
||||
|
||||
const std::string& GetStringData(uint32_t index) const
|
||||
{ return stringData[index]; }
|
||||
{
|
||||
return stringData[index];
|
||||
}
|
||||
|
||||
void PutStringData(const std::string& s)
|
||||
{ stringData.push_back(s); dcount++; }
|
||||
{
|
||||
stringData.push_back(s);
|
||||
dcount++;
|
||||
}
|
||||
|
||||
int ColumnOID() const
|
||||
{ return oid; }
|
||||
{
|
||||
return oid;
|
||||
}
|
||||
|
||||
void SetColumnOID(int o)
|
||||
{ oid = o; }
|
||||
{
|
||||
oid = o;
|
||||
}
|
||||
|
||||
uint64_t GetRid(uint32_t index) const
|
||||
{ return rids[index]; }
|
||||
{
|
||||
return rids[index];
|
||||
}
|
||||
|
||||
void PutRid(uint64_t rid)
|
||||
{ rids.push_back(rid); }
|
||||
{
|
||||
rids.push_back(rid);
|
||||
}
|
||||
|
||||
void PutRidOnly(uint64_t rid)
|
||||
{ rids.push_back(rid); dcount++; }
|
||||
{
|
||||
rids.push_back(rid);
|
||||
dcount++;
|
||||
}
|
||||
|
||||
int dataCount() const
|
||||
{ return dcount; }
|
||||
{
|
||||
return dcount;
|
||||
}
|
||||
|
||||
private:
|
||||
//defaults okay
|
||||
|
||||
@@ -33,7 +33,8 @@ using namespace messageqcpp;
|
||||
#include "dataconvert.h"
|
||||
#include "calpontsystemcatalog.h"
|
||||
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
/**
|
||||
* Constructors/Destructors
|
||||
*/
|
||||
@@ -83,6 +84,7 @@ ConstantColumn::ConstantColumn(const string& sql, TYPE type) :
|
||||
{
|
||||
fResultType.colDataType = CalpontSystemCatalog::BIGINT;
|
||||
}
|
||||
|
||||
fResultType.colWidth = 8;
|
||||
}
|
||||
else
|
||||
@@ -227,8 +229,10 @@ ConstantColumn::ConstantColumn(const uint64_t val, TYPE type) :
|
||||
ConstantColumn::~ConstantColumn()
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
|
||||
if (fRegex.get() != NULL)
|
||||
regfree(fRegex.get());
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -237,15 +241,19 @@ const string ConstantColumn::toString() const
|
||||
ostringstream oss;
|
||||
oss << "ConstantColumn: " << fConstval << " intVal=" << fResult.intVal << " uintVal=" << fResult.uintVal;
|
||||
oss << '(';
|
||||
|
||||
if (fType == LITERAL)
|
||||
oss << 'l';
|
||||
else if (fType == NUM)
|
||||
oss << 'n';
|
||||
else
|
||||
oss << "null";
|
||||
|
||||
oss << ')';
|
||||
oss << " resultType=" << colDataTypeToString(fResultType.colDataType);
|
||||
|
||||
if (fAlias.length() > 0) oss << "/Alias: " << fAlias;
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
@@ -310,18 +318,25 @@ bool ConstantColumn::operator==(const ConstantColumn& t) const
|
||||
|
||||
rc1 = static_cast<const ReturnedColumn*>(this);
|
||||
rc2 = static_cast<const ReturnedColumn*>(&t);
|
||||
|
||||
if (*rc1 != *rc2)
|
||||
return false;
|
||||
|
||||
if (fConstval != t.fConstval)
|
||||
return false;
|
||||
|
||||
if (fType != t.fType)
|
||||
return false;
|
||||
|
||||
if (fAlias != t.fAlias)
|
||||
return false;
|
||||
|
||||
if (fData != t.fData)
|
||||
return false;
|
||||
|
||||
if (fReturnAll != t.fReturnAll)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -330,8 +345,10 @@ bool ConstantColumn::operator==(const TreeNode* t) const
|
||||
const ConstantColumn* o;
|
||||
|
||||
o = dynamic_cast<const ConstantColumn*>(t);
|
||||
|
||||
if (o == NULL)
|
||||
return false;
|
||||
|
||||
return *this == *o;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,21 +28,24 @@
|
||||
|
||||
#include "returnedcolumn.h"
|
||||
|
||||
namespace messageqcpp {
|
||||
namespace messageqcpp
|
||||
{
|
||||
class ByteStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Namespace
|
||||
*/
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
/**
|
||||
* @brief A class to represent a constant return column
|
||||
*
|
||||
* This class is a specialization of class ReturnedColumn that
|
||||
* handles a constant column such as number and literal string.
|
||||
*/
|
||||
class ConstantColumn : public ReturnedColumn {
|
||||
class ConstantColumn : public ReturnedColumn
|
||||
{
|
||||
public:
|
||||
|
||||
enum TYPE
|
||||
@@ -81,19 +84,31 @@ public:
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
inline unsigned int type() const { return fType; }
|
||||
inline unsigned int type() const
|
||||
{
|
||||
return fType;
|
||||
}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
inline void type (unsigned int type) { fType = type; }
|
||||
inline void type (unsigned int type)
|
||||
{
|
||||
fType = type;
|
||||
}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
inline const std::string& constval() const { return fConstval; }
|
||||
inline const std::string& constval() const
|
||||
{
|
||||
return fConstval;
|
||||
}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
inline void constval(const std::string& constval) { fConstval = constval; }
|
||||
inline void constval(const std::string& constval)
|
||||
{
|
||||
fConstval = constval;
|
||||
}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
@@ -101,7 +116,10 @@ public:
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
virtual void data(const std::string data) { fData = data; }
|
||||
virtual void data(const std::string data)
|
||||
{
|
||||
fData = data;
|
||||
}
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
@@ -111,7 +129,10 @@ public:
|
||||
*
|
||||
* deep copy of this pointer and return the copy
|
||||
*/
|
||||
inline virtual ConstantColumn* clone() const {return new ConstantColumn (*this);}
|
||||
inline virtual ConstantColumn* clone() const
|
||||
{
|
||||
return new ConstantColumn (*this);
|
||||
}
|
||||
|
||||
/*
|
||||
* The serialization interface
|
||||
@@ -153,10 +174,16 @@ public:
|
||||
*/
|
||||
bool operator!=(const ConstantColumn& t) const;
|
||||
|
||||
virtual bool hasWindowFunc() {return false;}
|
||||
virtual bool hasWindowFunc()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Constant column on the filte can always be moved into derived table */
|
||||
virtual void setDerivedTable() { fDerivedTable = "*"; }
|
||||
virtual void setDerivedTable()
|
||||
{
|
||||
fDerivedTable = "*";
|
||||
}
|
||||
|
||||
private:
|
||||
std::string fConstval;
|
||||
@@ -257,11 +284,13 @@ public:
|
||||
virtual int32_t getDateIntVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
isNull = isNull || (fType == NULLDATA);
|
||||
|
||||
if (!fResult.valueConverted)
|
||||
{
|
||||
fResult.intVal = dataconvert::DataConvert::stringToDate(fResult.strVal);
|
||||
fResult.valueConverted = true;
|
||||
}
|
||||
|
||||
return fResult.intVal;
|
||||
}
|
||||
/**
|
||||
@@ -270,21 +299,29 @@ public:
|
||||
virtual int64_t getDatetimeIntVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
isNull = isNull || (fType == NULLDATA);
|
||||
|
||||
if (!fResult.valueConverted)
|
||||
{
|
||||
fResult.intVal = dataconvert::DataConvert::stringToDatetime(fResult.strVal);
|
||||
fResult.valueConverted = true;
|
||||
}
|
||||
|
||||
return fResult.intVal;
|
||||
}
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
inline float getFloatVal() const { return fResult.floatVal; }
|
||||
inline float getFloatVal() const
|
||||
{
|
||||
return fResult.floatVal;
|
||||
}
|
||||
/**
|
||||
* F&E
|
||||
*/
|
||||
inline double getDoubleVal() const { return fResult.doubleVal; }
|
||||
inline double getDoubleVal() const
|
||||
{
|
||||
return fResult.doubleVal;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -37,14 +37,19 @@ using namespace std;
|
||||
#include "aggregatecolumn.h"
|
||||
#include "windowfunctioncolumn.h"
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
template<class T> struct deleter : public unary_function<T&, void>
|
||||
{
|
||||
void operator()(T& x) { delete x; }
|
||||
void operator()(T& x)
|
||||
{
|
||||
delete x;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructors/Destructors
|
||||
@@ -76,6 +81,7 @@ ConstantFilter::ConstantFilter(const ConstantFilter& rhs):
|
||||
fSimpleColumnList.clear();
|
||||
fWindowFunctionColumnList.clear();
|
||||
SSFP ssfp;
|
||||
|
||||
for (uint32_t i = 0; i < rhs.fFilterList.size(); i++)
|
||||
{
|
||||
ssfp.reset(rhs.fFilterList[i]->clone());
|
||||
@@ -104,9 +110,13 @@ const string ConstantFilter::toString() const
|
||||
{
|
||||
ostringstream output;
|
||||
output << "ConstantFilter" << endl;
|
||||
|
||||
if (fOp) output << " " << *fOp << endl;
|
||||
|
||||
if (!fFunctionName.empty()) output << " Func: " << fFunctionName << endl;
|
||||
|
||||
if (fCol) output << " " << *fCol << endl;
|
||||
|
||||
for (unsigned int i = 0; i < fFilterList.size(); i++)
|
||||
output << " " << *fFilterList[i] << endl;
|
||||
|
||||
@@ -133,10 +143,12 @@ bool ConstantFilter::hasAggregate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!fAggColumnList.empty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -145,17 +157,22 @@ void ConstantFilter::serialize(messageqcpp::ByteStream& b) const
|
||||
FilterList::const_iterator it;
|
||||
b << static_cast<ObjectReader::id_t>(ObjectReader::CONSTANTFILTER);
|
||||
Filter::serialize(b);
|
||||
|
||||
if (fOp != NULL)
|
||||
fOp->serialize(b);
|
||||
else
|
||||
b << static_cast<ObjectReader::id_t>(ObjectReader::NULL_CLASS);
|
||||
|
||||
if (fCol != NULL)
|
||||
fCol->serialize(b);
|
||||
else
|
||||
b << static_cast<ObjectReader::id_t>(ObjectReader::NULL_CLASS);
|
||||
|
||||
b << static_cast<uint32_t>(fFilterList.size());
|
||||
|
||||
for (it = fFilterList.begin(); it != fFilterList.end(); it++)
|
||||
(*it)->serialize(b);
|
||||
|
||||
b << fFunctionName;
|
||||
}
|
||||
|
||||
@@ -173,7 +190,9 @@ void ConstantFilter::unserialize(messageqcpp::ByteStream& b)
|
||||
fSimpleColumnList.clear();
|
||||
fAggColumnList.clear();
|
||||
fWindowFunctionColumnList.clear();
|
||||
for (i = 0; i < size; i++) {
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
sf = dynamic_cast<SimpleFilter*>(ObjectReader::createTreeNode(b));
|
||||
SSFP ssfp(sf);
|
||||
fFilterList.push_back(ssfp);
|
||||
@@ -187,6 +206,7 @@ void ConstantFilter::unserialize(messageqcpp::ByteStream& b)
|
||||
ssfp->windowfunctionColumnList().begin(),
|
||||
ssfp->windowfunctionColumnList().end());
|
||||
}
|
||||
|
||||
b >> fFunctionName;
|
||||
}
|
||||
|
||||
@@ -197,10 +217,12 @@ bool ConstantFilter::operator==(const ConstantFilter& t) const
|
||||
|
||||
f1 = static_cast<const Filter*>(this);
|
||||
f2 = static_cast<const Filter*>(&t);
|
||||
|
||||
if (*f1 != *f2)
|
||||
return false;
|
||||
|
||||
if (fOp != NULL) {
|
||||
if (fOp != NULL)
|
||||
{
|
||||
if (*fOp != *t.fOp)
|
||||
return false;
|
||||
}
|
||||
@@ -210,6 +232,7 @@ bool ConstantFilter::operator==(const ConstantFilter& t) const
|
||||
//fFilterList
|
||||
if (fFilterList.size() != t.fFilterList.size())
|
||||
return false;
|
||||
|
||||
for (it = fFilterList.begin(), it2 = t.fFilterList.begin();
|
||||
it != fFilterList.end(); ++it, ++it2)
|
||||
{
|
||||
@@ -225,8 +248,10 @@ bool ConstantFilter::operator==(const TreeNode* t) const
|
||||
const ConstantFilter* o;
|
||||
|
||||
o = dynamic_cast<const ConstantFilter*>(t);
|
||||
|
||||
if (o == NULL)
|
||||
return false;
|
||||
|
||||
return *this == *o;
|
||||
}
|
||||
|
||||
@@ -247,6 +272,7 @@ void ConstantFilter::setDerivedTable()
|
||||
fDerivedTable = "";
|
||||
return;
|
||||
}
|
||||
|
||||
fDerivedTable = fCol->derivedTable();
|
||||
}
|
||||
|
||||
@@ -254,6 +280,7 @@ void ConstantFilter::replaceRealCol(std::vector<SRCP>& derivedColList)
|
||||
{
|
||||
ReturnedColumn* tmp = derivedColList[fCol->colPosition()]->clone();
|
||||
fCol.reset(tmp);
|
||||
|
||||
for (unsigned i = 0; i < fFilterList.size(); i++)
|
||||
fFilterList[i]->replaceRealCol(derivedColList);
|
||||
}
|
||||
@@ -266,6 +293,7 @@ const std::vector<SimpleColumn*>& ConstantFilter::simpleColumnList()
|
||||
void ConstantFilter::setSimpleColumnList()
|
||||
{
|
||||
fSimpleColumnList.clear();
|
||||
|
||||
for (uint32_t i = 0; i < fFilterList.size(); i++)
|
||||
{
|
||||
fFilterList[i]->setSimpleColumnList();
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
/**
|
||||
* Namespace
|
||||
*/
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
|
||||
class ReturnedColumn;
|
||||
class AggregateColumn;
|
||||
@@ -52,7 +53,8 @@ class WindowFunctionColumn;
|
||||
* operator (either "and" or "or"). This class is introduced for
|
||||
* easy operation combine for primitive processor.
|
||||
*/
|
||||
class ConstantFilter : public Filter {
|
||||
class ConstantFilter : public Filter
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -78,17 +80,39 @@ public:
|
||||
/**
|
||||
* Accessor Methods
|
||||
*/
|
||||
const FilterList& filterList() const {return fFilterList;}
|
||||
void filterList( const FilterList& filterList) {fFilterList = filterList; }
|
||||
const SOP& op() const {return fOp;}
|
||||
void op(const SOP& op){fOp = op;}
|
||||
const SRCP& col() const {return fCol;}
|
||||
void col(const SRCP& col) {fCol = col;}
|
||||
const FilterList& filterList() const
|
||||
{
|
||||
return fFilterList;
|
||||
}
|
||||
void filterList( const FilterList& filterList)
|
||||
{
|
||||
fFilterList = filterList;
|
||||
}
|
||||
const SOP& op() const
|
||||
{
|
||||
return fOp;
|
||||
}
|
||||
void op(const SOP& op)
|
||||
{
|
||||
fOp = op;
|
||||
}
|
||||
const SRCP& col() const
|
||||
{
|
||||
return fCol;
|
||||
}
|
||||
void col(const SRCP& col)
|
||||
{
|
||||
fCol = col;
|
||||
}
|
||||
|
||||
/**
|
||||
* Operations
|
||||
*/
|
||||
void pushFilter (SimpleFilter* sf) {SSFP ssfp(sf); fFilterList.push_back(ssfp);}
|
||||
void pushFilter (SimpleFilter* sf)
|
||||
{
|
||||
SSFP ssfp(sf);
|
||||
fFilterList.push_back(ssfp);
|
||||
}
|
||||
|
||||
//virtual const std::string data() const;
|
||||
virtual const std::string toString() const;
|
||||
@@ -142,13 +166,19 @@ public:
|
||||
*
|
||||
* get the function name for this function column
|
||||
*/
|
||||
std::string functionName() const { return fFunctionName; }
|
||||
std::string functionName() const
|
||||
{
|
||||
return fFunctionName;
|
||||
}
|
||||
|
||||
/** set function name
|
||||
*
|
||||
* set the function name for this function column
|
||||
*/
|
||||
void functionName(const std::string& functionName) { fFunctionName = functionName; }
|
||||
void functionName(const std::string& functionName)
|
||||
{
|
||||
fFunctionName = functionName;
|
||||
}
|
||||
|
||||
void setDerivedTable();
|
||||
virtual void replaceRealCol(std::vector<SRCP>&);
|
||||
@@ -178,7 +208,10 @@ public:
|
||||
void setSimpleColumnList();
|
||||
|
||||
// get all aggregate columns involved in this column
|
||||
const std::vector<AggregateColumn*>& aggColumnList() const { return fAggColumnList; }
|
||||
const std::vector<AggregateColumn*>& aggColumnList() const
|
||||
{
|
||||
return fAggColumnList;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<SimpleColumn*> fSimpleColumnList;
|
||||
@@ -194,12 +227,16 @@ inline bool ConstantFilter::getBoolVal(rowgroup::Row& row, bool& isNull)
|
||||
for (uint32_t i = 0; i < fFilterList.size(); i++)
|
||||
if (!fFilterList[i]->getBoolVal(row, isNull))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
case OP_OR:
|
||||
for (uint32_t i = 0; i < fFilterList.size(); i++)
|
||||
if (fFilterList[i]->getBoolVal(row, isNull))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
default:
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
@@ -29,7 +29,8 @@ using namespace std;
|
||||
using namespace messageqcpp;
|
||||
#include "objectreader.h"
|
||||
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
/**
|
||||
* Constructors/Destructors
|
||||
*/
|
||||
@@ -76,10 +77,12 @@ void ExistsFilter::serialize(messageqcpp::ByteStream& b) const
|
||||
{
|
||||
b << static_cast<ObjectReader::id_t>(ObjectReader::EXISTSFILTER);
|
||||
Filter::serialize(b);
|
||||
|
||||
if (fSub.get() != NULL)
|
||||
fSub->serialize(b);
|
||||
else
|
||||
b << static_cast<ObjectReader::id_t>(ObjectReader::NULL_CLASS);
|
||||
|
||||
b << static_cast<const ByteStream::doublebyte>(fNotExists);
|
||||
b << static_cast<const ByteStream::doublebyte>(fCorrelated);
|
||||
}
|
||||
@@ -99,12 +102,16 @@ bool ExistsFilter::operator==(const ExistsFilter& t) const
|
||||
|
||||
f1 = static_cast<const Filter*>(this);
|
||||
f2 = static_cast<const Filter*>(&t);
|
||||
|
||||
if (*f1 != *f2)
|
||||
return false;
|
||||
|
||||
if (*(fSub.get()) != t.fSub.get())
|
||||
return false;
|
||||
|
||||
if (fNotExists != t.fNotExists)
|
||||
return false;
|
||||
|
||||
if (fCorrelated != t.fCorrelated)
|
||||
return false;
|
||||
|
||||
@@ -116,8 +123,10 @@ bool ExistsFilter::operator==(const TreeNode* t) const
|
||||
const ExistsFilter* o;
|
||||
|
||||
o = dynamic_cast<const ExistsFilter*>(t);
|
||||
|
||||
if (o == NULL)
|
||||
return false;
|
||||
|
||||
return *this == *o;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,14 +32,16 @@
|
||||
/**
|
||||
* Namespace
|
||||
*/
|
||||
namespace execplan {
|
||||
namespace execplan
|
||||
{
|
||||
/**
|
||||
* @brief A class to represent a exists predicate
|
||||
*
|
||||
* This class is a specialization of class Filter that handles a
|
||||
* exists predicate like "exists (select col2 from table2)"
|
||||
*/
|
||||
class ExistsFilter : public Filter {
|
||||
class ExistsFilter : public Filter
|
||||
{
|
||||
/**
|
||||
* Public stuff
|
||||
*/
|
||||
@@ -55,14 +57,32 @@ public:
|
||||
/**
|
||||
* Accessor Methods
|
||||
*/
|
||||
const SCSEP& sub() const { return fSub; }
|
||||
void sub (SCSEP& sub) { fSub = sub; }
|
||||
const SCSEP& sub() const
|
||||
{
|
||||
return fSub;
|
||||
}
|
||||
void sub (SCSEP& sub)
|
||||
{
|
||||
fSub = sub;
|
||||
}
|
||||
|
||||
const bool notExists() const { return fNotExists; }
|
||||
void notExists (const bool notExists) { fNotExists = notExists; }
|
||||
const bool notExists() const
|
||||
{
|
||||
return fNotExists;
|
||||
}
|
||||
void notExists (const bool notExists)
|
||||
{
|
||||
fNotExists = notExists;
|
||||
}
|
||||
|
||||
const bool correlated() const { return fCorrelated; }
|
||||
void correlated(const bool correlated) { fCorrelated = correlated; }
|
||||
const bool correlated() const
|
||||
{
|
||||
return fCorrelated;
|
||||
}
|
||||
void correlated(const bool correlated)
|
||||
{
|
||||
fCorrelated = correlated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded stream operator
|
||||
|
||||
@@ -34,7 +34,8 @@
|
||||
#include <iterator>
|
||||
//#include <parsetree.h>
|
||||
|
||||
namespace expression {
|
||||
namespace expression
|
||||
{
|
||||
enum precedence { none, lower, equal, higher };
|
||||
|
||||
struct not_an_acceptor_tag {};
|
||||
@@ -42,7 +43,8 @@ namespace expression {
|
||||
struct accumulating_acceptor_tag {};
|
||||
|
||||
template<typename Acceptor>
|
||||
struct acceptor_traits {
|
||||
struct acceptor_traits
|
||||
{
|
||||
typedef typename Acceptor::acceptor_category acceptor_category;
|
||||
typedef typename Acceptor::input_symbol_type input_symbol_type;
|
||||
typedef typename Acceptor::result_type result_type;
|
||||
@@ -61,7 +63,8 @@ namespace expression {
|
||||
|
||||
enum associativity { non_associative, left_associative, right_associative };
|
||||
|
||||
struct default_expression_parser_error_policy {
|
||||
struct default_expression_parser_error_policy
|
||||
{
|
||||
template<typename Operand>
|
||||
void invalid_operand_position(Operand)
|
||||
{
|
||||
@@ -113,7 +116,8 @@ namespace expression {
|
||||
expression_acceptor<Token, Operand, Operator, Policy, OperandStack, \
|
||||
OperatorStack>
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
enum action {shift, reduce, prec, prec_assoc, invalid};
|
||||
|
||||
// Current larser state
|
||||
@@ -123,7 +127,8 @@ namespace expression {
|
||||
const int pre_positions = prefix | open;
|
||||
const int post_positions = postfix | close | infix | function_open;
|
||||
|
||||
const action parse_action[6][6] = {
|
||||
const action parse_action[6][6] =
|
||||
{
|
||||
/* prefix postfix infix open close func open */
|
||||
/* prefix */ { shift, prec, prec, shift, reduce, prec },
|
||||
/* postfix */ { invalid, reduce, reduce, reduce, reduce, reduce },
|
||||
@@ -141,9 +146,11 @@ namespace expression {
|
||||
typename OperandStack = std::stack<Operand>,
|
||||
typename OperatorStack = std::stack<Operator>
|
||||
>
|
||||
class expression_acceptor {
|
||||
class expression_acceptor
|
||||
{
|
||||
private:
|
||||
class assignment_proxy {
|
||||
class assignment_proxy
|
||||
{
|
||||
public:
|
||||
explicit assignment_proxy(expression_acceptor* acceptor) :
|
||||
m_expression_acceptor(acceptor) {}
|
||||
@@ -180,12 +187,24 @@ namespace expression {
|
||||
{
|
||||
}
|
||||
|
||||
assignment_proxy operator*() { return assignment_proxy(this); }
|
||||
expression_acceptor& operator++() { return *this; }
|
||||
expression_acceptor& operator++(int) { return *this; }
|
||||
assignment_proxy operator*()
|
||||
{
|
||||
return assignment_proxy(this);
|
||||
}
|
||||
expression_acceptor& operator++()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
expression_acceptor& operator++(int)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool accepted();
|
||||
bool trapped() { return m_state == rejected; }
|
||||
bool trapped()
|
||||
{
|
||||
return m_state == rejected;
|
||||
}
|
||||
|
||||
operator Operand()
|
||||
{
|
||||
@@ -209,31 +228,38 @@ namespace expression {
|
||||
EXP_TEMPLATE
|
||||
bool EXP_ACCEPTOR::accepted()
|
||||
{
|
||||
if (m_state == accepting) {
|
||||
if (m_state == accepting)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (m_state == rejected) {
|
||||
else if (m_state == rejected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (m_state == lookahead) {
|
||||
else if (m_state == lookahead)
|
||||
{
|
||||
m_state = post_operand;
|
||||
int position = m_policy.positions(m_ambiguous_operator);
|
||||
parse_operator(m_policy.as_operator(m_ambiguous_operator,
|
||||
position & (postfix | close)));
|
||||
}
|
||||
|
||||
while (!m_operator_stack.empty() && m_state != rejected) {
|
||||
while (!m_operator_stack.empty() && m_state != rejected)
|
||||
{
|
||||
do_reduce();
|
||||
}
|
||||
|
||||
if (m_state == rejected) {
|
||||
if (m_state == rejected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (m_operand_stack.size() > 1 || !m_operator_stack.empty()) {
|
||||
else if (m_operand_stack.size() > 1 || !m_operator_stack.empty())
|
||||
{
|
||||
m_state = rejected;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
m_state = accepting;
|
||||
return true;
|
||||
}
|
||||
@@ -247,28 +273,33 @@ namespace expression {
|
||||
if (m_state == rejected)
|
||||
return;
|
||||
|
||||
if (m_policy.is_operator(t)) {
|
||||
if (m_policy.is_operator(t))
|
||||
{
|
||||
int operator_positions = m_policy.positions(t);
|
||||
|
||||
if (m_state == lookahead) {
|
||||
if (m_state == lookahead)
|
||||
{
|
||||
bool could_be_pre = ((operator_positions & pre_positions) != 0);
|
||||
bool could_be_post = ((operator_positions & post_positions) != 0);
|
||||
|
||||
int ambiguous_position = m_policy.positions(m_ambiguous_operator);
|
||||
|
||||
if ( (could_be_pre && could_be_post) ||
|
||||
(!could_be_pre && !could_be_post) ) {
|
||||
(!could_be_pre && !could_be_post) )
|
||||
{
|
||||
m_policy.ambiguity(m_ambiguous_operator, t);
|
||||
m_state = rejected;
|
||||
return;
|
||||
}
|
||||
else if (could_be_pre) {
|
||||
else if (could_be_pre)
|
||||
{
|
||||
ambiguous_position &= (infix | function_open);
|
||||
parse_operator(m_policy.as_operator(m_ambiguous_operator,
|
||||
ambiguous_position));
|
||||
m_state = pre_operand;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
ambiguous_position &= (postfix | close);
|
||||
parse_operator(m_policy.as_operator(m_ambiguous_operator,
|
||||
ambiguous_position));
|
||||
@@ -280,7 +311,9 @@ namespace expression {
|
||||
(m_state == pre_operand) ? pre_positions : post_positions;
|
||||
|
||||
int positions = operator_positions & valid_positions;
|
||||
switch (positions) {
|
||||
|
||||
switch (positions)
|
||||
{
|
||||
case infix:
|
||||
case function_open:
|
||||
m_state = pre_operand;
|
||||
@@ -307,20 +340,24 @@ namespace expression {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (m_state == lookahead) {
|
||||
else
|
||||
{
|
||||
if (m_state == lookahead)
|
||||
{
|
||||
int positions = m_policy.positions(m_ambiguous_operator);
|
||||
positions &= (infix | function_open);
|
||||
parse_operator(m_policy.as_operator(m_ambiguous_operator,
|
||||
positions));
|
||||
m_state = post_operand;
|
||||
}
|
||||
else if (m_state == post_operand) {
|
||||
else if (m_state == post_operand)
|
||||
{
|
||||
m_policy.invalid_operand_position(m_policy.as_operand(t));
|
||||
m_state = rejected;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
m_state = post_operand;
|
||||
}
|
||||
|
||||
@@ -331,7 +368,8 @@ namespace expression {
|
||||
EXP_TEMPLATE
|
||||
inline int EXP_ACCEPTOR::operator_type_index(int position)
|
||||
{
|
||||
switch (position) {
|
||||
switch (position)
|
||||
{
|
||||
case prefix:
|
||||
return 0;
|
||||
|
||||
@@ -358,16 +396,19 @@ namespace expression {
|
||||
EXP_TEMPLATE
|
||||
void EXP_ACCEPTOR::parse_operator(const Operator& cur_operator)
|
||||
{
|
||||
if (m_operator_stack.empty()) {
|
||||
if (m_operator_stack.empty())
|
||||
{
|
||||
m_operator_stack.push(cur_operator);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
int cur_index = operator_type_index(m_policy.position(cur_operator));
|
||||
|
||||
Operator& prev_operator = m_operator_stack.top();
|
||||
int prev_index = operator_type_index(m_policy.position(prev_operator));
|
||||
|
||||
switch (parse_action[prev_index][cur_index]) {
|
||||
switch (parse_action[prev_index][cur_index])
|
||||
{
|
||||
case shift:
|
||||
m_operator_stack.push(cur_operator);
|
||||
break;
|
||||
@@ -378,7 +419,8 @@ namespace expression {
|
||||
break;
|
||||
|
||||
case prec:
|
||||
switch (m_policy.precedence(prev_operator, cur_operator)) {
|
||||
switch (m_policy.precedence(prev_operator, cur_operator))
|
||||
{
|
||||
case lower:
|
||||
m_operator_stack.push(cur_operator);
|
||||
break;
|
||||
@@ -393,10 +435,12 @@ namespace expression {
|
||||
m_state = rejected;
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case prec_assoc:
|
||||
switch (m_policy.precedence(prev_operator, cur_operator)) {
|
||||
switch (m_policy.precedence(prev_operator, cur_operator))
|
||||
{
|
||||
case lower:
|
||||
m_operator_stack.push(cur_operator);
|
||||
break;
|
||||
@@ -407,7 +451,8 @@ namespace expression {
|
||||
break;
|
||||
|
||||
case equal:
|
||||
switch(m_policy.associativity(prev_operator, cur_operator)) {
|
||||
switch (m_policy.associativity(prev_operator, cur_operator))
|
||||
{
|
||||
case left_associative:
|
||||
do_reduce();
|
||||
parse_operator(cur_operator);
|
||||
@@ -423,6 +468,7 @@ namespace expression {
|
||||
m_state = rejected;
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -430,6 +476,7 @@ namespace expression {
|
||||
m_state = rejected;
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case invalid:
|
||||
@@ -446,11 +493,13 @@ namespace expression {
|
||||
Operator op = m_operator_stack.top();
|
||||
m_operator_stack.pop();
|
||||
|
||||
switch (m_policy.position(op)) {
|
||||
switch (m_policy.position(op))
|
||||
{
|
||||
case prefix:
|
||||
case postfix:
|
||||
{
|
||||
if (m_operand_stack.empty()) {
|
||||
if (m_operand_stack.empty())
|
||||
{
|
||||
m_policy.missing_operand(op);
|
||||
m_state = rejected;
|
||||
return;
|
||||
@@ -465,7 +514,8 @@ namespace expression {
|
||||
|
||||
case infix:
|
||||
{
|
||||
if (m_operand_stack.size() < 2) {
|
||||
if (m_operand_stack.size() < 2)
|
||||
{
|
||||
m_policy.missing_operand(op);
|
||||
m_state = rejected;
|
||||
return;
|
||||
@@ -487,13 +537,15 @@ namespace expression {
|
||||
return;
|
||||
|
||||
case close:
|
||||
if (m_operator_stack.empty()) {
|
||||
if (m_operator_stack.empty())
|
||||
{
|
||||
m_policy.unbalanced_confix(op);
|
||||
m_state = rejected;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_operand_stack.empty()) {
|
||||
if (m_operand_stack.empty())
|
||||
{
|
||||
m_policy.missing_operand(op);
|
||||
m_state = rejected;
|
||||
return;
|
||||
@@ -506,8 +558,10 @@ namespace expression {
|
||||
Operand operand = m_operand_stack.top();
|
||||
m_operand_stack.pop();
|
||||
|
||||
if (m_policy.position(open) == function_open) {
|
||||
if (m_operand_stack.empty()) {
|
||||
if (m_policy.position(open) == function_open)
|
||||
{
|
||||
if (m_operand_stack.empty())
|
||||
{
|
||||
m_policy.missing_operand(open);
|
||||
m_state = rejected;
|
||||
return;
|
||||
@@ -520,10 +574,12 @@ namespace expression {
|
||||
m_policy.reduce(function, open, operand, op)
|
||||
);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
m_operand_stack.push(m_policy.reduce(open, op, operand));
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
default:
|
||||
@@ -552,7 +608,8 @@ namespace expression {
|
||||
typename OperandStack = std::stack<Operand>,
|
||||
typename OperatorStack = std::stack<Operator>
|
||||
>
|
||||
class expression_parser {
|
||||
class expression_parser
|
||||
{
|
||||
public:
|
||||
typedef detail::EXP_ACCEPTOR acceptor;
|
||||
typedef Token token_type;
|
||||
@@ -568,13 +625,18 @@ namespace expression {
|
||||
template<typename InputIterator>
|
||||
Operand parse(InputIterator first, InputIterator last)
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
#if _MSC_VER > 1600
|
||||
return std::_Copy_impl(first, last, start());}
|
||||
return std::_Copy_impl(first, last, start());
|
||||
}
|
||||
|
||||
#else
|
||||
return std::copy(first, last, start());}
|
||||
return std::copy(first, last, start());
|
||||
}
|
||||
#endif
|
||||
catch (const std::runtime_error&) {
|
||||
catch (const std::runtime_error&)
|
||||
{
|
||||
m_policy.cleanup(operandStack, operatorStack);
|
||||
throw;
|
||||
}
|
||||
@@ -586,10 +648,12 @@ namespace expression {
|
||||
// this is to chean up the pointers in the stack when exception
|
||||
// is thrown. the exception is then passed to the upper level.
|
||||
// changed by Zhixuan Zhu 07/03/06
|
||||
try {
|
||||
try
|
||||
{
|
||||
return acceptor(m_policy, operandStack, operatorStack);
|
||||
|
||||
} catch (const std::runtime_error&)
|
||||
}
|
||||
catch (const std::runtime_error&)
|
||||
{
|
||||
m_policy.cleanup(operandStack, operatorStack);
|
||||
throw;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user