[to #50277133] set column's synonym name recursively
This commit is contained in:
@ -432,14 +432,7 @@ int ObSelectStmtPrinter::print_select()
|
|||||||
}
|
}
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < select_stmt->get_select_item_size(); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < select_stmt->get_select_item_size(); ++i) {
|
||||||
const SelectItem &select_item = select_stmt->get_select_item(i);
|
const SelectItem &select_item = select_stmt->get_select_item(i);
|
||||||
if (NULL != select_item.expr_ && select_item.expr_->is_column_ref_expr()) {
|
OZ (set_synonym_name_recursively(select_item.expr_, stmt_));
|
||||||
ObColumnRefRawExpr *column_expr = static_cast<ObColumnRefRawExpr *>(select_item.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_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (select_item.is_implicit_added_ || select_item.implicit_filled_) {
|
if (select_item.is_implicit_added_ || select_item.implicit_filled_) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -503,6 +496,27 @@ 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,7 @@ 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:
|
||||||
|
|||||||
Reference in New Issue
Block a user