mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
specify server's port in conf file since at least on one of my
machines it's not what libpq expects. (Required by upgrade from 8.4 to 9.1.)
This commit is contained in:
parent
9ceb1615b3
commit
3d18e5832e
2 changed files with 16 additions and 5 deletions
|
@ -757,7 +757,9 @@ DBMgr::execSql( const char* const query )
|
|||
PGresult* result = PQexec( getThreadConn(), query );
|
||||
bool ok = PGRES_COMMAND_OK == PQresultStatus(result);
|
||||
if ( !ok ) {
|
||||
logf( XW_LOGERROR, "PQexec=>%s;%s", PQresStatus(PQresultStatus(result)), PQresultErrorMessage(result) );
|
||||
logf( XW_LOGERROR, "PQexec=>%s;%s", PQresStatus(PQresultStatus(result)),
|
||||
PQresultErrorMessage(result) );
|
||||
assert( 0 );
|
||||
}
|
||||
PQclear( result );
|
||||
return ok;
|
||||
|
@ -1143,12 +1145,19 @@ DBMgr::getThreadConn( void )
|
|||
|
||||
if ( NULL == conn ) {
|
||||
char buf[128];
|
||||
int len = snprintf( buf, sizeof(buf), "dbname = " );
|
||||
if ( !RelayConfigs::GetConfigs()->
|
||||
GetValueFor( "DB_NAME", &buf[len], sizeof(buf)-len ) ) {
|
||||
int port;
|
||||
if ( !RelayConfigs::GetConfigs()->GetValueFor( "DB_NAME", buf,
|
||||
sizeof(buf) ) ) {
|
||||
assert( 0 );
|
||||
}
|
||||
conn = PQconnectdb( buf );
|
||||
if ( !RelayConfigs::GetConfigs()->GetValueFor( "DB_PORT", &port ) ) {
|
||||
assert( 0 );
|
||||
}
|
||||
string params;
|
||||
string_printf( params, "dbname = %s ", buf );
|
||||
string_printf( params, "port = %d ", port );
|
||||
|
||||
conn = PQconnectdb( params.c_str() );
|
||||
pthread_setspecific( m_conn_key, conn );
|
||||
}
|
||||
return conn;
|
||||
|
|
|
@ -56,6 +56,8 @@ SERVERNAME=eehouse.org
|
|||
|
||||
# name of the database. (Table names are hard-coded.)
|
||||
DB_NAME=xwgames
|
||||
# UDP port postgres server is listening on
|
||||
DB_PORT=5433
|
||||
|
||||
# Initial level of logging. See xwrelay_priv.h for values. Currently
|
||||
# 0 means errors only, 1 info, 2 verbose and 3 very verbose.
|
||||
|
|
Loading…
Reference in a new issue