forked from oceanbase/oceanbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathob_sql_utils.cpp
More file actions
5245 lines (5022 loc) · 205 KB
/
Copy pathob_sql_utils.cpp
File metadata and controls
5245 lines (5022 loc) · 205 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.
*/
#define USING_LOG_PREFIX SQL_OPT
#include "sql/ob_sql_utils.h"
#include "sql/ob_sql.h"
#include <sys/time.h>
#include <openssl/md5.h>
#include "lib/string/ob_sql_string.h"
#include "lib/timezone/ob_time_convert.h"
#include "common/sql_mode/ob_sql_mode_utils.h"
#include "share/ob_i_tablet_scan.h"
#include "sql/parser/ob_parser.h"
#include "sql/parser/parse_malloc.h"
#include "sql/parser/parse_node.h"
#include "sql/code_generator/ob_expr_generator_impl.h"
#include "sql/resolver/expr/ob_raw_expr_util.h"
#include "sql/resolver/ob_resolver_utils.h"
#include "sql/resolver/dml/ob_sql_hint.h"
#include "sql/resolver/ob_stmt_type.h"
#include "sql/engine/ob_exec_context.h"
#include "sql/engine/expr/ob_expr_func_part_hash.h"
#include "sql/engine/expr/ob_expr_column_conv.h"
#include "sql/rewrite/ob_query_range.h"
#include "sql/session/ob_basic_session_info.h"
#include "sql/plan_cache/ob_sql_parameterization.h"
#include "sql/ob_select_stmt_printer.h"
#include "sql/ob_insert_all_stmt_printer.h"
#include "sql/ob_insert_stmt_printer.h"
#include "sql/ob_update_stmt_printer.h"
#include "sql/ob_delete_stmt_printer.h"
#include "sql/ob_merge_stmt_printer.h"
#include "sql/executor/ob_task_executor_ctx.h"
#include "sql/optimizer/ob_route_policy.h"
#include "sql/rewrite/ob_transform_rule.h"
#include "sql/rewrite/ob_transform_utils.h"
#include "common/ob_smart_call.h"
#include "observer/omt/ob_tenant_timezone_mgr.h"
#include "share/schema/ob_schema_printer.h"
#include "share/ob_order_perserving_encoder.h"
#include "sql/resolver/expr/ob_raw_expr.h"
#include "storage/ob_locality_manager.h"
#include "lib/utility/ob_tracepoint.h"
#include "lib/charset/ob_charset.h"
#include "pl/ob_pl_user_type.h"
#include "sql/engine/expr/ob_expr_lob_utils.h"
#ifdef OB_BUILD_SPM
#include "sql/spm/ob_spm_controller.h"
#endif
#include "observer/omt/ob_tenant_srs.h"
#include "sql/executor/ob_maintain_dependency_info_task.h"
#include "sql/resolver/ddl/ob_create_view_resolver.h"
extern "C" {
#include "sql/parser/ob_non_reserved_keywords.h"
}
using namespace oceanbase;
using namespace oceanbase::sql;
using namespace oceanbase::obmysql;
using namespace oceanbase::common;
using namespace oceanbase::share;
using namespace oceanbase::share::schema;
using namespace oceanbase::common::sqlclient;
ObSqlArrayExpandGuard::ObSqlArrayExpandGuard(ParamStore ¶ms, ObIAllocator &allocator)
: array_obj_list_(allocator),
ret_(OB_SUCCESS)
{
int &ret = ret_;
for (int64_t i = 0; OB_SUCC(ret) && i < params.count(); ++i) {
if (params.at(i).is_ext_sql_array()) {
int64_t param_addr = 0;
param_addr = params.at(i).get_ext();
const ObSqlArrayObj *array_param = reinterpret_cast<const ObSqlArrayObj*>(param_addr);
if (array_param->count_ > 0) {
ArrayObjPair array_pair(¶ms.at(i), params.at(i));
if (OB_FAIL(array_obj_list_.push_back(array_pair))) {
LOG_WARN("store array obj list failed", K(ret));
} else {
params.at(i) = array_param->data_[0];
}
}
}
}
}
ObSqlArrayExpandGuard::~ObSqlArrayExpandGuard()
{
common::ObList<ArrayObjPair, common::ObIAllocator>::iterator iter = array_obj_list_.begin();
for (; iter != array_obj_list_.end(); ++iter) {
*(iter->first) = iter->second;
}
}
int ObSQLUtils::check_enable_decimalint(const ObSQLSessionInfo *session, bool &enable_decimalint)
{
int ret = OB_SUCCESS;
enable_decimalint = false;
if (OB_ISNULL(session)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("session is null", K(ret));
} else {
enable_decimalint = (const_cast<ObSQLSessionInfo *>(session)->is_enable_decimal_int_type()
&& GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_3_0_0);
}
return ret;
}
bool ObSQLUtils::is_trans_commit_need_disconnect_err(int err)
{
bool bool_ret = true;
if (OB_SUCCESS == err
|| OB_TRANS_KILLED == err
|| OB_TRANS_CTX_NOT_EXIST == err
|| OB_TRANS_TIMEOUT == err
|| OB_TRANS_STMT_TIMEOUT == err
|| OB_TRANS_NEED_ROLLBACK == err
|| OB_TRANS_ROLLBACKED == err
|| OB_NOT_MASTER == err
|| OB_TRANS_IS_EXITING == err) {
bool_ret = false;
}
return bool_ret;
}
void ObSQLUtils::check_if_need_disconnect_after_end_trans(const int end_trans_err,
const bool is_rollback,
const bool is_explicit,
bool &is_need_disconnect)
{
// 1.对于commit操作(不管是隐式还是显式),失败的时候遇到事务模块目前没有明确指明的错误码,都采取断连接操作。
// 2.对于显式rollback操作,如果失败,由于客户端就算收到错误码也不知道怎么处理,因此统一都断连接。
// 3.对于隐式rollback操作,如果失败,这种情况是autocommit=1的情况,由于autocommit=1的分布式查询经常遇到rollback失败,
// 所以这种情况不断连接,如果这种情况下有特殊情况需要断连接,需要在外层调用implicit_end_trans之后自行加上断连接的逻辑。
is_need_disconnect = false;
if (is_rollback) {
// rollback
if (OB_UNLIKELY(OB_SUCCESS != end_trans_err && is_explicit)) {
// 显式rollback失败,要断连接
is_need_disconnect = true;
LOG_WARN_RET(end_trans_err, "fail to rollback explicitly, disconnect", K(end_trans_err));
} else {
// 隐式rollback(不管成功还是失败),或者显式rollback成功,不用断连接
is_need_disconnect = false;
}
} else {
// commit
if (OB_UNLIKELY(ObSQLUtils::is_trans_commit_need_disconnect_err(end_trans_err))) {
is_need_disconnect = true;
LOG_WARN_RET(end_trans_err, "fail to commit, and error number is unexpected, disconnect", K(end_trans_err), K(lbt()));
} else {
is_need_disconnect = false;
}
}
}
int ObSQLUtils::md5(const ObString &stmt, char *sql_id, int32_t len)
{
const int32_t MD5_LENGTH = 16;
int ret = OB_SUCCESS;
if (sql_id == NULL || len < 32) {
ret = OB_INVALID_ARGUMENT;
SQL_PC_LOG(WARN, "invalid args", KP(sql_id), K(len));
}
char md5_sum_buf[MD5_LENGTH];
ObString::obstr_size_t md5_sum_len = MD5_LENGTH;
if (OB_SUCC(ret)) {
unsigned char *res = MD5(reinterpret_cast<const unsigned char *>(stmt.ptr()),
stmt.length(),
reinterpret_cast<unsigned char *>(md5_sum_buf));
if (OB_ISNULL(res)) {
// MD5() in openssl always return an pointer not NULL, so we need not check return value.
// see:
// http://www.openssl.org/docs/crypto/md5.html#DESCRIPTION
// http://www.openssl.org/docs/crypto/md5.html#RETURN_VALUES
// Even so, we HAVE TO check it here. You know it.
ret = OB_ERR_UNEXPECTED;
LOG_WARN("md5 res null pointer", K(ret), K(res));
} else if (OB_FAIL(to_hex_cstr(md5_sum_buf, md5_sum_len, sql_id, len))) {
LOG_WARN("transform to hex str error", K(ret));
} else { }//do nothing
}
return ret;
}
int ObSQLUtils::calc_partition_ids(const ObIArray<ObNewRange*> &ranges,
const ObSqlExpression &partition_func,
const uint64_t part_num,
ObIArray<uint64_t> &partition_ids)
{
int ret = OB_SUCCESS;
ObSEArray<uint64_t, 16> par_ids; // for keeping the perhaps duplicate partition ids
ObNewRow calc_row;
ObExprCtx expr_ctx;
ObObj result;
ObArenaAllocator allocator(common::ObModIds::OB_SQL_EXPR_CALC);
expr_ctx.calc_buf_ = &allocator;
int64_t N = ranges.count();
for (int64_t i = 0; OB_SUCC(ret) && i < N; ++i) {
// calculate
ObNewRange *range = ranges.at(i);
if (OB_ISNULL(range)) {
ret = OB_ERR_UNEXPECTED;
SQL_EXE_LOG(WARN, "invalid argument", K(ret));
} else {
calc_row.reset();
result.reset();
int64_t result_par_id = 0;
// assuming all ranges are single-value
calc_row.cells_ = const_cast<ObObj*>(range->start_key_.get_obj_ptr());//FIXME 此处强转是否有问题?
calc_row.count_ = (range->start_key_.get_obj_cnt());
if (OB_FAIL(partition_func.calc(expr_ctx, calc_row, result))) {
SQL_EXE_LOG(WARN, "fail to calc hash expr", K(ret), K(calc_row));
} else if (OB_FAIL(result.get_int(result_par_id))) {
SQL_EXE_LOG(WARN, "fail to get int64 from result", K(ret), K(result));
} else if (OB_FAIL(par_ids.push_back(result_par_id % part_num))) {
SQL_EXE_LOG(WARN, "fail to push back partition id into array", K(ret));
}
}
}
// 最后将这些结果进行去重,即可得出最终的不重复的partition_id数组。
if (OB_SUCC(ret)) {
for (int64_t i = 0; OB_SUCC(ret) && i < par_ids.count(); ++i) {
bool duplicated = false;
for (int64_t j = 0; !duplicated && j < partition_ids.count(); ++j) {
if (par_ids.at(i) == partition_ids.at(j)) {
duplicated = true;
}
}
if (!duplicated) {
if (OB_FAIL(partition_ids.push_back(par_ids.at(i)))) {
SQL_EXE_LOG(WARN, "fail to push back partition id into array", K(ret));
}
}
}
}
return ret;
}
int ObSQLUtils::get_phy_plan_type(ObIArray<share::ObPartitionLocation> &part_location_set,
const ObAddr &my_address,
ObPhyPlanType &plan_type)
{
int ret = OB_SUCCESS;
bool is_same = true;
int64_t N = part_location_set.count();
if (0 == N) {
plan_type = OB_PHY_PLAN_LOCAL;
LOG_TRACE("no tables used, thus local plan");
} else {
ObReplicaLocation replica_first;
if (OB_FAIL(part_location_set.at(0).get_strong_leader(replica_first))) {
SQL_EXE_LOG(WARN, "failed to get leader replica location", K(ret));
} else {
SQL_EXE_LOG(DEBUG, "part_location_set first replica", K(ret), K(replica_first));
for (int64_t i = 1; OB_SUCC(ret) && true == is_same && i < N; ++i) {
ObReplicaLocation replica_location;
if (OB_FAIL(part_location_set.at(i).get_strong_leader(replica_location))) {
SQL_EXE_LOG(WARN, "failed to get leader replica location", K(ret));
} else {
is_same = is_same && (replica_location.server_ == replica_first.server_);
SQL_EXE_LOG(DEBUG, "part_location_set replica", K(ret), K(i), K(replica_location));
}
}
if (OB_SUCC(ret)) {
if (is_same) {
if (my_address == replica_first.server_) {
plan_type = OB_PHY_PLAN_LOCAL;
} else {
plan_type = OB_PHY_PLAN_REMOTE;
}
} else {
plan_type = OB_PHY_PLAN_DISTRIBUTED;
}
}
}
}
return ret;
}
int ObSQLUtils::has_outer_join_symbol(const ParseNode *node, bool &has)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(node)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpect null pointer", K(node), K(ret));
} else if (node->type_ == T_OP_ORACLE_OUTER_JOIN_SYMBOL) {
has = true;
}
for (int64_t i = 0 ; OB_SUCC(ret) && !has && i < node->num_child_; i++) {
if (NULL == node->children_[i]) {
//do nothing
} else if (OB_FAIL(SMART_CALL(has_outer_join_symbol(node->children_[i], has)))) {
LOG_WARN("check has_outer_join_symbol fail", K(ret));
}
}
return ret;
}
int ObSQLUtils::replace_questionmarks(ParseNode *tree,
const ParamStore ¶ms)
{
int ret = OB_SUCCESS;
bool is_stack_overflow = false;
if (OB_FAIL(check_stack_overflow(is_stack_overflow))) {
LOG_WARN("failed to check stack overflow", K(ret), K(is_stack_overflow));
} else if (is_stack_overflow) {
ret = OB_SIZE_OVERFLOW;
LOG_WARN("too deep recursive", K(ret), K(is_stack_overflow));
} else if (NULL != tree) {
// replace ? with given params
if (T_QUESTIONMARK == tree->type_) {
const ObObj ¶m = params.at(tree->value_);
switch (param.get_type()) {
case ObIntType:
tree->value_ = param.get_int();
tree->type_ = T_INT;
break;
case ObDateTimeType:
tree->value_ = param.get_datetime();
tree->type_ = T_DATETIME;
break;
case ObTimestampType:
tree->value_ = param.get_timestamp();
tree->type_ = T_TIMESTAMP;
break;
case ObDateType:
tree->value_ = param.get_date();
tree->type_ = T_DATE;
break;
case ObTimeType:
tree->value_ = param.get_time();
tree->type_ = T_TIME;
break;
case ObYearType:
tree->value_ = param.get_year();
tree->type_ = T_YEAR;
break;
case ObVarcharType:
tree->str_value_ = param.get_varchar().ptr();
tree->str_len_ = param.get_varchar().length();
tree->type_ = T_VARCHAR;
break;
case ObTinyIntType:
tree->value_ = param.get_bool();
tree->type_ = T_BOOL;
break;
case ObNumberType:
tree->str_value_ = param.get_number().format();
tree->type_ = T_NUMBER;
break;
default:
LOG_WARN("never reach here", "type", param.get_type());
break;
}
}
for (int32_t i = 0; OB_SUCC(ret) && i < tree->num_child_; ++i) {
if (OB_ISNULL(tree->children_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("invalid argument");
} else {
ret = SMART_CALL(replace_questionmarks(tree->children_[i], params));
}
}
}
return ret;
}
/**
* @brief calculate the result of the const or calculable expr
* @param[in] exec_ctx: exec context
* @param[in] raw_expr: input expr, must be const or calculable expr
* @param[out] result: result obj
* @param[out] is_valid: whether the result is valid when ignore_failure == true
* @param[out] allocator: used to deep copy result
* @param[in] ignore_failure: whether ignore failure when calc failed
* @param[out] constraints: add calc failure constraint when calc failed, used in query range
*/
int ObSQLUtils::calc_const_or_calculable_expr(
ObExecContext *exec_ctx,
const ObRawExpr *raw_expr,
ObObj &result,
bool &is_valid,
ObIAllocator &allocator,
bool ignore_failure /* = true*/,
ObIArray<ObExprConstraint> *constraints /* = NULL */)
{
int ret = OB_SUCCESS;
const ParamStore *params = NULL;
is_valid = false;
if (OB_ISNULL(raw_expr) || OB_ISNULL(exec_ctx) || OB_ISNULL(exec_ctx->get_physical_plan_ctx())) {
ret = OB_INVALID_ARGUMENT;
SQL_LOG(WARN, "Input arguments error", K(raw_expr), K(exec_ctx), K(ret));
} else if (FALSE_IT(params = &exec_ctx->get_physical_plan_ctx()->get_param_store())) {
} else if (raw_expr->is_const_raw_expr()) {
bool need_check = false;
if (OB_FAIL(calc_const_expr(raw_expr, params, result, need_check))) {
SQL_LOG(WARN, "failed to calc const expr", K(ret));
} else {
is_valid = true;
}
} else if (raw_expr->is_static_scalar_const_expr()) {
bool hit_cache = false;
if (OB_FAIL(get_result_from_ctx(*exec_ctx, raw_expr, result, is_valid, hit_cache))) {
LOG_WARN("failed to get result from ctx", K(ret));
} else if (hit_cache && (is_valid || ignore_failure)) {
// do nothing
} else if (OB_FAIL(calc_const_expr(*exec_ctx, raw_expr,
result, allocator, *params))) {
if (ignore_failure && !IS_SPATIAL_EXPR(raw_expr->get_expr_type())) {
LOG_TRACE("failed to calc const expr, ignore the failure", K(ret));
ret = OB_SUCCESS;
}
} else {
is_valid = true;
}
if (OB_SUCC(ret) && !hit_cache) {
if (OB_FAIL(store_result_to_ctx(*exec_ctx, raw_expr, result, is_valid))) {
LOG_WARN("failed to store result to ctx", K(ret));
}
}
if (OB_SUCC(ret) && !is_valid) {
if (NULL == constraints) {
// do nothing
} else if (OB_FAIL(add_calc_failure_constraint(raw_expr, *constraints))) {
LOG_WARN("failed to add calc failure constraint", K(ret));
}
}
} else {
ret = OB_INVALID_ARGUMENT;
SQL_LOG(WARN, "Expr should be const_expr or calculable_expr", K(*raw_expr), K(ret));
}
return ret;
}
int ObSQLUtils::calc_simple_expr_without_row(
ObSQLSessionInfo *session,
const ObRawExpr *raw_expr,
ObObj &result,
const ParamStore *params,
ObIAllocator &allocator)
{
int ret = OB_SUCCESS;
ObRawExprFactory expr_factory(allocator);
if (OB_ISNULL(raw_expr) || OB_ISNULL(params)) {
ret = OB_INVALID_ARGUMENT;
SQL_LOG(WARN, "Input arguments error", K(raw_expr), K(params), K(ret));
} else if (raw_expr->has_flag(CNT_SEQ_EXPR)) {
// skip accuracy check when default value includes sequence expr.
result.set_null();
} else if (raw_expr->is_const_raw_expr()) {
bool need_check = false;
if (OB_FAIL(calc_const_expr(raw_expr, params, result, need_check))) {
SQL_LOG(WARN, "failed to calc const expr", KPC(raw_expr), K(ret));
} else { /*do nothing*/ }
} else if (OB_FAIL(calc_const_expr(session, *raw_expr, result, allocator, *params))) {
SQL_LOG(WARN, "Get const_expr value error", KPC(raw_expr), K(ret));
}
return ret;
}
int ObSQLUtils::calc_raw_expr_without_row(
ObExecContext &exec_ctx,
const ObRawExpr *raw_expr,
ObObj &result,
const ParamStore *params,
ObIAllocator &allocator)
{
int ret = OB_SUCCESS;
bool is_overflow = false;
if (OB_FAIL(check_stack_overflow(is_overflow))) {
LOG_WARN("failed to check stack overflow", K(ret));
} else if (is_overflow) {
ret = OB_SIZE_OVERFLOW;
LOG_WARN("too deep recursive", K(ret));
}
if (OB_FAIL(ret)) {
// do nothing
} else if (OB_ISNULL(raw_expr)) {
ret = OB_INVALID_ARGUMENT;
SQL_LOG(WARN, "Input arguments error", K(raw_expr), K(ret));
} else if (raw_expr->is_const_raw_expr()) {
bool need_check = false;
if (OB_FAIL(calc_const_expr(raw_expr, params, result, need_check))) {
SQL_LOG(WARN, "failed to calc const expr", K(ret));
} else { /*do nothing*/ }
} else {
ParamStore empty_params;
if (OB_FAIL(calc_const_expr(exec_ctx, raw_expr, result, allocator, NULL == params ? empty_params : *params))) {
SQL_LOG(WARN, "Get calculable expr value without addr to parition id error", K(ret));
} else { /*do nothing*/ }
}
return ret;
}
// Clear expression's evaluation flag (children's evaluation flags are cascaded cleared too)
// to make expression be evaluated again.
//
// NOTE: this evaluation flag clear method can only be used in PL expression which
// evaluate value without row. This is why we implement this function here instead of making
// it a member function of ObExpr, otherwise it will be abused in SQL Engine.
void ObSQLUtils::clear_expr_eval_flags(const ObExpr &expr, ObEvalCtx &ctx)
{
if (expr.eval_func_ != NULL || T_OP_ROW == expr.type_) {
// The eval_func_ of the T_OP_ROW expression is null, causing the issue where the evaluation
// flag of the child expressions is not cleared. For more detail, see issue
//
expr.get_eval_info(ctx).clear_evaluated_flag();
for (int64_t i = 0; i < expr.arg_cnt_; i++) {
clear_expr_eval_flags(*expr.args_[i], ctx);
}
}
}
int ObSQLUtils::calc_sql_expression_without_row(
ObExecContext &exec_ctx,
const ObISqlExpression &expr,
ObObj &result,
ObIAllocator *allocator)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(exec_ctx.get_physical_plan_ctx())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("physical plan context is NULL", K(ret));
} else if (OB_ISNULL(exec_ctx.get_my_session())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("session is NULL", K(ret));
} else {
const sql::ObExpr *new_expr = expr.get_expr();
exec_ctx.get_physical_plan_ctx()->set_cur_time(ObTimeUtility::current_time(), *exec_ctx.get_my_session());
if (NULL == new_expr) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("static engine should have implement this function. unexpected null", K(ret));
} else {
ObDatum *datum = NULL;
ObEvalCtx eval_ctx(exec_ctx, allocator);
clear_expr_eval_flags(*new_expr, eval_ctx);
OZ(new_expr->eval(eval_ctx, datum)); // sql exprs called here
OZ(datum->to_obj(result, new_expr->obj_meta_, new_expr->obj_datum_map_));
}
}
return ret;
}
int ObSQLUtils::calc_const_expr(const ObRawExpr *expr,
const ParamStore *params,
common::ObObj &result,
bool &need_check)
{
int ret = OB_SUCCESS;
const ObConstRawExpr *const_expr = NULL;
need_check = false;
if (OB_ISNULL(expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get unexpected null", K(expr), K(ret));
} else if (OB_UNLIKELY(!expr->is_const_raw_expr())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("not const expr", K(expr->get_expr_type()), K(ret));
} else if (FALSE_IT(const_expr = static_cast<const ObConstRawExpr *>(expr))) {
// do nothing
} else if (T_QUESTIONMARK == const_expr->get_expr_type()) {
if (OB_ISNULL(params)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get unexpected null", K(params), K(ret));
} else if (OB_FAIL(get_param_value(const_expr->get_value(), *params, result, need_check))) {
LOG_WARN("get param value error", K(ret));
} else { /*do nothing*/ }
} else {
need_check = true;
result = const_expr->get_value();
}
return ret;
}
int ObSQLUtils::is_charset_data_version_valid(ObCharsetType charset_type, const int64_t tenant_id)
{
int ret = OB_SUCCESS;
uint64_t data_version = 0;
if (OB_FAIL(GET_MIN_DATA_VERSION(tenant_id, data_version))) {
SQL_LOG(WARN, "failed to GET_MIN_DATA_VERSION", K(ret));
} else if (CHARSET_LATIN1 == charset_type && data_version < DATA_VERSION_4_1_0_0 ) {
ret = OB_NOT_SUPPORTED;
SQL_LOG(WARN, "latin1 not supported when data_version < 4_1_0_0", K(ret));
LOG_USER_ERROR(OB_NOT_SUPPORTED, "tenant data version is less than 4.1, charset latin1 is");
} else if (CHARSET_GB18030_2022 == charset_type && data_version < DATA_VERSION_4_2_0_0 ) {
ret = OB_NOT_SUPPORTED;
SQL_LOG(WARN, "GB18030_2022 not supported when data_version < 4_2_0_0", K(ret));
LOG_USER_ERROR(OB_NOT_SUPPORTED, "tenant data version is less than 4.2, charset GB18030_2022 is");
}
return ret;
}
int ObSQLUtils::is_collation_data_version_valid(ObCollationType collation_type, const int64_t tenant_id)
{
int ret = OB_SUCCESS;
#ifndef OB_BUILD_CLOSE_MODULES
uint64_t data_version = 0;
if (OB_FAIL(GET_MIN_DATA_VERSION(tenant_id, data_version))) {
SQL_LOG(WARN, "failed to GET_MIN_DATA_VERSION", K(ret));
} else if (data_version < DATA_VERSION_4_2_2_0 &&
(CS_TYPE_UTF16_UNICODE_CI == collation_type ||
CS_TYPE_UTF8MB4_UNICODE_CI == collation_type)) {
ret = OB_NOT_SUPPORTED;
SQL_LOG(WARN, "Unicode collation not supported when data_version < 4_2_2_0", K(collation_type), K(ret));
LOG_USER_ERROR(OB_NOT_SUPPORTED, "tenant data version is less than 4.2.2, unicode collation is");
}
#endif
return ret;
}
// 参数raw_expr中如果出现函数addr_to_partition_id,
// 那么得到的partition_id结果在后面无法映射到相应的addr
int ObSQLUtils::calc_calculable_expr(ObSQLSessionInfo *session,
const ObRawExpr *expr,
ObObj &result,
ObIAllocator *allocator,
const ParamStore ¶ms_array)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(expr) || OB_ISNULL(allocator)) {
ret = OB_INVALID_ARGUMENT;
SQL_LOG(WARN, "Invalid arguments", K(expr), K(allocator));
} else if (!expr->is_static_scalar_const_expr()) {
ret = OB_INVALID_ARGUMENT;
SQL_LOG(WARN, "expr should be calculable expr", K(*expr), K(ret));
} else if (OB_FAIL(calc_const_expr(session,
*expr,
result,
*allocator,
params_array))) {
SQL_LOG(WARN, "failed to calc const expr", K(*expr), K(ret));
} else { /*do nothing*/ }
return ret;
}
int ObSQLUtils::calc_const_expr(ObExecContext &exec_ctx,
const ObRawExpr *expr,
ObObj &result,
ObIAllocator &allocator,
const ParamStore ¶ms_array)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(expr)) {
ret = OB_INVALID_ARGUMENT;
SQL_LOG(WARN, "Invalid arguments", K(expr));
} else if (OB_FAIL(calc_const_expr(exec_ctx.get_my_session(),
*expr,
result,
allocator,
params_array,
&exec_ctx))) {
SQL_LOG(WARN, "failed to calc const expr", K(*expr), K(ret));
} else { /*do nothing*/ }
return ret;
}
int ObSQLUtils::calc_const_expr(ObSQLSessionInfo *session,
const ObRawExpr &expr,
ObObj &result,
ObIAllocator &allocator,
const ParamStore ¶ms_array,
ObExecContext* exec_ctx)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(session)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid null session", K(ret));
} else {
if (OB_FAIL(se_calc_const_expr(session, &expr, params_array, allocator, exec_ctx, result))) {
LOG_WARN("failed to calc const expr", K(ret));
}
}
return ret;
}
int ObSQLUtils::se_calc_const_expr(ObSQLSessionInfo *session,
const ObRawExpr *expr,
const ParamStore ¶ms,
ObIAllocator &allocator,
ObExecContext *out_ctx,
common::ObObj &result)
{
int ret = OB_SUCCESS;
OB_ASSERT(NULL != session);
lib::ContextParam param;
param.set_mem_attr(session->get_effective_tenant_id(), "CalcConstExpr",
ObCtxIds::DEFAULT_CTX_ID)
.set_properties(lib::USE_TL_PAGE_OPTIONAL)
.set_page_size(OB_MALLOC_BIG_BLOCK_SIZE);
CREATE_WITH_TEMP_CONTEXT(param) {
ObIAllocator &tmp_allocator = CURRENT_CONTEXT->get_arena_allocator();
ObPhysicalPlanCtx phy_plan_ctx(tmp_allocator);
// pass the outside timeout timestamp if available
if (NULL != out_ctx && NULL != out_ctx->get_physical_plan_ctx()) {
phy_plan_ctx.set_timeout_timestamp(
out_ctx->get_physical_plan_ctx()->get_timeout_timestamp());
}
for (int i = 0; OB_SUCC(ret) && i < params.count(); i++) {
if (OB_FAIL(phy_plan_ctx.get_param_store_for_update().push_back(params.at(i)))) {
LOG_WARN("failed to push back element", K(ret));
}
} // end for
if (OB_FAIL(ret)) {
// do nothing
} else if (OB_FAIL(phy_plan_ctx.init_datum_param_store())) {
LOG_WARN("failed to init datum param store", K(ret));
} else {
ObSchemaGetterGuard *schema_guard = NULL;
if (NULL != out_ctx) {
if (OB_ISNULL(out_ctx->get_sql_ctx())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get nul sql ctx", K(ret));
} else {
schema_guard = out_ctx->get_sql_ctx()->schema_guard_;
}
} else {
schema_guard = &session->get_cached_schema_guard_info().get_schema_guard();
}
uint64_t effective_tenant_id = session->get_effective_tenant_id();
if (session->get_ddl_info().is_ddl_check_default_value()) {
effective_tenant_id = OB_SERVER_TENANT_ID;
}
SMART_VARS_2((ObExecContext, exec_ctx, tmp_allocator),
(ObStaticEngineExprCG, expr_cg, tmp_allocator,
session, schema_guard,
phy_plan_ctx.get_original_param_cnt(),
phy_plan_ctx.get_datum_param_store().count(),
(NULL != out_ctx ? out_ctx->get_min_cluster_version() : GET_MIN_CLUSTER_VERSION()))) {
LinkExecCtxGuard link_guard(*session, exec_ctx);
exec_ctx.set_my_session(session);
exec_ctx.set_mem_attr(ObMemAttr(effective_tenant_id,
ObModIds::OB_SQL_EXEC_CONTEXT,
ObCtxIds::EXECUTE_CTX_ID));
exec_ctx.set_physical_plan_ctx(&phy_plan_ctx);
if (NULL != out_ctx) {
exec_ctx.set_sql_ctx(out_ctx->get_sql_ctx());
}
void *frame_buf = NULL;
ObPreCalcExprFrameInfo *pre_calc_frame = NULL;
ObRawExpr *copied_expr = NULL;
ObRawExprFactory expr_factory(tmp_allocator);
int org_obj_cnt = phy_plan_ctx.get_param_store().count();
if (OB_FAIL(ObRawExprCopier::copy_expr(expr_factory, expr, copied_expr))) {
LOG_WARN("failed to copy raw expr", K(ret));
} else if (OB_ISNULL(copied_expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected null expr", K(ret), K(expr), K(copied_expr));
} else if (OB_ISNULL(frame_buf = tmp_allocator.alloc(sizeof(ObPreCalcExprFrameInfo)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("failed to allocate memory", K(ret));
} else {
pre_calc_frame = new(frame_buf)ObPreCalcExprFrameInfo(tmp_allocator);
if (OB_FAIL(expr_cg.generate_calculable_expr(copied_expr, *pre_calc_frame))) {
LOG_WARN("failed to generate calculable expr", K(ret));
// set current time before do pre calculation
} else if (FALSE_IT(phy_plan_ctx.set_cur_time(ObTimeUtility::current_time(), *session))) {
// do nothing
} else if (FALSE_IT(phy_plan_ctx.set_last_trace_id(session->get_last_trace_id()))) {
// do nothing
} else if (OB_FAIL(ObPlanCacheObject::pre_calculation(false,
*pre_calc_frame,
exec_ctx))) {
LOG_WARN("failed to pre calculate", K(ret));
} else if (OB_UNLIKELY(org_obj_cnt + 1 != phy_plan_ctx.get_param_store().count())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unpected param store", K(phy_plan_ctx.get_param_store()), K(org_obj_cnt));
} else if (OB_FAIL(deep_copy_obj(allocator,
phy_plan_ctx.get_param_store().at(org_obj_cnt),
result))) {
LOG_WARN("failed to deep copy obj", K(ret));
} else {
// do nothing
}
}
}
}
}
return ret;
}
int ObSQLUtils::make_generated_expression_from_str(const common::ObString &expr_str,
const share::schema::ObTableSchema &schema,
const share::schema::ObColumnSchemaV2 &gen_col,
const common::ObIArray<share::schema::ObColDesc> &col_ids,
common::ObIAllocator &allocator,
ObTempExpr *&temp_expr)
{
int ret = OB_SUCCESS;
uint64_t tenant_id = MTL_ID();
const ObTenantSchema *tenant_schema = nullptr;
ObSchemaGetterGuard guard;
SMART_VAR(sql::ObSQLSessionInfo, default_session) {
if (OB_FAIL(GCTX.schema_service_->get_tenant_schema_guard(tenant_id, guard))) {
LOG_WARN("fail to get schema guard", K(ret));
} else if (OB_FAIL(default_session.init(0, 0, &allocator))) {
LOG_WARN("init empty session failed", K(ret));
} else if (OB_FAIL(guard.get_tenant_info(tenant_id, tenant_schema))) {
LOG_WARN("fail to get tenant_schema", K(ret));
} else if (OB_FAIL(default_session.init_tenant(tenant_schema->get_tenant_name_str(), tenant_id))) {
LOG_WARN("fail to init", K(ret));
} else if (OB_FAIL(default_session.load_all_sys_vars(guard))) {
LOG_WARN("session load default system variable failed", K(ret));
} else if (OB_FAIL(make_generated_expression_from_str(
expr_str, default_session, schema, gen_col, col_ids, allocator, temp_expr))) {
LOG_WARN("make generated expression failed", K(ret), K(expr_str));
}
}
return ret;
}
int ObSQLUtils::make_generated_expression_from_str(const common::ObString &expr_str,
ObSQLSessionInfo &session,
const share::schema::ObTableSchema &schema,
const share::schema::ObColumnSchemaV2 &gen_col,
const common::ObIArray<share::schema::ObColDesc> &col_ids,
common::ObIAllocator &allocator,
ObTempExpr *&temp_expr)
{
int ret = OB_SUCCESS;
temp_expr = NULL;
ObRawExprFactory expr_factory(allocator);
ObRawExpr *expr = NULL;
RowDesc row_desc;
ObArray<ObQualifiedName> columns;
ObSEArray<ObRawExpr *, 6> real_exprs;
ObSchemaGetterGuard guard;
ObSchemaChecker schema_checker;
const bool allow_sequence = false;
if (OB_FAIL(GCTX.schema_service_->get_tenant_schema_guard(MTL_ID(), guard))) {
LOG_WARN("fail to get schema guard", K(ret));
} else if (OB_FAIL(schema_checker.init(guard))) {
LOG_WARN("failed to init schema checker", K(ret));
} else if (OB_FAIL(ObRawExprUtils::build_generated_column_expr(expr_str, expr_factory,
session, expr, columns,
&schema, allow_sequence, NULL,
&schema_checker))) {
LOG_WARN("get generated column expr failed", K(ret));
} else if (OB_ISNULL(expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("expr is null");
} else if (OB_FAIL(row_desc.init())) {
LOG_WARN("Failed to init row desc", K(ret));
} else {
//create row_desc
for (int64_t i = 0; OB_SUCC(ret) && i < col_ids.count(); ++i) {
ObColumnRefRawExpr *col_ref = NULL;
const ObColumnSchemaV2 *col_schema = NULL;
if (OB_HIDDEN_TRANS_VERSION_COLUMN_ID == col_ids.at(i).col_id_ ||
OB_HIDDEN_SQL_SEQUENCE_COLUMN_ID == col_ids.at(i).col_id_) {
continue; // hidden multi version column, not exist in schema, no need to add.
} else if (OB_ISNULL(col_schema = schema.get_column_schema(col_ids.at(i).col_id_))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get column schema failed", K_(col_ids.at(i).col_id));
} else if (OB_FAIL(ObRawExprUtils::build_column_expr(expr_factory, *col_schema, col_ref))) {
LOG_WARN("build column expr failed", K(ret));
} else if (OB_FAIL(row_desc.add_column(col_ref))) {
LOG_WARN("add column to row desc failed", K(ret));
} else { /*do nothing*/ }
//替换expr中所有和当前column ref相同的column
for (int64_t j = 0; OB_SUCC(ret) && j < columns.count(); ++j) {
ObQualifiedName &q_name = columns.at(j);
if ((!q_name.database_name_.empty() || !q_name.tbl_name_.empty()) && !q_name.is_pl_udf()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("expr is not based on single table", K(q_name));
} else if (ObCharset::case_insensitive_equal(q_name.col_name_, col_schema->get_column_name_str())) {
if (OB_FAIL(ObRawExprUtils::replace_ref_column(expr, q_name.ref_expr_, col_ref))) {
LOG_WARN("replace reference column failed", K(ret));
}
} else { /*do nothing*/ }
}
}
for (int64_t i = 0; OB_SUCC(ret) && i < columns.count(); ++i) {
ObQualifiedName &q_name = columns.at(i);
if (q_name.is_pl_udf()) {
OZ (session.set_default_database(q_name.tbl_name_));
OZ (ObRawExprUtils::resolve_gen_column_udf_expr(expr, const_cast<ObQualifiedName &>(q_name),
expr_factory, session, &schema_checker, columns, real_exprs, NULL), q_name, i, q_name.access_idents_.at(q_name.access_idents_.count() -1).udf_info_);
} else {
OZ (real_exprs.push_back(q_name.ref_expr_));
}
}
if (OB_SUCC(ret)) {
if (OB_FAIL(ObRawExprUtils::build_pad_expr_recursively(expr_factory, session, schema, gen_col, expr))) {
LOG_WARN("add pad expr failed", K(ret));
} else if (OB_FAIL(expr->formalize(&session))) {
LOG_WARN("formalize expression failed", K(ret));
}
}
if (OB_SUCC(ret)) {
ObExprResType dest_type;
dest_type.set_meta(gen_col.get_meta_type());
dest_type.set_accuracy(gen_col.get_accuracy());
if (ObRawExprUtils::need_column_conv(dest_type, *expr)) {
if (OB_FAIL(ObRawExprUtils::build_column_conv_expr(expr_factory, &gen_col, expr, &session))) {
LOG_WARN("create column convert expr failed", K(ret));
}
}
}
if (OB_SUCC(ret)) {
OZ (ObStaticEngineExprCG::gen_expr_with_row_desc(expr, row_desc, allocator,
&session, &guard, temp_expr));
CK (OB_NOT_NULL(temp_expr));
}
}
return ret;
}
int ObSQLUtils::make_default_expr_context(uint64_t tenant_id, ObIAllocator &allocator, ObExprCtx &expr_ctx)
{
int ret = OB_SUCCESS;
ObSchemaGetterGuard guard;
const ObTenantSchema *tenant_schema = nullptr;
ObSQLSessionInfo *default_session = static_cast<ObSQLSessionInfo*>(allocator.alloc(sizeof(ObSQLSessionInfo)));
if (OB_ISNULL(default_session)) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("allocate memory failed", K(ret));
} else if (OB_FAIL(GCTX.schema_service_->get_tenant_schema_guard(tenant_id, guard))) {
LOG_WARN("fail to get schema guard", K(ret));
} else {
default_session = new(default_session)ObSQLSessionInfo();
if (OB_FAIL(default_session->init(0, 0, &allocator))) {
LOG_WARN("init default session failed", K(ret));
} else if (OB_FAIL(guard.get_tenant_info(tenant_id, tenant_schema))) {
LOG_WARN("fail to get tenant_schema", K(ret));
} else if (OB_FAIL(default_session->init_tenant(tenant_schema->get_tenant_name_str(), tenant_id))) {
LOG_WARN("fail to init", K(ret));
} else if (OB_FAIL(default_session->load_all_sys_vars(guard))) {
LOG_WARN("load default system variable to session failed", K(ret));
} else {
expr_ctx.my_session_ = default_session;
}
}
if (OB_SUCC(ret)) {
ObPhysicalPlanCtx *phy_plan_ctx = static_cast<ObPhysicalPlanCtx*>(allocator.alloc(sizeof(ObPhysicalPlanCtx)));
if (OB_ISNULL(phy_plan_ctx)) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("allocate memory failed", K(ret));
} else {
phy_plan_ctx = new(phy_plan_ctx)ObPhysicalPlanCtx(allocator);
expr_ctx.phy_plan_ctx_ = phy_plan_ctx;
}
}
if (OB_SUCC(ret)) {
ObPhysicalPlan *phy_plan = static_cast<ObPhysicalPlan*>(allocator.alloc(sizeof(ObPhysicalPlan)));
if (OB_ISNULL(phy_plan)) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("allocate memory failed", K(ret));
} else {
phy_plan = new(phy_plan)ObPhysicalPlan();
expr_ctx.phy_plan_ctx_->set_phy_plan(phy_plan);
}
}
if (OB_SUCC(ret)) {
ObExecContext *exec_ctx = static_cast<ObExecContext*>(allocator.alloc(sizeof(ObExecContext)));
if (OB_ISNULL(exec_ctx)) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("allocate memory failed", K(ret));
} else {
exec_ctx = new(exec_ctx)ObExecContext(allocator);
exec_ctx->set_my_session(default_session);
exec_ctx->set_mem_attr(ObMemAttr(tenant_id,
ObModIds::OB_SQL_EXEC_CONTEXT,
ObCtxIds::EXECUTE_CTX_ID));
expr_ctx.exec_ctx_ = exec_ctx;
expr_ctx.exec_ctx_->set_my_session(default_session);
}
}
if (OB_SUCC(ret)) {
expr_ctx.calc_buf_ = &allocator;
}
if (OB_SUCC(ret)) {
if (OB_FAIL(wrap_column_convert_ctx(expr_ctx, expr_ctx.column_conv_ctx_))) {
LOG_WARN("wrap column convert ctx failed", K(ret));
}
}
return ret;
}
void ObSQLUtils::destruct_default_expr_context(ObExprCtx &expr_ctx)
{
if (NULL != expr_ctx.my_session_) {
expr_ctx.my_session_->~ObSQLSessionInfo();