Project

General

Profile

« Previous | Next » 

Revision 12662

schemas/util.sql: auto_rm_freq(): accept multiple tables, so the freq column is only dropped if all tables have all 1s

View differences:

util.sql
679 679

  
680 680

  
681 681
--
682
-- Name: auto_rm_freq(regclass, text); Type: FUNCTION; Schema: util; Owner: -
682
-- Name: auto_rm_freq(regclass[], text); Type: FUNCTION; Schema: util; Owner: -
683 683
--
684 684

  
685
CREATE FUNCTION auto_rm_freq(table_ regclass, freq_col text DEFAULT 'copies'::text) RETURNS void
685
CREATE FUNCTION auto_rm_freq(tables regclass[], freq_col text DEFAULT 'copies'::text) RETURNS void
686 686
    LANGUAGE sql
687 687
    AS $_$
688
SELECT CASE WHEN util.freq_always_1($1, $2) THEN util.drop_column(($1, $2)) END
688
SELECT CASE WHEN util.freq_always_1($1, $2)
689
THEN util.drop_column($1, $2, force := true)
690
END
689 691
$_$;
690 692

  
691 693

  
......
3659 3661
    LANGUAGE sql
3660 3662
    AS $_$
3661 3663
SELECT util.to_freq($1);
3662
SELECT util.auto_rm_freq($1);
3664
SELECT util.auto_rm_freq(ARRAY[$1]);
3663 3665
$_$;
3664 3666

  
3665 3667

  

Also available in: Unified diff