diff options
author | David Barksdale <amatus.amongus@gmail.com> | 2015-01-06 01:11:45 +0000 |
---|---|---|
committer | David Barksdale <amatus.amongus@gmail.com> | 2015-01-06 01:11:45 +0000 |
commit | 55182581d5e44ccc8d7495efd60a8f913d5b057d (patch) | |
tree | 219343d5a8d8c02bcb31dd10945dc98a491c340c /src/datastore/plugin_datastore_postgres.c | |
parent | 56342b51c42bba7f627de23cde834994171fb267 (diff) |
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.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index e9495d35e3..e7f7a7dd52 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c @@ -228,13 +228,15 @@ init_connection (struct Plugin *plugin) * @param cls our `struct Plugin *` * @return number of bytes used on disk */ -static unsigned long long -postgres_plugin_estimate_size (void *cls) +static void +postgres_plugin_estimate_size (void *cls, unsigned long long *estimate) { struct Plugin *plugin = cls; unsigned long long total; PGresult *ret; + if (NULL == estimate) + return; ret = PQexecParams (plugin->dbh, "SELECT SUM(LENGTH(value))+256*COUNT(*) FROM gn090", 0, @@ -242,23 +244,26 @@ postgres_plugin_estimate_size (void *cls) if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh, ret, PGRES_TUPLES_OK, "PQexecParams", "get_size")) { - return 0; + *estimate = 0; + return; } if ((PQntuples (ret) != 1) || (PQnfields (ret) != 1) ) { GNUNET_break (0); PQclear (ret); - return 0; + *estimate = 0; + return; } if (PQgetlength (ret, 0, 0) != sizeof (unsigned long long)) { GNUNET_break (0 == PQgetlength (ret, 0, 0)); PQclear (ret); - return 0; + *estimate = 0; + return; } total = GNUNET_ntohll (*(const unsigned long long *) PQgetvalue (ret, 0, 0)); PQclear (ret); - return total; + *estimate = total; } |