Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 committed Feb 27, 2011
1 parent cf1afa2 commit ed9af81
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/app/postgres/qgspgnewconnection.cpp
Expand Up @@ -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 )
{
Expand All @@ -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 )
Expand Down
10 changes: 5 additions & 5 deletions src/app/postgres/qgspgsourceselect.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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 )
{
Expand All @@ -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 )
Expand Down Expand Up @@ -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() );
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/spit/qgsspit.cpp
Expand Up @@ -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 )
Expand Down
4 changes: 2 additions & 2 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -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 )
{
Expand All @@ -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 )
Expand Down

0 comments on commit ed9af81

Please sign in to comment.