pgsql: Rethink handling of pass-by-value leaf datums in SP-GiST.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Rethink handling of pass-by-value leaf datums in SP-GiST.
Дата
Msg-id E1lS5Hi-0004kk-KT@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1ebdec8c03294e55a9fdb6e676a9e8de680231cc

Modified Files
--------------
src/backend/access/spgist/spgdoinsert.c | 41 +++++++++++-----------
src/backend/access/spgist/spgutils.c    | 62 ++++++++++++++++++++++++++-------
src/include/access/spgist_private.h     | 40 ++++++++++++---------
3 files changed, 94 insertions(+), 49 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Daniel Gustafsson
Дата:
Сообщение: Re: pgsql: Allow matching the DN of a client certificate for authentication
Следующее
От: Michael Paquier
Дата:
Сообщение: pgsql: Improve stability of test with vacuum_truncate in reloptions.sql