Project

General

Profile

« Previous | Next » 

Revision 10388

schemas/util.sql: SQL-language IMMUTABLE functions marked STRICT: removed STRICT to enable dynamic inlining, which speeds up the function up to 7x. STRICT was not removed where the function was particularly complex and the STRICT optimization would likely be more significant than inlining.

View differences:

schemas/util.sql
258 258
--
259 259

  
260 260
CREATE FUNCTION _lowercase(value text) RETURNS text
261
    LANGUAGE sql IMMUTABLE STRICT
261
    LANGUAGE sql IMMUTABLE
262 262
    AS $_$
263 263
SELECT lower($1)
264 264
$_$;
......
420 420
--
421 421

  
422 422
CREATE FUNCTION _not(value boolean) RETURNS boolean
423
    LANGUAGE sql IMMUTABLE STRICT
423
    LANGUAGE sql IMMUTABLE
424 424
    AS $_$
425 425
SELECT NOT $1
426 426
$_$;
......
517 517
--
518 518

  
519 519
CREATE FUNCTION _split(value text DEFAULT NULL::text, separator text DEFAULT '; '::text) RETURNS SETOF text
520
    LANGUAGE sql IMMUTABLE STRICT
520
    LANGUAGE sql IMMUTABLE
521 521
    AS $_$
522 522
SELECT regexp_split_to_table($1, $2)
523 523
$_$;
......
778 778
--
779 779

  
780 780
CREATE FUNCTION contains(search_for text, in_str text) RETURNS boolean
781
    LANGUAGE sql IMMUTABLE STRICT
781
    LANGUAGE sql IMMUTABLE
782 782
    AS $_$
783 783
SELECT position($1 in $2) > 0 /*1-based offset*/
784 784
$_$;
......
913 913
--
914 914

  
915 915
CREATE FUNCTION ensure_prefix(prefix text, str text) RETURNS text
916
    LANGUAGE sql IMMUTABLE STRICT
916
    LANGUAGE sql IMMUTABLE
917 917
    AS $_$
918 918
SELECT (CASE WHEN util.has_prefix($1, $2) THEN $2 ELSE $1||$2 END)
919 919
$_$;
......
1086 1086
--
1087 1087

  
1088 1088
CREATE FUNCTION has_prefix(prefix text, str text) RETURNS boolean
1089
    LANGUAGE sql IMMUTABLE STRICT
1089
    LANGUAGE sql IMMUTABLE
1090 1090
    AS $_$
1091 1091
SELECT substring($2 for length($1)) = $1
1092 1092
$_$;

Also available in: Unified diff