diff options
Diffstat (limited to 'src/bin/scripts')
-rw-r--r-- | src/bin/scripts/clusterdb.c | 15 | ||||
-rw-r--r-- | src/bin/scripts/createdb.c | 20 | ||||
-rw-r--r-- | src/bin/scripts/createuser.c | 12 | ||||
-rw-r--r-- | src/bin/scripts/dropdb.c | 7 | ||||
-rw-r--r-- | src/bin/scripts/dropuser.c | 7 | ||||
-rw-r--r-- | src/bin/scripts/pg_isready.c | 5 | ||||
-rw-r--r-- | src/bin/scripts/reindexdb.c | 65 | ||||
-rw-r--r-- | src/bin/scripts/vacuumdb.c | 136 |
8 files changed, 87 insertions, 180 deletions
diff --git a/src/bin/scripts/clusterdb.c b/src/bin/scripts/clusterdb.c index 4c97bd41d76..df1766679b5 100644 --- a/src/bin/scripts/clusterdb.c +++ b/src/bin/scripts/clusterdb.c @@ -109,7 +109,8 @@ main(int argc, char *argv[]) maintenance_db = pg_strdup(optarg); 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); } } @@ -128,7 +129,7 @@ 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); } @@ -144,16 +145,10 @@ main(int argc, char *argv[]) if (alldb) { if (dbname) - { - pg_log_error("cannot cluster all databases and a specific one at the same time"); - exit(1); - } + pg_fatal("cannot cluster all databases and a specific one at the same time"); if (tables.head != NULL) - { - pg_log_error("cannot cluster specific table(s) in all databases"); - exit(1); - } + pg_fatal("cannot cluster specific table(s) in all databases"); cparams.dbname = maintenance_db; diff --git a/src/bin/scripts/createdb.c b/src/bin/scripts/createdb.c index 0bffa2f3ee4..e523e58b218 100644 --- a/src/bin/scripts/createdb.c +++ b/src/bin/scripts/createdb.c @@ -135,7 +135,8 @@ main(int argc, char *argv[]) icu_locale = pg_strdup(optarg); 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); } } @@ -154,22 +155,16 @@ main(int argc, char *argv[]) default: pg_log_error("too many command-line arguments (first is \"%s\")", argv[optind + 2]); - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } if (locale) { if (lc_ctype) - { - pg_log_error("only one of --locale and --lc-ctype can be specified"); - exit(1); - } + pg_fatal("only one of --locale and --lc-ctype can be specified"); if (lc_collate) - { - pg_log_error("only one of --locale and --lc-collate can be specified"); - exit(1); - } + pg_fatal("only one of --locale and --lc-collate can be specified"); lc_ctype = locale; lc_collate = locale; } @@ -177,10 +172,7 @@ main(int argc, char *argv[]) if (encoding) { if (pg_char_to_encoding(encoding) < 0) - { - pg_log_error("\"%s\" is not a valid encoding name", encoding); - exit(1); - } + pg_fatal("\"%s\" is not a valid encoding name", encoding); } if (dbname == NULL) diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c index d6ce04a809b..bfba0d09d11 100644 --- a/src/bin/scripts/createuser.c +++ b/src/bin/scripts/createuser.c @@ -166,7 +166,8 @@ main(int argc, char *argv[]) interactive = true; 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); } } @@ -181,7 +182,7 @@ main(int argc, char *argv[]) default: pg_log_error("too many command-line arguments (first is \"%s\")", argv[optind + 1]); - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } @@ -274,11 +275,8 @@ main(int argc, char *argv[]) newuser, NULL); if (!encrypted_password) - { - pg_log_error("password encryption failed: %s", - PQerrorMessage(conn)); - exit(1); - } + pg_fatal("password encryption failed: %s", + PQerrorMessage(conn)); appendStringLiteralConn(&sql, encrypted_password, conn); PQfreemem(encrypted_password); } diff --git a/src/bin/scripts/dropdb.c b/src/bin/scripts/dropdb.c index 7e321dd11b1..afc00dac784 100644 --- a/src/bin/scripts/dropdb.c +++ b/src/bin/scripts/dropdb.c @@ -100,7 +100,8 @@ main(int argc, char *argv[]) maintenance_db = pg_strdup(optarg); 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); } } @@ -109,7 +110,7 @@ main(int argc, char *argv[]) { case 0: pg_log_error("missing required argument database name"); - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); case 1: dbname = argv[optind]; @@ -117,7 +118,7 @@ main(int argc, char *argv[]) default: pg_log_error("too many command-line arguments (first is \"%s\")", argv[optind + 1]); - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } diff --git a/src/bin/scripts/dropuser.c b/src/bin/scripts/dropuser.c index dfe4a5088c8..82c1f35ab23 100644 --- a/src/bin/scripts/dropuser.c +++ b/src/bin/scripts/dropuser.c @@ -91,7 +91,8 @@ main(int argc, char *argv[]) /* this covers the long options */ 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); } } @@ -106,7 +107,7 @@ main(int argc, char *argv[]) default: pg_log_error("too many command-line arguments (first is \"%s\")", argv[optind + 1]); - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } @@ -119,7 +120,7 @@ main(int argc, char *argv[]) else { pg_log_error("missing required argument role name"); - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } } diff --git a/src/bin/scripts/pg_isready.c b/src/bin/scripts/pg_isready.c index a7653b3eaf7..1aa834742d8 100644 --- a/src/bin/scripts/pg_isready.c +++ b/src/bin/scripts/pg_isready.c @@ -93,7 +93,8 @@ main(int argc, char **argv) pguser = pg_strdup(optarg); 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); /* * We need to make sure we don't return 1 here because someone @@ -107,7 +108,7 @@ 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); /* * We need to make sure we don't return 1 here because someone diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c index c292d432033..f3b03ec3256 100644 --- a/src/bin/scripts/reindexdb.c +++ b/src/bin/scripts/reindexdb.c @@ -170,7 +170,8 @@ main(int argc, char *argv[]) tablespace = pg_strdup(optarg); 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); } } @@ -189,7 +190,7 @@ 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); } @@ -205,30 +206,15 @@ main(int argc, char *argv[]) if (alldb) { if (dbname) - { - pg_log_error("cannot reindex all databases and a specific one at the same time"); - exit(1); - } + pg_fatal("cannot reindex all databases and a specific one at the same time"); if (syscatalog) - { - pg_log_error("cannot reindex all databases and system catalogs at the same time"); - exit(1); - } + pg_fatal("cannot reindex all databases and system catalogs at the same time"); if (schemas.head != NULL) - { - pg_log_error("cannot reindex specific schema(s) in all databases"); - exit(1); - } + pg_fatal("cannot reindex specific schema(s) in all databases"); if (tables.head != NULL) - { - pg_log_error("cannot reindex specific table(s) in all databases"); - exit(1); - } + pg_fatal("cannot reindex specific table(s) in all databases"); if (indexes.head != NULL) - { - pg_log_error("cannot reindex specific index(es) in all databases"); - exit(1); - } + pg_fatal("cannot reindex specific index(es) in all databases"); cparams.dbname = maintenance_db; @@ -238,26 +224,14 @@ main(int argc, char *argv[]) else if (syscatalog) { if (schemas.head != NULL) - { - pg_log_error("cannot reindex specific schema(s) and system catalogs at the same time"); - exit(1); - } + pg_fatal("cannot reindex specific schema(s) and system catalogs at the same time"); if (tables.head != NULL) - { - pg_log_error("cannot reindex specific table(s) and system catalogs at the same time"); - exit(1); - } + pg_fatal("cannot reindex specific table(s) and system catalogs at the same time"); if (indexes.head != NULL) - { - pg_log_error("cannot reindex specific index(es) and system catalogs at the same time"); - exit(1); - } + pg_fatal("cannot reindex specific index(es) and system catalogs at the same time"); if (concurrentCons > 1) - { - pg_log_error("cannot use multiple jobs to reindex system catalogs"); - exit(1); - } + pg_fatal("cannot use multiple jobs to reindex system catalogs"); if (dbname == NULL) { @@ -283,10 +257,7 @@ main(int argc, char *argv[]) * depending on the same relation. */ if (concurrentCons > 1 && indexes.head != NULL) - { - pg_log_error("cannot use multiple jobs to reindex indexes"); - exit(1); - } + pg_fatal("cannot use multiple jobs to reindex indexes"); if (dbname == NULL) { @@ -349,17 +320,15 @@ reindex_one_database(ConnParams *cparams, ReindexType type, if (concurrently && PQserverVersion(conn) < 120000) { PQfinish(conn); - pg_log_error("cannot use the \"%s\" option on server versions older than PostgreSQL %s", - "concurrently", "12"); - exit(1); + pg_fatal("cannot use the \"%s\" option on server versions older than PostgreSQL %s", + "concurrently", "12"); } if (tablespace && PQserverVersion(conn) < 140000) { PQfinish(conn); - pg_log_error("cannot use the \"%s\" option on server versions older than PostgreSQL %s", - "tablespace", "14"); - exit(1); + pg_fatal("cannot use the \"%s\" option on server versions older than PostgreSQL %s", + "tablespace", "14"); } if (!parallel) 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) { |