aboutsummaryrefslogtreecommitdiff
path: root/src/datacache/plugin_datacache_postgres.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-02-23 00:30:36 +0100
committerChristian Grothoff <christian@grothoff.org>2022-02-23 00:30:36 +0100
commit0209b47aeddf61686fe08e946d8909860cfb161a (patch)
tree5e683a11dbb6698d97ed6363ab80fe36c3fef38b /src/datacache/plugin_datacache_postgres.c
parent020df0bf2999e990806b72356c9a477b31b0142c (diff)
downloadgnunet-0209b47aeddf61686fe08e946d8909860cfb161a.tar.gz
gnunet-0209b47aeddf61686fe08e946d8909860cfb161a.zip
-fix datacache to return 2x num_closest in both directions
Diffstat (limited to 'src/datacache/plugin_datacache_postgres.c')
-rw-r--r--src/datacache/plugin_datacache_postgres.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c
index 4e48d89df..1a83cda86 100644
--- a/src/datacache/plugin_datacache_postgres.c
+++ b/src/datacache/plugin_datacache_postgres.c
@@ -108,14 +108,20 @@ init_connection (struct Plugin *plugin)
108 "SELECT length(value) AS len,oid,key FROM gn011dc" 108 "SELECT length(value) AS len,oid,key FROM gn011dc"
109 " ORDER BY prox ASC, discard_time ASC LIMIT 1", 109 " ORDER BY prox ASC, discard_time ASC LIMIT 1",
110 0), 110 0),
111 /* FIXME: do key >= ASC + UNION key <= DESC! */
112 GNUNET_PQ_make_prepare ("get_closest", 111 GNUNET_PQ_make_prepare ("get_closest",
113 "SELECT discard_time,type,value,path,key FROM gn011dc" 112 "(SELECT discard_time,type,value,path,key FROM gn011dc"
114 " WHERE key >= $1" 113 " WHERE key >= $1"
115 " AND discard_time >= $2" 114 " AND discard_time >= $2"
116 " AND ( (type = $3) OR ( 0 = $3) )" 115 " AND ( (type = $3) OR ( 0 = $3) )"
117 " ORDER BY key ASC" 116 " ORDER BY key ASC"
118 " LIMIT $4", 117 " LIMIT $4)"
118 " UNION "
119 "(SELECT discard_time,type,value,path,key FROM gn011dc"
120 " WHERE key <= $1"
121 " AND discard_time >= $2"
122 " AND ( (type = $3) OR ( 0 = $3) )"
123 " ORDER BY key DESC"
124 " LIMIT $4)",
119 4), 125 4),
120 GNUNET_PQ_make_prepare ("delrow", 126 GNUNET_PQ_make_prepare ("delrow",
121 "DELETE FROM gn011dc WHERE oid=$1", 127 "DELETE FROM gn011dc WHERE oid=$1",