1
0
mirror of https://github.com/haiwen/ccnet-server.git synced 2025-09-05 14:50:21 +00:00

Postgresql port setting

This commit is contained in:
cuihaikuo
2017-01-16 16:28:02 +08:00
parent 8d586a7b5e
commit 3084f6bbca
7 changed files with 23 additions and 3 deletions

View File

@@ -8,6 +8,7 @@
typedef struct PGDBConnPool {
DBConnPool parent;
char *host;
unsigned int port;
char *user;
char *password;
char *db_name;
@@ -16,6 +17,7 @@ typedef struct PGDBConnPool {
DBConnPool *
pgsql_db_conn_pool_new (const char *host,
unsigned int port,
const char *user,
const char *password,
const char *db_name,
@@ -24,6 +26,7 @@ pgsql_db_conn_pool_new (const char *host,
PGDBConnPool *pool = g_new0 (PGDBConnPool, 1);
pool->host = g_strdup (host);
pool->port = port;
pool->user = g_strdup (user);
pool->password = g_strdup (password);
pool->db_name = g_strdup(db_name);
@@ -88,6 +91,10 @@ connect_pgsql (PGDBConnPool *pool, GError **error)
g_string_append_printf (buf, "host='%s' ", pool->host);
}
if (pool->port > 0) {
g_string_append_printf (buf, "port=%u ", pool->port);
}
g_string_append_printf (buf, "dbname='%s' ", pool->db_name);
db = PQconnectdb (buf->str);