summaryrefslogtreecommitdiff
path: root/src/backenddb/plugin_merchantdb_postgres.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backenddb/plugin_merchantdb_postgres.c')
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 84c3827e..b5a75222 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -1114,13 +1114,16 @@ postgres_update_product (void *cls,
TALER_PQ_query_param_amount (&pd->price), /* $8+$9 */
GNUNET_PQ_query_param_uint64 (&pd->total_stock), /* $10 */
GNUNET_PQ_query_param_uint64 (&pd->total_lost),
- GNUNET_PQ_query_param_uint64 (&pd->total_sold),
TALER_PQ_query_param_json (pd->address),
GNUNET_PQ_query_param_absolute_time (&pd->next_restock),
GNUNET_PQ_query_param_end
};
- GNUNET_assert (pd->total_stock >= pd->total_lost + pd->total_sold);
+ if (pd->total_stock < pd->total_lost + pd->total_sold)
+ {
+ GNUNET_break (0);
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ }
check_connection (pg);
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"update_product",
@@ -6319,18 +6322,16 @@ postgres_connect (void *cls)
",price_frac=$9"
",total_stock=$10"
",total_lost=$11"
- ",total_sold=$12"
- ",address=$13"
- ",next_restock=$14"
+ ",address=$12"
+ ",next_restock=$13"
" WHERE merchant_serial="
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)"
" AND product_id=$2"
" AND total_stock <= $10"
- " AND total_sold <= $12"
" AND total_lost <= $11",
- 14),
+ 13),
/* for postgres_lock_product() */
GNUNET_PQ_make_prepare ("lock_product",