summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorÁlvaro Herrera2025-12-08 15:30:52 +0000
committerÁlvaro Herrera2025-12-08 15:30:52 +0000
commit502e256f2262351e92994878eea3332da64834b0 (patch)
tree8f5f5493a360a2dec5ed9d1d375a4e9abfb5255f /src
parent978cf02bb8caeafd6fe5178e67016ffd898599b4 (diff)
Unify error messages
No visible changes, just refactor how messages are constructed.
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/aclchk.c6
-rw-r--r--src/backend/commands/cluster.c4
-rw-r--r--src/backend/commands/dbcommands.c3
-rw-r--r--src/backend/commands/explain_state.c15
-rw-r--r--src/backend/commands/indexcmds.c4
-rw-r--r--src/backend/commands/vacuum.c6
-rw-r--r--src/backend/postmaster/checkpointer.c3
-rw-r--r--src/backend/replication/walsender.c4
-rw-r--r--src/bin/pg_basebackup/pg_createsubscriber.c6
-rw-r--r--src/bin/pg_dump/pg_dump.c40
-rw-r--r--src/bin/pg_dump/pg_dumpall.c16
-rw-r--r--src/bin/pg_dump/pg_restore.c39
12 files changed, 94 insertions, 52 deletions
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index cb496e018c5..5b410ff14c9 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -1207,7 +1207,8 @@ SetDefaultACL(InternalDefaultACL *iacls)
if (OidIsValid(iacls->nspid))
ereport(ERROR,
(errcode(ERRCODE_INVALID_GRANT_OPERATION),
- errmsg("cannot use IN SCHEMA clause when using GRANT/REVOKE ON SCHEMAS")));
+ errmsg("cannot use IN SCHEMA clause when using %s",
+ "GRANT/REVOKE ON SCHEMAS")));
objtype = DEFACLOBJ_NAMESPACE;
if (iacls->all_privs && this_privileges == ACL_NO_RIGHTS)
this_privileges = ACL_ALL_RIGHTS_SCHEMA;
@@ -1217,7 +1218,8 @@ SetDefaultACL(InternalDefaultACL *iacls)
if (OidIsValid(iacls->nspid))
ereport(ERROR,
(errcode(ERRCODE_INVALID_GRANT_OPERATION),
- errmsg("cannot use IN SCHEMA clause when using GRANT/REVOKE ON LARGE OBJECTS")));
+ errmsg("cannot use IN SCHEMA clause when using %s",
+ "GRANT/REVOKE ON LARGE OBJECTS")));
objtype = DEFACLOBJ_LARGEOBJECT;
if (iacls->all_privs && this_privileges == ACL_NO_RIGHTS)
this_privileges = ACL_ALL_RIGHTS_LARGEOBJECT;
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index b55221d44cd..d1e772efb72 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -124,8 +124,8 @@ cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel)
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("unrecognized CLUSTER option \"%s\"",
- opt->defname),
+ errmsg("unrecognized %s option \"%s\"",
+ "CLUSTER", opt->defname),
parser_errposition(pstate, opt->location)));
}
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 4d65e8c46c2..da85cd2d435 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -2354,7 +2354,8 @@ DropDatabase(ParseState *pstate, DropdbStmt *stmt)
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("unrecognized DROP DATABASE option \"%s\"", opt->defname),
+ errmsg("unrecognized %s option \"%s\"",
+ "DROP DATABASE", opt->defname),
parser_errposition(pstate, opt->location)));
}
diff --git a/src/backend/commands/explain_state.c b/src/backend/commands/explain_state.c
index 9fdeeab6436..dae256809d2 100644
--- a/src/backend/commands/explain_state.c
+++ b/src/backend/commands/explain_state.c
@@ -130,8 +130,8 @@ ParseExplainOptionList(ExplainState *es, List *options, ParseState *pstate)
else
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("unrecognized value for EXPLAIN option \"%s\": \"%s\"",
- opt->defname, p),
+ errmsg("unrecognized value for %s option \"%s\": \"%s\"",
+ "EXPLAIN", opt->defname, p),
parser_errposition(pstate, opt->location)));
}
else
@@ -155,15 +155,15 @@ ParseExplainOptionList(ExplainState *es, List *options, ParseState *pstate)
else
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("unrecognized value for EXPLAIN option \"%s\": \"%s\"",
- opt->defname, p),
+ errmsg("unrecognized value for %s option \"%s\": \"%s\"",
+ "EXPLAIN", opt->defname, p),
parser_errposition(pstate, opt->location)));
}
else if (!ApplyExtensionExplainOption(es, opt, pstate))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("unrecognized EXPLAIN option \"%s\"",
- opt->defname),
+ errmsg("unrecognized %s option \"%s\"",
+ "EXPLAIN", opt->defname),
parser_errposition(pstate, opt->location)));
}
@@ -195,7 +195,8 @@ ParseExplainOptionList(ExplainState *es, List *options, ParseState *pstate)
if (es->generic && es->analyze)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("EXPLAIN options ANALYZE and GENERIC_PLAN cannot be used together")));
+ errmsg("%s options %s and %s cannot be used together",
+ "EXPLAIN", "ANALYZE", "GENERIC_PLAN")));
/* if the summary was not set explicitly, set default value */
es->summary = (summary_set) ? es->summary : es->analyze;
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index a8033be4bff..d9cccb6ac18 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -2843,8 +2843,8 @@ ExecReindex(ParseState *pstate, const ReindexStmt *stmt, bool isTopLevel)
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("unrecognized REINDEX option \"%s\"",
- opt->defname),
+ errmsg("unrecognized %s option \"%s\"",
+ "REINDEX", opt->defname),
parser_errposition(pstate, opt->location)));
}
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index e785dd55ce5..29def1e94fa 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -232,7 +232,8 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel)
else if (!vacstmt->is_vacuumcmd)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("unrecognized ANALYZE option \"%s\"", opt->defname),
+ errmsg("unrecognized %s option \"%s\"",
+ "ANALYZE", opt->defname),
parser_errposition(pstate, opt->location)));
/* Parse options available on VACUUM */
@@ -294,7 +295,8 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel)
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("unrecognized VACUUM option \"%s\"", opt->defname),
+ errmsg("unrecognized %s option \"%s\"",
+ "VACUUM", opt->defname),
parser_errposition(pstate, opt->location)));
}
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index e84e8663e96..fa4d7438442 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -1027,7 +1027,8 @@ ExecCheckpoint(ParseState *pstate, CheckPointStmt *stmt)
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("unrecognized CHECKPOINT option \"%s\"", opt->defname),
+ errmsg("unrecognized %s option \"%s\"",
+ "CHECKPOINT", opt->defname),
parser_errposition(pstate, opt->location)));
}
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index a1b4301a4ee..0564c995500 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -1152,8 +1152,8 @@ parseCreateReplSlotOptions(CreateReplicationSlotCmd *cmd,
else
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("unrecognized value for CREATE_REPLICATION_SLOT option \"%s\": \"%s\"",
- defel->defname, action)));
+ errmsg("unrecognized value for %s option \"%s\": \"%s\"",
+ "CREATE_REPLICATION_SLOT", defel->defname, action)));
}
else if (strcmp(defel->defname, "reserve_wal") == 0)
{
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index 43dc6ff7693..ef6deec14af 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -2255,7 +2255,8 @@ main(int argc, char **argv)
if (bad_switch)
{
- pg_log_error("options %s and -a/--all cannot be used together", bad_switch);
+ pg_log_error("options %s and %s cannot be used together",
+ bad_switch, "-a/--all");
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
@@ -2386,7 +2387,8 @@ main(int argc, char **argv)
dbinfos.objecttypes_to_clean |= OBJECTTYPE_PUBLICATIONS;
else
{
- pg_log_error("invalid object type \"%s\" specified for --clean", cell->val);
+ pg_log_error("invalid object type \"%s\" specified for %s",
+ cell->val, "--clean");
pg_log_error_hint("The valid value is: \"%s\"", "publications");
exit(1);
}
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 2445085dbbd..24ad201af2f 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -831,23 +831,30 @@ main(int argc, char **argv)
/* reject conflicting "-only" options */
if (data_only && schema_only)
- pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-s/--schema-only", "-a/--data-only");
if (schema_only && statistics_only)
- pg_fatal("options -s/--schema-only and --statistics-only cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-s/--schema-only", "--statistics-only");
if (data_only && statistics_only)
- pg_fatal("options -a/--data-only and --statistics-only cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-a/--data-only", "--statistics-only");
/* reject conflicting "-only" and "no-" options */
if (data_only && no_data)
- pg_fatal("options -a/--data-only and --no-data cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-a/--data-only", "--no-data");
if (schema_only && no_schema)
- pg_fatal("options -s/--schema-only and --no-schema cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-s/--schema-only", "--no-schema");
if (statistics_only && no_statistics)
- pg_fatal("options --statistics-only and --no-statistics cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "--statistics-only", "--no-statistics");
/* reject conflicting "no-" options */
if (with_statistics && no_statistics)
- pg_fatal("options --statistics and --no-statistics cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "--statistics", "--no-statistics");
/* reject conflicting "-only" options */
if (data_only && with_statistics)
@@ -858,16 +865,20 @@ main(int argc, char **argv)
"-s/--schema-only", "--statistics");
if (schema_only && foreign_servers_include_patterns.head != NULL)
- pg_fatal("options -s/--schema-only and --include-foreign-data cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-s/--schema-only", "--include-foreign-data");
if (numWorkers > 1 && foreign_servers_include_patterns.head != NULL)
- pg_fatal("option --include-foreign-data is not supported with parallel backup");
+ pg_fatal("option %s is not supported with parallel backup",
+ "--include-foreign-data");
if (data_only && dopt.outputClean)
- pg_fatal("options -c/--clean and -a/--data-only cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-c/--clean", "-a/--data-only");
if (dopt.if_exists && !dopt.outputClean)
- pg_fatal("option --if-exists requires option -c/--clean");
+ pg_fatal("option %s requires option %s",
+ "--if-exists", "-c/--clean");
/*
* Set derivative flags. Ambiguous or nonsensical combinations, e.g.
@@ -887,7 +898,9 @@ main(int argc, char **argv)
* --rows-per-insert were specified.
*/
if (dopt.do_nothing && dopt.dump_inserts == 0)
- pg_fatal("option --on-conflict-do-nothing requires option --inserts, --rows-per-insert, or --column-inserts");
+ pg_fatal("option %s requires option %s, %s, or %s",
+ "--on-conflict-do-nothing",
+ "--inserts", "--rows-per-insert", "--column-inserts");
/* Identify archive format to emit */
archiveFormat = parseArchiveFormat(format, &archiveMode);
@@ -908,7 +921,8 @@ main(int argc, char **argv)
pg_fatal("invalid restrict key");
}
else if (dopt.restrict_key)
- pg_fatal("option --restrict-key can only be used with --format=plain");
+ pg_fatal("option %s can only be used with %s",
+ "--restrict-key", "--format=plain");
/*
* Custom and directory formats are compressed by default with gzip when
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index bb451c1bae1..8fa04930399 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -399,7 +399,9 @@ main(int argc, char *argv[])
if (database_exclude_patterns.head != NULL &&
(globals_only || roles_only || tablespaces_only))
{
- pg_log_error("option --exclude-database cannot be used together with -g/--globals-only, -r/--roles-only, or -t/--tablespaces-only");
+ pg_log_error("option %s cannot be used together with %s, %s, or %s",
+ "--exclude-database",
+ "-g/--globals-only", "-r/--roles-only", "-t/--tablespaces-only");
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit_nicely(1);
}
@@ -407,24 +409,28 @@ main(int argc, char *argv[])
/* Make sure the user hasn't specified a mix of globals-only options */
if (globals_only && roles_only)
{
- pg_log_error("options -g/--globals-only and -r/--roles-only cannot be used together");
+ pg_log_error("options %s and %s cannot be used together",
+ "-g/--globals-only", "-r/--roles-only");
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit_nicely(1);
}
if (globals_only && tablespaces_only)
{
- pg_log_error("options -g/--globals-only and -t/--tablespaces-only cannot be used together");
+ pg_log_error("options %s and %s cannot be used together",
+ "-g/--globals-only", "-t/--tablespaces-only");
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit_nicely(1);
}
if (if_exists && !output_clean)
- pg_fatal("option --if-exists requires option -c/--clean");
+ pg_fatal("option %s requires option %s",
+ "--if-exists", "-c/--clean");
if (roles_only && tablespaces_only)
{
- pg_log_error("options -r/--roles-only and -t/--tablespaces-only cannot be used together");
+ pg_log_error("options %s and %s cannot be used together",
+ "-r/--roles-only", "-t/--tablespaces-only");
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit_nicely(1);
}
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index c9776306c5c..84b8d410c9e 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -352,13 +352,15 @@ main(int argc, char **argv)
{
if (opts->filename)
{
- pg_log_error("options -d/--dbname and -f/--file cannot be used together");
+ pg_log_error("options %s and %s cannot be used together",
+ "-d/--dbname", "-f/--file");
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit_nicely(1);
}
if (opts->restrict_key)
- pg_fatal("options -d/--dbname and --restrict-key cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-d/--dbname", "--restrict-key");
opts->useDB = 1;
}
@@ -377,23 +379,30 @@ main(int argc, char **argv)
/* reject conflicting "-only" options */
if (data_only && schema_only)
- pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-s/--schema-only", "-a/--data-only");
if (schema_only && statistics_only)
- pg_fatal("options -s/--schema-only and --statistics-only cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-s/--schema-only", "--statistics-only");
if (data_only && statistics_only)
- pg_fatal("options -a/--data-only and --statistics-only cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-a/--data-only", "--statistics-only");
/* reject conflicting "-only" and "no-" options */
if (data_only && no_data)
- pg_fatal("options -a/--data-only and --no-data cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-a/--data-only", "--no-data");
if (schema_only && no_schema)
- pg_fatal("options -s/--schema-only and --no-schema cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-s/--schema-only", "--no-schema");
if (statistics_only && no_statistics)
- pg_fatal("options --statistics-only and --no-statistics cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "--statistics-only", "--no-statistics");
/* reject conflicting "no-" options */
if (with_statistics && no_statistics)
- pg_fatal("options --statistics and --no-statistics cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "--statistics", "--no-statistics");
/* reject conflicting "only-" options */
if (data_only && with_statistics)
@@ -404,17 +413,20 @@ main(int argc, char **argv)
"-s/--schema-only", "--statistics");
if (data_only && opts->dropSchema)
- pg_fatal("options -c/--clean and -a/--data-only cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-c/--clean", "-a/--data-only");
if (opts->single_txn && opts->txn_size > 0)
- pg_fatal("options -1/--single-transaction and --transaction-size cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-1/--single-transaction", "--transaction-size");
/*
* -C is not compatible with -1, because we can't create a database inside
* a transaction block.
*/
if (opts->createDB && opts->single_txn)
- pg_fatal("options -C/--create and -1/--single-transaction cannot be used together");
+ pg_fatal("options %s and %s cannot be used together",
+ "-C/--create", "-1/--single-transaction");
/* Can't do single-txn mode with multiple connections */
if (opts->single_txn && numWorkers > 1)
@@ -445,7 +457,8 @@ main(int argc, char **argv)
opts->no_subscriptions = no_subscriptions;
if (if_exists && !opts->dropSchema)
- pg_fatal("option --if-exists requires option -c/--clean");
+ pg_fatal("option %s requires option %s",
+ "--if-exists", "-c/--clean");
opts->if_exists = if_exists;
opts->strict_names = strict_names;