aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-10-01 12:09:26 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2023-10-01 12:09:26 -0400
commit95fd5c89ffa18f6958f0135013046f798cced72b (patch)
treeca8f8850faecf93153b9e0e997bc8e838627e270 /src
parent5ae245664830219bab2e2ada11d2379875f4501a (diff)
downloadpostgresql-95fd5c89ffa18f6958f0135013046f798cced72b.tar.gz
postgresql-95fd5c89ffa18f6958f0135013046f798cced72b.zip
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/20230929163739.3bea46e5.pfortin@pfortin.com
Diffstat (limited to 'src')
-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 763cfb23728..c6dbd972761 100644
--- a/src/backend/commands/copyfrom.c
+++ b/src/backend/commands/copyfrom.c
@@ -1337,6 +1337,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 */