aboutsummaryrefslogtreecommitdiff
path: root/src/datastore/plugin_datastore_postgres.c
diff options
context:
space:
mode:
authorDavid Barksdale <amatus.amongus@gmail.com>2015-01-06 01:11:45 +0000
committerDavid Barksdale <amatus.amongus@gmail.com>2015-01-06 01:11:45 +0000
commit55182581d5e44ccc8d7495efd60a8f913d5b057d (patch)
tree219343d5a8d8c02bcb31dd10945dc98a491c340c /src/datastore/plugin_datastore_postgres.c
parent56342b51c42bba7f627de23cde834994171fb267 (diff)
downloadgnunet-55182581d5e44ccc8d7495efd60a8f913d5b057d.tar.gz
gnunet-55182581d5e44ccc8d7495efd60a8f913d5b057d.zip
Workaround emscripten bug in returning int64_t
Emscripten can't return a 64-bit integer from dynamically loaded code.
Diffstat (limited to 'src/datastore/plugin_datastore_postgres.c')
-rw-r--r--src/datastore/plugin_datastore_postgres.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c
index e9495d35e..e7f7a7dd5 100644
--- a/src/datastore/plugin_datastore_postgres.c
+++ b/src/datastore/plugin_datastore_postgres.c
@@ -228,13 +228,15 @@ init_connection (struct Plugin *plugin)
228 * @param cls our `struct Plugin *` 228 * @param cls our `struct Plugin *`
229 * @return number of bytes used on disk 229 * @return number of bytes used on disk
230 */ 230 */
231static unsigned long long 231static void
232postgres_plugin_estimate_size (void *cls) 232postgres_plugin_estimate_size (void *cls, unsigned long long *estimate)
233{ 233{
234 struct Plugin *plugin = cls; 234 struct Plugin *plugin = cls;
235 unsigned long long total; 235 unsigned long long total;
236 PGresult *ret; 236 PGresult *ret;
237 237
238 if (NULL == estimate)
239 return;
238 ret = 240 ret =
239 PQexecParams (plugin->dbh, 241 PQexecParams (plugin->dbh,
240 "SELECT SUM(LENGTH(value))+256*COUNT(*) FROM gn090", 0, 242 "SELECT SUM(LENGTH(value))+256*COUNT(*) FROM gn090", 0,
@@ -242,23 +244,26 @@ postgres_plugin_estimate_size (void *cls)
242 if (GNUNET_OK != 244 if (GNUNET_OK !=
243 GNUNET_POSTGRES_check_result (plugin->dbh, ret, PGRES_TUPLES_OK, "PQexecParams", "get_size")) 245 GNUNET_POSTGRES_check_result (plugin->dbh, ret, PGRES_TUPLES_OK, "PQexecParams", "get_size"))
244 { 246 {
245 return 0; 247 *estimate = 0;
248 return;
246 } 249 }
247 if ((PQntuples (ret) != 1) || (PQnfields (ret) != 1) ) 250 if ((PQntuples (ret) != 1) || (PQnfields (ret) != 1) )
248 { 251 {
249 GNUNET_break (0); 252 GNUNET_break (0);
250 PQclear (ret); 253 PQclear (ret);
251 return 0; 254 *estimate = 0;
255 return;
252 } 256 }
253 if (PQgetlength (ret, 0, 0) != sizeof (unsigned long long)) 257 if (PQgetlength (ret, 0, 0) != sizeof (unsigned long long))
254 { 258 {
255 GNUNET_break (0 == PQgetlength (ret, 0, 0)); 259 GNUNET_break (0 == PQgetlength (ret, 0, 0));
256 PQclear (ret); 260 PQclear (ret);
257 return 0; 261 *estimate = 0;
262 return;
258 } 263 }
259 total = GNUNET_ntohll (*(const unsigned long long *) PQgetvalue (ret, 0, 0)); 264 total = GNUNET_ntohll (*(const unsigned long long *) PQgetvalue (ret, 0, 0));
260 PQclear (ret); 265 PQclear (ret);
261 return total; 266 *estimate = total;
262} 267}
263 268
264 269