From ee8ac44ab4b3063fe4d657ac2fba478b4b559b9f Mon Sep 17 00:00:00 2001 From: shparkcubrid Date: Tue, 23 Apr 2024 14:33:29 +0900 Subject: [PATCH 1/2] add check for order_by --- src/parser/view_transform.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/parser/view_transform.c b/src/parser/view_transform.c index 4f6c7e6fb17..ec47b324d8d 100644 --- a/src/parser/view_transform.c +++ b/src/parser/view_transform.c @@ -1735,7 +1735,8 @@ mq_is_pushable_subquery (PARSER_CONTEXT * parser, PT_NODE * subquery, PT_NODE * /* determine if class_spec is the only spec in the statement */ is_rownum_only = mq_is_rownum_only_predicate (parser, statement_spec, mainquery, order_by, subquery, class_); - is_only_spec = ((statement_spec->next == NULL && (pred == NULL || is_rownum_only)) ? true : false); + is_only_spec = + ((statement_spec->next == NULL && ((pred == NULL && order_by == NULL) || is_rownum_only)) ? true : false); /* check if orderby_for set to PT_EXPR_INFO_ROWNUM_ONLY */ orderby_for = subquery->info.query.orderby_for; From 61aa0dbe0cb454bb43232fddafd29c02e07f8268 Mon Sep 17 00:00:00 2001 From: shparkcubrid Date: Tue, 23 Apr 2024 17:05:25 +0900 Subject: [PATCH 2/2] add check for order_by of subquery and mainquery --- src/parser/view_transform.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/parser/view_transform.c b/src/parser/view_transform.c index ec47b324d8d..c3553a61b76 100644 --- a/src/parser/view_transform.c +++ b/src/parser/view_transform.c @@ -1736,7 +1736,8 @@ mq_is_pushable_subquery (PARSER_CONTEXT * parser, PT_NODE * subquery, PT_NODE * /* determine if class_spec is the only spec in the statement */ is_rownum_only = mq_is_rownum_only_predicate (parser, statement_spec, mainquery, order_by, subquery, class_); is_only_spec = - ((statement_spec->next == NULL && ((pred == NULL && order_by == NULL) || is_rownum_only)) ? true : false); + ((statement_spec->next == NULL && (pred == NULL || is_rownum_only) + && (subquery->info.query.order_by == NULL || order_by == NULL)) ? true : false); /* check if orderby_for set to PT_EXPR_INFO_ROWNUM_ONLY */ orderby_for = subquery->info.query.orderby_for;