Navigation Menu

Skip to content

Commit

Permalink
Fix a bug that "AND" doesn't work
Browse files Browse the repository at this point in the history
Reported by judgeOX. Thanks!!!
  • Loading branch information
kou committed Jan 22, 2015
1 parent 29b9b07 commit 7a65b4f
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 1 deletion.
20 changes: 20 additions & 0 deletions expected/text/single/and/bitmapscan.out
@@ -0,0 +1,20 @@
CREATE TABLE memos (
id integer,
content text
);
INSERT INTO memos VALUES (1, 'PostgreSQL is a RDBMS.');
INSERT INTO memos VALUES (2, 'Groonga is fast full text search engine.');
INSERT INTO memos VALUES (3, 'PGroonga is a PostgreSQL extension that uses Groonga.');
CREATE INDEX grnindex ON memos USING pgroonga (content);
SET enable_seqscan = off;
SET enable_indexscan = off;
SET enable_bitmapscan = on;
SELECT id, content
FROM memos
WHERE content %% 'PGroonga' AND content %% 'Groonga';
id | content
----+-------------------------------------------------------
3 | PGroonga is a PostgreSQL extension that uses Groonga.
(1 row)

DROP TABLE memos;
20 changes: 20 additions & 0 deletions expected/text/single/and/indexscan.out
@@ -0,0 +1,20 @@
CREATE TABLE memos (
id integer,
content text
);
INSERT INTO memos VALUES (1, 'PostgreSQL is a RDBMS.');
INSERT INTO memos VALUES (2, 'Groonga is fast full text search engine.');
INSERT INTO memos VALUES (3, 'PGroonga is a PostgreSQL extension that uses Groonga.');
CREATE INDEX grnindex ON memos USING pgroonga (content);
SET enable_seqscan = off;
SET enable_indexscan = on;
SET enable_bitmapscan = off;
SELECT id, content
FROM memos
WHERE content %% 'PGroonga' AND content %% 'Groonga';
id | content
----+-------------------------------------------------------
3 | PGroonga is a PostgreSQL extension that uses Groonga.
(1 row)

DROP TABLE memos;
20 changes: 20 additions & 0 deletions expected/text/single/and/seqscan.out
@@ -0,0 +1,20 @@
CREATE TABLE memos (
id integer,
content text
);
INSERT INTO memos VALUES (1, 'PostgreSQL is a RDBMS.');
INSERT INTO memos VALUES (2, 'Groonga is fast full text search engine.');
INSERT INTO memos VALUES (3, 'PGroonga is a PostgreSQL extension that uses Groonga.');
CREATE INDEX grnindex ON memos USING pgroonga (content);
SET enable_seqscan = on;
SET enable_indexscan = off;
SET enable_bitmapscan = off;
SELECT id, content
FROM memos
WHERE content %% 'PGroonga' AND content %% 'Groonga';
id | content
----+-------------------------------------------------------
3 | PGroonga is a PostgreSQL extension that uses Groonga.
(1 row)

DROP TABLE memos;
2 changes: 1 addition & 1 deletion pgroonga.c
Expand Up @@ -666,7 +666,7 @@ GrnSearch(IndexScanDesc scan)
GrnGetValue(index, key->sk_attno - 1, &buffer, key->sk_argument);

grn_expr_append_obj(ctx, expression, matchTarget, GRN_OP_PUSH, 1);
grn_expr_append_obj(ctx, expression, &buffer, GRN_OP_PUSH, 1);
grn_expr_append_const(ctx, expression, &buffer, GRN_OP_PUSH, 1);

switch (key->sk_strategy)
{
Expand Down
20 changes: 20 additions & 0 deletions sql/text/single/and/bitmapscan.sql
@@ -0,0 +1,20 @@
CREATE TABLE memos (
id integer,
content text
);

INSERT INTO memos VALUES (1, 'PostgreSQL is a RDBMS.');
INSERT INTO memos VALUES (2, 'Groonga is fast full text search engine.');
INSERT INTO memos VALUES (3, 'PGroonga is a PostgreSQL extension that uses Groonga.');

CREATE INDEX grnindex ON memos USING pgroonga (content);

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

SELECT id, content
FROM memos
WHERE content %% 'PGroonga' AND content %% 'Groonga';

DROP TABLE memos;
20 changes: 20 additions & 0 deletions sql/text/single/and/indexscan.sql
@@ -0,0 +1,20 @@
CREATE TABLE memos (
id integer,
content text
);

INSERT INTO memos VALUES (1, 'PostgreSQL is a RDBMS.');
INSERT INTO memos VALUES (2, 'Groonga is fast full text search engine.');
INSERT INTO memos VALUES (3, 'PGroonga is a PostgreSQL extension that uses Groonga.');

CREATE INDEX grnindex ON memos USING pgroonga (content);

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

SELECT id, content
FROM memos
WHERE content %% 'PGroonga' AND content %% 'Groonga';

DROP TABLE memos;
20 changes: 20 additions & 0 deletions sql/text/single/and/seqscan.sql
@@ -0,0 +1,20 @@
CREATE TABLE memos (
id integer,
content text
);

INSERT INTO memos VALUES (1, 'PostgreSQL is a RDBMS.');
INSERT INTO memos VALUES (2, 'Groonga is fast full text search engine.');
INSERT INTO memos VALUES (3, 'PGroonga is a PostgreSQL extension that uses Groonga.');

CREATE INDEX grnindex ON memos USING pgroonga (content);

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

SELECT id, content
FROM memos
WHERE content %% 'PGroonga' AND content %% 'Groonga';

DROP TABLE memos;

0 comments on commit 7a65b4f

Please sign in to comment.