Skip to content

Commit

Permalink
json test: add tests for element value
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Sep 23, 2015
1 parent 73537b5 commit 2b39467
Show file tree
Hide file tree
Showing 12 changed files with 258 additions and 0 deletions.
22 changes: 22 additions & 0 deletions expected/jsonb/element/boolean/bitmapscan.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CREATE TABLE fruits (
id int,
items jsonb
);
INSERT INTO fruits VALUES (1, '[true]');
INSERT INTO fruits VALUES (2, '[false]');
INSERT INTO fruits VALUES (3, '[true]');
CREATE INDEX pgroonga_index ON fruits USING pgroonga (items);
SET enable_seqscan = off;
SET enable_indexscan = off;
SET enable_bitmapscan = on;
SELECT id, items
FROM fruits
WHERE items @@ 'boolean == true'
ORDER BY id;
id | items
----+--------
1 | [true]
3 | [true]
(2 rows)

DROP TABLE fruits;
22 changes: 22 additions & 0 deletions expected/jsonb/element/boolean/indexscan.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CREATE TABLE fruits (
id int,
items jsonb
);
INSERT INTO fruits VALUES (1, '[true]');
INSERT INTO fruits VALUES (2, '[false]');
INSERT INTO fruits VALUES (3, '[true]');
CREATE INDEX pgroonga_index ON fruits USING pgroonga (items);
SET enable_seqscan = off;
SET enable_indexscan = on;
SET enable_bitmapscan = off;
SELECT id, items
FROM fruits
WHERE items @@ 'boolean == true'
ORDER BY id;
id | items
----+--------
1 | [true]
3 | [true]
(2 rows)

DROP TABLE fruits;
22 changes: 22 additions & 0 deletions expected/jsonb/element/number/bitmapscan.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CREATE TABLE fruits (
id int,
items jsonb
);
INSERT INTO fruits VALUES (1, '[100]');
INSERT INTO fruits VALUES (2, '[200, 30]');
INSERT INTO fruits VALUES (3, '[150]');
CREATE INDEX pgroonga_index ON fruits USING pgroonga (items);
SET enable_seqscan = off;
SET enable_indexscan = off;
SET enable_bitmapscan = on;
SELECT id, items
FROM fruits
WHERE items @@ 'number <= 100'
ORDER BY id;
id | items
----+-----------
1 | [100]
2 | [200, 30]
(2 rows)

DROP TABLE fruits;
22 changes: 22 additions & 0 deletions expected/jsonb/element/number/indexscan.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CREATE TABLE fruits (
id int,
items jsonb
);
INSERT INTO fruits VALUES (1, '[100]');
INSERT INTO fruits VALUES (2, '[200, 30]');
INSERT INTO fruits VALUES (3, '[150]');
CREATE INDEX pgroonga_index ON fruits USING pgroonga (items);
SET enable_seqscan = off;
SET enable_indexscan = on;
SET enable_bitmapscan = off;
SELECT id, items
FROM fruits
WHERE items @@ 'number <= 100'
ORDER BY id;
id | items
----+-----------
1 | [100]
2 | [200, 30]
(2 rows)

DROP TABLE fruits;
22 changes: 22 additions & 0 deletions expected/jsonb/element/string/bitmapscan.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CREATE TABLE fruits (
id int,
items jsonb
);
INSERT INTO fruits VALUES (1, '["apple"]');
INSERT INTO fruits VALUES (2, '["banana", "apple"]');
INSERT INTO fruits VALUES (3, '["peach"]');
CREATE INDEX pgroonga_index ON fruits USING pgroonga (items);
SET enable_seqscan = off;
SET enable_indexscan = off;
SET enable_bitmapscan = on;
SELECT id, items
FROM fruits
WHERE items @@ 'string == "apple"'
ORDER BY id;
id | items
----+---------------------
1 | ["apple"]
2 | ["banana", "apple"]
(2 rows)

DROP TABLE fruits;
22 changes: 22 additions & 0 deletions expected/jsonb/element/string/indexscan.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CREATE TABLE fruits (
id int,
items jsonb
);
INSERT INTO fruits VALUES (1, '["apple"]');
INSERT INTO fruits VALUES (2, '["banana", "apple"]');
INSERT INTO fruits VALUES (3, '["peach"]');
CREATE INDEX pgroonga_index ON fruits USING pgroonga (items);
SET enable_seqscan = off;
SET enable_indexscan = on;
SET enable_bitmapscan = off;
SELECT id, items
FROM fruits
WHERE items @@ 'string == "apple"'
ORDER BY id;
id | items
----+---------------------
1 | ["apple"]
2 | ["banana", "apple"]
(2 rows)

DROP TABLE fruits;
21 changes: 21 additions & 0 deletions sql/jsonb/element/boolean/bitmapscan.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TABLE fruits (
id int,
items jsonb
);

INSERT INTO fruits VALUES (1, '[true]');
INSERT INTO fruits VALUES (2, '[false]');
INSERT INTO fruits VALUES (3, '[true]');

CREATE INDEX pgroonga_index ON fruits USING pgroonga (items);

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

SELECT id, items
FROM fruits
WHERE items @@ 'boolean == true'
ORDER BY id;

DROP TABLE fruits;
21 changes: 21 additions & 0 deletions sql/jsonb/element/boolean/indexscan.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TABLE fruits (
id int,
items jsonb
);

INSERT INTO fruits VALUES (1, '[true]');
INSERT INTO fruits VALUES (2, '[false]');
INSERT INTO fruits VALUES (3, '[true]');

CREATE INDEX pgroonga_index ON fruits USING pgroonga (items);

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

SELECT id, items
FROM fruits
WHERE items @@ 'boolean == true'
ORDER BY id;

DROP TABLE fruits;
21 changes: 21 additions & 0 deletions sql/jsonb/element/number/bitmapscan.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TABLE fruits (
id int,
items jsonb
);

INSERT INTO fruits VALUES (1, '[100]');
INSERT INTO fruits VALUES (2, '[200, 30]');
INSERT INTO fruits VALUES (3, '[150]');

CREATE INDEX pgroonga_index ON fruits USING pgroonga (items);

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

SELECT id, items
FROM fruits
WHERE items @@ 'number <= 100'
ORDER BY id;

DROP TABLE fruits;
21 changes: 21 additions & 0 deletions sql/jsonb/element/number/indexscan.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TABLE fruits (
id int,
items jsonb
);

INSERT INTO fruits VALUES (1, '[100]');
INSERT INTO fruits VALUES (2, '[200, 30]');
INSERT INTO fruits VALUES (3, '[150]');

CREATE INDEX pgroonga_index ON fruits USING pgroonga (items);

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

SELECT id, items
FROM fruits
WHERE items @@ 'number <= 100'
ORDER BY id;

DROP TABLE fruits;
21 changes: 21 additions & 0 deletions sql/jsonb/element/string/bitmapscan.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TABLE fruits (
id int,
items jsonb
);

INSERT INTO fruits VALUES (1, '["apple"]');
INSERT INTO fruits VALUES (2, '["banana", "apple"]');
INSERT INTO fruits VALUES (3, '["peach"]');

CREATE INDEX pgroonga_index ON fruits USING pgroonga (items);

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

SELECT id, items
FROM fruits
WHERE items @@ 'string == "apple"'
ORDER BY id;

DROP TABLE fruits;
21 changes: 21 additions & 0 deletions sql/jsonb/element/string/indexscan.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TABLE fruits (
id int,
items jsonb
);

INSERT INTO fruits VALUES (1, '["apple"]');
INSERT INTO fruits VALUES (2, '["banana", "apple"]');
INSERT INTO fruits VALUES (3, '["peach"]');

CREATE INDEX pgroonga_index ON fruits USING pgroonga (items);

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

SELECT id, items
FROM fruits
WHERE items @@ 'string == "apple"'
ORDER BY id;

DROP TABLE fruits;

0 comments on commit 2b39467

Please sign in to comment.