1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-21 05:21:08 +03:00

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 9f8377f7a2
(16-era), in whose development thread there was no discussion on this
point.

Backpatch to 17.
This commit is contained in:
Alvaro Herrera
2024-08-08 15:17:11 -04:00
parent a7bf3e6685
commit 28b953f263
4 changed files with 66 additions and 29 deletions

View File

@@ -1444,8 +1444,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;
}
}
@@ -1486,8 +1487,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;
}
}