Skip to content

Commit

Permalink
[CUBRID-24687] query result is strange, when there is hidden columns …
Browse files Browse the repository at this point in the history
…in the select list. (CUBRID#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().
  • Loading branch information
mhoh3963 committed Feb 7, 2024
1 parent 1fd1edb commit 1b420f0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/compat/db_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 1b420f0

Please sign in to comment.