pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Greg Burd <greg@burd.me>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Andres Freund <andres@anarazel.de>
Subject: Re: ExecForceStoreHeapTuple() loses tts_tid, so ORDER BY-op index scans project an invalid ctid
Date: Wed, 9 Sep 2026 09:03:46 +0900
Message-ID: <aqCiYp8QjIXFckiN@paquier.xyz> (raw)
In-Reply-To: <0498c10f-839b-4f68-9994-c29b454e55a4@app.fastmail.com>
References: <0498c10f-839b-4f68-9994-c29b454e55a4@app.fastmail.com>

On Tue, Sep 08, 2026 at 01:28:22PM -0400, Greg Burd wrote:
> ExecForceStoreHeapTuple() does not set slot->tts_tid when the target
> slot is a TTS_IS_BUFFERTUPLE slot. Any plan that re-stores a heap tuple
> through it and then projects ctid therefore gets (4294967295,0) instead
> of the row's real heap TID.

Oops.  

My question would be what kind of testing you have done to spot that..

> ExecClearTuple() reaches tts_buffer_heap_clear(), which does
> ItemPointerSetInvalid(&slot->tts_tid). The tuple is then copied in, but
> tts_tid is left invalid. The sibling path, ExecStoreHeapTuple() ->
> tts_heap_store_tuple() — *does* slot->tts_tid = tuple->t_self, so this
> reads as a plain asymmetry rather than an intentional choice.

That's strange.  Once thing that I can see why scanning this file is
the same code pattern in tts_buffer_heap_copyslot(), where a slot is
similarly cleared in a copy-paste fashion.

Andres?
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (7+ messages)  latest in thread

Message-ID: <aqCiYp8QjIXFckiN@paquier.xyz>
Permalink:  ../aqCiYp8QjIXFckiN@paquier.xyz/
Also on:    postgresql.org/message-id/aqCiYp8QjIXFckiN@paquier.xyz

 · 

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-hackers@postgresql.org
  Cc: michael@paquier.xyz, greg@burd.me, andres@anarazel.de
  Subject: Re: ExecForceStoreHeapTuple() loses tts_tid, so ORDER BY-op index scans project an invalid ctid
  In-Reply-To: <aqCiYp8QjIXFckiN@paquier.xyz>
  References: <0498c10f-839b-4f68-9994-c29b454e55a4@app.fastmail.com> <aqCiYp8QjIXFckiN@paquier.xyz>

* 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