Skip to content

Commit 98bdaab

Browse files
author
Michael Meskes
committed
Fix ecpglib regression that made it impossible to close a cursor that was
opened in a prepared statement. Patch by: "Kuroda, Hayato" <kuroda.hayato@jp.fujitsu.com>
1 parent 3c06715 commit 98bdaab

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/interfaces/ecpg/ecpglib/cursor.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,20 +150,23 @@ ECPGclose(const char *cursor_name,
150150

151151
con = ecpg_get_connection(real_connection_name);
152152

153-
/* check the existence of the cursor in the connection */
154-
if (find_cursor(cursor_name, con) == false)
155-
{
156-
ecpg_raise(lineno, ECPG_INVALID_CURSOR, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL);
157-
return false;
158-
}
159-
153+
/* send the query to backend */
160154
va_start(args, query);
161155

162156
status = ecpg_do(lineno, compat, force_indicator, real_connection_name, questionmarks, st, query, args);
163157

164158
va_end(args);
165159

166-
remove_cursor(cursor_name, con);
160+
/* if it fails, raise an error */
161+
if (!status)
162+
{
163+
ecpg_raise(lineno, ECPG_INVALID_CURSOR, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL);
164+
return false;
165+
}
166+
167+
/* check the existence of the cursor in the connection */
168+
if (find_cursor(cursor_name, con) == true)
169+
remove_cursor(cursor_name, con);
167170

168171
return status;
169172
}

0 commit comments

Comments
 (0)