From f48a08df999f6ef611f0ed4f1fe20a499ed47bc1 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 12 Oct 2022 14:49:19 +0200 Subject: -update to latest GNUNET_PQ_make_prepare() API --- src/stasis/plugin_anastasis_postgres.c | 120 +++++++++++---------------------- 1 file changed, 40 insertions(+), 80 deletions(-) diff --git a/src/stasis/plugin_anastasis_postgres.c b/src/stasis/plugin_anastasis_postgres.c index 566b81a..147045f 100644 --- a/src/stasis/plugin_anastasis_postgres.c +++ b/src/stasis/plugin_anastasis_postgres.c @@ -143,24 +143,20 @@ prepare_statements (void *cls) "(user_id" ",expiration_date" ") VALUES " - "($1, $2);", - 2), + "($1, $2);"), GNUNET_PQ_make_prepare ("do_commit", - "COMMIT", - 0), + "COMMIT"), GNUNET_PQ_make_prepare ("user_select", "SELECT" " expiration_date " "FROM anastasis_user" " WHERE user_id=$1" - " FOR UPDATE;", - 1), + " FOR UPDATE;"), GNUNET_PQ_make_prepare ("user_update", "UPDATE anastasis_user" " SET " " expiration_date=$1" - " WHERE user_id=$2;", - 2), + " WHERE user_id=$2;"), GNUNET_PQ_make_prepare ("recdoc_payment_insert", "INSERT INTO anastasis_recdoc_payment " "(user_id" @@ -170,8 +166,7 @@ prepare_statements (void *cls) ",payment_identifier" ",creation_date" ") VALUES " - "($1, $2, $3, $4, $5, $6);", - 6), + "($1, $2, $3, $4, $5, $6);"), GNUNET_PQ_make_prepare ("challenge_payment_insert", "INSERT INTO anastasis_challenge_payment " "(truth_uuid" @@ -180,8 +175,7 @@ prepare_statements (void *cls) ",payment_identifier" ",creation_date" ") VALUES " - "($1, $2, $3, $4, $5);", - 5), + "($1, $2, $3, $4, $5);"), GNUNET_PQ_make_prepare ("truth_payment_insert", "INSERT INTO anastasis_truth_payment " "(truth_uuid" @@ -189,8 +183,7 @@ prepare_statements (void *cls) ",amount_frac" ",expiration" ") VALUES " - "($1, $2, $3, $4);", - 4), + "($1, $2, $3, $4);"), GNUNET_PQ_make_prepare ("recdoc_payment_done", "UPDATE anastasis_recdoc_payment " "SET" @@ -200,8 +193,7 @@ prepare_statements (void *cls) " AND" " user_id=$2" " AND" - " paid=FALSE;", - 2), + " paid=FALSE;"), GNUNET_PQ_make_prepare ("challenge_refund_update", "UPDATE anastasis_challenge_payment " "SET" @@ -211,8 +203,7 @@ prepare_statements (void *cls) " AND" " paid=TRUE" " AND" - " truth_uuid=$2;", - 2), + " truth_uuid=$2;"), GNUNET_PQ_make_prepare ("challenge_payment_done", "UPDATE anastasis_challenge_payment " "SET" @@ -224,8 +215,7 @@ prepare_statements (void *cls) " AND" " truth_uuid=$2" " AND" - " paid=FALSE;", - 2), + " paid=FALSE;"), GNUNET_PQ_make_prepare ("recdoc_payment_select", "SELECT" " creation_date" @@ -234,15 +224,13 @@ prepare_statements (void *cls) ",amount_frac" ",paid" " FROM anastasis_recdoc_payment" - " WHERE payment_identifier=$1;", - 1), + " WHERE payment_identifier=$1;"), GNUNET_PQ_make_prepare ("truth_payment_select", "SELECT" " expiration" " FROM anastasis_truth_payment" " WHERE truth_uuid=$1" - " AND expiration>$2;", - 2), + " AND expiration>$2;"), GNUNET_PQ_make_prepare ("challenge_payment_select", "SELECT" " creation_date" @@ -253,8 +241,7 @@ prepare_statements (void *cls) " WHERE payment_identifier=$1" " AND truth_uuid=$2" " AND refunded=FALSE" - " AND counter>0;", - 1), + " AND counter>0;"), GNUNET_PQ_make_prepare ("challenge_pending_payment_select", "SELECT" " creation_date" @@ -269,8 +256,7 @@ prepare_statements (void *cls) " AND" " truth_uuid=$1" " AND" - " creation_date > $2;", - 1), + " creation_date > $2;"), GNUNET_PQ_make_prepare ("recdoc_payments_select", "SELECT" " user_id" @@ -278,20 +264,17 @@ prepare_statements (void *cls) ",amount_val" ",amount_frac" " FROM anastasis_recdoc_payment" - " WHERE paid=FALSE;", - 0), + " WHERE paid=FALSE;"), GNUNET_PQ_make_prepare ("gc_accounts", "DELETE FROM anastasis_user " "WHERE" - " expiration_date < $1;", - 1), + " expiration_date < $1;"), GNUNET_PQ_make_prepare ("gc_recdoc_pending_payments", "DELETE FROM anastasis_recdoc_payment " "WHERE" " paid=FALSE" " AND" - " creation_date < $1;", - 1), + " creation_date < $1;"), GNUNET_PQ_make_prepare ("gc_challenge_pending_payments", "DELETE FROM anastasis_challenge_payment " "WHERE" @@ -299,8 +282,7 @@ prepare_statements (void *cls) " OR" " refunded=TRUE)" " AND" - " creation_date < $1;", - 1), + " creation_date < $1;"), GNUNET_PQ_make_prepare ("truth_insert", "INSERT INTO anastasis_truth " "(truth_uuid" @@ -310,8 +292,7 @@ prepare_statements (void *cls) ",truth_mime" ",expiration" ") VALUES " - "($1, $2, $3, $4, $5, $6);", - 6), + "($1, $2, $3, $4, $5, $6);"), GNUNET_PQ_make_prepare ("test_auth_iban_payment", "SELECT" " credit_val" @@ -319,8 +300,7 @@ prepare_statements (void *cls) ",wire_subject" " FROM anastasis_auth_iban_in" " WHERE debit_account_details=$1" - " AND execution_date>=$2;", - 2), + " AND execution_date>=$2;"), GNUNET_PQ_make_prepare ("store_auth_iban_payment_details", "INSERT INTO anastasis_auth_iban_in " "(wire_reference" @@ -331,8 +311,7 @@ prepare_statements (void *cls) ",credit_account_details" ",execution_date" ") VALUES " - "($1, $2, $3, $4, $5, $6, $7);", - 7), + "($1, $2, $3, $4, $5, $6, $7);"), GNUNET_PQ_make_prepare ("recovery_document_insert", "INSERT INTO anastasis_recoverydocument " "(user_id" @@ -343,16 +322,14 @@ prepare_statements (void *cls) ",recovery_meta_data" ",creation_date" ") VALUES " - "($1, $2, $3, $4, $5, $6, $7);", - 7), + "($1, $2, $3, $4, $5, $6, $7);"), GNUNET_PQ_make_prepare ("truth_select", "SELECT " " method_name" ",encrypted_truth" ",truth_mime" " FROM anastasis_truth" - " WHERE truth_uuid=$1;", - 1), + " WHERE truth_uuid=$1;"), GNUNET_PQ_make_prepare ("recoverydocument_select_meta", "SELECT " " version" @@ -362,8 +339,7 @@ prepare_statements (void *cls) " WHERE user_id=$1" " AND version < $2" " ORDER BY version DESC" - " LIMIT 1000;", - 2), + " LIMIT 1000;"), GNUNET_PQ_make_prepare ("latest_recoverydocument_select", "SELECT " " version" @@ -373,8 +349,7 @@ prepare_statements (void *cls) " FROM anastasis_recoverydocument" " WHERE user_id=$1" " ORDER BY version DESC" - " LIMIT 1;", - 1), + " LIMIT 1;"), GNUNET_PQ_make_prepare ("latest_recovery_version_select", "SELECT" " version" @@ -384,8 +359,7 @@ prepare_statements (void *cls) " JOIN anastasis_user USING (user_id)" " WHERE user_id=$1" " ORDER BY version DESC" - " LIMIT 1;", - 1), + " LIMIT 1;"), GNUNET_PQ_make_prepare ("recoverydocument_select", "SELECT " " account_sig" @@ -393,30 +367,26 @@ prepare_statements (void *cls) ",recovery_data" " FROM anastasis_recoverydocument" " WHERE user_id=$1" - " AND version=$2;", - 2), + " AND version=$2;"), GNUNET_PQ_make_prepare ("postcounter_select", "SELECT" " post_counter" " FROM anastasis_recdoc_payment" " WHERE user_id=$1" - " AND payment_identifier=$2;", - 2), + " AND payment_identifier=$2;"), GNUNET_PQ_make_prepare ("postcounter_update", "UPDATE" " anastasis_recdoc_payment" " SET" " post_counter=$1" " WHERE user_id =$2" - " AND payment_identifier=$3;", - 3), + " AND payment_identifier=$3;"), GNUNET_PQ_make_prepare ("key_share_select", "SELECT " "key_share_data " "FROM " "anastasis_truth " - "WHERE truth_uuid =$1;", - 1), + "WHERE truth_uuid =$1;"), GNUNET_PQ_make_prepare ("challengecode_insert", "INSERT INTO anastasis_challengecode " "(truth_uuid" @@ -425,8 +395,7 @@ prepare_statements (void *cls) ",expiration_date" ",retry_counter" ") VALUES " - "($1, $2, $3, $4, $5);", - 5), + "($1, $2, $3, $4, $5);"), GNUNET_PQ_make_prepare ("challengecode_select", "SELECT " " code" @@ -434,8 +403,7 @@ prepare_statements (void *cls) " FROM anastasis_challengecode" " WHERE truth_uuid=$1" " AND expiration_date > $2" - " AND retry_counter != 0;", - 2), + " AND retry_counter != 0;"), GNUNET_PQ_make_prepare ("challengecode_set_satisfied", "UPDATE anastasis_challengecode" " SET satisfied=TRUE" @@ -447,16 +415,14 @@ prepare_statements (void *cls) " WHERE truth_uuid=$1" " AND code=$2" " ORDER BY creation_date DESC" - " LIMIT 1);", - 2), + " LIMIT 1);"), GNUNET_PQ_make_prepare ("challengecode_test_satisfied", "SELECT 1 FROM anastasis_challengecode" " WHERE truth_uuid=$1" " AND satisfied=TRUE" " AND code=$2" " AND creation_date >= $3" - " LIMIT 1;", - 3), + " LIMIT 1;"), GNUNET_PQ_make_prepare ("challengecode_select_meta", "SELECT " " code" @@ -467,22 +433,19 @@ prepare_statements (void *cls) " AND expiration_date > $2" " AND creation_date > $3" " ORDER BY creation_date DESC" - " LIMIT 1;", - 2), + " LIMIT 1;"), GNUNET_PQ_make_prepare ("challengecode_update_retry", "UPDATE anastasis_challengecode" " SET retry_counter=retry_counter - 1" " WHERE truth_uuid=$1" " AND code=$2" - " AND retry_counter != 0;", - 1), + " AND retry_counter != 0;"), GNUNET_PQ_make_prepare ("challengepayment_dec_counter", "UPDATE anastasis_challenge_payment" " SET counter=counter - 1" " WHERE truth_uuid=$1" " AND payment_identifier=$2" - " AND counter > 0;", - 2), + " AND counter > 0;"), GNUNET_PQ_make_prepare ("challengecode_mark_sent", "UPDATE anastasis_challengecode" " SET retransmission_date=$3" @@ -494,21 +457,18 @@ prepare_statements (void *cls) " WHERE truth_uuid=$1" " AND code=$2" " ORDER BY creation_date DESC" - " LIMIT 1);", - 3), + " LIMIT 1);"), GNUNET_PQ_make_prepare ("get_last_auth_iban_payment", "SELECT " " wire_reference" " FROM anastasis_auth_iban_in" " WHERE credit_account_details=$1" " ORDER BY wire_reference DESC" - " LIMIT 1;", - 1), + " LIMIT 1;"), GNUNET_PQ_make_prepare ("gc_challengecodes", "DELETE FROM anastasis_challengecode " "WHERE " - "expiration_date < $1;", - 1), + "expiration_date < $1;"), GNUNET_PQ_PREPARED_STATEMENT_END }; -- cgit v1.2.3