From: Andres Freund <andres@anarazel.de>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: SQL-standard function body
Date: Wed, 7 Apr 2021 15:58:06 -0700
Message-ID: <20210407225806.majgznh4lk34hjvu@alap3.anarazel.de> (raw)
In-Reply-To: <E1lUEF5-00027L-N4@gemulon.postgresql.org>
References: <E1lUEF5-00027L-N4@gemulon.postgresql.org>
Hi,
On 2021-04-07 19:53:35 +0000, Peter Eisentraut wrote:
> SQL-standard function body
>
> This adds support for writing CREATE FUNCTION and CREATE PROCEDURE
> statements for language SQL with a function body that conforms to the
> SQL standard and is portable to other implementations.
>
> Instead of the PostgreSQL-specific AS $$ string literal $$ syntax,
> this allows writing out the SQL statements making up the body
> unquoted, either as a single statement:
>
> CREATE FUNCTION add(a integer, b integer) RETURNS integer
> LANGUAGE SQL
> RETURN a + b;
>
> or as a block
>
> CREATE PROCEDURE insert_data(a integer, b integer)
> LANGUAGE SQL
> BEGIN ATOMIC
> INSERT INTO tbl VALUES (a);
> INSERT INTO tbl VALUES (b);
> END;
>
> The function body is parsed at function definition time and stored as
> expression nodes in a new pg_proc column prosqlbody. So at run time,
> no further parsing is required.
>
> However, this form does not support polymorphic arguments, because
> there is no more parse analysis done at call time.
>
> Dependencies between the function and the objects it uses are fully
> tracked.
>
> A new RETURN statement is introduced. This can only be used inside
> function bodies. Internally, it is treated much like a SELECT
> statement.
>
> psql needs some new intelligence to keep track of function body
> boundaries so that it doesn't send off statements when it sees
> semicolons that are inside a function body.
>
> Tested-by: Jaime Casanova <jcasanov@systemguards.com.ec>
> Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>
> Discussion: https://www.postgresql.org/message-id/flat/1c11f1eb-f00c-43b7-799d-2d44132c02d7@2ndquadrant.com
>
> Branch
> ------
> master
>
> Details
> -------
> https://git.postgresql.org/pg/commitdiff/e717a9a18b2e34c9c40e5259ad4d31cd7e420750
This is turning the BF red:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=rhinoceros&dt=2021-04-07%2022%3A52%3A19
Might be force_parallel_mode=regress related.
Greetings,
Andres Freund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: andres@anarazel.de, peter@eisentraut.org
Subject: Re: pgsql: SQL-standard function body
In-Reply-To: <20210407225806.majgznh4lk34hjvu@alap3.anarazel.de>
References: <E1lUEF5-00027L-N4@gemulon.postgresql.org> <20210407225806.majgznh4lk34hjvu@alap3.anarazel.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox