summaryrefslogtreecommitdiff
path: root/src/backenddb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-06-28 11:04:48 +0200
committerChristian Grothoff <christian@grothoff.org>2020-06-28 11:04:48 +0200
commita118bd2c4951fa7b60737e3cca69e62266a1bcef (patch)
tree884a01b4b341c6db9a846bdf5eea8085b475dfdf /src/backenddb
parentc7465ea592f0cd34d259e3f94227e3320f62208a (diff)
downloadmerchant-a118bd2c4951fa7b60737e3cca69e62266a1bcef.tar.gz
merchant-a118bd2c4951fa7b60737e3cca69e62266a1bcef.tar.bz2
merchant-a118bd2c4951fa7b60737e3cca69e62266a1bcef.zip
deduplicate logic
Diffstat (limited to 'src/backenddb')
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c44
1 files changed, 15 insertions, 29 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 54d99d66..ae566021 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -1449,36 +1449,22 @@ postgres_lookup_contract_terms (void *cls,
GNUNET_PQ_query_param_string (order_id),
GNUNET_PQ_query_param_end
};
- check_connection (pg);
- if (NULL == contract_terms)
- {
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("order_serial",
- order_serial),
- GNUNET_PQ_result_spec_end
- };
-
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "lookup_contract_terms",
- params,
- rs);
- }
- else
- {
- struct GNUNET_PQ_ResultSpec rs[] = {
- TALER_PQ_result_spec_json ("contract_terms",
- contract_terms),
- GNUNET_PQ_result_spec_uint64 ("order_serial",
- order_serial),
- GNUNET_PQ_result_spec_end
- };
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ /* contract_terms must be first! */
+ TALER_PQ_result_spec_json ("contract_terms",
+ contract_terms),
+ GNUNET_PQ_result_spec_uint64 ("order_serial",
+ order_serial),
+ GNUNET_PQ_result_spec_end
+ };
- *contract_terms = NULL;
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "lookup_contract_terms",
- params,
- rs);
- }
+ check_connection (pg);
+ return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "lookup_contract_terms",
+ params,
+ (NULL != contract_terms)
+ ? rs
+ : &rs[1]);
}