From c93465b51a2fd53f79a84bc2952add941309bf0d Mon Sep 17 00:00:00 2001 From: ApoC Date: Wed, 18 Mar 2009 12:06:11 +0100 Subject: [PATCH] [7485] Added support for PostgreSQL connection using Unix sockets. 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. Signed-off-by: ApoC --- src/mangosd/mangosd.conf.dist.in | 14 +++++++++----- src/shared/Database/DatabasePostgre.cpp | 9 ++++++--- src/shared/revision_nr.h | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in index 86c600194..03d14e2cd 100644 --- a/src/mangosd/mangosd.conf.dist.in +++ b/src/mangosd/mangosd.conf.dist.in @@ -25,11 +25,15 @@ ConfVersion=2008080101 # WorldDatabaseInfo # CharacterDatabaseInfo # Database connection settings for the world server. -# Default: hostname;port;username;password;database -# .;somenumber;username;password;database - use named pipes at Windows -# Named pipes: mySQL required adding "enable-named-pipe" to [mysqld] section my.ini -# .;/path/to/unix_socket;username;password;database - use Unix sockets at Unix/Linux -# Unix sockets: experimental, not tested +# Default: +# ---MYSQL--- +# hostname;port;username;password;database +# .;somenumber;username;password;database - use named pipes at Windows +# Named pipes: mySQL required adding "enable-named-pipe" to [mysqld] section my.ini +# .;/path/to/unix_socket;username;password;database - use Unix sockets at Unix/Linux +# ---PGSQL--- +# hostname;port;username;password;database +# .;/path/to/unix_socket/DIRECTORY or . for default path;username;password;database - use Unix sockets at Unix/Linux # # MaxPingTime # Settings for maximum database-ping interval (minutes between pings) diff --git a/src/shared/Database/DatabasePostgre.cpp b/src/shared/Database/DatabasePostgre.cpp index a572a8320..e8f713ee9 100644 --- a/src/shared/Database/DatabasePostgre.cpp +++ b/src/shared/Database/DatabasePostgre.cpp @@ -77,14 +77,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()) @@ -92,7 +92,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) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index bb7e6d2a1..dd78d4e99 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7484" + #define REVISION_NR "7485" #endif // __REVISION_NR_H__ -- 2.11.4.GIT