BUG #18098: Console code page issue Postgresql 14.7
The following bug has been logged on the website:
Bug reference: 18098
Logged by: Gokul
Email address: gokulkrishnan99102@gmail.com
PostgreSQL version: 14.7
Operating system: Windows 10 Pro, Version - 22H2
Description:
Hi Team,
We are facing an issue on executing initdb.exe it throws error
like 'initdb: error: The program "postgres" was found by
"pgsql\bin\initdb.exe" but was not the same version as initdb'.
But postgres.exe and initdb.exe version are same. After referring
many articles, sites in google. We came to know that Console code page
causes this issue on specific case. If we are setting console code page on
particular cmd session it won't affects the init db process. But if chcp
value entry present in registry at the path
"HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun"(This entry
helps to execute any command in cmd at the time of opening). Hence in the
entire initdb process if cmd inkoved internally this chcp values will be set
on each cmd session. This may cause encoding issue during initdb process. On
referring postgres forum we found an bug raised with exact senario in
postgres 11 but no response found for that mail thread. Kindly help us to
resolve this issue.
Refer this link(bug) ->
/messages/by-id/15856-97c7d2fd3b86f13d@postgresql.org
Hi Team,
Since setting the chcp command on the registry is recommended by
microsoft. We cannot go with the clearing registry option. Kindly provide
the solution accordingly.
Thanks & Regards,
Gokul
On Fri, Sep 8, 2023 at 11:59 AM PG Bug reporting form <
noreply@postgresql.org> wrote:
Show quoted text
The following bug has been logged on the website:
Bug reference: 18098
Logged by: Gokul
Email address: gokulkrishnan99102@gmail.com
PostgreSQL version: 14.7
Operating system: Windows 10 Pro, Version - 22H2
Description:Hi Team,
We are facing an issue on executing initdb.exe it throws error
like 'initdb: error: The program "postgres" was found by
"pgsql\bin\initdb.exe" but was not the same version as initdb'.
But postgres.exe and initdb.exe version are same. After referring
many articles, sites in google. We came to know that Console code page
causes this issue on specific case. If we are setting console code page on
particular cmd session it won't affects the init db process. But if chcp
value entry present in registry at the path
"HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun"(This
entry
helps to execute any command in cmd at the time of opening). Hence in the
entire initdb process if cmd inkoved internally this chcp values will be
set
on each cmd session. This may cause encoding issue during initdb process.
On
referring postgres forum we found an bug raised with exact senario in
postgres 11 but no response found for that mail thread. Kindly help us to
resolve this issue.
Refer this link(bug) ->
/messages/by-id/15856-97c7d2fd3b86f13d@postgresql.org
On Fri, 2023-09-08 at 12:02 +0530, Gokul Krishnan wrote:
Kindly provide the solution accordingly.
Kindly provide a good problem description. Don't say "I run initdb.exe",
tell us how exactly you ran it, and what you ran before that to provoke the error.
What was your OS locale at that time? What was the exact error message?
What exactly did you have to change in the registry to make the problem go away?
Yours,
Laurenz Albe
Hi Laurenz,
Apologies for the inconvenience,I have shared the detailed
description below. Kindly provide a solution for this issue.
I have tried to initialize data directory using this below command,
*initdb.exe -D "..\data" -U postgres --no-locale -E UTF8*
Exact error returned by postgres,
*initdb: error: The program "postgres" was found by
"E:\pgsql\bin/initdb.exe"but was not the same version as initdb.Check your
installation.*
[image: image.png]
I have tried with different chcp values(1252,437.. etc) that are supported
by postgres <https://www.postgresql.org/docs/current/multibyte.html> but
doesn't work for my case(encoding command also changed according to
registry chcp value) .If I remove the *Active code page : 65001* from the
registry editor, then the above mentioned initdb command executes
successfully.
Successful execution log for your reference,
*Microsoft Windows [Version 10.0.19045.3324](c) Microsoft Corporation. All
rights reserved.E:\pgsql\bin>initdb.exe -D "..\data" -U postgres
--no-locale -E UTF8The files belonging to this database system will be
owned by user "gokul".*
*This user must also own the server process.The database cluster will be
initialized with locale "C".The default text search configuration will be
set to "english".Data page checksums are disabled.creating directory
../data ... okcreating subdirectories ... okselecting dynamic shared memory
implementation ... windowsselecting default max_connections ...
100selecting default shared_buffers ... 128MBselecting default time zone
... Asia/Calcuttacreating configuration files ... okrunning bootstrap
script ... okperforming post-bootstrap initialization ... oksyncing data to
disk ... okinitdb: warning: enabling "trust" authentication for local
connectionsYou can change this by editing pg_hba.conf or using the option
-A, or--auth-local and --auth-host, the next time you run initdb.Success.
You can now start the database server using: pg_ctl -D ^"^.^.^\data^" -l
logfile start*
[image: image.png]
Registry Editor key I have removed,
*Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\Autorun
-> *Removed the *Value data(chcp 65001)* content.
[image: image.png]
My Current System locale is *English (United States)*
[image: image.png]
*Thanks & Regards,*
Gokul
On Fri, Sep 8, 2023 at 12:17 PM Laurenz Albe <laurenz.albe@cybertec.at>
wrote:
Show quoted text
On Fri, 2023-09-08 at 12:02 +0530, Gokul Krishnan wrote:
Kindly provide the solution accordingly.
Kindly provide a good problem description. Don't say "I run initdb.exe",
tell us how exactly you ran it, and what you ran before that to provoke
the error.
What was your OS locale at that time? What was the exact error message?
What exactly did you have to change in the registry to make the problem go
away?Yours,
Laurenz Albe
Hi Laurenz,
I have shared all the required details in previous mail, Kindly provide a
solution for this issue.
*Thanks & Regards,*
Gokul
On Fri, Sep 8, 2023 at 3:51 PM Gokul Krishnan <gokulkrishnan99102@gmail.com>
wrote:
Show quoted text
Hi Laurenz,
Apologies for the inconvenience,I have shared the detailed
description below. Kindly provide a solution for this issue.
I have tried to initialize data directory using this below command,
*initdb.exe -D "..\data" -U postgres --no-locale -E UTF8*Exact error returned by postgres,
*initdb: error: The program "postgres" was found by
"E:\pgsql\bin/initdb.exe"but was not the same version as initdb.Check your
installation.*
[image: image.png]I have tried with different chcp values(1252,437.. etc) that are supported
by postgres <https://www.postgresql.org/docs/current/multibyte.html> but
doesn't work for my case(encoding command also changed according to
registry chcp value) .If I remove the *Active code page : 65001* from the
registry editor, then the above mentioned initdb command executes
successfully.Successful execution log for your reference,
*Microsoft Windows [Version 10.0.19045.3324](c) Microsoft Corporation. All
rights reserved.E:\pgsql\bin>initdb.exe -D "..\data" -U postgres
--no-locale -E UTF8The files belonging to this database system will be
owned by user "gokul".**This user must also own the server process.The database cluster will be
initialized with locale "C".The default text search configuration will be
set to "english".Data page checksums are disabled.creating directory
../data ... okcreating subdirectories ... okselecting dynamic shared memory
implementation ... windowsselecting default max_connections ...
100selecting default shared_buffers ... 128MBselecting default time zone
... Asia/Calcuttacreating configuration files ... okrunning bootstrap
script ... okperforming post-bootstrap initialization ... oksyncing data to
disk ... okinitdb: warning: enabling "trust" authentication for local
connectionsYou can change this by editing pg_hba.conf or using the option
-A, or--auth-local and --auth-host, the next time you run initdb.Success.
You can now start the database server using: pg_ctl -D ^"^.^.^\data^" -l
logfile start*[image: image.png]
Registry Editor key I have removed,
*Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\Autorun
-> *Removed the *Value data(chcp 65001)* content.[image: image.png]
My Current System locale is *English (United States)*
[image: image.png]
*Thanks & Regards,*
GokulOn Fri, Sep 8, 2023 at 12:17 PM Laurenz Albe <laurenz.albe@cybertec.at>
wrote:On Fri, 2023-09-08 at 12:02 +0530, Gokul Krishnan wrote:
Kindly provide the solution accordingly.
Kindly provide a good problem description. Don't say "I run initdb.exe",
tell us how exactly you ran it, and what you ran before that to provoke
the error.
What was your OS locale at that time? What was the exact error message?
What exactly did you have to change in the registry to make the problem
go away?Yours,
Laurenz Albe
At Tue, 12 Sep 2023 14:36:03 +0530, Gokul Krishnan <gokulkrishnan99102@gmail.com> wrote in
Hi Laurenz,
I have shared all the required details in previous mail, Kindly provide a
solution for this issue.
Thanks for the info. It suspect that the issue arises because chcp
prints "Active code page: 65001", which can clutter things up in
various situations. AFAICS there's no option to silence it. It's
puzzling why Microsoft would suggest such a problematic setup (if it
really does).
When initdb probes for the postgres version, it uses _popen. From what
I gather, it uses cmd.exe. This action then may automatically runs
chcp, injecting the line "Active code page: 65001" to the output. You
can observe this with the following command line. initdb expects the
secondline to come first.
work>cmd /c pgsql\bin\postgres -V
Active code page: 65001
postgres (PostgreSQL) 17devel
For the record, I couldn't reproduced this issue on Windows 11, so I
didn't observed what actually happens in this situation. Not entirely
sure why, but maybe _popen in that version either bypasses cmd.exe or
prevents it from executing autoruns. But, I face hiccups with
VsDevCmd.bat when pulling output from subshells.
As the result, I'd advise against doing that, especially on the server
running PostgreSQL.
I don't think we want to "fix" this issue, especially if Windows 11
has already adressed it. But I'm not sure about this.
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center
Hi kyotaro,
Thank you for your response. It makes sense. Let me check and get back to
you in case of any queries.
*Thanks & Regards,*
Gokul
On Wed, Sep 13, 2023, 8:32 AM Kyotaro Horiguchi <horikyota.ntt@gmail.com>
wrote:
Show quoted text
At Tue, 12 Sep 2023 14:36:03 +0530, Gokul Krishnan <
gokulkrishnan99102@gmail.com> wrote inHi Laurenz,
I have shared all the required details in previous mail, Kindly provide a
solution for this issue.Thanks for the info. It suspect that the issue arises because chcp
prints "Active code page: 65001", which can clutter things up in
various situations. AFAICS there's no option to silence it. It's
puzzling why Microsoft would suggest such a problematic setup (if it
really does).When initdb probes for the postgres version, it uses _popen. From what
I gather, it uses cmd.exe. This action then may automatically runs
chcp, injecting the line "Active code page: 65001" to the output. You
can observe this with the following command line. initdb expects the
secondline to come first.work>cmd /c pgsql\bin\postgres -V
Active code page: 65001
postgres (PostgreSQL) 17develFor the record, I couldn't reproduced this issue on Windows 11, so I
didn't observed what actually happens in this situation. Not entirely
sure why, but maybe _popen in that version either bypasses cmd.exe or
prevents it from executing autoruns. But, I face hiccups with
VsDevCmd.bat when pulling output from subshells.As the result, I'd advise against doing that, especially on the server
running PostgreSQL.I don't think we want to "fix" this issue, especially if Windows 11
has already adressed it. But I'm not sure about this.regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center