Re: Amcheck verification of GiST and GIN

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru>
Cc: Alexander Lakhin <exclusion(at)gmail(dot)com>, Andrey Borodin <amborodin86(at)gmail(dot)com>, Peter Geoghegan <pg(at)bowt(dot)ie>, Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>, Jose Arthur Benetasso Villanova <jose(dot)arthur(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tomas Vondra <tomas(at)vondra(dot)me>
Subject: Re: Amcheck verification of GiST and GIN
Date: 2024-11-29 13:57:42
Message-ID: CALdSSPjWcJx43uQURdA-bS9WYjtZFK0c765N6RB7gmi5XxD1aw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 26 Nov 2024 at 11:50, Kirill Reshke <reshkekirill(at)gmail(dot)com> wrote:
>
> ====
> Overall I think 0001 & 0002 are ready as-is. 0003 is maybe ok. Other
> patches need more review rounds.
>
> --
> Best regards,
> Kirill Reshke

=== Patch changes.

Polishing:
1)

> + /* last tuple in layer has no high key */
> + if (i != maxoff && !GinPageGetOpaque(page)->rightlink)
> + {
> + ptr->parenttup = CopyIndexTuple(idxtuple);
> + }
> + else
> + {
> + ptr->parenttup = NULL;
> + }

This coding does not align with PostgreSQL style. I removed
parentheses here and in other few places :

```
reshke(at)ygp-jammy:~/postgres$ git diff contrib/amcheck/verify_gin.c
diff --git a/contrib/amcheck/verify_gin.c b/contrib/amcheck/verify_gin.c
index 47b6e81fbc4..be44cc724f8 100644
--- a/contrib/amcheck/verify_gin.c
+++ b/contrib/amcheck/verify_gin.c
@@ -111,9 +111,7 @@ ginReadTupleWithoutState(IndexTuple itup, int *nitems)
nipd, ndecoded);
}
else
- {
ipd = palloc(0);
- }
}
else
{
@@ -194,7 +192,6 @@
gin_check_posting_tree_parent_keys_consistency(Relation rel,
BlockNumber posting
list = GinDataLeafPageGetItems(page, &nlist, minItem);

if (nlist > 0)
- {
snprintf(tidrange_buf, sizeof(tidrange_buf),
"%d tids (%u, %u) - (%u, %u)",
nlist,
@@ -202,11 +199,8 @@
gin_check_posting_tree_parent_keys_consistency(Relation rel,
BlockNumber posting

ItemPointerGetOffsetNumberNoCheck(&list[0]),

ItemPointerGetBlockNumberNoCheck(&list[nlist - 1]),

ItemPointerGetOffsetNumberNoCheck(&list[nlist - 1]));
- }
else
- {
snprintf(tidrange_buf,
sizeof(tidrange_buf), "0 tids");
- }

if (stack->parentblk != InvalidBlockNumber)
{
@@ -218,11 +212,9 @@
gin_check_posting_tree_parent_keys_consistency(Relation rel,
BlockNumber posting
tidrange_buf);
}
else
- {
elog(DEBUG3, "blk %u: root leaf, %s",
stack->blkno,
tidrange_buf);
- }

if (stack->parentblk != InvalidBlockNumber &&

ItemPointerGetOffsetNumberNoCheck(&stack->parentkey) !=
InvalidOffsetNumber &&
@@ -576,13 +568,9 @@ gin_check_parent_keys_consistency(Relation rel,
ptr->depth = stack->depth + 1;
/* last tuple in layer has no high key */
if (i != maxoff &&
!GinPageGetOpaque(page)->rightlink)
- {
ptr->parenttup =
CopyIndexTuple(idxtuple);
- }
else
- {
ptr->parenttup = NULL;
- }
ptr->parentblk = stack->blkno;
ptr->blkno = GinGetDownlink(idxtuple);
ptr->parentlsn = lsn;

```

2)

>+ else
>+ {
>+ /*
>+ * But now it is properly adjusted - nothing to do
>+ * here.
>+ */
>+ }

if (...) ... else {/* comment */} is a strange pattern.

PFA v6.
No other changes from v5 except for mandatory rebase of v5-0005 due to 18954ce.

=== CC changes
I changed Tomas's email to tomas(at)vondra(dot)me, as @enterprisedb one no
longer exists.

--
Best regards,
Kirill Reshke

Attachment Content-Type Size
v30-0001-A-tiny-nitpicky-tweak-to-beautify-the-Amcheck-in.patch application/octet-stream 948 bytes
v30-0002-Refactor-amcheck-internals-to-isolate-common-loc.patch application/octet-stream 21.4 KB
v30-0004-Add-gin_index_check-to-verify-GIN-index.patch application/octet-stream 32.6 KB
v30-0003-Add-gist_index_check-function-to-verify-GiST-ind.patch application/octet-stream 34.1 KB
v30-0005-Add-GiST-support-to-pg_amcheck.patch application/octet-stream 35.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2024-11-29 14:00:37 Re: CREATE SCHEMA ... CREATE DOMAIN support
Previous Message Sergey Prokhorenko 2024-11-29 13:57:30 Re: Отв.: Re: UUID v7