diff options
Diffstat (limited to 'src/bin/scripts/vacuumdb.c')
-rw-r--r-- | src/bin/scripts/vacuumdb.c | 136 |
1 files changed, 43 insertions, 93 deletions
diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c index 4f6917fd392..92f1ffe1479 100644 --- a/src/bin/scripts/vacuumdb.c +++ b/src/bin/scripts/vacuumdb.c @@ -237,7 +237,8 @@ main(int argc, char *argv[]) vacopts.process_toast = false; break; default: - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + /* getopt_long already emitted a complaint */ + pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } } @@ -256,54 +257,33 @@ main(int argc, char *argv[]) { pg_log_error("too many command-line arguments (first is \"%s\")", argv[optind]); - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } if (vacopts.analyze_only) { if (vacopts.full) - { - pg_log_error("cannot use the \"%s\" option when performing only analyze", - "full"); - exit(1); - } + pg_fatal("cannot use the \"%s\" option when performing only analyze", + "full"); if (vacopts.freeze) - { - pg_log_error("cannot use the \"%s\" option when performing only analyze", - "freeze"); - exit(1); - } + pg_fatal("cannot use the \"%s\" option when performing only analyze", + "freeze"); if (vacopts.disable_page_skipping) - { - pg_log_error("cannot use the \"%s\" option when performing only analyze", - "disable-page-skipping"); - exit(1); - } + pg_fatal("cannot use the \"%s\" option when performing only analyze", + "disable-page-skipping"); if (vacopts.no_index_cleanup) - { - pg_log_error("cannot use the \"%s\" option when performing only analyze", - "no-index-cleanup"); - exit(1); - } + pg_fatal("cannot use the \"%s\" option when performing only analyze", + "no-index-cleanup"); if (vacopts.force_index_cleanup) - { - pg_log_error("cannot use the \"%s\" option when performing only analyze", - "force-index-cleanup"); - exit(1); - } + pg_fatal("cannot use the \"%s\" option when performing only analyze", + "force-index-cleanup"); if (!vacopts.do_truncate) - { - pg_log_error("cannot use the \"%s\" option when performing only analyze", - "no-truncate"); - exit(1); - } + pg_fatal("cannot use the \"%s\" option when performing only analyze", + "no-truncate"); if (!vacopts.process_toast) - { - pg_log_error("cannot use the \"%s\" option when performing only analyze", - "no-process-toast"); - exit(1); - } + pg_fatal("cannot use the \"%s\" option when performing only analyze", + "no-process-toast"); /* allow 'and_analyze' with 'analyze_only' */ } @@ -311,26 +291,17 @@ main(int argc, char *argv[]) if (vacopts.parallel_workers >= 0) { if (vacopts.analyze_only) - { - pg_log_error("cannot use the \"%s\" option when performing only analyze", - "parallel"); - exit(1); - } + pg_fatal("cannot use the \"%s\" option when performing only analyze", + "parallel"); if (vacopts.full) - { - pg_log_error("cannot use the \"%s\" option when performing full vacuum", - "parallel"); - exit(1); - } + pg_fatal("cannot use the \"%s\" option when performing full vacuum", + "parallel"); } /* Prohibit --no-index-cleanup and --force-index-cleanup together */ if (vacopts.no_index_cleanup && vacopts.force_index_cleanup) - { - pg_log_error("cannot use the \"%s\" option with the \"%s\" option", - "no-index-cleanup", "force-index-cleanup"); - exit(1); - } + pg_fatal("cannot use the \"%s\" option with the \"%s\" option", + "no-index-cleanup", "force-index-cleanup"); /* fill cparams except for dbname, which is set below */ cparams.pghost = host; @@ -348,15 +319,9 @@ main(int argc, char *argv[]) if (alldb) { if (dbname) - { - pg_log_error("cannot vacuum all databases and a specific one at the same time"); - exit(1); - } + pg_fatal("cannot vacuum all databases and a specific one at the same time"); if (tables.head != NULL) - { - pg_log_error("cannot vacuum specific table(s) in all databases"); - exit(1); - } + pg_fatal("cannot vacuum specific table(s) in all databases"); cparams.dbname = maintenance_db; @@ -457,71 +422,56 @@ vacuum_one_database(ConnParams *cparams, if (vacopts->disable_page_skipping && PQserverVersion(conn) < 90600) { PQfinish(conn); - pg_log_error("cannot use the \"%s\" option on server versions older than PostgreSQL %s", - "disable-page-skipping", "9.6"); - exit(1); + pg_fatal("cannot use the \"%s\" option on server versions older than PostgreSQL %s", + "disable-page-skipping", "9.6"); } if (vacopts->no_index_cleanup && PQserverVersion(conn) < 120000) { PQfinish(conn); - pg_log_error("cannot use the \"%s\" option on server versions older than PostgreSQL %s", - "no-index-cleanup", "12"); - exit(1); + pg_fatal("cannot use the \"%s\" option on server versions older than PostgreSQL %s", + "no-index-cleanup", "12"); } if (vacopts->force_index_cleanup && PQserverVersion(conn) < 120000) { PQfinish(conn); - pg_log_error("cannot use the \"%s\" option on server versions older than PostgreSQL %s", - "force-index-cleanup", "12"); - exit(1); + pg_fatal("cannot use the \"%s\" option on server versions older than PostgreSQL %s", + "force-index-cleanup", "12"); } if (!vacopts->do_truncate && PQserverVersion(conn) < 120000) { PQfinish(conn); - pg_log_error("cannot use the \"%s\" option on server versions older than PostgreSQL %s", - "no-truncate", "12"); - exit(1); + pg_fatal("cannot use the \"%s\" option on server versions older than PostgreSQL %s", + "no-truncate", "12"); } if (!vacopts->process_toast && PQserverVersion(conn) < 140000) { PQfinish(conn); - pg_log_error("cannot use the \"%s\" option on server versions older than PostgreSQL %s", - "no-process-toast", "14"); - exit(1); + pg_fatal("cannot use the \"%s\" option on server versions older than PostgreSQL %s", + "no-process-toast", "14"); } if (vacopts->skip_locked && PQserverVersion(conn) < 120000) { PQfinish(conn); - pg_log_error("cannot use the \"%s\" option on server versions older than PostgreSQL %s", - "skip-locked", "12"); - exit(1); + pg_fatal("cannot use the \"%s\" option on server versions older than PostgreSQL %s", + "skip-locked", "12"); } if (vacopts->min_xid_age != 0 && PQserverVersion(conn) < 90600) - { - pg_log_error("cannot use the \"%s\" option on server versions older than PostgreSQL %s", - "--min-xid-age", "9.6"); - exit(1); - } + pg_fatal("cannot use the \"%s\" option on server versions older than PostgreSQL %s", + "--min-xid-age", "9.6"); if (vacopts->min_mxid_age != 0 && PQserverVersion(conn) < 90600) - { - pg_log_error("cannot use the \"%s\" option on server versions older than PostgreSQL %s", - "--min-mxid-age", "9.6"); - exit(1); - } + pg_fatal("cannot use the \"%s\" option on server versions older than PostgreSQL %s", + "--min-mxid-age", "9.6"); if (vacopts->parallel_workers >= 0 && PQserverVersion(conn) < 130000) - { - pg_log_error("cannot use the \"%s\" option on server versions older than PostgreSQL %s", - "--parallel", "13"); - exit(1); - } + pg_fatal("cannot use the \"%s\" option on server versions older than PostgreSQL %s", + "--parallel", "13"); if (!quiet) { |