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?