From: | Marko Tiikkaja <marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi> |
---|---|
To: | Greg Smith <greg(at)2ndquadrant(dot)com> |
Cc: | Boxuan Zhai <bxzhai2010(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Re: new patch of MERGE (merge_204) & a question about duplicated ctid |
Date: | 2010-12-29 12:43:55 |
Message-ID: | 4D1B2D0B.7000208@cs.helsinki.fi |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2010-12-29 2:14 PM, Greg Smith wrote:
> MERGE INTO Stock t
> USING (VALUES(10,100)) AS s(item_id,balance)
> ON s.item_id=t.item_id
> WHEN MATCHED THEN UPDATE SET balance=t.balance + s.balance
> WHEN NOT MATCHED THEN INSERT VALUES(s.item_id,s.balance)
> ;
>
> If you can suggest an alternate way to express this that works with the
> new patch, I might switch to that and retry. I was never 100% sure this
> was the right way to write this, and I don't have another database with
> MERGE support here to try against.
As far as I can tell, this should work. I played around with the patch
and the problem seems to be the VALUES:
INTO Stock t
USING (SELECT 30, 2000) AS s(item_id,balance)
ON s.item_id=t.item_id
WHEN MATCHED THEN UPDATE SET balance=t.balance + s.balance
WHEN NOT MATCHED THEN INSERT VALUES(s.item_id,s.balance)
;
MERGE 1
Regards,
Marko Tiikkaja
From | Date | Subject | |
---|---|---|---|
Next Message | Noah Misch | 2010-12-29 12:56:25 | Avoiding rewrite in ALTER TABLE ALTER TYPE |
Previous Message | Alvaro Herrera | 2010-12-29 12:39:43 | Re: small table left outer join big table |