patch 4.0

This commit is contained in:
wangzelin.wzl
2022-10-24 10:34:53 +08:00
parent 4ad6e00ec3
commit 93a1074b0c
10533 changed files with 2588271 additions and 2299373 deletions

View File

@ -15,11 +15,16 @@
#include "lib/utility/ob_print_utils.h"
#include "sql/parser/parse_node.h"
#include "lib/ob_name_def.h"
#include "common/ob_smart_call.h"
#include "lib/utility/ob_hang_fatal_error.h"
#include "share/ob_errno.h"
const char* get_type_name(int type);
namespace oceanbase {
namespace sql {
inline void databuff_print_stmt_location(char* buf, int64_t buf_len, int64_t& pos, const ObStmtLoc& obj)
namespace oceanbase
{
namespace sql
{
inline void databuff_print_stmt_location(char *buf, int64_t buf_len, int64_t &pos, const ObStmtLoc &obj)
{
if (obj.first_column_ > 0 || obj.last_column_ > 0 || obj.first_line_ > 0 || obj.last_line_ > 0) {
J_COMMA();
@ -27,65 +32,59 @@ inline void databuff_print_stmt_location(char* buf, int64_t buf_len, int64_t& po
int last_line = obj.last_line_;
int first_column = obj.first_column_;
int last_column = obj.last_column_;
J_KV(K(first_line), K(last_line), K(first_column), K(last_column));
J_KV(K(first_line),
K(last_line),
K(first_column),
K(last_column));
}
}
inline void databuff_print_obj(char* buf, const int64_t buf_len, int64_t& pos, const ParseNode& obj)
inline int databuff_print_obj(char *buf, const int64_t buf_len, int64_t &pos, const ParseNode &obj)
{
int ret = OB_SUCCESS;
J_OBJ_START();
J_KV(N_TYPE,
get_type_name(obj.type_),
N_INT_VALUE,
obj.value_,
N_STR_VALUE_LEN,
obj.str_len_,
N_STR_VALUE,
common::ObString(obj.str_len_, obj.str_value_));
J_KV(N_TYPE, get_type_name(obj.type_),
N_INT_VALUE, obj.value_,
N_STR_VALUE_LEN, obj.str_len_,
N_STR_VALUE, common::ObString(obj.str_len_, obj.str_value_));
databuff_print_stmt_location(buf, buf_len, pos, obj.stmt_loc_);
if (0 < obj.num_child_) {
J_COMMA();
J_NAME(N_CHILDREN);
J_COLON();
J_ARRAY_START();
for (int64_t i = 0; i < obj.num_child_; ++i) {
if (NULL == obj.children_[i]) {
J_EMPTY_OBJ();
} else {
databuff_print_obj(buf, buf_len, pos, *obj.children_[i]);
}
if (i != obj.num_child_ - 1) {
common::databuff_printf(buf, buf_len, pos, ", ");
} else if (OB_FAIL(SMART_CALL(databuff_print_obj(buf, buf_len, pos, *obj.children_[i])))) {
}
if (i != obj.num_child_ - 1) { common::databuff_printf(buf, buf_len, pos, ", "); }
}
J_ARRAY_END();
}
J_OBJ_END();
return ret;
}
inline void print_indent(char* buf, const int64_t buf_len, int64_t& pos, const int level)
inline void print_indent(char *buf, const int64_t buf_len, int64_t &pos, const int level)
{
for (int i = 0; i < level; ++i) {
for (int i=0; i<level; ++i) {
common::databuff_printf(buf, buf_len, pos, "\t");
}
}
inline void databuff_simple_print_obj(
char* buf, const int64_t buf_len, const int64_t index, int64_t& pos, const ParseNode* obj, int level)
inline void databuff_simple_print_obj(char *buf, const int64_t buf_len, const int64_t index, int64_t &pos, const ParseNode *obj, int level)
{
print_indent(buf, buf_len, pos, level);
if (NULL != obj) {
common::databuff_printf(buf,
buf_len,
pos,
"|--[%ld],[%s], str_value_=[%.*s], value=[%ld]\n",
index,
get_type_name(obj->type_),
int32_t(obj->str_len_),
obj->str_value_,
obj->value_);
buf_len, pos,
"|--[%ld],[%s], str_value_=[%.*s], value=[%ld]\n",
index,
get_type_name(obj->type_),
int32_t(obj->str_len_),
obj->str_value_,
obj->value_);
} else {
common::databuff_printf(buf, buf_len, pos, "|--[%ld]\n", index);
}
@ -96,9 +95,11 @@ inline void databuff_simple_print_obj(
}
}
class ObParserResultTreePrintWrapper {
class ObParserResultTreePrintWrapper
{
public:
explicit ObParserResultTreePrintWrapper(const ParseNode& parse_tree) : parse_tree_(parse_tree)
explicit ObParserResultTreePrintWrapper(const ParseNode &parse_tree)
:parse_tree_(parse_tree)
{}
int64_t to_string(char* buf, const int64_t buf_len) const
{
@ -107,33 +108,42 @@ public:
databuff_simple_print_obj(buf, buf_len, 0, pos, &parse_tree_, 0);
return pos;
}
private:
DISALLOW_COPY_AND_ASSIGN(ObParserResultTreePrintWrapper);
private:
const ParseNode& parse_tree_;
const ParseNode &parse_tree_;
};
class ObParserResultPrintWrapper {
class ObParserResultPrintWrapper
{
public:
explicit ObParserResultPrintWrapper(const ParseNode& parse_tree) : parse_tree_(parse_tree)
explicit ObParserResultPrintWrapper(const ParseNode &parse_tree)
:parse_tree_(parse_tree)
{}
int64_t to_string(char* buf, const int64_t buf_len) const
{
int64_t pos = 0;
databuff_print_obj(buf, buf_len, pos, parse_tree_);
int ret = OB_SUCCESS;
if (OB_FAIL(SMART_CALL(databuff_print_obj(buf, buf_len, pos, parse_tree_)))) {
pos = 0;
J_OBJ_START();
J_KV(N_TYPE, get_type_name(parse_tree_.type_),
N_INT_VALUE, parse_tree_.value_,
N_STR_VALUE_LEN, parse_tree_.str_len_,
N_STR_VALUE, common::ObString(parse_tree_.str_len_, parse_tree_.str_value_));
databuff_print_stmt_location(buf, buf_len, pos, parse_tree_.stmt_loc_);
J_OBJ_END();
}
return pos;
}
private:
DISALLOW_COPY_AND_ASSIGN(ObParserResultPrintWrapper);
private:
const ParseNode& parse_tree_;
const ParseNode &parse_tree_;
};
} // end namespace sql
} // end namespace oceanbase
} // end namespace sql
} // end namespace oceanbase
#endif /* _OB_PARSER_UTILS_H */