donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit f908dd8e4575e327a826d84c944e574dc34b184f
parent eb5cb1b5d38b270113eec295000534a444e0c54c
Author: Florian Dold <florian@dold.me>
Date:   Mon,  1 Jun 2026 17:37:54 +0200

donaudb: use proper meson target for SQL generation

Diffstat:
Asrc/donaudb/0002-preamble.sql | 33+++++++++++++++++++++++++++++++++
Dsrc/donaudb/Makefile.am | 131-------------------------------------------------------------------------------
Dsrc/donaudb/Makefile.sql | 19-------------------
Asrc/donaudb/amalgamate-sql.sh | 46++++++++++++++++++++++++++++++++++++++++++++++
Asrc/donaudb/commit.sql | 1+
Msrc/donaudb/meson.build | 51++++++++++++++++++++++++++++++++++++++-------------
Asrc/donaudb/procedures-preamble.sql | 19+++++++++++++++++++
7 files changed, 137 insertions(+), 163 deletions(-)

diff --git a/src/donaudb/0002-preamble.sql b/src/donaudb/0002-preamble.sql @@ -0,0 +1,33 @@ +-- +-- This file is part of TALER +-- Copyright (C) 2024 Taler Systems SA +-- +-- TALER is free software; you can redistribute it and/or modify it under the +-- terms of the GNU General Public License as published by the Free Software +-- Foundation; either version 3, or (at your option) any later version. +-- +-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +-- A PARTICULAR PURPOSE. See the GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License along with +-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +-- + +BEGIN; + +SELECT _v.register_patch('donau-0002', NULL, NULL); +SET search_path TO donau; + +CREATE DOMAIN gnunet_hashcode + AS BYTEA + CHECK(LENGTH(VALUE) = 32); + +CREATE TYPE taler_amount + AS + (val INT8 + ,frac INT4 + ); +COMMENT ON TYPE taler_amount + IS 'Stores an amount, fraction is in units of 1/100000000 of the base value'; + diff --git a/src/donaudb/Makefile.am b/src/donaudb/Makefile.am @@ -1,131 +0,0 @@ -# This Makefile.am is in the public domain -AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/include/donau-database -I$(top_srcdir)/src/pq/ $(POSTGRESQL_CPPFLAGS) - -if USE_COVERAGE - AM_CFLAGS = --coverage -O0 - XLIB = -lgcov -endif - -pkgcfgdir = $(prefix)/share/donau/config.d/ - -pkgcfg_DATA = \ - donaudb.conf \ - donaudb-postgres.conf - -sqldir = $(prefix)/share/donau/sql/ - -sqlinputs = \ - donau_do_*.sql \ - 0002-*.sql \ - donau-0002.sql \ - procedures.sql.in - -sql_DATA = \ - versioning.sql \ - donau-0001.sql \ - drop.sql \ - donau-0002.sql \ - procedures.sql - -BUILT_SOURCES = \ - drop.sql \ - donau-0001.sql \ - procedures.sql - -CLEANFILES = \ - donau-0002.sql - -procedures.sql: procedures.sql.in donau_do_*.sql - chmod +w $@ || true - gcc -E -P -undef - < procedures.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@ - chmod ugo-w $@ - -donau-0002.sql: donau-0002.sql.in 0002-*.sql - chmod +w $@ || true - gcc -E -P -undef - < donau-0002.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@ - chmod ugo-w $@ - -check_SCRIPTS = \ - test_idempotency.sh - -EXTRA_DIST = \ - donaudb.conf \ - donaudb-postgres.conf \ - test-donau-db-postgres.conf \ - $(sqlinputs) \ - $(sql_DATA) \ - $(check_SCRIPTS) \ - pg_template.h pg_template.c \ - pg_template.sh - -lib_LTLIBRARIES = \ - libdonaudb.la - -libdonaudb_la_SOURCES = \ - plugin_donaudb_postgres.c helper.h \ - preflight.c \ - commit.c \ - drop_tables.c \ - create_tables.c \ - event_listen.c \ - event_listen_cancel.c \ - event_notify.c \ - start.c \ - rollback.c \ - start_read_committed.c \ - start_read_only.c \ - insert_signing_key.c \ - lookup_signing_key.c \ - iterate_active_signing_keys.c \ - insert_donation_unit.c \ - iterate_donation_units.c \ - iterate_submitted_receipts.c \ - get_history.c \ - get_charities.c \ - insert_charity.c \ - update_charity.c \ - do_charity_delete.c \ - insert_history_entry.c \ - lookup_charity.c \ - lookup_issued_receipts.c \ - lookup_donation_unit_amount.c \ - insert_issued_receipt.c \ - insert_submitted_receipts.c -libdonaudb_la_LIBADD = \ - $(LTLIBINTL) \ - $(top_builddir)/src/pq/libdonaupq.la \ - $(top_builddir)/src/util/libdonauutil.la \ - -ltalerpq \ - -ltalerutil \ - -lgnunetpq \ - -lgnunetutil \ - -lpq \ - $(XLIB) -libdonaudb_la_LDFLAGS = \ - $(POSTGRESQL_LDFLAGS) \ - -version-info 1:0:0 \ - -no-undefined - -AM_TESTS_ENVIRONMENT=export DONAU_PREFIX=$${DONAU_PREFIX:-@libdir@};export PATH=$${DONAU_PREFIX:-@prefix@}/bin:$$PATH; -check_PROGRAMS = \ - test-donaudb-postgres - -TESTS = \ - $(check_SCRIPTS) \ - $(check_PROGRAMS) - -test_donaudb_postgres_SOURCES = \ - test_donaudb.c -test_donaudb_postgres_LDADD = \ - libdonaudb.la \ - $(top_builddir)/src/util/libdonauutil.la \ - -ljansson \ - -lgnunetjson \ - -lgnunetutil \ - -ltalerutil \ - -ltalerjson \ - -ltalerpq \ - $(XLIB) - -EXTRA_test_donaudb_postgres_DEPENDENCIES = \ - libdonaudb.la diff --git a/src/donaudb/Makefile.sql b/src/donaudb/Makefile.sql @@ -1,19 +0,0 @@ -procedures.sql: procedures.sql.in donau_do_*.sql - chmod +w $@ || true - gcc -E -P -undef - < procedures.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@ - chmod ugo-w $@ - -donau-0002.sql: donau-0002.sql.in 0002-*.sql - chmod +w $@ || true - gcc -E -P -undef - < donau-0002.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@ - chmod ugo-w $@ - - -CLEANFILES = \ - donau-0002.sql \ - procedures.sql - -all: ${CLEANFILES} - -clean: - rm ${CLEANFILES} diff --git a/src/donaudb/amalgamate-sql.sh b/src/donaudb/amalgamate-sql.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +# This file is part of TALER +# Copyright (C) 2026 Taler Systems SA +# +# TALER is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3, or (at your option) any later version. +# +# TALER is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + +set -eu + +if [ $# -lt 1 ]; then + echo "Usage: $0 SQLFILES..." >&2 + exit 1 +fi + +cat <<'EOF' +-- +-- This file is part of TALER +-- Copyright (C) 2014--2025 Taler Systems SA +-- +-- TALER is free software; you can redistribute it and/or modify it under the +-- terms of the GNU General Public License as published by the Free Software +-- Foundation; either version 3, or (at your option) any later version. +-- +-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +-- A PARTICULAR PURPOSE. See the GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License along with +-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +-- +EOF + +for x in $@; do + echo -- generated from $x + # Remove SQL comments and empty lines + cat $x | sed -e "s/--.*//" | awk 'NF' +done diff --git a/src/donaudb/commit.sql b/src/donaudb/commit.sql @@ -0,0 +1 @@ +COMMIT; diff --git a/src/donaudb/meson.build b/src/donaudb/meson.build @@ -4,24 +4,49 @@ install_data('donaudb.conf', 'donaudb-postgres.conf', install_dir: pkgcfgdir) sqldir = get_option('datadir') / 'donau' / 'sql' -# FIXME possibly provide this output in the tgz through dist script -run_command('make', '-f', 'Makefile.sql', 'all', check: true) - -sqlfiles = [ - 'drop.sql', - 'donau-0001.sql', - 'donau-0002.sql', - 'procedures.sql', - 'versioning.sql', +donau_0002 = [ + '0002-donation_units.sql', + '0002-donau_charities.sql', + '0002-donau_history.sql', + '0002-donau_receipts_issued.sql', + '0002-donau_receipts_submitted.sql', + '0002-donau_sign_keys.sql', + 'commit.sql', +] + +procedures_sql = [ + 'procedures-preamble.sql', + 'donau_do_amount_specific.sql', + 'donau_do_insert_submitted_receipts.sql', + 'donau_do_insert_issued_receipts.sql', + 'donau_do_insert_charity.sql', + 'commit.sql', +] + +generated_sql = [ + ['drop.sql', ['drop.sql']], + ['versioning.sql', ['versioning.sql']], + ['procedures.sql', procedures_sql], + ['donau-0001', ['donau-0001.sql']], + ['donau-0002', donau_0002], ] -install_data(sources: sqlfiles, install_dir: sqldir) -# This makes meson copy the files into the build directory for testing -foreach f : sqlfiles - configure_file(input: f, output: f, copy: true) +foreach g : generated_sql + custom_target( + 'gen-merchantdb-' + g[0], + input: g[1], + output: g[0], + capture: true, + command: ['./amalgamate-sql.sh', '@INPUT@'], + install: true, + install_dir: sqldir, + ) endforeach + + + test_idem = configure_file( input: 'test_idempotency.sh', output: 'test_idempotency.sh', diff --git a/src/donaudb/procedures-preamble.sql b/src/donaudb/procedures-preamble.sql @@ -0,0 +1,19 @@ +-- +-- This file is part of TALER +-- Copyright (C) 2024 Taler Systems SA +-- +-- TALER is free software; you can redistribute it and/or modify it under the +-- terms of the GNU General Public License as published by the Free Software +-- Foundation; either version 3, or (at your option) any later version. +-- +-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +-- A PARTICULAR PURPOSE. See the GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License along with +-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +-- + +BEGIN; + +SET search_path TO donau;