summaryrefslogtreecommitdiff
path: root/src/backenddb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-07-11 17:49:27 +0200
committerChristian Grothoff <christian@grothoff.org>2022-07-11 17:49:27 +0200
commit9556d8323344461999151069fc6b71b308b483bc (patch)
tree389ac923a9508b55782f67cd3afdff1c38f9ae3b /src/backenddb
parentcc53025af7b9aec2f37bc07a411f1ae666430b8d (diff)
downloadmerchant-9556d8323344461999151069fc6b71b308b483bc.tar.gz
merchant-9556d8323344461999151069fc6b71b308b483bc.tar.bz2
merchant-9556d8323344461999151069fc6b71b308b483bc.zip
-misc bugfixes
Diffstat (limited to 'src/backenddb')
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c22
-rw-r--r--src/backenddb/test_merchantdb.c5
2 files changed, 19 insertions, 8 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index d7e35897..830a3182 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -824,13 +824,12 @@ postgres_insert_account (
const struct TALER_MERCHANTDB_AccountDetails *account_details)
{
struct PostgresClosure *pg = cls;
- uint8_t active = account_details->active;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (id),
GNUNET_PQ_query_param_auto_from_type (&account_details->h_wire),
GNUNET_PQ_query_param_auto_from_type (&account_details->salt),
GNUNET_PQ_query_param_string (account_details->payto_uri),
- GNUNET_PQ_query_param_auto_from_type (&active),
+ GNUNET_PQ_query_param_bool (account_details->active),
GNUNET_PQ_query_param_end
};
@@ -2088,6 +2087,7 @@ postgres_lookup_contract_terms (void *cls,
* @param instance_id instance's identifier
* @param order_id order_id used to store
* @param contract_terms contract terms to store
+ * @param[out] order_serial set to the serial of the order
* @return transaction status, #GNUNET_DB_STATUS_HARD_ERROR if @a contract_terms
* is malformed
*/
@@ -2095,7 +2095,8 @@ static enum GNUNET_DB_QueryStatus
postgres_insert_contract_terms (void *cls,
const char *instance_id,
const char *order_id,
- json_t *contract_terms)
+ json_t *contract_terms,
+ uint64_t *order_serial)
{
struct PostgresClosure *pg = cls;
struct GNUNET_TIME_Timestamp pay_deadline;
@@ -2148,10 +2149,16 @@ postgres_insert_contract_terms (void *cls,
: GNUNET_PQ_query_param_string (fulfillment_url),
GNUNET_PQ_query_param_end
};
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_uint64 ("order_serial",
+ order_serial),
+ GNUNET_PQ_result_spec_end
+ };
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "insert_contract_terms",
- params);
+ return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "insert_contract_terms",
+ params,
+ rs);
}
}
@@ -8105,7 +8112,8 @@ postgres_connect (void *cls)
" AND merchant_serial="
" (SELECT merchant_serial"
" FROM merchant_instances"
- " WHERE merchant_id=$1)",
+ " WHERE merchant_id=$1)"
+ " RETURNING order_serial",
7),
/* for postgres_update_contract_terms() */
GNUNET_PQ_make_prepare ("update_contract_terms",
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index de27af31..e5eb8890 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -1643,11 +1643,14 @@ test_insert_contract_terms (const struct InstanceData *instance,
const struct OrderData *order,
enum GNUNET_DB_QueryStatus expected_result)
{
+ uint64_t os;
+
TEST_COND_RET_ON_FAIL (expected_result ==
plugin->insert_contract_terms (plugin->cls,
instance->instance.id,
order->id,
- order->contract),
+ order->contract,
+ &os),
"Insert contract terms failed\n");
return 0;
}