exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

exchange_do_comment_partitioned_column.sql (1372B)


      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_column(
     18    IN table_comment TEXT
     19   ,IN column_name TEXT
     20   ,IN table_name TEXT
     21   ,IN partition_suffix TEXT DEFAULT NULL
     22 )
     23 RETURNS VOID
     24 LANGUAGE plpgsql
     25 AS $$
     26 BEGIN
     27   IF ( (partition_suffix IS NOT NULL) AND
     28        (partition_suffix::int > 0) )
     29   THEN
     30     -- sharding, add shard name
     31     table_name=table_name || '_' || partition_suffix;
     32   END IF;
     33   EXECUTE FORMAT(
     34      'COMMENT ON COLUMN %s.%s IS %s'
     35     ,table_name
     36     ,column_name
     37     ,quote_literal(table_comment)
     38   );
     39 END $$;
     40 
     41 COMMENT ON FUNCTION comment_partitioned_column
     42   IS 'Generic function to create a comment on column of a table that is partitioned.';