pgsql: Introduce macros for typalign and typstorage constants.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Introduce macros for typalign and typstorage constants.
Date: 2020-03-04 15:34:36
Message-ID: E1j9W2e-0000hC-HW@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3ed2005ff595d349276e5b2edeca1a8100b08c87

Modified Files
--------------
contrib/hstore/hstore_gin.c | 2 +-
contrib/hstore/hstore_gist.c | 4 +-
contrib/hstore/hstore_io.c | 6 +--
contrib/hstore/hstore_op.c | 12 +++---
contrib/pageinspect/btreefuncs.c | 2 +-
contrib/pageinspect/ginfuncs.c | 5 ++-
contrib/pageinspect/hashfuncs.c | 8 +++-
contrib/pageinspect/heapfuncs.c | 4 +-
contrib/pg_trgm/trgm_op.c | 2 +-
contrib/pgcrypto/pgp-pgsql.c | 4 +-
src/backend/access/common/heaptuple.c | 10 ++---
src/backend/access/common/indextuple.c | 3 +-
src/backend/access/common/reloptions.c | 6 +--
src/backend/access/common/tupdesc.c | 16 ++++----
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/access/heap/heaptoast.c | 37 ++++++++++--------
src/backend/access/table/toast_helper.c | 19 +++++----
src/backend/bootstrap/bootstrap.c | 50 ++++++++++++------------
src/backend/catalog/heap.c | 32 +++++++--------
src/backend/catalog/objectaddress.c | 10 ++---
src/backend/catalog/pg_constraint.c | 12 +++---
src/backend/catalog/pg_proc.c | 2 +-
src/backend/catalog/pg_subscription.c | 2 +-
src/backend/catalog/pg_type.c | 19 ++++-----
src/backend/catalog/toasting.c | 6 +--
src/backend/commands/analyze.c | 2 +-
src/backend/commands/event_trigger.c | 3 +-
src/backend/commands/extension.c | 18 ++++-----
src/backend/commands/functioncmds.c | 8 ++--
src/backend/commands/policy.c | 6 +--
src/backend/commands/prepare.c | 3 +-
src/backend/commands/statscmds.c | 2 +-
src/backend/commands/subscriptioncmds.c | 2 +-
src/backend/commands/tablecmds.c | 22 +++++------
src/backend/commands/typecmds.c | 48 +++++++++++------------
src/backend/executor/nodeTidscan.c | 2 +-
src/backend/jit/llvm/llvmjit_deform.c | 8 ++--
src/backend/libpq/hba.c | 2 +-
src/backend/parser/parse_type.c | 2 +-
src/backend/parser/parse_utilcmd.c | 2 +-
src/backend/replication/logical/logicalfuncs.c | 2 +-
src/backend/tsearch/dict.c | 2 +-
src/backend/utils/adt/arrayutils.c | 2 +-
src/backend/utils/adt/enum.c | 3 +-
src/backend/utils/adt/float.c | 10 ++---
src/backend/utils/adt/format_type.c | 3 +-
src/backend/utils/adt/json.c | 6 +--
src/backend/utils/adt/jsonb.c | 6 +--
src/backend/utils/adt/jsonb_gin.c | 2 +-
src/backend/utils/adt/jsonb_op.c | 8 ++--
src/backend/utils/adt/jsonfuncs.c | 12 +++---
src/backend/utils/adt/lockfuncs.c | 4 +-
src/backend/utils/adt/name.c | 2 +-
src/backend/utils/adt/orderedsetaggs.c | 10 +++--
src/backend/utils/adt/pg_upgrade_support.c | 2 +-
src/backend/utils/adt/rangetypes.c | 4 +-
src/backend/utils/adt/regexp.c | 2 +-
src/backend/utils/adt/ruleutils.c | 10 ++---
src/backend/utils/adt/timestamp.c | 16 ++++----
src/backend/utils/adt/tsvector_op.c | 14 +++----
src/backend/utils/adt/varlena.c | 2 +-
src/backend/utils/adt/xml.c | 2 +-
src/backend/utils/cache/evtcache.c | 3 +-
src/backend/utils/cache/lsyscache.c | 4 +-
src/backend/utils/fmgr/funcapi.c | 8 ++--
src/backend/utils/misc/guc.c | 20 +++++-----
src/bin/pg_dump/pg_dump.c | 28 ++++++-------
src/include/access/toast_helper.h | 8 ++--
src/include/access/tupmacs.h | 10 +++--
src/include/catalog/pg_attribute.h | 9 +----
src/include/catalog/pg_type.h | 15 +++++++
src/include/utils/lsyscache.h | 2 +-
src/pl/plpgsql/src/pl_comp.c | 4 +-
src/pl/plpgsql/src/pl_exec.c | 2 +-
src/pl/plpython/plpy_typeio.c | 4 +-
src/test/modules/test_rls_hooks/test_rls_hooks.c | 4 +-
76 files changed, 341 insertions(+), 309 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Jeff Davis 2020-03-05 01:41:19 pgsql: Extend ExecBuildAggTrans() to support a NULL pointer check.
Previous Message Peter Eisentraut 2020-03-04 07:32:45 pgsql: Move pg_upgrade's Windows link() implementation to AC_REPLACE_FU