3 -- Adjust this setting to control where the objects get created.
4 SET search_path
= public;
6 -- These domains are just to catch schema-qualified references to the
8 CREATE DOMAIN tsvector
AS pg_catalog.tsvector
;
9 CREATE DOMAIN tsquery
AS pg_catalog.tsquery
;
10 CREATE DOMAIN gtsvector
AS pg_catalog.gtsvector
;
11 CREATE DOMAIN gtsq
AS pg_catalog.
text;
14 CREATE FUNCTION lexize(oid
, text)
18 RETURNS NULL ON NULL INPUT;
20 CREATE FUNCTION lexize(text, text)
22 as 'MODULE_PATHNAME', 'tsa_lexize_byname'
24 RETURNS NULL ON NULL INPUT;
26 CREATE FUNCTION lexize(text)
28 as 'MODULE_PATHNAME', 'tsa_lexize_bycurrent'
30 RETURNS NULL ON NULL INPUT;
32 CREATE FUNCTION set_curdict(int)
34 as 'MODULE_PATHNAME', 'tsa_set_curdict'
36 RETURNS NULL ON NULL INPUT;
38 CREATE FUNCTION set_curdict(text)
40 as 'MODULE_PATHNAME', 'tsa_set_curdict_byname'
42 RETURNS NULL ON NULL INPUT;
44 --built-in dictionaries
45 CREATE FUNCTION dex_init(internal
)
47 as 'MODULE_PATHNAME', 'tsa_dex_init'
50 CREATE FUNCTION dex_lexize(internal
,internal
,int4
)
52 as 'MODULE_PATHNAME', 'tsa_dex_lexize'
54 RETURNS NULL ON NULL INPUT;
56 CREATE FUNCTION snb_en_init(internal
)
58 as 'MODULE_PATHNAME', 'tsa_snb_en_init'
61 CREATE FUNCTION snb_lexize(internal
,internal
,int4
)
63 as 'MODULE_PATHNAME', 'tsa_snb_lexize'
65 RETURNS NULL ON NULL INPUT;
67 CREATE FUNCTION snb_ru_init_koi8(internal
)
69 as 'MODULE_PATHNAME', 'tsa_snb_ru_init_koi8'
72 CREATE FUNCTION snb_ru_init_utf8(internal
)
74 as 'MODULE_PATHNAME', 'tsa_snb_ru_init_utf8'
77 CREATE FUNCTION snb_ru_init(internal
)
79 as 'MODULE_PATHNAME', 'tsa_snb_ru_init'
82 CREATE FUNCTION spell_init(internal
)
84 as 'MODULE_PATHNAME', 'tsa_spell_init'
87 CREATE FUNCTION spell_lexize(internal
,internal
,int4
)
89 as 'MODULE_PATHNAME', 'tsa_spell_lexize'
91 RETURNS NULL ON NULL INPUT;
93 CREATE FUNCTION syn_init(internal
)
95 as 'MODULE_PATHNAME', 'tsa_syn_init'
98 CREATE FUNCTION syn_lexize(internal
,internal
,int4
)
100 as 'MODULE_PATHNAME', 'tsa_syn_lexize'
102 RETURNS NULL ON NULL INPUT;
104 CREATE FUNCTION thesaurus_init(internal
)
106 as 'MODULE_PATHNAME', 'tsa_thesaurus_init'
109 CREATE FUNCTION thesaurus_lexize(internal
,internal
,int4
,internal
)
111 as 'MODULE_PATHNAME', 'tsa_thesaurus_lexize'
113 RETURNS NULL ON NULL INPUT;
115 --sql-level interface
116 CREATE TYPE tokentype
117 as (tokid int4
, alias text, descr
text);
119 CREATE FUNCTION token_type(int4
)
120 RETURNS setof tokentype
121 as 'ts_token_type_byid'
123 RETURNS NULL ON NULL INPUT
126 CREATE FUNCTION token_type(text)
127 RETURNS setof tokentype
128 as 'ts_token_type_byname'
130 RETURNS NULL ON NULL INPUT
133 CREATE FUNCTION token_type()
134 RETURNS setof tokentype
135 as 'MODULE_PATHNAME', 'tsa_token_type_current'
137 RETURNS NULL ON NULL INPUT
140 CREATE FUNCTION set_curprs(int)
142 as 'MODULE_PATHNAME', 'tsa_set_curprs'
144 RETURNS NULL ON NULL INPUT;
146 CREATE FUNCTION set_curprs(text)
148 as 'MODULE_PATHNAME', 'tsa_set_curprs_byname'
150 RETURNS NULL ON NULL INPUT;
153 as (tokid int4
, token text);
155 CREATE FUNCTION parse(oid
,text)
156 RETURNS setof tokenout
159 RETURNS NULL ON NULL INPUT;
161 CREATE FUNCTION parse(text,text)
162 RETURNS setof tokenout
165 RETURNS NULL ON NULL INPUT;
167 CREATE FUNCTION parse(text)
168 RETURNS setof tokenout
169 as 'MODULE_PATHNAME', 'tsa_parse_current'
171 RETURNS NULL ON NULL INPUT;
174 CREATE FUNCTION prsd_start(internal
,int4
)
176 as 'MODULE_PATHNAME', 'tsa_prsd_start'
179 CREATE FUNCTION prsd_getlexeme(internal
,internal
,internal
)
181 as 'MODULE_PATHNAME', 'tsa_prsd_getlexeme'
184 CREATE FUNCTION prsd_end(internal
)
186 as 'MODULE_PATHNAME', 'tsa_prsd_end'
189 CREATE FUNCTION prsd_lextype(internal
)
191 as 'MODULE_PATHNAME', 'tsa_prsd_lextype'
194 CREATE FUNCTION prsd_headline(internal
,internal
,internal
)
196 as 'MODULE_PATHNAME', 'tsa_prsd_headline'
200 CREATE FUNCTION set_curcfg(int)
202 as 'MODULE_PATHNAME', 'tsa_set_curcfg'
204 RETURNS NULL ON NULL INPUT;
206 CREATE FUNCTION set_curcfg(text)
208 as 'MODULE_PATHNAME', 'tsa_set_curcfg_byname'
210 RETURNS NULL ON NULL INPUT;
212 CREATE FUNCTION show_curcfg()
214 AS 'get_current_ts_config'
216 RETURNS NULL ON NULL INPUT STABLE;
218 CREATE FUNCTION length(tsvector
)
222 RETURNS NULL ON NULL INPUT IMMUTABLE;
224 CREATE FUNCTION to_tsvector(oid
, text)
226 AS 'to_tsvector_byid'
228 RETURNS NULL ON NULL INPUT IMMUTABLE;
230 CREATE FUNCTION to_tsvector(text, text)
232 AS 'MODULE_PATHNAME', 'tsa_to_tsvector_name'
233 LANGUAGE C
RETURNS NULL ON NULL INPUT IMMUTABLE;
235 CREATE FUNCTION to_tsvector(text)
239 RETURNS NULL ON NULL INPUT IMMUTABLE;
241 CREATE FUNCTION strip(tsvector
)
245 RETURNS NULL ON NULL INPUT IMMUTABLE;
247 CREATE FUNCTION setweight(tsvector
,"char")
249 AS 'tsvector_setweight'
251 RETURNS NULL ON NULL INPUT IMMUTABLE;
253 CREATE FUNCTION concat(tsvector
,tsvector
)
257 RETURNS NULL ON NULL INPUT IMMUTABLE;
259 CREATE FUNCTION querytree(tsquery
)
262 LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT;
264 CREATE FUNCTION to_tsquery(oid
, text)
268 RETURNS NULL ON NULL INPUT IMMUTABLE;
270 CREATE FUNCTION to_tsquery(text, text)
272 AS 'MODULE_PATHNAME','tsa_to_tsquery_name'
273 LANGUAGE C
RETURNS NULL ON NULL INPUT IMMUTABLE;
275 CREATE FUNCTION to_tsquery(text)
279 RETURNS NULL ON NULL INPUT IMMUTABLE;
281 CREATE FUNCTION plainto_tsquery(oid
, text)
283 AS 'plainto_tsquery_byid'
285 RETURNS NULL ON NULL INPUT IMMUTABLE;
287 CREATE FUNCTION plainto_tsquery(text, text)
289 AS 'MODULE_PATHNAME','tsa_plainto_tsquery_name'
290 LANGUAGE C
RETURNS NULL ON NULL INPUT IMMUTABLE;
292 CREATE FUNCTION plainto_tsquery(text)
296 RETURNS NULL ON NULL INPUT IMMUTABLE;
299 CREATE FUNCTION tsearch2()
301 AS 'MODULE_PATHNAME', 'tsa_tsearch2'
305 CREATE FUNCTION rank(float4
[], tsvector
, tsquery
)
309 RETURNS NULL ON NULL INPUT IMMUTABLE;
311 CREATE FUNCTION rank(float4
[], tsvector
, tsquery
, int4
)
315 RETURNS NULL ON NULL INPUT IMMUTABLE;
317 CREATE FUNCTION rank(tsvector
, tsquery
)
321 RETURNS NULL ON NULL INPUT IMMUTABLE;
323 CREATE FUNCTION rank(tsvector
, tsquery
, int4
)
327 RETURNS NULL ON NULL INPUT IMMUTABLE;
329 CREATE FUNCTION rank_cd(float4
[], tsvector
, tsquery
)
333 RETURNS NULL ON NULL INPUT IMMUTABLE;
335 CREATE FUNCTION rank_cd(float4
[], tsvector
, tsquery
, int4
)
339 RETURNS NULL ON NULL INPUT IMMUTABLE;
341 CREATE FUNCTION rank_cd(tsvector
, tsquery
)
345 RETURNS NULL ON NULL INPUT IMMUTABLE;
347 CREATE FUNCTION rank_cd(tsvector
, tsquery
, int4
)
351 RETURNS NULL ON NULL INPUT IMMUTABLE;
353 CREATE FUNCTION headline(oid
, text, tsquery
, text)
355 AS 'ts_headline_byid_opt'
357 RETURNS NULL ON NULL INPUT IMMUTABLE;
359 CREATE FUNCTION headline(oid
, text, tsquery
)
361 AS 'ts_headline_byid'
363 RETURNS NULL ON NULL INPUT IMMUTABLE;
365 CREATE FUNCTION headline(text, text, tsquery
, text)
367 AS 'MODULE_PATHNAME', 'tsa_headline_byname'
368 LANGUAGE C
RETURNS NULL ON NULL INPUT IMMUTABLE;
370 CREATE FUNCTION headline(text, text, tsquery
)
372 AS 'MODULE_PATHNAME', 'tsa_headline_byname'
373 LANGUAGE C
RETURNS NULL ON NULL INPUT IMMUTABLE;
375 CREATE FUNCTION headline(text, tsquery
, text)
379 RETURNS NULL ON NULL INPUT IMMUTABLE;
381 CREATE FUNCTION headline(text, tsquery
)
385 RETURNS NULL ON NULL INPUT IMMUTABLE;
387 -- CREATE the OPERATOR class
388 CREATE OPERATOR CLASS gist_tsvector_ops
389 FOR TYPE tsvector
USING gist
391 OPERATOR 1 @@
(tsvector
, tsquery
),
392 FUNCTION 1 gtsvector_consistent (internal
, gtsvector
, int, oid
, internal
),
393 FUNCTION 2 gtsvector_union (internal
, internal
),
394 FUNCTION 3 gtsvector_compress (internal
),
395 FUNCTION 4 gtsvector_decompress (internal
),
396 FUNCTION 5 gtsvector_penalty (internal
, internal
, internal
),
397 FUNCTION 6 gtsvector_picksplit (internal
, internal
),
398 FUNCTION 7 gtsvector_same (gtsvector
, gtsvector
, internal
),
403 as (word
text, ndoc int4
, nentry int4
);
405 CREATE FUNCTION stat(text)
406 RETURNS setof statinfo
409 RETURNS NULL ON NULL INPUT;
411 CREATE FUNCTION stat(text,text)
412 RETURNS setof statinfo
415 RETURNS NULL ON NULL INPUT;
417 --reset - just for debuging
418 CREATE FUNCTION reset_tsearch()
420 as 'MODULE_PATHNAME', 'tsa_reset_tsearch'
422 RETURNS NULL ON NULL INPUT;
424 --get cover (debug for rank_cd)
425 CREATE FUNCTION get_covers(tsvector
,tsquery
)
427 as 'MODULE_PATHNAME', 'tsa_get_covers'
429 RETURNS NULL ON NULL INPUT;
432 create type tsdebug
as (
441 CREATE or replace FUNCTION _get_parser_from_curcfg()
443 $$
select prsname
::text from pg_catalog.pg_ts_parser p
join pg_ts_config c
on cfgparser
= p.oid
where c.oid
= show_curcfg();$$
444 LANGUAGE SQL RETURNS NULL ON NULL INPUT IMMUTABLE;
446 CREATE FUNCTION ts_debug(text)
447 RETURNS setof tsdebug
as $$
449 (select c.cfgname
::text from pg_catalog.pg_ts_config
as c
450 where c.oid
= show_curcfg()),
452 t.descr
as description
,
454 ARRAY ( SELECT m.mapdict
::pg_catalog.regdictionary
::pg_catalog.
text
455 FROM pg_catalog.pg_ts_config_map
AS m
456 WHERE m.mapcfg
= show_curcfg() AND m.maptokentype
= p.tokid
457 ORDER BY m.mapseqno
)
459 strip(to_tsvector(p.
token)) as tsvector
461 parse( _get_parser_from_curcfg(), $
1 ) as p
,
465 $$
LANGUAGE SQL RETURNS NULL ON NULL INPUT;
467 CREATE OR REPLACE FUNCTION numnode(tsquery
)
471 RETURNS NULL ON NULL INPUT IMMUTABLE;
473 CREATE OR REPLACE FUNCTION tsquery_and(tsquery
,tsquery
)
477 RETURNS NULL ON NULL INPUT IMMUTABLE;
479 CREATE OR REPLACE FUNCTION tsquery_or(tsquery
,tsquery
)
483 RETURNS NULL ON NULL INPUT IMMUTABLE;
485 CREATE OR REPLACE FUNCTION tsquery_not(tsquery
)
489 RETURNS NULL ON NULL INPUT IMMUTABLE;
491 --------------rewrite subsystem
493 CREATE OR REPLACE FUNCTION rewrite(tsquery
, text)
495 as 'tsquery_rewrite_query'
497 RETURNS NULL ON NULL INPUT IMMUTABLE;
499 CREATE OR REPLACE FUNCTION rewrite(tsquery
, tsquery
, tsquery
)
503 RETURNS NULL ON NULL INPUT IMMUTABLE;
505 CREATE OR REPLACE FUNCTION rewrite_accum(tsquery
,tsquery
[])
507 AS 'MODULE_PATHNAME', 'tsa_rewrite_accum'
510 CREATE OR REPLACE FUNCTION rewrite_finish(tsquery
)
512 as 'MODULE_PATHNAME', 'tsa_rewrite_finish'
515 CREATE AGGREGATE rewrite (
516 BASETYPE
= tsquery
[],
517 SFUNC
= rewrite_accum
,
519 FINALFUNC
= rewrite_finish
522 CREATE OR REPLACE FUNCTION tsq_mcontains(tsquery
, tsquery
)
526 RETURNS NULL ON NULL INPUT IMMUTABLE;
528 CREATE OR REPLACE FUNCTION tsq_mcontained(tsquery
, tsquery
)
532 RETURNS NULL ON NULL INPUT IMMUTABLE;
534 CREATE OPERATOR CLASS gist_tp_tsquery_ops
535 FOR TYPE tsquery
USING gist
537 OPERATOR 7 @
> (tsquery
, tsquery
),
538 OPERATOR 8 <@
(tsquery
, tsquery
),
539 FUNCTION 1 gtsquery_consistent (internal
, internal
, int, oid
, internal
),
540 FUNCTION 2 gtsquery_union (internal
, internal
),
541 FUNCTION 3 gtsquery_compress (internal
),
542 FUNCTION 4 gtsquery_decompress (internal
),
543 FUNCTION 5 gtsquery_penalty (internal
, internal
, internal
),
544 FUNCTION 6 gtsquery_picksplit (internal
, internal
),
545 FUNCTION 7 gtsquery_same (bigint, bigint, internal
),
548 CREATE OPERATOR CLASS gin_tsvector_ops
549 FOR TYPE tsvector
USING gin
551 OPERATOR 1 @@
(tsvector
, tsquery
),
552 OPERATOR 2 @@@
(tsvector
, tsquery
),
553 FUNCTION 1 bttextcmp(text, text),
554 FUNCTION 2 gin_extract_tsvector(tsvector
,internal
),
555 FUNCTION 3 gin_extract_tsquery(tsquery
,internal
,smallint,internal
),
556 FUNCTION 4 gin_tsquery_consistent(internal
,smallint,tsquery
,internal
),
559 CREATE OPERATOR CLASS tsvector_ops
560 FOR TYPE tsvector
USING btree
AS
566 FUNCTION 1 tsvector_cmp(tsvector
, tsvector
);
568 CREATE OPERATOR CLASS tsquery_ops
569 FOR TYPE tsquery
USING btree
AS
575 FUNCTION 1 tsquery_cmp(tsquery
, tsquery
);