Skip to content
Permalink
Browse files

postgres support: include application_name in connections

git-svn-id: http://svn.osgeo.org/qgis/trunk@15280 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Feb 27, 2011
1 parent cf1afa2 commit ed9af81226f9478dbff4fea7b8d2f2e0278854f3
@@ -178,7 +178,7 @@ void QgsPgNewConnection::testConnection()
QString conninfo = uri.connectionInfo();
QgsDebugMsg( "PQconnectdb(\"" + conninfo + "\");" );

PGconn *pd = PQconnectdb( conninfo.toLocal8Bit() ); // use what is set based on locale; after connecting, use Utf8
PGconn *pd = PQconnectdb(( conninfo + " application_name='Quantum GIS'" ).toLocal8Bit() ); // use what is set based on locale; after connecting, use Utf8
// check the connection status
if ( PQstatus( pd ) != CONNECTION_OK )
{
@@ -205,7 +205,7 @@ void QgsPgNewConnection::testConnection()
uri.setPassword( password );

QgsDebugMsg( "PQconnectdb(\"" + uri.connectionInfo() + "\");" );
pd = PQconnectdb( uri.connectionInfo().toLocal8Bit() );
pd = PQconnectdb(( uri.connectionInfo() + " application_name='Quantum GIS'" ).toLocal8Bit() );
}

if ( PQstatus( pd ) == CONNECTION_OK )
@@ -164,8 +164,8 @@ void QgsPgSourceSelect::saveClicked()

void QgsPgSourceSelect::loadClicked()
{
QString fileName = QFileDialog::getOpenFileName( this, tr( "Load connections )" ), ".",
tr( "XML files (*.xml *XML)" ) );
QString fileName = QFileDialog::getOpenFileName( this, tr( "Load connections" ), ".",
tr( "XML files (*.xml *XML)" ) );
if ( fileName.isEmpty() )
{
return;
@@ -458,7 +458,7 @@ void QgsPgSourceSelect::on_btnConnect_clicked()

m_privConnInfo = m_connInfo;

pd = PQconnectdb( m_privConnInfo.toLocal8Bit() ); // use what is set based on locale; after connecting, use Utf8
pd = PQconnectdb(( m_privConnInfo + " application_name='Quantum GIS'" ).toLocal8Bit() ); // use what is set based on locale; after connecting, use Utf8
// check the connection status
if ( PQstatus( pd ) != CONNECTION_OK )
{
@@ -479,7 +479,7 @@ void QgsPgSourceSelect::on_btnConnect_clicked()

m_privConnInfo = uri.connectionInfo();
QgsDebugMsg( "connecting " + m_privConnInfo );
pd = PQconnectdb( m_privConnInfo.toLocal8Bit() );
pd = PQconnectdb(( m_privConnInfo + " application_name='Quantum GIS'" ).toLocal8Bit() );
}

if ( PQstatus( pd ) == CONNECTION_OK )
@@ -949,7 +949,7 @@ void QgsGeomColumnTypeThread::getLayerTypes()
{
mStopped = false;

PGconn *pd = PQconnectdb( mConnInfo.toLocal8Bit() );
PGconn *pd = PQconnectdb(( mConnInfo + " application_name='Quantum GIS'" ).toLocal8Bit() );
if ( PQstatus( pd ) == CONNECTION_OK )
{
PQsetClientEncoding( pd, QString( "UNICODE" ).toLocal8Bit() );
@@ -410,7 +410,7 @@ void QgsSpit::dbConnect()
password,
( QgsDataSourceURI::SSLmode ) settings.value( key + "/sslmode", QgsDataSourceURI::SSLprefer ).toInt() );

conn = PQconnectdb( uri.connectionInfo().toUtf8() );
conn = PQconnectdb(( uri.connectionInfo() + " application_name='Quantum GIS'" ).toUtf8() );
}

if ( conn == NULL || PQstatus( conn ) != CONNECTION_OK )
@@ -213,7 +213,7 @@ QgsPostgresProvider::Conn *QgsPostgresProvider::Conn::connectDb( const QString &

QgsDebugMsg( QString( "New postgres connection for " ) + conninfo );

PGconn *pd = PQconnectdb( conninfo.toLocal8Bit() ); // use what is set based on locale; after connecting, use Utf8
PGconn *pd = PQconnectdb(( conninfo + " application_name='Quantum GIS'" ).toLocal8Bit() ); // use what is set based on locale; after connecting, use Utf8
// check the connection status
if ( PQstatus( pd ) != CONNECTION_OK )
{
@@ -236,7 +236,7 @@ QgsPostgresProvider::Conn *QgsPostgresProvider::Conn::connectDb( const QString &
uri.setPassword( password );

QgsDebugMsg( "Connecting to " + uri.connectionInfo() );
pd = PQconnectdb( uri.connectionInfo().toLocal8Bit() );
pd = PQconnectdb(( uri.connectionInfo() + " application_name='Quantum GIS'" ).toLocal8Bit() );
}

if ( PQstatus( pd ) == CONNECTION_OK )

0 comments on commit ed9af81

Please sign in to comment.
You can’t perform that action at this time.