This repository was archived by the owner on Jun 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathExExeUtil.h
More file actions
4189 lines (3521 loc) · 136 KB
/
ExExeUtil.h
File metadata and controls
4189 lines (3521 loc) · 136 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**********************************************************************
// @@@ START COPYRIGHT @@@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
// @@@ END COPYRIGHT @@@
**********************************************************************/
#ifndef EX_EXE_UTIL_H
#define EX_EXE_UTIL_H
/* -*-C++-*-
*****************************************************************************
*
* File: ExExeUtil.h
* Description:
*
*
* Created: 9/12/2005
* Language: C++
*
*
*
*
*****************************************************************************
*/
// forward
class ex_expr;
class Queue;
class ExTransaction;
class ContextCli;
class IpcServer;
class IpcServerClass;
class ExStatisticsArea;
class CmpDDLwithStatusInfo;
class ExSqlComp;
class ExProcessStats;
class ExpHbaseInterface;
class HdfsClient;
//class FILE_STREAM;
#include "ComAnsiNamePart.h"
#include "ComTdbExeUtil.h"
#include "ComTdbRoot.h"
#include "ComRtUtils.h"
#include "ExExeUtilCli.h"
#include "ExpLOBstats.h"
#include "hiveHook.h"
#include "ExpHbaseDefs.h"
#include "SequenceFileReader.h"
#define TO_FMT3u(u) MINOF(((u)+500)/1000, 999)
#define MAX_ACCUMULATED_STATS_DESC 2
#define MAX_PERTABLE_STATS_DESC 256
#define MAX_PROGRESS_STATS_DESC 256
#define MAX_OPERATOR_STATS_DESC 512
#define MAX_RMS_STATS_DESC 512
#define BUFFER_SIZE 4000
#define MAX_AUTHIDTYPE_CHAR 11
#define MAX_USERINFO_CHAR 257
// max number of attempts to create ORSERV upon failure
#define MAX_CREATE_ORSERV_COUNT 5
// -----------------------------------------------------------------------
// Classes defined in this file
// -----------------------------------------------------------------------
class ExExeUtilTdb;
class ExExeUtilDisplayExplainTdb;
class ExExeUtilDisplayExplainComplexTdb;
class ExExeUtilHiveTruncateTdb;
class ExExeUtilHiveQueryTdb;
class ExExeUtilSuspendTdb;
class ExExeUtilSuspendTcb;
class ExpHbaseInterface;
// -----------------------------------------------------------------------
// Classes referenced in this file
// -----------------------------------------------------------------------
class ex_tcb;
// -----------------------------------------------------------------------
// ExExeUtilTdb
// -----------------------------------------------------------------------
class ExExeUtilTdb : public ComTdbExeUtil
{
public:
// ---------------------------------------------------------------------
// Constructor is only called to instantiate an object used for
// retrieval of the virtual table function pointer of the class while
// unpacking. An empty constructor is enough.
// ---------------------------------------------------------------------
ExExeUtilTdb()
{}
virtual ~ExExeUtilTdb()
{}
// ---------------------------------------------------------------------
// Build a TCB for this TDB. Redefined in the Executor project.
// ---------------------------------------------------------------------
virtual ex_tcb *build(ex_globals *globals);
private:
// ---------------------------------------------------------------------
// !!!!!!! IMPORTANT -- NO DATA MEMBERS ALLOWED IN EXECUTOR TDB !!!!!!!!
// *********************************************************************
// The Executor TDB's are only used for the sole purpose of providing a
// way to supplement the Compiler TDB's (in comexe) with methods whose
// implementation depends on Executor objects. This is done so as to
// decouple the Compiler from linking in Executor objects unnecessarily.
//
// When a Compiler generated TDB arrives at the Executor, the same data
// image is "cast" as an Executor TDB after unpacking. Therefore, it is
// a requirement that a Compiler TDB has the same object layout as its
// corresponding Executor TDB. As a result of this, all Executor TDB's
// must have absolutely NO data members, but only member functions. So,
// if you reach here with an intention to add data members to a TDB, ask
// yourself two questions:
//
// 1. Are those data members Compiler-generated?
// If yes, put them in the ComTdbDLL instead.
// If no, they should probably belong to someplace else (like TCB).
//
// 2. Are the classes those data members belong defined in the executor
// project?
// If your answer to both questions is yes, you might need to move
// the classes to the comexe project.
// ---------------------------------------------------------------------
};
struct QueryString {
public:
const char * str;
};
//
// Task control block
//
class ExExeUtilTcb : public ex_tcb
{
friend class ExExeUtilTdb;
friend class ExExeUtilPrivateState;
public:
enum Step
{
EMPTY_,
PROCESSING_,
DONE_,
HANDLE_ERROR_,
CANCELLED_
};
enum ProcessQueryStep
{
PROLOGUE_,
EXECUTE_,
FETCH_ROW_,
RETURN_ROW_,
ERROR_RETURN_,
CLOSE_,
EPILOGUE_,
ALL_DONE_
};
// Constructor
ExExeUtilTcb(const ComTdbExeUtil & exe_util_tdb,
const ex_tcb * child_tcb, // for child queue
ex_globals * glob = 0);
~ExExeUtilTcb();
virtual short work();
ex_queue_pair getParentQueue() const;
Int32 orderedQueueProtocol() const;
virtual void freeResources();
virtual Int32 numChildren() const;
virtual const ex_tcb* getChild(Int32 pos) const;
void glueQueryFragments(Lng32 queryArraySize,
const QueryString * queryArray,
char * &gluedQuery,
Lng32 &gluedQuerySize);
short extractObjectParts(
char * objectName,
char * sys,
char * &cat,
char * &sch,
char * &tab,
char * ansiNameBuf);
// extract parts from 'objectName' and fixes up delimited names.
Lng32 extractParts
(char * objectName,
char ** parts0,
char ** parts1,
char ** parts2
);
Lng32 changeAuditAttribute(char * tableName,
NABoolean makeAudited,
NABoolean isVolatile = FALSE,
NABoolean isIndex = FALSE,
NABoolean parallelAlter = FALSE
);
virtual short moveRowToUpQueue(const char * row, Lng32 len = -1,
short * rc = NULL, NABoolean isVarchar = TRUE);
NABoolean isUpQueueFull(short size);
static char * getTimeAsString(Int64 t, char * timeBuf,
NABoolean noUsec = FALSE);
char * getTimestampAsString(Int64 t, char * timeBuf);
short initializeInfoList(Queue* &infoList);
short fetchAllRows(Queue * &infoList,
char * query,
Lng32 numOutputEntries,
NABoolean varcharFormat,
short &rc,
NABoolean monitorThis=FALSE);
ex_expr::exp_return_type evalScanExpr(char * ptr, Lng32 len,
NABoolean copyToVCbuf);
char * getStatusString(const char * operation,
const char * status,
const char * object,
char * outBuf,
NABoolean isET = FALSE,
char * timeBuf = NULL,
char * queryBuf = NULL,
char * sqlcodeBuf = NULL);
short executeQuery(char * step, char * object,
char * query,
NABoolean displayStartTime, NABoolean displayEndTime,
short &rc, short * warning, Lng32 * errorCode = NULL,
NABoolean moveErrorRow = TRUE,
NABoolean continueOnError = FALSE,
NABoolean monitorThis=FALSE);
ExeCliInterface * cliInterface() { return cliInterface_; };
ExeCliInterface * cliInterface2() { return cliInterface2_; };
ComDiagsArea *&getDiagsArea() { return diagsArea_; }
void setDiagsAreax(ComDiagsArea * d) { diagsArea_ = d; }
short setSchemaVersion(char * param1);
short setSystemVersion();
short holdAndSetCQD(const char * defaultName, const char * defaultValue,
ComDiagsArea * globalDiags = NULL);
short restoreCQD(const char * defaultName, ComDiagsArea * globalDiags = NULL);
short setCS(const char * csName, char * csValue,
ComDiagsArea * globalDiags = NULL);
short resetCS(const char * csName, ComDiagsArea * globalDiags = NULL);
void setMaintainControlTableTimeout(char * catalog);
void restoreMaintainControlTableTimeout(char * catalog);
static Lng32 holdAndSetCQD(const char * defaultName, const char * defaultValue,
ExeCliInterface * cliInterface,
ComDiagsArea * globalDiags = NULL);
static Lng32 restoreCQD(const char * defaultName,
ExeCliInterface * cliInterface,
ComDiagsArea * globalDiags = NULL);
static Lng32 setCS(const char * csName, char * csValue,
ExeCliInterface * cliInterface,
ComDiagsArea * globalDiags = NULL);
static Lng32 resetCS(const char * csName,
ExeCliInterface * cliInterface,
ComDiagsArea * globalDiags = NULL);
short disableCQS();
short restoreCQS();
short doubleQuoteStr(char * str, char * newStr,
NABoolean singleQuote);
char * getSchemaVersion()
{ return (strlen(versionStr_) == 0 ? (char *)"" : versionStr_); }
char * getSystemVersion()
{ return (strlen(sysVersionStr_) == 0 ? NULL : sysVersionStr_); }
Lng32 getSchemaVersionLen() { return versionStrLen_; }
short getObjectUid(char * catName, char * schName,
char * objName,
NABoolean isIndex, NABoolean isMv,
char * uid);
short lockUnlockObject(char * tableName,
NABoolean lock,
NABoolean parallel,
char * failReason);
short alterObjectState(NABoolean online, char * tableName,
char * failReason, NABoolean forPurgedata);
short alterDDLLock(NABoolean add, char * tableName,
char * failReason, NABoolean isMV,
Int32 lockType,
const char * lockPrefix = NULL,
NABoolean skipDDLLockCheck = FALSE);
short alterCorruptBit(short val, char * tableName,
char * failReason, Queue* indexList);
short alterAuditFlag(NABoolean audited, char * tableName,
NABoolean isIndex);
short handleError();
short handleDone();
NABoolean &infoListIsOutputInfo() { return infoListIsOutputInfo_; }
// Error: -1, creation of IpcServerClass failed.
// -2, PROCESSNAME_CREATE_ failed.
// -3, allocateServerProcess failed.
short createServer(char *serverName,
const char *inPName,
IpcServerTypeEnum serverType,
IpcServerAllocationMethod servAllocMethod,
char *nodeName,
short cpu,
const char *partnName,
Lng32 priority,
IpcServer* &ipcServer,
NABoolean logError,
const char * operation);
void deleteServer(IpcServer *ipcServer);
NABoolean isProcessObsolete(short cpu, pid_t pin, short segmentNum,
Int64 procCreateTime);
protected:
const ex_tcb * childTcb_;
ex_queue_pair qparent_;
ex_queue_pair qchild_;
atp_struct * workAtp_;
ComDiagsArea * diagsArea_;
char * query_;
unsigned short tcbFlags_;
char * explQuery_;
ExExeUtilTdb & exeUtilTdb() const{return (ExExeUtilTdb &) tdb;};
void handleErrors(Lng32 error);
CollHeap * getMyHeap()
{
return (getGlobals()->getDefaultHeap());
};
void AddCommas (char *outStr, Lng32 &intSize) const;
void FormatFloat (char *outStr, Lng32 &intSize,
Lng32 &fullSize, double floatVal,
NABoolean normalMode, NABoolean expertMode)const;
Queue * infoList_;
NABoolean infoListIsOutputInfo_;
char *childQueryId_;
Lng32 childQueryIdLen_;
SQL_QUERY_COST_INFO childQueryCostInfo_;
SQL_QUERY_COMPILER_STATS_INFO childQueryCompStatsInfo_;
char *outputBuf_;
char failReason_[2000];
private:
ExeCliInterface * cliInterface_;
ExeCliInterface * cliInterface2_;
ProcessQueryStep pqStep_;
char versionStr_[10];
Lng32 versionStrLen_;
char sysVersionStr_[10];
Lng32 sysVersionStrLen_;
NABoolean restoreTimeout_;
AnsiName *extractedPartsObj_;
Int64 startTime_;
Int64 endTime_;
Int64 elapsedTime_;
short warning_;
};
class ExExeUtilPrivateState : public ex_tcb_private_state
{
friend class ExExeUtilTcb;
friend class ExExeUtilCleanupVolatileTablesTcb;
friend class ExExeUtilCreateTableAsTcb;
friend class ExExeUtilHiveTruncateTcb;
friend class ExExeUtilHiveQueryTcb;
friend class ExExeUtilAQRTcb;
friend class ExExeUtilHBaseBulkLoadTcb;
friend class ExExeUtilHBaseBulkUnLoadTcb;
public:
ExExeUtilPrivateState(const ExExeUtilTcb * tcb); //constructor
~ExExeUtilPrivateState(); // destructor
ex_tcb_private_state * allocate_new(const ex_tcb * tcb);
protected:
ExExeUtilTcb::Step step_;
Int64 matches_;
};
// -----------------------------------------------------------------------
// ExExeUtilDisplayExplainTdb
// -----------------------------------------------------------------------
class ExExeUtilDisplayExplainTdb : public ComTdbExeUtilDisplayExplain
{
public:
// ---------------------------------------------------------------------
// Constructor is only called to instantiate an object used for
// retrieval of the virtual table function pointer of the class while
// unpacking. An empty constructor is enough.
// ---------------------------------------------------------------------
ExExeUtilDisplayExplainTdb()
{}
virtual ~ExExeUtilDisplayExplainTdb()
{}
// ---------------------------------------------------------------------
// Build a TCB for this TDB. Redefined in the Executor project.
// ---------------------------------------------------------------------
virtual ex_tcb *build(ex_globals *globals);
private:
// ---------------------------------------------------------------------
// !!!!!!! IMPORTANT -- NO DATA MEMBERS ALLOWED IN EXECUTOR TDB !!!!!!!!
// *********************************************************************
// The Executor TDB's are only used for the sole purpose of providing a
// way to supplement the Compiler TDB's (in comexe) with methods whose
// implementation depends on Executor objects. This is done so as to
// decouple the Compiler from linking in Executor objects unnecessarily.
//
// When a Compiler generated TDB arrives at the Executor, the same data
// image is "cast" as an Executor TDB after unpacking. Therefore, it is
// a requirement that a Compiler TDB has the same object layout as its
// corresponding Executor TDB. As a result of this, all Executor TDB's
// must have absolutely NO data members, but only member functions. So,
// if you reach here with an intention to add data members to a TDB, ask
// yourself two questions:
//
// 1. Are those data members Compiler-generated?
// If yes, put them in the ComTdbDLL instead.
// If no, they should probably belong to someplace else (like TCB).
//
// 2. Are the classes those data members belong defined in the executor
// project?
// If your answer to both questions is yes, you might need to move
// the classes to the comexe project.
// ---------------------------------------------------------------------
};
//
// Task control block
//
class ExExeUtilDisplayExplainTcb : public ExExeUtilTcb
{
friend class ExExeUtilDisplayExplainTdb;
friend class ExExeUtilPrivateState;
public:
// Constructor
ExExeUtilDisplayExplainTcb(const ComTdbExeUtilDisplayExplain & exe_util_tdb,
ex_globals * glob = 0);
~ExExeUtilDisplayExplainTcb();
virtual short work();
virtual ex_tcb_private_state * allocatePstates(
Lng32 &numElems, // inout, desired/actual elements
Lng32 &pstateLength); // out, length of one element
short processExplainRows();
//state machine states for work() method
enum Step
{
EMPTY_,
PREPARE_,
SETUP_EXPLAIN_,
FETCH_PROLOGUE_,
FETCH_EXPLAIN_ROW_,
FETCH_FIRST_EXPLAIN_ROW_,
GET_COLUMNS_,
DO_HEADER_,
DO_OPERATOR_,
RETURN_FMT_ROWS_,
RETURN_EXPLAIN_ROW_,
FETCH_EPILOGUE_,
FETCH_EPILOGUE_AND_RETURN_ERROR_,
DONE_,
HANDLE_ERROR_,
RETURN_ERROR_,
CANCELLED_
};
protected:
private:
// Enums
// enum { MLINE = 74 }; // max number of lines in the array, 3000/50 + 14
// enum { MLEN = 80 }; // max length of each line
enum { MNAME = 60 }; // width of the returned SQL name columns
enum { MOPER = 30 }; // width of the returned SQL operator column
enum { MCOST = 200 }; // width of the returned SQL detailed_cost column
enum { MDESC = 30000 }; // width of the returned SQL description column
enum { MUSERSP = 20 }; // max output number space for user
// enum { MWIDE = MLEN-1}; // max line width in char for output
enum { COL2 = 28 }; // position of column 2 (value) on the line
enum Option //which output format we are using
{
N_,
E_,
F_,
M_
};
// Variables
SQLMODULE_ID * module_;
SQLSTMT_ID * stmt_;
SQLDESC_ID * sql_src_;
SQLDESC_ID * input_desc_;
SQLDESC_ID * output_desc_;
char * outputBuf_;
char * explainQuery_;
Option optFlag_; // option flag
char ** lines_;
// char lines_[MLINE][MLEN]; // array of MLINE lines MLEN char wide
Lng32 cntLines_; // count of lines in lines_ array
Lng32 nextLine_; // number of next line to output from array
char* parsePtr_; // location in input string being parsed
Lng32 header_; // flag saying current node is root if 1
Lng32 lastFrag_; // previous row fragment number
char lastOp_[MOPER+1]; // previous row operator name
char * optFOutput;
// char optFOutput[MLEN]; // formatted line for optionsF
// Next 13 are the local column data, storage for one node's info
char moduleName_[MNAME+1]; // module name column, sometimes null, MNAME=60
char statementName_[MNAME+1];// stmt name column, sometimes null, MNAME=60
Int64 planId_; // large number, unique per plan
Lng32 seqNum_; // number of this node
char operName_[MOPER+1]; // operator name, MOPER=30
Lng32 leftChild_; // number of left child
Lng32 rightChild_; // number of right child
char tName_[MNAME+1]; // table name, often null, MNAME=60
float cardinality_; // number of rows returned by this node
float operatorCost_; // cost of this node alone, in seconds
float totalCost_; // cost of this node and all children, in seconds
char detailCost_[MCOST+1]; // node cost in 5 parts in key-value format, MCOST=200
char description_[MDESC+1]; // other attributs in key-value format, MDESC=3000
Lng32 MLINE;
Lng32 MLEN;
Lng32 MWIDE;
// Methods
short GetColumns();
void FormatForF(); // formats the line for optionsF and places into optFOutput
void DoHeader();
void DoOperator();
short OutputLines();
void truncate_whitespace(char * str) const;
void DoSeparator();
//void AddCommas (char *outStr, long &intSize) const;
//void FormatFloat (char *outStr, long &intSize, long &fullSize, float floatVal) const;
void FormatNumber (char *outStr, Lng32 &intSize, Lng32 &fullSize, char *strVal) const;
Lng32 GetField (char *col, const char *key, char *&fieldptr, Lng32 &fullSize) const;
Lng32 ParseField (char *&keyptr, char *&fieldptr, Lng32 &keySize, Lng32 &fullSize,
Lng32 &done);
Lng32 IsNumberFmt(char *fieldptr) const;
void FormatFirstLine (void);
NABoolean filterKey(
const char *key, Lng32 keySize, char * value, char * retVal,
Lng32 &decLoc);
void FormatLine (const char *key, const char *val, Lng32 keySize, Lng32 valSize,
Lng32 indent = 0, Lng32 decLoc = 0);
void FormatLongLine (const char *key, char *val, Lng32 keySize, Lng32 valSize,
Lng32 indent = 0);
void FormatSQL (const char *key, char *val, Lng32 keySize, Lng32 valSize, Lng32 indent = 0);
Lng32 FindParens(char *inStr, Lng32 par[]) const;
ExExeUtilDisplayExplainTdb & exeUtilTdb() const
{return (ExExeUtilDisplayExplainTdb &) tdb;};
};
class ExExeUtilDisplayExplainPrivateState : public ex_tcb_private_state
{
friend class ExExeUtilDisplayExplainTcb;
public:
ExExeUtilDisplayExplainPrivateState();
~ExExeUtilDisplayExplainPrivateState(); // destructor
protected:
ExExeUtilDisplayExplainTcb::Step step_;
Int64 matches_;
};
//////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------
// ExExeUtilDisplayExplainComplexTdb
// -----------------------------------------------------------------------
class ExExeUtilDisplayExplainComplexTdb : public ComTdbExeUtilDisplayExplainComplex
{
public:
// ---------------------------------------------------------------------
// Constructor is only called to instantiate an object used for
// retrieval of the virtual table function pointer of the class while
// unpacking. An empty constructor is enough.
// ---------------------------------------------------------------------
ExExeUtilDisplayExplainComplexTdb()
{}
virtual ~ExExeUtilDisplayExplainComplexTdb()
{}
// ---------------------------------------------------------------------
// Build a TCB for this TDB. Redefined in the Executor project.
// ---------------------------------------------------------------------
virtual ex_tcb *build(ex_globals *globals);
private:
// ---------------------------------------------------------------------
// !!!!!!! IMPORTANT -- NO DATA MEMBERS ALLOWED IN EXECUTOR TDB !!!!!!!!
// *********************************************************************
// The Executor TDB's are only used for the sole purpose of providing a
// way to supplement the Compiler TDB's (in comexe) with methods whose
// implementation depends on Executor objects. This is done so as to
// decouple the Compiler from linking in Executor objects unnecessarily.
//
// When a Compiler generated TDB arrives at the Executor, the same data
// image is "cast" as an Executor TDB after unpacking. Therefore, it is
// a requirement that a Compiler TDB has the same object layout as its
// corresponding Executor TDB. As a result of this, all Executor TDB's
// must have absolutely NO data members, but only member functions. So,
// if you reach here with an intention to add data members to a TDB, ask
// yourself two questions:
//
// 1. Are those data members Compiler-generated?
// If yes, put them in the ComTdbDLL instead.
// If no, they should probably belong to someplace else (like TCB).
//
// 2. Are the classes those data members belong defined in the executor
// project?
// If your answer to both questions is yes, you might need to move
// the classes to the comexe project.
// ---------------------------------------------------------------------
};
//
// Task control block
//
class ExExeUtilDisplayExplainComplexTcb : public ExExeUtilTcb
{
friend class ExExeUtilDisplayExplainComplexTdb;
friend class ExExeUtilPrivateState;
public:
// Constructor
ExExeUtilDisplayExplainComplexTcb(const ComTdbExeUtilDisplayExplainComplex & exe_util_tdb,
ex_globals * glob = 0);
~ExExeUtilDisplayExplainComplexTcb();
virtual short work();
virtual ex_tcb_private_state *
allocatePstates(
Lng32 &numElems, // inout, desired/actual elements
Lng32 &pstateLength); // out, length of one element
private:
//state machine states for work() method
enum Step
{
EMPTY_,
TURN_ON_IMOD_,
IN_MEMORY_BASE_TABLE_CREATE_,
IN_MEMORY_CREATE_,
REGULAR_CREATE_,
ALTER_TO_NOAUDIT_,
ALTER_TO_AUDIT_,
EXPLAIN_CREATE_,
EXPLAIN_INSERT_SELECT_,
DROP_AND_ERROR_,
DROP_AND_DONE_,
DONE_,
ERROR_,
CANCELLED_
};
ExExeUtilDisplayExplainComplexTdb & exeUtilTdb() const
{return (ExExeUtilDisplayExplainComplexTdb &) tdb;};
Step step_;
};
class ExExeUtilDisplayExplainComplexPrivateState : public ex_tcb_private_state
{
friend class ExExeUtilDisplayExplainComplexTcb;
public:
ExExeUtilDisplayExplainComplexPrivateState();
~ExExeUtilDisplayExplainComplexPrivateState(); // destructor
protected:
Int64 matches_;
};
class ExExeUtilDisplayExplainShowddlTcb : public ExExeUtilTcb
{
friend class ExExeUtilDisplayExplainComplexTdb;
friend class ExExeUtilPrivateState;
public:
// Constructor
ExExeUtilDisplayExplainShowddlTcb(const ComTdbExeUtilDisplayExplainComplex & exe_util_tdb,
ex_globals * glob = 0);
~ExExeUtilDisplayExplainShowddlTcb();
virtual short work();
virtual ex_tcb_private_state *
allocatePstates(
Lng32 &numElems, // inout, desired/actual elements
Lng32 &pstateLength); // out, length of one element
private:
//state machine states for work() method
enum Step
{
EMPTY_,
GET_LABEL_STATS_,
EXPLAIN_CREATE_,
DONE_,
ERROR_,
CANCELLED_
};
ExExeUtilDisplayExplainComplexTdb & exeUtilTdb() const
{return (ExExeUtilDisplayExplainComplexTdb &) tdb;};
Step step_;
char * newQry_;
};
class ExExeUtilDisplayExplainShowddlPrivateState : public ex_tcb_private_state
{
friend class ExExeUtilDisplayExplainShowddlTcb;
public:
ExExeUtilDisplayExplainShowddlPrivateState();
~ExExeUtilDisplayExplainShowddlPrivateState(); // destructor
protected:
Int64 matches_;
};
//////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------
// ExExeUtilCreateTableAsTdb
// -----------------------------------------------------------------------
class ExExeUtilCreateTableAsTdb : public ComTdbExeUtilCreateTableAs
{
public:
// ---------------------------------------------------------------------
// Constructor is only called to instantiate an object used for
// retrieval of the virtual table function pointer of the class while
// unpacking. An empty constructor is enough.
// ---------------------------------------------------------------------
ExExeUtilCreateTableAsTdb()
{}
virtual ~ExExeUtilCreateTableAsTdb()
{}
// ---------------------------------------------------------------------
// Build a TCB for this TDB. Redefined in the Executor project.
// ---------------------------------------------------------------------
virtual ex_tcb *build(ex_globals *globals);
private:
// ---------------------------------------------------------------------
// !!!!!!! IMPORTANT -- NO DATA MEMBERS ALLOWED IN EXECUTOR TDB !!!!!!!!
// *********************************************************************
// The Executor TDB's are only used for the sole purpose of providing a
// way to supplement the Compiler TDB's (in comexe) with methods whose
// implementation depends on Executor objects. This is done so as to
// decouple the Compiler from linking in Executor objects unnecessarily.
//
// When a Compiler generated TDB arrives at the Executor, the same data
// image is "cast" as an Executor TDB after unpacking. Therefore, it is
// a requirement that a Compiler TDB has the same object layout as its
// corresponding Executor TDB. As a result of this, all Executor TDB's
// must have absolutely NO data members, but only member functions. So,
// if you reach here with an intention to add data members to a TDB, ask
// yourself two questions:
//
// 1. Are those data members Compiler-generated?
// If yes, put them in the ComTdbDLL instead.
// If no, they should probably belong to someplace else (like TCB).
//
// 2. Are the classes those data members belong defined in the executor
// project?
// If your answer to both questions is yes, you might need to move
// the classes to the comexe project.
// ---------------------------------------------------------------------
};
class ExExeUtilCreateTableAsTcb : public ExExeUtilTcb
{
friend class ExExeUtilCreateTableAsTdb;
friend class ExExeUtilPrivateState;
public:
// Constructor
ExExeUtilCreateTableAsTcb(const ComTdbExeUtil & exe_util_tdb,
ex_globals * glob = 0);
virtual short work();
ExExeUtilCreateTableAsTdb & ctaTdb() const
{
return (ExExeUtilCreateTableAsTdb &) tdb;
};
virtual ex_tcb_private_state * allocatePstates(
Lng32 &numElems, // inout, desired/actual elements
Lng32 &pstateLength); // out, length of one element
private:
enum Step
{
INITIAL_,
CREATE_,
TRUNCATE_TABLE_,
INSERT_SIDETREE_,
INSERT_VSBB_,
ALTER_TO_NOAUDIT_,
ALTER_TO_AUDIT_,
ALTER_TO_AUDIT_AND_INSERT_VSBB_,
UPD_STATS_,
DONE_,
HANDLE_ERROR_, TRUNCATE_TABLE_AND_ERROR_, ERROR_,
DROP_AND_ERROR_,
DROP_AND_DONE_,
INSERT_SIDETREE_EXECUTE_,
INSERT_VSBB_EXECUTE_
};
Step step_;
NABoolean doSidetreeInsert_;
NABoolean tableExists_;
};
class ExExeUtilCreateTableAsPrivateState : public ex_tcb_private_state
{
friend class ExExeUtilCreateTableAsTcb;
public:
ExExeUtilCreateTableAsPrivateState();
~ExExeUtilCreateTableAsPrivateState(); // destructor
protected:
};
//////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------
// ExExeUtilCleanupVolatileTablesTdb
// -----------------------------------------------------------------------
class ExExeUtilCleanupVolatileTablesTdb : public ComTdbExeUtilCleanupVolatileTables
{
public:
// ---------------------------------------------------------------------
// Constructor is only called to instantiate an object used for
// retrieval of the virtual table function pointer of the class while
// unpacking. An empty constructor is enough.
// ---------------------------------------------------------------------
ExExeUtilCleanupVolatileTablesTdb()
{}
virtual ~ExExeUtilCleanupVolatileTablesTdb()
{}
// ---------------------------------------------------------------------
// Build a TCB for this TDB. Redefined in the Executor project.
// ---------------------------------------------------------------------
virtual ex_tcb *build(ex_globals *globals);
private:
// ---------------------------------------------------------------------
// !!!!!!! IMPORTANT -- NO DATA MEMBERS ALLOWED IN EXECUTOR TDB !!!!!!!!
// *********************************************************************
// The Executor TDB's are only used for the sole purpose of providing a
// way to supplement the Compiler TDB's (in comexe) with methods whose
// implementation depends on Executor objects. This is done so as to
// decouple the Compiler from linking in Executor objects unnecessarily.
//
// When a Compiler generated TDB arrives at the Executor, the same data
// image is "cast" as an Executor TDB after unpacking. Therefore, it is
// a requirement that a Compiler TDB has the same object layout as its
// corresponding Executor TDB. As a result of this, all Executor TDB's
// must have absolutely NO data members, but only member functions. So,
// if you reach here with an intention to add data members to a TDB, ask
// yourself two questions:
//
// 1. Are those data members Compiler-generated?
// If yes, put them in the ComTdbDLL instead.
// If no, they should probably belong to someplace else (like TCB).
//
// 2. Are the classes those data members belong defined in the executor
// project?
// If your answer to both questions is yes, you might need to move
// the classes to the comexe project.
// ---------------------------------------------------------------------
};
class ExExeUtilVolatileTablesTcb : public ExExeUtilTcb
{
public:
// Constructor
ExExeUtilVolatileTablesTcb(const ComTdbExeUtil & exe_util_tdb,
ex_globals * glob = 0);
virtual ex_tcb_private_state * allocatePstates(
Lng32 &numElems, // inout, desired/actual elements
Lng32 &pstateLength); // out, length of one element
protected:
short isCreatorProcessObsolete(const char * name,
NABoolean includesCat,