exchange_do_comment_partitioned_table.sql (1314B)
1 -- 2 -- This file is part of TALER 3 -- Copyright (C) 2014--2022 Taler Systems SA 4 -- 5 -- TALER is free software; you can redistribute it and/or modify it under the 6 -- terms of the GNU General Public License as published by the Free Software 7 -- Foundation; either version 3, or (at your option) any later version. 8 -- 9 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 -- A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 -- 13 -- You should have received a copy of the GNU General Public License along with 14 -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 -- 16 17 CREATE OR REPLACE FUNCTION comment_partitioned_table( 18 IN table_comment TEXT 19 ,IN table_name TEXT 20 ,IN partition_suffix TEXT DEFAULT NULL 21 ) 22 RETURNS VOID 23 LANGUAGE plpgsql 24 AS $$ 25 BEGIN 26 IF ( (partition_suffix IS NOT NULL) AND 27 (partition_suffix::int > 0) ) 28 THEN 29 -- sharding, add shard name 30 table_name=table_name || '_' || partition_suffix; 31 END IF; 32 EXECUTE FORMAT( 33 'COMMENT ON TABLE %s IS %s' 34 ,table_name 35 ,quote_literal(table_comment) 36 ); 37 END $$; 38 39 COMMENT ON FUNCTION comment_partitioned_table 40 IS 'Generic function to create a comment on table that is partitioned.';