Re: Encoding problem with 7.4 - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: Encoding problem with 7.4
Date
Msg-id 3FCDFE1B.6050300@dunslane.net
Whole thread Raw
In response to Re: Encoding problem with 7.4  ("E.Rodichev" <er@sai.msu.su>)
List pgsql-hackers
E.Rodichev wrote:

>On Fri, 28 Nov 2003, Tom Lane wrote:
>
>  
>
>>"E.Rodichev" <er@sai.msu.su> writes:
>>    
>>
>>>/e:2>createdb test
>>>      
>>>
>>> test      | er       | SQL_ASCII   <----- Incorrect!
>>>(3 rows)
>>>      
>>>
>>>Let's note than the last line is in fact completely incorrect.
>>>      
>>>
>>What's incorrect about it?  You didn't ask for any other encoding
>>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:

[andrew@Thor 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.iso885915MONETARY: 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

[andrew@Thor bin]$ ./pg_ctl -D /tmp/enctry -l /tmp/enclog -o '-p 5433' start
postmaster successfully started
[andrew@Thor bin]$ ./createdb -E KOI8-R -p 5433 testme
CREATE DATABASE
[andrew@Thor bin]$ ./psql -p 5433 -l      List of databases  Name    | Owner  | Encoding 
-----------+--------+-----------template0 | andrew | SQL_ASCIItemplate1 | andrew | SQL_ASCIItestme    | andrew | KOI8
(3 rows)

[andrew@Thor bin]$ ./pg_ctl -D /tmp/enctry  -o '-p 5433' stop
waiting for postmaster to shut down......done
postmaster successfully shut down
[andrew@Thor bin]$ rm -rf /tmp/enctry
[andrew@Thor 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.iso885915MONETARY: 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

[andrew@Thor bin]$ ./pg_ctl -D /tmp/enctry -l /tmp/enclog -o '-p 5433' start
postmaster successfully started
[andrew@Thor bin]$ ./createdb -p 5433 testme
CREATE DATABASE
[andrew@Thor bin]$ ./psql -p 5433 -l      List of databases  Name    | Owner  | Encoding
-----------+--------+----------template0 | andrew | KOI8template1 | andrew | KOI8testme    | andrew | KOI8
(3 rows)

[andrew@Thor bin]$


cheers

andrew



pgsql-hackers by date:

Previous
From: Robert Treat
Date:
Subject: Re: 7.3.5 bundled ...
Next
From: Andrew Dunstan
Date:
Subject: Re: Inside the Regex Engine