Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d8a0993

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 276393f commit d8a0993

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
@@ -1485,6 +1485,12 @@ BeginCopyFrom(ParseState *pstate,
14851485
cstate->need_transcoding = true;
14861486
cstate->conversion_proc = FindDefaultConversionProc(cstate->file_encoding,
14871487
GetDatabaseEncoding());
1488+
if (!OidIsValid(cstate->conversion_proc))
1489+
ereport(ERROR,
1490+
(errcode(ERRCODE_UNDEFINED_FUNCTION),
1491+
errmsg("default conversion function for encoding \"%s\" to \"%s\" does not exist",
1492+
pg_encoding_to_char(cstate->file_encoding),
1493+
pg_encoding_to_char(GetDatabaseEncoding()))));
14881494
}
14891495

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

0 commit comments

Comments
 (0)