postgresql/src/backend
Tom Lane 1ebdec8c03 Rethink handling of pass-by-value leaf datums in SP-GiST.
The existing convention in SP-GiST is that any pass-by-value datatype
is stored in Datum representation, i.e. it's of width sizeof(Datum)
even when typlen is less than that.  This is okay, or at least it's
too late to change it, for prefix datums and node-label datums in inner
(upper) tuples.  But it's problematic for leaf datums, because we'd
prefer those to be stored in Postgres' standard on-disk representation
so that we can easily extend leaf tuples to carry additional "included"
columns.

I believe, however, that we can get away with just up and changing that.
This would be an unacceptable on-disk-format break, but there are two
big mitigating factors:

1. It seems quite unlikely that there are any SP-GiST opclasses out
there that use pass-by-value leaf datatypes.  Certainly none of the
ones in core do, nor has codesearch.debian.net heard of any.  Given
what SP-GiST is good for, it's hard to conceive of a use-case where
the leaf-level values would be both small and fixed-width.  (As an
example, if you wanted to index text values with the leaf level being
just a byte, then every text string would have to be represented
with one level of inner tuple per preceding byte, which would be
horrendously space-inefficient and slow to access.  You always want
to use as few inner-tuple levels as possible, leaving as much as
possible in the leaf values.)

2. Even granting that you have such an index, this change only
breaks things on big-endian machines.  On little-endian, the high
order bytes of the Datum format will now just appear to be alignment
padding space.

So, change the code to store pass-by-value leaf datums in their
usual on-disk form.  Inner-tuple datums are not touched.

This is extracted from a larger patch that intends to add support for
"included" columns.  I'm committing it separately for visibility in
our commit logs.

Pavel Borisov and Tom Lane, reviewed by Andrey Borodin

Discussion: https://postgr.es/m/CALT9ZEFi-vMp4faht9f9Junb1nO3NOSjhpxTmbm1UGLMsLqiEQ@mail.gmail.com
2021-04-01 17:55:17 -04:00
..
access Rethink handling of pass-by-value leaf datums in SP-GiST. 2021-04-01 17:55:17 -04:00
bootstrap Allow composite types in catalog bootstrap 2021-03-24 00:47:52 +01:00
catalog Fix has_column_privilege function corner case 2021-03-31 13:55:25 -04:00
commands Rename Default Roles to Predefined Roles 2021-04-01 15:32:06 -04:00
executor Revert b6002a796 2021-04-01 13:33:23 +13:00
foreign Update copyright for 2021 2021-01-02 13:06:25 -05:00
jit Use errmsg_internal for debug messages 2021-02-17 11:33:25 +01:00
lib Update copyright for 2021 2021-01-02 13:06:25 -05:00
libpq Allow matching the DN of a client certificate for authentication 2021-03-29 15:49:39 -04:00
main Update copyright for 2021 2021-01-02 13:06:25 -05:00
nodes Revert b6002a796 2021-04-01 13:33:23 +13:00
optimizer Revert b6002a796 2021-04-01 13:33:23 +13:00
parser Allow an alias to be attached to a JOIN ... USING 2021-03-31 17:10:50 +02:00
partitioning ALTER TABLE ... DETACH PARTITION ... CONCURRENTLY 2021-03-25 18:00:28 -03:00
po Translation updates 2020-05-18 12:49:30 +02:00
port Use errmsg_internal for debug messages 2021-02-17 11:33:25 +01:00
postmaster Add support for asynchronous execution. 2021-03-31 18:45:00 +09:00
regex Further tweak memory management for regex DFAs. 2021-03-08 16:32:29 -05:00
replication Rename Default Roles to Predefined Roles 2021-04-01 15:32:06 -04:00
rewrite Rework planning and execution of UPDATE and DELETE. 2021-03-31 11:52:37 -04:00
snowball Update snowball 2021-02-19 08:10:15 +01:00
statistics Don't prematurely cram a value into a short int. 2021-03-31 16:45:24 -04:00
storage Rename Default Roles to Predefined Roles 2021-04-01 15:32:06 -04:00
tcop Extended statistics on expressions 2021-03-27 00:01:11 +01:00
tsearch Don't leak compiled regex(es) when an ispell cache entry is dropped. 2021-03-18 22:22:47 -04:00
utils Rename Default Roles to Predefined Roles 2021-04-01 15:32:06 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Add missing gettext triggers 2020-04-28 13:35:40 +02:00