Re: PL/pgSQL PERFORM with CTE

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, "David E(dot) Wheeler" <david(at)justatheory(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PL/pgSQL PERFORM with CTE
Date: 2013-08-20 12:48:35
Message-ID: CAHyXU0zAyGi5Jp-X_NrDCW0c4cxgk3LzFV08qbeq9D_Qf-sUew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Aug 20, 2013 at 7:44 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
>
>
>
> 2013/8/20 Merlin Moncure <mmoncure(at)gmail(dot)com>
>>
>> On Tue, Aug 20, 2013 at 7:25 AM, Andres Freund <andres(at)2ndquadrant(dot)com>
>> wrote:
>> > On 2013-08-20 14:15:55 +0200, David E. Wheeler wrote:
>> >> Hi Pavel,
>> >>
>> >> On Aug 20, 2013, at 2:11 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
>> >> wrote:
>> >>
>> >> >> david=# DO $$
>> >> >> david$# BEGIN
>> >> >> david$# WITH now AS (SELECT now())
>> >> >> david$# PERFORM * from now;
>> >> >> david$# END;
>> >> >> david$# $$;
>> >> >> ERROR: syntax error at or near "PERFORM"
>> >> >> LINE 4: PERFORM * from now;
>> >> >> ^
>> >> >> Parser bug in PL/pgSQL, perhaps?
>> >> >
>> >> > no
>> >> >
>> >> > you cannot use a PL/pgSQL statement inside SQL statement.
>> >>
>> >> Well, there ought to be *some* way to tell PL/pgSQL to discard the
>> >> result. Right now I am adding a variable to select into but never otherwise
>> >> use. Inelegant, IMHO. Perhaps I’m missing some other way to do it?
>> >>
>> >> If so, it would help if the hint suggesting the use of PERFORM pointed
>> >> to such alternatives.
>> >
>> > Not that that's elegant but IIRC PERFORM (WITH ...) ought to work. I
>> > don't think the intermingled plpgsql/sql grammars allow a nice way right
>> > now.
>>
>> I think the way forward is to remove the restriction such that data
>> returning queries must be PERFORM'd
>
>
> I disagree, current rule has sense.

Curious what your thinking is there.

merlin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2013-08-20 12:51:21 Re: ALTER SYSTEM SET command to change postgresql.conf parameters (RE: Proposal for Allow postgresql.conf values to be changed via SQL [review])
Previous Message David E. Wheeler 2013-08-20 12:46:44 Re: PL/pgSQL PERFORM with CTE