Re: [EXTERNAL] Re: BUG #18707: Installation issue - Mailing list pgsql-bugs

From Thomas Munro
Subject Re: [EXTERNAL] Re: BUG #18707: Installation issue
Date
Msg-id CA+hUKG+18+0PbhKzmkj=9O52jLMVuwj4sKDGRqnABBuuueeU3Q@mail.gmail.com
Whole thread Raw
In response to Re: [EXTERNAL] Re: BUG #18707: Installation issue  (Sandeep Thakkar <sandeep.thakkar@enterprisedb.com>)
Responses Re: [EXTERNAL] Re: BUG #18707: Installation issue
List pgsql-bugs
On Tue, Nov 19, 2024 at 8:02 PM Sandeep Thakkar
<sandeep.thakkar@enterprisedb.com> wrote:
> On Tue, Nov 19, 2024 at 6:39 AM Thomas Munro <thomas.munro@gmail.com> wrote:
>> a wild guess: would it help to use numerical SIDs instead of account
>> names when invoking shell commands like icacls?
>
> Yes, I tried that recently. It works well for init cluster, but pg_ctl fails to register the service:

I suppose the SID-vs-username thing is just one case anyway, and even
if we taught pg_ctl -U to accept SIDs (looks doable), I bet you could
have the same problem with paths with funky characters in them.

Let's see... so you pass shell commands to DoCmd[1] which injects them
into a wrapper batch file, after setting the codepage to match the
ACP[2].  After reading lots of horrible details on the internet, that
looks like the right idea to me, as it means that the rest of the
batch file should match what the Visual Basic program is using when it
writes out the command line, instead of the old MS-DOS OEM codepage
assumed by cmd.exe batch files.  I assume that is working OK for
some/most people and must have worked OK for some non-ASCII stuff on
some configurations as that's why you added it, many years ago.  So
what is different in these cases?

Idea: could the Visual Basic program actually be using a different
ACP, not the one in the registry, due to some explicit locale setting
or environment variable somewhere?  Would it be better to call
GetACP() instead of that registry lookup[2]?

Some assumptions: I think VBA works entirely with wchar_t strings, and
I think objBatchFile.WriteLine must be the point of implicit
transcoding to char if the file wasn't opened in "Unicode mode"
(Unicode here meaning wchar_t, which sounds potentially useful for
sidestepping all this stuff but apparently it wouldn't work for batch
files), and surely that transcoding is done with the value from
GetACP().  I couldn't find where that is written down, though.

[1]
https://github.com/EnterpriseDB/edb-installers/blob/5721b7804676fe1b74f5a4287692f56bd52e8b8f/server/scripts/windows/initcluster.vbs#L173
[2]
https://github.com/EnterpriseDB/edb-installers/blob/5721b7804676fe1b74f5a4287692f56bd52e8b8f/server/scripts/windows/initcluster.vbs#L75



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #18711: Attempting a connection with a database name longer than 63 characters now fails
Next
From: Erik Wienhold
Date:
Subject: Re: BUG #18715: replace() function silently fails if 3rd argument is null