Set the “application name” under Server Status

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
ccampbell
Posts: 29
Joined: Tue 01 Jun 2010 17:31
Location: Oregon

Set the “application name” under Server Status

Post by ccampbell » Thu 21 Oct 2010 17:28

Hi, using devart.data.PostgresSql 5.0.10.0

When I create a connection to a Postgres database, that connection appears under "server status" of the pgAdmin III program. However, the “application name” column of my connection is blank. I see that the active connections that appear for the pgAdmin program show that their application name is pgAdmin which is correct.

My question is how do I set the "application name" so it will appear in the column under active connections? I need to see what application “owns” the given active data connection. I’m guessing it’s when I create the data connection object somewhere but I can’t figure out which property to set.

Thanks for your help

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 25 Oct 2010 15:11

Thank you for your report. This feature ("Application name") was implemented in pgAdmin 1.12. I will post here when we add support for it in dotConnect for PostgreSQL.

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 01 Dec 2010 17:17

This is a designed behaviour. It is necessary to perform an additional query to database on the current connection to set Application name:
set application_name = '{0}'
{0} - application name

Code: Select all

    PgSqlConnection conn = new PgSqlConnection();
    conn.ConnectionString = "server=localhost;port=5433;uid=postgres;pwd=postgres;database=postgres;";
    conn.Open();
    //Application name is not set
    PgSqlCommand cmd = conn.CreateCommand();
    cmd.CommandText = "set application_name = 'myApp'";
    cmd.ExecuteNonQuery();
    //Application name is set to 'myApp'
    conn.Close();
By default, this query is not executed by our provider because of the performance considerations.

Post Reply