Kouhei Sutou
null+****@clear*****
Fri Apr 28 16:40:09 JST 2017
Kouhei Sutou 2017-04-28 16:40:09 +0900 (Fri, 28 Apr 2017) New Revision: 98c45fba610ffd7eb66cf0ad491fb67b2dcafe3c https://github.com/pgroonga/pgroonga/commit/98c45fba610ffd7eb66cf0ad491fb67b2dcafe3c Message: Add "&@" and "&?" v2 operators to v1 full text search ops It's for supporting painless migration. Added files: expected/full-text-search/text/single/match-v1-v2-compatible/bitmapscan.out expected/full-text-search/text/single/match-v1-v2-compatible/indexscan.out expected/full-text-search/text/single/match-v1-v2-compatible/seqscan.out sql/full-text-search/text/single/match-v1-v2-compatible/bitmapscan.sql sql/full-text-search/text/single/match-v1-v2-compatible/indexscan.sql sql/full-text-search/text/single/match-v1-v2-compatible/seqscan.sql Modified files: data/pgroonga--1.1.9--1.2.0.sql data/pgroonga.sql Modified: data/pgroonga--1.1.9--1.2.0.sql (+4 -0) =================================================================== --- data/pgroonga--1.1.9--1.2.0.sql 2017-04-28 15:33:09 +0900 (e69de29) +++ data/pgroonga--1.1.9--1.2.0.sql 2017-04-28 16:40:09 +0900 (23ae362) @@ -0,0 +1,4 @@ +ALTER OPERATOR FAMILY pgroonga.text_full_text_search_ops USING pgroonga + ADD + OPERATOR 12 &@ (text, text), + OPERATOR 13 &? (text, text); Modified: data/pgroonga.sql (+139 -131) =================================================================== --- data/pgroonga.sql 2017-04-28 15:33:09 +0900 (ecda7b4) +++ data/pgroonga.sql 2017-04-28 16:40:09 +0900 (4c2b204) @@ -156,6 +156,8 @@ CREATE FUNCTION pgroonga.escape(value timestamptz) IMMUTABLE STRICT; + +/* v1 */ CREATE FUNCTION pgroonga.match_term(target text, term text) RETURNS bool AS 'MODULE_PATHNAME', 'pgroonga_match_term_text' @@ -276,6 +278,138 @@ CREATE OPERATOR @~ ( ); +/* v2 */ +CREATE FUNCTION pgroonga.match_text(text, text) + RETURNS bool + AS 'MODULE_PATHNAME', 'pgroonga_match_text' + LANGUAGE C + IMMUTABLE + STRICT; + +CREATE OPERATOR &@ ( + PROCEDURE = pgroonga.match_text, + LEFTARG = text, + RIGHTARG = text +); + +CREATE FUNCTION pgroonga.query_text(text, text) + RETURNS bool + AS 'MODULE_PATHNAME', 'pgroonga_query_text' + LANGUAGE C + IMMUTABLE + STRICT; + +CREATE OPERATOR &? ( + PROCEDURE = pgroonga.query_text, + LEFTARG = text, + RIGHTARG = text +); + +CREATE FUNCTION pgroonga.similar_text(text, text) + RETURNS bool + AS 'MODULE_PATHNAME', 'pgroonga_similar_text' + LANGUAGE C + IMMUTABLE + STRICT; + +CREATE OPERATOR &~? ( + PROCEDURE = pgroonga.similar_text, + LEFTARG = text, + RIGHTARG = text +); + +CREATE FUNCTION pgroonga.prefix_text(text, text) + RETURNS bool + AS 'MODULE_PATHNAME', 'pgroonga_prefix_text' + LANGUAGE C + IMMUTABLE + STRICT; + +CREATE OPERATOR &^ ( + PROCEDURE = pgroonga.prefix_text, + LEFTARG = text, + RIGHTARG = text +); + +CREATE FUNCTION pgroonga.prefix_rk_text(text, text) + RETURNS bool + AS 'MODULE_PATHNAME', 'pgroonga_prefix_rk_text' + LANGUAGE C + IMMUTABLE + STRICT; + +CREATE OPERATOR &^~ ( + PROCEDURE = pgroonga.prefix_rk_text, + LEFTARG = text, + RIGHTARG = text +); + +CREATE FUNCTION pgroonga.script_text(text, text) + RETURNS bool + AS 'MODULE_PATHNAME', 'pgroonga_script_text' + LANGUAGE C + IMMUTABLE + STRICT; + +CREATE OPERATOR &` ( + PROCEDURE = pgroonga.script_text, + LEFTARG = text, + RIGHTARG = text +); + +CREATE FUNCTION pgroonga.match_contain_text(text, text[]) + RETURNS bool + AS 'MODULE_PATHNAME', 'pgroonga_match_contain_text' + LANGUAGE C + IMMUTABLE + STRICT; + +CREATE OPERATOR &@> ( + PROCEDURE = pgroonga.match_contain_text, + LEFTARG = text, + RIGHTARG = text[] +); + +CREATE FUNCTION pgroonga.query_contain_text(text, text[]) + RETURNS bool + AS 'MODULE_PATHNAME', 'pgroonga_query_contain_text' + LANGUAGE C + IMMUTABLE + STRICT; + +CREATE OPERATOR &?> ( + PROCEDURE = pgroonga.query_contain_text, + LEFTARG = text, + RIGHTARG = text[] +); + +CREATE FUNCTION pgroonga.prefix_contain_text_array(text[], text) + RETURNS bool + AS 'MODULE_PATHNAME', 'pgroonga_prefix_contain_text_array' + LANGUAGE C + IMMUTABLE + STRICT; + +CREATE OPERATOR &^> ( + PROCEDURE = pgroonga.prefix_contain_text_array, + LEFTARG = text[], + RIGHTARG = text +); + +CREATE FUNCTION pgroonga.prefix_rk_contain_text_array(text[], text) + RETURNS bool + AS 'MODULE_PATHNAME', 'pgroonga_prefix_rk_contain_text_array' + LANGUAGE C + IMMUTABLE + STRICT; + +CREATE OPERATOR &^~> ( + PROCEDURE = pgroonga.prefix_rk_contain_text_array, + LEFTARG = text[], + RIGHTARG = text +); + + CREATE FUNCTION pgroonga.insert(internal) RETURNS bool AS 'MODULE_PATHNAME', 'pgroonga_insert' @@ -377,12 +511,16 @@ EXCEPTION END; $$; + +/* v1 */ CREATE OPERATOR CLASS pgroonga.text_full_text_search_ops DEFAULT FOR TYPE text USING pgroonga AS OPERATOR 6 ~~, OPERATOR 7 ~~*, OPERATOR 8 %%, - OPERATOR 9 @@; + OPERATOR 9 @@, + OPERATOR 12 &@, + OPERATOR 13 &?; CREATE OPERATOR CLASS pgroonga.text_array_full_text_search_ops DEFAULT @@ -514,136 +652,6 @@ CREATE OPERATOR CLASS pgroonga.varchar_regexp_ops FOR TYPE varchar /* v2 */ -CREATE FUNCTION pgroonga.match_text(text, text) - RETURNS bool - AS 'MODULE_PATHNAME', 'pgroonga_match_text' - LANGUAGE C - IMMUTABLE - STRICT; - -CREATE OPERATOR &@ ( - PROCEDURE = pgroonga.match_text, - LEFTARG = text, - RIGHTARG = text -); - -CREATE FUNCTION pgroonga.query_text(text, text) - RETURNS bool - AS 'MODULE_PATHNAME', 'pgroonga_query_text' - LANGUAGE C - IMMUTABLE - STRICT; - -CREATE OPERATOR &? ( - PROCEDURE = pgroonga.query_text, - LEFTARG = text, - RIGHTARG = text -); - -CREATE FUNCTION pgroonga.similar_text(text, text) - RETURNS bool - AS 'MODULE_PATHNAME', 'pgroonga_similar_text' - LANGUAGE C - IMMUTABLE - STRICT; - -CREATE OPERATOR &~? ( - PROCEDURE = pgroonga.similar_text, - LEFTARG = text, - RIGHTARG = text -); - -CREATE FUNCTION pgroonga.prefix_text(text, text) - RETURNS bool - AS 'MODULE_PATHNAME', 'pgroonga_prefix_text' - LANGUAGE C - IMMUTABLE - STRICT; - -CREATE OPERATOR &^ ( - PROCEDURE = pgroonga.prefix_text, - LEFTARG = text, - RIGHTARG = text -); - -CREATE FUNCTION pgroonga.prefix_rk_text(text, text) - RETURNS bool - AS 'MODULE_PATHNAME', 'pgroonga_prefix_rk_text' - LANGUAGE C - IMMUTABLE - STRICT; - -CREATE OPERATOR &^~ ( - PROCEDURE = pgroonga.prefix_rk_text, - LEFTARG = text, - RIGHTARG = text -); - -CREATE FUNCTION pgroonga.script_text(text, text) - RETURNS bool - AS 'MODULE_PATHNAME', 'pgroonga_script_text' - LANGUAGE C - IMMUTABLE - STRICT; - -CREATE OPERATOR &` ( - PROCEDURE = pgroonga.script_text, - LEFTARG = text, - RIGHTARG = text -); - -CREATE FUNCTION pgroonga.match_contain_text(text, text[]) - RETURNS bool - AS 'MODULE_PATHNAME', 'pgroonga_match_contain_text' - LANGUAGE C - IMMUTABLE - STRICT; - -CREATE OPERATOR &@> ( - PROCEDURE = pgroonga.match_contain_text, - LEFTARG = text, - RIGHTARG = text[] -); - -CREATE FUNCTION pgroonga.query_contain_text(text, text[]) - RETURNS bool - AS 'MODULE_PATHNAME', 'pgroonga_query_contain_text' - LANGUAGE C - IMMUTABLE - STRICT; - -CREATE OPERATOR &?> ( - PROCEDURE = pgroonga.query_contain_text, - LEFTARG = text, - RIGHTARG = text[] -); - -CREATE FUNCTION pgroonga.prefix_contain_text_array(text[], text) - RETURNS bool - AS 'MODULE_PATHNAME', 'pgroonga_prefix_contain_text_array' - LANGUAGE C - IMMUTABLE - STRICT; - -CREATE OPERATOR &^> ( - PROCEDURE = pgroonga.prefix_contain_text_array, - LEFTARG = text[], - RIGHTARG = text -); - -CREATE FUNCTION pgroonga.prefix_rk_contain_text_array(text[], text) - RETURNS bool - AS 'MODULE_PATHNAME', 'pgroonga_prefix_rk_contain_text_array' - LANGUAGE C - IMMUTABLE - STRICT; - -CREATE OPERATOR &^~> ( - PROCEDURE = pgroonga.prefix_rk_contain_text_array, - LEFTARG = text[], - RIGHTARG = text -); - CREATE OPERATOR CLASS pgroonga.text_full_text_search_ops_v2 FOR TYPE text USING pgroonga AS OPERATOR 6 ~~, Added: expected/full-text-search/text/single/match-v1-v2-compatible/bitmapscan.out (+22 -0) 100644 =================================================================== --- /dev/null +++ expected/full-text-search/text/single/match-v1-v2-compatible/bitmapscan.out 2017-04-28 16:40:09 +0900 (d045ca5) @@ -0,0 +1,22 @@ +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 pgroonga.text_full_text_search_ops); +SET enable_seqscan = off; +SET enable_indexscan = off; +SET enable_bitmapscan = on; +SELECT id, content + FROM memos + WHERE content &@ 'Groonga'; + id | content +----+------------------------------------------------------- + 2 | Groonga is fast full text search engine. + 3 | PGroonga is a PostgreSQL extension that uses Groonga. +(2 rows) + +DROP TABLE memos; Added: expected/full-text-search/text/single/match-v1-v2-compatible/indexscan.out (+22 -0) 100644 =================================================================== --- /dev/null +++ expected/full-text-search/text/single/match-v1-v2-compatible/indexscan.out 2017-04-28 16:40:09 +0900 (ac7d824) @@ -0,0 +1,22 @@ +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 pgroonga.text_full_text_search_ops); +SET enable_seqscan = off; +SET enable_indexscan = on; +SET enable_bitmapscan = off; +SELECT id, content + FROM memos + WHERE content &@ 'Groonga'; + id | content +----+------------------------------------------------------- + 2 | Groonga is fast full text search engine. + 3 | PGroonga is a PostgreSQL extension that uses Groonga. +(2 rows) + +DROP TABLE memos; Added: expected/full-text-search/text/single/match-v1-v2-compatible/seqscan.out (+22 -0) 100644 =================================================================== --- /dev/null +++ expected/full-text-search/text/single/match-v1-v2-compatible/seqscan.out 2017-04-28 16:40:09 +0900 (de19034) @@ -0,0 +1,22 @@ +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 pgroonga.text_full_text_search_ops); +SET enable_seqscan = on; +SET enable_indexscan = off; +SET enable_bitmapscan = off; +SELECT id, content + FROM memos + WHERE content &@ 'Groonga'; + id | content +----+------------------------------------------------------- + 2 | Groonga is fast full text search engine. + 3 | PGroonga is a PostgreSQL extension that uses Groonga. +(2 rows) + +DROP TABLE memos; Added: sql/full-text-search/text/single/match-v1-v2-compatible/bitmapscan.sql (+21 -0) 100644 =================================================================== --- /dev/null +++ sql/full-text-search/text/single/match-v1-v2-compatible/bitmapscan.sql 2017-04-28 16:40:09 +0900 (2fee88c) @@ -0,0 +1,21 @@ +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 pgroonga.text_full_text_search_ops); + +SET enable_seqscan = off; +SET enable_indexscan = off; +SET enable_bitmapscan = on; + +SELECT id, content + FROM memos + WHERE content &@ 'Groonga'; + +DROP TABLE memos; Added: sql/full-text-search/text/single/match-v1-v2-compatible/indexscan.sql (+21 -0) 100644 =================================================================== --- /dev/null +++ sql/full-text-search/text/single/match-v1-v2-compatible/indexscan.sql 2017-04-28 16:40:09 +0900 (74843a6) @@ -0,0 +1,21 @@ +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 pgroonga.text_full_text_search_ops); + +SET enable_seqscan = off; +SET enable_indexscan = on; +SET enable_bitmapscan = off; + +SELECT id, content + FROM memos + WHERE content &@ 'Groonga'; + +DROP TABLE memos; Added: sql/full-text-search/text/single/match-v1-v2-compatible/seqscan.sql (+21 -0) 100644 =================================================================== --- /dev/null +++ sql/full-text-search/text/single/match-v1-v2-compatible/seqscan.sql 2017-04-28 16:40:09 +0900 (cd3b5a0) @@ -0,0 +1,21 @@ +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 pgroonga.text_full_text_search_ops); + +SET enable_seqscan = on; +SET enable_indexscan = off; +SET enable_bitmapscan = off; + +SELECT id, content + FROM memos + WHERE content &@ 'Groonga'; + +DROP TABLE memos; -------------- next part -------------- HTML����������������������������... Download