Revision 12366
Added by Aaron Marcuse-Kubitza almost 11 years ago
vegbien.sql | ||
---|---|---|
1951 | 1951 |
SET search_path = public_validations, pg_catalog; |
1952 | 1952 |
|
1953 | 1953 |
-- |
1954 |
-- Name: new_query_view_relation_name(text, text, text); Type: FUNCTION; Schema: public_validations; Owner: -
|
|
1954 |
-- Name: query_view_relation_max_prefix_len(); Type: FUNCTION; Schema: public_validations; Owner: -
|
|
1955 | 1955 |
-- |
1956 | 1956 |
|
1957 |
CREATE FUNCTION new_query_view_relation_name(query_view_from text, query_view_to text, relation_from text) RETURNS text
|
|
1957 |
CREATE FUNCTION query_view_relation_max_prefix_len() RETURNS integer
|
|
1958 | 1958 |
LANGUAGE sql IMMUTABLE |
1959 |
AS $$ |
|
1960 |
SELECT 6/*len of '~type.', '_diff_'*/ |
|
1961 |
$$; |
|
1962 |
|
|
1963 |
|
|
1964 |
-- |
|
1965 |
-- Name: new_query_view_relation_name(text, text, text, integer); Type: FUNCTION; Schema: public_validations; Owner: - |
|
1966 |
-- |
|
1967 |
|
|
1968 |
CREATE FUNCTION new_query_view_relation_name(query_view_from text, query_view_to text, relation_from text, max_prefix_len integer DEFAULT query_view_relation_max_prefix_len()) RETURNS text |
|
1969 |
LANGUAGE sql IMMUTABLE |
|
1959 | 1970 |
AS $_$ |
1960 |
SELECT util.replace_suffix($3, $1, $2) |
|
1971 |
SELECT util.replace_suffix($3, $1, $2, $4)
|
|
1961 | 1972 |
$_$; |
1962 | 1973 |
|
1963 | 1974 |
|
1964 | 1975 |
-- |
1965 |
-- Name: query_relations(regclass); Type: FUNCTION; Schema: public_validations; Owner: -
|
|
1976 |
-- Name: FUNCTION new_query_view_relation_name(query_view_from text, query_view_to text, relation_from text, max_prefix_len integer); Type: COMMENT; Schema: public_validations; Owner: -
|
|
1966 | 1977 |
-- |
1967 | 1978 |
|
1968 |
CREATE FUNCTION query_relations(query_view regclass) RETURNS SETOF regclass |
|
1979 |
COMMENT ON FUNCTION new_query_view_relation_name(query_view_from text, query_view_to text, relation_from text, max_prefix_len integer) IS ' |
|
1980 |
max_prefix_len: when str may have been truncated (eg. as a table name) due to |
|
1981 |
the prepending of a prefix, support prefixes up to this length. should be |
|
1982 |
left as the default value. |
|
1983 |
'; |
|
1984 |
|
|
1985 |
|
|
1986 |
-- |
|
1987 |
-- Name: query_relations(regclass, integer); Type: FUNCTION; Schema: public_validations; Owner: - |
|
1988 |
-- |
|
1989 |
|
|
1990 |
CREATE FUNCTION query_relations(query_view regclass, max_prefix_len integer DEFAULT query_view_relation_max_prefix_len()) RETURNS SETOF regclass |
|
1969 | 1991 |
LANGUAGE sql STABLE |
1970 | 1992 |
AS $_$ |
1971 |
SELECT * |
|
1972 |
FROM util.show_relations_like('^.*'||util.regexp_quote(util.name($1))||'$')
|
|
1993 |
SELECT * FROM util.show_relations_like(
|
|
1994 |
util.truncated_prefixed_name_regexp(util.name($1), $2))
|
|
1973 | 1995 |
$_$; |
1974 | 1996 |
|
1975 | 1997 |
|
1976 | 1998 |
-- |
1977 |
-- Name: query_view_relation_max_prefix_len(); Type: FUNCTION; Schema: public_validations; Owner: -
|
|
1999 |
-- Name: FUNCTION query_relations(query_view regclass, max_prefix_len integer); Type: COMMENT; Schema: public_validations; Owner: -
|
|
1978 | 2000 |
-- |
1979 | 2001 |
|
1980 |
CREATE FUNCTION query_view_relation_max_prefix_len() RETURNS integer
|
|
1981 |
LANGUAGE sql IMMUTABLE
|
|
1982 |
AS $$
|
|
1983 |
SELECT 6/*len of '~type.', '_diff_'*/
|
|
1984 |
$$;
|
|
2002 |
COMMENT ON FUNCTION query_relations(query_view regclass, max_prefix_len integer) IS '
|
|
2003 |
max_prefix_len: when str may have been truncated (eg. as a table name) due to
|
|
2004 |
the prepending of a prefix, support prefixes up to this length. should be
|
|
2005 |
left as the default value.
|
|
2006 |
';
|
|
1985 | 2007 |
|
1986 | 2008 |
|
1987 | 2009 |
-- |
Also available in: Unified diff
bugfix: schemas/vegbien.sql: query_relations(), new_query_view_relation_name(): need to take into account the prefix when determining truncation, using the max_prefix_len param