Thread: pg_database encoding again

pg_database encoding again

From
"Christopher Kings-Lynne"
Date:
Hi Guys,

I really need a solution to this one :(

What is the encoding of the database names in the pg_database table?  As far
as I can tell, each row is saved in the encoding of the database from which
it is created?  In my application, the actual names change from gobbledygook
to proper japanese or russian say, as I change the encoding of the page
through each database encoding.

How on earth can I display all the names at once?  Is it even possible?
What if I go:

SET CLIENT_ENCODING TO 'UNICODE';
SELECT * FROM pg_database;

That doesn't really seem to work that well though...

Chris



Re: pg_database encoding again

From
Tom Lane
Date:
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> What is the encoding of the database names in the pg_database table?  As far
> as I can tell, each row is saved in the encoding of the database from which
> it is created?

That sounds about right.  If you're using databases of different
encodings in the same installation, it would probably be wise to
restrict yourself to the intersection of those encodings when choosing
database names.

I agree that this isn't ideal, but I don't see any way to improve it.
If you like, we could put in code to *enforce* a restriction to 7-bit
ASCII in database names (and user and group names too) ... but that
doesn't seem like a big improvement.
        regards, tom lane


Re: pg_database encoding again

From
"Christopher Kings-Lynne"
Date:
> That sounds about right.  If you're using databases of different
> encodings in the same installation, it would probably be wise to
> restrict yourself to the intersection of those encodings when choosing
> database names.

Bummer.  So there's no one encoding I can set it to :(  Actually, since the
phpPgAdmin interface only allows the creation of databases via the create
database screen, could we just always set it to the encoding of template1?

How do I get the encoding of the server?  Is that the same as the encoding
of template1?

> I agree that this isn't ideal, but I don't see any way to improve it.
> If you like, we could put in code to *enforce* a restriction to 7-bit
> ASCII in database names (and user and group names too) ... but that
> doesn't seem like a big improvement.

I would suggest force Unicode...

Chris



Re: pg_database encoding again

From
Tom Lane
Date:
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> How do I get the encoding of the server?

There is none.  The per-database encodings are the only truth.
We aren't likely to institute one in future, either; the trend
seems to be more towards decentralization than the reverse.

> I would suggest force Unicode...

Seems quite unacceptable to those who aren't using Unicode.
        regards, tom lane