CREATE OR REPLACE FUNCTION LastIndexOf(text,char) RETURNS integer LANGUAGE SQL AS $$ select LENGTH($1) - strpos(reverse($1),$2) $$;