]> granicus.if.org Git - postgresql/commitdiff
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 9d096141a4283c0ebe16ce8b09bff611038bfae2..8f823e6e2e9f19d9f4ba779ebc69644b2436f24f 100644 (file)
@@ -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)