diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-03-04 10:34:25 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-03-04 10:34:25 -0500 |
commit | 3ed2005ff595d349276e5b2edeca1a8100b08c87 (patch) | |
tree | 361ca1ffdc3e816c98d45a0357c92d25ba71d760 /src/backend/access/common/heaptuple.c | |
parent | 0ad6f848eef267489d4aee7306c16f96454b7a64 (diff) | |
download | postgresql-3ed2005ff595d349276e5b2edeca1a8100b08c87.tar.gz postgresql-3ed2005ff595d349276e5b2edeca1a8100b08c87.zip |
Introduce macros for typalign and typstorage constants.
Our usual practice for "poor man's enum" catalog columns is to define
macros for the possible values and use those, not literal constants,
in C code. But for some reason lost in the mists of time, this was
never done for typalign/attalign or typstorage/attstorage. It's never
too late to make it better though, so let's do that.
The reason I got interested in this right now is the need to duplicate
some uses of the TYPSTORAGE constants in an upcoming ALTER TYPE patch.
But in general, this sort of change aids greppability and readability,
so it's a good idea even without any specific motivation.
I may have missed a few places that could be converted, and it's even
more likely that pending patches will re-introduce some hard-coded
references. But that's not fatal --- there's no expectation that
we'd actually change any of these values. We can clean up stragglers
over time.
Discussion: https://postgr.es/m/16457.1583189537@sss.pgh.pa.us
Diffstat (limited to 'src/backend/access/common/heaptuple.c')
-rw-r--r-- | src/backend/access/common/heaptuple.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c index b7c864cfacf..f89769f3793 100644 --- a/src/backend/access/common/heaptuple.c +++ b/src/backend/access/common/heaptuple.c @@ -24,7 +24,7 @@ * that have been put into a tuple but never sent to disk. Hopefully there * are few such places. * - * Varlenas still have alignment 'i' (or 'd') in pg_type/pg_attribute, since + * Varlenas still have alignment INT (or DOUBLE) in pg_type/pg_attribute, since * that's the normal requirement for the untoasted format. But we ignore that * for the 1-byte-header format. This means that the actual start position * of a varlena datum may vary depending on which format it has. To determine @@ -39,7 +39,7 @@ * catalog, this is now risky: it's only safe if the preceding field is * word-aligned, so that there will never be any padding. * - * We don't pack varlenas whose attstorage is 'p', since the data type + * We don't pack varlenas whose attstorage is PLAIN, since the data type * isn't expecting to have to detoast values. This is used in particular * by oidvector and int2vector, which are used in the system catalogs * and we'd like to still refer to them via C struct offsets. @@ -66,10 +66,10 @@ /* Does att's datatype allow packing into the 1-byte-header varlena format? */ #define ATT_IS_PACKABLE(att) \ - ((att)->attlen == -1 && (att)->attstorage != 'p') + ((att)->attlen == -1 && (att)->attstorage != TYPSTORAGE_PLAIN) /* Use this if it's already known varlena */ #define VARLENA_ATT_IS_PACKABLE(att) \ - ((att)->attstorage != 'p') + ((att)->attstorage != TYPSTORAGE_PLAIN) /* ---------------------------------------------------------------- @@ -274,7 +274,7 @@ fill_val(Form_pg_attribute att, { /* cstring ... never needs alignment */ *infomask |= HEAP_HASVARWIDTH; - Assert(att->attalign == 'c'); + Assert(att->attalign == TYPALIGN_CHAR); data_length = strlen(DatumGetCString(datum)) + 1; memcpy(data, DatumGetPointer(datum), data_length); } |