pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix WHERE CURRENT OF when the referenced cursor uses an index-on
Date: Sat, 17 Mar 2018 19:00:11 +0000
Message-ID: <E1exH3r-0008BG-Q1@gemulon.postgresql.org> (raw)

Fix WHERE CURRENT OF when the referenced cursor uses an index-only scan.

"UPDATE/DELETE WHERE CURRENT OF cursor_name" failed, with an error message
like "cannot extract system attribute from virtual tuple", if the cursor
was using a index-only scan for the target table.  Fix it by digging the
current TID out of the indexscan state.

It seems likely that the same failure could occur for CustomScan plans
and perhaps some FDW plan types, so that leaving this to be treated as an
internal error with an obscure message isn't as good an idea as it first
seemed.  Hence, add a bit of heaptuple.c infrastructure to let us deliver
a more on-topic message.  I chose to make the message match what you get
for the case where execCurrentOf can't identify the target scan node at
all, "cursor "foo" is not a simply updatable scan of table "bar"".
Perhaps it should be different, but we can always adjust that later.

In the future, it might be nice to provide hooks that would let custom
scan providers and/or FDWs deal with this in other ways; but that's
not a suitable topic for a back-patchable bug fix.

It's been like this all along, so back-patch to all supported branches.

Yugo Nagata and Tom Lane

Discussion: https://postgr.es/m/20180201013349.937dfc5f.nagata@sraoss.co.jp

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ee7bf0fd9fa7ed4a99e9cf1b9e97409f46a3eb40

Modified Files
--------------
src/backend/access/common/heaptuple.c | 26 ++++++++++++
src/backend/executor/execCurrent.c    | 79 ++++++++++++++++++++++++++---------
src/include/executor/tuptable.h       |  2 +
src/test/regress/expected/portals.out | 24 +++++++++++
src/test/regress/sql/portals.sql      | 10 +++++
5 files changed, 121 insertions(+), 20 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1exH3r-0008BG-Q1@gemulon.postgresql.org>
Permalink:  ../E1exH3r-0008BG-Q1@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1exH3r-0008BG-Q1@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix WHERE CURRENT OF when the referenced cursor uses an index-on
  In-Reply-To: <E1exH3r-0008BG-Q1@gemulon.postgresql.org>
  References: <E1exH3r-0008BG-Q1@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox