Skip to content
Snippets Groups Projects
Select Git revision
  • benchmark-tools
  • postgres-lambda
  • master default
  • REL9_4_25
  • REL9_5_20
  • REL9_6_16
  • REL_10_11
  • REL_11_6
  • REL_12_1
  • REL_12_0
  • REL_12_RC1
  • REL_12_BETA4
  • REL9_4_24
  • REL9_5_19
  • REL9_6_15
  • REL_10_10
  • REL_11_5
  • REL_12_BETA3
  • REL9_4_23
  • REL9_5_18
  • REL9_6_14
  • REL_10_9
  • REL_11_4
23 results

spgtextproc.c

Blame
    • Tom Lane's avatar
      c170655c
      Fix infinite loop when splitting inner tuples in SPGiST text indexes. · c170655c
      Tom Lane authored
      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.
      c170655c
      History
      Fix infinite loop when splitting inner tuples in SPGiST text indexes.
      Tom Lane authored
      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.