db: Fix some prepared statements

This commit is contained in:
Sree Harsha Totakura 2015-03-05 16:11:38 +01:00
parent 39e8dd862b
commit b6484371fb

View File

@ -282,9 +282,10 @@ TALER_MINT_DB_prepare (PGconn *db_conn)
result = PQprepare (db_conn, "get_reserve", result = PQprepare (db_conn, "get_reserve",
"SELECT " "SELECT "
" balance_value, balance_fraction, balance_currency " "current_balance_value"
",expiration_date, blind_session_pub, blind_session_priv" ",current_balance_fraction"
",status_sig, status_sign_pub " ",balance_currency "
",expiration_date "
"FROM reserves " "FROM reserves "
"WHERE reserve_pub=$1 " "WHERE reserve_pub=$1 "
"LIMIT 1; ", "LIMIT 1; ",
@ -300,14 +301,11 @@ TALER_MINT_DB_prepare (PGconn *db_conn)
result = PQprepare (db_conn, "update_reserve", result = PQprepare (db_conn, "update_reserve",
"UPDATE reserves " "UPDATE reserves "
"SET" "SET"
" balance_value=$2 " " current_balance_value=$2 "
",balance_fraction=$3 " ",current_balance_fraction=$3 "
",balance_currency=$4 " ",expiration_date=$4 "
",status_sig=$5 "
",status_sign_pub=$6 "
",expiration_date=$7 "
"WHERE reserve_pub=$1 ", "WHERE reserve_pub=$1 ",
9, NULL); 4, NULL);
if (PGRES_COMMAND_OK != PQresultStatus(result)) if (PGRES_COMMAND_OK != PQresultStatus(result))
{ {
break_db_err (result); break_db_err (result);
@ -343,21 +341,8 @@ TALER_MINT_DB_prepare (PGconn *db_conn)
} }
PQclear (result); PQclear (result);
result = PQprepare (db_conn, "insert_reserve_order",
"SELECT "
" blind_ev, blind_ev_sig, denom_pub, reserve_sig, reserve_pub "
"FROM collectable_blindcoins "
"WHERE blind_session_pub = $1",
1, NULL);
if (PGRES_COMMAND_OK != PQresultStatus(result))
{
break_db_err (result);
PQclear (result);
return GNUNET_SYSERR;
}
PQclear (result);
/* FIXME: does it make sense to store these computed values in the DB? */ /* FIXME: does it make sense to store these computed values in the DB? */
#if 0
result = PQprepare (db_conn, "get_refresh_session", result = PQprepare (db_conn, "get_refresh_session",
"SELECT " "SELECT "
" (SELECT count(*) FROM refresh_melt WHERE session_pub = $1)::INT2 as num_oldcoins " " (SELECT count(*) FROM refresh_melt WHERE session_pub = $1)::INT2 as num_oldcoins "
@ -378,6 +363,7 @@ TALER_MINT_DB_prepare (PGconn *db_conn)
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
PQclear (result); PQclear (result);
#endif
result = PQprepare (db_conn, "get_known_coin", result = PQprepare (db_conn, "get_known_coin",
"SELECT " "SELECT "