From dd2870f76fe0295f5507b44297a03fa612ece6db Mon Sep 17 00:00:00 2001 From: Teodor Sigaev Date: Wed, 6 Aug 2003 09:19:21 +0000 Subject: [PATCH] Add ts_debug function for debugging configurations --- contrib/tsearch2/expected/tsearch2.out | 11 +++++++++++ contrib/tsearch2/sql/tsearch2.sql | 2 ++ contrib/tsearch2/tsearch.sql._in | 36 ++++++++++++++++++++++++++++++++++ contrib/tsearch2/untsearch.sql.in | 3 +++ 4 files changed, 52 insertions(+) diff --git a/contrib/tsearch2/expected/tsearch2.out b/contrib/tsearch2/expected/tsearch2.out index de56d777d9..d0b9104353 100644 --- a/contrib/tsearch2/expected/tsearch2.out +++ b/contrib/tsearch2/expected/tsearch2.out @@ -2056,3 +2056,14 @@ A thousand years to trace The granite features of this cliff (1 row) +--check debug +select * from ts_debug('Tsearch module for PostgreSQL 7.3.3'); + ts_name | tok_type | description | token | dict_name | tsvector +---------+----------+-------------+------------+-----------+-------------- + default | lword | Latin word | Tsearch | {en_stem} | 'tsearch' + default | lword | Latin word | module | {en_stem} | 'modul' + default | lword | Latin word | for | {en_stem} | + default | lword | Latin word | PostgreSQL | {en_stem} | 'postgresql' + default | version | VERSION | 7.3.3 | {simple} | '7.3.3' +(5 rows) + diff --git a/contrib/tsearch2/sql/tsearch2.sql b/contrib/tsearch2/sql/tsearch2.sql index 6ca6480cc4..0c10edb6ec 100644 --- a/contrib/tsearch2/sql/tsearch2.sql +++ b/contrib/tsearch2/sql/tsearch2.sql @@ -241,3 +241,5 @@ The sculpture of these granite seams, Upon a woman s face. E. J. Pratt (1882 1964) ', to_tsquery('sea')); +--check debug +select * from ts_debug('Tsearch module for PostgreSQL 7.3.3'); diff --git a/contrib/tsearch2/tsearch.sql._in b/contrib/tsearch2/tsearch.sql._in index 91ffbc862d..de75a5bc64 100644 --- a/contrib/tsearch2/tsearch.sql._in +++ b/contrib/tsearch2/tsearch.sql._in @@ -666,6 +666,42 @@ CREATE FUNCTION get_covers(tsvector,tsquery) language 'C' with (isstrict); +--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 prs_name from pg_ts_cfg where oid = show_curcfg() ' +language 'SQL' with(isstrict,iscachable); + +create function ts_debug(text) +returns setof tsdebug as ' +select + m.ts_name, + t.alias as tok_type, + t.descr as description, + p.token, + m.dict_name, + strip(to_tsvector(p.token)) as tsvector +from + parse( _get_parser_from_curcfg(), $1 ) as p, + token_type() as t, + pg_ts_cfgmap as m, + pg_ts_cfg as c +where + t.tokid=p.tokid and + t.alias = m.tok_alias and + m.ts_name=c.ts_name and + c.oid=show_curcfg() +' language 'SQL' with(isstrict); + --example of ISpell dictionary --update pg_ts_dict set dict_initoption='DictFile="/usr/local/share/ispell/russian.dict" ,AffFile ="/usr/local/share/ispell/russian.aff", StopFile="/usr/local/share/ispell/russian.stop"' where dict_id=4; diff --git a/contrib/tsearch2/untsearch.sql.in b/contrib/tsearch2/untsearch.sql.in index a4fe145c6f..e7cfcc6a87 100644 --- a/contrib/tsearch2/untsearch.sql.in +++ b/contrib/tsearch2/untsearch.sql.in @@ -26,6 +26,8 @@ DROP TYPE tsquery CASCADE; DROP TYPE gtsvector CASCADE; DROP TYPE tsstat CASCADE; DROP TYPE statinfo CASCADE; +DROP TYPE tsdebug CASCADE; + DROP FUNCTION lexize(oid, text) ; DROP FUNCTION lexize(text, text); @@ -58,5 +60,6 @@ DROP FUNCTION gtsvector_picksplit(internal, internal); DROP FUNCTION gtsvector_union(bytea, internal); DROP FUNCTION reset_tsearch(); DROP FUNCTION tsearch2() CASCADE; +DROP FUNCTION _get_parser_from_curcfg(); END; -- 2.11.0