-
Notifications
You must be signed in to change notification settings - Fork 152
[TRAFODION-3034] Support Oracle Hierarchy Query (Connect By) #1688
base: master
Are you sure you want to change the base?
Changes from all commits
5fb8f21
b29f4dd
88e8b20
9fb3a59
b875ec3
1b853c5
f20b63c
5757f25
73a175a
1b32b6b
81ef30d
d781d88
cc9057d
8ae2ed9
26d9b06
6dd9c8e
d6fb419
e1a5911
caed495
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3028,3 +3028,59 @@ Lng32 ComTdbExeUtilLobInfo::unpack(void * base, void * reallocator) | |
return -1; | ||
return ComTdbExeUtil::unpack(base, reallocator); | ||
} | ||
|
||
ComTdbExeUtilConnectby::ComTdbExeUtilConnectby(char * query, | ||
ULng32 querylen, | ||
Int16 querycharset, | ||
char * tableName, | ||
char * stmtName, | ||
ex_expr * input_expr, | ||
ULng32 input_rowlen, | ||
ex_expr * output_expr, | ||
ULng32 output_rowlen, | ||
ex_expr * scan_expr, | ||
ex_cri_desc * work_cri_desc, | ||
const unsigned short work_atp_index, | ||
Lng32 colDescSize, | ||
Lng32 outputRowSize, | ||
ex_cri_desc * given_cri_desc, | ||
ex_cri_desc * returned_cri_desc, | ||
queue_index down, | ||
queue_index up, | ||
Lng32 num_buffers, | ||
ULng32 buffer_size, | ||
ExCriDescPtr workCriDesc | ||
) | ||
: ComTdbExeUtil(ComTdbExeUtil::CONNECT_BY_, | ||
query, querylen, querycharset, | ||
tableName, strlen(tableName), | ||
input_expr, input_rowlen, | ||
output_expr, output_rowlen, | ||
scan_expr, | ||
work_cri_desc, work_atp_index, | ||
given_cri_desc, returned_cri_desc, | ||
down, up, | ||
num_buffers, buffer_size), | ||
flags_(0), | ||
myWorkCriDesc_(workCriDesc), | ||
tupleLen_(outputRowSize) | ||
{ | ||
setNodeType(ComTdb::ex_CONNECT_BY); | ||
connTableName_ = tableName; | ||
maxDeep_ = 200; //by default, max deep of a tree | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two literals could be consts to improve readability. It looks like there are cqds defined to make these configurable, which is excellent. |
||
maxSize_ = 100000; //by default, the max number of rows to return for hierachy query | ||
hasPath_ = FALSE; | ||
hasIsLeaf_ = FALSE; | ||
} | ||
|
||
Long ComTdbExeUtilConnectby::pack(void * space) | ||
{ | ||
myWorkCriDesc_.pack(space); | ||
return ComTdbExeUtil::pack(space); | ||
} | ||
|
||
Lng32 ComTdbExeUtilConnectby::unpack(void * base, void * reallocator) | ||
{ | ||
if(myWorkCriDesc_.unpack(base, reallocator)) return -1; | ||
return ComTdbExeUtil::unpack(base, reallocator); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4138,6 +4138,7 @@ class ExExeUtilLobInfoTableTcb : public ExExeUtilTcb | |
DONE_ | ||
}; | ||
Step step_; | ||
char * data_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need a change in a Lob class? |
||
|
||
protected: | ||
Int64 getEmbeddedNumValue(char* &sep, char endChar, | ||
|
@@ -4172,6 +4173,48 @@ class ExExeUtilLobInfoPrivateState : public ex_tcb_private_state | |
protected: | ||
}; | ||
|
||
class connectByStackItem | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is unusual in the executor to have classes that do not have a base class. How about memory management for this class. I might understand more as I see how these classes are used. |
||
{ | ||
public: | ||
connectByStackItem() | ||
{ | ||
seedValue = NULL; | ||
pathItem = NULL; | ||
pathLen = 0; | ||
len = 0; | ||
level = 0; | ||
type = 0; | ||
parentId = 0; | ||
} | ||
~connectByStackItem() {} | ||
char * seedValue; | ||
char * pathItem; | ||
int len; | ||
int level; | ||
int type; | ||
int pathLen; | ||
int parentId; | ||
}; | ||
class connectByOneRow { | ||
|
||
public: | ||
connectByOneRow() | ||
{ | ||
data_ = NULL; | ||
len = 0; | ||
type = 0; | ||
} | ||
~connectByOneRow() {} | ||
char * data_; | ||
int len; | ||
int type; | ||
}; | ||
|
||
#define CONNECT_BY_DEFAULT_BATCH_SIZE 100 | ||
#define CONNECT_BY_MAX_LEVEL_SIZE 200 | ||
#define CONNECT_BY_MAX_SQL_TEXT_SIZE 2048 | ||
#define CONNECT_BY_MAX_PATH_SIZE 3000 | ||
|
||
//////////////////////////////////////////////////////////////////////////// | ||
class ExExeUtilLobInfoTablePrivateState : public ex_tcb_private_state | ||
{ | ||
|
@@ -4183,6 +4226,72 @@ class ExExeUtilLobInfoTablePrivateState : public ex_tcb_private_state | |
protected: | ||
}; | ||
|
||
class ExExeUtilConnectbyTcb : public ExExeUtilTcb | ||
{ | ||
friend class ExExeUtilConnectbyTdb; | ||
|
||
public: | ||
ExExeUtilConnectbyTcb(const ComTdbExeUtilConnectby &exe_util_tdb, | ||
ex_globals * glob = 0); | ||
|
||
virtual ~ExExeUtilConnectbyTcb() | ||
{} | ||
|
||
virtual short work(); | ||
virtual ex_tcb_private_state * allocatePstates( | ||
Lng32 &numElems, // inout, desired/actual elements | ||
Lng32 &pstateLength); // out, length of one element | ||
enum Step | ||
{ | ||
INITIAL_, | ||
EVAL_INPUT_, | ||
EVAL_START_WITH_, | ||
DO_CONNECT_BY_, | ||
EVAL_OUTPUT_EXPR_, | ||
NEXT_LEVEL_, | ||
NEXT_ROOT_, | ||
ERROR_, | ||
DONE_ | ||
}; | ||
Step step_; | ||
ExExeUtilConnectbyTdb& exeUtilTdb() const | ||
{return (ExExeUtilConnectbyTdb&) tdb;}; | ||
|
||
short emitRow(ExpTupleDesc * tDesc, int level, int isleaf, int iscycle, connectByStackItem *it) ; | ||
short emitPrevRow(ExpTupleDesc * tDesc, int level, int isleaf, int iscycle, Queue* q, int index) ; | ||
|
||
Queue *currArray[200]; | ||
Queue * getCurrentQueue(int level) { if(level <0 || level >200) abort(); return currArray[level];} | ||
short checkDuplicate(connectByStackItem *it,int len, int level); | ||
int currLevel_; | ||
Int64 resultSize_; | ||
Queue *currQueue_; | ||
Queue *seedQueue_; | ||
Queue *thisQueue_; | ||
Queue *prevQueue_; | ||
Queue *tmpPrevQueue_; | ||
Int32 currRootId_; | ||
Int32 connBatchSize_ ; | ||
|
||
protected: | ||
ExExeUtilConnectbyTcb *tcb_; | ||
|
||
private: | ||
tupp tuppData_; | ||
char * data_; | ||
}; | ||
|
||
class ExExeUtilConnectbyTdbState : public ex_tcb_private_state | ||
{ | ||
friend class ExExeUtilConnectbyTcb; | ||
|
||
public: | ||
ExExeUtilConnectbyTdbState(); | ||
~ExExeUtilConnectbyTdbState(); | ||
protected: | ||
ExExeUtilConnectbyTcb::Step step_; | ||
}; | ||
|
||
#endif | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In these three messages, it would help if we could give information specific to the instance when the error occurred. Maybe value of the prior column(s) as the error occurred. For the case of recursion exceeding a certain length or memory being exhausted, more details what level of recursion has been reached or how much memory has been consumed (if that information is readily available) would be helpful. This is an advisory suggestion, and by no means something to be addressed soon.
I would have expected some binder errors for statements where hierarchical constructs are not supported. It is possible though unlikely that all are caught in the parser. For example what happens if a hierarchical function or pseudocolumn is used a regular (non-hierarchical query)