Project

General

Profile

« Previous | Next » 

Revision 12338

schemas/vegbien.sql: added rm_query_view(), which removes all DB objects related to a particular validations query

View differences:

trunk/schemas/vegbien.my.sql
945 945

  
946 946

  
947 947
--
948
-- Name: rm_query_view(regclass, anyelement); Type: FUNCTION; Schema: public_validations; Owner: -
949
--
950

  
951

  
952

  
953

  
954
--
955
-- Name: FUNCTION rm_query_view(query_view regclass, schema_anchor anyelement); Type: COMMENT; Schema: public_validations; Owner: -
956
--
957

  
958

  
959

  
960

  
961
--
948 962
-- Name: validation_views(varchar(255)); Type: FUNCTION; Schema: public_validations; Owner: -
949 963
--
950 964

  
trunk/schemas/vegbien.sql
2162 2162

  
2163 2163

  
2164 2164
--
2165
-- Name: rm_query_view(regclass, anyelement); Type: FUNCTION; Schema: public_validations; Owner: -
2166
--
2167

  
2168
CREATE FUNCTION rm_query_view(query_view regclass, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
2169
    LANGUAGE plpgsql
2170
    SET search_path TO pg_temp
2171
    AS $$
2172
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
2173
changes of search_path (schema elements are bound at inline time rather than
2174
runtime) */
2175
/* function option search_path is needed to limit the effects of
2176
`SET LOCAL search_path` (mk_set_search_path()) to the current function */
2177
BEGIN
2178
	EXECUTE util.mk_use_own_schema(schema_anchor);
2179
	
2180
	PERFORM util.drop_relation(view_, force := true)
2181
		-- force: needed because some query-view-relations depend on others
2182
	FROM query_relations(query_view) view_
2183
	;
2184
END;
2185
$$;
2186

  
2187

  
2188
--
2189
-- Name: FUNCTION rm_query_view(query_view regclass, schema_anchor anyelement); Type: COMMENT; Schema: public_validations; Owner: -
2190
--
2191

  
2192
COMMENT ON FUNCTION rm_query_view(query_view regclass, schema_anchor anyelement) IS '
2193
removes all DB objects related to a particular validations query
2194

  
2195
usage:
2196
SELECT public_validations.rm_query_view(''public_validations._view_name'');
2197

  
2198
idempotent
2199

  
2200
schema_anchor: identifies which schema to use. should be left as the default value.
2201
';
2202

  
2203

  
2204
--
2165 2205
-- Name: validation_views(text); Type: FUNCTION; Schema: public_validations; Owner: -
2166 2206
--
2167 2207

  

Also available in: Unified diff