Thread: Passing server_encoding to the client is not future-proof

Passing server_encoding to the client is not future-proof

From
Peter Eisentraut
Date:
Has anyone thought of what will happen to the server_encoding parameter
when the character set/encoding will be settable for individual columns
and the concept of a global server encoding will go away?  What will
happen to clients that make use of this parameter?

-- 
Peter Eisentraut   peter_e@gmx.net


Re: Passing server_encoding to the client is not future-proof

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> Has anyone thought of what will happen to the server_encoding parameter
> when the character set/encoding will be settable for individual columns
> and the concept of a global server encoding will go away?  What will
> happen to clients that make use of this parameter?

I would imagine that we'd keep the concept of a per-database encoding,
but it would be become a default value for per-column encoding choices,
rather than the One True Value.  Clients could probably still make use
of server_encoding, though I'm unclear on what they'd use it for now,
let alone then.  ISTM client_encoding is the only setting the client
need deal with directly.
        regards, tom lane


Re: Passing server_encoding to the client is not future-proof

From
Peter Eisentraut
Date:
Tom Lane writes:

> Clients could probably still make use of server_encoding, though I'm
> unclear on what they'd use it for now, let alone then.  ISTM
> client_encoding is the only setting the client need deal with directly.

Then why did we add a GUC variable "server_encoding" at all?

-- 
Peter Eisentraut   peter_e@gmx.net


Re: Passing server_encoding to the client is not future-proof

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> Then why did we add a GUC variable "server_encoding" at all?

The JDBC guys wanted to know it.  Why is not clear to me, but I figured
it was easy enough to make them happy.
        regards, tom lane


Re: Passing server_encoding to the client is not future-proof

From
Rod Taylor
Date:
On Tue, 2003-07-29 at 09:50, Tom Lane wrote:
> Peter Eisentraut <peter_e@gmx.net> writes:
> > Then why did we add a GUC variable "server_encoding" at all?
>
> The JDBC guys wanted to know it.  Why is not clear to me, but I figured
> it was easy enough to make them happy.

It could still be useful for stored procedures (particularly Java ones)
which would have to deal with the encoding at the server.

Re: Passing server_encoding to the client is not future-proof

From
Carlos Guzman Alvarez
Date:
Hello:

> The JDBC guys wanted to know it.  Why is not clear to me, but I figured
> it was easy enough to make them happy.

I'm using it too in my .NET Data Provider for allow atomatic encoding of 
strings before send it to the server.




-- 
Best regards

Carlos Guzmán Álvarez
Vigo-Spain



Re: Passing server_encoding to the client is not future-proof

From
Tom Lane
Date:
Peter Eisentraut writes:
> Tom Lane wrote:
>> Clients could probably still make use of server_encoding, though I'm
>> unclear on what they'd use it for now, let alone then.  ISTM
>> client_encoding is the only setting the client need deal with directly.

> Then why did we add a GUC variable "server_encoding" at all?

I've just remembered one issue that bears on this subject.  Back around
mid-May we discussed whether "binary" transmission of textual datatypes
ought to perform client<->server encoding conversion or not.  If it does
not, then obviously it would be useful for clients to know what encoding
they are getting.

The current code does perform conversion in these cases.  I think that
when the May thread died off, we were leaning to changing it, but I've
not made it happen yet.

Of course, if we someday support multiple encodings on the server side,
life gets complex --- how would a client know which encoding it's
getting in a binary transmission?  (Perhaps it would have to be part of
the data.)  It doesn't seem like that's a reason to stay with
always-convert, though.  One of the reasons for not doing conversion in
binary mode is to have an escape hatch for unconvertible characters,
eg for dump purposes.  That need will get worse with multiple server
encodings.
        regards, tom lane


Re: Passing server_encoding to the client is not future-proof

From
Peter Eisentraut
Date:
Tom Lane writes:

> One of the reasons for not doing conversion in binary mode is to have an
> escape hatch for unconvertible characters, eg for dump purposes.

That functionality is already provided by setting the client encoding to
SQL_ASCII.

-- 
Peter Eisentraut   peter_e@gmx.net


Re: Passing server_encoding to the client is not future-proof

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> Tom Lane writes:
>> One of the reasons for not doing conversion in binary mode is to have an
>> escape hatch for unconvertible characters, eg for dump purposes.

> That functionality is already provided by setting the client encoding to
> SQL_ASCII.

Hm.  Okay, so are you arguing that we should not remove encoding
conversion from the binary-transmission case?
        regards, tom lane


Re: Passing server_encoding to the client is not future-proof

From
Peter Eisentraut
Date:
Carlos Guzman Alvarez writes:

> > The JDBC guys wanted to know it.  Why is not clear to me, but I figured
> > it was easy enough to make them happy.
>
> I'm using it too in my .NET Data Provider for allow atomatic encoding of
> strings before send it to the server.

Why would you want to do that?  The server can do the encoding conversion.
You're bound to get into trouble using this approach.

-- 
Peter Eisentraut   peter_e@gmx.net



Re: Passing server_encoding to the client is not future-proof

From
Peter Eisentraut
Date:
Tom Lane writes:

> Peter Eisentraut <peter_e@gmx.net> writes:
> > Tom Lane writes:
> >> One of the reasons for not doing conversion in binary mode is to have an
> >> escape hatch for unconvertible characters, eg for dump purposes.
>
> > That functionality is already provided by setting the client encoding to
> > SQL_ASCII.
>
> Hm.  Okay, so are you arguing that we should not remove encoding
> conversion from the binary-transmission case?

I think a binary mode for text is pretty useless, at least compared to
binary modes for numbers and other data types, where they are clearly
useful.  Therefore, we should keep the binary mode the same as the normal
mode and just label it "binary".  (I assume it's not practical to not have
a binary mode for particular data types.)

-- 
Peter Eisentraut   peter_e@gmx.net



Re: Passing server_encoding to the client is not future-proof

From
Peter Eisentraut
Date:
Tom Lane writes:

> The JDBC guys wanted to know it.  Why is not clear to me, but I figured
> it was easy enough to make them happy.

The JDBC guys didn't respond, and I don't see it used in their source
code, so I'm inclined to remove it.

-- 
Peter Eisentraut   peter_e@gmx.net