On Jul 2, 2013, at 6:35 AM, [email protected] wrote:
> Committed by Greg Sabino Mullane <[email protected]>
>
> Another stab at the UTF-8 system, this time simplified as much as possible.
> See the pod for pg_enable_utf8 for an explanation.
> Note that this commit will probably be picked out later, as we
> want to release a new minor version before releasing such a big
> change
Great news, Greg, thank you!
> +DBD::Pg specific attribute. The behavior of DBD::Pg with regards to this
> flag has
> +changed as of version xxx. The default value for this attribute, -1,
> indicates
> +that the internal C<utf8> flag will be turned on for all strings coming back
> +from the database if the client_encoding is set to 'UTF8'.
What happens if the client encoding is *not* UTF8? Does it also recognize
"UTF-8", "utf-8", and "unicode"?
> Use of this default
> +is highly encouraged, and you should not need to use this attribute except
> +for the following two conditions:
> +
> +If this attribute is set to 0, then the internal C<utf8> flag will *never*
> be
> +turned on for returned data, regardless of the current client_encoding.
> +
> +If this attribute is set to -1, then the internal C<utf8> flag will *always*
> +be turned on for returned data, regardless of the current client_encoding
> +(with the exception of bytea data).
Shouldn't that be 1?
What if it's set to 2, or 42?
Will it turn on the flag for all data without regard to type?
This looks like a good compromise to me: setting it to a boolean retains the
previous behavior (more or less, unless setting it to 1 still converts it for
specific types), and the new default is much saner (assuming that it applies to
*all* types).
> + /*
> + The only exception to our rule about setting
> utf8 if the client_encoding
> + is set to UTF8 is bytea.
> + */
> + if (type_info && PG_BYTEA ==
> type_info->type_id) {
> + SvUTF8_off(sv);
> + }
> + else {
> + SvUTF8_on(sv);
> }
> }
> -#endif
> }
> }
Isn't bytea returned in hex? If so, turning on UTF8 should do nothing. Maybe
DBD::Pg should decode bytea to binary, though?
Excited for this, thanks Greg!
Best,
David