Re: SQL-standard function body - Mailing list pgsql-hackers

From Noah Misch
Subject Re: SQL-standard function body
Date
Msg-id 20210410033014.GA993491@rfd.leadboat.com
Whole thread Raw
In response to Re: SQL-standard function body  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: SQL-standard function body
List pgsql-hackers
On Fri, Apr 09, 2021 at 12:09:43PM -0400, Tom Lane wrote:
> Finally, 0003 might be a bit controversial: it changes the stored
> prosrc for new-style SQL functions to be the query text of the CREATE
> FUNCTION command.  The main argument I can see being made against this
> is that it'll bloat the pg_proc entry.  But I think that that's
> not a terribly reasonable concern

Such storage cost should be acceptable, but ...

> The real value of 0003 of course would be to get an error cursor at
> runtime

A key benefit of $SUBJECT is the function body following DDL renames:

create table foo ();
insert into foo default values;
create function count_it() returns int begin atomic return (select count(*) from foo); end;
select count_it();
insert into foo default values;
alter table foo rename to some_new_long_table_name;
select count_it();  -- still works

After the rename, any stored prosrc is obsolete.  To show accurate error
cursors, deparse prosqlbody and use that in place of prosrc.



pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: pgsql: Move tablespace path re-creation from the makefiles to pg_regres
Next
From: Amit Kapila
Date:
Subject: Re: Replication slot stats misgivings