do equivalent update for results that was done to type queries in pq library
This commit is contained in:
parent
fe51219d58
commit
dc4847220a
@ -262,7 +262,7 @@ struct TALER_PQ_ResultSpec
|
|||||||
/**
|
/**
|
||||||
* Field name of the desired result.
|
* Field name of the desired result.
|
||||||
*/
|
*/
|
||||||
char *fname;
|
const char *fname;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Where to store actual size of the result.
|
* Where to store actual size of the result.
|
||||||
@ -274,6 +274,8 @@ struct TALER_PQ_ResultSpec
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* End of result parameter specification.
|
* End of result parameter specification.
|
||||||
|
*
|
||||||
|
* @return array last entry for the result specification to use
|
||||||
*/
|
*/
|
||||||
#define TALER_PQ_RESULT_SPEC_END { TALER_PQ_RF_END, NULL, 0, NULL, NULL }
|
#define TALER_PQ_RESULT_SPEC_END { TALER_PQ_RF_END, NULL, 0, NULL, NULL }
|
||||||
|
|
||||||
@ -283,6 +285,7 @@ struct TALER_PQ_ResultSpec
|
|||||||
* @param name name of the field in the table
|
* @param name name of the field in the table
|
||||||
* @param dst point to where to store the result
|
* @param dst point to where to store the result
|
||||||
* @param s number of bytes we should use in @a dst
|
* @param s number of bytes we should use in @a dst
|
||||||
|
* @return array entry for the result specification to use
|
||||||
*/
|
*/
|
||||||
#define TALER_PQ_RESULT_SPEC_SIZED(name, dst, s) { TALER_PQ_RF_FIXED_BLOB, (void *) (dst), (s), (name), NULL }
|
#define TALER_PQ_RESULT_SPEC_SIZED(name, dst, s) { TALER_PQ_RF_FIXED_BLOB, (void *) (dst), (s), (name), NULL }
|
||||||
|
|
||||||
@ -292,6 +295,7 @@ struct TALER_PQ_ResultSpec
|
|||||||
*
|
*
|
||||||
* @param name name of the field in the table
|
* @param name name of the field in the table
|
||||||
* @param dst point to where to store the result, type fits expected result size
|
* @param dst point to where to store the result, type fits expected result size
|
||||||
|
* @return array entry for the result specification to use
|
||||||
*/
|
*/
|
||||||
#define TALER_PQ_RESULT_SPEC(name, dst) { TALER_PQ_RF_VARSIZE_BLOB, (void *) dst, sizeof (*(dst)), name, NULL }
|
#define TALER_PQ_RESULT_SPEC(name, dst) { TALER_PQ_RF_VARSIZE_BLOB, (void *) dst, sizeof (*(dst)), name, NULL }
|
||||||
|
|
||||||
@ -300,53 +304,74 @@ struct TALER_PQ_ResultSpec
|
|||||||
* Variable-size result expected.
|
* Variable-size result expected.
|
||||||
*
|
*
|
||||||
* @param name name of the field in the table
|
* @param name name of the field in the table
|
||||||
* @param dst where to store the result (of type void **), to be allocated
|
* @param[out] dst where to store the result, allocated
|
||||||
* @param sptr pointer to a `size_t` for where to store the size of @a dst
|
* @param[out] sptr where to store the size of @a dst
|
||||||
|
* @return array entry for the result specification to use
|
||||||
*/
|
*/
|
||||||
#define TALER_PQ_RESULT_SPEC_VAR(name, dst, sptr) {TALER_PQ_RF_VARSIZE_BLOB, (void *) (dst), 0, (name), sptr }
|
struct TALER_PQ_ResultSpec
|
||||||
|
TALER_PQ_RESULT_SPEC_VAR (const char *name,
|
||||||
|
void **dst,
|
||||||
|
size_t *sptr);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currency amount expected.
|
* Currency amount expected.
|
||||||
*
|
*
|
||||||
* @param name name of the field in the table
|
* @param name name of the field in the table
|
||||||
* @param amount a `struct TALER_AmountNBO` where to store the result
|
* @param[out] amount where to store the result
|
||||||
|
* @return array entry for the result specification to use
|
||||||
*/
|
*/
|
||||||
#define TALER_PQ_RESULT_SPEC_AMOUNT_NBO(name, amount) {TALER_PQ_RF_AMOUNT_NBO, (void *) (&amount), sizeof (amount), (name), NULL }
|
struct TALER_PQ_ResultSpec
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT_NBO (const char *name,
|
||||||
|
struct TALER_AmountNBO *amount);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currency amount expected.
|
* Currency amount expected.
|
||||||
*
|
*
|
||||||
* @param name name of the field in the table
|
* @param name name of the field in the table
|
||||||
* @param amount a `struct TALER_Amount` where to store the result
|
* @param[out] amount where to store the result
|
||||||
|
* @return array entry for the result specification to use
|
||||||
*/
|
*/
|
||||||
#define TALER_PQ_RESULT_SPEC_AMOUNT(name, amount) {TALER_PQ_RF_AMOUNT, (void *) (&amount), sizeof (amount), (name), NULL }
|
struct TALER_PQ_ResultSpec
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT (const char *name,
|
||||||
|
struct TALER_Amount *amount);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSA public key expected.
|
* RSA public key expected.
|
||||||
*
|
*
|
||||||
* @param name name of the field in the table
|
* @param name name of the field in the table
|
||||||
* @param rsa a `struct GNUNET_CRYPTO_rsa_PublicKey *` where to store the result;
|
* @param[out] rsa where to store the result
|
||||||
* the R-value must be NULL at the time of the call
|
* @return array entry for the result specification to use
|
||||||
*/
|
*/
|
||||||
#define TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY(name, rsa) {TALER_PQ_RF_RSA_PUBLIC_KEY, (void *) &(rsa), 0, (name), NULL }
|
struct TALER_PQ_ResultSpec
|
||||||
|
TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY (const char *name,
|
||||||
|
struct GNUNET_CRYPTO_rsa_PublicKey **rsa);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSA signature expected.
|
* RSA signature expected.
|
||||||
*
|
*
|
||||||
* @param name name of the field in the table
|
* @param name name of the field in the table
|
||||||
* @param sig a `struct GNUNET_CRYPTO_rsa_Signature *` where to store the result;
|
* @param[out] sig where to store the result;
|
||||||
* the R-value must be NULL at the time of the call
|
* @return array entry for the result specification to use
|
||||||
*/
|
*/
|
||||||
#define TALER_PQ_RESULT_SPEC_RSA_SIGNATURE(name, sig) {TALER_PQ_RF_RSA_SIGNATURE, (void *) &(sig), 0, (name), NULL }
|
struct TALER_PQ_ResultSpec
|
||||||
|
TALER_PQ_RESULT_SPEC_RSA_SIGNATURE (const char *name,
|
||||||
|
struct GNUNET_CRYPTO_rsa_Signature **sig);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Absolute time expected.
|
* Absolute time expected.
|
||||||
*
|
*
|
||||||
* @param name name of the field in the table
|
* @param name name of the field in the table
|
||||||
* @param at a `struct GNUNET_TIME_Absolute` where to store the result
|
* @param[out] at where to store the result
|
||||||
|
* @return array entry for the result specification to use
|
||||||
*/
|
*/
|
||||||
#define TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME(name,at) {TALER_PQ_RF_TIME_ABSOLUTE, (void *) (&at), sizeof (at), (name), NULL }
|
struct TALER_PQ_ResultSpec
|
||||||
|
TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME (const char *name,
|
||||||
|
struct GNUNET_TIME_Absolute *at);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -894,8 +894,8 @@ postgres_reserve_get (void *cls,
|
|||||||
TALER_PQ_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
struct TALER_PQ_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_PQ_RESULT_SPEC_AMOUNT("current_balance", reserve->balance),
|
TALER_PQ_RESULT_SPEC_AMOUNT("current_balance", &reserve->balance),
|
||||||
TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME("expiration_date", reserve->expiry),
|
TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME("expiration_date", &reserve->expiry),
|
||||||
TALER_PQ_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1116,8 +1116,8 @@ postgres_get_collectable_blindcoin (void *cls,
|
|||||||
TALER_PQ_QUERY_PARAM_PTR (h_blind),
|
TALER_PQ_QUERY_PARAM_PTR (h_blind),
|
||||||
TALER_PQ_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub = NULL;
|
struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub;
|
||||||
struct GNUNET_CRYPTO_rsa_Signature *denom_sig = NULL;
|
struct GNUNET_CRYPTO_rsa_Signature *denom_sig;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = GNUNET_SYSERR;
|
ret = GNUNET_SYSERR;
|
||||||
@ -1136,8 +1136,8 @@ postgres_get_collectable_blindcoin (void *cls,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
struct TALER_PQ_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY("denom_pub", denom_pub),
|
TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY("denom_pub", &denom_pub),
|
||||||
TALER_PQ_RESULT_SPEC_RSA_SIGNATURE("denom_sig", denom_sig),
|
TALER_PQ_RESULT_SPEC_RSA_SIGNATURE("denom_sig", &denom_sig),
|
||||||
TALER_PQ_RESULT_SPEC("reserve_sig", &collectable->reserve_sig),
|
TALER_PQ_RESULT_SPEC("reserve_sig", &collectable->reserve_sig),
|
||||||
TALER_PQ_RESULT_SPEC("reserve_pub", &collectable->reserve_pub),
|
TALER_PQ_RESULT_SPEC("reserve_pub", &collectable->reserve_pub),
|
||||||
TALER_PQ_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
@ -1155,12 +1155,7 @@ postgres_get_collectable_blindcoin (void *cls,
|
|||||||
cleanup:
|
cleanup:
|
||||||
PQclear (result);
|
PQclear (result);
|
||||||
if (GNUNET_YES != ret)
|
if (GNUNET_YES != ret)
|
||||||
{
|
TALER_PQ_cleanup_result (rs);
|
||||||
if (NULL != denom_pub)
|
|
||||||
GNUNET_CRYPTO_rsa_public_key_free (denom_pub);
|
|
||||||
if (NULL != denom_sig)
|
|
||||||
GNUNET_CRYPTO_rsa_signature_free (denom_sig);
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1344,8 +1339,8 @@ postgres_get_reserve_history (void *cls,
|
|||||||
}
|
}
|
||||||
struct TALER_PQ_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_PQ_RESULT_SPEC ("blind_ev", &blind_ev),
|
TALER_PQ_RESULT_SPEC ("blind_ev", &blind_ev),
|
||||||
TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY ("denom_pub", denom_pub),
|
TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY ("denom_pub", &denom_pub),
|
||||||
TALER_PQ_RESULT_SPEC_RSA_SIGNATURE ("denom_sig", denom_sig),
|
TALER_PQ_RESULT_SPEC_RSA_SIGNATURE ("denom_sig", &denom_sig),
|
||||||
TALER_PQ_RESULT_SPEC ("reserve_sig", &reserve_sig),
|
TALER_PQ_RESULT_SPEC ("reserve_sig", &reserve_sig),
|
||||||
TALER_PQ_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
@ -1354,9 +1349,8 @@ postgres_get_reserve_history (void *cls,
|
|||||||
GNUNET_assert (NULL == rh_head->next);
|
GNUNET_assert (NULL == rh_head->next);
|
||||||
while (0 < rows)
|
while (0 < rows)
|
||||||
{
|
{
|
||||||
denom_sig = NULL;
|
if (GNUNET_YES !=
|
||||||
denom_pub = NULL;
|
TALER_PQ_extract_result (result, rs, --rows))
|
||||||
if (GNUNET_YES != TALER_PQ_extract_result (result, rs, --rows))
|
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1799,7 +1793,7 @@ postgres_get_refresh_order (void *cls,
|
|||||||
}
|
}
|
||||||
GNUNET_assert (1 == PQntuples (result));
|
GNUNET_assert (1 == PQntuples (result));
|
||||||
struct TALER_PQ_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY ("denom_pub", denom_pubs->rsa_public_key),
|
TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY ("denom_pub", &denom_pubs->rsa_public_key),
|
||||||
TALER_PQ_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
if (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0))
|
if (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0))
|
||||||
@ -1902,9 +1896,9 @@ postgres_get_refresh_commit_coins (void *cls,
|
|||||||
TALER_PQ_QUERY_PARAM_PTR(&newcoin_index_nbo),
|
TALER_PQ_QUERY_PARAM_PTR(&newcoin_index_nbo),
|
||||||
TALER_PQ_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
char *c_buf;
|
void *c_buf;
|
||||||
size_t c_buf_size;
|
size_t c_buf_size;
|
||||||
char *rl_buf;
|
void *rl_buf;
|
||||||
size_t rl_buf_size;
|
size_t rl_buf_size;
|
||||||
struct TALER_RefreshLinkEncrypted *rl;
|
struct TALER_RefreshLinkEncrypted *rl;
|
||||||
|
|
||||||
@ -2204,14 +2198,14 @@ postgres_get_link_data_list (void *cls,
|
|||||||
for (i = 0; i < PQntuples (result); i++)
|
for (i = 0; i < PQntuples (result); i++)
|
||||||
{
|
{
|
||||||
struct TALER_RefreshLinkEncrypted *link_enc;
|
struct TALER_RefreshLinkEncrypted *link_enc;
|
||||||
struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub = NULL;
|
struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub;
|
||||||
struct GNUNET_CRYPTO_rsa_Signature *sig = NULL;
|
struct GNUNET_CRYPTO_rsa_Signature *sig;
|
||||||
char *ld_buf;
|
void *ld_buf;
|
||||||
size_t ld_buf_size;
|
size_t ld_buf_size;
|
||||||
struct TALER_PQ_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_PQ_RESULT_SPEC_VAR("link_vector_enc", &ld_buf, &ld_buf_size),
|
TALER_PQ_RESULT_SPEC_VAR("link_vector_enc", &ld_buf, &ld_buf_size),
|
||||||
TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY("denom_pub", denom_pub),
|
TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY("denom_pub", &denom_pub),
|
||||||
TALER_PQ_RESULT_SPEC_RSA_SIGNATURE("ev_sig", sig),
|
TALER_PQ_RESULT_SPEC_RSA_SIGNATURE("ev_sig", &sig),
|
||||||
TALER_PQ_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2355,7 +2349,7 @@ postgres_get_coin_transactions (void *cls,
|
|||||||
TALER_PQ_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
json_error_t json_error;
|
json_error_t json_error;
|
||||||
char *json_wire_enc;
|
void *json_wire_enc;
|
||||||
size_t json_wire_enc_size;
|
size_t json_wire_enc_size;
|
||||||
int i;
|
int i;
|
||||||
result = TALER_PQ_exec_prepared (session->conn,
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
@ -2385,13 +2379,13 @@ postgres_get_coin_transactions (void *cls,
|
|||||||
*/
|
*/
|
||||||
TALER_PQ_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
if ((GNUNET_OK != TALER_PQ_extract_result (result, rs, i))
|
if ((GNUNET_OK != TALER_PQ_extract_result (result, rs, i)) ||
|
||||||
|| (GNUNET_OK != TALER_PQ_extract_amount (result,
|
(GNUNET_OK != TALER_PQ_extract_amount (result,
|
||||||
i,
|
i,
|
||||||
"amount_val",
|
"amount_val",
|
||||||
"amount_frac",
|
"amount_frac",
|
||||||
"amount_curr",
|
"amount_curr",
|
||||||
&deposit->amount_with_fee)))
|
&deposit->amount_with_fee)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
goto cleanup_deposit;
|
goto cleanup_deposit;
|
||||||
|
@ -415,7 +415,7 @@ TALER_PQ_extract_result (PGresult *result,
|
|||||||
const char *res;
|
const char *res;
|
||||||
int fnum;
|
int fnum;
|
||||||
|
|
||||||
GNUNET_break (NULL == *pk);
|
*pk = NULL;
|
||||||
fnum = PQfnumber (result,
|
fnum = PQfnumber (result,
|
||||||
spec->fname);
|
spec->fname);
|
||||||
if (fnum < 0)
|
if (fnum < 0)
|
||||||
@ -459,7 +459,7 @@ TALER_PQ_extract_result (PGresult *result,
|
|||||||
const char *res;
|
const char *res;
|
||||||
int fnum;
|
int fnum;
|
||||||
|
|
||||||
GNUNET_break (NULL == *sig);
|
*sig = NULL;
|
||||||
fnum = PQfnumber (result,
|
fnum = PQfnumber (result,
|
||||||
spec->fname);
|
spec->fname);
|
||||||
if (fnum < 0)
|
if (fnum < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user