summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/taler_pq_lib.h35
-rw-r--r--src/mintdb/plugin_mintdb_postgres.c10
-rw-r--r--src/pq/Makefile.am3
3 files changed, 26 insertions, 22 deletions
diff --git a/src/include/taler_pq_lib.h b/src/include/taler_pq_lib.h
index b826ae26a..d90b5f7aa 100644
--- a/src/include/taler_pq_lib.h
+++ b/src/include/taler_pq_lib.h
@@ -116,7 +116,8 @@ struct TALER_PQ_QueryParam
* @param x pointer to the query parameter to pass
* @param s number of bytes of @a x to use for the query
*/
-#define TALER_PQ_QUERY_PARAM_PTR_SIZED(x, s) { TALER_PQ_QF_FIXED_BLOB, (x), (s) }
+#define TALER_PQ_QUERY_PARAM_PTR_SIZED(x,s) { TALER_PQ_QF_FIXED_BLOB, (x), (s) }
+
/**
* Generate fixed-size query parameter with size determined
@@ -126,16 +127,17 @@ struct TALER_PQ_QueryParam
*/
#define TALER_PQ_QUERY_PARAM_PTR(x) { TALER_PQ_QF_VARSIZE_BLOB, x, sizeof (*(x)) }
+
/**
* Generate query parameter for a currency, consisting of the three
* components "value", "fraction" and "currency" in this order. The
* types must be a 64-bit integer, 32-bit integer and a
* TALER_CURRENCY_LEN-sized BLOB/VARCHAR respectively.
*
- * @param x pointer to the query parameter to pass, must be
- * a variable of type `struct TALER_AmountNBO`.
+ * @param x pointer to the query parameter to pass
*/
-#define TALER_PQ_QUERY_PARAM_AMOUNT_NBO(x) { TALER_PQ_QF_AMOUNT_NBO, &(x), sizeof (x) }
+struct TALER_PQ_QueryParam
+TALER_PQ_QUERY_PARAM_AMOUNT_NBO(const struct TALER_AmountNBO *x);
/**
@@ -144,39 +146,40 @@ struct TALER_PQ_QueryParam
* types must be a 64-bit integer, 32-bit integer and a
* TALER_CURRENCY_LEN-sized BLOB/VARCHAR respectively.
*
- * @param x pointer to the query parameter to pass, must be
- * a variable of type `struct TALER_Amount`.
+ * @param x pointer to the query parameter to pass
*/
-#define TALER_PQ_QUERY_PARAM_AMOUNT(x) { TALER_PQ_QF_AMOUNT, &(x), sizeof (x) }
+struct TALER_PQ_QueryParam
+TALER_PQ_QUERY_PARAM_AMOUNT(const struct TALER_Amount *x);
/**
* Generate query parameter for an RSA public key. The
* database must contain a BLOB type in the respective position.
*
- * @param x the query parameter to pass, must be
- * a variable of type `struct GNUNET_CRYPTO_rsa_PublicKey *`.
+ * @param x the query parameter to pass.
*/
-#define TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY(x) { TALER_PQ_QF_RSA_PUBLIC_KEY, (x), 0 }
+struct TALER_PQ_QueryParam
+TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY(const struct GNUNET_CRYPTO_rsa_PublicKey *x);
+
/**
* Generate query parameter for an RSA signature. The
* database must contain a BLOB type in the respective position.
*
- * @param x the query parameter to pass, must be
- * a variable of type `struct GNUNET_CRYPTO_rsa_Signature *`.
+ * @param x the query parameter to pass
*/
-#define TALER_PQ_QUERY_PARAM_RSA_SIGNATURE(x) { TALER_PQ_QF_RSA_SIGNATURE, (x), 0 }
+struct TALER_PQ_QueryParam
+TALER_PQ_QUERY_PARAM_RSA_SIGNATURE(const struct GNUNET_CRYPTO_rsa_Signature *x);
/**
* Generate query parameter for an absolute time value.
* The database must store a 64-bit integer.
*
- * @param x pointer to the query parameter to pass, must be
- * a variable of type `struct GNUNET_TIME_Absolute`.
+ * @param x pointer to the query parameter to pass
*/
-#define TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME(x) { TALER_PQ_QF_TIME_ABSOLUTE, &(x), sizeof (x) }
+struct TALER_PQ_QueryParam
+TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME(struct GNUNET_TIME_Absolute x);
/**
diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c
index 7b89673e2..b49995155 100644
--- a/src/mintdb/plugin_mintdb_postgres.c
+++ b/src/mintdb/plugin_mintdb_postgres.c
@@ -851,9 +851,9 @@ postgres_insert_denomination (void *cls,
TALER_PQ_QUERY_PARAM_PTR (&issue->expire_withdraw.abs_value_us__),
TALER_PQ_QUERY_PARAM_PTR (&issue->expire_spend.abs_value_us__),
TALER_PQ_QUERY_PARAM_PTR (&issue->expire_legal.abs_value_us__),
- TALER_PQ_QUERY_PARAM_AMOUNT_NBO (issue->value),
- TALER_PQ_QUERY_PARAM_AMOUNT_NBO (issue->fee_withdraw),
- TALER_PQ_QUERY_PARAM_AMOUNT_NBO (issue->fee_refresh),
+ TALER_PQ_QUERY_PARAM_AMOUNT_NBO (&issue->value),
+ TALER_PQ_QUERY_PARAM_AMOUNT_NBO (&issue->fee_withdraw),
+ TALER_PQ_QUERY_PARAM_AMOUNT_NBO (&issue->fee_refresh),
TALER_PQ_QUERY_PARAM_END
};
result = TALER_PQ_exec_prepared (session->conn,
@@ -947,7 +947,7 @@ postgres_reserves_update (void *cls,
return GNUNET_SYSERR;
struct TALER_PQ_QueryParam params[] = {
TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (reserve->expiry),
- TALER_PQ_QUERY_PARAM_AMOUNT (reserve->balance),
+ TALER_PQ_QUERY_PARAM_AMOUNT (&reserve->balance),
TALER_PQ_QUERY_PARAM_PTR (&reserve->pub),
TALER_PQ_QUERY_PARAM_END
};
@@ -1460,7 +1460,7 @@ postgres_insert_deposit (void *cls,
TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (deposit->coin.denom_pub.rsa_public_key),
TALER_PQ_QUERY_PARAM_RSA_SIGNATURE (deposit->coin.denom_sig.rsa_signature),
TALER_PQ_QUERY_PARAM_PTR (&deposit->transaction_id),
- TALER_PQ_QUERY_PARAM_AMOUNT (deposit->amount_with_fee),
+ TALER_PQ_QUERY_PARAM_AMOUNT (&deposit->amount_with_fee),
TALER_PQ_QUERY_PARAM_PTR (&deposit->merchant_pub),
TALER_PQ_QUERY_PARAM_PTR (&deposit->h_contract),
TALER_PQ_QUERY_PARAM_PTR (&deposit->h_wire),
diff --git a/src/pq/Makefile.am b/src/pq/Makefile.am
index 8a5399fb1..746094ce4 100644
--- a/src/pq/Makefile.am
+++ b/src/pq/Makefile.am
@@ -12,7 +12,8 @@ lib_LTLIBRARIES = \
libtalerpq.la
libtalerpq_la_SOURCES = \
- db_pq.c
+ db_pq.c \
+ pq_helper.c
libtalerpq_la_LIBADD = \
$(top_builddir)/src/util/libtalerutil.la \