aboutsummaryrefslogtreecommitdiff
path: root/src/datastore/plugin_datastore_postgres.c
diff options
context:
space:
mode:
authorDavid Barksdale <amatus@amat.us>2017-02-20 13:08:08 -0600
committerDavid Barksdale <amatus@amat.us>2017-02-20 13:11:19 -0600
commitfe4f6e8cedfa8d0a57b0247727fc4849d38c2f3a (patch)
treecbcbc99a93ec8f466426190a340cc46f54d2641e /src/datastore/plugin_datastore_postgres.c
parentf553963d649374a75cc5a6e57df39d83565eb913 (diff)
downloadgnunet-fe4f6e8cedfa8d0a57b0247727fc4849d38c2f3a.tar.gz
gnunet-fe4f6e8cedfa8d0a57b0247727fc4849d38c2f3a.zip
Restrict update to positive priority deltas
This is only ever called with positive values and the mysql and postgres plugins were not handling negative values correctly anyway.
Diffstat (limited to 'src/datastore/plugin_datastore_postgres.c')
-rw-r--r--src/datastore/plugin_datastore_postgres.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c
index 994118bfa..7b04cc68a 100644
--- a/src/datastore/plugin_datastore_postgres.c
+++ b/src/datastore/plugin_datastore_postgres.c
@@ -76,6 +76,11 @@ init_connection (struct Plugin *plugin)
76 if (NULL == plugin->dbh) 76 if (NULL == plugin->dbh)
77 return GNUNET_SYSERR; 77 return GNUNET_SYSERR;
78 78
79 /* FIXME: PostgreSQL does not have unsigned integers! This is ok for the type column because
80 * we only test equality on it and can cast it to/from uint32_t. For repl, prio, and anonLevel
81 * we do math or inequality tests, so we can't handle the entire range of uint32_t.
82 * This will also cause problems for expiration times after 294247-01-10-04:00:54 UTC.
83 */
79 ret = 84 ret =
80 PQexec (plugin->dbh, 85 PQexec (plugin->dbh,
81 "CREATE TABLE IF NOT EXISTS gn090 (" 86 "CREATE TABLE IF NOT EXISTS gn090 ("
@@ -869,9 +874,7 @@ postgres_plugin_get_expiration (void *cls,
869 * @param cls our `struct Plugin *` 874 * @param cls our `struct Plugin *`
870 * @param uid unique identifier of the datum 875 * @param uid unique identifier of the datum
871 * @param delta by how much should the priority 876 * @param delta by how much should the priority
872 * change? If priority + delta < 0 the 877 * change?
873 * priority should be set to 0 (never go
874 * negative).
875 * @param expire new expiration time should be the 878 * @param expire new expiration time should be the
876 * MAX of any existing expiration time and 879 * MAX of any existing expiration time and
877 * this value 880 * this value
@@ -881,16 +884,15 @@ postgres_plugin_get_expiration (void *cls,
881static void 884static void
882postgres_plugin_update (void *cls, 885postgres_plugin_update (void *cls,
883 uint64_t uid, 886 uint64_t uid,
884 int delta, 887 uint32_t delta,
885 struct GNUNET_TIME_Absolute expire, 888 struct GNUNET_TIME_Absolute expire,
886 PluginUpdateCont cont, 889 PluginUpdateCont cont,
887 void *cont_cls) 890 void *cont_cls)
888{ 891{
889 struct Plugin *plugin = cls; 892 struct Plugin *plugin = cls;
890 uint32_t idelta = delta;
891 uint32_t oid = (uint32_t) uid; 893 uint32_t oid = (uint32_t) uid;
892 struct GNUNET_PQ_QueryParam params[] = { 894 struct GNUNET_PQ_QueryParam params[] = {
893 GNUNET_PQ_query_param_uint32 (&idelta), 895 GNUNET_PQ_query_param_uint32 (&delta),
894 GNUNET_PQ_query_param_absolute_time (&expire), 896 GNUNET_PQ_query_param_absolute_time (&expire),
895 GNUNET_PQ_query_param_uint32 (&oid), 897 GNUNET_PQ_query_param_uint32 (&oid),
896 GNUNET_PQ_query_param_end 898 GNUNET_PQ_query_param_end