/usr/share/postgres-xc/extension/tsearch2--1.0.sql is in postgres-xc-contrib 1.1-2ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | /* contrib/tsearch2/tsearch2--1.0.sql */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION tsearch2" to load this file. \quit
-- These domains are just to catch schema-qualified references to the
-- old data types.
CREATE DOMAIN tsvector AS pg_catalog.tsvector;
CREATE DOMAIN tsquery AS pg_catalog.tsquery;
CREATE DOMAIN gtsvector AS pg_catalog.gtsvector;
CREATE DOMAIN gtsq AS pg_catalog.text;
--dict interface
CREATE FUNCTION lexize(oid, text)
RETURNS _text
as 'ts_lexize'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT;
CREATE FUNCTION lexize(text, text)
RETURNS _text
as 'MODULE_PATHNAME', 'tsa_lexize_byname'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
CREATE FUNCTION lexize(text)
RETURNS _text
as 'MODULE_PATHNAME', 'tsa_lexize_bycurrent'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
CREATE FUNCTION set_curdict(int)
RETURNS void
as 'MODULE_PATHNAME', 'tsa_set_curdict'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
CREATE FUNCTION set_curdict(text)
RETURNS void
as 'MODULE_PATHNAME', 'tsa_set_curdict_byname'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
--built-in dictionaries
CREATE FUNCTION dex_init(internal)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_dex_init'
LANGUAGE C;
CREATE FUNCTION dex_lexize(internal,internal,int4)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_dex_lexize'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
CREATE FUNCTION snb_en_init(internal)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_snb_en_init'
LANGUAGE C;
CREATE FUNCTION snb_lexize(internal,internal,int4)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_snb_lexize'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
CREATE FUNCTION snb_ru_init_koi8(internal)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_snb_ru_init_koi8'
LANGUAGE C;
CREATE FUNCTION snb_ru_init_utf8(internal)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_snb_ru_init_utf8'
LANGUAGE C;
CREATE FUNCTION snb_ru_init(internal)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_snb_ru_init'
LANGUAGE C;
CREATE FUNCTION spell_init(internal)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_spell_init'
LANGUAGE C;
CREATE FUNCTION spell_lexize(internal,internal,int4)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_spell_lexize'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
CREATE FUNCTION syn_init(internal)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_syn_init'
LANGUAGE C;
CREATE FUNCTION syn_lexize(internal,internal,int4)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_syn_lexize'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
CREATE FUNCTION thesaurus_init(internal)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_thesaurus_init'
LANGUAGE C;
CREATE FUNCTION thesaurus_lexize(internal,internal,int4,internal)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_thesaurus_lexize'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
--sql-level interface
CREATE TYPE tokentype
as (tokid int4, alias text, descr text);
CREATE FUNCTION token_type(int4)
RETURNS setof tokentype
as 'ts_token_type_byid'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT
ROWS 16;
CREATE FUNCTION token_type(text)
RETURNS setof tokentype
as 'ts_token_type_byname'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT
ROWS 16;
CREATE FUNCTION token_type()
RETURNS setof tokentype
as 'MODULE_PATHNAME', 'tsa_token_type_current'
LANGUAGE C
RETURNS NULL ON NULL INPUT
ROWS 16;
CREATE FUNCTION set_curprs(int)
RETURNS void
as 'MODULE_PATHNAME', 'tsa_set_curprs'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
CREATE FUNCTION set_curprs(text)
RETURNS void
as 'MODULE_PATHNAME', 'tsa_set_curprs_byname'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
CREATE TYPE tokenout
as (tokid int4, token text);
CREATE FUNCTION parse(oid,text)
RETURNS setof tokenout
as 'ts_parse_byid'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT;
CREATE FUNCTION parse(text,text)
RETURNS setof tokenout
as 'ts_parse_byname'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT;
CREATE FUNCTION parse(text)
RETURNS setof tokenout
as 'MODULE_PATHNAME', 'tsa_parse_current'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
--default parser
CREATE FUNCTION prsd_start(internal,int4)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_prsd_start'
LANGUAGE C;
CREATE FUNCTION prsd_getlexeme(internal,internal,internal)
RETURNS int4
as 'MODULE_PATHNAME', 'tsa_prsd_getlexeme'
LANGUAGE C;
CREATE FUNCTION prsd_end(internal)
RETURNS void
as 'MODULE_PATHNAME', 'tsa_prsd_end'
LANGUAGE C;
CREATE FUNCTION prsd_lextype(internal)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_prsd_lextype'
LANGUAGE C;
CREATE FUNCTION prsd_headline(internal,internal,internal)
RETURNS internal
as 'MODULE_PATHNAME', 'tsa_prsd_headline'
LANGUAGE C;
--tsearch config
CREATE FUNCTION set_curcfg(int)
RETURNS void
as 'MODULE_PATHNAME', 'tsa_set_curcfg'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
CREATE FUNCTION set_curcfg(text)
RETURNS void
as 'MODULE_PATHNAME', 'tsa_set_curcfg_byname'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
CREATE FUNCTION show_curcfg()
RETURNS oid
AS 'get_current_ts_config'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT STABLE;
CREATE FUNCTION length(tsvector)
RETURNS int4
AS 'tsvector_length'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION to_tsvector(oid, text)
RETURNS tsvector
AS 'to_tsvector_byid'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION to_tsvector(text, text)
RETURNS tsvector
AS 'MODULE_PATHNAME', 'tsa_to_tsvector_name'
LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION to_tsvector(text)
RETURNS tsvector
AS 'to_tsvector'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION strip(tsvector)
RETURNS tsvector
AS 'tsvector_strip'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION setweight(tsvector,"char")
RETURNS tsvector
AS 'tsvector_setweight'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION concat(tsvector,tsvector)
RETURNS tsvector
AS 'tsvector_concat'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION querytree(tsquery)
RETURNS text
AS 'tsquerytree'
LANGUAGE INTERNAL RETURNS NULL ON NULL INPUT;
CREATE FUNCTION to_tsquery(oid, text)
RETURNS tsquery
AS 'to_tsquery_byid'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION to_tsquery(text, text)
RETURNS tsquery
AS 'MODULE_PATHNAME','tsa_to_tsquery_name'
LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION to_tsquery(text)
RETURNS tsquery
AS 'to_tsquery'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION plainto_tsquery(oid, text)
RETURNS tsquery
AS 'plainto_tsquery_byid'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION plainto_tsquery(text, text)
RETURNS tsquery
AS 'MODULE_PATHNAME','tsa_plainto_tsquery_name'
LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION plainto_tsquery(text)
RETURNS tsquery
AS 'plainto_tsquery'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
--Trigger
CREATE FUNCTION tsearch2()
RETURNS trigger
AS 'MODULE_PATHNAME', 'tsa_tsearch2'
LANGUAGE C;
--Relevation
CREATE FUNCTION rank(float4[], tsvector, tsquery)
RETURNS float4
AS 'ts_rank_wtt'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION rank(float4[], tsvector, tsquery, int4)
RETURNS float4
AS 'ts_rank_wttf'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION rank(tsvector, tsquery)
RETURNS float4
AS 'ts_rank_tt'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION rank(tsvector, tsquery, int4)
RETURNS float4
AS 'ts_rank_ttf'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION rank_cd(float4[], tsvector, tsquery)
RETURNS float4
AS 'ts_rankcd_wtt'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION rank_cd(float4[], tsvector, tsquery, int4)
RETURNS float4
AS 'ts_rankcd_wttf'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION rank_cd(tsvector, tsquery)
RETURNS float4
AS 'ts_rankcd_tt'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION rank_cd(tsvector, tsquery, int4)
RETURNS float4
AS 'ts_rankcd_ttf'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION headline(oid, text, tsquery, text)
RETURNS text
AS 'ts_headline_byid_opt'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION headline(oid, text, tsquery)
RETURNS text
AS 'ts_headline_byid'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION headline(text, text, tsquery, text)
RETURNS text
AS 'MODULE_PATHNAME', 'tsa_headline_byname'
LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION headline(text, text, tsquery)
RETURNS text
AS 'MODULE_PATHNAME', 'tsa_headline_byname'
LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION headline(text, tsquery, text)
RETURNS text
AS 'ts_headline_opt'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION headline(text, tsquery)
RETURNS text
AS 'ts_headline'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
-- CREATE the OPERATOR class
CREATE OPERATOR CLASS gist_tsvector_ops
FOR TYPE tsvector USING gist
AS
OPERATOR 1 @@ (tsvector, tsquery),
FUNCTION 1 gtsvector_consistent (internal, gtsvector, int, oid, internal),
FUNCTION 2 gtsvector_union (internal, internal),
FUNCTION 3 gtsvector_compress (internal),
FUNCTION 4 gtsvector_decompress (internal),
FUNCTION 5 gtsvector_penalty (internal, internal, internal),
FUNCTION 6 gtsvector_picksplit (internal, internal),
FUNCTION 7 gtsvector_same (gtsvector, gtsvector, internal),
STORAGE gtsvector;
--stat info
CREATE TYPE statinfo
as (word text, ndoc int4, nentry int4);
CREATE FUNCTION stat(text)
RETURNS setof statinfo
as 'ts_stat1'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT;
CREATE FUNCTION stat(text,text)
RETURNS setof statinfo
as 'ts_stat2'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT;
--reset - just for debuging
CREATE FUNCTION reset_tsearch()
RETURNS void
as 'MODULE_PATHNAME', 'tsa_reset_tsearch'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
--get cover (debug for rank_cd)
CREATE FUNCTION get_covers(tsvector,tsquery)
RETURNS text
as 'MODULE_PATHNAME', 'tsa_get_covers'
LANGUAGE C
RETURNS NULL ON NULL INPUT;
--debug function
create type tsdebug as (
ts_name text,
tok_type text,
description text,
token text,
dict_name text[],
"tsvector" tsvector
);
CREATE FUNCTION _get_parser_from_curcfg()
RETURNS text as
$$select prsname::text from pg_catalog.pg_ts_parser p join pg_ts_config c on cfgparser = p.oid where c.oid = show_curcfg();$$
LANGUAGE SQL RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION ts_debug(text)
RETURNS setof tsdebug as $$
select
(select c.cfgname::text from pg_catalog.pg_ts_config as c
where c.oid = show_curcfg()),
t.alias as tok_type,
t.descr as description,
p.token,
ARRAY ( SELECT m.mapdict::pg_catalog.regdictionary::pg_catalog.text
FROM pg_catalog.pg_ts_config_map AS m
WHERE m.mapcfg = show_curcfg() AND m.maptokentype = p.tokid
ORDER BY m.mapseqno )
AS dict_name,
strip(to_tsvector(p.token)) as tsvector
from
parse( _get_parser_from_curcfg(), $1 ) as p,
token_type() as t
where
t.tokid = p.tokid
$$ LANGUAGE SQL RETURNS NULL ON NULL INPUT;
CREATE FUNCTION numnode(tsquery)
RETURNS int4
as 'tsquery_numnode'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION tsquery_and(tsquery,tsquery)
RETURNS tsquery
as 'tsquery_and'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION tsquery_or(tsquery,tsquery)
RETURNS tsquery
as 'tsquery_or'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION tsquery_not(tsquery)
RETURNS tsquery
as 'tsquery_not'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
--------------rewrite subsystem
CREATE FUNCTION rewrite(tsquery, text)
RETURNS tsquery
as 'tsquery_rewrite_query'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION rewrite(tsquery, tsquery, tsquery)
RETURNS tsquery
as 'tsquery_rewrite'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION rewrite_accum(tsquery,tsquery[])
RETURNS tsquery
AS 'MODULE_PATHNAME', 'tsa_rewrite_accum'
LANGUAGE C;
CREATE FUNCTION rewrite_finish(tsquery)
RETURNS tsquery
as 'MODULE_PATHNAME', 'tsa_rewrite_finish'
LANGUAGE C;
CREATE AGGREGATE rewrite (
BASETYPE = tsquery[],
SFUNC = rewrite_accum,
STYPE = tsquery,
FINALFUNC = rewrite_finish
);
CREATE FUNCTION tsq_mcontains(tsquery, tsquery)
RETURNS bool
as 'tsq_mcontains'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION tsq_mcontained(tsquery, tsquery)
RETURNS bool
as 'tsq_mcontained'
LANGUAGE INTERNAL
RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE OPERATOR CLASS gist_tp_tsquery_ops
FOR TYPE tsquery USING gist
AS
OPERATOR 7 @> (tsquery, tsquery),
OPERATOR 8 <@ (tsquery, tsquery),
FUNCTION 1 gtsquery_consistent (internal, internal, int, oid, internal),
FUNCTION 2 gtsquery_union (internal, internal),
FUNCTION 3 gtsquery_compress (internal),
FUNCTION 4 gtsquery_decompress (internal),
FUNCTION 5 gtsquery_penalty (internal, internal, internal),
FUNCTION 6 gtsquery_picksplit (internal, internal),
FUNCTION 7 gtsquery_same (bigint, bigint, internal),
STORAGE bigint;
CREATE OPERATOR CLASS gin_tsvector_ops
FOR TYPE tsvector USING gin
AS
OPERATOR 1 @@ (tsvector, tsquery),
OPERATOR 2 @@@ (tsvector, tsquery),
FUNCTION 1 bttextcmp(text, text),
FUNCTION 2 gin_extract_tsvector(tsvector,internal,internal),
FUNCTION 3 gin_extract_tsquery(tsquery,internal,smallint,internal,internal,internal,internal),
FUNCTION 4 gin_tsquery_consistent(internal,smallint,tsquery,int,internal,internal,internal,internal),
FUNCTION 5 gin_cmp_prefix(text,text,smallint,internal),
STORAGE text;
CREATE OPERATOR CLASS tsvector_ops
FOR TYPE tsvector USING btree AS
OPERATOR 1 < ,
OPERATOR 2 <= ,
OPERATOR 3 = ,
OPERATOR 4 >= ,
OPERATOR 5 > ,
FUNCTION 1 tsvector_cmp(tsvector, tsvector);
CREATE OPERATOR CLASS tsquery_ops
FOR TYPE tsquery USING btree AS
OPERATOR 1 < ,
OPERATOR 2 <= ,
OPERATOR 3 = ,
OPERATOR 4 >= ,
OPERATOR 5 > ,
FUNCTION 1 tsquery_cmp(tsquery, tsquery);
|