diff options
Diffstat (limited to 'src/backenddb')
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 831c676a..8e466b70 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -1116,6 +1116,45 @@ postgres_lookup_order (void *cls, /** + * Retrieve order summary given its @a order_id and the @a instance_id. + * + * @param cls closure + * @param instance_id instance to obtain order of + * @param order_id order id used to perform the lookup + * @param[out] timestamp when was the order created + * @param[out] order_serial under which serial do we keep this order + * @return transaction status + */ +static enum GNUNET_DB_QueryStatus +postgres_lookup_order_summary (void *cls, + const char *instance_id, + const char *order_id, + struct GNUNET_TIME_Absolute *timestamp, + uint64_t *order_serial) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_string (instance_id), + GNUNET_PQ_query_param_string (order_id), + GNUNET_PQ_query_param_end + }; + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("order_serial", + order_serial), + GNUNET_PQ_result_spec_absolute_time ("creation_time", + timestamp), + GNUNET_PQ_result_spec_end + }; + + check_connection (pg); + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, + "lookup_order_summary", + params, + rs); +} + + +/** * Context used for postgres_lookup_orders(). */ struct LookupOrdersContext @@ -6052,6 +6091,18 @@ libtaler_plugin_merchantdb_postgres_init (void *cls) " WHERE merchant_id=$1)" " AND merchant_orders.order_id=$2", 2), + /* for postgres_lookup_order_summary() */ + GNUNET_PQ_make_prepare ("lookup_order_summary", + "SELECT" + " creation_time" + ",order_serial" + " FROM merchant_orders" + " WHERE merchant_orders.merchant_serial=" + " (SELECT merchant_serial " + " FROM merchant_instances" + " WHERE merchant_id=$1)" + " AND merchant_orders.order_id=$2", + 2), /* for postgres_lookup_orders() */ GNUNET_PQ_make_prepare ("lookup_orders_inc", "(SELECT" @@ -8157,6 +8208,7 @@ libtaler_plugin_merchantdb_postgres_init (void *cls) plugin->lock_product = &postgres_lock_product; plugin->delete_order = &postgres_delete_order; plugin->lookup_order = &postgres_lookup_order; + plugin->lookup_order_summary = &postgres_lookup_order_summary; plugin->lookup_orders = &postgres_lookup_orders; plugin->insert_order = &postgres_insert_order; plugin->unlock_inventory = &postgres_unlock_inventory; |