Re: Re: [COMMITTERS] pgsql: Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.

From: Andres Freund <andres(at)anarazel(dot)de>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: [COMMITTERS] pgsql: Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.
Date: 2015-05-21 01:12:29
Message-ID: 20150521011229.GX27868@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 2015-05-20 15:21:49 -0700, Peter Geoghegan wrote:
> On Wed, May 20, 2015 at 3:14 PM, Peter Geoghegan <pg(at)heroku(dot)com> wrote:
> > I think you're right. The initial commit neglected to update that, and
> > only handled it from ProcessQuery(). So it works for PlannedStmts, not
> > raw parse trees.
>
> Attached patch fixes this. Thanks for the report.

> diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
> index a95eff1..8fd5ee8 100644
> --- a/src/backend/tcop/utility.c
> +++ b/src/backend/tcop/utility.c
> @@ -1898,7 +1898,14 @@ CreateCommandTag(Node *parsetree)
> {
> /* raw plannable queries */
> case T_InsertStmt:
> - tag = "INSERT";
> + {
> + InsertStmt *stmt = (InsertStmt *) parsetree;
> +
> + tag = "INSERT";
> + if (stmt->onConflictClause &&
> + stmt->onConflictClause->action == ONCONFLICT_UPDATE)
> + tag = "UPSERT";
> + }
> break;
>
> case T_DeleteStmt:

You realize there's other instances of this in the same damn function?

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2015-05-21 01:22:08 Re: Re: [COMMITTERS] pgsql: Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.
Previous Message Peter Geoghegan 2015-05-20 22:21:49 Re: Re: [COMMITTERS] pgsql: Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-05-21 01:22:08 Re: Re: [COMMITTERS] pgsql: Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.
Previous Message Andres Freund 2015-05-21 00:46:51 Re: Change pg_cancel_*() to ignore current backend