Skip to content

Commit ea0e7cd

Browse files
committed
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 f82de5c. 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
1 parent 910eb61 commit ea0e7cd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/backend/commands/copyfrom.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,12 @@ BeginCopyFrom(ParseState *pstate,
14811481
cstate->need_transcoding = true;
14821482
cstate->conversion_proc = FindDefaultConversionProc(cstate->file_encoding,
14831483
GetDatabaseEncoding());
1484+
if (!OidIsValid(cstate->conversion_proc))
1485+
ereport(ERROR,
1486+
(errcode(ERRCODE_UNDEFINED_FUNCTION),
1487+
errmsg("default conversion function for encoding \"%s\" to \"%s\" does not exist",
1488+
pg_encoding_to_char(cstate->file_encoding),
1489+
pg_encoding_to_char(GetDatabaseEncoding()))));
14841490
}
14851491

14861492
cstate->copy_src = COPY_FILE; /* default */

0 commit comments

Comments
 (0)