Re: Relax requirement for INTO with SELECT in pl/pgsql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Relax requirement for INTO with SELECT in pl/pgsql
Date: 2016-03-21 22:49:55
Message-ID: 6820.1458600595@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com> writes:
> On 3/21/16 5:03 PM, Merlin Moncure wrote:
>> in Oracle, you'd simply do:
>> LogIt('I did something');

> It would be *great* if we could support that in plpgsql.

FWIW, I'm hesitant to just start accepting that syntax as if it were an
equivalent to "SELECT f(x)" or "PERFORM f(x)". I think that someday
we will want to have the ability to have pass-by-reference parameters
to functions, and that's a fundamentally incompatible behavior so it
ought to be invoked by a new syntax. I'd like to save "f(x)" as a
bare statement for that purpose. We could also consider inventing
"CALL f(x)"; but supposing that we already had both "CALL f(x)" (which
would allow x to be pass-by-ref and possibly modified) and "SELECT f(x)"
(which would not), which one would you assign bare "f(x)" to mean? It
should be "CALL f(x)", not least because that would be the semantics most
comparable to Oracle's behavior (since they have pass-by-ref parameters
already).

So, I'm -1 on not having any keyword at all. I have no objection
to Merlin's proposal though. I agree that PERFORM is starting to
look a bit silly, since it doesn't play with WITH for instance.

> While we're on the subject, it'd be great if variable := SELECT ...
> worked too.

It does, though you might need parens around the sub-select.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2016-03-21 23:10:08 Re: Relax requirement for INTO with SELECT in pl/pgsql
Previous Message Jim Nasby 2016-03-21 22:47:16 Re: [PATCH] we have added support for box type in SP-GiST index