Revision 14276
Added by Aaron Marcuse-Kubitza over 10 years ago
util.sql | ||
---|---|---|
1949 | 1949 |
|
1950 | 1950 |
|
1951 | 1951 |
-- |
1952 |
-- Name: derived_col_name_from_check_constraint(check_constraint_def); Type: FUNCTION; Schema: util; Owner: - |
|
1953 |
-- |
|
1954 |
|
|
1955 |
CREATE FUNCTION derived_col_name_from_check_constraint(check_constraint_def check_constraint_def) RETURNS text |
|
1956 |
LANGUAGE sql IMMUTABLE |
|
1957 |
AS $_$ |
|
1958 |
-- **IMPORTANT**: need to remove the enclosing () to be consistent everywhere |
|
1959 |
SELECT (SELECT regexp_matches( |
|
1960 |
util.trim_parens(util.remove_prefix($$NOT $$, util.trim_parens( |
|
1961 |
util.check_constraint_expr_enable(check_constraint_def.expr) |
|
1962 |
), require := true)) |
|
1963 |
, $$^(.*?) IS DISTINCT FROM $$))[1] |
|
1964 |
$_$; |
|
1965 |
|
|
1966 |
|
|
1967 |
-- |
|
1952 | 1968 |
-- Name: derived_col_populated(col); Type: FUNCTION; Schema: util; Owner: - |
1953 | 1969 |
-- |
1954 | 1970 |
|
Also available in: Unified diff
schemas/util.sql: added derived_col_name_from_check_constraint()