aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <sreeharsha@totakura.in>2015-03-05 16:11:38 +0100
committerSree Harsha Totakura <sreeharsha@totakura.in>2015-03-06 10:31:44 +0100
commitb6484371fb414f8cb7583f9057ea81ad8f44c29a (patch)
treec3010dbebc39c209e66070fb77bf7e31416ea973
parent39e8dd862bd1b8f1de86ee93e531ba28eb95b92e (diff)
downloadexchange-b6484371fb414f8cb7583f9057ea81ad8f44c29a.tar.gz
exchange-b6484371fb414f8cb7583f9057ea81ad8f44c29a.zip
db: Fix some prepared statements
-rw-r--r--src/mint/mint_db.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/src/mint/mint_db.c b/src/mint/mint_db.c
index 354bb7008..268b22a00 100644
--- a/src/mint/mint_db.c
+++ b/src/mint/mint_db.c
@@ -282,9 +282,10 @@ TALER_MINT_DB_prepare (PGconn *db_conn)
282 282
283 result = PQprepare (db_conn, "get_reserve", 283 result = PQprepare (db_conn, "get_reserve",
284 "SELECT " 284 "SELECT "
285 " balance_value, balance_fraction, balance_currency " 285 "current_balance_value"
286 ",expiration_date, blind_session_pub, blind_session_priv" 286 ",current_balance_fraction"
287 ",status_sig, status_sign_pub " 287 ",balance_currency "
288 ",expiration_date "
288 "FROM reserves " 289 "FROM reserves "
289 "WHERE reserve_pub=$1 " 290 "WHERE reserve_pub=$1 "
290 "LIMIT 1; ", 291 "LIMIT 1; ",
@@ -300,14 +301,11 @@ TALER_MINT_DB_prepare (PGconn *db_conn)
300 result = PQprepare (db_conn, "update_reserve", 301 result = PQprepare (db_conn, "update_reserve",
301 "UPDATE reserves " 302 "UPDATE reserves "
302 "SET" 303 "SET"
303 " balance_value=$2 " 304 " current_balance_value=$2 "
304 ",balance_fraction=$3 " 305 ",current_balance_fraction=$3 "
305 ",balance_currency=$4 " 306 ",expiration_date=$4 "
306 ",status_sig=$5 "
307 ",status_sign_pub=$6 "
308 ",expiration_date=$7 "
309 "WHERE reserve_pub=$1 ", 307 "WHERE reserve_pub=$1 ",
310 9, NULL); 308 4, NULL);
311 if (PGRES_COMMAND_OK != PQresultStatus(result)) 309 if (PGRES_COMMAND_OK != PQresultStatus(result))
312 { 310 {
313 break_db_err (result); 311 break_db_err (result);
@@ -343,21 +341,8 @@ TALER_MINT_DB_prepare (PGconn *db_conn)
343 } 341 }
344 PQclear (result); 342 PQclear (result);
345 343
346 result = PQprepare (db_conn, "insert_reserve_order",
347 "SELECT "
348 " blind_ev, blind_ev_sig, denom_pub, reserve_sig, reserve_pub "
349 "FROM collectable_blindcoins "
350 "WHERE blind_session_pub = $1",
351 1, NULL);
352 if (PGRES_COMMAND_OK != PQresultStatus(result))
353 {
354 break_db_err (result);
355 PQclear (result);
356 return GNUNET_SYSERR;
357 }
358 PQclear (result);
359
360 /* FIXME: does it make sense to store these computed values in the DB? */ 344 /* FIXME: does it make sense to store these computed values in the DB? */
345#if 0
361 result = PQprepare (db_conn, "get_refresh_session", 346 result = PQprepare (db_conn, "get_refresh_session",
362 "SELECT " 347 "SELECT "
363 " (SELECT count(*) FROM refresh_melt WHERE session_pub = $1)::INT2 as num_oldcoins " 348 " (SELECT count(*) FROM refresh_melt WHERE session_pub = $1)::INT2 as num_oldcoins "
@@ -378,6 +363,7 @@ TALER_MINT_DB_prepare (PGconn *db_conn)
378 return GNUNET_SYSERR; 363 return GNUNET_SYSERR;
379 } 364 }
380 PQclear (result); 365 PQclear (result);
366#endif
381 367
382 result = PQprepare (db_conn, "get_known_coin", 368 result = PQprepare (db_conn, "get_known_coin",
383 "SELECT " 369 "SELECT "