Revision 12287
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: remake_diff_table(regclass, anyelement); Type: FUNCTION; Schema: public_validations; Owner: - |
|
1955 |
-- |
|
1956 |
|
|
1957 |
CREATE FUNCTION remake_diff_table(in_view regclass, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS regclass |
|
1958 |
LANGUAGE plpgsql |
|
1959 |
SET search_path TO pg_temp |
|
1960 |
AS $_$ |
|
1961 |
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime |
|
1962 |
changes of search_path (schema elements are bound at inline time rather than |
|
1963 |
runtime) */ |
|
1964 |
/* function option search_path is needed to limit the effects of |
|
1965 |
`SET LOCAL search_path` (mk_set_search_path()) to the current function */ |
|
1966 |
DECLARE |
|
1967 |
in_table regclass; |
|
1968 |
out_table regclass; |
|
1969 |
diff_table text = util.qual_name(util.schema(in_view), |
|
1970 |
'_diff_'||util.name(in_view)); |
|
1971 |
BEGIN |
|
1972 |
EXECUTE util.mk_use_own_schema(schema_anchor); |
|
1973 |
|
|
1974 |
in_table = rematerialize_in_view(in_view); |
|
1975 |
out_table = rematerialize_out_view(in_view); |
|
1976 |
PERFORM util.inherit(in_table, out_table); |
|
1977 |
|
|
1978 |
PERFORM util.rematerialize_query(diff_table, $$ |
|
1979 |
SELECT * FROM util.diff( |
|
1980 |
$$||quote_nullable(in_table)||$$ |
|
1981 |
, $$||quote_nullable(out_table)||$$ |
|
1982 |
, NULL::$$||out_table||$$) |
|
1983 |
$$); |
|
1984 |
|
|
1985 |
RETURN diff_table; |
|
1986 |
END; |
|
1987 |
$_$; |
|
1988 |
|
|
1989 |
|
|
1990 |
-- |
|
1991 |
-- Name: FUNCTION remake_diff_table(in_view regclass, schema_anchor anyelement); Type: COMMENT; Schema: public_validations; Owner: - |
|
1992 |
-- |
|
1993 |
|
|
1994 |
COMMENT ON FUNCTION remake_diff_table(in_view regclass, schema_anchor anyelement) IS ' |
|
1995 |
usage: |
|
1996 |
SELECT public_validations.remake_diff_table(''datasource._view_name'') AS diff_table; |
|
1997 |
|
|
1998 |
idempotent, but repeats action each time |
|
1999 |
|
|
2000 |
schema_anchor: identifies which schema to use. should be left as the default value. |
|
2001 |
'; |
|
2002 |
|
|
2003 |
|
|
2004 |
-- |
|
1954 | 2005 |
-- Name: rematerialize_in_view(regclass); Type: FUNCTION; Schema: public_validations; Owner: - |
1955 | 2006 |
-- |
1956 | 2007 |
|
Also available in: Unified diff
schemas/vegbien.sql: added remake_diff_table()