Project

General

Profile

« Previous | Next » 

Revision 13099

schemas/vegbien.sql: rm_output_queries(): also support removing just a particular output query

View differences:

trunk/schemas/vegbien.my.sql
2574 2574

  
2575 2575

  
2576 2576
--
2577
-- Name: FUNCTION rm_output_queries(group_ varchar(255), schema_anchor anyelement); Type: COMMENT; Schema: public_validations; Owner: -
2577
-- Name: FUNCTION rm_output_queries(prefix varchar(255), schema_anchor anyelement); Type: COMMENT; Schema: public_validations; Owner: -
2578 2578
--
2579 2579

  
2580 2580

  
trunk/schemas/vegbien.sql
4400 4400
-- Name: rm_output_queries(text, anyelement); Type: FUNCTION; Schema: public_validations; Owner: -
4401 4401
--
4402 4402

  
4403
CREATE FUNCTION rm_output_queries(group_ text DEFAULT NULL::text, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
4403
CREATE FUNCTION rm_output_queries(prefix text DEFAULT NULL::text, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
4404 4404
    LANGUAGE sql
4405 4405
    AS $_$
4406
SELECT util.drop_relations_like('^(?:\w*~type\.)?_'||
4407
COALESCE(util.regexp_quote($1), '[[:alpha:]]+') ||'_',
4406
SELECT util.drop_relations_like('^(?:\w*~type\.)?'||
4407
COALESCE(util.regexp_quote($1), '_[[:alpha:]]+_'),
4408 4408
$2, force := true/*needed because some query-view-relations depend on others*/)
4409 4409
$_$;
4410 4410

  
4411 4411

  
4412 4412
--
4413
-- Name: FUNCTION rm_output_queries(group_ text, schema_anchor anyelement); Type: COMMENT; Schema: public_validations; Owner: -
4413
-- Name: FUNCTION rm_output_queries(prefix text, schema_anchor anyelement); Type: COMMENT; Schema: public_validations; Owner: -
4414 4414
--
4415 4415

  
4416
COMMENT ON FUNCTION rm_output_queries(group_ text, schema_anchor anyelement) IS '
4417
removes all validations *output* queries (in this function''s schema), or just
4418
those that have a particular group prefix.
4416
COMMENT ON FUNCTION rm_output_queries(prefix text, schema_anchor anyelement) IS '
4417
removes validations *output* queries (in this function''s schema)
4419 4418

  
4420 4419
note that this will cascadingly drop all result tables for those queries as well
4421 4420
(as these inherit from type tables in this function''s schema).
4422 4421

  
4423 4422
usage:
4424
SELECT public_validations.rm_query_group(''plots'');
4425 4423

  
4424
to remove all output queries:
4425
SELECT public_validations.rm_output_queries();
4426

  
4427
to remove output queries with a particular group prefix:
4428
SELECT public_validations.rm_output_queries(''_group_'');
4429

  
4430
to remove a particular output query:
4431
SELECT public_validations.rm_output_queries(''_view_name'');
4432

  
4426 4433
idempotent
4427 4434

  
4428 4435
schema_anchor: identifies this function''s schema. should be left as the default.

Also available in: Unified diff