aboutsummaryrefslogtreecommitdiff
path: root/src/mintdb
diff options
context:
space:
mode:
authorSree Harsha Totakura <sreeharsha@totakura.in>2015-08-17 10:30:45 +0200
committerSree Harsha Totakura <sreeharsha@totakura.in>2015-08-17 10:30:45 +0200
commit8e6f121a68c00cb6bdf9d160164684446af6d6c2 (patch)
tree24c9e045897bb84cb53748b3afe574635fce2e92 /src/mintdb
parent767e2f18f19bf5106ffaf9cc5c5cf053aaca6cea (diff)
parent08c947a01f9e2048f7668cabac58a5938dc477f5 (diff)
Merge branch 'master' of git+ssh://taler.net/var/git/mint
Diffstat (limited to 'src/mintdb')
-rw-r--r--src/mintdb/plugin_mintdb_postgres.c115
1 files changed, 61 insertions, 54 deletions
diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c
index beb1efb3e..aaa1c9016 100644
--- a/src/mintdb/plugin_mintdb_postgres.c
+++ b/src/mintdb/plugin_mintdb_postgres.c
@@ -2648,33 +2648,36 @@ postgres_insert_refresh_commit_links (void *cls,
uint16_t num_links,
const struct TALER_RefreshCommitLinkP *links)
{
- // FIXME: check logic! links is array!
- struct TALER_PQ_QueryParam params[] = {
- TALER_PQ_query_param_auto_from_type (session_hash),
- TALER_PQ_query_param_auto_from_type (&links->transfer_pub),
- TALER_PQ_query_param_uint16 (&cnc_index),
- TALER_PQ_query_param_uint16 (&num_links),
- TALER_PQ_query_param_auto_from_type (&links->shared_secret_enc),
- TALER_PQ_query_param_end
- };
+ uint16_t i;
- PGresult *result = TALER_PQ_exec_prepared (session->conn,
- "insert_refresh_commit_link",
- params);
- if (PGRES_COMMAND_OK != PQresultStatus (result))
+ for (i=0;i<num_links;i++)
{
- BREAK_DB_ERR (result);
- PQclear (result);
- return GNUNET_SYSERR;
- }
+ struct TALER_PQ_QueryParam params[] = {
+ TALER_PQ_query_param_auto_from_type (session_hash),
+ TALER_PQ_query_param_auto_from_type (&links[i].transfer_pub),
+ TALER_PQ_query_param_uint16 (&cnc_index),
+ TALER_PQ_query_param_uint16 (&i),
+ TALER_PQ_query_param_auto_from_type (&links[i].shared_secret_enc),
+ TALER_PQ_query_param_end
+ };
- if (0 != strcmp ("1", PQcmdTuples (result)))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
+ PGresult *result = TALER_PQ_exec_prepared (session->conn,
+ "insert_refresh_commit_link",
+ params);
+ if (PGRES_COMMAND_OK != PQresultStatus (result))
+ {
+ BREAK_DB_ERR (result);
+ PQclear (result);
+ return GNUNET_SYSERR;
+ }
+
+ if (0 != strcmp ("1", PQcmdTuples (result)))
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ PQclear (result);
}
-
- PQclear (result);
return GNUNET_OK;
}
@@ -2701,46 +2704,50 @@ postgres_get_refresh_commit_links (void *cls,
uint16_t num_links,
struct TALER_RefreshCommitLinkP *links)
{
- // FIXME: check logic: was written for a single link!
- struct TALER_PQ_QueryParam params[] = {
- TALER_PQ_query_param_auto_from_type (session_hash),
- TALER_PQ_query_param_uint16 (&cnc_index),
- TALER_PQ_query_param_uint16 (&num_links),
- TALER_PQ_query_param_end
- };
- PGresult *result;
+ uint16_t i;
- result = TALER_PQ_exec_prepared (session->conn,
- "get_refresh_commit_link",
- params);
- if (PGRES_TUPLES_OK != PQresultStatus (result))
- {
- BREAK_DB_ERR (result);
- PQclear (result);
- return GNUNET_SYSERR;
- }
- if (0 == PQntuples (result))
+ for (i=0;i<num_links;i++)
{
- PQclear (result);
- return GNUNET_NO;
- }
- {
- struct TALER_PQ_ResultSpec rs[] = {
- TALER_PQ_result_spec_auto_from_type ("transfer_pub",
- &links->transfer_pub),
- TALER_PQ_result_spec_auto_from_type ("link_secret_enc",
- &links->shared_secret_enc),
- TALER_PQ_result_spec_end
+ struct TALER_PQ_QueryParam params[] = {
+ TALER_PQ_query_param_auto_from_type (session_hash),
+ TALER_PQ_query_param_uint16 (&cnc_index),
+ TALER_PQ_query_param_uint16 (&i),
+ TALER_PQ_query_param_end
};
+ PGresult *result;
- if (GNUNET_YES !=
- TALER_PQ_extract_result (result, rs, 0))
+ result = TALER_PQ_exec_prepared (session->conn,
+ "get_refresh_commit_link",
+ params);
+ if (PGRES_TUPLES_OK != PQresultStatus (result))
{
+ BREAK_DB_ERR (result);
PQclear (result);
return GNUNET_SYSERR;
}
+ if (0 == PQntuples (result))
+ {
+ PQclear (result);
+ return GNUNET_NO;
+ }
+ {
+ struct TALER_PQ_ResultSpec rs[] = {
+ TALER_PQ_result_spec_auto_from_type ("transfer_pub",
+ &links[i].transfer_pub),
+ TALER_PQ_result_spec_auto_from_type ("link_secret_enc",
+ &links[i].shared_secret_enc),
+ TALER_PQ_result_spec_end
+ };
+
+ if (GNUNET_YES !=
+ TALER_PQ_extract_result (result, rs, 0))
+ {
+ PQclear (result);
+ return GNUNET_SYSERR;
+ }
+ }
+ PQclear (result);
}
- PQclear (result);
return GNUNET_OK;
}