Commit 7280fab7 authored by Tom Lane's avatar Tom Lane

Fix bug #4814 (wrong subscript in consistent-function call), and add some

minimal regression test coverage for matchPartialInPendingList().
parent 2c39ab12
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.25 2009/04/05 11:32:01 teodor Exp $ * $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.26 2009/05/19 02:48:26 tgl Exp $
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -820,10 +820,11 @@ scanGetCandidate(IndexScanDesc scan, pendingPosition *pos) ...@@ -820,10 +820,11 @@ scanGetCandidate(IndexScanDesc scan, pendingPosition *pos)
} }
/* /*
* Scan page from current tuple (off) up to the first event: * Scan page from current tuple (off) up till the first of:
* - tuple's attribute number is not equal to entry's attrnum
* - reach of last tuple
* - match is found (then returns true) * - 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 static bool
matchPartialInPendingList(GinState *ginstate, Page page, matchPartialInPendingList(GinState *ginstate, Page page,
...@@ -849,13 +850,13 @@ 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 => 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 * case cmp < 0 => not match and continue scan
*---------- *----------
*/ */
cmp = DatumGetInt32(FunctionCall4(&ginstate->comparePartialFn[attrnum], cmp = DatumGetInt32(FunctionCall4(&ginstate->comparePartialFn[attrnum-1],
value, value,
datum[off-1], datum[off-1],
UInt16GetDatum(strategy), UInt16GetDatum(strategy),
......
...@@ -1027,3 +1027,37 @@ SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty'); ...@@ -1027,3 +1027,37 @@ SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');
1 1
(1 row) (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)
...@@ -361,3 +361,14 @@ SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty'); ...@@ -361,3 +361,14 @@ SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');
INSERT INTO test_tsvector (t) VALUES ('345 qwerty'); INSERT INTO test_tsvector (t) VALUES ('345 qwerty');
SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment