Skip to content

Commit 98afa68

Browse files
committed
Use C99 designated initializers for some structs
These are just a few particularly egregious cases that were hard to read and write, and error prone because of many similar adjacent types. Discussion: https://www.postgresql.org/message-id/flat/4c9f01be-9245-2148-b569-61a8562ef190%402ndquadrant.com
1 parent 75f7855 commit 98afa68

File tree

8 files changed

+240
-505
lines changed

8 files changed

+240
-505
lines changed

src/backend/access/transam/xact.c

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -199,27 +199,8 @@ typedef TransactionStateData *TransactionState;
199199
* transaction at all, or when in a top-level transaction.
200200
*/
201201
static TransactionStateData TopTransactionStateData = {
202-
0, /* transaction id */
203-
0, /* subtransaction id */
204-
NULL, /* savepoint name */
205-
0, /* savepoint level */
206-
TRANS_DEFAULT, /* transaction state */
207-
TBLOCK_DEFAULT, /* transaction block state from the client
208-
* perspective */
209-
0, /* transaction nesting depth */
210-
0, /* GUC context nesting depth */
211-
NULL, /* cur transaction context */
212-
NULL, /* cur transaction resource owner */
213-
NULL, /* subcommitted child Xids */
214-
0, /* # of subcommitted child Xids */
215-
0, /* allocated size of childXids[] */
216-
InvalidOid, /* previous CurrentUserId setting */
217-
0, /* previous SecurityRestrictionContext */
218-
false, /* entry-time xact r/o state */
219-
false, /* startedInRecovery */
220-
false, /* didLogXid */
221-
0, /* parallelModeLevel */
222-
NULL /* link to parent state block */
202+
.state = TRANS_DEFAULT,
203+
.blockState = TBLOCK_DEFAULT,
223204
};
224205

225206
/*

src/backend/catalog/heap.c

Lines changed: 77 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -145,39 +145,87 @@ static List *insert_ordered_unique_oid(List *list, Oid datum);
145145
*/
146146

147147
static FormData_pg_attribute a1 = {
148-
0, {"ctid"}, TIDOID, 0, sizeof(ItemPointerData),
149-
SelfItemPointerAttributeNumber, 0, -1, -1,
150-
false, 'p', 's', true, false, false, '\0', false, true, 0
148+
.attname = {"ctid"},
149+
.atttypid = TIDOID,
150+
.attlen = sizeof(ItemPointerData),
151+
.attnum = SelfItemPointerAttributeNumber,
152+
.attcacheoff = -1,
153+
.atttypmod = -1,
154+
.attbyval = false,
155+
.attstorage = 'p',
156+
.attalign = 's',
157+
.attnotnull = true,
158+
.attislocal = true,
151159
};
152160

153161
static FormData_pg_attribute a2 = {
154-
0, {"oid"}, OIDOID, 0, sizeof(Oid),
155-
ObjectIdAttributeNumber, 0, -1, -1,
156-
true, 'p', 'i', true, false, false, '\0', false, true, 0
162+
.attname = {"oid"},
163+
.atttypid = OIDOID,
164+
.attlen = sizeof(Oid),
165+
.attnum = ObjectIdAttributeNumber,
166+
.attcacheoff = -1,
167+
.atttypmod = -1,
168+
.attbyval = true,
169+
.attstorage = 'p',
170+
.attalign = 'i',
171+
.attnotnull = true,
172+
.attislocal = true,
157173
};
158174

159175
static FormData_pg_attribute a3 = {
160-
0, {"xmin"}, XIDOID, 0, sizeof(TransactionId),
161-
MinTransactionIdAttributeNumber, 0, -1, -1,
162-
true, 'p', 'i', true, false, false, '\0', false, true, 0
176+
.attname = {"xmin"},
177+
.atttypid = XIDOID,
178+
.attlen = sizeof(TransactionId),
179+
.attnum = MinTransactionIdAttributeNumber,
180+
.attcacheoff = -1,
181+
.atttypmod = -1,
182+
.attbyval = true,
183+
.attstorage = 'p',
184+
.attalign = 'i',
185+
.attnotnull = true,
186+
.attislocal = true,
163187
};
164188

165189
static FormData_pg_attribute a4 = {
166-
0, {"cmin"}, CIDOID, 0, sizeof(CommandId),
167-
MinCommandIdAttributeNumber, 0, -1, -1,
168-
true, 'p', 'i', true, false, false, '\0', false, true, 0
190+
.attname = {"cmin"},
191+
.atttypid = CIDOID,
192+
.attlen = sizeof(CommandId),
193+
.attnum = MinCommandIdAttributeNumber,
194+
.attcacheoff = -1,
195+
.atttypmod = -1,
196+
.attbyval = true,
197+
.attstorage = 'p',
198+
.attalign = 'i',
199+
.attnotnull = true,
200+
.attislocal = true,
169201
};
170202

171203
static FormData_pg_attribute a5 = {
172-
0, {"xmax"}, XIDOID, 0, sizeof(TransactionId),
173-
MaxTransactionIdAttributeNumber, 0, -1, -1,
174-
true, 'p', 'i', true, false, false, '\0', false, true, 0
204+
.attname = {"xmax"},
205+
.atttypid = XIDOID,
206+
.attlen = sizeof(TransactionId),
207+
.attnum = MaxTransactionIdAttributeNumber,
208+
.attcacheoff = -1,
209+
.atttypmod = -1,
210+
.attbyval = true,
211+
.attstorage = 'p',
212+
.attalign = 'i',
213+
.attnotnull = true,
214+
.attislocal = true,
175215
};
176216

177217
static FormData_pg_attribute a6 = {
178-
0, {"cmax"}, CIDOID, 0, sizeof(CommandId),
179-
MaxCommandIdAttributeNumber, 0, -1, -1,
180-
true, 'p', 'i', true, false, false, '\0', false, true, 0
218+
.attname = {"cmax"},
219+
.atttypid = CIDOID,
220+
.attlen = sizeof(CommandId),
221+
.attnum = MaxCommandIdAttributeNumber,
222+
.attcacheoff = -1,
223+
.atttypmod = -1,
224+
.attbyval = true,
225+
.attstorage = 'p',
226+
.attalign = 'i',
227+
.attnotnull = true,
228+
.attislocal = true,
181229
};
182230

183231
/*
@@ -187,9 +235,17 @@ static FormData_pg_attribute a6 = {
187235
* used in SQL.
188236
*/
189237
static FormData_pg_attribute a7 = {
190-
0, {"tableoid"}, OIDOID, 0, sizeof(Oid),
191-
TableOidAttributeNumber, 0, -1, -1,
192-
true, 'p', 'i', true, false, false, '\0', false, true, 0
238+
.attname = {"tableoid"},
239+
.atttypid = OIDOID,
240+
.attlen = sizeof(Oid),
241+
.attnum = TableOidAttributeNumber,
242+
.attcacheoff = -1,
243+
.atttypmod = -1,
244+
.attbyval = true,
245+
.attstorage = 'p',
246+
.attalign = 'i',
247+
.attnotnull = true,
248+
.attislocal = true,
193249
};
194250

195251
static const Form_pg_attribute SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6, &a7};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy