Re: heapgettup refactoring - Mailing list pgsql-hackers

From Melanie Plageman
Subject Re: heapgettup refactoring
Date
Msg-id CAAKRu_Ydy7p0_bdm=sTmoGyWKd7Wznbo_=5BzUDJLrZnzBUf1Q@mail.gmail.com
Whole thread Raw
In response to Re: heapgettup refactoring  (Peter Eisentraut <peter.eisentraut@enterprisedb.com>)
Responses Re: heapgettup refactoring
List pgsql-hackers
On Thu, Jan 5, 2023 at 8:52 AM Peter Eisentraut
<peter.eisentraut@enterprisedb.com> wrote:
>
> Ok, let's look through these patches starting from the top then.
>
> v4-0001-Add-no-movement-scan-helper.patch
>
> This makes sense overall; there is clearly some duplicate code that can
> be unified.
>
> It appears that during your rebasing you have effectively reverted your
> earlier changes that have been committed as
> 8e1db29cdbbd218ab6ba53eea56624553c3bef8c.  You should undo that.

Thanks. I think I have addressed this.
I've attached a rebased v5.

> I don't understand the purpose of the noinline maker.  If it's not
> necessary to inline, we can just leave it off, but there is no need to
> outright prevent inlining AFAICT.
>

I have removed it.

> I don't know why you changed the if/else sequences.  Before, the
> sequence was effectively
>
> if (forward)
> {
>      ...
> }
> else if (backward)
> {
>      ...
> }
> else
> {
>      /* it's no movement */
> }
>
> Now it's changed to
>
> if (no movement)
> {
>      ...
>      return;
> }
>
> if (forward)
> {
>      ...
> }
> else
> {
>      Assert(backward);
>      ...
> }
>
> Sure, that's the same thing, but it looks less elegant to me.

In this commit, you could keep the original ordering of if statements. I
preferred no movement scan first because then backwards and forwards
scans' code is physically closer to the rest of the code without the
intrusion of the no movement scan code.

Ultimately, the refactor (in later patches) flips the ordering of if
statements at the top from
        if (scan direction)
        to
        if (initial or continue)
and this isn't a very interesting distinction for no movement scans. By
dealing with no movement scan at the top, I didn't have to handle no
movement scans in the initial and continue branches in the new structure.

Also, I will note that patches 4-6 at least and perhaps 4-7 do not make
sense as separate commits. I separated them for ease of review. Each is
correct and passes tests but is not really an improvement without the
others.

- Melanie

Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Fixing a couple of buglets in how VACUUM sets visibility map bits
Next
From: Corey Huinker
Date:
Subject: Re: Add SHELL_EXIT_CODE to psql