Re: Relocatable locale

Lists: pgsql-patches
From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Relocatable locale
Date: 2004-05-25 00:59:28
Message-ID: 200405250059.i4P0xSB22857@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Magnus found out that LOCALEDIR wasn't being handled in a relocatable
manner.

This patch fixes that. It also adjusts the get_*_path functions to
limit values to MAXPGPATH.

I have two questions. First, setlocale() seemed to be inconsistently
set inside and outside of ENABLE_NLS. I assume the proper location is
inside. Second, libpq has a locale setting for error messages, but a
libpq program could be in any directory, so I see no way to make that
relocatable. Instead, I just use the hardcoded path. I could make it
relocatable, but that seems to error-prone, plus I would have to look up
the exec path and stuff, and it seemed too complicated.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 29.1 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-25 01:29:30
Message-ID: 16158.1085448570@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> I have two questions. First, setlocale() seemed to be inconsistently
> set inside and outside of ENABLE_NLS. I assume the proper location is
> inside.

Please do *not* go adding setlocale calls that were not there before.
You *will* break things.

> ! setlocale(LC_ALL, "");
^^^^^^^^^^^^^^^^^^^^^

Putting this call in the backend is a very serious mistake. It might be
okay in clients, but not in the backend.

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-25 01:41:46
Message-ID: 200405250141.i4P1fkg29764@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > I have two questions. First, setlocale() seemed to be inconsistently
> > set inside and outside of ENABLE_NLS. I assume the proper location is
> > inside.
>
> Please do *not* go adding setlocale calls that were not there before.
> You *will* break things.
>
> > ! setlocale(LC_ALL, "");
> ^^^^^^^^^^^^^^^^^^^^^
>
> Putting this call in the backend is a very serious mistake. It might be
> okay in clients, but not in the backend.

OK, patch applied. Turns out it was only added for the backend
("postgres").

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 722 bytes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-25 01:47:53
Message-ID: 16396.1085449673@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> OK, patch applied. Turns out it was only added for the backend
> ("postgres").

Hm? Isn't that code going to be executed in postmaster, bootstrap,
checkpoint processes, etc etc?

I don't really believe that path.c has any business doing this at
all, in any program.

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-25 01:53:35
Message-ID: 200405250153.i4P1rZr01946@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > OK, patch applied. Turns out it was only added for the backend
> > ("postgres").
>
> Hm? Isn't that code going to be executed in postmaster, bootstrap,
> checkpoint processes, etc etc?
>
> I don't really believe that path.c has any business doing this at
> all, in any program.

Well, all our client apps used to do it in their own code. Now they
call set_pglocale to do it centrally and relocabably.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-25 01:56:02
Message-ID: 16525.1085450162@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Tom Lane wrote:
>> I don't really believe that path.c has any business doing this at
>> all, in any program.

> Well, all our client apps used to do it in their own code. Now they
> call set_pglocale to do it centrally and relocabably.

I don't care if the clients do it. I don't want main.c doing it.

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-25 01:59:40
Message-ID: 200405250159.i4P1xeP08496@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Tom Lane wrote:
> >> I don't really believe that path.c has any business doing this at
> >> all, in any program.
>
> > Well, all our client apps used to do it in their own code. Now they
> > call set_pglocale to do it centrally and relocabably.
>
> I don't care if the clients do it. I don't want main.c doing it.

Well, as coded now, it will behave the same.

The old code has in main.c:

- bindtextdomain("postgres", LOCALEDIR);
- textdomain("postgres");

and now it has a call to set_pgsetlocale which does:

if (find_my_exec(argv0, my_exec_path) < 0)
return;

get_locale_path(argv0, path);
bindtextdomain(app, path);
textdomain(app);

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 860 bytes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-25 02:08:16
Message-ID: 16664.1085450896@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Well, as coded now, it will behave the same.

No it won't: as you have it, the postmaster and everything else that
goes through main.c will execute a setlocale call, which was not there
before for very good reasons.

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-25 02:12:52
Message-ID: 200405250212.i4P2CqP22074@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Well, as coded now, it will behave the same.
>
> No it won't: as you have it, the postmaster and everything else that
> goes through main.c will execute a setlocale call, which was not there
> before for very good reasons.

I don't understand. I moved it up little in the file, but those calls
were happening in that file before, just a little lower.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-25 02:36:28
Message-ID: 16916.1085452588@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> I don't understand. I moved it up little in the file, but those calls
> were happening in that file before, just a little lower.

No, *that* call wasn't happening at all. The calls that were there
were setting certain limited, safe LC categories. You added a call
that sets *all* LC categories, including ones we do not want changed.
See the discussion in src/backend/utils/adt/pg_locale.c.

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-25 02:37:36
Message-ID: 200405250237.i4P2baR25638@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > I don't understand. I moved it up little in the file, but those calls
> > were happening in that file before, just a little lower.
>
> No, *that* call wasn't happening at all. The calls that were there
> were setting certain limited, safe LC categories. You added a call
> that sets *all* LC categories, including ones we do not want changed.
> See the discussion in src/backend/utils/adt/pg_locale.c.

But I added code to path.c to skip that if the app is "postgres". Why
doesn't that work?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-25 02:45:21
Message-ID: 17021.1085453121@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> But I added code to path.c to skip that if the app is "postgres". Why
> doesn't that work?

That will work fine ... for a standalone backend. Not so fine for
postmaster or bootstrap or other cases that go through main.c.

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-25 02:47:31
Message-ID: 200405250247.i4P2lV527003@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > But I added code to path.c to skip that if the app is "postgres". Why
> > doesn't that work?
>
> That will work fine ... for a standalone backend. Not so fine for
> postmaster or bootstrap or other cases that go through main.c.

But they all use the app name of "postgres". They always did.

That is not 'progname' but a hardcoded appname that is used in the
main.c call.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-25 02:54:21
Message-ID: 17131.1085453661@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> But they all use the app name of "postgres". They always did.

Oh! Sorry, I'm barking up the wrong tree then. I was thinking you were
looking at the exec_path.

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-25 03:09:31
Message-ID: 200405250309.i4P39VF29581@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > But they all use the app name of "postgres". They always did.
>
> Oh! Sorry, I'm barking up the wrong tree then. I was thinking you were
> looking at the exec_path.

Nope, hard-coded, as they all are. I could pull from argv[0], but that
doesn't work in too many cases. The main.c call is:

set_pglocale(argv[0], "postgres");

and is the same no matter what is coming through main.c.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-26 17:14:11
Message-ID: 200405261914.11887.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian wrote:
> I have two questions. First, setlocale() seemed to be inconsistently
> set inside and outside of ENABLE_NLS. I assume the proper location
> is inside.

No, in case of doubt it's outside.

> Second, libpq has a locale setting for error messages,
> but a libpq program could be in any directory, so I see no way to
> make that relocatable. Instead, I just use the hardcoded path. I
> could make it relocatable, but that seems to error-prone, plus I
> would have to look up the exec path and stuff, and it seemed too
> complicated.

Hmm, so this says that a relocatable install isn't in fact possible?


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-26 18:59:51
Message-ID: 200405261859.i4QIxpv08623@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Peter Eisentraut wrote:
> Bruce Momjian wrote:
> > I have two questions. First, setlocale() seemed to be inconsistently
> > set inside and outside of ENABLE_NLS. I assume the proper location
> > is inside.
>
> No, in case of doubt it's outside.

OK, moved. New code is:

void
set_pglocale(const char *argv0, const char *app)
{
#ifdef ENABLE_NLS
char path[MAXPGPATH];
char my_exec_path[MAXPGPATH];
#endif

/* don't set LC_ALL in the backend */
if (strcmp(app, "postgres") != 0)
setlocale(LC_ALL, "");

#ifdef ENABLE_NLS
if (find_my_exec(argv0, my_exec_path) < 0)
return;

get_locale_path(my_exec_path, path);
bindtextdomain(app, path);
textdomain(app);
#endif
}

>
> > Second, libpq has a locale setting for error messages,
> > but a libpq program could be in any directory, so I see no way to
> > make that relocatable. Instead, I just use the hardcoded path. I
> > could make it relocatable, but that seems to error-prone, plus I
> > would have to look up the exec path and stuff, and it seemed too
> > complicated.
>
> Hmm, so this says that a relocatable install isn't in fact possible?

Yep. I don't see how you can have a library know where to look for its
localized messages. The only thing I can think of is an environment
variable to override the hard-coded default. How is that?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-26 19:48:19
Message-ID: 40B4F483.2030001@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian wrote:

> Yep. I don't see how you can have a library know where to look for its
>
>localized messages. The only thing I can think of is an environment
>variable to override the hard-coded default. How is that?
>
>
>

I'm confused. Can you explain the problem more clearly, please? Do we
need to distinguish known apps with a known (relative) message location,
from unknown libpq clients?

cheers

andrew


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-26 20:12:25
Message-ID: 200405262212.25850.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Andrew Dunstan wrote:
> I'm confused. Can you explain the problem more clearly, please? Do we
> need to distinguish known apps with a known (relative) message
> location, from unknown libpq clients?

The problem boils down to the fact that libpq needs to find its data
files (in this case locale data, but it could be anything), but it
doesn't know its own location, so it can't use a relative path
reference as has been proposed.


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-27 00:31:13
Message-ID: 200405270031.i4R0VDt03772@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Peter Eisentraut wrote:
> Andrew Dunstan wrote:
> > I'm confused. Can you explain the problem more clearly, please? Do we
> > need to distinguish known apps with a known (relative) message
> > location, from unknown libpq clients?
>
> The problem boils down to the fact that libpq needs to find its data
> files (in this case locale data, but it could be anything), but it
> doesn't know its own location, so it can't use a relative path
> reference as has been proposed.

I am wondering if we should use environment variables, and have our apps
use putenv() to set it to the proper relative path.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-27 00:59:46
Message-ID: 40B53D82.5020201@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian wrote:

>Peter Eisentraut wrote:
>
>
>>Andrew Dunstan wrote:
>>
>>
>>>I'm confused. Can you explain the problem more clearly, please? Do we
>>>need to distinguish known apps with a known (relative) message
>>>location, from unknown libpq clients?
>>>
>>>
>>The problem boils down to the fact that libpq needs to find its data
>>files (in this case locale data, but it could be anything), but it
>>doesn't know its own location, so it can't use a relative path
>>reference as has been proposed.
>>
>>
>
>I am wondering if we should use environment variables, and have our apps
>use putenv() to set it to the proper relative path.
>
>

It seems a bit roundabout, but might make sense. Maybe they shouldn't
override any value already present in the environment, just set it if
there is nothing there? Then the library could use the environment if
set, or fall back on a hardcoded path.

cheers

andrew


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-27 01:08:42
Message-ID: 200405270108.i4R18gb15049@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Andrew Dunstan wrote:
>
>
> Bruce Momjian wrote:
>
> >Peter Eisentraut wrote:
> >
> >
> >>Andrew Dunstan wrote:
> >>
> >>
> >>>I'm confused. Can you explain the problem more clearly, please? Do we
> >>>need to distinguish known apps with a known (relative) message
> >>>location, from unknown libpq clients?
> >>>
> >>>
> >>The problem boils down to the fact that libpq needs to find its data
> >>files (in this case locale data, but it could be anything), but it
> >>doesn't know its own location, so it can't use a relative path
> >>reference as has been proposed.
> >>
> >>
> >
> >I am wondering if we should use environment variables, and have our apps
> >use putenv() to set it to the proper relative path.
> >
> >
>
> It seems a bit roundabout, but might make sense. Maybe they shouldn't
> override any value already present in the environment, just set it if
> there is nothing there? Then the library could use the environment if
> set, or fall back on a hardcoded path.

Yes, that is what I was thinking. Call it PGLOCALEDIR.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-27 02:26:04
Message-ID: 5757.1085624764@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Peter Eisentraut wrote:
>> The problem boils down to the fact that libpq needs to find its data
>> files (in this case locale data, but it could be anything), but it
>> doesn't know its own location, so it can't use a relative path
>> reference as has been proposed.

> I am wondering if we should use environment variables, and have our apps
> use putenv() to set it to the proper relative path.

*Our* apps are not the problem. The problem comes when libpq is
embedded in somebody else's app --- which is not going to be that
cooperative, and would have no good way to know what path to supply
if it did want to be cooperative.

I can't say I care for the environment variable idea either; though
there may not be any better alternative.

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-27 02:41:55
Message-ID: 200405270241.i4R2fto09238@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Peter Eisentraut wrote:
> >> The problem boils down to the fact that libpq needs to find its data
> >> files (in this case locale data, but it could be anything), but it
> >> doesn't know its own location, so it can't use a relative path
> >> reference as has been proposed.
>
> > I am wondering if we should use environment variables, and have our apps
> > use putenv() to set it to the proper relative path.
>
> *Our* apps are not the problem. The problem comes when libpq is

Well, right now our apps don't work, so it is a problem. Of course the
bigger problem is other apps. How do libs find related files? I can't
think if a common API for that.

> I can't say I care for the environment variable idea either; though
> there may not be any better alternative.

I think the best we can do is putenv() for our apps, and document the
variable for other apps.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-27 02:45:15
Message-ID: 6047.1085625915@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> I think the best we can do is putenv() for our apps, and document the
> variable for other apps.

Document what? How will another app find libpq's locale file?
AFAICS *it can't*. Documenting a useless variable is not a solution.

regards, tom lane


From: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
To: <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-27 02:56:13
Message-ID: 1316.24.211.141.25.1085626573.squirrel@www.dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane said:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
>> I think the best we can do is putenv() for our apps, and document the
>> variable for other apps.
>
> Document what? How will another app find libpq's locale file?
> AFAICS *it can't*. Documenting a useless variable is not a solution.
>

You wouldn't expect the environment var to be set by an app in those
cases - it would be set by a sysadmin or an installer on a system-wide
basis when pg is installed in other than the hardcoded location. At least,
that's the way I understood Bruce's suggestion.

cheers

andrew


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-27 03:26:11
Message-ID: 200405270326.i4R3QBP15180@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > I think the best we can do is putenv() for our apps, and document the
> > variable for other apps.
>
> Document what? How will another app find libpq's locale file?
> AFAICS *it can't*. Documenting a useless variable is not a solution.

I figured our apps could use putenv to set the locale directory, and
users of other apps could set the environment variable before running
the app.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Relocatable locale
Date: 2004-05-27 03:26:35
Message-ID: 200405270326.i4R3QZP15200@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Andrew Dunstan wrote:
> Tom Lane said:
> > Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> >> I think the best we can do is putenv() for our apps, and document the
> >> variable for other apps.
> >
> > Document what? How will another app find libpq's locale file?
> > AFAICS *it can't*. Documenting a useless variable is not a solution.
> >
>
> You wouldn't expect the environment var to be set by an app in those
> cases - it would be set by a sysadmin or an installer on a system-wide
> basis when pg is installed in other than the hardcoded location. At least,
> that's the way I understood Bruce's suggestion.

Right.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-27 05:21:34
Message-ID: 200405270721.34666.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian wrote:
> I am wondering if we should use environment variables, and have our
> apps use putenv() to set it to the proper relative path.

The problem isn't our applications, it's someone else's applications.
Are you saying that from now on, setting certain environment variables
is part of the required startup for libpq programs? Remember that on
Windows in generall all installations are relocated away from the
default location.


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-27 05:28:42
Message-ID: 200405270728.42613.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Andrew Dunstan wrote:
> You wouldn't expect the environment var to be set by an app in those
> cases - it would be set by a sysadmin or an installer on a
> system-wide basis when pg is installed in other than the hardcoded
> location. At least, that's the way I understood Bruce's suggestion.

Strange. I don't suppose that PostgreSQL is the first package using
gettext on Windows. How does everyone else handle this?


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-27 05:31:06
Message-ID: 200405270531.i4R5V6226885@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Peter Eisentraut wrote:
> Bruce Momjian wrote:
> > I am wondering if we should use environment variables, and have our
> > apps use putenv() to set it to the proper relative path.
>
> The problem isn't our applications, it's someone else's applications.
> Are you saying that from now on, setting certain environment variables
> is part of the required startup for libpq programs? Remember that on
> Windows in generall all installations are relocated away from the
> default location.

Well, if they want locale-specific error messages from libpq in their
applications, the have to supply those locale files somehow. They could
supply them in the same directory as their binaries and use putenv()
and find_my_exec().

Sure, it is a hack, but what other option do we have? Do we somehow
move the locale files into the library?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-27 12:05:48
Message-ID: 200405271405.48984.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Am Donnerstag, 27. Mai 2004 07:31 schrieb Bruce Momjian:
> Sure, it is a hack, but what other option do we have? Do we somehow
> move the locale files into the library?

On Windows we use the feature that DLLs can locate themselves (described by
Magnus Hagander), and on Unix we forget about pretending to offer relocatable
installations.


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-06-03 00:06:49
Message-ID: 200406030006.i5306oI25269@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


With no one coming up with a better idea, this applied patch adds PGETC
(for pg_service.conf) and PGLOCALE (for locale dir) environment variable
processing to libpq.

The patch also adds code to our client apps so we set the environment
variable directly based on our binary location, unless it is already
set. This will allow our applications to emit proper locale messages
that are generated in libpq.

---------------------------------------------------------------------------

Bruce Momjian wrote:
> Andrew Dunstan wrote:
> >
> >
> > Bruce Momjian wrote:
> >
> > >Peter Eisentraut wrote:
> > >
> > >
> > >>Andrew Dunstan wrote:
> > >>
> > >>
> > >>>I'm confused. Can you explain the problem more clearly, please? Do we
> > >>>need to distinguish known apps with a known (relative) message
> > >>>location, from unknown libpq clients?
> > >>>
> > >>>
> > >>The problem boils down to the fact that libpq needs to find its data
> > >>files (in this case locale data, but it could be anything), but it
> > >>doesn't know its own location, so it can't use a relative path
> > >>reference as has been proposed.
> > >>
> > >>
> > >
> > >I am wondering if we should use environment variables, and have our apps
> > >use putenv() to set it to the proper relative path.
> > >
> > >
> >
> > It seems a bit roundabout, but might make sense. Maybe they shouldn't
> > override any value already present in the environment, just set it if
> > there is nothing there? Then the library could use the environment if
> > set, or fall back on a hardcoded path.
>
> Yes, that is what I was thinking. Call it PGLOCALEDIR.
>
> --
> Bruce Momjian | http://candle.pha.pa.us
> pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
> + If your life is a hard drive, | 13 Roberts Road
> + Christ can be your backup. | Newtown Square, Pennsylvania 19073
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 17.6 KB

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-06-08 07:55:32
Message-ID: 200406080955.32146.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian wrote:
> With no one coming up with a better idea, this applied patch adds
> PGETC (for pg_service.conf) and PGLOCALE (for locale dir) environment
> variable processing to libpq.

Considering that in other places these locations are referred to as
"sysconfdir" and "localdir", it would make sense to name the variables
"PGSYSCONFDIR" and "PGLOCALEDIR", so we stick to one set of terms.


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-06-08 13:49:22
Message-ID: 200406081349.i58DnMb24162@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Peter Eisentraut wrote:
> Bruce Momjian wrote:
> > With no one coming up with a better idea, this applied patch adds
> > PGETC (for pg_service.conf) and PGLOCALE (for locale dir) environment
> > variable processing to libpq.
>
> Considering that in other places these locations are referred to as
> "sysconfdir" and "localdir", it would make sense to name the variables
> "PGSYSCONFDIR" and "PGLOCALEDIR", so we stick to one set of terms.

OK, change made.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073