diff options
Diffstat (limited to 'util/sql/func.sql')
-rw-r--r-- | util/sql/func.sql | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/util/sql/func.sql b/util/sql/func.sql index e5e12eab..125455a2 100644 --- a/util/sql/func.sql +++ b/util/sql/func.sql @@ -15,6 +15,14 @@ CREATE OR REPLACE FUNCTION strip_bb_tags(t text) RETURNS text AS $$ SELECT regexp_replace(t, '\[(?:url=[^\]]+|/?(?:spoiler|quote|raw|code|url))\]', ' ', 'gi'); $$ LANGUAGE sql IMMUTABLE; +-- Wrapper around to_tsvector() and strip_bb_tags(), implemented in plpgsql and +-- with an associated cost function to make it opaque to the query planner and +-- ensure the query planner realizes that this function is _slow_. +CREATE OR REPLACE FUNCTION bb_tsvector(t text) RETURNS tsvector AS $$ +BEGIN + RETURN to_tsvector('english', strip_bb_tags(t)); +END; +$$ LANGUAGE plpgsql IMMUTABLE COST 500; -- BUG: Since this isn't a full bbcode parser, [spoiler] tags inside [raw] or [code] are still considered spoilers. CREATE OR REPLACE FUNCTION strip_spoilers(t text) RETURNS text AS $$ |