pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedDetecting SQL_ASCII databases
4+ messages / 2 participants
[nested] [flat]
* Detecting SQL_ASCII databases
@ 2004-09-18 22:35 Oliver Jowett <oliver@opencloud.com>
0 siblings, 1 reply; 4+ messages in thread
From: Oliver Jowett @ 2004-09-18 22:35 UTC (permalink / raw)
To: pgsql-jdbc
8.0 backends report the server_encoding value of the database via
ParameterStatus during startup. I'd like to use this to detect SQL_ASCII
databases and complain loudly.
The simplest approach is: if the server reports server_encoding on V3
startup, and it is SQL_ASCII, close the connecton and throw SQLException.
Perhaps a nicer approach is to do this on V3 connections:
1) if charSet=foo is specified, send a startup packet with
client_encoding = foo, otherwise send client_encoding = UNICODE. Set the
actual connection encoding to match client_encoding.
2) if the server reports server_encoding = SQL_ASCII and charSet was not
specified, close the connection and throw SQLException.
and change the >=7.3 logic in the V2 path to respect charSet if used,
for consistency with the 7.2 and V3 paths.
This lets users who have SQL_ASCII databases continue to use them by
explicitly specifying an encoding to use.
We still have some inconsistency in when you get the "this db is
SQL_ASCII, go away" class of error but I'm not sure if this is worth
fixing. It seems like we'd need an extra roundtrip on connection setup
to check it for 7.4 servers.
Another issue is whether we should allow charSet to be used when
server_encoding != SQL_ASCII. It seems confusing to allow this, but we
can only detect it after we've established a connection and set
everything up. Should we throw an error, change client_encoding back to
UNICODE, or just continue with the specified charSet?
Opinions?
-O
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Detecting SQL_ASCII databases
@ 2004-09-20 09:31 Kris Jurka <books@ejurka.com>
parent: Oliver Jowett <oliver@opencloud.com>
0 siblings, 1 reply; 4+ messages in thread
From: Kris Jurka @ 2004-09-20 09:31 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc
On Sun, 19 Sep 2004, Oliver Jowett wrote:
> 8.0 backends report the server_encoding value of the database via
> ParameterStatus during startup. I'd like to use this to detect SQL_ASCII
> databases and complain loudly.
That would certainly help people who have setup their databases
incorrectly, but it is actually legal to have a setup like this as long as
you only use seven bit ascii characters. I'm not sure where I stand on
this. There are probably plenty of databases that are working fine with
the current setup. For example even using 8 bit chars in a SQL_ASCII
database, if all clients are unicode then the only problem you'll see is
the length check in something like varchar(100) failing.
Kris Jurka
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Detecting SQL_ASCII databases
@ 2004-09-23 00:29 Oliver Jowett <oliver@opencloud.com>
parent: Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 4+ messages in thread
From: Oliver Jowett @ 2004-09-23 00:29 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
Kris Jurka wrote:
>
> On Sun, 19 Sep 2004, Oliver Jowett wrote:
>
>
>>8.0 backends report the server_encoding value of the database via
>>ParameterStatus during startup. I'd like to use this to detect SQL_ASCII
>>databases and complain loudly.
>
>
> That would certainly help people who have setup their databases
> incorrectly, but it is actually legal to have a setup like this as long as
> you only use seven bit ascii characters.
We could support this case by requiring charSet=SQL_ASCII to be
specified if you have this case. (this would set client_encoding =
SQL_ASCII and interpret data as US-ASCII).
Part of the problem is that SQL_ASCII seems to mean "just store whatever
I'm given directly"; there is no real "7-bit ascii only" encoding?
> I'm not sure where I stand on
> this. There are probably plenty of databases that are working fine with
> the current setup. For example even using 8 bit chars in a SQL_ASCII
> database, if all clients are unicode then the only problem you'll see is
> the length check in something like varchar(100) failing.
We could support this with charSet=UNICODE (set client_encoding =
SQL_ASCII and interpret data as UTF-8)
-O
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Detecting SQL_ASCII databases
@ 2004-09-23 07:16 Kris Jurka <books@ejurka.com>
parent: Oliver Jowett <oliver@opencloud.com>
0 siblings, 0 replies; 4+ messages in thread
From: Kris Jurka @ 2004-09-23 07:16 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc
On Thu, 23 Sep 2004, Oliver Jowett wrote:
> >>8.0 backends report the server_encoding value of the database via
> >>ParameterStatus during startup. I'd like to use this to detect SQL_ASCII
> >>databases and complain loudly.
> >
Sounds good to me as long as we can make existing "broken" setups still
work (at least as well as they do now). I was initially hesitant because
you seemed to want to force people to encode their data correctly
(requiring a dump/reload). If they just need to set a URL parameter
acknowledging that their setup isn't quite right, that's low impact.
Kris Jurka
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2004-09-23 07:16 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-09-18 22:35 Detecting SQL_ASCII databases Oliver Jowett <oliver@opencloud.com>
2004-09-20 09:31 ` Kris Jurka <books@ejurka.com>
2004-09-23 00:29 ` Oliver Jowett <oliver@opencloud.com>
2004-09-23 07:16 ` Kris Jurka <books@ejurka.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox