pgsql: Fix infinite loop when splitting inner tuples in SPGiST text ind

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix infinite loop when splitting inner tuples in SPGiST text ind
Дата
Msg-id E1Wu6E5-0003II-6A@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix infinite loop when splitting inner tuples in SPGiST text indexes.

Previously, the code used a node label of zero both for strings that
contain no bytes beyond the inner tuple's prefix, and for cases where an
"allTheSame" inner tuple has to be split to allow a string with a different
next byte to be inserted into it.  Failing to distinguish these cases meant
that if a string ending with the current prefix needed to be inserted into
an allTheSame tuple, we got into an infinite loop, because after splitting
the tuple we'd descend into the child allTheSame tuple and then find we
need to split again.

To fix, instead use -1 and -2 as the node labels for these two cases.
This requires widening the node label type from "char" to int2, but
fortunately SPGiST stores all pass-by-value node label types in their
Datum representation, which means that this change is transparently upward
compatible so far as the on-disk representation goes.  We continue to
recognize zero as a dummy node label for reading purposes, but will not
attempt to push new index entries down into such a label, so that the loop
won't occur even when dealing with an existing index.

Per report from Teodor Sigaev.  Back-patch to 9.2 where the faulty
code was introduced.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/c170655cc81fd5e3c152e951c52247171bb57611

Modified Files
--------------
src/backend/access/spgist/spgtextproc.c |  142 +++++++++++++++++++------------
1 file changed, 89 insertions(+), 53 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix infinite loop when splitting inner tuples in SPGiST text ind
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix planner bug with nested PlaceHolderVars in 9.2 (only).