commit cdfb53bf74be05729a86a433f7d7f2e73f8e2c7a
parent 47d23897ad8b81e4ea9e38ddc6c3f77d6e251bbf
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date: Thu, 8 Dec 2016 21:59:13 +0100
Fix prepared statement find_contract
Diffstat:
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
@@ -278,6 +278,13 @@ postgres_initialize (void *cls)
2);
PG_PREPARE (pg,
+ "find_contract",
+ "SELECT plain_contract FROM merchant_contract_maps"
+ " WHERE"
+ " h_contract=$1",
+ 1);
+
+ PG_PREPARE (pg,
"find_transactions_by_date",
"SELECT"
" transaction_id"
@@ -392,7 +399,7 @@ postgres_initialize (void *cls)
*/
static int
postgres_find_contract (void *cls,
- json_t *contract, /*Legal?*/
+ json_t *contract,
struct GNUNET_HashCode *h_contract)
{
struct PostgresClosure *pg = cls;
@@ -408,13 +415,16 @@ postgres_find_contract (void *cls,
"find_contract",
params);
i = PQntuples (result);
- if (1 > i)
+ if (1 < i)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Mupltiple contracts share the same hashcode.\n");
return GNUNET_SYSERR;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "i, %d\n", i);
+
if (0 == i)
return GNUNET_NO;
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
@@ -363,8 +363,8 @@ run (void *cls)
FAILIF (GNUNET_OK !=
plugin->find_contract (plugin->cls,
- &contract,
- &out));
+ out,
+ &h_contract));
FAILIF (GNUNET_OK !=
plugin->store_transaction (plugin->cls,