summaryrefslogtreecommitdiff
path: root/controller/PostgreSQL.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'controller/PostgreSQL.cpp')
-rw-r--r--controller/PostgreSQL.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp
index 4a33e4b6..412bca6b 100644
--- a/controller/PostgreSQL.cpp
+++ b/controller/PostgreSQL.cpp
@@ -23,6 +23,7 @@
#include "../version.h"
#include <libpq-fe.h>
+#include <sstream>
using json = nlohmann::json;
namespace {
@@ -200,6 +201,10 @@ void PostgreSQL::initializeNetworks(PGconn *conn)
json empty;
json config;
+ const char *nwidparam[1] = {
+ PQgetvalue(res, i, 0)
+ };
+
config["id"] = PQgetvalue(res, i, 0);
config["nwid"] = PQgetvalue(res, i, 0);
config["creationTime"] = std::stoull(PQgetvalue(res, i, 1));
@@ -225,7 +230,7 @@ void PostgreSQL::initializeNetworks(PGconn *conn)
"SELECT host(ip_range_start), host(ip_range_end) FROM ztc_network_assignment_pool WHERE network_id = $1",
1,
NULL,
- params,
+ nwidparam,
NULL,
NULL,
0);
@@ -252,7 +257,7 @@ void PostgreSQL::initializeNetworks(PGconn *conn)
"SELECT host(address), bits, host(via) FROM ztc_network_route WHERE network_id = $1",
1,
NULL,
- params,
+ nwidparam,
NULL,
NULL,
0);
@@ -284,6 +289,8 @@ void PostgreSQL::initializeNetworks(PGconn *conn)
PQclear(r2);
_networkChanged(empty, config, false);
+
+ fprintf(stderr, "%s", OSUtils::jsonDump(config, 2).c_str());
}
PQclear(res);
@@ -1234,4 +1241,4 @@ void PostgreSQL::onlineNotificationThread()
}
PQfinish(conn);
}
-#endif //ZT_CONTROLLER_USE_LIBPQ \ No newline at end of file
+#endif //ZT_CONTROLLER_USE_LIBPQ