[CP] [to #52554591] fix returning expression print with table synonym
This commit is contained in:
parent
c577174ede
commit
825bc775d5
@ -56,6 +56,28 @@ void ObDMLStmtPrinter::init(char *buf, int64_t buf_len, int64_t *pos, ObDMLStmt
|
|||||||
print_cte_ = false;
|
print_cte_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ObDMLStmtPrinter::set_synonym_name_recursively(ObRawExpr * cur_expr, const ObDMLStmt *stmt)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_ISNULL(cur_expr) || OB_ISNULL(stmt)) {
|
||||||
|
} else if (cur_expr->is_column_ref_expr()) {
|
||||||
|
ObColumnRefRawExpr *column_expr = static_cast<ObColumnRefRawExpr *>(cur_expr);
|
||||||
|
const TableItem *table_item = stmt->get_table_item_by_id(column_expr->get_table_id());
|
||||||
|
if (NULL != table_item && table_item->alias_name_.empty()) {
|
||||||
|
column_expr->set_synonym_name(table_item->synonym_name_);
|
||||||
|
column_expr->set_synonym_db_name(table_item->synonym_db_name_);
|
||||||
|
}
|
||||||
|
} else if (cur_expr->get_param_count() > 0) {
|
||||||
|
for (int64_t param_idx = 0; param_idx < cur_expr->get_param_count(); ++param_idx) {
|
||||||
|
ObRawExpr * param_expr = cur_expr->get_param_expr(param_idx);
|
||||||
|
OZ (SMART_CALL(set_synonym_name_recursively(param_expr, stmt)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int ObDMLStmtPrinter::print_hint()
|
int ObDMLStmtPrinter::print_hint()
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
@ -1758,9 +1780,11 @@ int ObDMLStmtPrinter::print_returning()
|
|||||||
const ObIArray<ObRawExpr*> &returning_exprs = dml_stmt.get_returning_exprs();
|
const ObIArray<ObRawExpr*> &returning_exprs = dml_stmt.get_returning_exprs();
|
||||||
if (returning_exprs.count() > 0) {
|
if (returning_exprs.count() > 0) {
|
||||||
DATA_PRINTF(" returning ");
|
DATA_PRINTF(" returning ");
|
||||||
|
OZ (set_synonym_name_recursively(returning_exprs.at(0), stmt_));
|
||||||
OZ (expr_printer_.do_print(returning_exprs.at(0), T_NONE_SCOPE));
|
OZ (expr_printer_.do_print(returning_exprs.at(0), T_NONE_SCOPE));
|
||||||
for (uint64_t i = 1; OB_SUCC(ret) && i < returning_exprs.count(); ++i) {
|
for (uint64_t i = 1; OB_SUCC(ret) && i < returning_exprs.count(); ++i) {
|
||||||
DATA_PRINTF(",");
|
DATA_PRINTF(",");
|
||||||
|
OZ (set_synonym_name_recursively(returning_exprs.at(i), stmt_));
|
||||||
OZ (expr_printer_.do_print(returning_exprs.at(i), T_NONE_SCOPE));
|
OZ (expr_printer_.do_print(returning_exprs.at(i), T_NONE_SCOPE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,7 @@ public:
|
|||||||
void disable_print_temp_table_as_cte() { print_cte_ = false; }
|
void disable_print_temp_table_as_cte() { print_cte_ = false; }
|
||||||
void init(char *buf, int64_t buf_len, int64_t *pos, ObDMLStmt *stmt);
|
void init(char *buf, int64_t buf_len, int64_t *pos, ObDMLStmt *stmt);
|
||||||
virtual int do_print() = 0;
|
virtual int do_print() = 0;
|
||||||
|
static int set_synonym_name_recursively(ObRawExpr * cur_expr, const ObDMLStmt *stmt);
|
||||||
|
|
||||||
int print_from(bool need_from = true);
|
int print_from(bool need_from = true);
|
||||||
int print_semi_join();
|
int print_semi_join();
|
||||||
|
@ -496,27 +496,6 @@ int ObSelectStmtPrinter::print_select()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObSelectStmtPrinter::set_synonym_name_recursively(ObRawExpr *cur_expr, const ObDMLStmt *stmt) {
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_ISNULL(cur_expr) || OB_ISNULL(stmt)) {
|
|
||||||
} else if (cur_expr->is_column_ref_expr()) {
|
|
||||||
ObColumnRefRawExpr *column_expr = static_cast<ObColumnRefRawExpr *>(cur_expr);
|
|
||||||
const TableItem *table_item = stmt->get_table_item_by_id(column_expr->get_table_id());
|
|
||||||
if (NULL != table_item && table_item->alias_name_.empty()) {
|
|
||||||
column_expr->set_synonym_name(table_item->synonym_name_);
|
|
||||||
column_expr->set_synonym_db_name(table_item->synonym_db_name_);
|
|
||||||
}
|
|
||||||
} else if (cur_expr->get_param_count() > 0) {
|
|
||||||
for (int64_t param_idx = 0; param_idx < cur_expr->get_param_count(); ++param_idx) {
|
|
||||||
ObRawExpr * param_expr = cur_expr->get_param_expr(param_idx);
|
|
||||||
OZ (SMART_CALL(set_synonym_name_recursively(param_expr, stmt)));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//do nothing
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObSelectStmtPrinter::remove_double_quotation_for_string(ObString &alias_string,
|
int ObSelectStmtPrinter::remove_double_quotation_for_string(ObString &alias_string,
|
||||||
ObIAllocator &allocator)
|
ObIAllocator &allocator)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,6 @@ public:
|
|||||||
virtual int do_print();
|
virtual int do_print();
|
||||||
static int remove_double_quotation_for_string(ObString &alias_string, ObIAllocator &allocator);
|
static int remove_double_quotation_for_string(ObString &alias_string, ObIAllocator &allocator);
|
||||||
void set_column_list(common::ObIArray<common::ObString> *column_list) { column_list_ = column_list; }
|
void set_column_list(common::ObIArray<common::ObString> *column_list) { column_list_ = column_list; }
|
||||||
static int set_synonym_name_recursively(ObRawExpr * cur_expr, const ObDMLStmt *stmt);
|
|
||||||
bool need_print_alias() const { return force_col_alias_ || (is_root_stmt() && print_params_.print_origin_stmt_); }
|
bool need_print_alias() const { return force_col_alias_ || (is_root_stmt() && print_params_.print_origin_stmt_); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user