[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated (b46cad2d4 -> 1a90e7878)
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated (b46cad2d4 -> 1a90e7878) |
Date: |
Sat, 03 Jun 2017 23:18:09 +0200 |
This is an automated email from the git hooks/post-receive script.
burdges pushed a change to branch master
in repository gnunet.
from b46cad2d4 Oops.
new c53f7586d Do non-select statements
new 1a90e7878 Do singleton select statements
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/psycstore/plugin_psycstore_postgres.c | 251 +++++-------------------------
1 file changed, 42 insertions(+), 209 deletions(-)
diff --git a/src/psycstore/plugin_psycstore_postgres.c
b/src/psycstore/plugin_psycstore_postgres.c
index 26c732fbe..f23b75a0c 100644
--- a/src/psycstore/plugin_psycstore_postgres.c
+++ b/src/psycstore/plugin_psycstore_postgres.c
@@ -386,22 +386,15 @@ static int
exec_channel (struct Plugin *plugin, const char *stmt,
const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key)
{
- PGresult *ret;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (channel_key),
GNUNET_PQ_query_param_end
};
- ret = GNUNET_PQ_exec_prepared (plugin->dbh, stmt, params);
- if (GNUNET_OK !=
- GNUNET_POSTGRES_check_result (plugin->dbh,
- ret,
- PGRES_COMMAND_OK,
- "PQexecPrepared", stmt))
+ if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+ GNUNET_PQ_eval_prepared_non_select (plugin->dbh, stmt, params))
return GNUNET_SYSERR;
- PQclear (ret);
-
return GNUNET_OK;
}
@@ -412,23 +405,15 @@ exec_channel (struct Plugin *plugin, const char *stmt,
static int
transaction_begin (struct Plugin *plugin, enum Transactions transaction)
{
- PGresult *ret;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_end
};
- ret = GNUNET_PQ_exec_prepared (plugin->dbh, "transaction_begin", params);
- if (GNUNET_OK !=
- GNUNET_POSTGRES_check_result (plugin->dbh,
- ret,
- PGRES_COMMAND_OK,
- "PQexecPrepared", "transaction_begin"))
- {
+ if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+ GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "transaction_begin",
params))
return GNUNET_SYSERR;
- }
plugin->transaction = transaction;
- PQclear (ret);
return GNUNET_OK;
}
@@ -439,23 +424,14 @@ transaction_begin (struct Plugin *plugin, enum
Transactions transaction)
static int
transaction_commit (struct Plugin *plugin)
{
- PGresult *ret;
-
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_end
};
- ret = GNUNET_PQ_exec_prepared (plugin->dbh, "transaction_commit", params);
- if (GNUNET_OK !=
- GNUNET_POSTGRES_check_result (plugin->dbh,
- ret,
- PGRES_COMMAND_OK,
- "PQexecPrepared", "transaction_commit"))
- {
+ if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+ GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "transaction_commit",
params))
return GNUNET_SYSERR;
- }
- PQclear (ret);
plugin->transaction = TRANSACTION_NONE;
return GNUNET_OK;
}
@@ -467,23 +443,14 @@ transaction_commit (struct Plugin *plugin)
static int
transaction_rollback (struct Plugin *plugin)
{
- PGresult *ret;
-
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_end
};
- ret = GNUNET_PQ_exec_prepared (plugin->dbh, "transaction_rollback", params);
- if (GNUNET_OK !=
- GNUNET_POSTGRES_check_result (plugin->dbh,
- ret,
- PGRES_COMMAND_OK,
- "PQexecPrepared", "transaction_rollback"))
- {
+ if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+ GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "transaction_rollback",
params))
return GNUNET_SYSERR;
- }
- PQclear (ret);
plugin->transaction = TRANSACTION_NONE;
return GNUNET_OK;
}
@@ -493,24 +460,15 @@ static int
channel_key_store (struct Plugin *plugin,
const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key)
{
- PGresult *ret;
-
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (channel_key),
GNUNET_PQ_query_param_end
};
- ret = GNUNET_PQ_exec_prepared (plugin->dbh, "insert_channel_key", params);
- if (GNUNET_OK !=
- GNUNET_POSTGRES_check_result (plugin->dbh,
- ret,
- PGRES_COMMAND_OK,
- "PQexecPrepared", "insert_channel_key"))
- {
+ if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+ GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_channel_key",
params))
return GNUNET_SYSERR;
- }
- PQclear (ret);
return GNUNET_OK;
}
@@ -519,24 +477,15 @@ static int
slave_key_store (struct Plugin *plugin,
const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key)
{
- PGresult *ret;
-
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (slave_key),
GNUNET_PQ_query_param_end
};
- ret = GNUNET_PQ_exec_prepared (plugin->dbh, "insert_slave_key", params);
- if (GNUNET_OK !=
- GNUNET_POSTGRES_check_result (plugin->dbh,
- ret,
- PGRES_COMMAND_OK,
- "PQexecPrepared", "insert_slave_key"))
- {
+ if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+ GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_slave_key",
params))
return GNUNET_SYSERR;
- }
- PQclear (ret);
return GNUNET_OK;
}
@@ -558,7 +507,6 @@ postgres_membership_store (void *cls,
uint64_t effective_since,
uint64_t group_generation)
{
- PGresult *ret;
struct Plugin *plugin = cls;
uint32_t idid_join = (uint32_t)did_join;
@@ -587,17 +535,10 @@ postgres_membership_store (void *cls,
GNUNET_PQ_query_param_end
};
- ret = GNUNET_PQ_exec_prepared (plugin->dbh, "insert_membership", params);
- if (GNUNET_OK !=
- GNUNET_POSTGRES_check_result (plugin->dbh,
- ret,
- PGRES_COMMAND_OK,
- "PQexecPrepared", "insert_membership"))
- {
+ if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+ GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_membership",
params))
return GNUNET_SYSERR;
- }
- PQclear (ret);
return GNUNET_OK;
}
@@ -615,13 +556,10 @@ membership_test (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key,
uint64_t message_id)
{
- PGresult *res;
struct Plugin *plugin = cls;
uint32_t did_join = 0;
- int ret = GNUNET_SYSERR;
-
struct GNUNET_PQ_QueryParam params_select[] = {
GNUNET_PQ_query_param_auto_from_type (channel_key),
GNUNET_PQ_query_param_auto_from_type (slave_key),
@@ -629,35 +567,17 @@ membership_test (void *cls,
GNUNET_PQ_query_param_end
};
- res = GNUNET_PQ_exec_prepared (plugin->dbh, "select_membership",
params_select);
- if (GNUNET_OK !=
- GNUNET_POSTGRES_check_result (plugin->dbh,
- res,
- PGRES_TUPLES_OK,
- "PQexecPrepared", "select_membership"))
- {
- return GNUNET_SYSERR;
- }
-
struct GNUNET_PQ_ResultSpec results_select[] = {
GNUNET_PQ_result_spec_uint32 ("did_join", &did_join),
GNUNET_PQ_result_spec_end
};
- switch (GNUNET_PQ_extract_result (res, results_select, 0))
- {
- case GNUNET_OK:
- ret = GNUNET_YES;
- break;
+ if (GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT !=
+ GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh,
"select_membership",
+ params_select, results_select))
+ return GNUNET_SYSERR;
- default:
- ret = GNUNET_NO;
- break;
- }
-
- PQclear (res);
-
- return ret;
+ return GNUNET_OK;
}
/**
@@ -673,7 +593,6 @@ fragment_store (void *cls,
const struct GNUNET_MULTICAST_MessageHeader *msg,
uint32_t psycstore_flags)
{
- PGresult *res;
struct Plugin *plugin = cls;
GNUNET_assert (TRANSACTION_NONE == plugin->transaction);
@@ -716,15 +635,10 @@ fragment_store (void *cls,
GNUNET_PQ_query_param_end
};
- res = GNUNET_PQ_exec_prepared (plugin->dbh, "insert_fragment",
params_insert);
- if (GNUNET_OK !=
- GNUNET_POSTGRES_check_result (plugin->dbh,
- res,
- PGRES_COMMAND_OK,
- "PQexecPrepared", "insert_fragment"))
+ if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+ GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_fragment",
params_insert))
return GNUNET_SYSERR;
- PQclear (res);
return GNUNET_OK;
}
@@ -741,7 +655,6 @@ message_add_flags (void *cls,
uint64_t message_id,
uint32_t psycstore_flags)
{
- PGresult *res;
struct Plugin *plugin = cls;
struct GNUNET_PQ_QueryParam params_update[] = {
@@ -751,14 +664,10 @@ message_add_flags (void *cls,
GNUNET_PQ_query_param_end
};
- res = GNUNET_PQ_exec_prepared (plugin->dbh, "update_message_flags",
params_update);
- if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh,
- res,
- PGRES_COMMAND_OK,
-
"PQexecPrepared","update_message_flags"))
+ if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+ GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "update_message_flags",
params_update))
return GNUNET_SYSERR;
- PQclear (res);
return GNUNET_OK;
}
@@ -1072,7 +981,6 @@ counters_message_get (void *cls,
uint64_t *max_message_id,
uint64_t *max_group_generation)
{
- PGresult *res;
struct Plugin *plugin = cls;
const char *stmt = "select_counters_message";
@@ -1082,15 +990,6 @@ counters_message_get (void *cls,
GNUNET_PQ_query_param_end
};
- res = GNUNET_PQ_exec_prepared (plugin->dbh, stmt, params_select);
- if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh,
- res,
- PGRES_TUPLES_OK,
- "PQexecPrepared", stmt))
- {
- return GNUNET_SYSERR;
- }
-
struct GNUNET_PQ_ResultSpec results_select[] = {
GNUNET_PQ_result_spec_uint64 ("fragment_id", max_fragment_id),
GNUNET_PQ_result_spec_uint64 ("message_id", max_message_id),
@@ -1098,14 +997,10 @@ counters_message_get (void *cls,
GNUNET_PQ_result_spec_end
};
- if (GNUNET_OK != GNUNET_PQ_extract_result (res, results_select, 0))
- {
- PQclear (res);
- return GNUNET_SYSERR;
- }
-
- GNUNET_PQ_cleanup_result(results_select);
- PQclear (res);
+ if (GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT !=
+ GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, stmt,
+ params_select, results_select))
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
@@ -1122,44 +1017,26 @@ counters_state_get (void *cls,
const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
uint64_t *max_state_message_id)
{
- PGresult *res;
struct Plugin *plugin = cls;
const char *stmt = "select_counters_state";
- int ret = GNUNET_SYSERR;
-
struct GNUNET_PQ_QueryParam params_select[] = {
GNUNET_PQ_query_param_auto_from_type (channel_key),
GNUNET_PQ_query_param_end
};
- res = GNUNET_PQ_exec_prepared (plugin->dbh, stmt, params_select);
- if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh,
- res,
- PGRES_TUPLES_OK,
- "PQexecPrepared", stmt))
- {
- return GNUNET_SYSERR;
- }
-
struct GNUNET_PQ_ResultSpec results_select[] = {
GNUNET_PQ_result_spec_uint64 ("max_state_message_id",
max_state_message_id),
GNUNET_PQ_result_spec_end
};
- ret = GNUNET_PQ_extract_result (res, results_select, 0);
+ if (GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT !=
+ GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, stmt,
+ params_select, results_select))
+ return GNUNET_SYSERR;
- if (GNUNET_OK != ret)
- {
- PQclear (res);
- return GNUNET_SYSERR;
- }
-
- GNUNET_PQ_cleanup_result(results_select);
- PQclear (res);
-
- return ret;
+ return GNUNET_OK;
}
@@ -1173,8 +1050,6 @@ state_assign (struct Plugin *plugin, const char *stmt,
const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
const char *name, const void *value, size_t value_size)
{
- PGresult *res;
-
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (channel_key),
GNUNET_PQ_query_param_string (name),
@@ -1182,16 +1057,9 @@ state_assign (struct Plugin *plugin, const char *stmt,
GNUNET_PQ_query_param_end
};
- res = GNUNET_PQ_exec_prepared (plugin->dbh, stmt, params);
- if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh,
- res,
- PGRES_COMMAND_OK,
- "PQexecPrepared", stmt))
- {
+ if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+ GNUNET_PQ_eval_prepared_non_select (plugin->dbh, stmt, params))
return GNUNET_SYSERR;
- }
-
- PQclear (res);
return GNUNET_OK;
}
@@ -1203,24 +1071,15 @@ update_message_id (struct Plugin *plugin,
const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
uint64_t message_id)
{
- PGresult *res;
-
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&message_id),
GNUNET_PQ_query_param_auto_from_type (channel_key),
GNUNET_PQ_query_param_end
};
- res = GNUNET_PQ_exec_prepared (plugin->dbh, stmt, params);
- if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh,
- res,
- PGRES_COMMAND_OK,
- "PQexecPrepared", stmt))
- {
+ if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+ GNUNET_PQ_eval_prepared_non_select (plugin->dbh, stmt, params))
return GNUNET_SYSERR;
- }
-
- PQclear (res);
return GNUNET_OK;
}
@@ -1431,10 +1290,7 @@ static int
state_get (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
const char *name, GNUNET_PSYCSTORE_StateCallback cb, void *cb_cls)
{
- PGresult *res;
-
struct Plugin *plugin = cls;
- int ret = GNUNET_SYSERR;
const char *stmt = "select_state_one";
@@ -1447,41 +1303,18 @@ state_get (void *cls, const struct
GNUNET_CRYPTO_EddsaPublicKey *channel_key,
void *value_current = NULL;
size_t value_size = 0;
- struct GNUNET_PQ_ResultSpec results[] = {
+ struct GNUNET_PQ_ResultSpec results_select[] = {
GNUNET_PQ_result_spec_variable_size ("value_current", &value_current,
&value_size),
GNUNET_PQ_result_spec_end
};
- res = GNUNET_PQ_exec_prepared (plugin->dbh, stmt, params_select);
- if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh,
- res,
- PGRES_TUPLES_OK,
- "PQexecPrepared", stmt))
- {
- return GNUNET_SYSERR;
- }
-
- if (PQntuples (res) == 0)
- {
- PQclear (res);
- ret = GNUNET_NO;
- }
-
- ret = GNUNET_PQ_extract_result (res, results, 0);
+ if (GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT !=
+ GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, stmt,
+ params_select, results_select))
+ return GNUNET_SYSERR;
- if (GNUNET_OK != ret)
- {
- PQclear (res);
- return GNUNET_SYSERR;
- }
-
- ret = cb (cb_cls, name, value_current,
+ return cb (cb_cls, name, value_current,
value_size);
-
- GNUNET_PQ_cleanup_result(results);
- PQclear (res);
-
- return ret;
}
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] branch master updated (b46cad2d4 -> 1a90e7878),
gnunet <=