From 498ee9ee2f4bc7d79f2d91cdd817b2a8f14a664f Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Thu, 8 Aug 2024 15:17:11 -0400 Subject: Refactor error messages to reduce duplication I also took the liberty of changing errmsg("COPY DEFAULT only available using COPY FROM") to errmsg("COPY %s cannot be used with %s", "DEFAULT", "COPY TO") because the original wording is unlike all other messages that indicate option incompatibility. This message was added by commit 9f8377f7a279 (16-era), in whose development thread there was no discussion on this point. Backpatch to 17. --- src/backend/commands/copyfrom.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/backend/commands/copyfrom.c') diff --git a/src/backend/commands/copyfrom.c b/src/backend/commands/copyfrom.c index c42a5621d5a..ca85270be6d 100644 --- a/src/backend/commands/copyfrom.c +++ b/src/backend/commands/copyfrom.c @@ -1454,8 +1454,9 @@ BeginCopyFrom(ParseState *pstate, if (!list_member_int(cstate->attnumlist, attnum)) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), - errmsg("FORCE_NOT_NULL column \"%s\" not referenced by COPY", - NameStr(attr->attname)))); + /*- translator: first %s is the name of a COPY option, e.g. FORCE_NOT_NULL */ + errmsg("%s column \"%s\" not referenced by COPY", + "FORCE_NOT_NULL", NameStr(attr->attname)))); cstate->opts.force_notnull_flags[attnum - 1] = true; } } @@ -1496,8 +1497,9 @@ BeginCopyFrom(ParseState *pstate, if (!list_member_int(cstate->attnumlist, attnum)) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), - errmsg("FORCE_NULL column \"%s\" not referenced by COPY", - NameStr(attr->attname)))); + /*- translator: first %s is the name of a COPY option, e.g. FORCE_NOT_NULL */ + errmsg("%s column \"%s\" not referenced by COPY", + "FORCE_NULL", NameStr(attr->attname)))); cstate->opts.force_null_flags[attnum - 1] = true; } } -- cgit v1.2.3