Fix a bug when create view with having clause

This commit is contained in:
xianyu-w
2023-08-22 03:44:38 +00:00
committed by ob-robot
parent 5e31c2aa1c
commit 7b6f4dae66
2 changed files with 3 additions and 2 deletions

View File

@ -792,7 +792,7 @@ int ObSelectStmtPrinter::print_having()
if (having_exprs_size > 0) { if (having_exprs_size > 0) {
DATA_PRINTF(" having "); DATA_PRINTF(" having ");
for (int64_t i = 0; OB_SUCC(ret) && i < having_exprs_size; ++i) { for (int64_t i = 0; OB_SUCC(ret) && i < having_exprs_size; ++i) {
if (OB_FAIL(expr_printer_.do_print(having_exprs.at(i), T_NONE_SCOPE))) { if (OB_FAIL(expr_printer_.do_print(having_exprs.at(i), T_HAVING_SCOPE))) {
LOG_WARN("fail to print having expr", K(ret)); LOG_WARN("fail to print having expr", K(ret));
} }
DATA_PRINTF(" and "); DATA_PRINTF(" and ");

View File

@ -102,7 +102,8 @@ int ObRawExprPrinter::print(ObRawExpr *expr)
&& scope_ != T_GROUP_SCOPE && scope_ != T_GROUP_SCOPE
&& scope_ != T_WHERE_SCOPE && scope_ != T_WHERE_SCOPE
&& scope_ != T_NONE_SCOPE && scope_ != T_NONE_SCOPE
&& scope_ != T_ORDER_SCOPE) { && scope_ != T_ORDER_SCOPE
&& (scope_ == T_HAVING_SCOPE && lib::is_mysql_mode())) {
//expr is a alias column ref //expr is a alias column ref
//alias column target list //alias column target list
PRINT_IDENT_WITH_QUOT(expr->get_alias_column_name()); PRINT_IDENT_WITH_QUOT(expr->get_alias_column_name());