I recently set up a new system for regression testing with PostgreSQL. 
I have a suggested change to how we create PostgreSQL databases.

Background: The Bacula project recommends an SQL_ASCII encoding for 
Bacula because not all file pathnames can be guaranteed to be UTF-8 
compliant.  UTF-8 is referenced in the previous statement, but the 
statement applies equally well to any non SQL-ASCII encoding.

The problem I encountered during regression testing:

psql:<stdin>:1: ERROR:  new encoding (SQL_ASCII) is incompatible with 
the encoding of the template database (UTF8)
HINT:  Use the same encoding as in the template database, or use 
template0 as template.
psql:<stdin>:2: ERROR:  database "regress" does not exist
Creation of regress database succeeded.
psql: FATAL:  database "regress" does not exist

The default encoding of PostgreSQL is UTF-8:

$ psql -l
                            List of databases
    Name    | Owner | Encoding  | Collation | Ctype | Access privileges
-----------+-------+-----------+-----------+-------+-------------------
  postgres  | pgsql | UTF8      | C         | C     |
  template0 | pgsql | UTF8      | C         | C     | =c/pgsql
                                                    : pgsql=CTc/pgsql
  template1 | pgsql | UTF8      | C         | C     | =c/pgsql
                                                    : pgsql=CTc/pgsql


 From the createdb documentation at 
http://www.postgresql.org/docs/current/static/sql-createdatabase.html :

###
encoding

     Character set encoding to use in the new database. Specify a string 
constant (e.g., 'SQL_ASCII'), or an integer encoding number, or DEFAULT 
to use the default encoding (namely, the encoding of the template 
database). The character sets supported by the PostgreSQL server are 
described in Section 22.2.1. See below for additional restrictions.

The encoding and locale settings must match those of the template 
database, except when template0 is used as template. This is because 
other databases might contain data that does not match the specified 
encoding, or might contain indexes whose sort ordering is affected by 
LC_COLLATE and LC_CTYPE. Copying such data would result in a database 
that is corrupt according to the new settings. template0, however, is 
known to not contain any data or indexes that would be affected.
###

Thus, the following fails:

$ createdb -E SQL_ASCII testing
createdb: database creation failed: ERROR:  new encoding (SQL_ASCII) is 
incompatible with the encoding of the template database (UTF8)
HINT:  Use the same encoding as in the template database, or use 
template0 as template.


But the following does not:

$ createdb -T template0 -E SQL_ASCII testing

I will submit patches later after I've tested them.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Bacula-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-devel

Reply via email to