]> granicus.if.org Git - postgresql/commit
Fix bogus tree-flattening logic in QTNTernary().
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 30 Oct 2016 19:24:40 +0000 (15:24 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 30 Oct 2016 19:24:40 +0000 (15:24 -0400)
commitb0f8a273e678354d9c6c7cb02598e892942ad5b3
treea103ab01e0e2aab0b080c57838b603ed1eabc9c2
parent2be2838a7174b50592c32aba4863ff5f0049b083
Fix bogus tree-flattening logic in QTNTernary().

QTNTernary() contains logic to flatten, eg, '(a & b) & c' into 'a & b & c',
which is all well and good, but it tries to do that to NOT nodes as well,
so that '!!a' gets changed to '!a'.  Explicitly restrict the conversion to
be done only on AND and OR nodes, and add a test case illustrating the bug.

In passing, provide some comments for the sadly naked functions in
tsquery_util.c, and simplify some baroque logic in QTNFree(), which
I think may have been leaking some items it intended to free.

Noted while investigating a complaint from Andreas Seltenreich.
Back-patch to all supported versions.
src/backend/utils/adt/tsquery_util.c
src/test/regress/expected/tsearch.out
src/test/regress/sql/tsearch.sql