forked from oceanbase/seekdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathob_err_log_op.cpp
More file actions
101 lines (93 loc) · 2.92 KB
/
Copy pathob_err_log_op.cpp
File metadata and controls
101 lines (93 loc) · 2.92 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
/*
* Copyright (c) 2025 OceanBase.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define USING_LOG_PREFIX SQL_ENG
#include "sql/engine/dml/ob_err_log_op.h"
#include "sql/engine/ob_exec_context.h"
namespace oceanbase
{
using namespace common;
using namespace share;
namespace sql
{
OB_SERIALIZE_MEMBER((ObErrLogSpec, ObOpSpec), err_log_ct_def_, type_)
int ObErrLogOp::inner_open()
{
int ret = OB_SUCCESS;
return ret;
}
int ObErrLogOp::inner_get_next_row()
{
int ret = OB_SUCCESS;
ObString err_msg;
ObString err_op_type;
bool need_get_next_row = false;
do {
need_get_next_row = false;
clear_evaluated_flag();
if (OB_FAIL(child_->get_next_row())) {
if (OB_ITER_END != ret) {
LOG_WARN("fail to get_next_row from child ", K(ret));
}
} else {
for (int64_t i = 0; OB_SUCC(ret) && i < MY_SPEC.output_.count(); i++) {
ObExpr *expr = MY_SPEC.output_[i];
ObDatum *datum = NULL;
if (OB_FAIL(expr->eval(eval_ctx_, datum))) {
if(should_catch_err(ret) && OB_NOT_NULL(datum)) {
err_log_rt_def_.first_err_ret_ = ret;
datum->set_null();
expr->set_evaluated_projected(eval_ctx_);
ret = OB_SUCCESS;
} else {
LOG_WARN("fail to eval expr", K(ret), KPC(expr));
}
}
}
if (OB_SUCCESS != err_log_rt_def_.first_err_ret_ && OB_SUCC(ret)) {
if (OB_FAIL(record_err_log())) {
LOG_WARN("fail to record_err_log", K(ret));
} else {
err_log_rt_def_.curr_err_log_record_num_++;
err_log_rt_def_.reset();
need_get_next_row = true;
}
}
}
} while (OB_SUCC(ret) && need_get_next_row);
return ret;
}
int ObErrLogOp::record_err_log()
{
int ret = OB_SUCCESS;
const ObSQLSessionInfo *session = ctx_.get_my_session();
if (OB_ISNULL(session)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("session is null");
} else if (OB_FAIL(err_log_service_.insert_err_log_record(session,
MY_SPEC.err_log_ct_def_,
err_log_rt_def_,
MY_SPEC.type_))) {
LOG_WARN("fail to insert error logging table", K(ret));
}
return ret;
}
int ObErrLogOp::inner_close()
{
NG_TRACE(insert_close);
return ObOperator::inner_close();
}
} // namespace sql
} // namespace oceanbase