Re: PL/pgSQL support to define multi variables once - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: PL/pgSQL support to define multi variables once
Date
Msg-id CAFj8pRCfry3Uq02wXSpwz4WRpSpy7+LFzGANwfP3xcZO+4Bk5Q@mail.gmail.com
Whole thread Raw
In response to Re: PL/pgSQL support to define multi variables once  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers



2014-06-13 17:32 GMT+02:00 Tom Lane <tgl@sss.pgh.pa.us>:
David G Johnston <david.g.johnston@gmail.com> writes:
> Tom Lane-2 wrote
>> At the very least I think we should stay away from this syntax until
>> the SQL committee understand it better than they evidently do today.
>> I don't want to implement it and then get caught by a future
>> clarification that resolves the issue differently than we did.

> Its not quite as unclear as you make it out to be:

Yes it is.

> Though I suppose someone might want to do the following:
> random_1, random_2, random_3 float := random(1234);
> The decision to copy, not re-execute, is safer to use as the behavior and
> force explicitness in the re-execute situation.

I would agree with that argument, if we both sat on the SQL committee and
were discussing how to resolve the ambiguity.  We don't, and we have no
good way to predict what they'll do (when and if they do anything :-().

The problem I've got is that a literal reading of the spec seems to
suggest multiple evaluation, since "DV" appears to refer to the syntactic
construct representing the initializer, not its evaluated value.  It's
hard to argue that the spec isn't telling us to do this:

     SET random_1 = random(1234);
     SET random_2 = random(1234);
     SET random_3 = random(1234);

That's not the reading I want, and it's not the reading you want either,
but there is nothing in the existing text that justifies single
evaluation.  So I think we'd be well advised to sit on our hands until
the committee clarifies that.  It's not like there is some urgent reason
to have this feature.

I don't think so this feature is 100% necessary, but a few users requested some more compressed form of variable declarations.

we can allow multi variable declaration without initial value specification

so "a,b,c text" can be valid, and "a,b,c text := 'hello'" not

It is just step to users who knows this feature from others languages.

Regards

Pavel
 

                        regards, tom lane


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: PL/pgSQL support to define multi variables once
Next
From: David Johnston
Date:
Subject: Re: PL/pgSQL support to define multi variables once