Re: Dyamic updates of NEW with pl/pgsql

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, 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 22:41:18
Message-ID: 603c8f071003121441l607ef9fcoac665e3a7ebe028@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Mar 12, 2010 at 4:24 PM, Boszormenyi Zoltan <zb(at)cybertec(dot)at> wrote:
> Merlin Moncure írta:
>> On Fri, Mar 12, 2010 at 3:01 PM, Boszormenyi Zoltan <zb(at)cybertec(dot)at> wrote:
>>
>>> What's wrong with "UPDATE foo SET (foo) = (NEW);" ?
>>>
>>>
>>
>> amen brother! :-)
>>
>> I say though, since you can do:
>> SELECT foo FROM foo;
>> why not
>> UPDATE foo SET foo = new;?
>>
>
> I just tried this:
>
> zozo=# create table foo (foo integer, bar integer);
> CREATE TABLE
> zozo=# insert into foo values (1, 2), (2, 4);
> INSERT 0 2
> zozo=# select foo from foo;
>  foo
> -----
>   1
>   2
> (2 rows)

But you can always get around this with, e.g.

SELECT v FROM foo v;

...Robert

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2010-03-12 22:46:25 Re: buildfarm logging versus embedded nulls
Previous Message Tom Lane 2010-03-12 22:24:55 Re: Reposnse from backend when wrong user/database request send