]> granicus.if.org Git - postgresql/commit
Prevent crash when ts_rewrite() replaces a non-top-level subtree with null.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 11 Dec 2016 18:09:57 +0000 (13:09 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 11 Dec 2016 18:09:57 +0000 (13:09 -0500)
commitf4ccee408d7fc9d52adf9a9153130f1298e3acb1
tree480f8a96f5f0eebd980b701d1cd76a713ad9f28d
parent981885d1777e4ee20d1057de7f6507f259f67e9f
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/8737i01dew.fsf@credativ.de
src/backend/utils/adt/tsquery_rewrite.c
src/test/regress/expected/tsearch.out
src/test/regress/sql/tsearch.sql