Re: BUG #19034: Recursive function with sql_body can replace an existing function but can not be created on it's own - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #19034: Recursive function with sql_body can replace an existing function but can not be created on it's own
Date
Msg-id 1030106.1756999498@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #19034: Recursive function with sql_body can replace an existing function but can not be created on it's own  (Yushu Chen <gentcys@gmail.com>)
Responses Re: BUG #19034: Recursive function with sql_body can replace an existing function but can not be created on it's own
List pgsql-bugs
Yushu Chen <gentcys@gmail.com> writes:
> I ran a test on my local postgresql server, resulting in the same error as
> described.
> However, I wonder about the necessity of supporting recursive functions in
> the CREATE FUNCTION command alone?

This is a general property of SQL-standard functions: all objects
referenced in the function body have to exist before creating the
function.  Poking holes in that property would largely defeat the
point of having this type of function.

You could imagine supporting the case by making CREATE FUNCTION act
as though it were
  CREATE FUNCTION foo ... AS $$something dummy$$;
  CREATE OR REPLACE FUNCTION foo ... BEGIN real-body END;
However, that would be a significant amount of work to implement
and it'd about double the cost of doing CREATE FUNCTION.  Note
that this cost would probably have to be incurred for every
SQL-standard function, as I see no good way to detect whether
the body contains a recursive reference in advance of parsing it.

Given that recursive SQL functions are a tiny-minority use case
and there's already a perfectly serviceable way to make them
(ie use an old-style body), I seriously doubt that we'll do
anything about this request.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Greg Sabino Mullane
Date:
Subject: Re: empty,query_id, pg_stat_activity
Next
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: BUG #19041: Logical replication locks wal processing