Make CREATE CONVERSION verify that a putative encoding conversion function
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 14 Nov 2008 17:40:56 +0000 (17:40 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 14 Nov 2008 17:40:56 +0000 (17:40 +0000)
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

index 2ab0759b4dcad62dc712517f837ea1b850fc8754..c26811ef454f5bc00ad5df759602e510f8304460 100644 (file)
@@ -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)