Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit75f4922

Browse files
committed
Static assertions cleanup
Because we added StaticAssertStmt() first before StaticAssertDecl(),some uses as well as the instructions in c.h are now a bit backwardsfrom the "native" way static assertions are meant to be used in C.This updates the guidance and moves some static assertions to betterplaces.Specifically, since the addition of StaticAssertDecl(), we can putstatic assertions at the file level. This moves a number of staticassertions out of function bodies, where they might have been stuckout of necessity, to perhaps better places at the file level or inheader files.Also, when the static assertion appears in a position where adeclaration is allowed, then using StaticAssertDecl() is more nativethan StaticAssertStmt().Reviewed-by: John Naylor <john.naylor@enterprisedb.com>Discussion:https://www.postgresql.org/message-id/flat/941a04e7-dd6f-c0e4-8cdf-a33b3338cbda%40enterprisedb.com
1 parent2613dec commit75f4922

File tree

29 files changed

+99
-104
lines changed

29 files changed

+99
-104
lines changed

‎src/backend/access/heap/heapam.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5783,10 +5783,6 @@ heap_finish_speculative(Relation relation, ItemPointer tid)
57835783

57845784
htup= (HeapTupleHeader)PageGetItem(page,lp);
57855785

5786-
/* SpecTokenOffsetNumber should be distinguishable from any real offset */
5787-
StaticAssertStmt(MaxOffsetNumber<SpecTokenOffsetNumber,
5788-
"invalid speculative token constant");
5789-
57905786
/* NO EREPORT(ERROR) from here till changes are logged */
57915787
START_CRIT_SECTION();
57925788

@@ -7921,7 +7917,7 @@ index_delete_sort(TM_IndexDeleteOp *delstate)
79217917
constintgaps[9]= {1968,861,336,112,48,21,7,3,1};
79227918

79237919
/* Think carefully before changing anything here -- keep swaps cheap */
7924-
StaticAssertStmt(sizeof(TM_IndexDelete) <=8,
7920+
StaticAssertDecl(sizeof(TM_IndexDelete) <=8,
79257921
"element size exceeds 8 bytes");
79267922

79277923
for (intg=0;g<lengthof(gaps);g++)

‎src/backend/access/nbtree/nbtutils.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,13 +2486,6 @@ _bt_check_natts(Relation rel, bool heapkeyspace, Page page, OffsetNumber offnum)
24862486
Assert(offnum >=FirstOffsetNumber&&
24872487
offnum <=PageGetMaxOffsetNumber(page));
24882488

2489-
/*
2490-
* Mask allocated for number of keys in index tuple must be able to fit
2491-
* maximum possible number of index attributes
2492-
*/
2493-
StaticAssertStmt(BT_OFFSET_MASK >=INDEX_MAX_KEYS,
2494-
"BT_OFFSET_MASK can't fit INDEX_MAX_KEYS");
2495-
24962489
itup= (IndexTuple)PageGetItem(page,PageGetItemId(page,offnum));
24972490
tupnatts=BTreeTupleGetNAtts(itup,rel);
24982491

‎src/backend/access/transam/clog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
275275
boolall_xact_same_page)
276276
{
277277
/* Can't use group update when PGPROC overflows. */
278-
StaticAssertStmt(THRESHOLD_SUBTRANS_CLOG_OPT <=PGPROC_MAX_CACHED_SUBXIDS,
278+
StaticAssertDecl(THRESHOLD_SUBTRANS_CLOG_OPT <=PGPROC_MAX_CACHED_SUBXIDS,
279279
"group clog threshold less than PGPROC cached subxids");
280280

281281
/*

‎src/backend/access/transam/xlog.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3883,15 +3883,6 @@ WriteControlFile(void)
38833883
intfd;
38843884
charbuffer[PG_CONTROL_FILE_SIZE];/* need not be aligned */
38853885

3886-
/*
3887-
* Ensure that the size of the pg_control data structure is sane. See the
3888-
* comments for these symbols in pg_control.h.
3889-
*/
3890-
StaticAssertStmt(sizeof(ControlFileData) <=PG_CONTROL_MAX_SAFE_SIZE,
3891-
"pg_control is too large for atomic disk writes");
3892-
StaticAssertStmt(sizeof(ControlFileData) <=PG_CONTROL_FILE_SIZE,
3893-
"sizeof(ControlFileData) exceeds PG_CONTROL_FILE_SIZE");
3894-
38953886
/*
38963887
* Initialize version and compatibility-check fields
38973888
*/

‎src/backend/backup/basebackup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ perform_base_backup(basebackup_options *opt, bbsink *sink)
370370
else
371371
{
372372
/* Properly terminate the tarfile. */
373-
StaticAssertStmt(2*TAR_BLOCK_SIZE <=BLCKSZ,
373+
StaticAssertDecl(2*TAR_BLOCK_SIZE <=BLCKSZ,
374374
"BLCKSZ too small for 2 tar blocks");
375375
memset(sink->bbs_buffer,0,2*TAR_BLOCK_SIZE);
376376
bbsink_archive_contents(sink,2*TAR_BLOCK_SIZE);
@@ -1745,7 +1745,7 @@ _tarWriteHeader(bbsink *sink, const char *filename, const char *linktarget,
17451745
* large enough to fit an entire tar block. We double-check by means
17461746
* of these assertions.
17471747
*/
1748-
StaticAssertStmt(TAR_BLOCK_SIZE <=BLCKSZ,
1748+
StaticAssertDecl(TAR_BLOCK_SIZE <=BLCKSZ,
17491749
"BLCKSZ too small for tar block");
17501750
Assert(sink->bbs_buffer_length >=TAR_BLOCK_SIZE);
17511751

‎src/backend/catalog/dependency.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ static const Oid object_classes[] = {
191191
TransformRelationId/* OCLASS_TRANSFORM */
192192
};
193193

194+
/*
195+
* Make sure object_classes is kept up to date with the ObjectClass enum.
196+
*/
197+
StaticAssertDecl(lengthof(object_classes)==LAST_OCLASS+1,
198+
"object_classes[] must cover all ObjectClasses");
199+
194200

195201
staticvoidfindDependentObjects(constObjectAddress*object,
196202
intobjflags,
@@ -2550,12 +2556,6 @@ add_object_address(ObjectClass oclass, Oid objectId, int32 subId,
25502556
{
25512557
ObjectAddress*item;
25522558

2553-
/*
2554-
* Make sure object_classes is kept up to date with the ObjectClass enum.
2555-
*/
2556-
StaticAssertStmt(lengthof(object_classes)==LAST_OCLASS+1,
2557-
"object_classes[] must cover all ObjectClasses");
2558-
25592559
/* enlarge array if needed */
25602560
if (addrs->numrefs >=addrs->maxrefs)
25612561
{

‎src/backend/executor/execExprInterp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
496496
&&CASE_EEOP_LAST
497497
};
498498

499-
StaticAssertStmt(lengthof(dispatch_table)==EEOP_LAST+1,
499+
StaticAssertDecl(lengthof(dispatch_table)==EEOP_LAST+1,
500500
"dispatch_table out of whack with ExprEvalOp");
501501

502502
if (unlikely(state==NULL))

‎src/backend/libpq/auth-scram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ scram_mock_salt(const char *username)
14431443
* not larger than the SHA256 digest length. If the salt is smaller, the
14441444
* caller will just ignore the extra data.)
14451445
*/
1446-
StaticAssertStmt(PG_SHA256_DIGEST_LENGTH >=SCRAM_DEFAULT_SALT_LEN,
1446+
StaticAssertDecl(PG_SHA256_DIGEST_LENGTH >=SCRAM_DEFAULT_SALT_LEN,
14471447
"salt length greater than SHA256 digest length");
14481448

14491449
ctx=pg_cryptohash_create(PG_SHA256);

‎src/backend/libpq/hba.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ static const char *const UserAuthName[] =
127127
"peer"
128128
};
129129

130+
/*
131+
* Make sure UserAuthName[] tracks additions to the UserAuth enum
132+
*/
133+
StaticAssertDecl(lengthof(UserAuthName)==USER_AUTH_LAST+1,
134+
"UserAuthName[] must match the UserAuth enum");
135+
130136

131137
staticList*tokenize_expand_file(List*tokens,constchar*outer_filename,
132138
constchar*inc_filename,intelevel,
@@ -3117,11 +3123,5 @@ hba_getauthmethod(hbaPort *port)
31173123
constchar*
31183124
hba_authname(UserAuthauth_method)
31193125
{
3120-
/*
3121-
* Make sure UserAuthName[] tracks additions to the UserAuth enum
3122-
*/
3123-
StaticAssertStmt(lengthof(UserAuthName)==USER_AUTH_LAST+1,
3124-
"UserAuthName[] must match the UserAuth enum");
3125-
31263126
returnUserAuthName[auth_method];
31273127
}

‎src/backend/port/atomics.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pg_extern_compiler_barrier(void)
5454
void
5555
pg_atomic_init_flag_impl(volatilepg_atomic_flag*ptr)
5656
{
57-
StaticAssertStmt(sizeof(ptr->sema) >=sizeof(slock_t),
57+
StaticAssertDecl(sizeof(ptr->sema) >=sizeof(slock_t),
5858
"size mismatch of atomic_flag vs slock_t");
5959

6060
#ifndefHAVE_SPINLOCKS
@@ -105,7 +105,7 @@ pg_atomic_unlocked_test_flag_impl(volatile pg_atomic_flag *ptr)
105105
void
106106
pg_atomic_init_u32_impl(volatilepg_atomic_uint32*ptr,uint32val_)
107107
{
108-
StaticAssertStmt(sizeof(ptr->sema) >=sizeof(slock_t),
108+
StaticAssertDecl(sizeof(ptr->sema) >=sizeof(slock_t),
109109
"size mismatch of atomic_uint32 vs slock_t");
110110

111111
/*
@@ -181,7 +181,7 @@ pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_)
181181
void
182182
pg_atomic_init_u64_impl(volatilepg_atomic_uint64*ptr,uint64val_)
183183
{
184-
StaticAssertStmt(sizeof(ptr->sema) >=sizeof(slock_t),
184+
StaticAssertDecl(sizeof(ptr->sema) >=sizeof(slock_t),
185185
"size mismatch of atomic_uint64 vs slock_t");
186186

187187
/*

‎src/backend/storage/lmgr/lwlock.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ extern slock_t *ShmemLock;
108108
/* Must be greater than MAX_BACKENDS - which is 2^23-1, so we're fine. */
109109
#defineLW_SHARED_MASK((uint32) ((1 << 24)-1))
110110

111+
StaticAssertDecl(LW_VAL_EXCLUSIVE> (uint32)MAX_BACKENDS,
112+
"MAX_BACKENDS too big for lwlock.c");
113+
111114
/*
112115
* There are three sorts of LWLock "tranches":
113116
*
@@ -466,12 +469,6 @@ LWLockShmemSize(void)
466469
void
467470
CreateLWLocks(void)
468471
{
469-
StaticAssertStmt(LW_VAL_EXCLUSIVE> (uint32)MAX_BACKENDS,
470-
"MAX_BACKENDS too big for lwlock.c");
471-
472-
StaticAssertStmt(sizeof(LWLock) <=LWLOCK_PADDED_SIZE,
473-
"Miscalculated LWLock padding");
474-
475472
if (!IsUnderPostmaster)
476473
{
477474
SizespaceLocks=LWLockShmemSize();

‎src/backend/storage/page/itemptr.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
#include"storage/itemptr.h"
1818

1919

20+
/*
21+
* We really want ItemPointerData to be exactly 6 bytes.
22+
*/
23+
StaticAssertDecl(sizeof(ItemPointerData)==3*sizeof(uint16),
24+
"ItemPointerData struct is improperly padded");
25+
2026
/*
2127
* ItemPointerEquals
2228
*Returns true if both item pointers point to the same item,
@@ -28,13 +34,6 @@
2834
bool
2935
ItemPointerEquals(ItemPointerpointer1,ItemPointerpointer2)
3036
{
31-
/*
32-
* We really want ItemPointerData to be exactly 6 bytes. This is rather a
33-
* random place to check, but there is no better place.
34-
*/
35-
StaticAssertStmt(sizeof(ItemPointerData)==3*sizeof(uint16),
36-
"ItemPointerData struct is improperly padded");
37-
3837
if (ItemPointerGetBlockNumber(pointer1)==
3938
ItemPointerGetBlockNumber(pointer2)&&
4039
ItemPointerGetOffsetNumber(pointer1)==

‎src/backend/utils/adt/numeric.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4187,7 +4187,8 @@ int64_div_fast_to_numeric(int64 val1, int log10val2)
41874187
{
41884188
staticintpow10[]= {1,10,100,1000};
41894189

4190-
StaticAssertStmt(lengthof(pow10)==DEC_DIGITS,"mismatch with DEC_DIGITS");
4190+
StaticAssertDecl(lengthof(pow10)==DEC_DIGITS,"mismatch with DEC_DIGITS");
4191+
41914192
if (unlikely(pg_mul_s64_overflow(val1,pow10[DEC_DIGITS-m],&val1)))
41924193
{
41934194
/*

‎src/backend/utils/adt/tsginidx.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,6 @@ gin_tsquery_consistent(PG_FUNCTION_ARGS)
236236
* query.
237237
*/
238238
gcv.first_item=GETQUERY(query);
239-
StaticAssertStmt(sizeof(GinTernaryValue)==sizeof(bool),
240-
"sizes of GinTernaryValue and bool are not equal");
241239
gcv.check= (GinTernaryValue*)check;
242240
gcv.map_item_operand= (int*) (extra_data[0]);
243241

‎src/backend/utils/adt/xid8funcs.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ typedef struct
7474
#definePG_SNAPSHOT_MAX_NXIP \
7575
((MaxAllocSize - offsetof(pg_snapshot, xip)) / sizeof(FullTransactionId))
7676

77+
/*
78+
* Compile-time limits on the procarray (MAX_BACKENDS processes plus
79+
* MAX_BACKENDS prepared transactions) guarantee nxip won't be too large.
80+
*/
81+
StaticAssertDecl(MAX_BACKENDS*2 <=PG_SNAPSHOT_MAX_NXIP,
82+
"possible overflow in pg_current_snapshot()");
83+
84+
7785
/*
7886
* Helper to get a TransactionId from a 64-bit xid with wraparound detection.
7987
*
@@ -402,13 +410,6 @@ pg_current_snapshot(PG_FUNCTION_ARGS)
402410
if (cur==NULL)
403411
elog(ERROR,"no active snapshot set");
404412

405-
/*
406-
* Compile-time limits on the procarray (MAX_BACKENDS processes plus
407-
* MAX_BACKENDS prepared transactions) guarantee nxip won't be too large.
408-
*/
409-
StaticAssertStmt(MAX_BACKENDS*2 <=PG_SNAPSHOT_MAX_NXIP,
410-
"possible overflow in pg_current_snapshot()");
411-
412413
/* allocate */
413414
nxip=cur->xcnt;
414415
snap=palloc(PG_SNAPSHOT_SIZE(nxip));

‎src/backend/utils/cache/syscache.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,9 @@ static const struct cachedesc cacheinfo[] = {
10401040
}
10411041
};
10421042

1043+
StaticAssertDecl(lengthof(cacheinfo)==SysCacheSize,
1044+
"SysCacheSize does not match syscache.c's array");
1045+
10431046
staticCatCache*SysCache[SysCacheSize];
10441047

10451048
staticboolCacheInitialized= false;
@@ -1068,9 +1071,6 @@ InitCatalogCache(void)
10681071
{
10691072
intcacheId;
10701073

1071-
StaticAssertStmt(lengthof(cacheinfo)==SysCacheSize,
1072-
"SysCacheSize does not match syscache.c's array");
1073-
10741074
Assert(!CacheInitialized);
10751075

10761076
SysCacheRelationOidSize=SysCacheSupportingRelOidSize=0;

‎src/backend/utils/mmgr/aset.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ AllocSetFreeIndex(Size size)
306306
tsize;
307307

308308
/* Statically assert that we only have a 16-bit input value. */
309-
StaticAssertStmt(ALLOC_CHUNK_LIMIT< (1 <<16),
309+
StaticAssertDecl(ALLOC_CHUNK_LIMIT< (1 <<16),
310310
"ALLOC_CHUNK_LIMIT must be less than 64kB");
311311

312312
tsize=size-1;
@@ -358,10 +358,10 @@ AllocSetContextCreateInternal(MemoryContext parent,
358358
AllocBlockblock;
359359

360360
/* ensure MemoryChunk's size is properly maxaligned */
361-
StaticAssertStmt(ALLOC_CHUNKHDRSZ==MAXALIGN(ALLOC_CHUNKHDRSZ),
361+
StaticAssertDecl(ALLOC_CHUNKHDRSZ==MAXALIGN(ALLOC_CHUNKHDRSZ),
362362
"sizeof(MemoryChunk) is not maxaligned");
363363
/* check we have enough space to store the freelist link */
364-
StaticAssertStmt(sizeof(AllocFreeListLink) <= (1 <<ALLOC_MINBITS),
364+
StaticAssertDecl(sizeof(AllocFreeListLink) <= (1 <<ALLOC_MINBITS),
365365
"sizeof(AllocFreeListLink) larger than minimum allocation size");
366366

367367
/*

‎src/backend/utils/mmgr/generation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ GenerationContextCreate(MemoryContext parent,
167167
GenerationBlock*block;
168168

169169
/* ensure MemoryChunk's size is properly maxaligned */
170-
StaticAssertStmt(Generation_CHUNKHDRSZ==MAXALIGN(Generation_CHUNKHDRSZ),
170+
StaticAssertDecl(Generation_CHUNKHDRSZ==MAXALIGN(Generation_CHUNKHDRSZ),
171171
"sizeof(MemoryChunk) is not maxaligned");
172172

173173
/*

‎src/backend/utils/mmgr/slab.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ SlabContextCreate(MemoryContext parent,
151151
inti;
152152

153153
/* ensure MemoryChunk's size is properly maxaligned */
154-
StaticAssertStmt(Slab_CHUNKHDRSZ==MAXALIGN(Slab_CHUNKHDRSZ),
154+
StaticAssertDecl(Slab_CHUNKHDRSZ==MAXALIGN(Slab_CHUNKHDRSZ),
155155
"sizeof(MemoryChunk) is not maxaligned");
156156
Assert(MAXALIGN(chunkSize) <=MEMORYCHUNK_MAX_VALUE);
157157

‎src/common/checksum_helper.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ pg_checksum_final(pg_checksum_context *context, uint8 *output)
177177
{
178178
intretval=0;
179179

180-
StaticAssertStmt(sizeof(pg_crc32c) <=PG_CHECKSUM_MAX_LENGTH,
180+
StaticAssertDecl(sizeof(pg_crc32c) <=PG_CHECKSUM_MAX_LENGTH,
181181
"CRC-32C digest too big for PG_CHECKSUM_MAX_LENGTH");
182-
StaticAssertStmt(PG_SHA224_DIGEST_LENGTH <=PG_CHECKSUM_MAX_LENGTH,
182+
StaticAssertDecl(PG_SHA224_DIGEST_LENGTH <=PG_CHECKSUM_MAX_LENGTH,
183183
"SHA224 digest too big for PG_CHECKSUM_MAX_LENGTH");
184-
StaticAssertStmt(PG_SHA256_DIGEST_LENGTH <=PG_CHECKSUM_MAX_LENGTH,
184+
StaticAssertDecl(PG_SHA256_DIGEST_LENGTH <=PG_CHECKSUM_MAX_LENGTH,
185185
"SHA256 digest too big for PG_CHECKSUM_MAX_LENGTH");
186-
StaticAssertStmt(PG_SHA384_DIGEST_LENGTH <=PG_CHECKSUM_MAX_LENGTH,
186+
StaticAssertDecl(PG_SHA384_DIGEST_LENGTH <=PG_CHECKSUM_MAX_LENGTH,
187187
"SHA384 digest too big for PG_CHECKSUM_MAX_LENGTH");
188-
StaticAssertStmt(PG_SHA512_DIGEST_LENGTH <=PG_CHECKSUM_MAX_LENGTH,
188+
StaticAssertDecl(PG_SHA512_DIGEST_LENGTH <=PG_CHECKSUM_MAX_LENGTH,
189189
"SHA512 digest too big for PG_CHECKSUM_MAX_LENGTH");
190190

191191
switch (context->type)

‎src/common/controldata_utils.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,6 @@ update_controlfile(const char *DataDir,
149149
charbuffer[PG_CONTROL_FILE_SIZE];
150150
charControlFilePath[MAXPGPATH];
151151

152-
/*
153-
* Apply the same static assertions as in backend's WriteControlFile().
154-
*/
155-
StaticAssertStmt(sizeof(ControlFileData) <=PG_CONTROL_MAX_SAFE_SIZE,
156-
"pg_control is too large for atomic disk writes");
157-
StaticAssertStmt(sizeof(ControlFileData) <=PG_CONTROL_FILE_SIZE,
158-
"sizeof(ControlFileData) exceeds PG_CONTROL_FILE_SIZE");
159-
160152
/* Update timestamp */
161153
ControlFile->time= (pg_time_t)time(NULL);
162154

‎src/common/encnames.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,9 @@ static const char *const pg_enc2icu_tbl[] =
451451
"KOI8-U",/* PG_KOI8U */
452452
};
453453

454+
StaticAssertDecl(lengthof(pg_enc2icu_tbl)==PG_ENCODING_BE_LAST+1,
455+
"pg_enc2icu_tbl incomplete");
456+
454457

455458
/*
456459
* Is this encoding supported by ICU?
@@ -469,9 +472,6 @@ is_encoding_supported_by_icu(int encoding)
469472
constchar*
470473
get_encoding_name_for_icu(intencoding)
471474
{
472-
StaticAssertStmt(lengthof(pg_enc2icu_tbl)==PG_ENCODING_BE_LAST+1,
473-
"pg_enc2icu_tbl incomplete");
474-
475475
if (!PG_VALID_BE_ENCODING(encoding))
476476
returnNULL;
477477
returnpg_enc2icu_tbl[encoding];

‎src/include/access/gin.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ typedef struct GinStatsData
5757
*/
5858
typedefcharGinTernaryValue;
5959

60+
StaticAssertDecl(sizeof(GinTernaryValue)==sizeof(bool),
61+
"sizes of GinTernaryValue and bool are not equal");
62+
6063
#defineGIN_FALSE0/* item is not present / does not match */
6164
#defineGIN_TRUE1/* item is present / matches */
6265
#defineGIN_MAYBE2/* don't know if item is present / don't know

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp