Re: heapgettup refactoring
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: David Rowley <dgrowleyml@gmail.com>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>,
Andres Freund <andres@anarazel.de>, Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2023-02-02T06:00:37Z
Lists: pgsql-hackers
Attachments
- v9-0001-Further-refactor-of-heapgettup-and-heapgettup_pag.patch (text/plain) patch v9-0001
On Thu, 2 Feb 2023 at 10:12, Melanie Plageman <melanieplageman@gmail.com> wrote: > FWIW, I like setting rs_inited in heapgettup_initial_block() better in > the final refactor, but I agree with you that in this patch on its own > it is better in the body of heapgettup() and heapgettup_pagemode(). We can reconsider that when we get to that patch. It just felt a bit ugly to add an InvalidBlockNumber check after calling table_block_parallelscan_nextpage() > I believe this else is superfluous since we returned above. TBH, that's on purpose. I felt that it just looked better that way as the code all fitted onto my screen. I think if the function was longer and people had to scroll down to read it, it can often be better to return and reduce the nesting. This allows you to mentally not that a certain case is handled above. However, since all these helper functions seem to fit onto a screen without too much trouble, it just seems better (to me) if they all follow the format that I mentioned earlier. I might live to regret that as we often see get-rid-of-useless-else-clause patches coming up. I'm starting to wonder if someone's got some alarm that goes off every time one gets committed, but we'll see. I'd much rather have consistency between the helper functions than save a few bytes on tab characters. It would be different if the indentation were shifting things too far right, but that's not going to happen in a function that all fits onto a screen at once. I've attached a version of the next patch in the series. I admit to making a couple of adjustments. I couldn't bring myself to remove the snapshot local variable in this commit. We can deal with that when we come to it in whichever patch that needs to be changed in. The only other thing I really did was question your use of rs_cindex to store the last OffsetNumber. I ended up adding a new field which slots into the padding between a bool and BlockNumber field named rs_coffset for this purpose. I noticed what Andres wrote [1] earlier in this thread about that, so thought we should move away from looking at the last tuple to get this number I've attached the rebased and updated patch. David [1] https://postgr.es/m/20221101010948.hsf33emgnwzvil4a@awork3.anarazel.de
Commits
-
Remove stray duplicated comment in heapam.h
- 9ed50ab3496f 16.0 landed
-
More refactoring of heapgettup() and heapgettup_pagemode()
- cfcf56f92398 16.0 landed
-
Run pgindent on heapam.c
- 009dbdea02d7 16.0 landed
-
Push lpp variable closer to usage in heapgetpage()
- e351f8541831 16.0 landed
-
Variable renaming in preparation for refactoring
- 8e1db29cdbbd 16.0 landed
-
Turn HeapKeyTest macro into inline function
- 4eb3b1120001 16.0 landed
-
Remove unused include
- c0f1e51ac79e 16.0 landed
-
Remove redundant breaks in HeapTupleSatisfiesVisibility
- c3652cd84ac8 16.0 landed