Project

General

Profile

« Previous | Next » 

Revision 13387

fix: schemas/public_.sql: rm_all_queries(): also remove output-only result tables

View differences:

trunk/schemas/vegbien.my.sql
2749 2749

  
2750 2750

  
2751 2751
--
2752
-- Name: rm_all_queries(varchar(255), anyelement); Type: FUNCTION; Schema: public_validations; Owner: -
2752
-- Name: rm_all_queries(varchar(255), varchar(255)); Type: FUNCTION; Schema: public_validations; Owner: -
2753 2753
--
2754 2754

  
2755 2755

  
2756 2756

  
2757 2757

  
2758 2758
--
2759
-- Name: FUNCTION rm_all_queries(schema varchar(255), schema_anchor anyelement); Type: COMMENT; Schema: public_validations; Owner: -
2759
-- Name: FUNCTION rm_all_queries(schema varchar(255), query_view_regexp varchar(255)); Type: COMMENT; Schema: public_validations; Owner: -
2760 2760
--
2761 2761

  
2762 2762

  
trunk/schemas/public_.sql
4643 4643

  
4644 4644

  
4645 4645
--
4646
-- Name: rm_all_queries(text, anyelement); Type: FUNCTION; Schema: public_validations; Owner: -
4646
-- Name: rm_all_queries(text, text); Type: FUNCTION; Schema: public_validations; Owner: -
4647 4647
--
4648 4648

  
4649
CREATE FUNCTION rm_all_queries(schema text DEFAULT NULL::text, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
4650
    LANGUAGE plpgsql
4651
    SET search_path TO pg_temp
4652
    AS $$
4653
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
4654
changes of search_path (schema elements are bound at inline time rather than
4655
runtime) */
4656
/* function option search_path is needed to limit the effects of
4657
`SET LOCAL search_path` to the current function */
4658
BEGIN
4659
	PERFORM util.use_schema(schema_anchor);
4660
	
4661
	PERFORM rm_query_view(view_, schema_anchor)
4662
		-- note: rm_query_view('public_validations.view') searches *all* schemas
4663
	FROM validation_views(schema/*NULL->searches *all* schemas*/) view_
4664
	;
4665
END;
4666
$$;
4649
CREATE FUNCTION rm_all_queries(schema text DEFAULT NULL::text, query_view_regexp text DEFAULT query_view_regexp()) RETURNS void
4650
    LANGUAGE sql
4651
    AS $_$
4652
SELECT util.drop_relations_like($2, $1,
4653
force := true/*needed because some query-view-relations depend on others*/)
4654
$_$;
4667 4655

  
4668 4656

  
4669 4657
--
4670
-- Name: FUNCTION rm_all_queries(schema text, schema_anchor anyelement); Type: COMMENT; Schema: public_validations; Owner: -
4658
-- Name: FUNCTION rm_all_queries(schema text, query_view_regexp text); Type: COMMENT; Schema: public_validations; Owner: -
4671 4659
--
4672 4660

  
4673
COMMENT ON FUNCTION rm_all_queries(schema text, schema_anchor anyelement) IS '
4661
COMMENT ON FUNCTION rm_all_queries(schema text, query_view_regexp text) IS '
4674 4662
removes all validations queries in a specific schema, or in all schemas
4675 4663

  
4676
**WARNING**: if schema = ''public_validations'', this removes in *all* schemas,
4677
not just public_validations. this is because this uses rm_query_view().
4678

  
4679 4664
usage:
4680 4665
SELECT public_validations.rm_all_queries(''datasource'');
4681 4666

  
4682 4667
idempotent
4683 4668

  
4684
schema: if NULL or ''public_validations'', operates on all schemas
4669
schema: if NULL, operates on all schemas
4685 4670
schema_anchor: identifies this function''s schema. should be left as the default.
4686 4671
';
4687 4672

  
trunk/schemas/vegbien.sql
4643 4643

  
4644 4644

  
4645 4645
--
4646
-- Name: rm_all_queries(text, anyelement); Type: FUNCTION; Schema: public_validations; Owner: -
4646
-- Name: rm_all_queries(text, text); Type: FUNCTION; Schema: public_validations; Owner: -
4647 4647
--
4648 4648

  
4649
CREATE FUNCTION rm_all_queries(schema text DEFAULT NULL::text, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
4650
    LANGUAGE plpgsql
4651
    SET search_path TO pg_temp
4652
    AS $$
4653
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
4654
changes of search_path (schema elements are bound at inline time rather than
4655
runtime) */
4656
/* function option search_path is needed to limit the effects of
4657
`SET LOCAL search_path` to the current function */
4658
BEGIN
4659
	PERFORM util.use_schema(schema_anchor);
4660
	
4661
	PERFORM rm_query_view(view_, schema_anchor)
4662
		-- note: rm_query_view('public_validations.view') searches *all* schemas
4663
	FROM validation_views(schema/*NULL->searches *all* schemas*/) view_
4664
	;
4665
END;
4666
$$;
4649
CREATE FUNCTION rm_all_queries(schema text DEFAULT NULL::text, query_view_regexp text DEFAULT query_view_regexp()) RETURNS void
4650
    LANGUAGE sql
4651
    AS $_$
4652
SELECT util.drop_relations_like($2, $1,
4653
force := true/*needed because some query-view-relations depend on others*/)
4654
$_$;
4667 4655

  
4668 4656

  
4669 4657
--
4670
-- Name: FUNCTION rm_all_queries(schema text, schema_anchor anyelement); Type: COMMENT; Schema: public_validations; Owner: -
4658
-- Name: FUNCTION rm_all_queries(schema text, query_view_regexp text); Type: COMMENT; Schema: public_validations; Owner: -
4671 4659
--
4672 4660

  
4673
COMMENT ON FUNCTION rm_all_queries(schema text, schema_anchor anyelement) IS '
4661
COMMENT ON FUNCTION rm_all_queries(schema text, query_view_regexp text) IS '
4674 4662
removes all validations queries in a specific schema, or in all schemas
4675 4663

  
4676
**WARNING**: if schema = ''public_validations'', this removes in *all* schemas,
4677
not just public_validations. this is because this uses rm_query_view().
4678

  
4679 4664
usage:
4680 4665
SELECT public_validations.rm_all_queries(''datasource'');
4681 4666

  
4682 4667
idempotent
4683 4668

  
4684
schema: if NULL or ''public_validations'', operates on all schemas
4669
schema: if NULL, operates on all schemas
4685 4670
schema_anchor: identifies this function''s schema. should be left as the default.
4686 4671
';
4687 4672

  

Also available in: Unified diff