Revision 14174
Added by Aaron Marcuse-Kubitza over 10 years ago
trunk/schemas/util.sql | ||
---|---|---|
4092 | 4092 |
-- |
4093 | 4093 |
|
4094 | 4094 |
CREATE FUNCTION remove_prefix(prefix text, str text, require boolean DEFAULT true) RETURNS text |
4095 |
LANGUAGE sql IMMUTABLE |
|
4095 |
LANGUAGE sql IMMUTABLE STRICT
|
|
4096 | 4096 |
AS $$ |
4097 |
-- must be declared STRICT to handle NULL properly |
|
4097 | 4098 |
SELECT CASE |
4098 | 4099 |
WHEN substring(str from 1 for length(prefix)) = prefix THEN |
4099 | 4100 |
substring(str from 1+length(prefix)) |
... | ... | |
4110 | 4111 |
-- |
4111 | 4112 |
|
4112 | 4113 |
CREATE FUNCTION remove_suffix(suffix text, str text, require boolean DEFAULT true) RETURNS text |
4113 |
LANGUAGE sql IMMUTABLE |
|
4114 |
LANGUAGE sql IMMUTABLE STRICT
|
|
4114 | 4115 |
AS $$ |
4116 |
-- must be declared STRICT to handle NULL properly |
|
4115 | 4117 |
SELECT CASE |
4116 | 4118 |
WHEN substring(str from 1+(length(str)-length(suffix))) = suffix THEN |
4117 | 4119 |
substring(str from 1 for length(str)-length(suffix)) |
Also available in: Unified diff
bugfix: schemas/util.sql: remove_prefix(), remove_suffix(): must be declared STRICT to handle NULL properly