Dytut
Dytut

Reputation: 317

psql console not accepting localization

I have encountered a strange problem on one of our machines.

It is a fresh install of Debian Squeeze, with Postgres 8.4.10.

I have a few localizations installed on the machine, locale -a gives this:

C
en_US
en_US.iso88591
en_US.utf8
POSIX
swedish
sv_SE
sv_SE.iso88591
sv_SE.utf8

In the regular linux console I can use swedish localization (åäö works), but when I enter the psql console I can't use localized characters. Doesn't matter how I configure my terminal (tried just about every encoding I can think of).

The database itself works fine, I can input localized chars by making a SQL file and keep the inserts there. It's just no the most efficient way of doing it ;-)

Haven't run into this problem before, and I've installed quite a few machines. Does anyone have any idea of what could possibly be the cause of this?

Upvotes: 6

Views: 1002

Answers (2)

Daniel Vérité
Daniel Vérité

Reputation: 61696

I believe you're experiencing the problem explained in this bug report: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=608442

Summary: due to a licensing issue, psql is now linked to libedit instead of libreadline, and unfortunately libedit is broken/incomplete with regard to accented characters. According to the report, a work-around is to launch psql with:

LD_PRELOAD=/lib/libreadline.so.5 psql

or upgrade the postgresql-common package to version 114 or higher. Since it's not in the stable branch, the easiest way may be to switch to backports:

# aptitude -t squeeze-backports install postgresql-common

Upvotes: 7

Clodoaldo Neto
Clodoaldo Neto

Reputation: 125534

Check the database encoding with \l then check the client encoding:

=> show client_encoding;
 client_encoding 
-----------------
 UTF8
(1 row)

If they do not match then change the client encoding to that of the database:

set client_encoding=iso88591;

Upvotes: 0

Related Questions