Use C99 designated designators in a couple of places
authorÁlvaro Herrera <alvherre@kurilemu.de>
Fri, 30 Jan 2026 09:11:04 +0000 (10:11 +0100)
committerÁlvaro Herrera <alvherre@kurilemu.de>
Fri, 30 Jan 2026 09:11:04 +0000 (10:11 +0100)
This makes the arrays somewhat easier to read.

Author: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://postgr.es/m/202601281204.sdxbr5qvpunk@alvherre.pgsql

src/backend/access/heap/heapam.c
src/backend/postmaster/bgworker.c

index ae31efe8c255cbeb3390967af3b94a14a82262ee..3004964ab7f960ec08bf4eb5324901e5da14b410 100644 (file)
@@ -111,11 +111,11 @@ static HeapTuple ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool ke
 
 
 /*
- * Each tuple lock mode has a corresponding heavyweight lock, and one or two
- * corresponding MultiXactStatuses (one to merely lock tuples, another one to
- * update them).  This table (and the macros below) helps us determine the
- * heavyweight lock mode and MultiXactStatus values to use for any particular
- * tuple lock strength.
+ * This table lists the heavyweight lock mode that corresponds to each tuple
+ * lock mode, as well as one or two corresponding MultiXactStatus values:
+ * .lockstatus to merely lock tuples, and .updstatus to update them.  The
+ * latter is set to -1 if the corresponding tuple lock mode does not allow
+ * updating tuples -- see get_mxact_status_for_lock().
  *
  * These interact with InplaceUpdateTupleLock, an alias for ExclusiveLock.
  *
@@ -127,29 +127,30 @@ static const struct
    LOCKMODE    hwlock;
    int         lockstatus;
    int         updstatus;
-}
+}          tupleLockExtraInfo[] =
 
-           tupleLockExtraInfo[MaxLockTupleMode + 1] =
 {
-   {                           /* LockTupleKeyShare */
-       AccessShareLock,
-       MultiXactStatusForKeyShare,
-       -1                      /* KeyShare does not allow updating tuples */
+   [LockTupleKeyShare] = {
+       .hwlock = AccessShareLock,
+       .lockstatus = MultiXactStatusForKeyShare,
+       /* KeyShare does not allow updating tuples */
+       .updstatus = -1
    },
-   {                           /* LockTupleShare */
-       RowShareLock,
-       MultiXactStatusForShare,
-       -1                      /* Share does not allow updating tuples */
+   [LockTupleShare] = {
+       .hwlock = RowShareLock,
+       .lockstatus = MultiXactStatusForShare,
+       /* Share does not allow updating tuples */
+       .updstatus = -1
    },
-   {                           /* LockTupleNoKeyExclusive */
-       ExclusiveLock,
-       MultiXactStatusForNoKeyUpdate,
-       MultiXactStatusNoKeyUpdate
+   [LockTupleNoKeyExclusive] = {
+       .hwlock = ExclusiveLock,
+       .lockstatus = MultiXactStatusForNoKeyUpdate,
+       .updstatus = MultiXactStatusNoKeyUpdate
    },
-   {                           /* LockTupleExclusive */
-       AccessExclusiveLock,
-       MultiXactStatusForUpdate,
-       MultiXactStatusUpdate
+   [LockTupleExclusive] = {
+       .hwlock = AccessExclusiveLock,
+       .lockstatus = MultiXactStatusForUpdate,
+       .updstatus = MultiXactStatusUpdate
    }
 };
 
index 65deabe91a77c8adece99c68949c199a1bdf734f..51874481751db9fa69402ca4e218e3074e13805b 100644 (file)
@@ -120,22 +120,28 @@ static const struct
 
 {
    {
-       "ParallelWorkerMain", ParallelWorkerMain
+       .fn_name = "ParallelWorkerMain",
+       .fn_addr = ParallelWorkerMain
    },
    {
-       "ApplyLauncherMain", ApplyLauncherMain
+       .fn_name = "ApplyLauncherMain",
+       .fn_addr = ApplyLauncherMain
    },
    {
-       "ApplyWorkerMain", ApplyWorkerMain
+       .fn_name = "ApplyWorkerMain",
+       .fn_addr = ApplyWorkerMain
    },
    {
-       "ParallelApplyWorkerMain", ParallelApplyWorkerMain
+       .fn_name = "ParallelApplyWorkerMain",
+       .fn_addr = ParallelApplyWorkerMain
    },
    {
-       "TableSyncWorkerMain", TableSyncWorkerMain
+       .fn_name = "TableSyncWorkerMain",
+       .fn_addr = TableSyncWorkerMain
    },
    {
-       "SequenceSyncWorkerMain", SequenceSyncWorkerMain
+       .fn_name = "SequenceSyncWorkerMain",
+       .fn_addr = SequenceSyncWorkerMain
    }
 };