Re: PostgreSQL driver DBD::Pg releases version 3.0.0
Hi David On 08/02/14 03:45, David E. Wheeler wrote: On Feb 7, 2014, at 3:59 AM, Peter J. Holzer wrote: o Decoding incoming data $$item{$_} = decode('utf-8', $$item{$_} || '') for keys %$item Same here. With pg_enable_utf8 I would expect to get character strings, not byte strings, so no decode should be necessary. Yes, true. More: http://savage.net.au/Ron/html/Debian.MariaDB.Perl.DBD.mysql.html The demo uses MySQL, Pg and SQLite. With 3.0.0, if you have your client_encoding set to UTF-8, you can delete the call to pg_enable_utf8 and it will DTRT. I did not try that. This has been a long time coming, but most welcome. Indeed. -- Ron Savage http://savage.net.au/
Re: PostgreSQL driver DBD::Pg releases version 3.0.0
On Feb 7, 2014, at 3:59 AM, Peter J. Holzer wrote: >> o Decoding incoming data >> $$item{$_} = decode('utf-8', $$item{$_} || '') for keys %$item > > Same here. With pg_enable_utf8 I would expect to get character strings, > not byte strings, so no decode should be necessary. With 3.0.0, if you have your client_encoding set to UTF-8, you can delete the call to pg_enable_utf8 and it will DTRT. This has been a long time coming, but most welcome. David
Re: PostgreSQL driver DBD::Pg releases version 3.0.0
Hi Peter I've written a demo using MySQL and will shortly expand it to Pg and SQLite, and then blog about it, either on this list or blogs.perl.org. It stores a string in both encoded and unencoding forms, and retrieves it. On 07/02/14 22:59, Peter J. Holzer wrote: On 2014-02-06 12:30:15 +1100, Ron Savage wrote: 'Major change in UTF-8 handling' is right. I was: I haven't checked the docs yet, just my gut feeling how it should work. o Declaring the Pg db as utf8 I guess this means setting pg_enable_utf8? o Encoding outgoing data Eg: map{($_ => encode('utf-8', $$hashref{$_}) )} keys %$hashref That seems superfluous to me. If you set pg_enable_utf8 I would expect the DBD to translate between perl character strings (aka 'utf8 strings', but you aren't supposed to know that and in newer perls the difference shouldn't matter any more) and whatever encoding the database expects. o Decoding incoming data $$item{$_} = decode('utf-8', $$item{$_} || '') for keys %$item Same here. With pg_enable_utf8 I would expect to get character strings, not byte strings, so no decode should be necessary. hp -- Ron Savage http://savage.net.au/
Re: PostgreSQL driver DBD::Pg releases version 3.0.0
On 2014-02-06 12:30:15 +1100, Ron Savage wrote: > 'Major change in UTF-8 handling' is right. I was: I haven't checked the docs yet, just my gut feeling how it should work. > o Declaring the Pg db as utf8 I guess this means setting pg_enable_utf8? > o Encoding outgoing data > Eg: map{($_ => encode('utf-8', $$hashref{$_}) )} keys %$hashref That seems superfluous to me. If you set pg_enable_utf8 I would expect the DBD to translate between perl character strings (aka 'utf8 strings', but you aren't supposed to know that and in newer perls the difference shouldn't matter any more) and whatever encoding the database expects. > o Decoding incoming data > $$item{$_} = decode('utf-8', $$item{$_} || '') for keys %$item Same here. With pg_enable_utf8 I would expect to get character strings, not byte strings, so no decode should be necessary. hp -- _ | Peter J. Holzer | I think we need two definitions: |_|_) | WSR - Softwaredevelopment | 1) The problem the *users* want us to solve | | | und Projektunterstützung | 2) The problem our solution addresses. __/ | h...@wsr.ac.at |-- Phillip Hallam-Baker on spam signature.asc Description: Digital signature
Re: PostgreSQL driver DBD::Pg releases version 3.0.0
Hi Tim On 06/02/14 23:48, Tim Bunce wrote: On Thu, Feb 06, 2014 at 12:30:15PM +1100, Ron Savage wrote: Eg: map{($_ => encode('utf-8', $$hashref{$_}) )} keys %$hashref $$item{$_} = decode('utf-8', $$item{$_} || '') for keys %$item Performance tip: using the function form of encode() and decode() is significantly slower than using the method call form: $utf8_encoding->decode($$item{$_} || ''): So, first call my($utf8_encoding) = find_encoding('utf-8'), eh? $many x $thanx; And each module tested under V 3.0.0 broke. But a 1-line change fixes them: $$attr{pg_enable_utf8}= 0 if ($$config{dsn} =~ /dbi:Pg/i); Sweet. Gotta love utf8. :) Tim. -- Ron Savage http://savage.net.au/
Re: PostgreSQL driver DBD::Pg releases version 3.0.0
On Thu, Feb 06, 2014 at 12:30:15PM +1100, Ron Savage wrote: > Eg: map{($_ => encode('utf-8', $$hashref{$_}) )} keys %$hashref > $$item{$_} = decode('utf-8', $$item{$_} || '') for keys %$item Performance tip: using the function form of encode() and decode() is significantly slower than using the method call form: $utf8_encoding->decode($$item{$_} || ''): > And each module tested under V 3.0.0 broke. > > But a 1-line change fixes them: > > $$attr{pg_enable_utf8}= 0 if ($$config{dsn} =~ /dbi:Pg/i); Sweet. > Gotta love utf8. :) Tim.
PostgreSQL driver DBD::Pg releases version 3.0.0
Hi 'Major change in UTF-8 handling' is right. I was: o Declaring the Pg db as utf8 o Encoding outgoing data Eg: map{($_ => encode('utf-8', $$hashref{$_}) )} keys %$hashref o Decoding incoming data $$item{$_} = decode('utf-8', $$item{$_} || '') for keys %$item o Using on my web page And each module tested under V 3.0.0 broke. But a 1-line change fixes them: $$attr{pg_enable_utf8}= 0 if ($$config{dsn} =~ /dbi:Pg/i); Gotta love utf8. -- Ron Savage http://savage.net.au/
PostgreSQL driver DBD::Pg releases version 3.0.0
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 Version 3.0.0 of DBD::Pg, the Perl interface to Postgres, has just been released. As you can see from the version number, this is a major release. In addition to many bugfixes and enhancements, the behavior of pg_enable_utf8 has been changed. The minimum versions of Perl (5.8.1) and DBI (1.614) have been increased. The new version is available from CPAN. Checksums: 58c2613bcb241279aca4c111ba16db48 DBD-Pg-3.0.0.tar.gz 03ded628d453718cbceaea906da3412df5a7137a DBD-Pg-3.0.0.tar.gz The complete list of changes: Version 3.0.0 - Major change in UTF-8 handling. If client_encoding is set to UTF-8, always mark returned Perl strings as utf8. See the pg_enable_utf8 docs for more information. [Greg Sabino Mullane, David E. Wheeler, David Christensen] - Bump DBI requirement to 1.614 - Bump Perl requirement to 5.8.1 - Add new handle attribute, switch_prepared, to control when we stop using PQexecParams and start using PQexecPrepared. The default is 2: in previous versions, the effective behavior was 1 (i.e. PQexecParams was never used). [Greg Sabino Mullane] - Better handling of items inside of arrays, particularly bytea arrays. [Greg Sabino Mullane] (CPAN bug #91454) - Map SQL_CHAR back to bpchar, not char [Greg Sabino Mullane, reported by H.Merijn Brand] - Do not force oids to Perl ints [Greg Sabino Mullane] (CPAN bug #85836) - Return better sqlstate codes on fatal errors [Rainer Weikusat] - Better prepared statement names to avoid bug [Spencer Sun] (CPAN bug #88827) - Add pg_expression field to statistics_info output to show functional index information [Greg Sabino Mullane] (CPAN bug #76608) - Adjust lo_import_with_oid check for 8.3 (CPAN bug #83145) - Better handling of libpq errors to return SQLSTATE 08000 [Stephen Keller] - Make sure CREATE TABLE .. AS SELECT returns rows in non do() cases - Add support for AutoInactiveDestroy [David Dick] (CPAN bug #68893) - Fix ORDINAL_POSITION in foreign_key_info [Dagfinn Ilmari Mannsker] (CPAN bug #88794) - Fix foreign_key_info with unspecified schema [Dagfinn Ilmari Mannsker] (CPAN bug #88787) - Allow foreign_key_info to work when pg_expand_array is off [Greg Sabino Mullane and Tim Bunce] (CPAN bug #51780) - Remove math.h linking, as we no longer need it (CPAN bug #79256) - Spelling fixes (CPAN bug #78168) - Better wording for the AutoCommit docs (CPAN bug #82536) - Change NOTICE to DEBUG1 in t/02attribs.t test for handle attribute "PrintWarn": implicit index creation is now quieter in Postgres. [Erik Rijkers] - Use correct SQL_BIGINT constant for int8 [Dagfinn Ilmari Mannsker] - Fix assertion when binding array columns on debug perls >= 5.16 [Dagfinn Ilmari Mannsker] - Adjust test to use 3 digit exponential values [Greg Sabino Mullane] (CPAN bug #59449) - Avoid reinstalling driver methods in threads [Dagfinn Ilmari Mannsker] (CPAN bug #83638) - Make sure App::Info does not prompt for pg_config location if AUTOMATED_TESTING or PERL_MM_USE_DEFAULT is set [David E. Wheeler] (CPAN bug #90799) - Fix typo in docs for pg_placeholder_dollaronly [Bryan Carpenter] (CPAN bug #91400) - Cleanup dangling largeobjects in tests [Fitz Elliott] (CPAN bug #92212) - Fix skip test counting in t/09arrays.t [Greg Sabino Mullane] (CPAN bug #79544) - Explicitly specify en_US for spell checking [Dagfinn Ilmari Mannsker] (CPAN bug #91804) - -- Greg Sabino Mullane g...@turnstep.com End Point Corporation http://www.endpoint.com/ PGP Key: 0x14964AC8 201402050932 http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 -BEGIN PGP SIGNATURE- iEYEAREDAAYFAlLyS34ACgkQvJuQZxSWSsjLcgCeM413ALNdM7rj4SfYMnyEmee5 VtAAnj56tNtWoK9dWJKVg1wHgTsXBXok =6wwX -END PGP SIGNATURE-