Project

General

Profile

« Previous | Next » 

Revision 14187

schemas/util.sql: added starts_with(), ends_with()

View differences:

trunk/schemas/util.sql
2053 2053

  
2054 2054

  
2055 2055
--
2056
-- Name: ends_with(text, text); Type: FUNCTION; Schema: util; Owner: -
2057
--
2058

  
2059
CREATE FUNCTION ends_with(suffix text, str text) RETURNS boolean
2060
    LANGUAGE sql IMMUTABLE
2061
    AS $$
2062
SELECT substring(str from 1+(length(str)-length(suffix))) = suffix
2063
$$;
2064

  
2065

  
2066
--
2056 2067
-- Name: ensure_prefix(text, text); Type: FUNCTION; Schema: util; Owner: -
2057 2068
--
2058 2069

  
......
4927 4938

  
4928 4939

  
4929 4940
--
4941
-- Name: starts_with(text, text); Type: FUNCTION; Schema: util; Owner: -
4942
--
4943

  
4944
CREATE FUNCTION starts_with(prefix text, str text) RETURNS boolean
4945
    LANGUAGE sql IMMUTABLE
4946
    AS $$
4947
SELECT substring(str from 1 for length(prefix)) = prefix
4948
$$;
4949

  
4950

  
4951
--
4930 4952
-- Name: str_equality_regexp(text); Type: FUNCTION; Schema: util; Owner: -
4931 4953
--
4932 4954

  

Also available in: Unified diff