]> granicus.if.org Git - postgresql/commitdiff
Add ts_debug function for debugging configurations
authorTeodor Sigaev <teodor@sigaev.ru>
Wed, 6 Aug 2003 09:19:21 +0000 (09:19 +0000)
committerTeodor Sigaev <teodor@sigaev.ru>
Wed, 6 Aug 2003 09:19:21 +0000 (09:19 +0000)
contrib/tsearch2/expected/tsearch2.out
contrib/tsearch2/sql/tsearch2.sql
contrib/tsearch2/tsearch.sql._in
contrib/tsearch2/untsearch.sql.in

index de56d777d9c51c63dee8e71794030825b7a00618..d0b910435392112f22336f3b7141d0713a9569cb 100644 (file)
@@ -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)
+
index 6ca6480cc48eb2acf12ba8aa8f098e78f175ca84..0c10edb6ec9dec16fb41e8a71289fb61370913a7 100644 (file)
@@ -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');
index 91ffbc862d19c4aca61a3a62803e58f936fe4de6..de75a5bc649ac15cb7cabb9fb12e51a8201e3fad 100644 (file)
@@ -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;
index a4fe145c6fdb66c5a81e90a22fcec0cd72a95216..e7cfcc6a879ac5066f119e2a18671b265e4f9834 100644 (file)
@@ -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;