Navigation Menu

Skip to content

Commit

Permalink
pgroonga.score: support HOT update
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 22, 2015
1 parent ffc946f commit e98adb5
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
24 changes: 24 additions & 0 deletions expected/full-text-search/text/single/score/hot_updated.out
@@ -0,0 +1,24 @@
CREATE TABLE memos (
id integer PRIMARY KEY,
tag varchar(256),
content text
);
CREATE INDEX grnindex ON memos USING pgroonga (id, content);
INSERT INTO memos VALUES (1, 'pgsql', 'PostgreSQL is a RDBMS.');
INSERT INTO memos VALUES (2, 'groonga', 'Groonga is fast full text search engine.');
INSERT INTO memos VALUES (3, 'pgsql', 'PGroonga is a PostgreSQL extension that uses Groonga.');
UPDATE memos SET tag = 'groonga'
WHERE id = 3;
SET enable_seqscan = off;
SET enable_indexscan = on;
SET enable_bitmapscan = off;
SELECT id, content, pgroonga.score(memos)
FROM memos
WHERE content @@ 'PGroonga OR Groonga';
id | content | score
----+-------------------------------------------------------+-------
3 | PGroonga is a PostgreSQL extension that uses Groonga. | 2
2 | Groonga is fast full text search engine. | 1
(2 rows)

DROP TABLE memos;
4 changes: 3 additions & 1 deletion pgroonga.c
Expand Up @@ -913,13 +913,15 @@ PGrnIsAliveCtid(Relation table, ItemPointer ctid)
Buffer buffer;
HeapTupleData tuple;
Snapshot snapshot;
ItemPointerData realCtid;
bool allDead;
bool found;
bool isAlive;

buffer = ReadBuffer(table, ItemPointerGetBlockNumber(ctid));
snapshot = RegisterSnapshot(GetLatestSnapshot());
found = heap_hot_search_buffer(ctid, table, buffer, snapshot, &tuple,
realCtid = *ctid;
found = heap_hot_search_buffer(&realCtid, table, buffer, snapshot, &tuple,
&allDead, true);
isAlive = (found && CtidToUInt64(&(tuple.t_self)) == CtidToUInt64(ctid));
UnregisterSnapshot(snapshot);
Expand Down
23 changes: 23 additions & 0 deletions sql/full-text-search/text/single/score/hot_updated.sql
@@ -0,0 +1,23 @@
CREATE TABLE memos (
id integer PRIMARY KEY,
tag varchar(256),
content text
);

CREATE INDEX grnindex ON memos USING pgroonga (id, content);

INSERT INTO memos VALUES (1, 'pgsql', 'PostgreSQL is a RDBMS.');
INSERT INTO memos VALUES (2, 'groonga', 'Groonga is fast full text search engine.');
INSERT INTO memos VALUES (3, 'pgsql', 'PGroonga is a PostgreSQL extension that uses Groonga.');
UPDATE memos SET tag = 'groonga'
WHERE id = 3;

SET enable_seqscan = off;
SET enable_indexscan = on;
SET enable_bitmapscan = off;

SELECT id, content, pgroonga.score(memos)
FROM memos
WHERE content @@ 'PGroonga OR Groonga';

DROP TABLE memos;

0 comments on commit e98adb5

Please sign in to comment.