3
3
*
4
4
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
5
5
*
6
- * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.139 2008/05/14 19:10:29 tgl Exp $
6
+ * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.140 2008/08/16 01:36:35 tgl Exp $
7
7
*/
8
8
#include "postgres_fe.h"
9
9
#include "common.h"
@@ -880,16 +880,20 @@ SendQuery(const char *query)
880
880
/* If we made a temporary savepoint, possibly release/rollback */
881
881
if (on_error_rollback_savepoint )
882
882
{
883
- PGresult * svptres ;
883
+ const char * svptcmd ;
884
884
885
885
transaction_status = PQtransactionStatus (pset .db );
886
886
887
- /* We always rollback on an error */
888
887
if (transaction_status == PQTRANS_INERROR )
889
- svptres = PQexec (pset .db , "ROLLBACK TO pg_psql_temporary_savepoint" );
890
- /* If they are no longer in a transaction, then do nothing */
888
+ {
889
+ /* We always rollback on an error */
890
+ svptcmd = "ROLLBACK TO pg_psql_temporary_savepoint" ;
891
+ }
891
892
else if (transaction_status != PQTRANS_INTRANS )
892
- svptres = NULL ;
893
+ {
894
+ /* If they are no longer in a transaction, then do nothing */
895
+ svptcmd = NULL ;
896
+ }
893
897
else
894
898
{
895
899
/*
@@ -901,20 +905,27 @@ SendQuery(const char *query)
901
905
(strcmp (PQcmdStatus (results ), "SAVEPOINT" ) == 0 ||
902
906
strcmp (PQcmdStatus (results ), "RELEASE" ) == 0 ||
903
907
strcmp (PQcmdStatus (results ), "ROLLBACK" ) == 0 ))
904
- svptres = NULL ;
908
+ svptcmd = NULL ;
905
909
else
906
- svptres = PQexec ( pset . db , "RELEASE pg_psql_temporary_savepoint" ) ;
910
+ svptcmd = "RELEASE pg_psql_temporary_savepoint" ;
907
911
}
908
- if (svptres && PQresultStatus (svptres ) != PGRES_COMMAND_OK )
912
+
913
+ if (svptcmd )
909
914
{
910
- psql_error ("%s" , PQerrorMessage (pset .db ));
911
- PQclear (results );
915
+ PGresult * svptres ;
916
+
917
+ svptres = PQexec (pset .db , svptcmd );
918
+ if (PQresultStatus (svptres ) != PGRES_COMMAND_OK )
919
+ {
920
+ psql_error ("%s" , PQerrorMessage (pset .db ));
921
+ PQclear (svptres );
922
+
923
+ PQclear (results );
924
+ ResetCancelConn ();
925
+ return false;
926
+ }
912
927
PQclear (svptres );
913
- ResetCancelConn ();
914
- return false;
915
928
}
916
-
917
- PQclear (svptres );
918
929
}
919
930
920
931
PQclear (results );
0 commit comments