summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2023-10-01 16:09:26 +0000
committerTom Lane2023-10-01 16:09:26 +0000
commitd8a09939a3e830c7e2c3a68925d5f4c298dc3336 (patch)
tree8f663c6255c739301c264a0ef2d37d8bba93da42
parent276393f53efbf08f72190221e9c1ef2a28e7fc66 (diff)
In COPY FROM, fail cleanly when unsupported encoding conversion is needed.
In recent releases, such cases fail with "cache lookup failed for function 0" rather than complaining that the conversion function doesn't exist as prior versions did. Seems to be a consequence of sloppy refactoring in commit f82de5c46. Add the missing error check. Per report from Pierre Fortin. Back-patch to v14 where the oversight crept in. Discussion: https://postgr.es/m/[email protected]
-rw-r--r--src/backend/commands/copyfrom.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/commands/copyfrom.c b/src/backend/commands/copyfrom.c
index cf0fc9d794..cec80bacea 100644
--- a/src/backend/commands/copyfrom.c
+++ b/src/backend/commands/copyfrom.c
@@ -1485,6 +1485,12 @@ BeginCopyFrom(ParseState *pstate,
cstate->need_transcoding = true;
cstate->conversion_proc = FindDefaultConversionProc(cstate->file_encoding,
GetDatabaseEncoding());
+ if (!OidIsValid(cstate->conversion_proc))
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_FUNCTION),
+ errmsg("default conversion function for encoding \"%s\" to \"%s\" does not exist",
+ pg_encoding_to_char(cstate->file_encoding),
+ pg_encoding_to_char(GetDatabaseEncoding()))));
}
cstate->copy_src = COPY_FILE; /* default */