From 7781053c4c66546ca462a837cfe456e9d13e29df Mon Sep 17 00:00:00 2001 From: Mike MyungHwan Oh Date: Wed, 7 Feb 2024 13:27:07 +0900 Subject: [PATCH] [CUBRID-24687] query result is strange, when there is hidden columns in the select list. (#4934) * [CUBRID-24687] query result is strange, when there is hidden columns in the select list http://jira.cubrid.org/browse/CBRD-24687 **Description** The query result is strange, when there is hidden columns in ther select list. This is the case when sp is used in the order by clause, as in the following query. (ex : SELECT col1, col2) FROM tbl1 ORDER BY intTest(col1)) **Resolution** - fix to use query_type instead of col_cnt at db_query_column_count(). --- src/compat/db_query.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/compat/db_query.c b/src/compat/db_query.c index 8acc4716f70..fac798ad7fb 100644 --- a/src/compat/db_query.c +++ b/src/compat/db_query.c @@ -3150,6 +3150,9 @@ db_query_tuple_count (DB_QUERY_RESULT * result) int db_query_column_count (DB_QUERY_RESULT * result) { + DB_QUERY_TYPE *t; + int num_cols = 0; + CHECK_1ARG_MINUSONE (result); if (result->status == T_CLOSED) @@ -3164,7 +3167,12 @@ db_query_column_count (DB_QUERY_RESULT * result) return -1; } - return (DB_OID_INCLUDED (result)) ? (result->col_cnt - 1) : result->col_cnt; + for (t = result->query_type; t != NULL; t = db_query_format_next (t)) + { + num_cols++; + } + + return num_cols; } #if defined(WINDOWS) || defined (ENABLE_UNUSED_FUNCTION)