commit 354c630648c5f86310718eaaabe224595bd4cb38
parent f811e37f7dcd93137b8c96323a0f48c0536a2d19
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 17 Apr 2024 11:57:45 +0200
-misc fixes
Diffstat:
5 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/src/donau/donau-httpd_batch-submit.c b/src/donau/donau-httpd_batch-submit.c
@@ -163,7 +163,15 @@ DH_handler_submit_receipts_post (struct DH_RequestContext *rc,
const size_t num_dr = json_array_size (donation_receipts);
struct DONAU_DonationReceipt *dr_arr;
- if (0 != num_dr)
+ if (0 == num_dr)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Empty array of donation receipts!\n");
+ return TALER_MHD_reply_with_error (rc->connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_GENERIC_PARAMETER_MALFORMED,
+ "donation_receipts");
+ }
{
json_t *dr_obj;
size_t index;
@@ -184,15 +192,6 @@ DH_handler_submit_receipts_post (struct DH_RequestContext *rc,
}
}
}
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Empty array of donation receipts!\n");
- return TALER_MHD_reply_with_error (rc->connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "donation_receipts");
- }
for (size_t i = 0; i < num_dr; i++)
{
diff --git a/src/donaudb/donau-0001.sql b/src/donaudb/donau-0001.sql
@@ -49,8 +49,7 @@ COMMENT ON COLUMN donau_tables.finished
-- Main DB setup loop
---------------------------------------------------------------------------
-CREATE FUNCTION do_create_tables()
- RETURNS VOID
+CREATE PROCEDURE do_create_tables()
LANGUAGE plpgsql
AS $$
DECLARE
@@ -106,7 +105,7 @@ BEGIN
END LOOP; -- create/alter/drop actions
END $$;
-COMMENT ON FUNCTION do_create_tables
+COMMENT ON PROCEDURE do_create_tables
IS 'Creates all tables for the given number of partitions that need creating. Does NOT support sharding.';
diff --git a/src/donaudb/pg_create_tables.c b/src/donaudb/pg_create_tables.c
@@ -39,7 +39,7 @@ DH_PG_create_tables (void *cls)
struct GNUNET_PQ_PreparedStatement ps[] = {
GNUNET_PQ_make_prepare ("create_tables",
- "SELECT"
+ "CALL"
" donau.do_create_tables"
" ();"),
GNUNET_PQ_PREPARED_STATEMENT_END
@@ -56,15 +56,29 @@ DH_PG_create_tables (void *cls)
es,
ps);
if (NULL == conn)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to connect to database\n");
return GNUNET_SYSERR;
+ }
if (0 >
GNUNET_PQ_eval_prepared_non_select (conn,
"create_tables",
params))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to create tables\n");
ret = GNUNET_SYSERR;
+ }
if (GNUNET_OK == ret)
+ {
ret = GNUNET_PQ_exec_sql (conn,
"procedures");
+ if (GNUNET_OK != ret)
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to load stored procedures: %d\n",
+ ret);
+ }
GNUNET_PQ_disconnect (conn);
return ret;
}
diff --git a/src/donaudb/test_donaudb.c b/src/donaudb/test_donaudb.c
@@ -100,6 +100,8 @@ run (void *cls)
if (NULL ==
(plugin = DONAUDB_plugin_load (cfg)))
{
+ fprintf (stderr,
+ "Failed to load DB plugin\n");
result = 77;
return;
}
diff --git a/src/util/donau_os_installation.c b/src/util/donau_os_installation.c
@@ -24,6 +24,7 @@
* @author Lukas Matyja
*/
#include <taler/platform.h>
+#include <taler/taler_util.h>
#include <gnunet/gnunet_util_lib.h>
@@ -64,6 +65,7 @@ DONAU_project_data_default (void)
void __attribute__ ((constructor))
DONAU_OS_init ()
{
+ GNUNET_OS_init (TALER_project_data_default ());
GNUNET_OS_init (&donau_pd);
}