Re: PL/pgSQL PERFORM with CTE

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: "David E(dot) Wheeler" <david(at)justatheory(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:22:36
Message-ID: CAFj8pRCYHty_W6_ziijd6FqATx9NoMsGppKP5zTiwX_SyNT8qA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2013/8/29 David E. Wheeler <david(at)justatheory(dot)com>

> 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.
>

We can discussed about syntax later - now it is offtopic and it is too
early - still we miss a procedures.

>
> > 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.
>

yes, I know it well - although some syntax is shared - CASE statements

>
> > 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.
>

No, originally, there was a target of compatibility with PL/SQL (more or
less in some time), and PL/SQL disallow unbound SELECT.

More - PL/SQL allow a direct procedure call - so some like PERFORM is
useless there.

>
> > 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.
>

It was a little bit a irony. I am think now so all problems about PERFORM
is based on porting PL/SQL environment (that was a classic simplified ADA)
to PostgreSQL without procedures. So PERFORM was a designed for evaluation
of something like procedures - but there was nothing in this time - a VOID
functions are younger. Without PERFORM we didn't do this talk.

Still I don't think so correct solution is enabling a unbound SELECTs, but
correct is a fix a PERFORM and remove a necessity to use a PERFORM for call
of VOID functions.

Regards

Pavel

>
> Best,
>
> David
>
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ants Aasma 2013-08-29 21:22:49 Re: Master-slave visibility order
Previous Message David E. Wheeler 2013-08-29 21:01:32 Re: PL/pgSQL PERFORM with CTE