Use wrappers of PG_DETOAST_DATUM_PACKED() more.
authorNoah Misch <noah@leadboat.com>
Sun, 12 Mar 2017 23:35:34 +0000 (19:35 -0400)
committerNoah Misch <noah@leadboat.com>
Sun, 12 Mar 2017 23:35:34 +0000 (19:35 -0400)
commit3a0d473192b2045cbaf997df8437e7762d34f3ba
tree8bdf7e5e8f6a69041ff3fd4b2114cb9e8cbd69d4
parent9d7726c2ba06b932f791f2d0cc5acf73cc0b4dca
Use wrappers of PG_DETOAST_DATUM_PACKED() more.

This makes almost all core code follow the policy introduced in the
previous commit.  Specific decisions:

- Text search support functions with char* and length arguments, such as
  prsstart and lexize, may receive unaligned strings.  I doubt
  maintainers of non-core text search code will notice.

- Use plain VARDATA() on values detoasted or synthesized earlier in the
  same function.  Use VARDATA_ANY() on varlenas sourced outside the
  function, even if they happen to always have four-byte headers.  As an
  exception, retain the universal practice of using VARDATA() on return
  values of SendFunctionCall().

- Retain PG_GETARG_BYTEA_P() in pageinspect.  (Page images are too large
  for a one-byte header, so this misses no optimization.)  Sites that do
  not call get_page_from_raw() typically need the four-byte alignment.

- For now, do not change btree_gist.  Its use of four-byte headers in
  memory is partly entangled with storage of 4-byte headers inside
  GBT_VARKEY, on disk.

- For now, do not change gtrgm_consistent() or gtrgm_distance().  They
  incorporate the varlena header into a cache, and there are multiple
  credible implementation strategies to consider.
59 files changed:
contrib/adminpack/adminpack.c
contrib/dblink/dblink.c
contrib/fuzzystrmatch/dmetaphone.c
contrib/fuzzystrmatch/fuzzystrmatch.c
contrib/intarray/_int_op.c
contrib/pageinspect/btreefuncs.c
contrib/pageinspect/rawpage.c
contrib/pg_prewarm/pg_prewarm.c
contrib/pg_trgm/trgm_gin.c
contrib/pg_trgm/trgm_gist.c
contrib/pg_trgm/trgm_op.c
contrib/pgcrypto/pgcrypto.c
contrib/pgcrypto/pgp-pgsql.c
contrib/pgrowlocks/pgrowlocks.c
contrib/pgstattuple/pgstatindex.c
contrib/pgstattuple/pgstattuple.c
contrib/sepgsql/label.c
contrib/spi/autoinc.c
contrib/sslinfo/sslinfo.c
contrib/unaccent/unaccent.c
contrib/uuid-ossp/uuid-ossp.c
contrib/xml2/xpath.c
contrib/xml2/xslt_proc.c
src/backend/access/spgist/spgtextproc.c
src/backend/access/transam/xlogfuncs.c
src/backend/commands/extension.c
src/backend/commands/sequence.c
src/backend/commands/trigger.c
src/backend/commands/tsearchcmds.c
src/backend/executor/execQual.c
src/backend/libpq/be-fsstubs.c
src/backend/replication/logical/origin.c
src/backend/tsearch/dict.c
src/backend/tsearch/to_tsany.c
src/backend/tsearch/wparser.c
src/backend/utils/adt/acl.c
src/backend/utils/adt/char.c
src/backend/utils/adt/dbsize.c
src/backend/utils/adt/encode.c
src/backend/utils/adt/formatting.c
src/backend/utils/adt/genfile.c
src/backend/utils/adt/json.c
src/backend/utils/adt/jsonb.c
src/backend/utils/adt/jsonfuncs.c
src/backend/utils/adt/like.c
src/backend/utils/adt/numeric.c
src/backend/utils/adt/quote.c
src/backend/utils/adt/rangetypes.c
src/backend/utils/adt/regproc.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/selfuncs.c
src/backend/utils/adt/tid.c
src/backend/utils/adt/tsquery_rewrite.c
src/backend/utils/adt/tsvector_op.c
src/backend/utils/adt/varlena.c
src/backend/utils/adt/xml.c
src/backend/utils/misc/rls.c
src/pl/plperl/Util.xs
src/pl/plpython/plpy_typeio.c