Prevent crash when ts_rewrite() replaces a non-top-level subtree with null.
authorTom Lane <[email protected]>
Sun, 11 Dec 2016 18:09:57 +0000 (13:09 -0500)
committerTom Lane <[email protected]>
Sun, 11 Dec 2016 18:09:57 +0000 (13:09 -0500)
commit79e1a9efa808d2e15ea41d06d7696a6daab05467
tree75885bb84cf00aaee9d2053b6f114a78da4c334b
parentcea6de20b35624d5cc7985867b15c7af2b87ea0b
Prevent crash when ts_rewrite() replaces a non-top-level subtree with null.

When ts_rewrite()'s replacement argument is an empty tsquery, it's supposed
to simplify any operator nodes whose operand(s) become NULL; but it failed
to do that reliably, because dropvoidsubtree() only examined the top level
of the result tree.  Rather than make a second recursive pass, let's just
give the responsibility to dofindsubquery() to simplify while it's doing
the main replacement pass.  Per report from Andreas Seltenreich.

Artur Zakirov, with some cosmetic changes by me.  Back-patch to all
supported branches.

Discussion: https://postgr.es/m/[email protected]
src/backend/utils/adt/tsquery_rewrite.c
src/test/regress/expected/tsearch.out
src/test/regress/sql/tsearch.sql