File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -873,20 +873,24 @@ pgAutoCtlDebugNoticeProcessor(void *arg, const char *message)
873873bool
874874pgsql_begin (PGSQL * pgsql )
875875{
876+ /*
877+ * Indicate that we're running a transaction, so that the connection is not
878+ * closed after each query automatically. It also allows us to detect bugs
879+ * easily. We need to do this before executing BEGIN, because otherwise the
880+ * connection is closed after the BEGIN statement automatically.
881+ */
882+ pgsql -> connectionStatementType = PGSQL_CONNECTION_MULTI_STATEMENT ;
883+
876884 if (!pgsql_execute (pgsql , "BEGIN" ))
877885 {
878886 /*
879- * connection is closed by pgsql_execute already, so no need for
880- * further cleanup .
887+ * We need to manually call pgsql_finish to clean up here in case of
888+ * this failure, because we have set the statement type to MULTI .
881889 */
890+ pgsql_finish (pgsql );
882891 return false;
883892 }
884893
885- /*
886- * Indicate that we're in a transaction so that we can detect bugs easily.
887- */
888- pgsql -> connectionStatementType = PGSQL_CONNECTION_MULTI_STATEMENT ;
889-
890894 return true;
891895}
892896
You can’t perform that action at this time.
0 commit comments