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

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: Re: [COMMITTERS] pgsql: Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.
Дата
Msg-id 20150521011229.GX27868@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: Re: [COMMITTERS] pgsql: Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.  (Peter Geoghegan <pg@heroku.com>)
Ответы Re: Re: [COMMITTERS] pgsql: Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Re: [COMMITTERS] pgsql: Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.  (Peter Geoghegan <pg@heroku.com>)
Список 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@heroku.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?



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Change pg_cancel_*() to ignore current backend
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Re: [COMMITTERS] pgsql: Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.