Re: Dyamic updates of NEW with pl/pgsql

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: David Fetter <david(at)fetter(dot)org>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, depesz(at)depesz(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Dyamic updates of NEW with pl/pgsql
Date: 2010-03-12 20:01:47
Message-ID: 4B9A9DAB.3090209@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

strk írta:
> On Fri, Mar 12, 2010 at 10:47:45AM -0800, David Fetter wrote:
>
>> On Fri, Mar 12, 2010 at 07:35:41PM +0100, Pavel Stehule wrote:
>>
>>> 2010/3/12 David Fetter <david(at)fetter(dot)org>:
>>>
>>>> This is, by the way, an excellent argument for including hstore in
>>>> core in 9.1. :)
>>>>
>>> I like it - but it looking little bit strange - I thinking we need
>>> only one function (maybe with some special support from pl executor)
>>>
>>> begin
>>> update_field(NEW, 'field', value);
>>> ....
>>>
>> This doesn't seem like a terribly useful addition, it being specific
>> to PL/pgsql. Then there's the quoting issue, which the above doesn't
>> quite address. Putting hstore in would let all the other PLs use it,
>> to the extent that they need such a thing. :)
>>
>
> Plus pure SQL use !
>

What's wrong with "UPDATE foo SET (foo) = (NEW);" ?

I know it's a little ambiguous, as table "foo" can have fields
named "foo" and "new", but the
UPDATE foo SET (field, ...) = (value, ...);
works in plain SQL and the (...) usually denotes a list with
more than one field/value. pl/pgSQL could treat the
"list with single name" as a special case (maybe checking
whether the table has fields "foo", "new" and/or "old" and
issue a warning when relevant) and treat the above as a
whole-row update.

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2010-03-12 20:17:31 Re: Dyamic updates of NEW with pl/pgsql
Previous Message Tom Lane 2010-03-12 19:48:55 Re: Server crash with older tzload library