From 7cdb633c89da82d4c6fdfba007a9ff05a9dff29e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 6 Feb 2026 20:46:03 -0500 Subject: [PATCH] Make some minor cleanups in typalign-related code. Commit 7b378237a widened AclMode to 64 bits, which implies that the alignment of AclItem is now determined by an int64 field. That commit correctly set the typalign for SQL type aclitem to 'd', but it missed the hard-wired knowledge about _aclitem in bootstrap.c. This doesn't seem to have caused any ill effects, probably because we never try to fill a non-null value into an aclitem[] column during bootstrap. Nonetheless, it's clearly a gotcha waiting to happen, so fix it up. In passing, also fix a couple of typanalyze functions that were using hard-coded typalign constants when they could just as easily use greppable TYPALIGN_xxx macros. Noticed these while working on a patch to expand the set of typalign values. I doubt we are going to pursue that path, but these fixes still seem worth a quick commit. Discussion: https://postgr.es/m/1127261.1769649624@sss.pgh.pa.us --- src/backend/bootstrap/bootstrap.c | 2 +- src/backend/tsearch/ts_typanalyze.c | 2 +- src/backend/utils/adt/rangetypes_typanalyze.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index dd57624b4f9..e8f825b3d65 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -137,7 +137,7 @@ static const struct typinfo TypInfo[] = { F_ARRAY_IN, F_ARRAY_OUT}, {"_char", 1002, CHAROID, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, InvalidOid, F_ARRAY_IN, F_ARRAY_OUT}, - {"_aclitem", 1034, ACLITEMOID, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, InvalidOid, + {"_aclitem", 1034, ACLITEMOID, -1, false, TYPALIGN_DOUBLE, TYPSTORAGE_EXTENDED, InvalidOid, F_ARRAY_IN, F_ARRAY_OUT} }; diff --git a/src/backend/tsearch/ts_typanalyze.c b/src/backend/tsearch/ts_typanalyze.c index 0c513d694e7..48ee050e37f 100644 --- a/src/backend/tsearch/ts_typanalyze.c +++ b/src/backend/tsearch/ts_typanalyze.c @@ -444,7 +444,7 @@ compute_tsvector_stats(VacAttrStats *stats, stats->statypid[0] = TEXTOID; stats->statyplen[0] = -1; /* typlen, -1 for varlena */ stats->statypbyval[0] = false; - stats->statypalign[0] = 'i'; + stats->statypalign[0] = TYPALIGN_INT; } } else diff --git a/src/backend/utils/adt/rangetypes_typanalyze.c b/src/backend/utils/adt/rangetypes_typanalyze.c index 38d12dedbc5..278d4e6941a 100644 --- a/src/backend/utils/adt/rangetypes_typanalyze.c +++ b/src/backend/utils/adt/rangetypes_typanalyze.c @@ -398,7 +398,7 @@ compute_range_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, stats->statypid[slot_idx] = FLOAT8OID; stats->statyplen[slot_idx] = sizeof(float8); stats->statypbyval[slot_idx] = true; - stats->statypalign[slot_idx] = 'd'; + stats->statypalign[slot_idx] = TYPALIGN_DOUBLE; /* Store the fraction of empty ranges */ emptyfrac = palloc_object(float4); -- 2.47.3