[HACKERS] syntax for reaching into records, specifically ts_stat results

2008-12-09 Thread Dan Chak
Dear Postgres Folk, In working with tsvectors (added in 8.3), I've come to a place where my syntax-fu has failed me. I've resorted to turning a result set of records into strings so that I can regexp out the record fields I need, rather than access them directly, as I'm sure it's possible

Re: [HACKERS] syntax for reaching into records, specifically ts_stat results

2008-12-09 Thread Oleg Bartunov
try select * from ts_stat() btw, performance of ts_stat() was greatly improved in 8.4. Oleg On Tue, 9 Dec 2008, Dan Chak wrote: Dear Postgres Folk, In working with tsvectors (added in 8.3), I've come to a place where my syntax-fu has failed me. I've resorted to turning a result set of

Re: [HACKERS] syntax for reaching into records, specifically ts_stat results

2008-12-09 Thread Tom Lane
Dan Chak [EMAIL PROTECTED] writes: If I say stat.word (instead of subscripting), I get 'missing FROM- clause entry for table stat'. If I say foo.stat.word, I get 'ERROR: schema foo does not exist'. I think the syntax you need is (stat).word etc. See Field Selection here:

Re: [HACKERS] syntax for reaching into records, specifically ts_stat results

2008-12-09 Thread Dan Chak
Oleg, This syntax works fine until I also want to get the sentence_id column in there as well, so that I can differentiate one set of ts_stat results from another. With the syntax where ts_stat is treated like a table, it isn't possible to run ts_stat separately on multiple tsvectors as

Re: [HACKERS] syntax for reaching into records, specifically ts_stat results

2008-12-09 Thread Dan Chak
That works perfectly! Thanks, Dan On Dec 9, 2008, at 3:13 PM, Tom Lane wrote: Dan Chak [EMAIL PROTECTED] writes: If I say stat.word (instead of subscripting), I get 'missing FROM- clause entry for table stat'. If I say foo.stat.word, I get 'ERROR: schema foo does not exist'. I think the

Re: [HACKERS] syntax for reaching into records, specifically ts_stat results

2008-12-09 Thread Oleg Bartunov
On Tue, 9 Dec 2008, Dan Chak wrote: Oleg, This syntax works fine until I also want to get the sentence_id column in there as well, so that I can differentiate one set of ts_stat results from another. With the syntax where ts_stat is treated like a table, it isn't possible to run ts_stat

Re: [HACKERS] syntax for reaching into records, specifically ts_stat results

2008-12-09 Thread Oleg Bartunov
ok, here is a function ( credits to Teodor ) CREATE OR REPLACE FUNCTION ts_stat(tsvector, OUT word text, OUT ndoc integer, OUT nentry integer) RETURNS SETOF record AS $$ SELECT ts_stat('SELECT ' || quote_literal( $1::text ) || '::tsvector'); $$ LANGUAGE SQL RETURNS NULL ON NULL INPUT