[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-donau] branch master updated: [db] fix errors
From: |
gnunet |
Subject: |
[taler-donau] branch master updated: [db] fix errors |
Date: |
Sat, 06 Jan 2024 21:22:30 +0100 |
This is an automated email from the git hooks/post-receive script.
johannes-casaburi pushed a commit to branch master
in repository donau.
The following commit(s) were added to refs/heads/master by this push:
new 0ee91a6 [db] fix errors
0ee91a6 is described below
commit 0ee91a6af04d318c43520bfc062154c9b58c039f
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
AuthorDate: Sat Jan 6 21:21:54 2024 +0100
[db] fix errors
---
src/donaudb/0002-donation_units.sql | 2 +-
src/donaudb/Makefile.am | 25 +++++++-
src/donaudb/pg_activate_signing_key.c | 2 +-
src/donaudb/pg_activate_signing_key.h | 2 +-
src/donaudb/pg_add_donation_unit_key.c | 9 +--
src/donaudb/pg_add_donation_unit_key.h | 3 +-
src/donaudb/pg_get_charities.c | 2 +-
src/donaudb/pg_get_donation_unit_info.c | 67 ----------------------
src/donaudb/pg_get_donation_unit_info.h | 41 -------------
src/donaudb/pg_helper.h | 65 +++++++++++----------
src/donaudb/pg_lookup_charity.c | 3 +-
src/donaudb/pg_lookup_charity.h | 4 +-
...nation_unit_key.c => pg_lookup_donation_unit.c} | 9 +--
...nation_unit_key.h => pg_lookup_donation_unit.h} | 0
src/donaudb/pg_lookup_signing_key.c | 2 +-
src/donaudb/pg_lookup_signing_key.h | 2 +-
src/include/donau_service.h | 10 ++--
src/util/donau_signatures.c | 2 +-
18 files changed, 85 insertions(+), 165 deletions(-)
diff --git a/src/donaudb/0002-donation_units.sql
b/src/donaudb/0002-donation_units.sql
index 7d4b30a..06da924 100644
--- a/src/donaudb/0002-donation_units.sql
+++ b/src/donaudb/0002-donation_units.sql
@@ -16,7 +16,7 @@
CREATE TABLE donation_units
(donation_unit_serial BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
- ,donation_unit_pub_hash BYTEA PRIMARY KEY CHECK
(LENGTH(donation_unit_pub_hash)=64)
+ ,donation_unit_hash BYTEA PRIMARY KEY CHECK (LENGTH(donation_unit_hash)=64)
,donation_unit_pub BYTEA NOT NULL
,validity_year INT4 NOT NULL
,donation_unit taler_amount NOT NULL
diff --git a/src/donaudb/Makefile.am b/src/donaudb/Makefile.am
index f940b21..79a90c0 100644
--- a/src/donaudb/Makefile.am
+++ b/src/donaudb/Makefile.am
@@ -57,8 +57,31 @@ plugin_LTLIBRARIES = \
libtaler_plugin_donaudb_postgres.la
endif
+
libtaler_plugin_donaudb_postgres_la_SOURCES = \
- plugin_donaudb_postgres.c pg_helper.h
+ plugin_donaudb_postgres.c pg_helper.h \
+ pg_preflight.h pg_preflight.c \
+ pg_commit.h pg_commit.c \
+ pg_drop_tables.h pg_drop_tables.c \
+ pg_create_tables.h pg_create_tables.c \
+ pg_event_listen.h pg_event_listen.c \
+ pg_event_listen_cancel.h pg_event_listen_cancel.c \
+ pg_event_notify.h pg_event_notify.c \
+ pg_start.h pg_start.c \
+ pg_rollback.h pg_rollback.c \
+ pg_start_read_committed.h pg_start_read_committed.c \
+ pg_start_read_only.h pg_start_read_only.c \
+ pg_activate_signing_key.c pg_activate_signing_key.h \
+ pg_lookup_signing_key.h pg_lookup_signing_key.c \
+ pg_add_donation_unit_key.c pg_add_donation_unit_key.h \
+ pg_lookup_donation_unit.c pg_lookup_donation_unit.h \
+ #pg_get_charities.h pg_get_charities.c \
+ pg_insert_charity.h pg_insert_charity.c \
+ pg_lookup_charity.h pg_lookup_charity.c \
+ pg_insert_history_entry.h pg_insert_history_entry.c \
+ pg_insert_issued_receipts.h pg_insert_issued_receipts.c \
+ pg_insert_submitted_receipts.h pg_insert_submitted_receipts.c
+
libtaler_plugin_donaudb_postgres_la_LIBADD = \
$(LTLIBINTL)
libtaler_plugin_donaudb_postgres_la_LDFLAGS = \
diff --git a/src/donaudb/pg_activate_signing_key.c
b/src/donaudb/pg_activate_signing_key.c
index d8707c9..98b1b80 100644
--- a/src/donaudb/pg_activate_signing_key.c
+++ b/src/donaudb/pg_activate_signing_key.c
@@ -28,7 +28,7 @@
enum GNUNET_DB_QueryStatus
DH_PG_activate_signing_key (
void *cls,
- const struct DONAU_EddsaPublicKeyP *donau_pub,
+ const struct DONAU_DonauPublicKeyP *donau_pub,
const struct DONAUDB_SignkeyMetaData *meta)
{
struct PostgresClosure *pg = cls;
diff --git a/src/donaudb/pg_activate_signing_key.h
b/src/donaudb/pg_activate_signing_key.h
index 370f09e..5a44ebf 100644
--- a/src/donaudb/pg_activate_signing_key.h
+++ b/src/donaudb/pg_activate_signing_key.h
@@ -36,7 +36,7 @@
enum GNUNET_DB_QueryStatus
DH_PG_activate_signing_key (
void *cls,
- const struct DONAU_EddsaPublicKeyP *donau_pub,
+ const struct DONAU_DonauPublicKeyP *donau_pub,
const struct DONAUDB_SignkeyMetaData *meta);
#endif
diff --git a/src/donaudb/pg_add_donation_unit_key.c
b/src/donaudb/pg_add_donation_unit_key.c
index 5fd7ba9..6a120a4 100644
--- a/src/donaudb/pg_add_donation_unit_key.c
+++ b/src/donaudb/pg_add_donation_unit_key.c
@@ -34,17 +34,18 @@ DH_PG_add_donation_unit_key (
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam iparams[] = {
- GNUNET_PQ_query_param_auto_from_type (&meta->donation_unit_pub_hash),
- TALER_PQ_query_param_donation_unit_pub (donation_unit_pub),
+ GNUNET_PQ_query_param_auto_from_type (&meta->donation_unit_hash),
+ GNUNET_PQ_query_param_auto_from_type (donation_unit_pub),
GNUNET_PQ_query_param_uint64 (&meta->validity_year),
- TALER_PQ_query_param_amount (&meta->value),
+ TALER_PQ_query_param_amount (pg->conn,
+ &meta->value),
GNUNET_PQ_query_param_end
};
PREPARE (pg,
"donation_unit_insert",
"INSERT INTO donation_units "
- "(donation_unit_pub_hash"
+ "(donation_unit_hash"
",donation_unit_pub"
",validity_year"
",taler_amount"
diff --git a/src/donaudb/pg_add_donation_unit_key.h
b/src/donaudb/pg_add_donation_unit_key.h
index b05208f..26b3812 100644
--- a/src/donaudb/pg_add_donation_unit_key.h
+++ b/src/donaudb/pg_add_donation_unit_key.h
@@ -37,5 +37,6 @@ enum GNUNET_DB_QueryStatus
DH_PG_add_donation_unit_key (
void *cls,
const struct DONAU_DonationUnitPublicKey *donation_unit_pub,
- const struct DONAUDB_DonationUnitKeyMetaInfo *meta)
+ const struct DONAUDB_DonationUnitKeyMetaData *meta);
+
#endif
diff --git a/src/donaudb/pg_get_charities.c b/src/donaudb/pg_get_charities.c
index 54dc1fa..fb1b51a 100644
--- a/src/donaudb/pg_get_charities.c
+++ b/src/donaudb/pg_get_charities.c
@@ -99,7 +99,7 @@ DH_PG_get_charities (void *cls,
void *cb_cls)
{
struct PostgresClosure *pg = cls;
- struct GetWireAccountsContext ctx = {
+ struct GetCharitiesContext ctx = {
.cb = cb,
.cb_cls = cb_cls,
.status = GNUNET_OK
diff --git a/src/donaudb/pg_get_donation_unit_info.c
b/src/donaudb/pg_get_donation_unit_info.c
deleted file mode 100644
index 3cb59c7..0000000
--- a/src/donaudb/pg_get_donation_unit_info.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2023 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 CHARITYABILITY 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/>
- */
-/**
- * @file donaudb/pg_get_donation_unit_info.c
- * @brief Implementation of the get_donation_unit_info function for Postgres
- * @author Johannes Casaburi
- */
-#include "taler/platform.h"
-#include "taler/taler_error_codes.h"
-#include "taler/taler_dbevents.h"
-#include "taler/taler_pq_lib.h"
-#include "pg_get_donation_unit_info.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-DH_PG_get_donation_unit_info (
- void *cls,
- const struct DONAU_DonationUnitHashP *donation_unit_pub_hash,
- struct DONAUDB_DonationUnitKeyMetaData *meta)
-{
- struct PostgresClosure *pg = cls;
- enum GNUNET_DB_QueryStatus qs;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_auto_from_type ("donation_unit_pub",
- &meta->donation_unit_pub),
- TALER_PQ_RESULT_SPEC_AMOUNT ("value",
- &meta->donation_unit),
- GNUNET_PQ_result_spec_uint32 ("validity_year",
- &meta->validity_year),
- GNUNET_PQ_result_spec_end
- };
-
- PREPARE (pg,
- "donation_unit_get",
- "SELECT"
- ",donation_unit_pub"
- ",validity_year"
- ",value"
- " FROM donation_units"
- " WHERE donation_unit_pub_hash=$1;");
- qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "donation_unit_get",
- params,
- rs);
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
- return qs;
- meta->donation_unit_hash = *donation_unit_pub_hash;
- return qs;
-}
diff --git a/src/donaudb/pg_get_donation_unit_info.h
b/src/donaudb/pg_get_donation_unit_info.h
deleted file mode 100644
index 842ac1b..0000000
--- a/src/donaudb/pg_get_donation_unit_info.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 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 CHARITYABILITY 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/>
- */
-/**
- * @file donaudb/pg_get_donation_unit_info.h
- * @brief implementation of the get_donation_unit_info function for Postgres
- * @author Johannes Casaburi
- */
-#ifndef PG_GET_DONATION_UNIT_INFO_H
-#define PG_GET_DONATION_UNIT_INFO_H
-
-#include <taler/taler_util.h>
-#include "taler/taler_json_lib.h"
-#include "donaudb_plugin.h"
-/**
- * Fetch information about a donation unit key.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param donation_unit_pub_hash hash of the public key
- * @param[out] info information with value and other info about the coin
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-DH_PG_get_donation_unit_info (
- void *cls,
- const struct DONAU_DonationUnitHashP *donation_unit_pub_hash,
- struct DONAUDB_DonationUnitKeyMetaData *meta);
-
-#endif
diff --git a/src/donaudb/pg_helper.h b/src/donaudb/pg_helper.h
index b17be81..03cd852 100644
--- a/src/donaudb/pg_helper.h
+++ b/src/donaudb/pg_helper.h
@@ -60,6 +60,11 @@ struct PostgresClosure
*/
unsigned long long prep_gen;
+ /**
+ * Name of the current transaction, for debugging.
+ */
+ const char *transaction_name;
+
};
@@ -73,37 +78,37 @@ struct PostgresClosure
* @param sql actual SQL text
*/
#define PREPARE(pg,name,sql) \
- do { \
- static struct { \
- unsigned long long cnt; \
- struct PostgresClosure *pg; \
- } preps[2]; /* 2 ctrs for taler-auditor-sync*/ \
- unsigned int off = 0; \
+ do { \
+ static struct { \
+ unsigned long long cnt; \
+ struct PostgresClosure *pg; \
+ } preps[2]; /* 2 ctrs for taler-auditor-sync*/ \
+ unsigned int off = 0; \
\
- while ( (NULL != preps[off].pg) && \
- (pg != preps[off].pg) && \
- (off < sizeof(preps) / sizeof(*preps)) ) \
- off++; \
- GNUNET_assert (off < \
- sizeof(preps) / sizeof(*preps)); \
- if (preps[off].cnt < pg->prep_gen) \
- { \
- struct GNUNET_PQ_PreparedStatement ps[] = { \
- GNUNET_PQ_make_prepare (name, sql), \
- GNUNET_PQ_PREPARED_STATEMENT_END \
- }; \
+ while ( (NULL != preps[off].pg) && \
+ (pg != preps[off].pg) && \
+ (off < sizeof(preps) / sizeof(*preps)) ) \
+ off++; \
+ GNUNET_assert (off < \
+ sizeof(preps) / sizeof(*preps)); \
+ if (preps[off].cnt < pg->prep_gen) \
+ { \
+ struct GNUNET_PQ_PreparedStatement ps[] = { \
+ GNUNET_PQ_make_prepare (name, sql), \
+ GNUNET_PQ_PREPARED_STATEMENT_END \
+ }; \
\
- if (GNUNET_OK != \
- GNUNET_PQ_prepare_statements (pg->conn, \
- ps)) \
- { \
- GNUNET_break (0); \
- return GNUNET_DB_STATUS_HARD_ERROR; \
- } \
- preps[off].pg = pg; \
- preps[off].cnt = pg->prep_gen; \
- } \
- } while (0)
+ if (GNUNET_OK != \
+ GNUNET_PQ_prepare_statements (pg->conn, \
+ ps)) \
+ { \
+ GNUNET_break (0); \
+ return GNUNET_DB_STATUS_HARD_ERROR; \
+ } \
+ preps[off].pg = pg; \
+ preps[off].cnt = pg->prep_gen; \
+ } \
+ } while (0)
/**
@@ -115,7 +120,7 @@ struct PostgresClosure
*/
#define TALER_PQ_RESULT_SPEC_AMOUNT(field, \
amountp) TALER_PQ_result_spec_amount ( \
- field,pg->currency,amountp)
+ field,pg->currency,amountp)
#endif
diff --git a/src/donaudb/pg_lookup_charity.c b/src/donaudb/pg_lookup_charity.c
index 94f2258..7b3a62b 100644
--- a/src/donaudb/pg_lookup_charity.c
+++ b/src/donaudb/pg_lookup_charity.c
@@ -28,6 +28,7 @@
enum GNUNET_DB_QueryStatus
DH_PG_lookup_charity (
void *cls,
+ unsigned long long charity_id,
struct DONAUDB_CharityMetaData *meta)
{
struct PostgresClosure *pg = cls;
@@ -37,7 +38,7 @@ DH_PG_lookup_charity (
};
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_query_param_string ("charity_url",
- &meta->charity_url),
+ &meta->charity_url),
GNUNET_PQ_query_param_string ("charity_name",
&meta->charity_name),
GNUNET_PQ_result_spec_end
diff --git a/src/donaudb/pg_lookup_charity.h b/src/donaudb/pg_lookup_charity.h
index 7c10277..3b8de5a 100644
--- a/src/donaudb/pg_lookup_charity.h
+++ b/src/donaudb/pg_lookup_charity.h
@@ -28,13 +28,13 @@
* Fetch information about a donation unit key.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param donation_unit_pub_hash hash of the public key
* @param[out] info information with value and other info about the coin
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
DH_PG_lookup_charity (
void *cls,
- struct DONAUDB_CharityMetaData *meta);
+ unsigned long long charity_id,
+ const struct DONAUDB_CharityMetaData *meta);
#endif
diff --git a/src/donaudb/pg_lookup_donation_unit_key.c
b/src/donaudb/pg_lookup_donation_unit.c
similarity index 86%
rename from src/donaudb/pg_lookup_donation_unit_key.c
rename to src/donaudb/pg_lookup_donation_unit.c
index a223853..d6ae644 100644
--- a/src/donaudb/pg_lookup_donation_unit_key.c
+++ b/src/donaudb/pg_lookup_donation_unit.c
@@ -22,7 +22,7 @@
#include "taler/taler_error_codes.h"
#include "taler/taler_dbevents.h"
#include "taler/taler_pq_lib.h"
-#include "pg_lookup_donation_unit_key.h"
+#include "pg_lookup_donation_unit.h"
#include "pg_helper.h"
enum GNUNET_DB_QueryStatus
@@ -37,9 +37,7 @@ DH_PG_lookup_donation_unit_key (
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_auto_from_type ("donation_unit_pub",
- &meta->donation_unit_pub),
- GNUNET_PQ_query_param_uint64 ("validity_year",
+ GNUNET_PQ_result_spec_uint64 ("validity_year",
&meta->validity_year),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
&meta->value),
@@ -49,11 +47,10 @@ DH_PG_lookup_donation_unit_key (
PREPARE (pg,
"lookup_donation_unit_key",
"SELECT"
- ",donation_unit_pub"
" validity_year"
",amount"
" FROM donation_units"
- " WHERE donation_unit_pub_hash=$1;");
+ " WHERE donation_unit_hash=$1;");
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"lookup_donation_unit_key",
params,
diff --git a/src/donaudb/pg_lookup_donation_unit_key.h
b/src/donaudb/pg_lookup_donation_unit.h
similarity index 100%
rename from src/donaudb/pg_lookup_donation_unit_key.h
rename to src/donaudb/pg_lookup_donation_unit.h
diff --git a/src/donaudb/pg_lookup_signing_key.c
b/src/donaudb/pg_lookup_signing_key.c
index 7153158..a8882ab 100644
--- a/src/donaudb/pg_lookup_signing_key.c
+++ b/src/donaudb/pg_lookup_signing_key.c
@@ -29,7 +29,7 @@
enum GNUNET_DB_QueryStatus
DH_PG_lookup_signing_key (
void *cls,
- const struct DONAU_EddsaPublicKeyP *donau_pub,
+ const struct DONAU_DonauPublicKeyP *donau_pub,
struct DONAUDB_SignkeyMetaData *meta)
{
struct PostgresClosure *pg = cls;
diff --git a/src/donaudb/pg_lookup_signing_key.h
b/src/donaudb/pg_lookup_signing_key.h
index 613a43d..eb5e12e 100644
--- a/src/donaudb/pg_lookup_signing_key.h
+++ b/src/donaudb/pg_lookup_signing_key.h
@@ -37,7 +37,7 @@
enum GNUNET_DB_QueryStatus
DH_PG_lookup_signing_key (
void *cls,
- const struct DONAU_EddsaPublicKeyP *donau_pub,
+ const struct DONAU_DonauPublicKeyP *donau_pub,
struct DONAUDB_SignkeyMetaData *meta);
#endif
diff --git a/src/include/donau_service.h b/src/include/donau_service.h
index e6a3c17..3d65a03 100644
--- a/src/include/donau_service.h
+++ b/src/include/donau_service.h
@@ -42,7 +42,7 @@ struct DONAU_SigningPublicKeyAndValidity
/**
* The signing public key
*/
- struct DONAU_EddsaPublicKeyP key;
+ struct DONAU_DonauPublicKeyP key;
/**
* Tax year this key is valid for.
@@ -311,7 +311,7 @@ struct DONAU_GetKeysHandle *
DONAU_get_keys (
struct GNUNET_CURL_Context *ctx,
const char *url,
- //struct DONAU_Keys *last_keys, -> temporarily removed
+ // struct DONAU_Keys *last_keys, -> temporarily removed
DONAU_GetKeysCallback cert_cb,
void *cert_cb_cls);
@@ -379,7 +379,7 @@ enum GNUNET_GenericReturnValue
DONAU_test_signing_key (
const struct DONAU_Keys *keys,
const unsigned int year,
- const struct DONAU_EddsaPublicKeyP *pub);
+ const struct DONAU_DonauPublicKeyP *pub);
/**
@@ -421,7 +421,7 @@ DONAU_get_donation_unit_key_by_hash (
const struct DONAU_SigningPublicKeyAndValidity *
DONAU_get_signing_key_info (
const struct DONAU_Keys *keys,
- const struct DONAU_EddsaPublicKeyP *donau_pub);
+ const struct DONAU_DonauPublicKeyP *donau_pub);
/* ********************* POST / issue receipt *********************** */
@@ -1057,7 +1057,7 @@ struct DONAU_CharityRequest
/**
* public key of the charity
*/
- struct DONAU_EddsaPublicKeyP charity_pub;
+ struct DONAU_DonauPublicKeyP charity_pub;
};
/**
diff --git a/src/util/donau_signatures.c b/src/util/donau_signatures.c
index 57e0560..dfe725b 100644
--- a/src/util/donau_signatures.c
+++ b/src/util/donau_signatures.c
@@ -35,7 +35,7 @@ struct DONAU_DonationStatementConfirmationPS
{
/**
* Purpose must be #DONAU_SIGNATURE_DONAU_DONATION_STATEMENT. Signed
- * by a `struct DONAU_EddsaPublicKeyP` using EdDSA.
+ * by a `struct DONAU_DonauPublicKeyP` using EdDSA.
*/
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-donau] branch master updated: [db] fix errors,
gnunet <=