Prevent crash when ts_rewrite() replaces a non-top-level subtree with null.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 79e1a9efa808d2e15ea41d06d7696a6daab05467
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2016-12-11T18:09:57Z
Releases: 9.3.16
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

Files

Discussion