@@ -484,6 +484,11 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
484
484
else
485
485
free_slot = slots ;
486
486
487
+ /*
488
+ * Execute the vacuum. If not in parallel mode, this terminates the
489
+ * program in case of an error. (The parallel case handles query
490
+ * errors in GetQueryResult through GetIdleSlot.)
491
+ */
487
492
run_vacuum_command (free_slot -> connection , sql .data ,
488
493
echo , dbname , tabname , progname , parallel );
489
494
@@ -661,21 +666,27 @@ prepare_vacuum_command(PQExpBuffer sql, PGconn *conn, vacuumingOptions *vacopts,
661
666
/*
662
667
* Execute a vacuum/analyze command to the server.
663
668
*
664
- * Result status is checked only if 'async' is false.
669
+ * Any errors during command execution are reported to stderr. If async is
670
+ * false, this function exits the program after reporting the error.
665
671
*/
666
672
static void
667
673
run_vacuum_command (PGconn * conn , const char * sql , bool echo ,
668
674
const char * dbname , const char * table ,
669
675
const char * progname , bool async )
670
676
{
677
+ bool status ;
678
+
671
679
if (async )
672
680
{
673
681
if (echo )
674
682
printf ("%s\n" , sql );
675
683
676
- PQsendQuery (conn , sql );
684
+ status = PQsendQuery (conn , sql ) == 1 ;
677
685
}
678
- else if (!executeMaintenanceCommand (conn , sql , echo ))
686
+ else
687
+ status = executeMaintenanceCommand (conn , sql , echo );
688
+
689
+ if (!status )
679
690
{
680
691
if (table )
681
692
fprintf (stderr ,
@@ -684,8 +695,12 @@ run_vacuum_command(PGconn *conn, const char *sql, bool echo,
684
695
else
685
696
fprintf (stderr , _ ("%s: vacuuming of database \"%s\" failed: %s" ),
686
697
progname , dbname , PQerrorMessage (conn ));
687
- PQfinish (conn );
688
- exit (1 );
698
+
699
+ if (!async )
700
+ {
701
+ PQfinish (conn );
702
+ exit (1 );
703
+ }
689
704
}
690
705
}
691
706
0 commit comments