Thread: pgsql: Add various assertions to heap pruning code.

pgsql: Add various assertions to heap pruning code.

From
Peter Geoghegan
Date:
Add various assertions to heap pruning code.

These assertions document (and verify) our high level assumptions about
how pruning can and cannot affect existing items from target heap pages.
For example, one of the new assertions verifies that pruning does not
set a heap-only tuple to LP_DEAD.

Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAH2-Wz=vhvBx1GjF+oueHh8YQcHoQYrMi0F0zFMHEr8yc4sCoA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5cd7eb1f1c32e1b95894f28b277b4e4b89add772

Modified Files
--------------
src/backend/access/heap/pruneheap.c | 84 +++++++++++++++++++++++++++++++++++--
1 file changed, 80 insertions(+), 4 deletions(-)


Re: pgsql: Add various assertions to heap pruning code.

From
Michael Paquier
Date:
Hi Peter,

On Fri, Nov 05, 2021 at 02:09:47AM +0000, Peter Geoghegan wrote:
> Add various assertions to heap pruning code.
>
> These assertions document (and verify) our high level assumptions about
> how pruning can and cannot affect existing items from target heap pages.
> For example, one of the new assertions verifies that pruning does not
> set a heap-only tuple to LP_DEAD.

This generates some warnings on Windows without asserts:
pruneheap.c(847): warning C4101: 'htup' unreferenced local variable
pruneheap.c(859): warning C4101: 'tolp' unreferenced local variable

You could move those two variables within their USE_ASSERT_CHECKING
blocks, for example.

Thanks,
--
Michael

Attachment

Re: pgsql: Add various assertions to heap pruning code.

From
Peter Geoghegan
Date:
On Thu, Nov 4, 2021 at 11:48 PM Michael Paquier <michael@paquier.xyz> wrote:
> This generates some warnings on Windows without asserts:
> pruneheap.c(847): warning C4101: 'htup' unreferenced local variable
> pruneheap.c(859): warning C4101: 'tolp' unreferenced local variable
>
> You could move those two variables within their USE_ASSERT_CHECKING
> blocks, for example.

Why doesn't PG_USED_FOR_ASSERTS_ONLY work on this platform? If it
doesn't work on this platform at all, but I'm required to avoid these
warnings all the same, then why do we even have
PG_USED_FOR_ASSERTS_ONLY? If it works in at least some cases on this
platform, then why not in this particular case?

-- 
Peter Geoghegan