[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] 03/03: -do not update total_sold when patching product,
From: |
gnunet |
Subject: |
[taler-merchant] 03/03: -do not update total_sold when patching product, not provided as an argument, breaks invariants |
Date: |
Wed, 21 Apr 2021 01:01:51 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
commit cd5a980318d467206d30958073fa34fbb6a20f18
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Apr 21 01:01:44 2021 +0200
-do not update total_sold when patching product, not provided as an
argument, breaks invariants
---
.../taler-merchant-httpd_private-patch-products-ID.c | 3 +++
src/backenddb/plugin_merchantdb_postgres.c | 17 +++++++----------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_private-patch-products-ID.c
b/src/backend/taler-merchant-httpd_private-patch-products-ID.c
index 47f695af..f9f7bc67 100644
--- a/src/backend/taler-merchant-httpd_private-patch-products-ID.c
+++ b/src/backend/taler-merchant-httpd_private-patch-products-ID.c
@@ -57,6 +57,7 @@ determine_cause (struct MHD_Connection *connection,
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
+ GNUNET_break (0);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_FETCH_FAILED,
@@ -87,6 +88,7 @@ determine_cause (struct MHD_Connection *connection,
if (pd->total_stock - pdx.total_sold < pd->total_lost)
ec = TALER_EC_MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_LOST_EXCEEDS_STOCKS;
TALER_MERCHANTDB_product_details_free (&pdx);
+ GNUNET_break (TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE != ec);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_CONFLICT,
ec,
@@ -213,6 +215,7 @@ TMH_private_patch_products_ID (const struct
TMH_RequestHandler *rh,
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
+ GNUNET_break (0);
ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_STORE_FAILED,
diff --git a/src/backenddb/plugin_merchantdb_postgres.c
b/src/backenddb/plugin_merchantdb_postgres.c
index 0170767d..cb9d1163 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -1111,8 +1111,7 @@ postgres_update_product (void *cls,
TALER_PQ_query_param_json (pd->taxes),
TALER_PQ_query_param_amount (&pd->price),
GNUNET_PQ_query_param_uint64 (&pd->total_stock),
- GNUNET_PQ_query_param_uint64 (&pd->total_sold),
- GNUNET_PQ_query_param_uint64 (&pd->total_lost), /* $11 */
+ GNUNET_PQ_query_param_uint64 (&pd->total_lost), /* $10 */
TALER_PQ_query_param_json (pd->address),
GNUNET_PQ_query_param_absolute_time (&pd->next_restock),
GNUNET_PQ_query_param_end
@@ -6315,20 +6314,18 @@ postgres_connect (void *cls)
",price_val=$8"
",price_frac=$9"
",total_stock=$10"
- ",total_sold=$11"
- ",total_lost=$12"
- ",address=$13"
- ",next_restock=$14"
+ ",total_lost=$11"
+ ",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 <= $11"
- " AND $10 - $11 >= $12"
- " AND total_lost <= $12",
- 14),
+ " AND $10 - total_sold >= $11"
+ " AND total_lost <= $11",
+ 13),
/* for postgres_lock_product() */
GNUNET_PQ_make_prepare ("lock_product",
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.