Clarify comment on multixid offset wraparound check
authorHeikki Linnakangas <[email protected]>
Mon, 15 Dec 2025 09:47:04 +0000 (11:47 +0200)
committerHeikki Linnakangas <[email protected]>
Mon, 15 Dec 2025 09:47:58 +0000 (11:47 +0200)
Coverity complained that offset cannot be 0 here because there's an
explicit check for "offset == 0" earlier in the function, but it
didn't see the possibility that offset could've wrapped around to 0.
The code is correct, but clarify the comment about it.

The same code exists in backbranches in the server
GetMultiXactIdMembers() function and in 'master' in the pg_upgrade
GetOldMultiXactIdSingleMember function. In backbranches Coverity
didn't complain about it because the check was merely an assertion,
but change the comment in all supported branches for consistency.

Per Tom Lane's suggestion.

Discussion: https://www.postgresql.org/message-id/1827755.1765752936@sss.pgh.pa.us

src/backend/access/transam/multixact.c

index 606922537470e95be7057225141f7280353e7a47..80f93a71b6433c762ad4704eae250d2e71acaed9 100644 (file)
@@ -1602,7 +1602,10 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 
        if (!TransactionIdIsValid(*xactptr))
        {
-           /* Corner case 2: we must be looking at unused slot zero */
+           /*
+            * Corner case 2: offset must have wrapped around to unused slot
+            * zero.
+            */
            Assert(offset == 0);
            continue;
        }