]> granicus.if.org Git - postgresql/commitdiff
Remove obsolete prohibition on function name matching a column name.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 18 Jun 2018 15:57:33 +0000 (11:57 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 18 Jun 2018 15:57:33 +0000 (11:57 -0400)
ProcedureCreate formerly threw an error if the function to be created
has one argument of composite type and the function name matches some
column of the composite type.  This was a (very non-bulletproof) defense
against creating situations where f(x) and x.f are ambiguous.  But we
don't really need such a defense in the wake of commit b97a3465d, which
allows us to deal with such situations fairly cleanly.  This behavior
also created a dump-and-reload hazard, since a function might be
rejected if a conflicting column name had been added to the input
composite type later.  Hence, let's just drop the check.

Discussion: https://postgr.es/m/CAOW5sYa3Wp7KozCuzjOdw6PiOYPi6D=VvRybtH2S=2C0SVmRmA@mail.gmail.com

src/backend/catalog/pg_proc.c

index d78335291194d7fad7432ca8bf285d85b2a245b9..9b4015d0d4a9e695bac5e76244b5f652d8708013 100644 (file)
@@ -108,7 +108,6 @@ ProcedureCreate(const char *procedureName,
        bool            nulls[Natts_pg_proc];
        Datum           values[Natts_pg_proc];
        bool            replaces[Natts_pg_proc];
-       Oid                     relid;
        NameData        procname;
        TupleDesc       tupDesc;
        bool            is_update;
@@ -254,20 +253,6 @@ ProcedureCreate(const char *procedureName,
                                 errmsg("unsafe use of pseudo-type \"internal\""),
                                 errdetail("A function returning \"internal\" must have at least one \"internal\" argument.")));
 
-       /*
-        * don't allow functions of complex types that have the same name as
-        * existing attributes of the type
-        */
-       if (parameterCount == 1 &&
-               OidIsValid(parameterTypes->values[0]) &&
-               (relid = typeOrDomainTypeRelid(parameterTypes->values[0])) != InvalidOid &&
-               get_attnum(relid, procedureName) != InvalidAttrNumber)
-               ereport(ERROR,
-                               (errcode(ERRCODE_DUPLICATE_COLUMN),
-                                errmsg("\"%s\" is already an attribute of type %s",
-                                               procedureName,
-                                               format_type_be(parameterTypes->values[0]))));
-
        if (paramModes != NULL)
        {
                /*