Re: "RETURNING PRIMARY KEY" syntax extension - Mailing list pgsql-hackers

From Tom Lane
Subject Re: "RETURNING PRIMARY KEY" syntax extension
Date
Msg-id 28583.1402325169@sss.pgh.pa.us
Whole thread Raw
In response to "RETURNING PRIMARY KEY" syntax extension  (Ian Barwick <ian@2ndquadrant.com>)
List pgsql-hackers
Ian Barwick <ian@2ndquadrant.com> writes:
> [ RETURNING PRIMARY KEY ]

It looks to me like this is coded to have the expansion of the "primary
key" done at parse time, which seems like fundamentally the wrong thing.
Consider a view or rule containing this clause; the pkey might be
different by the time execution rolls around.  It'd be better probably
if the rewriter or planner did the expansion (and threw the error for
no-primary-key, if necessary).

Alternatively, we could do it like this and consider that the view is
dependent on the primary key constraint, but that seems inflexible.

BTW, it seems like your representation of the clause was rather poorly
chosen: it forces changing a whole lot of code that otherwise would
not need to be changed.  I'd have left returningList alone and put the
returningPrimaryKey flag someplace else.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Inaccuracy in VACUUM's tuple count estimates
Next
From: Merlin Moncure
Date:
Subject: Re: NUMA packaging and patch