[CP] fix distinct clob bug

This commit is contained in:
sdc 2023-10-13 03:43:46 +00:00 committed by ob-robot
parent b660977d13
commit 75b04d6a2b
3 changed files with 21 additions and 29 deletions

View File

@ -1037,6 +1037,13 @@ int ObStaticEngineCG::generate_spec(
if (OB_ISNULL(raw_expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("null pointer", K(ret));
} else if (is_oracle_mode() && OB_UNLIKELY(ObLongTextType == raw_expr->get_data_type()
|| ObLobType == raw_expr->get_data_type())) {
ret = OB_ERR_INVALID_TYPE_FOR_OP;
LOG_WARN("select distinct lob not allowed", K(ret));
} else if (is_oracle_mode() && OB_UNLIKELY(ObJsonType == raw_expr->get_data_type())) {
ret = OB_ERR_INVALID_CMP_OP;
LOG_WARN("select distinct json not allowed", K(ret));
} else if (raw_expr->is_const_expr()) {
// distinct const value, 这里需要注意:distinct 1被跳过了,
// 但ObMergeDistinct中,如果没有distinct列,则默认所有值都相等,这个语义正好是符合预期的。
@ -1105,6 +1112,13 @@ int ObStaticEngineCG::generate_spec(
if (OB_ISNULL(raw_expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("null pointer", K(ret));
} else if (is_oracle_mode() && OB_UNLIKELY(ObLongTextType == raw_expr->get_data_type()
|| ObLobType == raw_expr->get_data_type())) {
ret = OB_ERR_INVALID_TYPE_FOR_OP;
LOG_WARN("select distinct lob not allowed", K(ret));
} else if (is_oracle_mode() && OB_UNLIKELY(ObJsonType == raw_expr->get_data_type())) {
ret = OB_ERR_INVALID_CMP_OP;
LOG_WARN("select distinct json not allowed", K(ret));
} else if (raw_expr->is_const_expr()) {
// distinct const value, 这里需要注意:distinct 1被跳过了,
// 但ObMergeDistinct中,如果没有distinct列,则默认所有值都相等,这个语义正好是符合预期的。
@ -1693,6 +1707,13 @@ int ObStaticEngineCG::fill_sort_funcs(
// other udt types not supported, xmltype does not have order or map member function
ret = OB_ERR_NO_ORDER_MAP_SQL;
LOG_WARN("cannot ORDER objects without MAP or ORDER method", K(ret));
} else if (is_oracle_mode() && OB_UNLIKELY(ObLongTextType == expr->datum_meta_.type_
|| ObLobType == expr->datum_meta_.type_)) {
ret = OB_ERR_INVALID_TYPE_FOR_OP;
LOG_WARN("order by lob not allowed", K(ret));
} else if (is_oracle_mode() && OB_UNLIKELY(ObJsonType == expr->datum_meta_.type_)) {
ret = OB_ERR_INVALID_CMP_OP;
LOG_WARN("order by json not allowed", K(ret));
} else {
ObSortCmpFunc cmp_func;
cmp_func.cmp_func_ = ObDatumFuncs::get_nullsafe_cmp_func(expr->datum_meta_.type_,

View File

@ -960,33 +960,6 @@ int ObSelectResolver::check_order_by()
return ret;
}
int ObSelectResolver::check_field_list()
{
int ret = OB_SUCCESS;
ObSelectStmt *select_stmt = get_select_stmt();
if (! is_oracle_mode()) {
} else if (OB_ISNULL(select_stmt)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("select stmt is null", K(ret));
} else if (select_stmt->has_distinct()) {
common::ObIArray<SelectItem> &select_items = select_stmt->get_select_items();
for (int64_t i = 0; OB_SUCC(ret) && i < select_items.count(); i++) {
ObRawExpr *expr = NULL;
if (OB_ISNULL(expr = select_items.at(i).expr_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("select expr is null", K(ret));
} else if (ObLongTextType == expr->get_data_type() || ObLobType == expr->get_data_type()) {
ret = OB_ERR_INVALID_TYPE_FOR_OP;
LOG_WARN("select distinct lob not allowed", K(ret));
} else if (lib::is_oracle_mode() && ObJsonType == expr->get_data_type()) {
ret = OB_ERR_INVALID_CMP_OP;
LOG_WARN("select distinct json not allowed", K(ret));
}
}
}
return ret;
}
int ObSelectResolver::search_connect_group_by_clause(const ParseNode &parent,
const ParseNode *&start_with,
const ParseNode *&connect_by,
@ -1175,7 +1148,6 @@ int ObSelectResolver::resolve_normal_query(const ParseNode &parse_tree)
OZ( select_stmt->formalize_stmt(session_info_) );
//统一为本层的表达式进行only full group by验证,避免检查的逻辑过于分散
OZ( check_field_list() );
OZ( check_group_by() );
OZ( check_order_by() );
OZ( check_pseudo_columns() );

View File

@ -248,7 +248,6 @@ protected:
virtual int check_in_sysview(bool &in_sysview) const override;
int check_group_by();
int check_order_by();
int check_field_list();
int check_pseudo_columns();
int check_grouping_columns();
int check_grouping_columns(ObSelectStmt &stmt, ObRawExpr *&expr);