Re: heapgettup() with NoMovementScanDirection unused in core?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: heapgettup() with NoMovementScanDirection unused in core?
Date: 2023-01-27 22:05:16
Message-ID: 3577737.1674857116@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Melanie Plageman <melanieplageman(at)gmail(dot)com> writes:
> I have written the patch to remove the unreachable code in
> heapgettup_pagemode]().

A few thoughts ...

1. Do we really need quite so many Asserts? I'd kind of lean
to just having one, at some higher level of the executor.

2. I'm not sure if we want to do this:

- direction = estate->es_direction;
- /* flip direction if this is an overall backward scan */
- if (ScanDirectionIsBackward(((IndexScan *) node->ss.ps.plan)->indexorderdir))
- {
- if (ScanDirectionIsForward(direction))
- direction = BackwardScanDirection;
- else if (ScanDirectionIsBackward(direction))
- direction = ForwardScanDirection;
- }
+ direction = estate->es_direction * ((IndexScan *) node->ss.ps.plan)->indexorderdir;

AFAIR, there is noplace today that depends on the exact encoding
of ForwardScanDirection and BackwardScanDirection, and I'm not
sure that we want to introduce such a dependency. If we do it
at least deserves a comment here, and you probably ought to adjust
the wishy-washy comment in sdir.h as well. Taking out the existing
comment explaining what this code is doing is not an improvement
either.

3. You didn't update the header comment for heapgettup, nor the
one in pathnodes.h for IndexPath.indexscandir.

4. I don't think the proposed test case is worth the cycles.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Melanie Plageman 2023-01-27 22:35:53 Re: heapgettup() with NoMovementScanDirection unused in core?
Previous Message Andres Freund 2023-01-27 22:00:35 Re: Non-superuser subscription owners