Thread: pgsql: Fix two bugs in tsquery @> operator.
Fix two bugs in tsquery @> operator. 1. The comparison for matching terms used only the CRC to decide if there's a match. Two different terms with the same CRC gave a match. 2. It assumed that if the second operand has more terms than the first, it's never a match. That assumption is bogus, because there can be duplicate terms in either operand. Rewrite the implementation in a way that doesn't have those bugs. Backpatch to all supported versions. Branch ------ REL9_2_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/604d94d4cacc787bfa41452785a2927c24829fc5 Modified Files -------------- src/backend/utils/adt/tsquery_op.c | 131 +++++++++++++++++++++++++----------- 1 file changed, 90 insertions(+), 41 deletions(-)
On Mon, Oct 27, 2014 at 5:52 PM, Heikki Linnakangas <heikki.linnakangas@iki.fi> wrote: > Fix two bugs in tsquery @> operator. > > 1. The comparison for matching terms used only the CRC to decide if there's > a match. Two different terms with the same CRC gave a match. > > 2. It assumed that if the second operand has more terms than the first, it's > never a match. That assumption is bogus, because there can be duplicate > terms in either operand. > > Rewrite the implementation in a way that doesn't have those bugs. > > Backpatch to all supported versions. Perhaps the CRC implementation would change in the future, but what about adding regression tests as well? Those are still bugs. -- Michael