diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-04-05 18:41:09 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-04-05 18:41:21 -0400 |
commit | 09c1c6ab4bc5764dd69c53ccfd43b2060b1fd090 (patch) | |
tree | 0b5eacefe5007d52388f475499b018cccd228c0e /src/backend/access/common/indextuple.c | |
parent | 49f49defe7c0a330cca084de5da14ccdfdafc6a3 (diff) | |
download | postgresql-09c1c6ab4bc5764dd69c53ccfd43b2060b1fd090.tar.gz postgresql-09c1c6ab4bc5764dd69c53ccfd43b2060b1fd090.zip |
Support INCLUDE'd columns in SP-GiST.
Not much to say here: does what it says on the tin.
We steal a previously-always-zero bit from the nextOffset
field of leaf index tuples in order to track whether there
is a nulls bitmap. Otherwise it works about like included
columns in other index types.
Pavel Borisov, reviewed by Andrey Borodin and Anastasia Lubennikova,
and rather heavily editorialized on by me
Discussion: https://postgr.es/m/CALT9ZEFi-vMp4faht9f9Junb1nO3NOSjhpxTmbm1UGLMsLqiEQ@mail.gmail.com
Diffstat (limited to 'src/backend/access/common/indextuple.c')
-rw-r--r-- | src/backend/access/common/indextuple.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c index ae932691af8..a4cb8914cc6 100644 --- a/src/backend/access/common/indextuple.c +++ b/src/backend/access/common/indextuple.c @@ -446,22 +446,37 @@ void index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor, Datum *values, bool *isnull) { - int hasnulls = IndexTupleHasNulls(tup); - int natts = tupleDescriptor->natts; /* number of atts to extract */ - int attnum; char *tp; /* ptr to tuple data */ - int off; /* offset in tuple data */ bits8 *bp; /* ptr to null bitmap in tuple */ - bool slow = false; /* can we use/set attcacheoff? */ - - /* Assert to protect callers who allocate fixed-size arrays */ - Assert(natts <= INDEX_MAX_KEYS); /* XXX "knows" t_bits are just after fixed tuple header! */ bp = (bits8 *) ((char *) tup + sizeof(IndexTupleData)); tp = (char *) tup + IndexInfoFindDataOffset(tup->t_info); - off = 0; + + index_deform_tuple_internal(tupleDescriptor, values, isnull, + tp, bp, IndexTupleHasNulls(tup)); +} + +/* + * Convert an index tuple into Datum/isnull arrays, + * without assuming any specific layout of the index tuple header. + * + * Caller must supply pointer to data area, pointer to nulls bitmap + * (which can be NULL if !hasnulls), and hasnulls flag. + */ +void +index_deform_tuple_internal(TupleDesc tupleDescriptor, + Datum *values, bool *isnull, + char *tp, bits8 *bp, int hasnulls) +{ + int natts = tupleDescriptor->natts; /* number of atts to extract */ + int attnum; + int off = 0; /* offset in tuple data */ + bool slow = false; /* can we use/set attcacheoff? */ + + /* Assert to protect callers who allocate fixed-size arrays */ + Assert(natts <= INDEX_MAX_KEYS); for (attnum = 0; attnum < natts; attnum++) { |