From: Álvaro Herrera Date: Fri, 30 Jan 2026 09:11:04 +0000 (+0100) Subject: Use C99 designated designators in a couple of places X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1eb09ed63a8d8063dc6bb75c8f31ec564bf35250;p=thirdparty%2Fpostgresql.git Use C99 designated designators in a couple of places This makes the arrays somewhat easier to read. Author: Álvaro Herrera Reviewed-by: Peter Eisentraut Reviewed-by: Melanie Plageman Reviewed-by: Jelte Fennema-Nio Discussion: https://postgr.es/m/202601281204.sdxbr5qvpunk@alvherre.pgsql --- diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index ae31efe8c25..3004964ab7f 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -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 } }; diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c index 65deabe91a7..51874481751 100644 --- a/src/backend/postmaster/bgworker.c +++ b/src/backend/postmaster/bgworker.c @@ -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 } };