[plt-dev] pgsql package

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Wed Jul 29 11:26:58 EDT 2009

Robby wrote:
> Hi all (Ryan?): I've got a question about pgsql. From what I can tell,
> string data is stored in the database in the latin-1 encoding
> (sql-data.ss line 191), but is then retrieved from the database in the
> utf-8 encoding (io.ss line 205). Am I getting that right?
> This doesn't mean much, but I changed planet's copy of io.ss to use
> bytes->string/latin-1 instead of bytes->string/utf-8, and I was able
> to avoid crashing (but the latin-1 encoding might not have any
> unencodable octets, so that isn't really saying too too much).

PostgreSQL lets you specify character encodings on a per-database and  
per-client basis. The shell command:

   psql -l

will show you your setting for each database on your server. The psql  


will show you your client encoding for your current session. You can  
set your client encoding using the psql command:

     \encoding UTF8

I'm guessing backslash commands can also be sent over an SPGSQL  
connection... you could try doing:

     (send conn exec "\\encoding UTF8")

as soon as you connect. If that works, perhaps it's something that  
could be rolled into SPGSQL's "connect" procedure?

Hope this helps,

-- Dave

Posted on the dev mailing list.