forked from oceanbase/oceanbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathob_delete_stmt_printer.cpp
More file actions
119 lines (101 loc) · 3.2 KB
/
Copy pathob_delete_stmt_printer.cpp
File metadata and controls
119 lines (101 loc) · 3.2 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
/**
* 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
#include "sql/ob_delete_stmt_printer.h"
#include "sql/ob_sql_context.h"
namespace oceanbase
{
using namespace common;
namespace sql
{
void ObDeleteStmtPrinter::init(char *buf, int64_t buf_len, int64_t *pos, ObDeleteStmt *stmt)
{
ObDMLStmtPrinter::init(buf, buf_len, pos, stmt);
}
int ObDeleteStmtPrinter::do_print()
{
int ret = OB_SUCCESS;
if (OB_ISNULL(stmt_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("stmt should not be NULL", K(ret));
} else {
expr_printer_.init(buf_,
buf_len_,
pos_,
schema_guard_,
print_params_,
param_store_);
if (OB_FAIL(print())) {
LOG_WARN("fail to print stmt", K(ret));
}
}
return ret;
}
int ObDeleteStmtPrinter::print()
{
int ret = OB_SUCCESS;
if (OB_ISNULL(stmt_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("stmt_ should not be NULL", K(ret));
} else if (OB_FAIL(print_basic_stmt())) {
LOG_WARN("fail to print basic stmt", K(ret), K(*stmt_));
} else { /*do nothing*/ }
return ret;
}
int ObDeleteStmtPrinter::print_basic_stmt()
{
int ret = OB_SUCCESS;
if (OB_ISNULL(stmt_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("stmt_ should not be NULL", K(ret));
} else if (OB_FAIL(print_with())) {
LOG_WARN("failed to print with", K(ret));
} else if (OB_FAIL(print_temp_table_as_cte())) {
LOG_WARN("failed to print cte", K(ret));
} else if (OB_FAIL(print_delete())) {
LOG_WARN("fail to print select", K(ret), K(*stmt_));
} else if (OB_FAIL(print_from())) {
LOG_WARN("fail to print from", K(ret), K(*stmt_));
} else if (OB_FAIL(print_where())) {
LOG_WARN("fail to print where", K(ret), K(*stmt_));
} else if (OB_FAIL(print_order_by())) {
LOG_WARN("fail to print order by", K(ret), K(*stmt_));
} else if (OB_FAIL(print_limit())) {
LOG_WARN("fail to print limit", K(ret), K(*stmt_));
} else if (OB_FAIL(print_returning())) {
LOG_WARN("fail to print_returning", K(ret), K(*stmt_));
} else {
// do-nothing
}
return ret;
}
int ObDeleteStmtPrinter::print_delete()
{
int ret = OB_SUCCESS;
if (OB_ISNULL(stmt_) || OB_ISNULL(buf_) || OB_ISNULL(pos_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("stmt_ is NULL or buf_ is NULL or pos_ is NULL", K(ret));
} else if (!stmt_->is_delete_stmt()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("Not a valid delete stmt", K(stmt_->get_stmt_type()), K(ret));
} else {
DATA_PRINTF("delete ");
if (OB_SUCC(ret)) {
if (OB_FAIL(print_hint())) { // hint
LOG_WARN("fail to print hint", K(ret), K(*stmt_));
}
}
}
return ret;
}
} //end of namespace sql
} //end of namespace oceanbase