Project

General

Profile

« Previous | Next » 

Revision 12309

schemas/vegbien.sql: added remake_diff_tables()

View differences:

trunk/schemas/vegbien.my.sql
882 882

  
883 883

  
884 884
--
885
-- Name: remake_diff_tables(varchar(255), anyelement); Type: FUNCTION; Schema: public_validations; Owner: -
886
--
887

  
888

  
889

  
890

  
891
--
885 892
-- Name: rematerialize_in_view(regclass); Type: FUNCTION; Schema: public_validations; Owner: -
886 893
--
887 894

  
trunk/schemas/vegbien.sql
1994 1994

  
1995 1995

  
1996 1996
--
1997
-- Name: remake_diff_tables(text, anyelement); Type: FUNCTION; Schema: public_validations; Owner: -
1998
--
1999

  
2000
CREATE FUNCTION remake_diff_tables(schema text, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
2001
    LANGUAGE plpgsql
2002
    AS $$
2003
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
2004
changes of search_path (schema elements are bound at inline time rather than
2005
runtime) */
2006
/* function option search_path is needed to limit the effects of
2007
`SET LOCAL search_path` (mk_set_search_path()) to the current function */
2008
DECLARE
2009
	errors_ct integer = 0;
2010
	in_view regclass;
2011
BEGIN
2012
	EXECUTE util.mk_use_own_schema(schema_anchor);
2013
	
2014
	FOR in_view IN SELECT * FROM validation_views(schema)
2015
	LOOP
2016
		BEGIN
2017
			PERFORM remake_diff_table(in_view, schema_anchor);
2018
		EXCEPTION
2019
		WHEN OTHERS THEN
2020
			errors_ct = errors_ct+1;
2021
			PERFORM util.raise_notice(SQLERRM);
2022
		END;
2023
	END LOOP;
2024
	IF errors_ct > 0 THEN
2025
		RAISE internal_error USING MESSAGE =
2026
			errors_ct||' queries had errors. please see the NOTICEs for details.';
2027
	END IF;
2028
END;
2029
$$;
2030

  
2031

  
2032
--
1997 2033
-- Name: rematerialize_in_view(regclass); Type: FUNCTION; Schema: public_validations; Owner: -
1998 2034
--
1999 2035

  

Also available in: Unified diff