From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
Cc: | Peter Geoghegan <pg(at)heroku(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Stephen Frost <sfrost(at)snowman(dot)net>, Bruce Momjian <bruce(at)momjian(dot)us>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> |
Subject: | Re: INSERT ... ON CONFLICT IGNORE (and UPDATE) 3.0 |
Date: | 2015-04-15 15:01:19 |
Message-ID: | 20150415150119.GA2643@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2015-04-15 17:58:54 +0300, Heikki Linnakangas wrote:
> On 04/15/2015 07:51 AM, Peter Geoghegan wrote:
> >+heap_finish_speculative(Relation relation, HeapTuple tuple, bool conflict)
> >+{
> >+ if (!conflict)
> >+ {
> >+ /*
> >+ * Update the tuple in-place, in the common case where no conflict was
> >+ * detected during speculative insertion.
> >+ *
> >+ * When heap_insert is called in respect of a speculative tuple, the
> >+ * page will actually have a tuple inserted. However, during recovery
> >+ * replay will add an all-zero tuple to the page instead, which is the
> >+ * same length as the original (but the tuple header is still WAL
> >+ * logged and will still be restored at that point). If and when the
> >+ * in-place update record corresponding to releasing a value lock is
> >+ * replayed, crash recovery takes the final tuple value from there.
> >+ * Thus, speculative heap records require two WAL records.
> >+ *
> >+ * Logical decoding interprets an in-place update associated with a
> >+ * speculative insertion as a regular insert change. In other words,
> >+ * the in-place record generated affirms that a speculative insertion
> >+ * completed successfully.
> >+ */
> >+ heap_inplace_update(relation, tuple);
> >+ }
> >+ else
> >+ {
>
> That's a bizarre solution.
I tend to agree, but for different reasons.
> In logical decoding, decode speculative insertions like any other insertion.
> To decode a super-deletion record, scan the reorder buffer for the
> transaction to find the corresponding speculative insertion record for the
> tuple, and remove it.
Not that easy. That buffer is spilled to disk and such. As discussed.
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2015-04-15 15:11:02 | Re: [COMMITTERS] pgsql: Move pg_upgrade from contrib/ to src/bin/ |
Previous Message | Heikki Linnakangas | 2015-04-15 14:58:54 | Re: INSERT ... ON CONFLICT IGNORE (and UPDATE) 3.0 |