[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) {
|
||||
const SelectItem &select_item = select_stmt->get_select_item(i);
|
||||
if (NULL != select_item.expr_ && select_item.expr_->is_column_ref_expr()) {
|
||||
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_);
|
||||
}
|
||||
}
|
||||
OZ (set_synonym_name_recursively(select_item.expr_, stmt_));
|
||||
if (select_item.is_implicit_added_ || select_item.implicit_filled_) {
|
||||
continue;
|
||||
}
|
||||
@ -503,6 +496,27 @@ int ObSelectStmtPrinter::print_select()
|
||||
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,
|
||||
ObIAllocator &allocator)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user