Hmm ... playing a bit more with the example I was just on about:
regression=# create table ts_subst(target tsquery, subst tsquery);
CREATE TABLE
regression=# insert into ts_subst values('a', 'foo|bar');
INSERT 0 1
regression=# insert into ts_subst values('bar', 'baz');
INSERT 0 1
regression=# select ts_rewrite('a & b'::tsquery, 'select target, subst from ts_subst'); ts_rewrite
-------------------------'b' & ( 'foo' | 'bar' )
(1 row)
Shouldn't I have gotten 'b' & ( 'foo' | 'baz' ) ???
regards, tom lane