-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

Here's the latest proposed utf8 plan:

On connection, we check if the database (server_encoding) 
is SQL_ASCII. If it is, we do nothing. If it is not SQL_ASCII, 
we check the client_encoding. If not UTF-8, we SET it so.

We also check if the pg_enable_utf8 flag is set before the above. 
If it is set to true, we ignore the SQL_ASCII check. If set to 
false, we do not do the UTF-8 client_encoding SET.

At this point, all we care about is if we are in utf8 mode, or 
byte soup mode. If the former, we assume everything coming back 
from the database is UTF-8 and mark it as such in the Perl strings. 
If the latter, we do nothing special and never set strings to utf8. 
How we get to the states:

byte soup: server_encoding is SQL_ASCII or pg_enable_utf8 is false
utf8: server_encoding != SQL_ASCII or pg_enable_utf8 is true

What happens when pg_enable_utf8 is changed later on? If the value 
is set to true, and it was false before, we do NOT set client_encoding 
to UTF-8 (as we may be in a transaction), but simply raise a warning 
if it is not set to UTF-8 already. Then we flip the internal flag 
from byte soup to utf-8. If the value is set to false, we do not change 
the client_encoding* and flip the internal bit from utf8 to byte soup.

* One complication: is it worth it to store the initial client_encoding 
before we change it so that we know whether to issue a warning when they 
flip pg_enable_utf8 off and they were NOT in UTF-8 originally*?

** A further complication: client_encoding is a fairly arbitrary string, 
so we really should be doing a generous comparison to catch things 
like 'uTF--_8' (which is valid, sadly).

At this point, I'm blocked on being able to read pg_enable_utf8 inside 
the login function. In theory, DBD_ATTRIB_GET_IV should work, but I 
cannot seem to get it to do the right thing. When I get some cycles 
I will dig in further, but anyone else feel free to take a swing. 
We need something like this inside of dbd_db_login6:

DBD_ATTRIB_GET_IV( attr, "pg_enable_utf8",  14, svp, userutf8);

- -- 
Greg Sabino Mullane g...@turnstep.com
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201102031506
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8

-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAk1LCzkACgkQvJuQZxSWSsjD2ACePibJq4oJnUCmGUcqPUPEdMfe
B0IAn0oF/bGwvJNeBGZODPg02MVnheVr
=C812
-----END PGP SIGNATURE-----


Reply via email to