Author Topic: PostgreSQL database initialization  (Read 4269 times)

Doug Clark

  • Sr. Member
  • ****
  • Posts: 307
  • Karma: +7/-1
    • View Profile
PostgreSQL database initialization
« on: May 30, 2019, 01:51:16 am »
I have installed PostgreSQL v 9.6.6 - by unzipping into e:\pgsql

I have two issues:

1) initDB apparently doesn't like the OS/2 code page IBM-850
The error message is below

[E:\]initdb -D E:\PGDATA
LOG:  00000: invalid binary "E:/"E:/pgsql/bin/postgres.exe"
LOCATION:  find_my_exec, exec.c:146
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.IBM-850".
could not determine encoding for locale "en_US.IBM-850": codeset is "IBM-850"
initdb: could not find suitable encoding for locale "en_US.IBM-850"
Rerun initdb with the -E option.
Try "initdb --help" for more information.

----------------------------
2) I think the encoding of LATIN1 (ISO-8859-1) is the closest encoding to IBM-850 that PostgreSQL recognize, so I specified -E LATIN1.
But now I get a strange issue of Postgres not being able to find its own binaries.  Notice the error message below says invalid executable: "E:/"E:/pgsql/bin/postgres.exe"
For some reason Postgres is prefixing the current directory to the front of the path containing the executable and then using that as the path for the executable.

Anyone had success in getting version 9.6.6 to install and run?





[E:\]initdb -E LATIN1 -D E:\PGDATA
LOG:  00000: invalid binary "E:/"E:/pgsql/bin/postgres.exe"
LOCATION:  find_my_exec, exec.c:146
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.IBM-850".
could not determine encoding for locale "en_US.IBM-850": codeset is "IBM-850"
could not determine encoding for locale "en_US.IBM-850": codeset is "IBM-850"
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory E:/PGDATA ... ok
creating subdirectories ... ok
selecting default max_connections ... 10
selecting default shared_buffers ... 400kB
selecting dynamic shared memory implementation ... sysv
creating configuration files ... ok
running bootstrap script ... LOG:  00000: invalid binary "E:/"E:/pgsql/bin/postg
res.exe"
LOCATION:  find_my_exec, exec.c:146
LOG:  00000: invalid binary "E:/"E:/pgsql/bin/postgres.exe"
LOCATION:  find_my_exec, exec.c:146
FATAL:  XX000: "E:/pgsql/bin/postgres.exe": could not locate my own executable p
ath
LOCATION:  InitStandaloneProcess, miscinit.c:236
child process exited with exit code 1
initdb: removing data directory "E:/PGDATA"

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 275
  • Karma: +5/-0
    • View Profile
Re: PostgreSQL database initialization
« Reply #1 on: May 30, 2019, 03:33:19 pm »
Hello,

I've seen similar issues with it as well as with earlier builds.
The PostgreSQL team doesn't want to add IBM850 as a codepage. I also have issues with Swedish (sv_SE) on top of that, to support national characters such as åäö and ÅÄÖ.

See further down for a cmd-script by Paul that should work with German (de_DE).
Does it work better for you?

==pg.cmd, adjust paths to current version==
@ECHO OFF
SET PGINST_HOME=C:\OS2TOOLS\PG843
SET PGDB_HOME=D:/db/pg840data

SET OLDPATH=%PATH%
SET PATH=%PGINST_HOME%\bin;%PATH%

SET OLDBEGINLIBPATH=%BEGINLIBPATH%
SET BEGINLIBPATH=%PGINST_HOME%\bin;%PGINST_HOME%\lib;%BEGINLIBPATH%

SET OLDLANG=%LANG%
SET LANG=de_DE

call MODE 102,80

IF "%1"=="init" GOTO INITDB
IF "%1"=="start" GOTO STARTDB
IF "%1"=="stop" GOTO STOPDB
GOTO ERRORMSG


:INITDB
CMD /C  "initdb.exe -D %PGDB_HOME% --encoding=UTF8 --no-locale"
REM CMD /C  "initdb.exe -D %PGDB_HOME% --encoding=ISO8859-1 --locale=de_DE"
GOTO CLEANUP


:STARTDB
CMD /C "pg_ctl.exe -D %PGDB_HOME% -l "%PGINST_HOME%\postgres.log" start"
GOTO CLEANUP


:STOPDB
CMD /C "pg_ctl.exe -D %PGDB_HOME% stop"
GOTO CLEANUP


:ERRORMSG
ECHO.
ECHO ERROR:
ECHO ======
ECHO Only the parameters 'init', 'start' and 'stop' are supported!
ECHO.
GOTO CLEANUP

:CLEANUP
SET PATH=%OLDPATH%
SET BEGINLIBPATH=%OLDBEGINLIBPATH%
SET LANG=%OLDLANG%

Doug Clark

  • Sr. Member
  • ****
  • Posts: 307
  • Karma: +7/-1
    • View Profile
Re: PostgreSQL database initialization
« Reply #2 on: May 30, 2019, 06:36:43 pm »
Thanks Jan-Erik for the script. It looks like that will take care of my encoding issue. Since I am US english speaking I think I could probably use a number of different code pages without too much issue: we don't have strange accented letters, just confusing syntax and lots and lots of different words that mean the same thing, e.g. flammable and inflammable.

My other issue is the execution seems to stop part way through because of a path issue. It (initdb.exe) seems to incorrectly concatenate the current directory with the path where the executable is located. In the error message below I executed the script from E:\PGSQL. 
------------------
LOG:  00000: invalid binary "E:/pgsql/"E:/pgsql/bin/postgres.exe"
LOCATION:  find_my_exec, exec.c:146
------------------

If I execute if from C:\ the error becomes
-----------------------------------------
LOG:  00000: invalid binary "C:/"E:/pgsql/bin/postgres.exe"
-----------------------------------------