patch 4.0
This commit is contained in:
@ -17,112 +17,123 @@
|
||||
#include "lib/string/ob_sql_string.h"
|
||||
#include "common/ob_smart_call.h"
|
||||
#include "sql/ob_sql_utils.h"
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
#include "sql/dblink/ob_dblink_utils.h"
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
class ObTimeZoneInfo;
|
||||
}
|
||||
namespace sql {
|
||||
class ObRawExprPrinter {
|
||||
namespace sql
|
||||
{
|
||||
class ObRawExprPrinter
|
||||
{
|
||||
#define LEN_AND_PTR(str) (str.length()), (str.ptr())
|
||||
#define SQL_ESCAPE_STR(str) (to_cstring(ObHexEscapeSqlStr(str)))
|
||||
#define _DATA_PRINTF(...) databuff_printf(buf_, buf_len_, *pos_, __VA_ARGS__)
|
||||
#define DATA_PRINTF(...) \
|
||||
#define DATA_PRINTF(...) \
|
||||
do { \
|
||||
if (OB_SUCC(ret)) { \
|
||||
if (OB_ISNULL(buf_) || OB_ISNULL(pos_)) { \
|
||||
ret = OB_ERR_UNEXPECTED; \
|
||||
LOG_WARN("buf_ or pos_ is null", K(ret)); \
|
||||
} else if (OB_FAIL(_DATA_PRINTF(__VA_ARGS__))) { \
|
||||
LOG_WARN("fail to print", K(ret)); \
|
||||
} \
|
||||
} \
|
||||
} while(0) \
|
||||
|
||||
#define PRINT_IDENT(ident_str) \
|
||||
do { \
|
||||
if (OB_SUCC(ret) && OB_FAIL(ObSQLUtils::print_identifier( \
|
||||
buf_, buf_len_, (*pos_), print_params_.cs_type_, ident_str))) { \
|
||||
LOG_WARN("fail to print ident str", K(ret), K(ident_str)); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define CONVERT_CHARSET_FOR_RPINT(alloc, input_str) \
|
||||
do { \
|
||||
if (OB_SUCC(ret) && OB_FAIL(ObCharset::charset_convert(allocator, \
|
||||
input_str, \
|
||||
CS_TYPE_UTF8MB4_BIN, \
|
||||
print_params_.cs_type_, \
|
||||
input_str))) { \
|
||||
LOG_WARN("fail to gen ident str", K(ret), K(input_str)); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define PRINT_EXPR(expr) \
|
||||
do { \
|
||||
if (OB_SUCC(ret)) { \
|
||||
if (OB_ISNULL(buf_) || OB_ISNULL(pos_)) { \
|
||||
ret = OB_ERR_UNEXPECTED; \
|
||||
LOG_WARN("buf_ or pos_ is null", K(ret)); \
|
||||
} else if (OB_FAIL(_DATA_PRINTF(__VA_ARGS__))) { \
|
||||
LOG_WARN("fail to print", K(ret)); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
if (OB_SUCCESS == ret && OB_FAIL(SMART_CALL(print(expr)))) { \
|
||||
LOG_WARN("fail to print expr", K(ret)); \
|
||||
} \
|
||||
} while(0) \
|
||||
|
||||
#define PRINT_IDENT(ident_str) \
|
||||
do { \
|
||||
if (OB_SUCC(ret) && \
|
||||
OB_FAIL(ObSQLUtils::print_identifier(buf_, buf_len_, (*pos_), print_params_.cs_type_, ident_str))) { \
|
||||
LOG_WARN("fail to print ident str", K(ret), K(ident_str)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CONVERT_CHARSET_FOR_RPINT(alloc, input_str) \
|
||||
do { \
|
||||
if (OB_SUCC(ret) && OB_FAIL(ObCharset::charset_convert( \
|
||||
allocator, input_str, CS_TYPE_UTF8MB4_BIN, print_params_.cs_type_, input_str))) { \
|
||||
LOG_WARN("fail to gen ident str", K(ret), K(input_str)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define PRINT_EXPR(expr) \
|
||||
do { \
|
||||
if (OB_SUCCESS == ret && OB_FAIL(SMART_CALL(print(expr)))) { \
|
||||
LOG_WARN("fail to print expr", K(ret)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define SET_SYMBOL_IF_EMPTY(str) \
|
||||
do { \
|
||||
if (0 == symbol.length()) { \
|
||||
symbol = str; \
|
||||
} \
|
||||
} while (0)
|
||||
#define SET_SYMBOL_IF_EMPTY(str) \
|
||||
do { \
|
||||
if (0 == symbol.length()) { \
|
||||
symbol = str; \
|
||||
} \
|
||||
} while (0) \
|
||||
|
||||
// cast函数在parse阶段用到这两个宏, 但定义在sql_parse_tab.c中
|
||||
// cast函数功能不完善,beta之前不会修改, 先定义在这里
|
||||
// TODO@nijia.nj
|
||||
#define BINARY_COLLATION 63
|
||||
#define INVALID_COLLATION 0
|
||||
|
||||
public:
|
||||
ObRawExprPrinter();
|
||||
ObRawExprPrinter(
|
||||
char* buf, int64_t buf_len, int64_t* pos, common::ObObjPrintParams print_params = common::ObObjPrintParams());
|
||||
ObRawExprPrinter(char *buf, int64_t buf_len, int64_t *pos, common::ObObjPrintParams print_params = common::ObObjPrintParams(), const ParamStore *param_store = NULL);
|
||||
ObRawExprPrinter(bool);
|
||||
virtual ~ObRawExprPrinter();
|
||||
|
||||
void init(char* buf, int64_t buf_len, int64_t* pos, ObObjPrintParams print_params);
|
||||
int do_print(ObRawExpr* expr, ObStmtScope scope, bool only_column_namespace = false);
|
||||
|
||||
void init(char *buf, int64_t buf_len, int64_t *pos, ObObjPrintParams print_params, const ParamStore *param_store = NULL);
|
||||
// stmt中会出现若干expr, 为了避免反复实例化,这里将expr作为do_print的参数
|
||||
int do_print(ObRawExpr *expr, ObStmtScope scope, bool only_column_namespace = false, bool is_bool_expr = false);
|
||||
int set_gen_unique_name(GenUniqueAliasName *gen_unique_name);
|
||||
private:
|
||||
int print(ObRawExpr* expr);
|
||||
int print(ObRawExpr *expr);
|
||||
|
||||
int print(ObConstRawExpr* expr);
|
||||
int print(ObQueryRefRawExpr* expr);
|
||||
int print(ObColumnRefRawExpr* expr);
|
||||
int print(ObOpRawExpr* expr);
|
||||
int print(ObCaseOpRawExpr* expr);
|
||||
int print(ObSetOpRawExpr* expr);
|
||||
int print(ObAggFunRawExpr* expr);
|
||||
int print(ObSysFunRawExpr* expr);
|
||||
int print(ObWinFunRawExpr* expr);
|
||||
int print(ObFunMatchAgainst* expr);
|
||||
int print(ObPseudoColumnRawExpr* expr);
|
||||
int print(ObConstRawExpr *expr);
|
||||
int print(ObQueryRefRawExpr *expr);
|
||||
int print(ObColumnRefRawExpr *expr);
|
||||
int print(ObOpRawExpr *expr);
|
||||
int print(ObCaseOpRawExpr *expr);
|
||||
int print(ObSetOpRawExpr *expr);
|
||||
int print(ObAggFunRawExpr *expr);
|
||||
int print(ObSysFunRawExpr *expr);
|
||||
int print(ObUDFRawExpr *expr);
|
||||
int print(ObWinFunRawExpr *expr);
|
||||
int print(ObPseudoColumnRawExpr *expr);
|
||||
|
||||
int print_date_unit(ObRawExpr* expr);
|
||||
int print_get_format_unit(ObRawExpr* expr);
|
||||
int print_cast_type(ObRawExpr* expr);
|
||||
int print_date_unit(ObRawExpr *expr);
|
||||
int print_get_format_unit(ObRawExpr *expr);
|
||||
int print_cast_type(ObRawExpr *expr);
|
||||
|
||||
int print_partition_exprs(ObWinFunRawExpr* expr);
|
||||
int print_order_items(ObWinFunRawExpr* expr);
|
||||
int print_window_clause(ObWinFunRawExpr* expr);
|
||||
int print_partition_exprs(ObWinFunRawExpr *expr);
|
||||
int print_order_items(ObWinFunRawExpr *expr);
|
||||
int print_window_clause(ObWinFunRawExpr *expr);
|
||||
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObRawExprPrinter);
|
||||
|
||||
private:
|
||||
// data members
|
||||
char* buf_;
|
||||
char *buf_;
|
||||
int64_t buf_len_;
|
||||
// avoid to update pos_ between different printers(mainly ObRawExprPrinter
|
||||
// and ObSelectStmtPrinter), we definate pointer of pos_ rather than object
|
||||
int64_t* pos_;
|
||||
int64_t *pos_;
|
||||
ObStmtScope scope_;
|
||||
bool only_column_namespace_;
|
||||
bool is_inited_;
|
||||
const common::ObTimeZoneInfo* tz_info_;
|
||||
const common::ObTimeZoneInfo *tz_info_;
|
||||
ObObjPrintParams print_params_;
|
||||
const ParamStore* params_;
|
||||
const ParamStore *param_store_;
|
||||
GenUniqueAliasName *gen_unique_name_;
|
||||
};
|
||||
|
||||
} // end namespace sql
|
||||
} // end namespace oceanbase
|
||||
} // end namespace sql
|
||||
} // end namespace oceanbase
|
||||
|
||||
#endif // OCEANBASE_SQL_RESOLVER_EXPR_OB_RAW_EXPR_PRINTER_H_
|
||||
#endif // OCEANBASE_SQL_RESOLVER_EXPR_OB_RAW_EXPR_PRINTER_H_
|
||||
|
||||
Reference in New Issue
Block a user