diff --git a/expected/ruminv.out b/expected/ruminv.out index 840dcfc85c..d26863ff35 100644 --- a/expected/ruminv.out +++ b/expected/ruminv.out @@ -9,6 +9,7 @@ INSERT INTO test_invrum VALUES ('(a|b)&c'::tsquery); INSERT INTO test_invrum VALUES ('(!(a|b))&c'::tsquery); INSERT INTO test_invrum VALUES ('(a|b)&(c|d)'::tsquery); INSERT INTO test_invrum VALUES ('!a'::tsquery); +INSERT INTO test_invrum VALUES ('a&!(b&c)'::tsquery); INSERT INTO test_invrum VALUES ('(a|a1|a2|a3|a4|a5)&(b|b1|b2|b3|b4|b5|b6)&!(c|c1|c2|c3)'::tsquery); SELECT * FROM test_invrum WHERE q @@ ''::tsvector; q @@ -20,12 +21,13 @@ SELECT * FROM test_invrum WHERE q @@ ''::tsvector; (4 rows) SELECT * FROM test_invrum WHERE q @@ 'a'::tsvector; - q ----------------- + q +---------------------- 'a' | 'b' !( 'a' & 'b' ) 'a' & !'b' -(3 rows) + 'a' & !( 'b' & 'c' ) +(4 rows) SELECT * FROM test_invrum WHERE q @@ 'b'::tsvector; q @@ -42,8 +44,9 @@ SELECT * FROM test_invrum WHERE q @@ 'a b'::tsvector; 'a' | 'b' 'a' & 'b' !'a' | 'b' + 'a' & !( 'b' & 'c' ) ( 'a' | 'a1' | 'a2' | 'a3' | 'a4' | 'a5' ) & ( 'b' | 'b1' | 'b2' | 'b3' | 'b4' | 'b5' | 'b6' ) & !( 'c' | 'c1' | 'c2' | 'c3' ) -(4 rows) +(5 rows) SELECT * FROM test_invrum WHERE q @@ 'c'::tsvector; q @@ -63,7 +66,8 @@ SELECT * FROM test_invrum WHERE q @@ 'a c'::tsvector; 'a' & !'b' ( 'a' | 'b' ) & 'c' ( 'a' | 'b' ) & ( 'c' | 'd' ) -(5 rows) + 'a' & !( 'b' & 'c' ) +(6 rows) SELECT * FROM test_invrum WHERE q @@ 'b c'::tsvector; q @@ -102,7 +106,8 @@ SELECT * FROM test_invrum WHERE q @@ 'a d'::tsvector; !( 'a' & 'b' ) 'a' & !'b' ( 'a' | 'b' ) & ( 'c' | 'd' ) -(4 rows) + 'a' & !( 'b' & 'c' ) +(5 rows) SELECT * FROM test_invrum WHERE q @@ 'b d'::tsvector; q @@ -121,8 +126,9 @@ SELECT * FROM test_invrum WHERE q @@ 'a b d'::tsvector; 'a' & 'b' !'a' | 'b' ( 'a' | 'b' ) & ( 'c' | 'd' ) + 'a' & !( 'b' & 'c' ) ( 'a' | 'a1' | 'a2' | 'a3' | 'a4' | 'a5' ) & ( 'b' | 'b1' | 'b2' | 'b3' | 'b4' | 'b5' | 'b6' ) & !( 'c' | 'c1' | 'c2' | 'c3' ) -(5 rows) +(6 rows) SELECT * FROM test_invrum WHERE q @@ 'c d'::tsvector; q @@ -142,7 +148,8 @@ SELECT * FROM test_invrum WHERE q @@ 'a c d'::tsvector; 'a' & !'b' ( 'a' | 'b' ) & 'c' ( 'a' | 'b' ) & ( 'c' | 'd' ) -(5 rows) + 'a' & !( 'b' & 'c' ) +(6 rows) CREATE INDEX test_invrum_idx ON test_invrum USING rum(q); SET enable_seqscan = OFF; @@ -152,12 +159,13 @@ SELECT * FROM test_invrum WHERE q @@ ''::tsvector; (0 rows) SELECT * FROM test_invrum WHERE q @@ 'a'::tsvector; - q ----------------- + q +---------------------- 'a' | 'b' !( 'a' & 'b' ) 'a' & !'b' -(3 rows) + 'a' & !( 'b' & 'c' ) +(4 rows) SELECT * FROM test_invrum WHERE q @@ 'b'::tsvector; q @@ -234,7 +242,8 @@ SELECT * FROM test_invrum WHERE q @@ 'a d'::tsvector; !( 'a' & 'b' ) 'a' & !'b' ( 'a' | 'b' ) & ( 'c' | 'd' ) -(4 rows) + 'a' & !( 'b' & 'c' ) +(5 rows) SELECT * FROM test_invrum WHERE q @@ 'b d'::tsvector; q diff --git a/sql/ruminv.sql b/sql/ruminv.sql index b1c8eba709..dc42d1b4ba 100644 --- a/sql/ruminv.sql +++ b/sql/ruminv.sql @@ -10,6 +10,7 @@ INSERT INTO test_invrum VALUES ('(a|b)&c'::tsquery); INSERT INTO test_invrum VALUES ('(!(a|b))&c'::tsquery); INSERT INTO test_invrum VALUES ('(a|b)&(c|d)'::tsquery); INSERT INTO test_invrum VALUES ('!a'::tsquery); +INSERT INTO test_invrum VALUES ('a&!(b&c)'::tsquery); INSERT INTO test_invrum VALUES ('(a|a1|a2|a3|a4|a5)&(b|b1|b2|b3|b4|b5|b6)&!(c|c1|c2|c3)'::tsquery); SELECT * FROM test_invrum WHERE q @@ ''::tsvector; diff --git a/src/rumtsquery.c b/src/rumtsquery.c index 6c6b3c86d0..fb07763dcc 100644 --- a/src/rumtsquery.c +++ b/src/rumtsquery.c @@ -476,6 +476,7 @@ ruminv_tsvector_consistent(PG_FUNCTION_ARGS) int i, lastIndex = 0; TmpNode nodes[256]; + bool leafHit = false; *recheck = false; @@ -543,6 +544,8 @@ ruminv_tsvector_consistent(PG_FUNCTION_ARGS) nodes[index].sum--; else nodes[index].sum++; + + leafHit = true; } if (index == 0) @@ -581,6 +584,12 @@ ruminv_tsvector_consistent(PG_FUNCTION_ARGS) } } + if (!res && leafHit) + { + res = true; + *recheck = true; + } + PG_RETURN_BOOL(res); }
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: