summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2019-03-11 16:00:13 +0100
committerMichael Meskes <meskes@postgresql.org>2019-03-11 16:00:13 +0100
commit98bdaab0d918169a36d64a06667a809c673ec065 (patch)
tree1096e372ab0f5ac0fa3f92883ab04edec79d57d7 /src
parent3c067154471100ae691d1a7b2659ee439ab7b96d (diff)
downloadpostgresql-98bdaab0d918169a36d64a06667a809c673ec065.tar.gz
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>
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/ecpg/ecpglib/cursor.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/interfaces/ecpg/ecpglib/cursor.c b/src/interfaces/ecpg/ecpglib/cursor.c
index ae67bfe8e0..133d62321b 100644
--- a/src/interfaces/ecpg/ecpglib/cursor.c
+++ b/src/interfaces/ecpg/ecpglib/cursor.c
@@ -150,20 +150,23 @@ ECPGclose(const char *cursor_name,
con = ecpg_get_connection(real_connection_name);
- /* check the existence of the cursor in the connection */
- if (find_cursor(cursor_name, con) == false)
- {
- ecpg_raise(lineno, ECPG_INVALID_CURSOR, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL);
- return false;
- }
-
+ /* send the query to backend */
va_start(args, query);
status = ecpg_do(lineno, compat, force_indicator, real_connection_name, questionmarks, st, query, args);
va_end(args);
- remove_cursor(cursor_name, con);
+ /* if it fails, raise an error */
+ if (!status)
+ {
+ ecpg_raise(lineno, ECPG_INVALID_CURSOR, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL);
+ return false;
+ }
+
+ /* check the existence of the cursor in the connection */
+ if (find_cursor(cursor_name, con) == true)
+ remove_cursor(cursor_name, con);
return status;
}