forked from oceanbase/seekdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathob_sql_define.h
More file actions
821 lines (735 loc) · 23.1 KB
/
Copy pathob_sql_define.h
File metadata and controls
821 lines (735 loc) · 23.1 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
/*
* Copyright (c) 2025 OceanBase.
*
* Licensed 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.
*/
#ifndef OCEANBASE_SQL_OB_SQL_DEFINE_H_
#define OCEANBASE_SQL_OB_SQL_DEFINE_H_
#include "lib/container/ob_fixed_array.h"
#include "share/datum/ob_datum.h"
#include "common/object/ob_object.h"
#include "share/ob_define.h"
#include "deps/oblib/src/lib/container/ob_array.h"
#include "src/share/rc/ob_tenant_base.h"
#include "deps/oblib/src/lib/container/ob_2d_array.h"
namespace oceanbase
{
namespace share
{
namespace schema
{
struct ObSchemaObjVersion;
}
}
using namespace common;
namespace sql
{
const int64_t OB_SQL_MAX_CHILD_OPERATOR_NUM = 16;
const int64_t OB_MIN_PARALLEL_TASK_COUNT = 13; // expected minimum number of tasks held by each parallelism
const int64_t OB_MAX_PARALLEL_TASK_COUNT = 100; // expected maximum number of tasks held per parallelism
const int64_t OB_MIN_MARCO_COUNT_IN_TASK = 1; // each task is responsible for at least this number of macro blocks
const int64_t OB_INVAILD_PARALLEL_TASK_COUNT = -1;
const int64_t OB_EXPECTED_TASK_LOAD = 102400; //KB, one task will get 100MB data from disk
const int64_t OB_GET_MACROS_COUNT_BY_QUERY_RANGE = 1;
const int64_t OB_GET_BLOCK_RANGE = 2;
const int64_t OB_BROADCAST_THRESHOLD = 100;
const int64_t OB_PARTITION_COUNT_PRE_SQL = 16; // used for the bucket size of hash table or default size of SEAarry, assuming that general SQL will not exceed 16 partitions
const int64_t OB_MAX_RECURSIVE_SQL_LEVELS = 50; //compatible with oracle
typedef common::ObFixedArray<share::schema::ObSchemaObjVersion, common::ObIAllocator> DependenyTableStore;
typedef common::ParamStore ParamStore;
// ob_rowkey_info.h oceanbase::common::ObOrderType also defined
enum ObOrderDirection
{
NULLS_FIRST_ASC = 0, // order, forward scan, Forward, NULLs first
NULLS_LAST_ASC, // order, forward scan, Forward, NULLs last
NULLS_FIRST_DESC, // descending order, backward scan, Backward, NULLs first
NULLS_LAST_DESC, // descending order, backward scan, Backward, NULLs last
UNORDERED, // do not sort, keep as is
MAX_DIR, // illegal value
};
inline bool is_null_first(ObOrderDirection order_direction) {
return NULLS_FIRST_ASC == order_direction || NULLS_FIRST_DESC == order_direction;
}
extern ObOrderDirection default_asc_direction();
extern ObOrderDirection default_desc_direction();
inline bool is_ascending_direction(const ObOrderDirection direction)
{
return (NULLS_FIRST_ASC == direction || NULLS_LAST_ASC == direction);
}
inline bool is_descending_direction(const ObOrderDirection direction)
{
return (NULLS_FIRST_DESC == direction || NULLS_LAST_DESC == direction);
}
enum ObJoinType
{
UNKNOWN_JOIN = 0,
INNER_JOIN,
LEFT_OUTER_JOIN,
RIGHT_OUTER_JOIN,
FULL_OUTER_JOIN,
LEFT_SEMI_JOIN,
RIGHT_SEMI_JOIN,
LEFT_ANTI_JOIN,
RIGHT_ANTI_JOIN,
MAX_JOIN_TYPE
};
enum SlaveMappingType {
SM_NONE = 0,
SM_PWJ_HASH_HASH,
SM_PPWJ_HASH_HASH,
SM_PPWJ_BCAST_NONE,
SM_PPWJ_NONE_BCAST,
};
enum PathType
{
INVALID = 0,
ACCESS,
JOIN,
SUBQUERY,
FAKE_CTE_TABLE_ACCESS,
FUNCTION_TABLE_ACCESS,
TEMP_TABLE_ACCESS,
JSON_TABLE_ACCESS,
VALUES_TABLE_ACCESS
};
enum JtColType {
INVALID_COL_TYPE = 0,
COL_TYPE_ORDINALITY, // 1
COL_TYPE_EXISTS, // 2
COL_TYPE_QUERY, // 3
COL_TYPE_VALUE, // 4
NESTED_COL_TYPE, // 5
COL_TYPE_QUERY_JSON_COL, // 6
COL_TYPE_VAL_EXTRACT_XML, // 7
COL_TYPE_XMLTYPE_XML, // 8
COL_TYPE_ORDINALITY_XML = 9,
COL_TYPE_RB_ITERATE = 10,
COL_TYPE_UNNEST = 11,
};
enum ObNameTypeClass
{
OB_TABLE_NAME_CLASS = 0, //table name, database names, table alias names ,affected by system variable lower_case_table_names
OB_COLUMN_NAME_CLASS = 1,// column name,column alias name. index name , stored using lettercase and comparisons are case insensitive
OB_USER_NAME_CLASS = 2,// user names, tenant names and other names, stored using lettercase and comparisons are case sensitive
};
enum ObMatchAgainstMode {
NATURAL_LANGUAGE_MODE = 0,
NATURAL_LANGUAGE_MODE_WITH_QUERY_EXPANSION = 1,
BOOLEAN_MODE = 2,
WITH_QUERY_EXPANSION = 3,
MATCH_PHRASE_MODE = 4,
MAX_MATCH_AGAINST_MODE = 5,
};
enum ObMatchOperator {
MATCH_OPERATOR_OR = 0,
MATCH_OPERATOR_AND = 1,
MAX_MATCH_OPERATOR = 2,
};
enum ObMatchScoreNorm {
SCORE_NORM_NONE = 0,
SCORE_NORM_MIN_MAX = 1,
MAX_SCORE_NORM_TYPE = 3,
};
enum ObMatchFiledsType {
MATCH_MOST_FIELDS = 0,
MATCH_BEST_FIELDS = 1,
MATCH_CROSS_FIELDS = 2,
MAX_MATCH_FIELDS_TYPE = 3,
};
#define IS_HASH_SLAVE_MAPPING(type) \
(((type) == SlaveMappingType::SM_PWJ_HASH_HASH) \
|| ((type) == SlaveMappingType::SM_PPWJ_HASH_HASH))
#define IS_BCAST_SLAVE_MAPPING(type) \
(((type) == SlaveMappingType::SM_PPWJ_BCAST_NONE) \
|| ((type) == SlaveMappingType::SM_PPWJ_NONE_BCAST))
#define IS_JOIN(type) \
(((type) == PHY_MERGE_JOIN) || \
((type) == PHY_NESTED_LOOP_JOIN) || \
((type) == PHY_HASH_JOIN) || \
((type) == PHY_BLOCK_BASED_NESTED_LOOP_JOIN))
#define IS_OUTER_JOIN(join_type) \
((join_type) == LEFT_OUTER_JOIN || \
(join_type) == RIGHT_OUTER_JOIN || \
(join_type) == FULL_OUTER_JOIN)
#define IS_SEMI_ANTI_JOIN(join_type) \
((join_type) == LEFT_SEMI_JOIN || \
(join_type) == RIGHT_SEMI_JOIN || \
(join_type) == LEFT_ANTI_JOIN || \
(join_type) == RIGHT_ANTI_JOIN)
#define IS_SEMI_JOIN(join_type) \
((join_type) == LEFT_SEMI_JOIN || \
(join_type) == RIGHT_SEMI_JOIN)
#define IS_ANTI_JOIN(join_type) \
((join_type) == LEFT_ANTI_JOIN || \
(join_type) == RIGHT_ANTI_JOIN)
#define IS_LEFT_SEMI_ANTI_JOIN(join_type) \
((join_type) == LEFT_SEMI_JOIN || \
(join_type) == LEFT_ANTI_JOIN)
#define IS_RIGHT_SEMI_ANTI_JOIN(join_type) \
((join_type) == RIGHT_SEMI_JOIN || \
(join_type) == RIGHT_ANTI_JOIN)
#define IS_INNER_JOIN(join_type) (INNER_JOIN == join_type)
#define IS_NOT_INNER_JOIN(join_type) (INNER_JOIN != join_type)
#define IS_LEFT_STYLE_JOIN(join_type) \
((join_type) == LEFT_SEMI_JOIN || \
(join_type) == LEFT_ANTI_JOIN || \
(join_type) == LEFT_OUTER_JOIN || \
(join_type) == FULL_OUTER_JOIN)
#define IS_RIGHT_STYLE_JOIN(join_type) \
((join_type) == RIGHT_SEMI_JOIN || \
(join_type) == RIGHT_ANTI_JOIN || \
(join_type) == RIGHT_OUTER_JOIN || \
(join_type) == FULL_OUTER_JOIN)
#define IS_SET_PHY_OP(type) \
(((type) == PHY_MERGE_UNION) || \
((type) == PHY_HASH_UNION) || \
((type) == PHY_HASH_INTERSECT) || \
((type) == PHY_MERGE_INTERSECT) || \
((type) == PHY_HASH_EXCEPT) || \
((type) == PHY_MERGE_EXCEPT))
inline ObJoinType get_opposite_join_type(ObJoinType type)
{
ObJoinType oppo_type = UNKNOWN_JOIN;
switch (type) {
case INNER_JOIN:
oppo_type = INNER_JOIN;
break;
case LEFT_OUTER_JOIN:
oppo_type = RIGHT_OUTER_JOIN;
break;
case RIGHT_OUTER_JOIN:
oppo_type = LEFT_OUTER_JOIN;
break;
case FULL_OUTER_JOIN:
oppo_type = FULL_OUTER_JOIN;
break;
case LEFT_SEMI_JOIN:
oppo_type = RIGHT_SEMI_JOIN;
break;
case RIGHT_SEMI_JOIN:
oppo_type = LEFT_SEMI_JOIN;
break;
case LEFT_ANTI_JOIN:
oppo_type = RIGHT_ANTI_JOIN;
break;
case RIGHT_ANTI_JOIN:
oppo_type = LEFT_ANTI_JOIN;
break;
default:
break;
}
return oppo_type;
}
inline const ObString &ob_join_type_str(ObJoinType join_type)
{
static const ObString join_type_str_st[] =
{
"UNKNOWN JOIN",
"JOIN",
"OUTER JOIN",
"RIGHT OUTER JOIN",
"FULL OUTER JOIN",
"SEMI JOIN",
"RIGHT SEMI JOIN",
"ANTI JOIN",
"RIGHT ANTI JOIN"
};
if (OB_LIKELY(join_type >= UNKNOWN_JOIN) && OB_LIKELY(join_type <= RIGHT_ANTI_JOIN)) {
return join_type_str_st[join_type];
} else {
return join_type_str_st[0];
}
}
enum ObTableLocationType
{
OB_TBL_LOCATION_UNINITIALIZED = 0,
OB_TBL_LOCATION_LOCAL,
OB_TBL_LOCATION_REMOTE,
OB_TBL_LOCATION_DISTRIBUTED,
OB_TBL_LOCATION_ALL//like EXPRESSION, match all
};
enum ObRepartitionType
{
OB_REPARTITION_NO_REPARTITION = 0,//no repartition
OB_REPARTITION_ONE_SIDE_ONE_LEVEL,//Only one side does repartition at a single level, the other side that does not do repartition is also at a single level
OB_REPARTITION_ONE_SIDE_TWO_LEVEL,//Only one side does repartition according to two-level partitioning, the other side that does not do repartition is two-level partitioning
OB_REPARTITION_BOTH_SIDE_ONE_LEVEL,//Both sides do repartition according to the first-level partitioning method, the partition key is the join key
OB_REPARTITION_ONE_SIDE_ONE_LEVEL_FIRST,//Only one side repartitions according to the level one partition of the other side (secondary partition table)
OB_REPARTITION_ONE_SIDE_ONE_LEVEL_SUB,//Only one side repartitions according to the second-level partition of the other side (second-level partition)
};
enum ObRepartitionScope
{
OB_REPARTITION_NONE_SIDE = 0,
OB_REPARTITION_LEFT_SIDE,
OB_REPARTITION_RIGHT_SIDE,
OB_REPARTITION_BOTH_SIDE,
};
// enum ObPLCacheObjectType start wich OB_PHY_PLAN_UNCERTAIN value.
// if it need add enum value to ObPhyPlanType, need skip ObPLCacheObjectType max value.
enum ObPhyPlanType
{
OB_PHY_PLAN_UNINITIALIZED = 0,
OB_PHY_PLAN_LOCAL,
OB_PHY_PLAN_REMOTE,
OB_PHY_PLAN_DISTRIBUTED,
OB_PHY_PLAN_UNCERTAIN
};
inline const ObString &ob_plan_type_str(ObPhyPlanType plan_type)
{
static const ObString plan_type_str_st[] =
{
"UNINITIALIZED",
"LOCAL",
"REMOTE",
"DISTRIBUTED",
};
if (OB_LIKELY(plan_type >= OB_PHY_PLAN_UNINITIALIZED)
&& OB_LIKELY(plan_type <= OB_PHY_PLAN_DISTRIBUTED)) {
return plan_type_str_st[plan_type];
} else {
return plan_type_str_st[0];
}
}
enum ExplainType
{
EXPLAIN_UNINITIALIZED = 0,
EXPLAIN_OUTLINE,
EXPLAIN_EXTENDED,
EXPLAIN_PARTITIONS,
EXPLAIN_TRADITIONAL,
EXPLAIN_FORMAT_JSON,
EXPLAIN_BASIC,
EXPLAIN_PLANREGRESS,
EXPLAIN_EXTENDED_NOADDR,
EXPLAIN_DBLINK_STMT,
EXPLAIN_HINT_FORMAT,
EXPLAIN_PLAN_TABLE
};
enum DiagnosticsType
{
DIAGNOSTICS_UNINITIALIZED = 0,
GET_CURRENT_COND,
GET_CURRENT_INFO,
GET_STACKED_COND,
GET_STACKED_INFO
};
enum OutlineType
{
OUTLINE_TYPE_UNINIT = 0,
USED_HINT,
OUTLINE_DATA
};
enum ObPlanLocationType
{
UNINITIALIZED = 0,
LOCAL,
REMOTE,
DISTRIBUTED
};
struct ObPQDistributeMethod
{
#define PQ_DIST_METHOD_DEF(DEF) \
DEF(NONE,) \
DEF(PARTITION,) \
DEF(RANDOM,) \
DEF(RANDOM_LOCAL,) \
DEF(HASH,) \
DEF(BROADCAST,) \
\
/* distribute in two level: SQC && PX worker*/ \
/* BROADCAST for SQC, RANDOM for PX worker */ \
DEF(BC2HOST,) \
DEF(SM_BROADCAST,) \
DEF(PARTITION_HASH,) \
DEF(DROP,) \
/*PARTITION_RANDOM: PDML situation handles parallel processing within partitions of a partitioned table; data is divided according to the SQC where the partition resides,*/ \
/*Parallelism is not limited by the number of partitions; however, the partition granularity for the pkey partition corresponding to PARTITION is partition,*/ \
/*Actual parallelism is limited by the number of partitions, unable to fully utilize parallelism in PDML scenarios*/ \
DEF(PARTITION_RANDOM,) \
DEF(RANGE,)\
DEF(PARTITION_RANGE,)\
DEF(HYBRID_HASH_BROADCAST,) /* aka PX SEND HYBRID HASH */ \
DEF(HYBRID_HASH_RANDOM,) /* aka PX SEND HYBRID HASH */ \
DEF(LOCAL,) /* represents pull to local */
DECLARE_ENUM(Type, type, PQ_DIST_METHOD_DEF, static);
static ObPQDistributeMethod::Type get_print_dist(ObPQDistributeMethod::Type method) {
ObPQDistributeMethod::Type print_method = ObPQDistributeMethod::LOCAL;
if (ObPQDistributeMethod::Type::SM_BROADCAST == method) {
print_method = ObPQDistributeMethod::Type::BROADCAST;
} else if (ObPQDistributeMethod::Type::PARTITION_HASH == method) {
print_method = ObPQDistributeMethod::Type::PARTITION;
} else {
print_method = method;
}
return print_method;
}
};
#define IS_PKEY_DIST_METHOD(type) \
(((type) == ObPQDistributeMethod::Type::PARTITION) \
|| ((type) == ObPQDistributeMethod::Type::PARTITION_RANDOM) \
|| ((type) == ObPQDistributeMethod::Type::PARTITION_HASH) \
|| ((type) == ObPQDistributeMethod::Type::PARTITION_RANGE))
struct ObNullDistributeMethod
{
/*
* ObNullDistributeMethod::NONE - neither DROP nor RANDOM, do null distribution as ObSliceCalc said
*/
#define NULL_DIST_METHOD_DEF(DEF) \
DEF(NONE,) \
DEF(DROP,) \
DEF(RANDOM,)
DECLARE_ENUM(Type, type, NULL_DIST_METHOD_DEF, static);
static ObNullDistributeMethod::Type get_print_dist(ObNullDistributeMethod::Type method) {
return method;
}
};
enum PartitionFilterType {
Uninitialized,
Forbidden,
OneLevelPartitionKey,
TwoLevelPartitionKey,
WholePartitionKey,
};
enum DistinctType
{
T_DISTINCT_NONE = 0,
T_HASH_DISTINCT = 1,
T_MERGE_DISTINCT = 2
};
enum class ObPDMLOption {
NOT_SPECIFIED = -1,
ENABLE,
DISABLE,
MAX_VALUE
};
enum class ObParallelDASOption {
NOT_SPECIFIED = -1,
ENABLE,
DISABLE,
MAX_VALUE
};
enum OrderingFlag
{
NOT_MATCH = 0,
JOIN_MATCH = 1,
GROUP_MATCH = 1 << 1,
WINFUNC_MATCH = 1 << 2,
DISTINCT_MATCH = 1 << 3,
SET_MATCH = 1 << 4,
ORDERBY_MATCH = 1 << 5,
POTENTIAL_MATCH = 1 << 6 // ordering may be used after subplan scan
};
enum OrderingCheckScope
{
NOT_CHECK = 0,
CHECK_GROUP = 1,
CHECK_WINFUNC = 1 << 1,
CHECK_DISTINCT = 1 << 2,
CHECK_SET = 1 << 3,
CHECK_ORDERBY = 1 << 4,
CHECK_ALL = (1 << 5) - 1
};
enum ObExecuteMode
{
EXECUTE_INVALID = 0,
EXECUTE_INNER,
EXECUTE_LOCAL,
EXECUTE_REMOTE,
EXECUTE_DIST,
EXECUTE_PS_PREPARE,//prepare statement local server
EXECUTE_PS_EXECUTE,//prepare statement local server
EXECUTE_PS_FETCH,
EXECUTE_PS_SEND_PIECE,
EXECUTE_PS_GET_PIECE,
EXECUTE_PS_SEND_LONG_DATA,
EXECUTE_PL_EXECUTE
};
enum PartitionIdCalcType {
CALC_INVALID = -1, // invalid calc type
CALC_NORMAL = 0, // calc both part id and subpart id
CALC_IGNORE_FIRST_PART = 1, // only calc subpart id
CALC_IGNORE_SUB_PART =2 // only calc part id
};
enum class ObParamOption {
NOT_SPECIFIED = -1,
FORCE,
EXACT,
MAX_VALUE
};
enum DominateRelation
{
OBJ_LEFT_DOMINATE = 0,
OBJ_RIGHT_DOMINATE,
OBJ_EQUAL,
OBJ_UNCOMPARABLE
};
// for parallel precedence, refer to
// https://docs.oracle.com/cd/E11882_01/server.112/e41573/hintsref.htm#PFGRF94937
enum PXParallelRule
{
USE_PX_DEFAULT = 0, // default disable parallel
MANUAL_HINT, // /*+ parallel(3) */
SESSION_FORCE_PARALLEL, // alter session force parallel query parallel 3;
MANUAL_TABLE_DOP, // create table t1 (...) parallel 3;
AUTO_DOP, // /*+ parallel(auto) */ or alter session set parallel_degree_policy = 'auto';
// force disable parallel below
PL_UDF_DAS_FORCE_SERIALIZE, //stmt has_pl_udf will use das, force serialize;
DBLINK_FORCE_SERIALIZE, //stmt has dblink will use das, force seialize;
LICENSE_NOT_ALLOW_OLAP, // current license does not support olap
MAX_OPTION
};
inline const char *ob_px_parallel_rule_str(PXParallelRule px_parallel_ruel)
{
const char *ret = "MAX_OPTION";
static const char *parallel_rule_type_to_str[] =
{
"USE_PX_DEFAULT",
"MANUAL_HINT",
"SESSION_FORCE_PARALLEL",
"MANUAL_TABLE_DOP",
"AUTO_DOP",
"PL_UDF_DAS_FORCE_SERIALIZE",
"DBLINK_FORCE_SERIALIZE",
"LICENSE_NOT_ALLOW_OLAP",
"MAX_OPTION",
};
if (OB_LIKELY(px_parallel_ruel >= USE_PX_DEFAULT)
&& OB_LIKELY(px_parallel_ruel <= MAX_OPTION)) {
ret = parallel_rule_type_to_str[px_parallel_ruel];
}
return ret;
}
static const int64_t PDML_DOP_LIMIT_PER_PARTITION = 10;
static const int64_t ROW_COUNT_THRESHOLD_PER_DOP = 10000; // zhanyuetodo: need adjust this by test
enum OpParallelRule
{
OP_GLOBAL_DOP = 0, /* use DOP from global parallel rule except MANUAL_TABLE_DOP or AUTO_DOP */
OP_DAS_DOP, /*+ DAS use DOP = 1 */
OP_HINT_DOP, /* use parallel hint for table: parallel(t1, 3) */
OP_TABLE_DOP, /*+ use table parallel property: create table t1 (...) parallel 3; */
OP_AUTO_DOP, /*+ DOP is calculated by AUTO_DOP */
OP_INHERIT_DOP, /*+ inherited from other op or determined by other op in the same DFO */
OP_DOP_RULE_MAX
};
typedef common::ObDmlEventType ObDmlEventType;
enum MayAddIntervalPart {
NO, // do nothing, just set part id to 0
YES, // add an interval partition, and set err code to force retry
PART_CHANGE_ERR, // set err code, make query stop and report and error msg to client
};
enum ObIDPAbortType
{
IDP_DEFAULT_ABORT = -1,
IDP_INVALID_HINT_ABORT = 0,
IDP_STOPENUM_EXPDOWN_ABORT = 1,
IDP_STOPENUM_LINEARDOWN_ABORT = 2,
IDP_ENUM_FAILED_ABORT = 3,
IDP_NO_ABORT = 4
};
enum class PseudoColumnRefType {
PSEUDO_PARTITION_ID = 0,
PSEUDO_SUB_PARTITION_ID = 1,
PSEUDO_PARTITION_NAME = 2,
PSEUDO_SUB_PARTITION_NAME = 3,
PSEUDO_PARTITION_INDEX = 4,
PSEUDO_SUB_PARTITION_INDEX = 5,
MAX = 255 // The maximum value not exceeding 8 bits
};
struct ObSqlDatumArray
{
ObSqlDatumArray()
: data_(nullptr),
count_(0),
element_()
{
}
typedef common::ObArrayWrap<common::ObDatum> DatumArray;
static ObSqlDatumArray *alloc(common::ObIAllocator &allocator, int64_t count);
TO_STRING_KV("data", DatumArray(data_, count_),
K_(count),
K_(element));
common::ObDatum *data_;
int64_t count_;
common::ObDataType element_;
};
OB_INLINE ObSqlDatumArray *ObSqlDatumArray::alloc(common::ObIAllocator &allocator, int64_t count)
{
ObSqlDatumArray *array_obj = nullptr;
void *array_buf = nullptr;
void *data_buf = nullptr;
int64_t array_size = sizeof(ObSqlDatumArray) + sizeof(common::ObDatum) * count;
if (OB_NOT_NULL(array_buf = allocator.alloc(array_size))) {
array_obj = new (array_buf) ObSqlDatumArray();
data_buf = static_cast<char*>(array_buf) + sizeof(ObSqlDatumArray);
array_obj->data_ = new (data_buf) common::ObDatum[count];
array_obj->count_ = count;
}
return array_obj;
}
// Window function optimization settings. (_windowfunc_optimization_settings sys variable)
struct ObWinfuncOptimizationOpt
{
ObWinfuncOptimizationOpt() : v_(0) {}
union {
struct {
uint64_t disable_range_distribution_:1;
uint64_t disable_reporting_wf_pushdown_:1;
// add more options here.
};
uint64_t v_;
};
};
// class full name: ob tenant memory array.
// Used to solve the following problem:
// the initial memory allocation of ObSEArray is relatively large, leading to memory inflation issues in some scenarios.
// Default to using the MTL_ID() tenant,
// and the lifecycle of this class cannot cross tenants.
template<typename T, typename BlockAllocatorT = ModulePageAllocator, bool auto_free = false>
class ObTMArray final : public ObSEArrayImpl<T, 0, BlockAllocatorT, auto_free>
{
public:
using ObSEArrayImpl<T, 0, BlockAllocatorT, auto_free>::ObSEArrayImpl;
ObTMArray(int64_t block_size = std::min(static_cast<int64_t>(4 * sizeof(T)), OB_MALLOC_NORMAL_BLOCK_SIZE),
const BlockAllocatorT &alloc = BlockAllocatorT("TMArray"));
};
template<typename T, typename BlockAllocatorT, bool auto_free>
ObTMArray<T, BlockAllocatorT, auto_free>::ObTMArray(int64_t block_size,
const BlockAllocatorT &alloc)
: ObSEArrayImpl<T, 0, BlockAllocatorT, auto_free>(block_size, alloc)
{
this->set_tenant_id(MTL_ID());
}
template <typename T, int max_block_size = OB_MALLOC_BIG_BLOCK_SIZE,
typename BlockAllocatorT = ModulePageAllocator,
bool auto_free = false,
typename BlockPointerArrayT = ObSEArray<T *, OB_BLOCK_POINTER_ARRAY_SIZE,
BlockAllocatorT, auto_free> >
class ObTMSegmentArray final : public Ob2DArray<T, max_block_size, BlockAllocatorT, auto_free,
BlockPointerArrayT>
{
public:
ObTMSegmentArray(const BlockAllocatorT &alloc = BlockAllocatorT("TMSegmentArray"));
int assign(const ObTMSegmentArray &other) { return this->inner_assign(other); }
};
template <typename T, int max_block_size,
typename BlockAllocatorT, bool auto_free,
typename BlockPointerArrayT>
ObTMSegmentArray<T, max_block_size, BlockAllocatorT, auto_free,
BlockPointerArrayT>::ObTMSegmentArray(const BlockAllocatorT &alloc)
: Ob2DArray<T, max_block_size, BlockAllocatorT, auto_free,
BlockPointerArrayT>(alloc)
{
this->set_tenant_id(MTL_ID());
}
inline const ObString &ob_match_against_mode_str(const ObMatchAgainstMode mode)
{
static const ObString ma_mode_str[] =
{
"NATURAL LANGUAGE MODE",
"NATURAL LANGUAGE MODE WITH QUERY EXPANSION",
"BOOLEAN MODE",
"WITH QUERY EXPANSION",
"MATCH_PHRASE_MODE",
"UNKNOWN MATCH MODE"
};
if (OB_LIKELY(mode >= ObMatchAgainstMode::NATURAL_LANGUAGE_MODE)
&& OB_LIKELY(mode < ObMatchAgainstMode::MAX_MATCH_AGAINST_MODE)) {
return ma_mode_str[mode];
} else {
return ma_mode_str[ObMatchAgainstMode::MAX_MATCH_AGAINST_MODE];
}
}
static bool is_fixed_length_storage(ObObjType type) {
bool is_fixed = true;
ObObjTypeClass tc = ob_obj_type_class(type);
OB_ASSERT(tc >= ObNullTC && tc < ObMaxTC);
if (ObNumberTC == tc
|| ObExtendTC == tc
|| ObTextTC == tc
|| ObEnumSetInnerTC == tc
|| ObRawTC == tc
|| ObRowIDTC == tc
|| ObLobTC == tc
|| ObJsonTC == tc
|| ObGeometryTC == tc
|| ObUserDefinedSQLTC == tc
|| ObDecimalIntTC == tc
|| ObRoaringBitmapTC == tc) {
is_fixed = false;
}
return is_fixed;
}
static bool is_fixed_length(ObObjType type) {
bool is_fixed = true;
ObObjTypeClass tc = ob_obj_type_class(type);
OB_ASSERT(tc >= ObNullTC && tc < ObMaxTC);
if (ObNumberTC == tc
|| ObExtendTC == tc
|| ObTextTC == tc
|| ObStringTC == tc
|| ObEnumSetInnerTC == tc
|| ObRawTC == tc
|| ObRowIDTC == tc
|| ObLobTC == tc
|| ObJsonTC == tc
|| ObGeometryTC == tc
|| ObUserDefinedSQLTC == tc
|| ObDecimalIntTC == tc
|| ObRoaringBitmapTC == tc
|| ObCollectionSQLTC == tc) {
is_fixed = false;
}
return is_fixed;
}
static int16_t get_type_fixed_length(ObObjType type) {
int16_t len = 0;
ObObjTypeClass tc = ob_obj_type_class(type);
OB_ASSERT(tc >= ObNullTC && tc < ObMaxTC);
switch (tc)
{
case ObUIntTC:
case ObIntTC:
case ObDoubleTC:
case ObDateTimeTC:
case ObMySQLDateTimeTC:
case ObTimeTC:
case ObBitTC:
case ObEnumSetTC:
{
len = 8;
break;
}
case ObDateTC:
case ObMySQLDateTC:
case ObFloatTC:
{
len = 4;
break;
}
case ObYearTC:
{
len = 1;
break;
}
case ObOTimestampTC: {
len = 10;
break;
}
default:
break;
}
return len;
}
} // namespace sql
} // namespace oceanbase
#endif /* OCEANBASE_SQL_OB_SQL_DEFINE_H_ */