Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/oscon_tsearch2/readme_overview_08.html
Дата изменения: Unknown
Дата индексирования: Sat Dec 22 10:29:14 2007
Кодировка:
Open Source Convention
 Previous   Next 

Tsearch2 README File Example: Overview (Continued)

Currently if we insert or update a line in the ts_readme table, we have to remember to also update the ts_vec column.

Tsearch comes with a trigger function, tsearch2(), to do this automatically.

CREATE TRIGGER ts_readme_ts_vec_update
BEFORE UPDATE OR INSERT ON ts_readme
FOR EACH ROW
EXECUTE PROCEDURE tsearch2(ts_vec, line);    

INSERT INTO ts_readme (line_number, line) 
VALUES (211, 'Adding another line to tsearch readme file.');

SELECT * FROM ts_readme
WHERE line_number = 211;

-[ RECORD 1 ]---------------------------------------------------------
line_number | 211
line        | Adding another line to tsearch readme file.
ts_vec      | 'ad':1 'file':7 'line':3 'anoth':2 'readm':6 'tsearch':5