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-03T02:26:40Z
Lists: pgsql-hackers
On Fri, 3 Feb 2023 at 06:23, Melanie Plageman <melanieplageman@gmail.com> wrote: > Your code also switches to saving the OffsetNumber -- just in a separate > variable of OffsetNumber type. I am fine with this if it your rationale > is that it is not a good idea to store a smaller number in a larger > datatype. However, the benefit I saw in reusing rs_cindex is that we > could someday converge the code for heapgettup() and > heapgettup_pagemode() even more. Even in my final refactor, there is a > lot of duplicate code between the two. I was more concerned about the reuse of an unrelated field. I'm struggling to imagine why using the separate field would cause any issues around not being able to reduce the code duplication any more than we otherwise would. Surely in one case you need to get the offset by indexing the rs_vistuples[] array and the other is the offset directly. The only thing I can think of that would allow us not to have a condition there would be if we populated the rs_vistuples[] array with 1..n. I doubt should do that and if we did, we could just use the rs_cindex to index that without having to worry that we're using an unrelated field for something. I've pushed all but the final 2 patches now. David
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