aboutsummaryrefslogtreecommitdiff
path: root/src/shared/Database/DatabasePostgre.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-03-18 20:39:21 -0600
committermegamage <none@none>2009-03-18 20:39:21 -0600
commit1c8775258422f1c51f4aa363191f2386ff01cd08 (patch)
treecf5b2d240ffd44af6e03ff5fd4afe04ea4c75571 /src/shared/Database/DatabasePostgre.cpp
parent74a8d5a1accd77fe8020b8deb90087f85d58b93f (diff)
[7485] Added support for PostgreSQL connection using Unix sockets. Author: ApoC
For using socket connection specify host name as . and port as path to Unix socket directory or . for default path specified in PostgreSQL compile time. --HG-- branch : trunk
Diffstat (limited to 'src/shared/Database/DatabasePostgre.cpp')
-rw-r--r--src/shared/Database/DatabasePostgre.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/shared/Database/DatabasePostgre.cpp b/src/shared/Database/DatabasePostgre.cpp
index 502808b7933..79e1c87f5e3 100644
--- a/src/shared/Database/DatabasePostgre.cpp
+++ b/src/shared/Database/DatabasePostgre.cpp
@@ -79,14 +79,14 @@ bool DatabasePostgre::Initialize(const char *infoString)
Tokens::iterator iter;
- std::string host, port_or_socket, user, password, database;
+ std::string host, port_or_socket_dir, user, password, database;
iter = tokens.begin();
if(iter != tokens.end())
host = *iter++;
if(iter != tokens.end())
- port_or_socket = *iter++;
+ port_or_socket_dir = *iter++;
if(iter != tokens.end())
user = *iter++;
if(iter != tokens.end())
@@ -94,7 +94,10 @@ bool DatabasePostgre::Initialize(const char *infoString)
if(iter != tokens.end())
database = *iter++;
- mPGconn = PQsetdbLogin(host.c_str(), port_or_socket.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str());
+ if (host == ".")
+ mPGconn = PQsetdbLogin(NULL, port_or_socket_dir == "." ? NULL : port_or_socket_dir.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str());
+ else
+ mPGconn = PQsetdbLogin(host.c_str(), port_or_socket_dir.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str());
/* check to see that the backend connection was successfully made */
if (PQstatus(mPGconn) != CONNECTION_OK)