Project

General

Profile

« Previous | Next » 

Revision 12294

bugfix: schemas/vegbien.sql: remake_diff_table(): can't have in_table/out_table inherit from each other, because inheritance also causes the rows of the parent table to be included in the child table. instead, they need to inherit from a common, empty table, as implemented by the new util.remake_diff_table().

View differences:

trunk/schemas/vegbien.sql
1957 1957
CREATE FUNCTION remake_diff_table(in_view regclass, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS regclass
1958 1958
    LANGUAGE plpgsql
1959 1959
    SET search_path TO pg_temp
1960
    AS $_$
1960
    AS $$
1961 1961
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
1962 1962
changes of search_path (schema elements are bound at inline time rather than
1963 1963
runtime) */
1964 1964
/* function option search_path is needed to limit the effects of
1965 1965
`SET LOCAL search_path` (mk_set_search_path()) to the current function */
1966 1966
DECLARE
1967
	in_table regclass;
1968
	out_table regclass;
1967
	type_table text = util.qual_name(util.schema(in_view),
1968
		'_type_'||util.name(in_view));
1969 1969
	diff_table text = util.qual_name(util.schema(in_view),
1970 1970
		'_diff_'||util.name(in_view));
1971 1971
BEGIN
1972 1972
	EXECUTE util.mk_use_own_schema(schema_anchor);
1973 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);
1974
	PERFORM util.remake_diff_table(diff_table, rematerialize_in_view(in_view),
1975
		rematerialize_out_view(in_view), type_table);
1977 1976
	
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 1977
	RETURN diff_table;
1986 1978
END;
1987
$_$;
1979
$$;
1988 1980

  
1989 1981

  
1990 1982
--

Also available in: Unified diff