Re: [GENERAL] Full text search, SQL functions, and the planner

2013-06-07 Thread Tom Lane
Marc Dahn writes: > So -- is there a way to let the planner look through the CASE? No. It would actually be wrong to simplify the expression in the way you're imagining, since "1 = case when bool_expr then 1 else 0 end" does not give the same result as the plain bool_expr if the latter yields nu

[GENERAL] Full text search, SQL functions, and the planner

2013-06-07 Thread Marc Dahn
Hi, To maintain an externally defined interface, I'd like to define a function hasword(haystack, needle) that (essentially) returns 1 when to_tsvector(haystack) @@ to_tsquery(needle), 0 otherwise. I've tried CREATE OR REPLACE FUNCTION ivo_hasword(haystack TEXT, needle TEXT) RETUR