From 4f38b9a80acdc9514ab03a912e275f6d84319597 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 14 Nov 2008 17:40:56 +0000 Subject: [PATCH] Make CREATE CONVERSION verify that a putative encoding conversion function returns VOID. This is the last of the easy fixes I recommended in 11870.1218838360@sss.pgh.pa.us --- the others got done awhile ago but I forgot about this one. --- src/backend/commands/conversioncmds.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/commands/conversioncmds.c b/src/backend/commands/conversioncmds.c index 9d096141a4..8f823e6e2e 100644 --- a/src/backend/commands/conversioncmds.c +++ b/src/backend/commands/conversioncmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.35 2008/06/19 00:46:04 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.36 2008/11/14 17:40:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -82,6 +82,13 @@ CreateConversionCommand(CreateConversionStmt *stmt) funcoid = LookupFuncName(func_name, sizeof(funcargs) / sizeof(Oid), funcargs, false); + /* Check it returns VOID, else it's probably the wrong function */ + if (get_func_rettype(funcoid) != VOIDOID) + ereport(ERROR, + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmsg("encoding conversion function %s must return type \"void\"", + NameListToString(func_name)))); + /* Check we have EXECUTE rights for the function */ aclresult = pg_proc_aclcheck(funcoid, GetUserId(), ACL_EXECUTE); if (aclresult != ACLCHECK_OK)