Re: Application name patch - v2

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Dave Page" <dpage(at)pgadmin(dot)org>
Cc: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, "Heikki Linnakangas" <heikki(dot)linnakangas(at)enterprisedb(dot)com>, "Harald Armin Massa" <chef(at)ghum(dot)de>, "Magnus Hagander" <magnus(at)hagander(dot)net>, "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Application name patch - v2
Date: 2009-10-21 16:12:16
Message-ID: 4ADEEC90020000250002BC4C@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dave Page <dpage(at)pgadmin(dot)org> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>
>> I also like PGAPPNAME better, for the same reasons as Tom.
>
> :-). Have to admit, I've mistyped it a few times too.

Well, it would seem we have consensus on that. :-)

I don't feel that the Java default issue reached the same level of
consensus, though. I think we can rule out anything beyond an
environment variable or system property as a non-null default. The
options seem to be:

(1) No non-null default. If they don't set it through the standard
techniques, the default is null.

(2) Use an environment variable.

(3) Use a system property.

(4) Some combination of (2) and (3), with one having precedence over
the other.

Here's what the Java documentation has to say about environment
variables versus system properties:

| System properties and environment variables are both conceptually
| mappings between names and values. Both mechanisms can be used to
| pass user-defined information to a Java process. Environment
| variables have a more global effect, because they are visible to all
| descendants of the process which defines them, not just the
| immediate Java subprocess. They can have subtly different semantics,
| such as case insensitivity, on different operating systems. For
| these reasons, environment variables are more likely to have
| unintended side effects. It is best to use system properties where
| possible. Environment variables should be used when a global effect
| is desired, or when an external system interface requires an
| environment variable (such as PATH).

It would be zero lines of programming to support *setting* either or
both, just documenting it and very simple code to use either. For
example, assuming the code to support the standard setting is written,
we could allow both defaults for cases where it isn't explicitly set,
with precedence given to the system property; and the entire
programming effort would look something like this:

if (appName == null)
appName = System.getProperty("PGAPPNAME",
System.getenv("PGAPPNAME"));

So the coding involved isn't overwhelming. :-)

The primary use case would be to allow someone with an existing
application to set this without changing or recompiling any Java code
-- they could just set the value in the launch script.

Does anyone have an opinion on this?

-Kevin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Samuel ROZE 2009-10-21 16:13:32 Re: URL Managment - C Function help
Previous Message Dave Page 2009-10-21 15:47:22 Re: Client application name