further fix for identifier is too long
This commit is contained in:
@ -89,7 +89,7 @@ int ObInsertAllStmtPrinter::print_multi_insert_stmt()
|
|||||||
OB_ISNULL(sub_select_stmt = table_item->ref_query_)) {
|
OB_ISNULL(sub_select_stmt = table_item->ref_query_)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("sub select stmt is null", K(ret), K(table_item), K(sub_select_stmt));
|
LOG_WARN("sub select stmt is null", K(ret), K(table_item), K(sub_select_stmt));
|
||||||
} else if (OB_FAIL(print_subquery(sub_select_stmt, PRINT_CTE))) {
|
} else if (OB_FAIL(print_subquery(sub_select_stmt, PRINT_CTE | FORCE_COL_ALIAS))) {
|
||||||
LOG_WARN("failed to print subquery");
|
LOG_WARN("failed to print subquery");
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG("print multi insert stmt complete");
|
LOG_DEBUG("print multi insert stmt complete");
|
||||||
|
|||||||
@ -6482,18 +6482,19 @@ int ObSelectResolver::check_auto_gen_column_names() {
|
|||||||
if (OB_ISNULL(select_stmt)) {
|
if (OB_ISNULL(select_stmt)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("select stmt is null", K(ret));
|
LOG_WARN("select stmt is null", K(ret));
|
||||||
} else if (OB_FAIL(recursive_check_auto_gen_column_names(select_stmt))) {
|
} else if (OB_FAIL(recursive_check_auto_gen_column_names(select_stmt, true))) {
|
||||||
LOG_WARN("fail to check auto gen column names", K(ret));
|
LOG_WARN("fail to check auto gen column names", K(ret));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObSelectResolver::recursive_check_auto_gen_column_names(ObSelectStmt *select_stmt) {
|
int ObSelectResolver::recursive_check_auto_gen_column_names(ObSelectStmt *select_stmt,
|
||||||
|
bool in_outer_stmt) {
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
ObSEArray<ObSelectStmt*, 4> child_stmts;
|
ObSEArray<ObSelectStmt*, 4> child_stmts;
|
||||||
if (OB_ISNULL(select_stmt)) {
|
if (OB_ISNULL(select_stmt) || OB_ISNULL(allocator_)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("select stmt is null", K(ret));
|
LOG_WARN("get unexpected null", K(ret), K(select_stmt), K(allocator_));
|
||||||
} else if (OB_FAIL(select_stmt->get_child_stmts(child_stmts))) {
|
} else if (OB_FAIL(select_stmt->get_child_stmts(child_stmts))) {
|
||||||
LOG_WARN("fail to get child stmts", K(ret));
|
LOG_WARN("fail to get child stmts", K(ret));
|
||||||
}
|
}
|
||||||
@ -6502,7 +6503,7 @@ int ObSelectResolver::recursive_check_auto_gen_column_names(ObSelectStmt *select
|
|||||||
if (OB_ISNULL(child_stmt)) {
|
if (OB_ISNULL(child_stmt)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("child select stmt is null", K(ret), K(i));
|
LOG_WARN("child select stmt is null", K(ret), K(i));
|
||||||
} else if (OB_FAIL(SMART_CALL(recursive_check_auto_gen_column_names(child_stmt)))) {
|
} else if (OB_FAIL(SMART_CALL(recursive_check_auto_gen_column_names(child_stmt, false)))) {
|
||||||
LOG_WARN("fail to check child stmt", K(ret), K(i));
|
LOG_WARN("fail to check child stmt", K(ret), K(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6512,8 +6513,10 @@ int ObSelectResolver::recursive_check_auto_gen_column_names(ObSelectStmt *select
|
|||||||
if (OB_ISNULL(select_item) || OB_ISNULL(select_item->expr_)) {
|
if (OB_ISNULL(select_item) || OB_ISNULL(select_item->expr_)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("select item expr is null", K(ret), K(select_item));
|
LOG_WARN("select item expr is null", K(ret), K(select_item));
|
||||||
|
} else if (OB_FAIL(recursive_update_column_name(select_stmt, select_item->expr_))) {
|
||||||
|
LOG_WARN("fail to update column name", K(ret), KPC(select_item));
|
||||||
} else if (select_item->alias_name_.length() > static_cast<size_t>(OB_MAX_COLUMN_NAME_LENGTH)) {
|
} else if (select_item->alias_name_.length() > static_cast<size_t>(OB_MAX_COLUMN_NAME_LENGTH)) {
|
||||||
if (lib::is_oracle_mode()) {
|
if (lib::is_oracle_mode() && in_outer_stmt) {
|
||||||
ret = OB_ERR_TOO_LONG_IDENT;
|
ret = OB_ERR_TOO_LONG_IDENT;
|
||||||
LOG_WARN("auto generated alias is too long", K(ret), K(select_item->alias_name_.length()), K(select_item->alias_name_));
|
LOG_WARN("auto generated alias is too long", K(ret), K(select_item->alias_name_.length()), K(select_item->alias_name_));
|
||||||
} else {
|
} else {
|
||||||
@ -6526,15 +6529,33 @@ int ObSelectResolver::recursive_check_auto_gen_column_names(ObSelectStmt *select
|
|||||||
ObString col_name;
|
ObString col_name;
|
||||||
if (OB_FAIL(ob_write_string(*allocator_, tmp_col_name, col_name))) {
|
if (OB_FAIL(ob_write_string(*allocator_, tmp_col_name, col_name))) {
|
||||||
LOG_WARN("Can not malloc space for constraint name", K(ret));
|
LOG_WARN("Can not malloc space for constraint name", K(ret));
|
||||||
} else if (OB_FALSE_IT(select_item->alias_name_.assign_ptr(col_name.ptr(), col_name.length()))) {
|
} else {
|
||||||
} else if (select_item->expr_->is_column_ref_expr()) {
|
select_item->alias_name_.assign_ptr(col_name.ptr(), col_name.length());
|
||||||
ObColumnRefRawExpr *col_ref_expr = static_cast<ObColumnRefRawExpr*>(select_item->expr_);
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObSelectResolver::recursive_update_column_name(ObSelectStmt *select_stmt,
|
||||||
|
ObRawExpr *expr) {
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_ISNULL(select_stmt) || OB_ISNULL(expr) || OB_ISNULL(allocator_)) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("get unexpected null", K(ret), K(select_stmt), K(expr), K(allocator_));
|
||||||
|
} else if (expr->is_column_ref_expr()) {
|
||||||
|
ObColumnRefRawExpr *col_ref_expr = static_cast<ObColumnRefRawExpr*>(expr);
|
||||||
TableItem *table_item = NULL;
|
TableItem *table_item = NULL;
|
||||||
ObSelectStmt *ref_stmt = NULL;
|
ObSelectStmt *ref_stmt = NULL;
|
||||||
SelectItem *ref_select_item = NULL;
|
SelectItem *ref_select_item = NULL;
|
||||||
|
ObString col_name;
|
||||||
if (OB_ISNULL(table_item = select_stmt->get_table_item_by_id(col_ref_expr->get_table_id()))) {
|
if (OB_ISNULL(table_item = select_stmt->get_table_item_by_id(col_ref_expr->get_table_id()))) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("table item is null", K(ret));
|
LOG_WARN("table item is null", K(ret));
|
||||||
|
} else if (!table_item->is_generated_table()) {
|
||||||
|
// do nothing
|
||||||
} else if (OB_ISNULL(ref_stmt = table_item->ref_query_)) {
|
} else if (OB_ISNULL(ref_stmt = table_item->ref_query_)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("ref query stmt is null", K(ret));
|
LOG_WARN("ref query stmt is null", K(ret));
|
||||||
@ -6546,8 +6567,10 @@ int ObSelectResolver::recursive_check_auto_gen_column_names(ObSelectStmt *select
|
|||||||
} else {
|
} else {
|
||||||
col_ref_expr->get_column_name().assign_ptr(col_name.ptr(), col_name.length());
|
col_ref_expr->get_column_name().assign_ptr(col_name.ptr(), col_name.length());
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
}
|
for (int64_t i = 0; OB_SUCC(ret) && i < expr->get_param_count(); ++i) {
|
||||||
|
if (OB_FAIL(SMART_CALL(recursive_update_column_name(select_stmt, expr->get_param_expr(i))))) {
|
||||||
|
LOG_WARN("fail to update child column name", K(ret), K(i), KPC(expr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -348,7 +348,8 @@ private:
|
|||||||
|
|
||||||
int resolve_shared_order_item(OrderItem &order_item, ObSelectStmt *select_stmt);
|
int resolve_shared_order_item(OrderItem &order_item, ObSelectStmt *select_stmt);
|
||||||
int adjust_recursive_cte_table_columns(const ObSelectStmt* parent_stmt, ObSelectStmt *right_stmt);
|
int adjust_recursive_cte_table_columns(const ObSelectStmt* parent_stmt, ObSelectStmt *right_stmt);
|
||||||
int recursive_check_auto_gen_column_names(ObSelectStmt *select_stmt);
|
int recursive_check_auto_gen_column_names(ObSelectStmt *select_stmt, bool in_outer_stmt);
|
||||||
|
int recursive_update_column_name(ObSelectStmt *select_stmt, ObRawExpr *expr);
|
||||||
protected:
|
protected:
|
||||||
// data members
|
// data members
|
||||||
/*these member is only for with clause*/
|
/*these member is only for with clause*/
|
||||||
|
|||||||
Reference in New Issue
Block a user