diff options
author | Tom Lane | 2009-05-19 02:48:26 +0000 |
---|---|---|
committer | Tom Lane | 2009-05-19 02:48:26 +0000 |
commit | a2f4f39ae059f0bd677ba18eb7fe145dac98119f (patch) | |
tree | 806e5b873529162e2881d6b5ffe4fb182327d309 | |
parent | 0703079cef45942af51db9ebed17742f75dcdef2 (diff) |
Fix bug #4814 (wrong subscript in consistent-function call), and add some
minimal regression test coverage for matchPartialInPendingList().
-rw-r--r-- | src/backend/access/gin/ginget.c | 13 | ||||
-rw-r--r-- | src/test/regress/expected/tsearch.out | 36 | ||||
-rw-r--r-- | src/test/regress/sql/tsearch.sql | 11 |
3 files changed, 53 insertions, 7 deletions
diff --git a/src/backend/access/gin/ginget.c b/src/backend/access/gin/ginget.c index f1e7ca55be..491e589f32 100644 --- a/src/backend/access/gin/ginget.c +++ b/src/backend/access/gin/ginget.c @@ -820,10 +820,11 @@ scanGetCandidate(IndexScanDesc scan, pendingPosition *pos) } /* - * Scan page from current tuple (off) up to the first event: - * - tuple's attribute number is not equal to entry's attrnum - * - reach of last tuple + * Scan page from current tuple (off) up till the first of: * - match is found (then returns true) + * - no later match is possible + * - tuple's attribute number is not equal to entry's attrnum + * - reach end of page */ static bool matchPartialInPendingList(GinState *ginstate, Page page, @@ -849,13 +850,13 @@ matchPartialInPendingList(GinState *ginstate, Page page, } /*---------- - * Check of partial match. + * Check partial match. * case cmp == 0 => match - * case cmp > 0 => not match and finish scan + * case cmp > 0 => not match and end scan (no later match possible) * case cmp < 0 => not match and continue scan *---------- */ - cmp = DatumGetInt32(FunctionCall4(&ginstate->comparePartialFn[attrnum], + cmp = DatumGetInt32(FunctionCall4(&ginstate->comparePartialFn[attrnum-1], value, datum[off-1], UInt16GetDatum(strategy), diff --git a/src/test/regress/expected/tsearch.out b/src/test/regress/expected/tsearch.out index 39dbaf67b5..04b75dc6d0 100644 --- a/src/test/regress/expected/tsearch.out +++ b/src/test/regress/expected/tsearch.out @@ -624,7 +624,7 @@ to_tsquery('english', 'sea&foo'), 'HighlightAll=true'); <body> <b>Sea</b> view wow <u><b>foo</b> bar</u> <i>qq</i> <a href="http://www.google.com/foo.bar.html" target="_blank">YES </a> - ff-bg + ff-bg <script> document.write(15); </script> @@ -1027,3 +1027,37 @@ SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty'); 1 (1 row) +-- test finding items in GIN's pending list +create temp table pendtest (ts tsvector); +create index pendtest_idx on pendtest using gin(ts); +insert into pendtest values (to_tsvector('Lore ipsam')); +insert into pendtest values (to_tsvector('Lore ipsum')); +select * from pendtest where 'ipsu:*'::tsquery @@ ts; + ts +-------------------- + 'ipsum':2 'lore':1 +(1 row) + +select * from pendtest where 'ipsa:*'::tsquery @@ ts; + ts +-------------------- + 'ipsam':2 'lore':1 +(1 row) + +select * from pendtest where 'ips:*'::tsquery @@ ts; + ts +-------------------- + 'ipsam':2 'lore':1 + 'ipsum':2 'lore':1 +(2 rows) + +select * from pendtest where 'ipt:*'::tsquery @@ ts; + ts +---- +(0 rows) + +select * from pendtest where 'ipi:*'::tsquery @@ ts; + ts +---- +(0 rows) + diff --git a/src/test/regress/sql/tsearch.sql b/src/test/regress/sql/tsearch.sql index f15d79318e..3467b1f6de 100644 --- a/src/test/regress/sql/tsearch.sql +++ b/src/test/regress/sql/tsearch.sql @@ -361,3 +361,14 @@ SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty'); INSERT INTO test_tsvector (t) VALUES ('345 qwerty'); SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty'); + +-- test finding items in GIN's pending list +create temp table pendtest (ts tsvector); +create index pendtest_idx on pendtest using gin(ts); +insert into pendtest values (to_tsvector('Lore ipsam')); +insert into pendtest values (to_tsvector('Lore ipsum')); +select * from pendtest where 'ipsu:*'::tsquery @@ ts; +select * from pendtest where 'ipsa:*'::tsquery @@ ts; +select * from pendtest where 'ips:*'::tsquery @@ ts; +select * from pendtest where 'ipt:*'::tsquery @@ ts; +select * from pendtest where 'ipi:*'::tsquery @@ ts; |