bugfix : dot notation input with *
This commit is contained in:
@ -2491,6 +2491,7 @@ int ObSelectResolver::resolve_star(const ParseNode *node)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSelectStmt *select_stmt = get_select_stmt();
|
||||
const share::schema::ObTableSchema *table_schema = NULL;
|
||||
|
||||
if (OB_ISNULL(node) || OB_ISNULL(session_info_)
|
||||
|| OB_ISNULL(select_stmt) || OB_ISNULL(params_.expr_factory_)) {
|
||||
@ -2546,6 +2547,9 @@ int ObSelectResolver::resolve_star(const ParseNode *node)
|
||||
}
|
||||
} else if (node->type_ == T_COLUMN_REF && node->children_[2]->type_ == T_STAR) {
|
||||
ObQualifiedName column_ref;
|
||||
bool is_json_wildcard_column = false; // special input : tab_name.column_name.*
|
||||
bool is_column_name_equal = false;
|
||||
const TableItem* tab_item = NULL;
|
||||
ObNameCaseMode case_mode = OB_NAME_CASE_INVALID;
|
||||
if (OB_FAIL(session_info_->get_name_case_mode(case_mode))) {
|
||||
LOG_WARN("fail to get name case mode", K(ret));
|
||||
@ -2558,30 +2562,57 @@ int ObSelectResolver::resolve_star(const ParseNode *node)
|
||||
column_ref.tbl_name_, table_items))) {
|
||||
LOG_WARN("get all matched table failed", K(ret));
|
||||
} else if (table_items.count() <= 0) {
|
||||
ret = OB_ERR_BAD_TABLE;
|
||||
ObString table_name = concat_table_name(column_ref.database_name_, column_ref.tbl_name_);
|
||||
LOG_USER_ERROR(OB_ERR_BAD_TABLE, table_name.length(), table_name.ptr());
|
||||
ret = OB_SUCCESS;
|
||||
ObString db_name;
|
||||
if (lib::is_oracle_mode() && OB_FAIL(select_stmt->get_all_table_item_by_tname(session_info_, db_name,
|
||||
column_ref.database_name_, table_items))) {
|
||||
LOG_WARN("get all matched table failed", K(ret));
|
||||
} else if (lib::is_mysql_mode() || table_items.count() <= 0) {
|
||||
ret = OB_ERR_BAD_TABLE;
|
||||
} else {
|
||||
is_json_wildcard_column = true;
|
||||
}
|
||||
if (ret != 0) { // according to oracle , need cover error code
|
||||
ret = OB_ERR_BAD_TABLE;
|
||||
ObString table_name = concat_table_name(column_ref.database_name_, column_ref.tbl_name_);
|
||||
LOG_USER_ERROR(OB_ERR_BAD_TABLE, table_name.length(), table_name.ptr());
|
||||
}
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < table_items.count(); ++i) {
|
||||
target_list.reset();
|
||||
if (OB_ISNULL(table_items.at(i))) {
|
||||
tab_item = table_items.at(i);
|
||||
if (OB_ISNULL(tab_item)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(table_items.at(i)), K(ret));
|
||||
} else if (OB_FAIL(expand_target_list(*table_items.at(i), target_list))) {
|
||||
LOG_WARN("resolve table columns failed", K(ret), K(table_items.at(i)), K(i));
|
||||
LOG_WARN("get unexpected null", K(tab_item), K(ret));
|
||||
} else if (OB_FAIL(expand_target_list(*tab_item, target_list))) {
|
||||
LOG_WARN("resolve table columns failed", K(ret), K(tab_item), K(i));
|
||||
} else if (is_json_wildcard_column) {
|
||||
if (OB_FAIL(schema_checker_->get_table_schema(session_info_->get_effective_tenant_id(), tab_item->ref_id_, table_schema))) {
|
||||
ret = OB_TABLE_NOT_EXIST;
|
||||
LOG_WARN("get table schema failed", K_(tab_item->table_name), K(tab_item->ref_id_), K(ret));
|
||||
} else if (OB_ISNULL(table_schema)) {
|
||||
ret = OB_TABLE_NOT_EXIST;
|
||||
LOG_WARN("get table schema failed", K_(tab_item->table_name), K(tab_item->ref_id_), K(ret));
|
||||
} else if (OB_NOT_NULL(table_schema->get_column_schema(column_ref.tbl_name_))
|
||||
&& !table_schema->get_column_schema(column_ref.tbl_name_)->is_json()) {
|
||||
ret = OB_ERR_TABLE_NAME_NOT_IN_LIST;
|
||||
LOG_WARN("table name not in from list", K(ret), K(column_ref.tbl_name_));
|
||||
}
|
||||
}
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < target_list.count(); ++j) {
|
||||
if (OB_FAIL(select_stmt->add_select_item(target_list.at(j)))) {
|
||||
is_column_name_equal = is_json_wildcard_column & (0 != column_ref.tbl_name_.case_compare(target_list.at(j).alias_name_));
|
||||
if (!is_column_name_equal && OB_FAIL(select_stmt->add_select_item(target_list.at(j)))) {
|
||||
LOG_WARN("add select item to select stmt failed", K(ret));
|
||||
} else if (is_only_full_group_by_on(session_info_->get_sql_mode())) {
|
||||
//如果是only full group by,所有target list中的列都必须检查是否满足group约束
|
||||
if (OB_FAIL(standard_group_checker_.add_unsettled_column(target_list.at(j).expr_))) {
|
||||
if (is_column_name_equal) { // target column not equal with current column without judge
|
||||
} else if (OB_FAIL(standard_group_checker_.add_unsettled_column(target_list.at(j).expr_))) {
|
||||
LOG_WARN("add unsettled column failed", K(ret));
|
||||
} else if (OB_FAIL(standard_group_checker_.add_unsettled_expr(target_list.at(j).expr_))) {
|
||||
LOG_WARN("add unsettled expr to standard group checker failed", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_SUCC(ret) && !is_column_name_equal) {
|
||||
ret = column_namespace_checker_.check_column_existence_in_using_clause(
|
||||
table_items.at(i)->table_id_, target_list.at(j).expr_name_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user