forked from oceanbase/oceanbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathob_raw_expr_util.h
More file actions
1189 lines (1118 loc) · 67.5 KB
/
Copy pathob_raw_expr_util.h
File metadata and controls
1189 lines (1118 loc) · 67.5 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
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#ifndef _OB_RAW_EXPR_UTIL_H
#define _OB_RAW_EXPR_UTIL_H 1
#include "sql/resolver/expr/ob_raw_expr.h"
#include "common/row/ob_row_desc.h"
#include "sql/parser/parse_node.h"
#include "lib/hash/ob_placement_hashmap.h"
#include "share/schema/ob_column_schema.h"
#include "share/system_variable/ob_system_variable.h"
#include "share/schema/ob_schema_getter_guard.h"
#include "sql/resolver/ob_resolver_utils.h"
#include "lib/hash/ob_hashset.h"
#include "lib/allocator/ob_allocator.h"
#include "share/schema/ob_trigger_info.h"
namespace oceanbase
{
namespace sql
{
class ObBasicSessionInfo;
class ObStmt;
class ObDMLStmt;
struct ColumnItem;
struct ObGroupbyExpr;
struct ObResolverUtils;
struct ObSelectIntoItem;
class ObDMLResolver;
class ObSequenceNamespaceChecker;
enum JsonArrayaggParserOffset
{
PARSE_JSON_ARRAYAGG_DISTINCT,
PARSE_JSON_ARRAYAGG_EXPR,
PARSE_JSON_ARRAYAGG_FORMAT,
PARSE_JSON_ARRAYAGG_ORDER,
PARSE_JSON_ARRAYAGG_ON_NULL,
PARSE_JSON_ARRAYAGG_RETURNING,
PARSE_JSON_ARRAYAGG_STRICT,
PARSE_JSON_ARRAYAGG_MAX_IDX
};
enum JsonObjectaggParserOffset
{
PARSE_JSON_OBJECTAGG_KEY,
PARSE_JSON_OBJECTAGG_VALUE,
PARSE_JSON_OBJECTAGG_FORMAT,
PARSE_JSON_OBJECTAGG_ON_NULL,
PARSE_JSON_OBJECTAGG_RETURNING,
PARSE_JSON_OBJECTAGG_STRICT,
PARSE_JSON_OBJECTAGG_UNIQUE_KEYS,
PARSE_JSON_OBJECTAGG_MAX_IDX
};
enum JsonAraayaggDeduceOffset
{
DEDUCE_JSON_ARRAYAGG_EXPR,
DEDUCE_JSON_ARRAYAGG_FORMAT,
DEDUCE_JSON_ARRAYAGG_ON_NULL,
DEDUCE_JSON_ARRAYAGG_RETURNING,
DEDUCE_JSON_ARRAYAGG_STRICT,
DEDUCE_JSON_ARRAYAGG_MAX_IDX
};
template <class T>
class UniqueSetWrapAllocer
{
public:
UniqueSetWrapAllocer() : allocator_(NULL) {}
UniqueSetWrapAllocer(ObIAllocator &alloc) : allocator_(&alloc) {}
T *alloc()
{
T *ret = static_cast<T *>(allocator_->alloc(sizeof(T)));
if (NULL != ret) {
new(ret) T();
}
return ret;
}
void free(T *data)
{
if (NULL == data || NULL == allocator_) {
SQL_LOG_RET(WARN, common::OB_INVALID_ARGUMENT, "invalid param null pointer", KP(data), KP(allocator_));
} else {
data->~T();
allocator_->free(data);
}
}
void inc_ref() {}
void dec_ref() {}
private:
ObIAllocator *allocator_;
};
class ObRawExprUniqueSet
{
public:
ObRawExprUniqueSet(bool need_unique)
: need_unique_(need_unique)
{}
virtual ~ObRawExprUniqueSet() {}
int64_t count() const { return expr_array_.count(); }
template<typename RawExprType>
int append(RawExprType *expr);
template<typename RawExprType>
int append(const ObIArray<RawExprType *> &exprs);
const ObIArray<ObRawExpr *> &get_expr_array() const { return expr_array_; } ;
void reuse() { expr_array_.reuse(); }
int flatten_and_add_raw_exprs(const ObIArray<ObRawExpr *> &raw_exprs,
std::function<bool(ObRawExpr *)> filter,
bool need_flatten_gen_col = true);
int flatten_and_add_raw_exprs(const ObRawExprUniqueSet &raw_exprs,
bool need_flatten_gen_col = true,
std::function<bool(ObRawExpr *)> filter
= [](ObRawExpr *e){ return NULL != e;});
int flatten_temp_expr(ObRawExpr *raw_expr);
private:
int flatten_and_add_raw_exprs(ObRawExpr *raw_expr,
bool need_flatten_gen_col = true,
std::function<bool(ObRawExpr *)> filter
= [](ObRawExpr *e){ return NULL != e;});
DISALLOW_COPY_AND_ASSIGN(ObRawExprUniqueSet);
private:
ObSEArray<ObRawExpr *, 16, common::ModulePageAllocator, true> expr_array_;
bool need_unique_;
};
template<typename RawExprType>
int ObRawExprUniqueSet::append(RawExprType *expr)
{
int ret = OB_SUCCESS;
if (!need_unique_) {
if (OB_FAIL(expr_array_.push_back(expr))) {
SQL_LOG(WARN, "fail to append expr", K(ret));
}
} else {
if (expr->has_flag(IS_MARKED)) {
// do nothing
} else {
if (OB_FAIL(expr_array_.push_back(expr))) {
SQL_LOG(WARN, "fail to append expr", K(ret));
} else if (OB_FAIL(expr->add_flag(IS_MARKED))) {
SQL_LOG(WARN, "fail to add flag", K(ret));
}
}
}
return ret;
}
template<typename RawExprType>
int ObRawExprUniqueSet::append(const ObIArray<RawExprType *> &exprs)
{
int ret = OB_SUCCESS;
for (int64_t i = 0; OB_SUCC(ret) && i < exprs.count(); i++) {
if (OB_FAIL(append(exprs.at(i)))) {
SQL_LOG(WARN, "fail to append expr", K(ret));
}
}
return ret;
}
class ObRawExprUtils
{
public:
/**
* make expression from string
*
* @param expr_str [in] expression string
* @param buf_len [in] expression string length
* @param allocator [in] allocator used by parser
* @param resolve_ctx [in] expression resolver context
* @param expr [out] resolved expression
* @param columns [out] columns in the expr
* @param sys_vars [out] system variables in the expr
* @param sub_query_info [out] subqueries in the expr
*
* @return
*/
static int make_raw_expr_from_str(const char *expr_str, const int64_t buf_len,
ObExprResolveContext &resolve_ctx,
ObRawExpr *&expr,
common::ObIArray<ObQualifiedName> &columns,
common::ObIArray<ObVarInfo> &sys_vars,
common::ObIArray<ObSubQueryInfo> *sub_query_info,
common::ObIArray<ObAggFunRawExpr*> &aggr_exprs,
common::ObIArray<ObWinFunRawExpr*> &win_exprs,
common::ObIArray<ObUDFInfo> &udf_info);
static int make_raw_expr_from_str(const common::ObString &expr_str,
ObExprResolveContext &resolve_ctx,
ObRawExpr *&expr,
common::ObIArray<ObQualifiedName> &column,
common::ObIArray<ObVarInfo> &sys_vars,
common::ObIArray<ObSubQueryInfo> *sub_query_info,
common::ObIArray<ObAggFunRawExpr*> &aggr_exprs,
common::ObIArray<ObWinFunRawExpr*> &win_exprs,
common::ObIArray<ObUDFInfo> &udf_info);
static int parse_default_expr_from_str(const common::ObString &expr_str,
ObCharsets4Parser expr_str_cs_type,
common::ObIAllocator &allocator,
const ParseNode *&node);
static int parse_expr_list_node_from_str(const common::ObString &expr_str,
ObCharsets4Parser expr_str_cs_type,
common::ObIAllocator &allocator,
const ParseNode *&node,
const ObSQLMode &sql_mode);
static int parse_expr_node_from_str(const common::ObString &expr_str,
ObCharsets4Parser expr_str_cs_type,
common::ObIAllocator &allocator,
const ParseNode *&node,
const ObSQLMode &sql_mode = 0);
static int parse_bool_expr_node_from_str(const common::ObString &expr_str,
common::ObIAllocator &allocator,
const ParseNode *&node);
static int build_check_constraint_expr(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo &session_info,
const ParseNode &node,
ObRawExpr *&expr,
common::ObIArray<ObQualifiedName> &columns);
static int check_deterministic(const ObRawExpr *expr,
common::ObIAllocator &allocator,
const ObResolverUtils::PureFunctionCheckStatus
check_status = ObResolverUtils::DISABLE_CHECK);
static int check_deterministic_single(const ObRawExpr *expr,
const ObResolverUtils::PureFunctionCheckStatus
check_status = ObResolverUtils::DISABLE_CHECK);
static int build_generated_column_expr(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo &session_info,
const ParseNode &node,
ObRawExpr *&expr,
common::ObIArray<ObQualifiedName> &columns,
const ObTableSchema* new_table_schema,
const bool sequence_allowed,
ObDMLResolver *dml_resolver,
const ObSchemaChecker *schema_checker = NULL,
const ObResolverUtils::PureFunctionCheckStatus
check_status = ObResolverUtils::DISABLE_CHECK,
const bool need_check_simple_column = true);
static int build_generated_column_expr(const common::ObString &expr_str,
ObRawExprFactory &expr_factory,
const ObSQLSessionInfo &session_info,
ObRawExpr *&expr,
common::ObIArray<ObQualifiedName> &columns,
const ObTableSchema* new_table_schema,
const bool sequence_allowed,
ObDMLResolver *dml_resolver,
const ObSchemaChecker *schema_checker = NULL,
const ObResolverUtils::PureFunctionCheckStatus
check_status = ObResolverUtils::DISABLE_CHECK,
const bool need_check_simple_column = true);
static int build_generated_column_expr(const obrpc::ObCreateIndexArg *arg,
const common::ObString &expr_str,
ObRawExprFactory &expr_factory,
const ObSQLSessionInfo &session_info,
const share::schema::ObTableSchema &table_schema,
ObRawExpr *&expr,
const ObSchemaChecker *schema_checker = NULL,
const ObResolverUtils::PureFunctionCheckStatus
check_status = ObResolverUtils::DISABLE_CHECK,
ObIArray<share::schema::ObColumnSchemaV2*> *resolved_cols = NULL);
static int build_generated_column_expr(const common::ObString &expr_str,
ObRawExprFactory &expr_factory,
const ObSQLSessionInfo &session_info,
uint64_t table_id,
const share::schema::ObTableSchema &table_schema,
const share::schema::ObColumnSchemaV2 &gen_col_schema,
ObRawExpr *&expr,
const bool sequence_allowed,
ObDMLResolver *dml_resolver,
const ObSchemaChecker *schema_checker = NULL,
const ObResolverUtils::PureFunctionCheckStatus
check_status = ObResolverUtils::DISABLE_CHECK);
static int check_generated_column_expr_str(const common::ObString &expr_str,
const ObSQLSessionInfo &session_info,
const share::schema::ObTableSchema &table_schema);
static int build_seq_nextval_expr(ObRawExpr *&expr,
const ObSQLSessionInfo *session_info,
ObRawExprFactory *expr_factory,
const ObQualifiedName &q_name,
uint64_t seq_id,
ObDMLStmt *stmt);
// build oracle sequence_object.currval, sequence_object.nextval expr
static int build_seq_nextval_expr(ObRawExpr *&expr,
const ObSQLSessionInfo *session_info,
ObRawExprFactory *expr_factory,
const ObString &database_name,
const ObString &tbl_name,
const ObString &col_name,
uint64_t seq_id,
ObDMLStmt *stmt);
static int resolve_sequence_object(const ObQualifiedName &q_name,
ObDMLResolver *dml_resolver,
const ObSQLSessionInfo *session_info,
ObRawExprFactory *expr_factory,
ObSequenceNamespaceChecker &sequence_namespace_checker,
ObRawExpr *&real_ref_expr,
bool is_generated_column);
static int build_pad_expr_recursively(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo &session,
const share::schema::ObTableSchema &table_schema,
const share::schema::ObColumnSchemaV2 &gen_col_schema,
ObRawExpr *&expr);
static int build_rls_predicate_expr(const common::ObString &expr_str,
ObRawExprFactory &expr_factory,
const ObSQLSessionInfo &session_info,
common::ObIArray<ObQualifiedName> &columns,
ObRawExpr *&expr);
static int build_raw_expr(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo &session_info,
const ParseNode &node,
ObRawExpr *&expr,
common::ObIArray<ObQualifiedName> &columns,
common::ObIArray<ObVarInfo> &sys_vars,
common::ObIArray<ObAggFunRawExpr*> &aggr_exprs,
common::ObIArray<ObWinFunRawExpr*> &win_exprs,
common::ObIArray<ObSubQueryInfo> &sub_query_info,
common::ObIArray<ObUDFInfo> &udf_info,
common::ObIArray<ObOpRawExpr*> &op_exprs,
bool is_prepare_protocol = false);
static int build_raw_expr(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo &session_info,
ObSchemaChecker *schema_checker,
pl::ObPLBlockNS *ns,
ObStmtScope current_scope,
ObStmt *stmt,
const ParamStore *param_list,
ExternalParams *external_param_info,
const ParseNode &node,
ObRawExpr *&expr,
common::ObIArray<ObQualifiedName> &columns,
common::ObIArray<ObVarInfo> &sys_vars,
common::ObIArray<ObAggFunRawExpr*> &aggr_exprs,
common::ObIArray<ObWinFunRawExpr*> &win_exprs,
common::ObIArray<ObSubQueryInfo> &sub_query_info,
common::ObIArray<ObUDFInfo> &udf_info,
common::ObIArray<ObOpRawExpr*> &op_exprs,
bool is_prepare_protocol/*= false*/,
TgTimingEvent tg_timing_event = TgTimingEvent::TG_TIMING_EVENT_INVALID);
static bool is_same_raw_expr(const ObRawExpr *src, const ObRawExpr *dst);
/// replace all `from' to `to' in the raw_expr
static int replace_all_ref_column(ObRawExpr *&raw_expr, const common::ObIArray<ObRawExpr *> &exprs, int64_t& offset);
// if %expr_factory is not NULL, will deep copy %to expr. default behavior is shallow copy
// if except_exprs is not NULL, will skip the expr in except_exprs
static int replace_ref_column(ObRawExpr *&raw_expr,
ObRawExpr *from,
ObRawExpr *to,
const ObIArray<ObRawExpr*> *except_exprs = NULL);
static int replace_ref_column(ObRawExpr *&raw_expr,
ObIArray<ObRawExpr *> &from,
ObIArray<ObRawExpr *> &to,
const ObIArray<ObRawExpr*> *except_exprs = NULL);
static int replace_level_column(ObRawExpr *&raw_expr, ObRawExpr *to, bool &replaced);
static int replace_ref_column(common::ObIArray<ObRawExpr *> &exprs,
ObRawExpr *from,
ObRawExpr *to,
const ObIArray<ObRawExpr*> *except_exprs = NULL);
static int replace_ref_column(common::ObIArray<ObRawExpr *> &exprs,
ObIArray<ObRawExpr *> &from,
ObIArray<ObRawExpr *> &to,
const ObIArray<ObRawExpr*> *except_exprs = NULL);
static int contain_virtual_generated_column(ObRawExpr *&expr,
bool &is_contain_vir_gen_column);
static bool is_all_column_exprs(const common::ObIArray<ObRawExpr*> &exprs);
static int extract_set_op_exprs(const ObRawExpr *raw_expr,
common::ObIArray<ObRawExpr*> &set_op_exprs);
static int extract_var_assign_exprs(const ObRawExpr *raw_expr,
common::ObIArray<ObRawExpr*> &assign_exprs);
static int extract_set_op_exprs(const ObIArray<ObRawExpr*> &exprs,
common::ObIArray<ObRawExpr*> &set_op_exprs);
/// extract column exprs from the raw expr
static int extract_column_exprs(const ObRawExpr *raw_expr,
common::ObIArray<ObRawExpr*> &column_exprs,
bool need_pseudo_column = false);
static int extract_column_exprs(const common::ObIArray<ObRawExpr*> &exprs,
common::ObIArray<ObRawExpr *> &column_exprs,
bool need_pseudo_column = false);
static int extract_column_exprs(const ObRawExpr *raw_expr,
int64_t table_id,
common::ObIArray<ObRawExpr*> &column_exprs);
static int extract_column_exprs(const common::ObIArray<ObRawExpr*> &exprs,
int64_t table_id,
common::ObIArray<ObRawExpr *> &column_exprs);
// no need to add cast.
static int extract_column_exprs(const ObRawExpr *expr,
ObIArray<const ObRawExpr*> &column_exprs);
static int extract_column_exprs(ObRawExpr* expr,
ObRelIds &rel_ids,
ObIArray<ObRawExpr*> &column_exprs);
static int extract_column_exprs(ObIArray<ObRawExpr*> &exprs,
ObRelIds &rel_ids,
ObIArray<ObRawExpr*> &column_exprs);
static int extract_contain_exprs(ObRawExpr *raw_expr,
const common::ObIArray<ObRawExpr*> &src_exprs,
common::ObIArray<ObRawExpr *> &contain_exprs);
static int mark_column_explicited_reference(ObRawExpr &expr);
static int extract_column_ids(const ObIArray<ObRawExpr*> &exprs, common::ObIArray<uint64_t> &column_ids);
static int extract_column_ids(const ObRawExpr *raw_expr, common::ObIArray<uint64_t> &column_ids);
static int extract_table_ids(const ObRawExpr *raw_expr, common::ObIArray<uint64_t> &table_ids);
static int extract_table_ids_from_exprs(const common::ObIArray<ObRawExpr *> &exprs,
common::ObIArray<uint64_t> &table_ids);
static int extract_param_idxs(const ObRawExpr *expr, common::ObIArray<int64_t> ¶m_idxs);
static int extract_col_aggr_exprs(ObIArray<ObRawExpr*> &exprs,
ObIArray<ObRawExpr*> &column_or_aggr_exprs);
static int extract_col_aggr_exprs(ObRawExpr* expr,
ObIArray<ObRawExpr*> &column_or_aggr_exprs);
static int extract_col_aggr_winfunc_exprs(ObIArray<ObRawExpr*> &exprs,
ObIArray<ObRawExpr*> &column_aggr_winfunc_exprs);
static int extract_col_aggr_winfunc_exprs(ObRawExpr* expr,
ObIArray<ObRawExpr*> &column_aggr_winfunc_exprs);
static int find_alias_expr(ObRawExpr *expr, ObAliasRefRawExpr *&alias_expr);
static int find_flag(const ObRawExpr *expr, ObExprInfoFlag flag, bool &is_found);
static int find_flag_rec(const ObRawExpr *expr, ObExprInfoFlag flag, bool &is_found);
// try add cast expr above %expr , set %dst_expr to &expr if no cast added.
static int try_add_cast_expr_above(ObRawExprFactory *expr_factory,
const ObSQLSessionInfo *session,
ObRawExpr &src_expr,
const ObExprResType &dst_type,
ObRawExpr *&new_expr);
static int try_add_cast_expr_above(ObRawExprFactory *expr_factory,
const ObSQLSessionInfo *session,
ObRawExpr &expr,
const ObExprResType &dst_type,
const ObCastMode &cm,
ObRawExpr *&new_expr);
static int implict_cast_pl_udt_to_sql_udt(ObRawExprFactory *expr_factory,
const ObSQLSessionInfo *session,
ObRawExpr* &real_ref_expr);
static int implict_cast_sql_udt_to_pl_udt(ObRawExprFactory *expr_factory,
const ObSQLSessionInfo *session,
ObRawExpr* &real_ref_expr);
// new engine: may create more cast exprs to handle non-system-collation string.
// e.g.: utf16->number: utf16->utf8->number (two cast expr)
// utf8_bin->number: utf8->number (just one cat expr)
// if %use_def_cm is not true, %cm will be set as cast mode for cast exprs.
// NOTE: IS_INNER_ADDED_EXPR flag will be set.
static int create_cast_expr(ObRawExprFactory &expr_factory,
ObRawExpr *src_expr,
const ObExprResType &dst_type,
ObSysFunRawExpr *&func_expr,
const ObSQLSessionInfo *session_info,
bool use_def_cm = true,
ObCastMode cm = CM_NONE);
static void need_extra_cast(const ObExprResType &src_type,
const ObExprResType &dst_type,
bool &need_extra_cast_for_src_type,
bool &need_extra_cast_for_dst_type);
static int setup_extra_cast_utf8_type(const ObExprResType &type,
ObExprResType &utf8_type);
static int erase_inner_added_exprs(ObRawExpr *src_expr, ObRawExpr *&out_expr);
// erase implicit cast which added for operand casting.
static int erase_operand_implicit_cast(ObRawExpr *src, ObRawExpr *&out);
static const ObRawExpr *skip_inner_added_expr(const ObRawExpr *expr);
static ObRawExpr *skip_implicit_cast(ObRawExpr *e);
static ObRawExpr *skip_inner_added_expr(ObRawExpr *expr);
static const ObColumnRefRawExpr *get_column_ref_expr_recursively(const ObRawExpr *expr);
static ObRawExpr *get_sql_udt_type_expr_recursively(ObRawExpr *expr);
static int create_to_type_expr(ObRawExprFactory &expr_factory,
ObRawExpr *src_expr,
const common::ObObjType &dst_type,
ObSysFunRawExpr *&to_type,
ObSQLSessionInfo *session_info);
static int create_substr_expr(ObRawExprFactory &expr_factory,
ObSQLSessionInfo *session_info,
ObRawExpr *first_expr,
ObRawExpr *second_expr,
ObRawExpr *third_expr,
ObSysFunRawExpr *&out_expr);
static int create_instr_expr(ObRawExprFactory &expr_factory,
ObSQLSessionInfo *session_info,
ObRawExpr *first_expr,
ObRawExpr *second_expr,
ObRawExpr *third_expr,
ObRawExpr *fourth_expr,
ObSysFunRawExpr *&out_expr);
static int create_concat_expr(ObRawExprFactory &expr_factory,
ObSQLSessionInfo *session_info,
ObRawExpr *first_expr,
ObRawExpr *second_expr,
ObOpRawExpr *&out_expr);
static int create_prefix_pattern_expr(ObRawExprFactory &expr_factory,
ObSQLSessionInfo *session_info,
ObRawExpr *first_expr,
ObRawExpr *second_expr,
ObRawExpr *third_expr,
ObSysFunRawExpr *&out_expr);
static int create_type_to_str_expr(ObRawExprFactory &expr_factory,
ObRawExpr *src_expr,
ObSysFunRawExpr *&out_expr,
ObSQLSessionInfo *session_info,
bool is_type_to_str,
ObObjType dst_type = ObMaxType);
static int wrap_enum_set_for_stmt(ObRawExprFactory &expr_factory,
ObSelectStmt *stmt,
ObSQLSessionInfo *session_info);
static int get_exec_param_expr(ObRawExprFactory &expr_factory,
ObQueryRefRawExpr *query_ref,
ObRawExpr *correlated_expr,
ObRawExpr *&exec_param);
static int create_new_exec_param(ObQueryCtx *query_ctx,
ObRawExprFactory &expr_factory,
ObRawExpr *&expr,
bool is_onetime = false);
static int create_exec_param_expr(ObQueryCtx *query_ctx,
ObRawExprFactory &expr_factory,
ObRawExpr *&src_expr,
std::pair<int64_t, ObRawExpr*> &init_expr);
static int create_param_expr(ObRawExprFactory &expr_factory, int64_t param_idx, ObRawExpr *&expr);
static int build_trim_expr(const share::schema::ObColumnSchemaV2 *column_schema,
ObRawExprFactory &expr_factory,
const ObSQLSessionInfo *session_info,
ObRawExpr *&expr);
static bool need_column_conv(const ColumnItem &column, ObRawExpr &expr);
static int build_pad_expr(ObRawExprFactory &expr_factory,
bool is_char,
const share::schema::ObColumnSchemaV2 *column_schema,
ObRawExpr *&expr,
const sql::ObSQLSessionInfo *session_info);
static bool need_column_conv(const ObExprResType &expected_type, const ObRawExpr &expr);
// 此方法请谨慎使用,会丢失enum类型的 enum_set_values
static int build_column_conv_expr(ObRawExprFactory &expr_factory,
const share::schema::ObColumnSchemaV2 *column_schema,
ObRawExpr *&expr,
const sql::ObSQLSessionInfo *session_info);
static int build_column_conv_expr(ObRawExprFactory &expr_factory,
common::ObIAllocator &allocator,
const ObColumnRefRawExpr &col_expr,
ObRawExpr *&expr,
const ObSQLSessionInfo *session_info,
bool is_generated_column = false);
static int build_column_conv_expr(const ObSQLSessionInfo *session_info,
ObRawExprFactory &expr_factory,
const common::ObObjType &type,
const common::ObCollationType &collation,
const int64_t &accuracy,
const bool &is_nullable,
const common::ObString *column_conv_info,
const common::ObIArray<common::ObString> *type_infos,
ObRawExpr *&expr,
bool is_in_pl = false,
bool is_generated_column = false);
static int build_var_int_expr(ObRawExprFactory &expr_factory,
ObConstRawExpr *&expr);
static int build_default_expr(ObRawExprFactory &expr_factory,
const common::ObObjType &type,
const common::ObCollationType &collation,
const int64_t &accuracy,
ObRawExpr *&expr);
static int build_const_int_expr(ObRawExprFactory &expr_factory,
common::ObObjType type,
int64_t int_value,
ObConstRawExpr *&expr);
static int build_const_uint_expr(ObRawExprFactory &expr_factory,
common::ObObjType type,
uint64_t uint_value,
ObConstRawExpr *&expr);
static int build_const_float_expr(ObRawExprFactory &expr_factory,
common::ObObjType type,
float value,
ObConstRawExpr *&expr);
static int build_const_double_expr(ObRawExprFactory &expr_factory,
common::ObObjType type,
double value,
ObConstRawExpr *&expr);
static int build_const_datetime_expr(ObRawExprFactory &expr_factory,
int64_t int_value,
ObConstRawExpr *&expr);
static int build_const_date_expr(ObRawExprFactory &expr_factory,
int64_t int_value,
ObConstRawExpr *&expr);
static int build_const_ym_expr(ObRawExprFactory &expr_factory,
common::ObObjType type,
const ObObj &obj,
ObConstRawExpr *&expr);
static int build_const_ds_expr(ObRawExprFactory &expr_factory,
common::ObObjType type,
ObIntervalDSValue &ds_value,
ObConstRawExpr *&expr);
static int build_const_timestampnano_expr(ObRawExprFactory &expr_factory,
ObObjType type,
ObOTimestampData &value,
ObConstRawExpr *&expr);
static int build_const_number_expr(ObRawExprFactory &expr_factory,
ObObjType type,
number::ObNumber value,
ObConstRawExpr *&expr);
static int build_const_obj_expr(ObRawExprFactory &expr_factory,
const ObObj &obj,
ObConstRawExpr *&expr);
static int build_mul_expr(ObRawExprFactory &raw_expr_factory,
ObRawExpr *expr1,
ObRawExpr *expr2,
ObOpRawExpr *&expr_out);
static int build_div_expr(ObRawExprFactory &raw_expr_factory,
ObRawExpr *expr1,
ObRawExpr *expr2,
ObOpRawExpr *&expr_out);
static int build_add_all_expr(ObRawExprFactory &raw_expr_factory,
ObRawExpr *expr1,
ObRawExpr *expr2,
ObRawExpr *expr3,
ObRawExpr *expr4,
ObOpRawExpr *&sum_expr);
static int build_second_expr_from_interval_ds(ObRawExprFactory &raw_expr_factory,
ObRawExpr *interval_ds_expr,
ObOpRawExpr *&second_expr);
static int build_month_expr_from_interval_ym(ObRawExprFactory &raw_expr_factory,
ObRawExpr *interval_ym_expr,
ObOpRawExpr *&month_expr);
static int build_datepart_to_second_expr(ObRawExprFactory &raw_expr_factory,
ObRawExpr *interval_ds_expr,
int datapart,
int n,
ObRawExpr *&expr_out);
static int build_interval_ym_diff_exprs(ObRawExprFactory &raw_expr_factory,
ObObj &const_val,
const ObObj &transition_val,
const ObObj &interval_val,
ObRawExpr *&diff_1_out,
ObRawExpr *&diff_2_out,
ObConstRawExpr *&transition_expr,
ObConstRawExpr *&interval_expr);
static int build_interval_ds_diff_exprs(ObRawExprFactory &raw_expr_factory,
ObObj &const_val,
const ObObj &transition_val,
const ObObj &interval_val,
ObRawExpr *&diff_1_out,
ObRawExpr *&diff_2_out,
ObConstRawExpr *&transition_expr,
ObConstRawExpr *&interval_expr);
static int build_high_bound_raw_expr(ObRawExprFactory &raw_expr_factory,
ObSQLSessionInfo* session,
ObObj &const_val,
const ObObj &transition_val,
const ObObj &interval_val,
ObRawExpr *&result_expr_out,
ObRawExpr *&n_part_expr);
static int build_common_diff_exprs(ObRawExprFactory &raw_expr_factory,
ObObj &const_val,
const ObObj &transition_val,
const ObObj &interval_val,
ObRawExpr *&diff_1_out,
ObRawExpr *&diff_2_out,
ObConstRawExpr *&transition_expr,
ObConstRawExpr *&interval_expr);
static int build_sign_expr(ObRawExprFactory &expr_factory,
ObRawExpr *param,
ObRawExpr *&sign_expr);
static int build_less_than_expr(ObRawExprFactory &expr_factory,
ObRawExpr *left,
ObRawExpr *right,
ObOpRawExpr *&less_than_expr);
static int build_variable_expr(ObRawExprFactory &expr_factory,
const ObExprResType &result_type,
ObVarRawExpr *&expr);
static int build_op_pseudo_column_expr(ObRawExprFactory &expr_factory,
const ObItemType expr_type,
const char *expr_name,
const ObExprResType &res_type,
ObOpPseudoColumnRawExpr *&expr);
static int build_const_bool_expr(ObRawExprFactory *expr_factory,
ObRawExpr *&expr,
bool b_value);
static int build_const_string_expr(ObRawExprFactory &expr_factory,
common::ObObjType type,
const common::ObString &string_value,
common::ObCollationType cs_type,
ObConstRawExpr *&expr);
static int build_null_expr(ObRawExprFactory &expr_factory, ObRawExpr *&expr);
static int build_nvl_expr(ObRawExprFactory &expr_factory, const ColumnItem *column_item, ObRawExpr *&expr);
static int build_nvl_expr(ObRawExprFactory &expr_factory, const ColumnItem *column_item, ObRawExpr *&expr1, ObRawExpr *&expr2);
static int build_lnnvl_expr(ObRawExprFactory &expr_factory,
ObRawExpr *param_expr,
ObRawExpr *&lnnvl_expr);
static int build_equal_last_insert_id_expr(ObRawExprFactory &expr_factory,
ObRawExpr *&expr,
ObSQLSessionInfo *session);
static int build_get_user_var(ObRawExprFactory &expr_factory,
const common::ObString &var_name,
ObRawExpr *&expr,
const ObSQLSessionInfo *session_info = NULL,
ObQueryCtx *query_ctx = NULL,
common::ObIArray<ObUserVarIdentRawExpr*> *user_var_exprs = NULL);
static int build_get_sys_var(ObRawExprFactory &expr_factory,
const common::ObString &var_name,
share::ObSetVar::SetScopeType var_scope,
ObRawExpr *&expr,
const ObSQLSessionInfo *session_info = NULL);
static int get_package_var_ids(ObRawExpr *expr, uint64_t &package_id, int64_t &var_idx);
static int set_package_var_ids(ObRawExpr *expr, uint64_t package_id, int64_t var_idx);
static int build_get_package_var(ObRawExprFactory &expr_factory,
share::schema::ObSchemaGetterGuard &schema_guard,
uint64_t package_id,
int64_t var_idx,
ObExprResType *result_type,
ObRawExpr *&expr,
const ObSQLSessionInfo *session_info);
static int build_calc_part_id_expr(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo &session,
uint64_t ref_table_id,
share::schema::ObPartitionLevel part_level,
ObRawExpr *part_expr,
ObRawExpr *subpart_expr,
ObRawExpr *&expr);
static int build_calc_tablet_id_expr(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo &session,
uint64_t ref_table_id,
ObPartitionLevel part_level,
ObRawExpr *part_expr,
ObRawExpr *subpart_expr,
ObRawExpr *&expr);
static int build_calc_partition_tablet_id_expr(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo &session,
uint64_t ref_table_id,
ObPartitionLevel part_level,
ObRawExpr *part_expr,
ObRawExpr *subpart_expr,
ObRawExpr *&expr);
static int build_get_subprogram_var(ObRawExprFactory &expr_factory,
uint64_t package_id,
uint64_t routine_id,
int64_t var_idx,
const ObExprResType *result_type,
ObRawExpr *&expr,
const ObSQLSessionInfo *session_info);
static int build_exists_expr(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo *session_info,
ObItemType type,
ObRawExpr *param_expr,
ObRawExpr *&exists_expr);
static int build_ora_decode_expr(ObRawExprFactory *expr_factory,
const ObSQLSessionInfo &session_info,
ObRawExpr *&expr,
ObIArray<ObRawExpr *> ¶m_exprs);
template <typename T>
static bool find_expr(const common::ObIArray<T> &exprs, const ObRawExpr* expr);
template <typename T>
static int64_t get_expr_idx(const common::ObIArray<T> &exprs, const ObRawExpr* expr);
static int create_equal_expr(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo *session_info,
const ObRawExpr *val_ref,
const ObRawExpr *col_ref,
ObRawExpr *&expr);
static int create_double_op_expr(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo *session_info,
ObItemType expr_type,
ObRawExpr *&add_expr,
const ObRawExpr *left_expr,
const ObRawExpr *right_expr);
static int make_set_op_expr(ObRawExprFactory &expr_factory,
int64_t idx,
ObItemType set_op_type,
const ObExprResType &res_type,
ObSQLSessionInfo *session_info,
ObRawExpr *&out_expr);
static int merge_variables(const common::ObIArray<ObVarInfo> &src_vars, common::ObIArray<ObVarInfo> &dst_vars);
static int get_item_count(const ObRawExpr *expr, int64_t &count);
static int get_array_param_index(const ObRawExpr *expr, int64_t ¶m_index);
static int build_column_expr(ObRawExprFactory &expr_factory,
const share::schema::ObColumnSchemaV2 &column_schema,
ObColumnRefRawExpr *&column_expr);
static bool is_same_column_ref(const ObRawExpr *column_ref1, const ObRawExpr *column_ref2);
static int build_alias_column_expr(ObRawExprFactory &expr_factory, ObRawExpr *ref_expr, int32_t alias_level, ObAliasRefRawExpr *&alias_expr);
static int build_query_output_ref(ObRawExprFactory &expr_factory,
ObQueryRefRawExpr *query_ref,
int64_t project_index,
ObAliasRefRawExpr *&alias_expr);
static int init_column_expr(const share::schema::ObColumnSchemaV2 &column_schema, ObColumnRefRawExpr &column_expr);
static ObCollationLevel get_column_collation_level(const common::ObObjType &type);
/* 计算基本列的flag */
static uint32_t calc_column_result_flag(const share::schema::ObColumnSchemaV2 &column_schema);
static int expr_is_order_consistent(const ObRawExpr *from, const ObRawExpr *to, bool &is_consistent);
static int is_expr_comparable(const ObRawExpr *expr, bool &can_be);
static int exprs_contain_subquery(const common::ObIArray<ObRawExpr*> &exprs, bool &cnt_subquery);
static int function_alias(ObRawExprFactory &expr_factory, ObSysFunRawExpr *&expr);
//extract from const value
static int extract_int_value(const ObRawExpr *expr, int64_t &val);
//used for enum set type
static int need_wrap_to_string(common::ObObjType param_type, common::ObObjType calc_type,
const bool is_same_type_need, bool &need_wrap);
static bool contain_id(const common::ObIArray<uint64_t> &ids, const uint64_t target);
static int clear_exprs_flag(const common::ObIArray<ObRawExpr*> &exprs, ObExprInfoFlag flag);
static int resolve_udf_common_info(const ObString &db_name,
const ObString &package_name,
int64_t udf_id,
int64_t package_id,
const ObIArray<int64_t> &subprogram_path,
int64_t udf_schema_version,
int64_t pkg_schema_version,
bool is_deterministic,
bool is_parallel_enable,
bool is_pkg_body_udf,
bool is_pl_agg,
int64_t type_id,
ObUDFInfo &udf_info);
static int resolve_udf_param_types(const share::schema::ObIRoutineInfo* func_info,
share::schema::ObSchemaGetterGuard &schema_guard,
sql::ObSQLSessionInfo &session_info,
common::ObIAllocator &allocator,
common::ObMySQLProxy &sql_proxy,
ObUDFInfo &udf_info);
static int resolve_udf_param_exprs(ObResolverParams ¶ms,
const share::schema::ObIRoutineInfo *func_info,
ObUDFInfo &udf_info);
static int resolve_udf_param_exprs(const share::schema::ObIRoutineInfo* func_info,
pl::ObPLBlockNS &secondary_namespace_,
ObSchemaChecker &schema_checker,
sql::ObSQLSessionInfo &session_info,
ObIAllocator &allocator,
bool is_prepare_protocol,
sql::ObRawExprFactory &expr_factory,
common::ObMySQLProxy &sql_proxy,
ExternalParams *extern_param_info,
ObUDFInfo &udf_info);
static int rebuild_expr_params(ObUDFInfo &udf_info,
sql::ObRawExprFactory *expr_factory,
common::ObIArray<sql::ObRawExpr*> &expr_params);
static int resolve_udf_info(common::ObIAllocator &allocator,
sql::ObRawExprFactory &expr_factory,
sql::ObSQLSessionInfo &session_info,
share::schema::ObSchemaGetterGuard &schema_guard,
ObUDFInfo &udf_info);
//判断expr里是否包含字符串前缀的表达式
static bool has_prefix_str_expr(const ObRawExpr &expr,
const ObColumnRefRawExpr &orig_column_expr,
const ObRawExpr *&substr_expr);
static int build_like_expr(ObRawExprFactory &expr_factory,
ObSQLSessionInfo *session_info,
ObRawExpr *text_expr,
ObRawExpr *pattern_expr,
ObRawExpr *escape_expr,
ObOpRawExpr *&like_expr);
static int resolve_op_expr_for_oracle_implicit_cast(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo *session_info,
ObOpRawExpr* &b_expr);
static int resolve_op_expr_implicit_cast(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo *session_info,
ObItemType op_type,
ObRawExpr* &sub_expr1,
ObRawExpr* &sub_expr2);
static inline int resolve_op_expr_add_implicit_cast(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo *session_info,
ObRawExpr *src_expr,
const ObExprResType &dst_type,
ObSysFunRawExpr *&func_expr);
static int resolve_op_exprs_for_oracle_implicit_cast(ObRawExprFactory &expr_factory,
const ObSQLSessionInfo *session_info,
common::ObIArray<ObOpRawExpr*> &op_exprs);
static int check_composite_cast(ObRawExpr *&expr, ObSchemaChecker &schema_checker);
static int add_cast_to_multiset(ObRawExpr *&expr);
// 对parent的所有子节点一次调用try_create_bool_expr,给每个前面子节点按需增加bool expr
static int try_add_bool_expr(ObOpRawExpr *parent, ObRawExprFactory &expr_factory);
// 针对case表达式的overload方法. 会给case expr的所有when expr前面按需增加bool expr
static int try_add_bool_expr(ObCaseOpRawExpr *parent, ObRawExprFactory &expr_factory);
// 判断src_epxr前面是否需要bool expr,如果需要则创建bool expr并加到src_expr前面
// 如果不需要则out_expr被赋值为原本的src_expr
static int try_create_bool_expr(ObRawExpr *src_expr, ObRawExpr *&out_expr,
ObRawExprFactory &expr_factory);
// 根据表达式类型判断是否需要增加布尔表达式
// 因为有些表达式的返回结果就是布尔语义的,这些表达式前面就不用再增加布尔表达式
static int check_need_bool_expr(const ObRawExpr *expr, bool &need_bool_expr);
static int check_is_bool_expr(const ObRawExpr *expr, bool &is_bool_expr);
// parent_raw_expr -> child_raw_expr加入隐式cast表达式后,变为:
// parent_raw_expr -> cast_raw_expr -> child_raw_expr
// 该函数的作用是为了获得child_raw_expr,如果有多个cast_raw_expr,会迭代循环,一直循环到
// 第一个非隐式cast的表达式并返回
// deduce type阶段会调用它来忽略隐式cast expr
static int get_real_expr_without_cast(const ObRawExpr *expr,
const ObRawExpr *&out_expr);
// build remove_const for const expr to remove const attribute.
static int build_remove_const_expr(ObRawExprFactory &factory,
ObSQLSessionInfo &session_info,
ObRawExpr *arg,
ObRawExpr *&out);
static int build_wrapper_inner_expr(ObRawExprFactory &factory,
ObSQLSessionInfo &session_info,
ObRawExpr *arg,
ObRawExpr *&out);
static int build_dup_data_expr(ObRawExprFactory &factory,
ObRawExpr *param,
ObRawExpr *&new_param);
static int build_inner_aggr_code_expr(ObRawExprFactory &factory,
const ObSQLSessionInfo &session_info,
ObRawExpr *&out);
static int build_inner_wf_aggr_status_expr(ObRawExprFactory &factory,
const ObSQLSessionInfo &session_info,
ObOpPseudoColumnRawExpr *&out);
static int build_pseudo_rollup_id(ObRawExprFactory &factory,
const ObSQLSessionInfo &session_info,
ObRawExpr *&out);
static int build_pseudo_random(ObRawExprFactory &factory,
const ObSQLSessionInfo &session_info,
ObRawExpr *&out);
static bool is_pseudo_column_like_expr(const ObRawExpr &expr);
static bool is_sharable_expr(const ObRawExpr &expr);
static int check_need_cast_expr(const ObExprResType &src_res_type,
const ObExprResType &dst_res_type,
bool &need_cast,
bool &ignore_dup_cast_error);
static int build_add_expr(ObRawExprFactory &expr_factory,
ObRawExpr *param_expr1,
ObRawExpr *param_expr2,
ObOpRawExpr *&add_expr);
static int build_minus_expr(ObRawExprFactory &expr_factory,
ObRawExpr *param_expr1,
ObRawExpr *param_expr2,
ObOpRawExpr *&add_expr);
static int build_date_add_expr(ObRawExprFactory &expr_factory,
ObRawExpr *param_expr1,
ObRawExpr *param_expr2,
ObRawExpr *param_expr3,
ObSysFunRawExpr *&date_add_expr);
static int build_date_sub_expr(ObRawExprFactory &expr_factory,
ObRawExpr *param_expr1,
ObRawExpr *param_expr2,
ObRawExpr *param_expr3,
ObSysFunRawExpr *&date_sub_expr);
static int build_common_binary_op_expr(ObRawExprFactory &expr_factory,
const ObItemType expect_op_type,
ObRawExpr *param_expr1,
ObRawExpr *param_expr2,
ObRawExpr *&expr);
static int build_case_when_expr(ObRawExprFactory &expr_factory,
ObRawExpr *when_expr,
ObRawExpr *then_expr,
ObRawExpr *default_expr,
ObRawExpr *&case_when_expr);
static int build_is_not_expr(ObRawExprFactory &expr_factory,
ObRawExpr *param_expr1,
ObRawExpr *param_expr2,
ObRawExpr *&is_not_expr);
static int build_is_not_null_expr(ObRawExprFactory &expr_factory,
ObRawExpr *param_expr,
bool is_not_null,
ObRawExpr *&is_not_null_expr);
static int process_window_complex_agg_expr(ObRawExprFactory &expr_factory,
const ObItemType func_type,
ObWinFunRawExpr *win_func,
ObRawExpr *&agg_expr,
common::ObIArray<ObWinFunRawExpr*> *win_exprs);
static int build_common_aggr_expr(ObRawExprFactory &expr_factory,
ObSQLSessionInfo *session_info,
const ObItemType expect_op_type,
ObRawExpr *param_expr,
ObAggFunRawExpr *&aggr_expr);
//专用于limit_expr/offset_expr中,用于构造case when limit_expr < 0 then 0 else limit_expr end
static int build_case_when_expr_for_limit(ObRawExprFactory &expr_factory,
ObRawExpr *limit_expr,
ObRawExpr *&case_when_expr);
static int build_not_expr(ObRawExprFactory &expr_factory,
ObRawExpr *expr,
ObRawExpr* ¬_expr);
static int build_or_exprs(ObRawExprFactory &expr_factory,