get_progname and .exe suffix

Lists: pgsql-hackers-win32
From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-hackers-win32 <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: get_progname and .exe suffix
Date: 2004-10-16 15:30:12
Message-ID: 41713E84.4090106@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers-win32


People,

I posted on -hackers the other day about get_progname returning a name
with the .exe suffix. There was no response other than one from Dave
Page saying he had reported the problem. Does anyone have an idea of the
best way to fix it? Apart from being plain ugly it causes the contrib
regression tests to fail, so I think this is a must-fix for 8.0.

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers-win32 <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: Re: get_progname and .exe suffix
Date: 2004-10-16 16:24:00
Message-ID: 4312.1097943840@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers-win32

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> I posted on -hackers the other day about get_progname returning a name
> with the .exe suffix.

What would break if we caused get_progname itself to strip the suffix?
That would be a nice localized fix if it worked ...

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers-win32 <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: Re: get_progname and .exe suffix
Date: 2004-10-16 16:35:41
Message-ID: 41714DDD.4080007@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers-win32

Tom Lane wrote:

>Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>
>
>>I posted on -hackers the other day about get_progname returning a name
>>with the .exe suffix.
>>
>>
>
>What would break if we caused get_progname itself to strip the suffix?
>That would be a nice localized fix if it worked ...
>
>

Yes. get_progname() actually just returns a pointer to one past the last
directory separator it finds in its argument string. Having it strip the
.exe directly would in effect involve mangling argv[0]. That's what
makes me slightly nervous about it. We could have it strdup() the result
and then mangle that - note that it is called by postmaster before we
set up any memory context stuff.

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers-win32 <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: Re: get_progname and .exe suffix
Date: 2004-10-16 16:57:26
Message-ID: 8650.1097945846@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers-win32

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> Tom Lane wrote:
>> What would break if we caused get_progname itself to strip the suffix?

> Yes. get_progname() actually just returns a pointer to one past the last
> directory separator it finds in its argument string. Having it strip the
> .exe directly would in effect involve mangling argv[0]. That's what
> makes me slightly nervous about it. We could have it strdup() the result
> and then mangle that - note that it is called by postmaster before we
> set up any memory context stuff.

Seems reasonable. What I was more worried about though was whether
there are any callers that actually need a non-stripped result.

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers-win32 <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: Re: get_progname and .exe suffix
Date: 2004-10-16 19:37:36
Message-ID: 41717880.8050202@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers-win32

Tom Lane wrote:

>Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>
>
>>Tom Lane wrote:
>>
>>
>>>What would break if we caused get_progname itself to strip the suffix?
>>>
>>>
>
>
>
>>Yes. get_progname() actually just returns a pointer to one past the last
>>directory separator it finds in its argument string. Having it strip the
>>.exe directly would in effect involve mangling argv[0]. That's what
>>makes me slightly nervous about it. We could have it strdup() the result
>>and then mangle that - note that it is called by postmaster before we
>>set up any memory context stuff.
>>
>>
>
>Seems reasonable. What I was more worried about though was whether
>there are any callers that actually need a non-stripped result.
>
>

Ok, I will have a look. grep tells me it's called in these places:

./src/backend/postmaster/postmaster.c
./src/bin/initdb/initdb.c
./src/bin/pg_config/pg_config.c
./src/bin/pg_controldata/pg_controldata.c
./src/bin/pg_ctl/pg_ctl.c
./src/bin/pg_dump/pg_dump.c
./src/bin/pg_dump/pg_dumpall.c
./src/bin/pg_dump/pg_restore.c
./src/bin/pg_resetxlog/pg_resetxlog.c
./src/bin/psql/startup.c
./src/bin/scripts/clusterdb.c
./src/bin/scripts/common.c
./src/bin/scripts/createdb.c
./src/bin/scripts/createlang.c
./src/bin/scripts/createuser.c
./src/bin/scripts/dropdb.c
./src/bin/scripts/droplang.c
./src/bin/scripts/dropuser.c
./src/bin/scripts/vacuumdb.c
./src/interfaces/ecpg/preproc/ecpg.c

cheers

andrew