forked from oceanbase/oceanbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathob_basic_session_info.cpp
More file actions
4587 lines (4306 loc) · 160 KB
/
ob_basic_session_info.cpp
File metadata and controls
4587 lines (4306 loc) · 160 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_SESSION
#include "sql/session/ob_basic_session_info.h"
#include "lib/string/ob_sql_string.h"
#include "lib/timezone/ob_oracle_format_models.h"
#include "common/sql_mode/ob_sql_mode_utils.h"
#include "common/ob_smart_call.h"
#include "share/config/ob_server_config.h"
#include "share/schema/ob_schema_getter_guard.h"
#include "share/schema/ob_sys_variable_mgr.h"
#include "sql/engine/ob_exec_context.h"
#include "sql/plan_cache/ob_plan_cache_util.h"
#include "sql/plan_cache/ob_prepare_stmt_struct.h"
#include "sql/ob_sql_trans_util.h"
#include "observer/ob_server_struct.h"
#include "sql/engine/ob_physical_plan.h"
#include "storage/transaction/ob_weak_read_util.h" //ObWeakReadUtil
#include "observer/omt/ob_tenant_timezone_mgr.h"
using namespace oceanbase::common;
using namespace oceanbase::share;
using namespace oceanbase::share::schema;
using namespace oceanbase::transaction;
namespace oceanbase {
namespace sql {
ObBasicSessionInfo::ObBasicSessionInfo()
: query_mutex_(),
thread_data_mutex_(),
is_valid_(true),
is_deserialized_(false),
tenant_id_(OB_INVALID_ID),
effective_tenant_id_(OB_INVALID_ID),
rpc_tenant_id_(0),
is_changed_to_temp_tenant_(false),
user_id_(OB_INVALID_ID),
client_version_(),
driver_version_(),
sessid_(0),
master_sessid_(INVALID_SESSID),
version_(0),
proxy_sessid_(VALID_PROXY_SESSID),
// in_transaction_(false),
variables_last_modify_time_(0),
global_vars_version_(0),
sys_var_base_version_(OB_INVALID_VERSION),
des_sys_var_base_version_(OB_INVALID_VERSION),
trans_desc_(),
trans_consistency_type_(transaction::ObTransConsistencyType::UNKNOWN),
// minus 32 is used for alignment of ObMalloc, preventing memory allocation more than 8K.
block_allocator_(
SMALL_BLOCK_SIZE, common::OB_MALLOC_NORMAL_BLOCK_SIZE - 32, ObMalloc(ObModIds::OB_SQL_SESSION_SBLOCK)),
ps_session_info_allocator_(
sizeof(ObPsSessionInfo), common::OB_MALLOC_NORMAL_BLOCK_SIZE - 32, ObMalloc("PsSessionInfo")),
name_pool_(ObModIds::OB_SQL_SESSION, OB_MALLOC_NORMAL_BLOCK_SIZE),
base_sys_var_alloc_(ObModIds::OB_SQL_SESSION, OB_MALLOC_NORMAL_BLOCK_SIZE),
trans_flags_(),
bucket_allocator_wrapper_(&block_allocator_),
user_var_val_map_(SMALL_BLOCK_SIZE, ObWrapperAllocator(&block_allocator_)),
influence_plan_var_indexs_(),
is_first_gen_(true),
sys_var_fac_(),
consistency_level_(INVALID_CONSISTENCY),
tz_info_wrap_(),
next_tx_read_only_(-1),
next_tx_isolation_(transaction::ObTransIsolation::UNKNOWN),
log_id_level_map_valid_(false),
cur_phy_plan_(NULL),
capability_(),
proxy_capability_(),
client_mode_(OB_MIN_CLIENT_MODE),
changed_sys_vars_(),
changed_user_vars_(),
changed_var_pool_(ObModIds::OB_SQL_SESSION, OB_MALLOC_NORMAL_BLOCK_SIZE),
is_database_changed_(false),
feedback_manager_(),
trans_spec_status_(TRANS_SPEC_NOT_SET),
debug_sync_actions_(),
partition_hit_(),
magic_num_(0x13572468),
current_execution_id_(-1),
database_id_(OB_INVALID_ID),
retry_info_(),
last_query_trace_id_(),
nested_count_(-1),
safe_weak_read_snapshot_(0),
weak_read_snapshot_source_(0),
curr_trans_last_stmt_end_time_(0),
read_snapshot_version_(OB_INVALID_VERSION),
check_sys_variable_(true),
is_foreign_key_cascade_(false),
is_foreign_key_check_exist_(false),
acquire_from_pool_(false),
release_to_pool_(true),
is_tenant_killed_(0),
reused_count_(0),
first_stmt_type_(stmt::T_NONE),
exec_min_cluster_version_(GET_MIN_CLUSTER_VERSION()),
stmt_type_(stmt::T_NONE),
thread_id_(0),
is_password_expired_(false)
{
MEMSET(sys_vars_, 0, sizeof(sys_vars_));
log_id_level_map_.reset_level();
CHAR_CARRAY_INIT(tenant_);
CHAR_CARRAY_INIT(effective_tenant_);
CHAR_CARRAY_INIT(trace_id_buff_);
ssl_cipher_buff_[0] = '\0';
}
ObBasicSessionInfo::~ObBasicSessionInfo()
{
destroy();
}
bool ObBasicSessionInfo::is_server_status_in_transaction() const
{
bool result = get_in_transaction() ||
(!get_local_autocommit() && trans_desc_.get_standalone_stmt_desc().is_snapshot_version_valid());
return result;
}
// for test
int ObBasicSessionInfo::test_init(
uint32_t version, uint32_t sessid, uint64_t proxy_sessid, common::ObIAllocator* bucket_allocator)
{
int ret = OB_SUCCESS;
if (NULL != bucket_allocator) {
bucket_allocator_wrapper_.set_alloc(bucket_allocator);
}
ret = user_var_val_map_.init(1024 * 1024 * 2,
256, // # of user variables
(NULL == bucket_allocator ? NULL : &bucket_allocator_wrapper_));
if (OB_FAIL(ret)) {
LOG_WARN("fail to init user_var_val_map", K(ret));
} else if (OB_FAIL(debug_sync_actions_.init(SMALL_BLOCK_SIZE, bucket_allocator_wrapper_))) {
LOG_WARN("fail to init debug sync actions", K(ret));
} else if (OB_FAIL(set_session_state(SESSION_INIT))) {
LOG_WARN("fail to set session stat", K(ret));
} else if (OB_FAIL(trans_desc_.test_init())) {
LOG_WARN("transaction desc init error", K(ret));
} else if (OB_FAIL(set_time_zone(ObString("+8:00"), is_oracle_compatible(), true /* check_timezone_valid */))) {
LOG_WARN("fail to set time zone", K(ret));
} else {
// tz_info_wrap_.set_tz_info_map(GCTX.tz_info_mgr_->get_tz_info_map());
version_ = version;
sessid_ = sessid;
proxy_sessid_ = proxy_sessid;
}
return ret;
}
bool ObBasicSessionInfo::is_use_inner_allocator() const
{
return bucket_allocator_wrapper_.get_alloc() == &block_allocator_;
}
int ObBasicSessionInfo::init(uint32_t version, uint32_t sessid, uint64_t proxy_sessid,
common::ObIAllocator* bucket_allocator, const ObTZInfoMap* tz_info)
{
int ret = OB_SUCCESS;
ObWrapperAllocator* user_var_allocator_wrapper = NULL;
if (is_acquire_from_pool()) {
reused_count_++;
if (OB_NOT_NULL(bucket_allocator) || !is_use_inner_allocator()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("session from pool must use inner allocator", K(ret));
}
} else {
if (NULL != bucket_allocator) {
bucket_allocator_wrapper_.set_alloc(bucket_allocator);
user_var_allocator_wrapper = &bucket_allocator_wrapper_;
}
}
if (OB_FAIL(ret)) {
} else if (!is_acquire_from_pool() &&
OB_FAIL(user_var_val_map_.init(1024 * 1024 * 2, 256, user_var_allocator_wrapper))) {
LOG_WARN("fail to init user_var_val_map", K(ret));
} else if (!is_acquire_from_pool() &&
OB_FAIL(debug_sync_actions_.init(SMALL_BLOCK_SIZE, bucket_allocator_wrapper_))) {
LOG_WARN("fail to init debug sync actions", K(ret));
} else if (OB_FAIL(set_session_state(SESSION_INIT))) {
LOG_WARN("fail to set session stat", K(ret));
} else if (OB_FAIL(trans_desc_.init(this))) {
LOG_WARN("transaction desc init error", K(ret));
} else if (FALSE_IT(trans_result_.set_trans_desc(&trans_desc_))) {
} else {
version_ = version;
sessid_ = sessid;
proxy_sessid_ = proxy_sessid;
uint64_t tenant_id = tenant_id_;
if (OB_ISNULL(tz_info)) {
ObTZMapWrap tz_map_wrap;
if (OB_FAIL(OTTZ_MGR.get_tenant_tz(tenant_id, tz_map_wrap))) {
LOG_WARN("get tenant timezone map failed", K(ret));
} else {
tz_info_wrap_.set_tz_info_map(tz_map_wrap.get_tz_map());
}
} else {
tz_info_wrap_.set_tz_info_map(tz_info);
}
}
return ret;
}
int ObBasicSessionInfo::update_safe_weak_read_snapshot(
const uint64_t tenant_id, const int64_t& safe_weak_read_snapshot, const int64_t& safe_weak_read_snapshot_source)
{
int ret = OB_SUCCESS;
if (!ObWeakReadUtil::enable_monotonic_weak_read(tenant_id)) {
LOG_WARN("observer not support causal order slave read", K(safe_weak_read_snapshot));
} else if (safe_weak_read_snapshot < 0) {
TRANS_LOG(WARN, "invalid argument", K(safe_weak_read_snapshot));
ret = OB_INVALID_ARGUMENT;
} else {
if (safe_weak_read_snapshot_ < safe_weak_read_snapshot) {
safe_weak_read_snapshot_ = safe_weak_read_snapshot;
weak_read_snapshot_source_ = safe_weak_read_snapshot_source;
}
}
return ret;
}
void ObBasicSessionInfo::destroy()
{
if (magic_num_ != 0x13572468) {
LOG_ERROR("ObBasicSessionInfo may be double free!!!", K(magic_num_));
}
trans_desc_.destroy();
trans_result_.reset();
trans_consistency_type_ = transaction::ObTransConsistencyType::UNKNOWN;
magic_num_ = 0x86427531;
if (thread_data_.cur_query_ != nullptr) {
ob_free(thread_data_.cur_query_);
thread_data_.cur_query_ = nullptr;
thread_data_.cur_query_buf_len_ = 0;
}
total_stmt_tables_.reset();
cur_stmt_tables_.reset();
}
void ObBasicSessionInfo::clean_status()
{
// in_transaction_ = false;
trans_flags_.reset();
trans_spec_status_ = TRANS_SPEC_NOT_SET;
// trans_desc_.reset();
trans_consistency_type_ = transaction::ObTransConsistencyType::UNKNOWN;
set_valid(true);
thread_data_.cur_query_start_time_ = 0;
thread_data_.cur_query_len_ = 0;
thread_data_.last_active_time_ = 0;
reset_session_changed_info();
}
void ObBasicSessionInfo::reset(bool skip_sys_var)
{
set_valid(false);
is_deserialized_ = false;
CHAR_CARRAY_INIT(tenant_);
tenant_id_ = OB_INVALID_ID;
CHAR_CARRAY_INIT(effective_tenant_);
effective_tenant_id_ = OB_INVALID_ID;
is_changed_to_temp_tenant_ = false;
user_id_ = OB_INVALID_ID;
client_version_.reset();
driver_version_.reset();
sessid_ = 0;
master_sessid_ = INVALID_SESSID;
version_ = 0;
proxy_sessid_ = VALID_PROXY_SESSID;
variables_last_modify_time_ = 0;
global_vars_version_ = 0;
des_sys_var_base_version_ = OB_INVALID_VERSION;
trans_desc_.reset();
trans_consistency_type_ = transaction::ObTransConsistencyType::UNKNOWN;
trans_result_.reset();
total_stmt_tables_.reset();
cur_stmt_tables_.reset();
// reset() of user_var_val_map_ and debug_sync_actions_ will keep some memory
// allocated from block_allocator_ / bucket_allocator_wrapper_, so we skip
// reset() of block_allocator_ and bucket_allocator_wrapper_.
// block_allocator_.reset();
ps_session_info_allocator_.reset();
trans_flags_.reset();
// bucket_allocator_wrapper_.reset();
user_var_val_map_.reuse();
if (!skip_sys_var) {
memset(sys_vars_, 0, sizeof(sys_vars_));
influence_plan_var_indexs_.reset();
} else {
const SysVarIds& all_sys_var_ids = sys_var_inc_info_.get_all_sys_var_ids();
for (int i = 0; i < all_sys_var_ids.count(); i++) {
int ret = OB_SUCCESS;
int64_t store_idx = -1;
ObSysVarClassType sys_var_id = all_sys_var_ids.at(i);
OZ(ObSysVarFactory::calc_sys_var_store_idx(sys_var_id, store_idx));
OV(0 <= store_idx && store_idx < ObSysVarFactory::ALL_SYS_VARS_COUNT);
OV(OB_NOT_NULL(sys_vars_[store_idx]));
OX(sys_vars_[store_idx]->clean_inc_value());
}
sys_var_inc_info_.reset();
reset_timezone();
}
sys_var_in_pc_str_.reset();
is_first_gen_ = true;
CHAR_CARRAY_INIT(trace_id_buff_);
// consistency_level_ = INVALID_CONSISTENCY;
next_tx_read_only_ = -1;
next_tx_isolation_ = transaction::ObTransIsolation::UNKNOWN;
log_id_level_map_valid_ = false;
log_id_level_map_.reset_level();
cur_phy_plan_ = NULL;
capability_.capability_ = 0;
proxy_capability_.capability_ = 0;
client_mode_ = OB_MIN_CLIENT_MODE;
reset_session_changed_info();
trans_spec_status_ = TRANS_SPEC_NOT_SET;
debug_sync_actions_.reset();
partition_hit_.reset();
// magic_num_ = 0x86427531;
current_execution_id_ = -1;
last_trace_id_.reset();
app_trace_id_.reset();
database_id_ = OB_INVALID_ID;
retry_info_.reset();
last_query_trace_id_.reset();
thread_data_.reset();
nested_count_ = -1;
if (!skip_sys_var) {
sys_vars_cache_.reset();
} else {
sys_vars_cache_.clean_inc();
}
safe_weak_read_snapshot_ = 0;
weak_read_snapshot_source_ = 0;
curr_trans_last_stmt_end_time_ = 0;
read_snapshot_version_ = OB_INVALID_VERSION;
check_sys_variable_ = true;
is_foreign_key_cascade_ = false;
is_foreign_key_check_exist_ = false;
acquire_from_pool_ = false;
// skip release_to_pool_, see comments in .h file.
is_tenant_killed_ = 0;
first_stmt_type_ = stmt::T_NONE;
exec_min_cluster_version_ = GET_MIN_CLUSTER_VERSION();
thread_id_ = 0;
is_password_expired_ = false;
// release all allocators at last, otherwise some members may keep invalid pointers,
// and for_each_session() of session mgr may core if access these invalid pointers.
name_pool_.reset();
if (!skip_sys_var) {
base_sys_var_alloc_.reset();
sys_var_fac_.destroy();
}
}
void ObBasicSessionInfo::reset_timezone()
{
int ret = OB_SUCCESS;
ObObj tmp_obj1;
if (OB_FAIL(get_sys_variable(SYS_VAR_TIME_ZONE, tmp_obj1))) {
LOG_WARN("get sys var failed", K(ret));
} else if (OB_FAIL(process_session_time_zone_value(tmp_obj1, false))) {
LOG_WARN("set time zone failed", K(ret));
}
ObObj tmp_obj2;
if (OB_FAIL(get_sys_variable(SYS_VAR_ERROR_ON_OVERLAP_TIME, tmp_obj2))) {
LOG_WARN("get sys var failed", K(ret));
} else if (OB_FAIL(process_session_overlap_time_value(tmp_obj2))) {
LOG_WARN("process session overlap time value failed", K(ret), K(tmp_obj2));
}
}
int ObBasicSessionInfo::init_tenant(const ObString& tenant_name, const uint64_t tenant_id)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(!is_valid_tenant_id(tenant_id))) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid tenant id", K(tenant_id), K(ret));
} else if (tenant_name.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("tenant name is empty", K(tenant_name), K(ret));
} else if (tenant_name.length() > OB_MAX_TENANT_NAME_LENGTH) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("tenant name too long", K(tenant_name), K(ret));
} else if (OB_FAIL(ob_cstrcopy(tenant_, sizeof(tenant_), tenant_name))) {
LOG_WARN("failed to copy tenant name", K(tenant_name), K(ret));
} else if (OB_FAIL(ob_cstrcopy(effective_tenant_, sizeof(effective_tenant_), tenant_name))) {
LOG_WARN("failed to copy effective tenant name", K(tenant_name), K(ret));
} else {
ObTZMapWrap tz_map_wrap;
if (OB_FAIL(OTTZ_MGR.get_tenant_tz(tenant_id, tz_map_wrap))) {
LOG_WARN("get tenant timezone map failed", K(ret));
} else {
tz_info_wrap_.set_tz_info_map(tz_map_wrap.get_tz_map());
tenant_id_ = tenant_id;
effective_tenant_id_ = tenant_id;
LOG_DEBUG("init session tenant", K(tenant_name), K(tenant_id));
}
}
return ret;
}
int ObBasicSessionInfo::set_tenant(const common::ObString& tenant_name, const uint64_t tenant_id)
{
int ret = OB_SUCCESS;
if (!is_valid_tenant_id(tenant_id)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid tenant id", K(tenant_id), K(ret));
} else if (tenant_name.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("tenant name is empty", K(tenant_name), K(ret));
} else if (tenant_name.length() > OB_MAX_TENANT_NAME_LENGTH) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("tenant name too long", K(tenant_name), K(ret));
} else if (OB_FAIL(ob_cstrcopy(tenant_, sizeof(tenant_), tenant_name))) {
LOG_WARN("tenant name too long", K(tenant_name));
} else {
tenant_id_ = tenant_id;
LOG_TRACE("set tenant", K(tenant_name), K(tenant_id));
}
return ret;
}
int ObBasicSessionInfo::set_tenant(const common::ObString& tenant_name, const uint64_t tenant_id, char* ori_tenant_name,
const uint64_t length, uint64_t& ori_tenant_id)
{
int ret = OB_SUCCESS;
if (!is_valid_tenant_id(tenant_id)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid tenant id", K(tenant_id), K(ret));
} else if (OB_ISNULL(ori_tenant_name)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("ori_tenant_name is NULL", K(ret));
} else if (length < OB_MAX_TENANT_NAME_LENGTH + 1) {
ret = OB_INVALID_ARGUMENT_FOR_LENGTH;
LOG_WARN("tenant_name length is not enough ");
} else if (tenant_name.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("tenant name is empty", K(tenant_name), K(ret));
} else if (tenant_name.length() > OB_MAX_TENANT_NAME_LENGTH) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("tenant name too long", K(tenant_name), K(ret));
} else if (OB_FAIL(ob_cstrcopy(ori_tenant_name, length, tenant_, strlen(tenant_)))) {
LOG_ERROR("tenant_name is longer than ori_tenant_name", K(length), K(strlen(tenant_)));
} else if (OB_FAIL(ob_cstrcopy(tenant_, sizeof(tenant_), tenant_name))) {
LOG_ERROR("tenant name too long", K(tenant_name));
} else {
ori_tenant_id = tenant_id_;
tenant_id_ = tenant_id;
}
return ret;
}
int ObBasicSessionInfo::switch_tenant(uint64_t effective_tenant_id)
{
int ret = OB_SUCCESS;
if (OB_SYS_TENANT_ID != tenant_id_) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("only support sys tenant switch tenant", K(ret), K(tenant_id_), K(effective_tenant_id_));
} else if (effective_tenant_id <= 0) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid tenant_id", K(ret), K(effective_tenant_id));
} else {
#ifndef NDEBUG
if (effective_tenant_id_ != effective_tenant_id) {
LOG_INFO(
"switch tenant", K(effective_tenant_id), K(effective_tenant_id_), "priv_tenant_id", tenant_id_, K(lbt()));
}
#endif
effective_tenant_id_ = effective_tenant_id;
}
return ret;
}
const common::ObString ObBasicSessionInfo::get_tenant_name() const
{
return ObString::make_string(tenant_);
}
const common::ObString ObBasicSessionInfo::get_effective_tenant_name() const
{
return ObString::make_string(effective_tenant_);
}
int ObBasicSessionInfo::set_user(const ObString& user_name, const ObString& host_name, const uint64_t user_id)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(user_name.length() > common::OB_MAX_USER_NAME_LENGTH) ||
OB_UNLIKELY(host_name.length() > common::OB_MAX_HOST_NAME_LENGTH)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("name length invalid_", K(user_name), K(host_name), K(ret));
} else {
char tmp_buf[common::OB_MAX_USER_NAME_LENGTH + common::OB_MAX_HOST_NAME_LENGTH + 2] = {};
snprintf(tmp_buf,
sizeof(tmp_buf),
"%.*s@%.*s",
user_name.length(),
user_name.ptr(),
host_name.length(),
host_name.ptr());
ObString tmp_string(tmp_buf);
LockGuard lock_guard(thread_data_mutex_);
if (OB_FAIL(name_pool_.write_string(user_name, &thread_data_.user_name_))) {
LOG_WARN("fail to write username to string_buf_", K(user_name), K(ret));
} else if (OB_FAIL(name_pool_.write_string(host_name, &thread_data_.host_name_))) {
LOG_WARN("fail to write hostname to string_buf_", K(host_name), K(ret));
} else if (OB_FAIL(name_pool_.write_string(tmp_string, &thread_data_.user_at_host_name_))) {
LOG_WARN("fail to write user_at_host_name to string_buf_", K(tmp_string), K(ret));
} else {
user_id_ = user_id;
}
}
return ret;
}
int ObBasicSessionInfo::set_real_client_ip(const common::ObString& client_ip)
{
int ret = OB_SUCCESS;
char tmp_buf[common::OB_MAX_USER_NAME_LENGTH + common::OB_MAX_HOST_NAME_LENGTH + 2] = {};
snprintf(tmp_buf,
sizeof(tmp_buf),
"%.*s@%.*s",
thread_data_.user_name_.length(),
thread_data_.user_name_.ptr(),
client_ip.length(),
client_ip.ptr());
ObString tmp_string(tmp_buf);
LockGuard lock_guard(thread_data_mutex_);
if (OB_FAIL(name_pool_.write_string(client_ip, &thread_data_.client_ip_))) {
LOG_WARN("fail to write client_ip to string_buf_", K(client_ip), K(ret));
} else if (OB_FAIL(name_pool_.write_string(tmp_string, &thread_data_.user_at_client_ip_))) {
LOG_WARN("fail to write user_at_host_name to string_buf_", K(tmp_string), K(ret));
} else {
thread_data_.user_client_addr_.set_ip_addr(client_ip, 0);
}
return ret;
}
int ObBasicSessionInfo::check_and_init_retry_info(const ObCurTraceId::TraceId& cur_trace_id, const ObString& sql)
{
int ret = OB_SUCCESS;
if (last_query_trace_id_.equals(cur_trace_id)) { // is retrying.
if (OB_UNLIKELY(!retry_info_.is_inited())) {
LOG_ERROR("is retry packet, but retry info is not inited, will init it",
K(last_query_trace_id_),
K(cur_trace_id),
K(retry_info_),
K(get_sessid()),
K(sql));
if (OB_FAIL(retry_info_.init())) {
LOG_WARN("fail to init retry info", K(ret), K(retry_info_), K(sql));
}
}
} else {
if (OB_UNLIKELY(retry_info_.is_inited())) {
retry_info_.reset();
}
if (OB_FAIL(retry_info_.init())) {
LOG_WARN("fail to init retry info", K(ret), K(retry_info_), K(sql));
} else {
last_query_trace_id_.set(cur_trace_id);
}
}
return ret;
}
void ObBasicSessionInfo::check_and_reset_retry_info(const ObCurTraceId::TraceId& cur_trace_id, bool is_packet_retry)
{
if (!is_packet_retry) {
retry_info_.reset();
}
last_query_trace_id_.set(cur_trace_id);
}
const ObLogIdLevelMap* ObBasicSessionInfo::get_log_id_level_map() const
{
return (log_id_level_map_valid_ ? (&log_id_level_map_) : NULL);
}
int ObBasicSessionInfo::set_client_version(const ObString& client_version)
{
int ret = OB_SUCCESS;
if (client_version.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("client version is empty", K(client_version), K(ret));
} else if (OB_FAIL(name_pool_.write_string(client_version, &client_version_))) {
LOG_WARN("failed to write client_version to string_buf_", K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::set_driver_version(const ObString& driver_version)
{
int ret = OB_SUCCESS;
if (driver_version.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("driver version is empty", K(driver_version), K(ret));
} else if (OB_FAIL(name_pool_.write_string(driver_version, &driver_version_))) {
LOG_WARN("failed to write driver_version to string_buf_", K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::set_default_database(
const ObString& database_name, const ObCollationType coll_type /*= CS_TYPE_INVALID */)
{
int ret = OB_SUCCESS;
if (database_name.length() > OB_MAX_DATABASE_NAME_LENGTH) {
ret = OB_INVALID_ARGUMENT_FOR_LENGTH;
LOG_WARN("invalid length for database_name", K(database_name), K(ret));
} else {
if (CS_TYPE_INVALID != coll_type) {
const int64_t coll_val = static_cast<int64_t>(coll_type);
if (OB_FAIL(update_sys_variable(SYS_VAR_CHARACTER_SET_DATABASE, coll_val))) {
LOG_WARN("failed to update variable", K(ret));
} else if (OB_FAIL(update_sys_variable(SYS_VAR_COLLATION_DATABASE, coll_val))) {
LOG_WARN("failed to update variable", K(ret));
} else {
}
}
if (OB_SUCC(ret)) {
LockGuard lock_guard(thread_data_mutex_);
MEMCPY(thread_data_.database_name_, database_name.ptr(), database_name.length());
thread_data_.database_name_[database_name.length()] = '\0';
if (is_track_session_info()) {
is_database_changed_ = true;
}
}
}
return ret;
}
int ObBasicSessionInfo::update_database_variables(ObSchemaGetterGuard* schema_guard)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(schema_guard)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid schema guard is NULL", K(ret));
} else {
if ('\0' == thread_data_.database_name_[0]) {
// no default database
ObObj val;
if (OB_FAIL(get_sys_variable(SYS_VAR_CHARACTER_SET_SERVER, val))) {
LOG_WARN("failed to get sys variable", K(ret));
} else if (OB_FAIL(update_sys_variable(SYS_VAR_CHARACTER_SET_DATABASE, val))) {
LOG_WARN("failed to update sys variable", K(ret));
} else if (OB_FAIL(get_sys_variable(SYS_VAR_COLLATION_SERVER, val))) {
LOG_WARN("failed to get sys variable", K(ret));
} else if (OB_FAIL(update_sys_variable(SYS_VAR_COLLATION_DATABASE, val))) {
LOG_WARN("failed to update sys variable", K(ret));
} else {
}
} else {
const share::schema::ObDatabaseSchema* db_schema = NULL;
ObString db_name(thread_data_.database_name_);
if (OB_FAIL(schema_guard->get_database_schema(effective_tenant_id_, db_name, db_schema))) {
LOG_WARN("get database schema failed", K(effective_tenant_id_), K(db_name), K(ret));
} else if (NULL == db_schema) {
ret = OB_ERR_BAD_DATABASE;
LOG_WARN("database not exist", K(effective_tenant_id_), K(db_name), K(ret));
LOG_USER_ERROR(OB_ERR_BAD_DATABASE, db_name.length(), db_name.ptr());
} else {
const int64_t db_coll = static_cast<int64_t>(db_schema->get_collation_type());
if (OB_FAIL(update_sys_variable(SYS_VAR_CHARACTER_SET_DATABASE, db_coll))) {
LOG_WARN("failed to update sys variable", K(ret));
} else if (OB_FAIL(update_sys_variable(SYS_VAR_COLLATION_DATABASE, db_coll))) {
LOG_WARN("failed to update sys variable", K(ret));
} else {
}
}
}
}
return ret;
}
int ObBasicSessionInfo::update_max_packet_size()
{
int ret = OB_SUCCESS;
int64_t max_allowed_pkt = 0;
int64_t net_buffer_len = 0;
if (OB_FAIL(get_max_allowed_packet(max_allowed_pkt))) {
LOG_WARN("fail to get_max_allowed_packet", K(ret));
} else if (OB_FAIL(get_net_buffer_length(net_buffer_len))) {
LOG_WARN("fail to get_net_buffer_length", K(ret));
} else {
thread_data_.max_packet_size_ = std::max(max_allowed_pkt, net_buffer_len);
}
return ret;
}
const ObString ObBasicSessionInfo::get_database_name() const
{
ObString str_ret;
str_ret.assign_ptr(
const_cast<char*>(thread_data_.database_name_), static_cast<int32_t>(strlen(thread_data_.database_name_)));
return str_ret;
}
//// FIXME:
// int ObBasicSessionInfo::get_database_id(
// ObSchemaGetterGuard *schema_guard,
// uint64_t &db_id) const
//{
// int ret = OB_SUCCESS;
// db_id = OB_INVALID_ID;
// if (get_database_name().empty()) {
// //do nothing
// } else if (OB_UNLIKELY(NULL == schema_guard)) {
// ret = OB_INVALID_ARGUMENT;
// LOG_WARN("Schema guard should not be NULL", K(ret));
// } else if (OB_FAIL(schema_guard->get_database_id(get_effective_tenant_id(), get_database_name(),
// db_id))) {
// db_id = OB_INVALID_ID;
// LOG_WARN("failed to get database id", K(db_id), K(ret));
// } else { }//do nothing
// return ret;
//}
////////////////////////////////////////////////////////////////
int ObBasicSessionInfo::get_global_sys_variable(
const ObBasicSessionInfo* session, ObIAllocator& calc_buf, const ObString& var_name, ObObj& val)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(session)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("session is NULL", K(ret), K(var_name));
} else {
// const ObDataTypeCastParams dtc_params(session->get_timezone_info(),
// session->get_local_nls_formats(),
// session->get_nls_collation(),
// session->get_nls_collation_nation());
ObDataTypeCastParams dtc_params = session->get_dtc_params();
if (OB_FAIL(get_global_sys_variable(session->get_effective_tenant_id(), calc_buf, dtc_params, var_name, val))) {
LOG_WARN("fail to get global sys variable", K(ret), K(var_name));
}
}
return ret;
}
int ObBasicSessionInfo::get_global_sys_variable(const uint64_t actual_tenant_id, // tenant may be switched
ObIAllocator& calc_buf, const ObDataTypeCastParams& dtc_params, const ObString& var_name, ObObj& val)
{
int ret = OB_SUCCESS;
ObSchemaGetterGuard schema_guard;
const ObTenantSchema* tenant_schema = NULL;
const ObSysVarSchema* sysvar_schema = NULL;
const ObSysVariableSchema* sys_variable_schema = NULL;
if (OB_UNLIKELY(!is_valid_tenant_id(actual_tenant_id))) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid tenant id", K(actual_tenant_id), K(ret));
} else if (OB_ISNULL(GCTX.schema_service_)) {
ret = OB_INVALID_ARGUMENT;
OB_LOG(WARN, "invalid argument", K(GCTX.schema_service_));
} else if (OB_FAIL(GCTX.schema_service_->get_tenant_schema_guard(actual_tenant_id, schema_guard))) {
ret = OB_SCHEMA_ERROR;
OB_LOG(WARN, "fail get schema guard", K(ret));
} else if (OB_FAIL(schema_guard.get_tenant_info(actual_tenant_id, tenant_schema))) {
LOG_WARN("get tenant info failed", K(ret), K(actual_tenant_id));
} else if (OB_ISNULL(tenant_schema)) {
ret = OB_SCHEMA_ERROR;
LOG_WARN("tenant_schema is NULL", K(ret));
} else if (OB_FAIL(schema_guard.get_sys_variable_schema(actual_tenant_id, sys_variable_schema))) {
LOG_WARN("get sys variable schema failed", K(ret));
} else if (OB_ISNULL(sys_variable_schema)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("sys variable schema is null", K(ret));
} else if (OB_FAIL(sys_variable_schema->get_sysvar_schema(var_name, sysvar_schema))) {
ret = OB_ERR_SYS_VARIABLE_UNKNOWN;
LOG_WARN("failed to get sysvar", K(ret), K(var_name));
} else if (OB_ISNULL(sysvar_schema)) {
ret = OB_SCHEMA_ERROR;
LOG_WARN("tenant_schema is NULL", K(ret));
} else if (OB_FAIL(sysvar_schema->get_value(&calc_buf, dtc_params, val))) {
LOG_WARN("failed to get value", K(ret), K(var_name));
} else if (OB_FAIL(ObBasicSessionInfo::change_value_for_special_sys_var(var_name, val, val))) {
LOG_ERROR("fail to change value for special sys var", K(ret), K(var_name), K(val));
} else {
LOG_DEBUG("get global sysvar", K(var_name), K(val));
}
return ret;
}
const ObBasicSysVar* ObBasicSessionInfo::get_sys_var(const int64_t idx) const
{
const ObBasicSysVar* var = NULL;
if (idx >= 0 && idx < ObSysVarFactory::ALL_SYS_VARS_COUNT) {
var = sys_vars_[idx];
}
return var;
}
int ObBasicSessionInfo::init_system_variables(const bool print_info_log, const bool is_sys_tenant)
{
int ret = OB_SUCCESS;
ObString name;
ObObj type;
ObObj value;
ObObj min_val;
ObObj max_val;
ObObjType var_type = ObNullType;
int64_t var_flag = ObSysVarFlag::NONE;
int64_t var_amount = ObSysVariables::get_amount();
ObObj casted_value;
ObArenaAllocator calc_buf(ObModIds::OB_SQL_SESSION);
ObCastCtx cast_ctx(&calc_buf, NULL, CM_NONE, ObCharset::get_system_collation());
for (int64_t i = 0; OB_SUCC(ret) && i < var_amount; ++i) {
name.assign_ptr(const_cast<char*>(ObSysVariables::get_name(i).ptr()),
static_cast<ObString::obstr_size_t>(strlen(ObSysVariables::get_name(i).ptr())));
bool is_exist = false;
if (OB_FAIL(sys_variable_exists(name, is_exist))) {
LOG_WARN("failed to check if sys variable exists", K(name), K(ret));
} else if (!is_exist) {
var_type = ObSysVariables::get_type(i);
var_flag = ObSysVariables::get_flags(i);
value.set_varchar(ObSysVariables::get_value(i));
value.set_collation_type(ObCharset::get_system_collation());
min_val.set_varchar(ObSysVariables::get_min(i));
min_val.set_collation_type(ObCharset::get_system_collation());
max_val.set_varchar(ObSysVariables::get_max(i));
max_val.set_collation_type(ObCharset::get_system_collation());
type.set_type(var_type);
if (is_sys_tenant) {
if (OB_FAIL(process_variable_for_tenant(name, value))) {
LOG_WARN("process system variable for tenant error", K(name), K(value), K(ret));
}
}
if (OB_SUCC(ret)) {
if (OB_FAIL(load_sys_variable(name, type, value, min_val, max_val, var_flag))) {
LOG_WARN("fail to load default system variable", K(name), K(ret));
} else if (OB_NOT_NULL(sys_vars_[i]) && sys_vars_[i]->is_influence_plan() &&
OB_FAIL(influence_plan_var_indexs_.push_back(i))) {
LOG_WARN("fail to add influence plan sys var", K(name), K(ret));
} else if (print_info_log) {
LOG_INFO("load default system variable", name.ptr(), value.get_string().ptr());
}
}
}
} // end for
if (OB_SUCC(ret)) {
if (OB_FAIL(gen_sys_var_in_pc_str())) {
LOG_INFO("fail to generate system variables in pc str");
} else {
global_vars_version_ = 0;
sys_var_base_version_ = 0;
}
}
return ret;
}
int ObBasicSessionInfo::update_query_sensitive_system_variable(ObSchemaGetterGuard& schema_guard)
{
int ret = OB_SUCCESS;
const ObSysVarSchema* sysvar = NULL;
int64_t schema_version = -1;
const ObSimpleSysVariableSchema* sys_variable_schema = NULL;
const uint64_t tenant_id = get_effective_tenant_id();
int64_t refreshed_schema_version = OB_INVALID_VERSION;
if (!check_sys_variable_) {
// skip to avoid circular dependency.
} else if (OB_FAIL(schema_guard.get_schema_version(tenant_id, refreshed_schema_version))) {
LOG_WARN("fail to get tenant schema version", K(ret), K(tenant_id));
} else if (OB_CORE_SCHEMA_VERSION >= refreshed_schema_version) {
// if in tenant creation process or the tenant creation fails or the local schema is not refreshed,
// the system variables can not be obtained, skip this step.
} else if (OB_FAIL(schema_guard.get_sys_variable_schema(tenant_id, sys_variable_schema))) {
LOG_WARN("get tenant schema version failed", K(ret), K(tenant_id));
} else if (OB_ISNULL(sys_variable_schema)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("sys variable schema should not be null", K(ret), K(tenant_id));
} else if (FALSE_IT(schema_version = sys_variable_schema->get_schema_version())) {
ret = OB_ERR_UNEXPECTED;
} else if (schema_version > get_global_vars_version() && schema_version > OB_CORE_SCHEMA_VERSION) {
const ObTenantSchema* tenant_info = NULL;
bool need_update_version = false;
const ObSysVariableSchema* sys_variable_schema = NULL;
if (OB_FAIL(schema_guard.get_tenant_info(get_effective_tenant_id(), tenant_info))) {
LOG_WARN("get tenant info from schema guard failed", K(ret));
} else if (OB_FAIL(schema_guard.get_sys_variable_schema(get_effective_tenant_id(), sys_variable_schema))) {
if (OB_TENANT_NOT_EXIST == ret) {
LOG_INFO("tenant maybe creating, just skip", K(ret), K(ret));
ret = OB_SUCCESS;
} else {
LOG_WARN("get sys variable schema failed", K(ret));
}
} else if (OB_ISNULL(sys_variable_schema)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("sys variable schema is null", K(ret));
} else {
for (int64_t i = 0; OB_SUCC(ret) && i < sys_variable_schema->get_sysvar_count(); ++i) {
sysvar = sys_variable_schema->get_sysvar_schema(i);
if (sysvar != NULL && sysvar->is_query_sensitive()) {
if (OB_FAIL(update_sys_variable(sysvar->get_name(), sysvar->get_value()))) {
if (OB_ERR_SYS_VARIABLE_UNKNOWN == ret) {
// this system variable may come from a higher version,
// which is not available locally, ignore it.
ret = OB_SUCCESS;
} else {
LOG_WARN("update system variable failed", K(ret), K(*sysvar));
}
} else {
need_update_version = true;
}
}
}
if (OB_SUCC(ret) && need_update_version) {
set_global_vars_version(schema_version);
}
}
}
return ret;
}
// used for bootstarp, in which we can not get system variables from inner table.
int ObBasicSessionInfo::load_default_sys_variable(const bool print_info_log, const bool is_sys_tenant)
{
int ret = OB_SUCCESS;
if (OB_FAIL(init_system_variables(print_info_log, is_sys_tenant))) {
LOG_WARN("Init system variables failed !", K(ret));
} else {
variables_last_modify_time_ = ObTimeUtility::current_time();
}
return ret;
}
// used for session deserialization from lower version observer,
// and some system variables may be supported in current version.
int ObBasicSessionInfo::load_default_sys_variable(int64_t var_idx)
{
int ret = OB_SUCCESS;
ObString name;
ObObj type;
ObObj value;
ObObj min_val;
ObObj max_val;
ObObjType var_type = ObNullType;
int64_t var_flag = ObSysVarFlag::NONE;
if (var_idx < 0 || var_idx >= ObSysVarFactory::ALL_SYS_VARS_COUNT) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("the value of var_idx is unexpected", K(ret));
} else {
name.assign_ptr(const_cast<char*>(ObSysVariables::get_name(var_idx).ptr()),
static_cast<ObString::obstr_size_t>(strlen(ObSysVariables::get_name(var_idx).ptr())));
var_type = ObSysVariables::get_type(var_idx);
var_flag = ObSysVariables::get_flags(var_idx);
value.set_varchar(ObSysVariables::get_value(var_idx));
value.set_collation_type(ObCharset::get_system_collation());
min_val.set_varchar(ObSysVariables::get_min(var_idx));
min_val.set_collation_type(ObCharset::get_system_collation());
max_val.set_varchar(ObSysVariables::get_max(var_idx));
max_val.set_collation_type(ObCharset::get_system_collation());
type.set_type(var_type);
if (OB_FAIL(load_sys_variable(name, type, value, min_val, max_val, var_flag))) {
LOG_WARN("fail to load default system variable", K(name), K(ret));
}
}
return ret;
}
int ObBasicSessionInfo::process_variable_for_tenant(const ObString& var, ObObj& val)
{
int ret = OB_SUCCESS;
if (0 == var.compare(OB_SV_LOWER_CASE_TABLE_NAMES)) {
val.set_varchar("2");
val.set_collation_type(ObCharset::get_system_collation());
}
return ret;
}
int ObBasicSessionInfo::create_sys_var(ObSysVarClassType sys_var_id, int64_t store_idx, ObBasicSysVar*& sys_var)
{
int ret = OB_SUCCESS;
OV(0 <= store_idx && store_idx < ObSysVarFactory::ALL_SYS_VARS_COUNT, OB_ERR_UNEXPECTED, sys_var_id, store_idx);
if (OB_NOT_NULL(sys_vars_[store_idx])) {