Added setting for client_encoding of the PostgreSQL connection.
git-svn-id: http://voip.null.ro/svn/yate@2530 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
a5b79ca801
commit
730b3c4ccf
|
@ -16,6 +16,10 @@
|
||||||
; retry: int: How many times to retry the connection or query
|
; retry: int: How many times to retry the connection or query
|
||||||
;retry=5
|
;retry=5
|
||||||
|
|
||||||
|
; encoding: string: Character set encoding used to communicate with the server
|
||||||
|
; If not set will match the encoding of server side database
|
||||||
|
;encoding=
|
||||||
|
|
||||||
; connection: string: Ready-built client connection string for PQconnectStart
|
; connection: string: Ready-built client connection string for PQconnectStart
|
||||||
; If this is not set the string is built from the following pieces
|
; If this is not set the string is built from the following pieces
|
||||||
; Take care if you set this - it will override anything that follows
|
; Take care if you set this - it will override anything that follows
|
||||||
|
|
|
@ -56,6 +56,7 @@ private:
|
||||||
bool startDb();
|
bool startDb();
|
||||||
int queryDbInternal(const char* query, Message* dest);
|
int queryDbInternal(const char* query, Message* dest);
|
||||||
String m_name,m_connection;
|
String m_name,m_connection;
|
||||||
|
String m_encoding;
|
||||||
int m_retry;
|
int m_retry;
|
||||||
u_int64_t m_timeout;
|
u_int64_t m_timeout;
|
||||||
PGconn *m_conn;
|
PGconn *m_conn;
|
||||||
|
@ -107,6 +108,7 @@ DbConn::DbConn(const NamedList* sect)
|
||||||
if (m_timeout < 500000)
|
if (m_timeout < 500000)
|
||||||
m_timeout = 500000;
|
m_timeout = 500000;
|
||||||
m_retry = sect->getIntValue("retry",5);
|
m_retry = sect->getIntValue("retry",5);
|
||||||
|
m_encoding = sect->getValue("encoding");
|
||||||
}
|
}
|
||||||
|
|
||||||
DbConn::~DbConn()
|
DbConn::~DbConn()
|
||||||
|
@ -139,6 +141,9 @@ bool DbConn::initDb(int retry)
|
||||||
return false;
|
return false;
|
||||||
case CONNECTION_OK:
|
case CONNECTION_OK:
|
||||||
Debug(&module,DebugAll,"Connection for '%s' succeeded",m_name.c_str());
|
Debug(&module,DebugAll,"Connection for '%s' succeeded",m_name.c_str());
|
||||||
|
if (m_encoding && PQsetClientEncoding(m_conn,m_encoding))
|
||||||
|
Debug(&module,DebugWarn,"Failed to set encoding '%s' on connection '%s'",
|
||||||
|
m_encoding.c_str(),m_name.c_str());
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue