On Fri, 28 Nov 2003, Tom Lane wrote:
"E.Rodichev" <[EMAIL PROTECTED]> writes:
/e:2>createdb testWhat's incorrect about it? You didn't ask for any other encoding
test | er | SQL_ASCII <----- Incorrect!
(3 rows)
Let's note than the last line is in fact completely incorrect.
than SQL_ASCII.
It is incorrect, because database "test" is, really, in KOI8, NOT in SQL_ASCII in this example, as I explained in my mail.
Best wishes, E.R.
You can set the default encoding at initdb time, IIRC, but you didn't.
You can set the default at initdb time, or per database at createdb time, but it has to be done explicitly. You seem to think it should be picked up from the environment, but this isn't so, you must use the -E|--encoding flag on either createdb or initdb, or if creating directly from SQL use the ENCODING option on "create database" to use something other than the default set by initdb.
examples:
[EMAIL PROTECTED] bin]$ ./initdb /tmp/enctry The files belonging to this database system will be owned by user "andrew". This user must also own the server process.
The database cluster will be initialized with locales: COLLATE: ru_RU.KOI8-R CTYPE: ru_RU.KOI8-R MESSAGES: en_US.iso885915 MONETARY: en_US.iso885915 NUMERIC: en_US.iso885915 TIME: en_US.iso885915
creating directory /tmp/enctry... ok creating directory /tmp/enctry/base... ok creating directory /tmp/enctry/global... ok creating directory /tmp/enctry/pg_xlog... ok creating directory /tmp/enctry/pg_clog... ok selecting default max_connections... 100 selecting default shared_buffers... 1000 creating configuration files... ok creating template1 database in /tmp/enctry/base/1... ok initializing pg_shadow... ok enabling unlimited row size for system tables... ok initializing pg_depend... ok creating system views... ok loading pg_description... ok creating conversions... ok setting privileges on built-in objects... ok creating information schema... ok vacuuming database template1... ok copying template1 to template0... ok
Success. You can now start the database server using:
./postmaster -D /tmp/enctry or ./pg_ctl -D /tmp/enctry -l logfile start
[EMAIL PROTECTED] bin]$ ./pg_ctl -D /tmp/enctry -l /tmp/enclog -o '-p 5433' start
postmaster successfully started
[EMAIL PROTECTED] bin]$ ./createdb -E KOI8-R -p 5433 testme
CREATE DATABASE
[EMAIL PROTECTED] bin]$ ./psql -p 5433 -l
List of databases
Name | Owner | Encoding -----------+--------+-----------
template0 | andrew | SQL_ASCII
template1 | andrew | SQL_ASCII
testme | andrew | KOI8
(3 rows)
[EMAIL PROTECTED] bin]$ ./pg_ctl -D /tmp/enctry -o '-p 5433' stop waiting for postmaster to shut down......done postmaster successfully shut down [EMAIL PROTECTED] bin]$ rm -rf /tmp/enctry [EMAIL PROTECTED] bin]$ ./initdb -E KOI8-R /tmp/enctry The files belonging to this database system will be owned by user "andrew". This user must also own the server process.
The database cluster will be initialized with locales: COLLATE: ru_RU.KOI8-R CTYPE: ru_RU.KOI8-R MESSAGES: en_US.iso885915 MONETARY: en_US.iso885915 NUMERIC: en_US.iso885915 TIME: en_US.iso885915
creating directory /tmp/enctry... ok creating directory /tmp/enctry/base... ok creating directory /tmp/enctry/global... ok creating directory /tmp/enctry/pg_xlog... ok creating directory /tmp/enctry/pg_clog... ok selecting default max_connections... 100 selecting default shared_buffers... 1000 creating configuration files... ok creating template1 database in /tmp/enctry/base/1... ok initializing pg_shadow... ok enabling unlimited row size for system tables... ok initializing pg_depend... ok creating system views... ok loading pg_description... ok creating conversions... ok setting privileges on built-in objects... ok creating information schema... ok vacuuming database template1... ok copying template1 to template0... ok
Success. You can now start the database server using:
./postmaster -D /tmp/enctry or ./pg_ctl -D /tmp/enctry -l logfile start
[EMAIL PROTECTED] bin]$ ./pg_ctl -D /tmp/enctry -l /tmp/enclog -o '-p 5433' start postmaster successfully started [EMAIL PROTECTED] bin]$ ./createdb -p 5433 testme CREATE DATABASE [EMAIL PROTECTED] bin]$ ./psql -p 5433 -l List of databases Name | Owner | Encoding -----------+--------+---------- template0 | andrew | KOI8 template1 | andrew | KOI8 testme | andrew | KOI8 (3 rows)
[EMAIL PROTECTED] bin]$
cheers
andrew
---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives?
http://archives.postgresql.org