Re: PL/pgSQL PERFORM with CTE

From: "David E(dot) Wheeler" <david(at)justatheory(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, Marko Tiikkaja <marko(at)joh(dot)to>, Jan Wieck <JanWieck(at)yahoo(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PL/pgSQL PERFORM with CTE
Date: 2013-08-29 21:01:32
Message-ID: E7ADEE10-DE87-4E58-9967-4BA7366F1390@justatheory.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Aug 29, 2013, at 1:11 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:

> I cannot to say what is good design for PL/pgSQL - only I feel so some variant of RETURN statement is not good, because semantic is significantly different. And I see a increasing inconsistency between a original ADA and PL/pgSQL.

So YIELD or implement PL/PSM.

> Sure, When I am thinking about PSM, I am thinking about T-SQL syntax, but there is little bit simpler situation - there is a precedent in PSM implementation in MySQL and some other new databases.

PL/pgSQL is not PSM.

> so main problem is a impossibility to write
>
> BEGIN
> CALL fce()
>
> or
>
> BEGIN
> fce();
>
> A workaround in Postgres is PERFORM - and I really has nothing again to remove PERFORM for start of VOID functions!

No reason SELECT could not work just a well.

> A unhelpful error message has zero relevant to topic - just almost all in PL/pgSQL is SELECT.

Well, it was an aside, but points out another problem with PERFORM: It doesn't really exist. I gets replaced with SELECT internally, leading to confusing error messages. Solution: Allow SELECT instead of PERFORM.

> Do you would to remove a ":=" statement too?
>
> postgres=# do $$declare x int; begin x := notexisting(10); end; $$ ;
> ERROR: function notexisting(integer) does not exist
> LINE 1: SELECT notexisting(10)
> ^
> HINT: No function matches the given name and argument types. You might need to add explicit type casts.
> QUERY: SELECT notexisting(10)
> CONTEXT: PL/pgSQL function inline_code_block line 1 at assignment

I agree it would be nice if it didn't report SELECT there, but at least it's not *removing* anything from what you see in the source.

Best,

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2013-08-29 21:22:36 Re: PL/pgSQL PERFORM with CTE
Previous Message Pavel Stehule 2013-08-29 20:55:32 Re: Variadic aggregates vs. project policy