BUG: test_ginpostinglist second itemptr check is a no-op due to copy-paste error
BUG: test_ginpostinglist second itemptr check is a no-op due to copy-paste error
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
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
Re: BUG: test_ginpostinglist second itemptr check is a no-op due to copy-paste error
От:
John Naylor <johncnaylorls@gmail.com>
Дата:
On Tue, Mar 24, 2026 at 8:45 AM Jianghua Yang 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
Re: BUG: test_ginpostinglist second itemptr check is a no-op due to copy-paste error
От:
John Naylor <johncnaylorls@gmail.com>
Дата:
On Tue, Mar 24, 2026 at 8:59 AM John Naylor wrote: > > On Tue, Mar 24, 2026 at 8:45 AM Jianghua Yang 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