From: | Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com> |
---|---|
To: | Peter Geoghegan <pg(at)bowt(dot)ie> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, Pavan Deolasee <pavan(dot)deolasee(at)2ndquadrant(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [HACKERS] MERGE SQL Statement for PG11 |
Date: | 2018-03-22 12:24:07 |
Message-ID: | CABOikdPd7xu_svfyA_YYmrm4yq14M_hstT7+gEW2FKHkbnuwwQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Mar 22, 2018 at 1:15 AM, Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
>
> >
> >
> > No, it did not. We only support VALUES clause with INSERT action.
>
> But can't you have a subselect in the VALUES()? Support for subselects
> seems like a totally distinct thing to the restriction that only a
> (single row) VALUES() is allowed in INSERT actions.
>
>
Ah, right. That works even today.
postgres=# CREATE TABLE target (a int, b text);
CREATE TABLE
postgres=# MERGE INTO target USING (SELECT 1) s ON false WHEN NOT MATCHED
THEN INSERT VALUES ((SELECT count(*) FROM pg_class), (SELECT relname FROM
pg_class LIMIT 1));
MERGE 1
postgres=# SELECT * FROM target;
a | b
-----+----------------
755 | pgbench_source
(1 row)
Thanks,
Pavan
--
Pavan Deolasee http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Korotkov | 2018-03-22 12:24:36 | Re: [HACKERS] GUC for cleanup indexes threshold. |
Previous Message | Kyotaro HORIGUCHI | 2018-03-22 12:11:48 | Re: [HACKERS] PATCH: Batch/pipelining support for libpq |