public inbox for [email protected]
help / color / mirror / Atom feedBUG: test_ginpostinglist second itemptr check is a no-op due to copy-paste error
3+ messages / 2 participants
[nested] [flat]
* BUG: test_ginpostinglist second itemptr check is a no-op due to copy-paste error
@ 2026-03-24 01:44 Jianghua Yang <[email protected]>
0 siblings, 1 reply; 3+ messages in thread
From: Jianghua Yang @ 2026-03-24 01:44 UTC (permalink / raw)
To: [email protected]
Hi,
I found a copy-paste bug in
src/test/modules/test_ginpostinglist/test_ginpostinglist.c.
The function test_itemptr_pair() encodes a pair of item pointers and
decodes them back to verify the round-trip. The two original item
pointers are:
orig_itemptrs[0] = (0, 1)
orig_itemptrs[1] = (blk, off)
After the first itemptr check (lines 68-72), there is a second check
intended to verify the second decoded item pointer when ndecoded == 2:
if (ndecoded == 2 &&
!ItemPointerEquals(&orig_itemptrs[0], &decoded_itemptrs[0]))
{
elog(ERROR, "mismatch on second itemptr: (%u, %d) vs (%u, %d)",
0, 1,
ItemPointerGetBlockNumber(&decoded_itemptrs[0]),
ItemPointerGetOffsetNumber(&decoded_itemptrs[0]));
}
This is an exact duplicate of the first check — it uses index [0]
throughout, and the expected value is hardcoded as (0, 1) instead of
(blk, off). As a result, any decoding error in decoded_itemptrs[1]
would go undetected.
This is particularly unfortunate because the whole purpose of testing a
pair (as the comment at line 30-33 explains) is to exercise the varbyte
delta encoding, which only applies to the second and subsequent item
pointers. The broken check defeats exactly that goal.
The attached patch fixes the second check to compare orig_itemptrs[1]
with decoded_itemptrs[1] and reports (blk, off) as the expected
value in the error message.
Regards,
Jianghua Yang
Attachments:
[application/octet-stream] v1-0001-Fix-copy-paste-error-in-test_ginpostinglist-secon.patch (1.7K, 3-v1-0001-Fix-copy-paste-error-in-test_ginpostinglist-secon.patch)
download | inline diff:
From dda3c6611ef5fd4a619b8284e56a990b9e0fefe7 Mon Sep 17 00:00:00 2001
From: Jianghua Yang <[email protected]>
Date: Mon, 23 Mar 2026 18:29:54 -0700
Subject: [PATCH v1] Fix copy-paste error in test_ginpostinglist second itemptr
check
The check for a mismatch on the second decoded item pointer was an
exact copy of the first item pointer check, comparing orig_itemptrs[0]
with decoded_itemptrs[0] instead of orig_itemptrs[1] with
decoded_itemptrs[1]. The error message also reported (0, 1) as the
expected value instead of (blk, off). As a result, any decoding error
in the second item pointer (where the varbyte delta encoding is
exercised) would go undetected.
Author: Jianghua Yang <[email protected]>
---
.../modules/test_ginpostinglist/test_ginpostinglist.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/test/modules/test_ginpostinglist/test_ginpostinglist.c b/src/test/modules/test_ginpostinglist/test_ginpostinglist.c
index 83cf3469886..6d84364f5c5 100644
--- a/src/test/modules/test_ginpostinglist/test_ginpostinglist.c
+++ b/src/test/modules/test_ginpostinglist/test_ginpostinglist.c
@@ -72,12 +72,12 @@ test_itemptr_pair(BlockNumber blk, OffsetNumber off, int maxsize)
ItemPointerGetOffsetNumber(&decoded_itemptrs[0]));
if (ndecoded == 2 &&
- !ItemPointerEquals(&orig_itemptrs[0], &decoded_itemptrs[0]))
+ !ItemPointerEquals(&orig_itemptrs[1], &decoded_itemptrs[1]))
{
elog(ERROR, "mismatch on second itemptr: (%u, %d) vs (%u, %d)",
- 0, 1,
- ItemPointerGetBlockNumber(&decoded_itemptrs[0]),
- ItemPointerGetOffsetNumber(&decoded_itemptrs[0]));
+ blk, off,
+ ItemPointerGetBlockNumber(&decoded_itemptrs[1]),
+ ItemPointerGetOffsetNumber(&decoded_itemptrs[1]));
}
}
--
2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG: test_ginpostinglist second itemptr check is a no-op due to copy-paste error
@ 2026-03-24 01:59 John Naylor <[email protected]>
parent: Jianghua Yang <[email protected]>
0 siblings, 1 reply; 3+ messages in thread
From: John Naylor @ 2026-03-24 01:59 UTC (permalink / raw)
To: Jianghua Yang <[email protected]>; +Cc: [email protected]
On Tue, Mar 24, 2026 at 8:45 AM Jianghua Yang <[email protected]> wrote:
> The attached patch fixes the second check to compare orig_itemptrs[1]
> with decoded_itemptrs[1] and reports (blk, off) as the expected
> value in the error message.
Seems right to me, thanks for the patch. I'll take care of this.
--
John Naylor
Amazon Web Services
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG: test_ginpostinglist second itemptr check is a no-op due to copy-paste error
@ 2026-03-24 10:30 John Naylor <[email protected]>
parent: John Naylor <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: John Naylor @ 2026-03-24 10:30 UTC (permalink / raw)
To: Jianghua Yang <[email protected]>; +Cc: [email protected]
On Tue, Mar 24, 2026 at 8:59 AM John Naylor <[email protected]> wrote:
>
> On Tue, Mar 24, 2026 at 8:45 AM Jianghua Yang <[email protected]> wrote:
> > The attached patch fixes the second check to compare orig_itemptrs[1]
> > with decoded_itemptrs[1] and reports (blk, off) as the expected
> > value in the error message.
>
> Seems right to me, thanks for the patch. I'll take care of this.
This is done. It seems unlikely that this test would need to be
changed in back branches, but I went ahead and backpatched it anyway
just in case.
--
John Naylor
Amazon Web Services
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-03-24 10:30 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-03-24 01:44 BUG: test_ginpostinglist second itemptr check is a no-op due to copy-paste error Jianghua Yang <[email protected]>
2026-03-24 01:59 ` John Naylor <[email protected]>
2026-03-24 10:30 ` John Naylor <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox