Improve functions
This commit is contained in:
parent
f9448ab188
commit
ac06d83542
1 changed files with 12 additions and 4 deletions
|
@ -1,13 +1,21 @@
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
CREATE FUNCTION is_name(value TEXT) RETURNS BOOLEAN LANGUAGE plpgsql
|
CREATE FUNCTION is_name(value TEXT)
|
||||||
|
RETURNS BOOLEAN
|
||||||
|
IMMUTABLE
|
||||||
|
PARALLEL SAFE
|
||||||
|
LANGUAGE plpgsql
|
||||||
AS $$BEGIN
|
AS $$BEGIN
|
||||||
RETURN value = btrim(value) AND length(value) > 0;
|
RETURN value IS NOT NULL AND value = btrim(value) AND length(value) > 0;
|
||||||
END$$;
|
END$$;
|
||||||
|
|
||||||
CREATE FUNCTION is_language_code(value VARCHAR) RETURNS BOOLEAN LANGUAGE plpgsql
|
CREATE FUNCTION is_language_code(value VARCHAR)
|
||||||
|
RETURNS BOOLEAN
|
||||||
|
IMMUTABLE
|
||||||
|
PARALLEL SAFE
|
||||||
|
LANGUAGE plpgsql
|
||||||
AS $$BEGIN
|
AS $$BEGIN
|
||||||
RETURN value ~ '^[a-z]{2}$';
|
RETURN value IS NOT NULL AND value ~ '^[a-z]{2}$';
|
||||||
END$$;
|
END$$;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
Loading…
Reference in a new issue