Re: SP-GiST bug.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Teodor Sigaev <teodor(at)sigaev(dot)ru>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SP-GiST bug.
Date: 2014-06-05 22:39:13
Message-ID: 26213.1402007953@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> I think what we have to do is use a different dummy value for the node
> label of a pushed-down allTheSame tuple than we do for end-of-string.
> This requires widening the node labels from uint8 to (at least) int16.
> However, I think that's essentially free because pass-by-value node
> labels are stored as Datums anyway. In fact, it might even be upward
> compatible, at least for cases that aren't broken today.

Here's a draft patch along these lines. AFAICT it is fully upward
compatible with existing indexes, although in cases where the current code
creates a zero node label for strings ending at that level, this code will
choose to push new strings into a new child node with label -1 instead, so
that there's some very small added inefficiency. I don't think we need to
tell people to reindex if we use this fix, though. I went with new
dummy labels of -1 and -2 partially so that an existing zero label would
not be a hazard for future insertions, and partly with the thought that if
we ever allow embedded \0 in strings, this coding would be able to handle
it with minimal adjustment.

Note that this fix slightly reduces the maximum safe length of a prefix
string (SPGIST_MAX_PREFIX_LENGTH). In an existing index, there might be
prefixes longer than that. The code will still work, but it's
theoretically possible that addition of nodes to such a tuple could result
in "SPGiST inner tuple size exceeds maximum" errors, if you managed to
populate all possible next-byte values at that tuple. I think the odds of
this being a problem in the field are negligible (and if it did happen,
reindexing would fix the problem).

regards, tom lane

Attachment Content-Type Size
spgist-zero-label-fix.patch text/x-diff 15.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2014-06-05 23:03:35 Re: slotname vs slot_name
Previous Message Linos 2014-06-05 21:09:46 Re: performance regression in 9.2/9.3