Author: timbo
Date: Mon Oct 29 14:07:20 2012
New Revision: 15460

Modified:
   dbi/branches/sqlengine/   (props changed)
   dbi/branches/sqlengine/Changes
   dbi/branches/sqlengine/DBI.pm
   dbi/branches/sqlengine/TODO_2005.txt
   dbi/branches/sqlengine/ex/unicode_test.pl
   dbi/branches/sqlengine/t/08keeperr.t

Log:
merged trunk in

Modified: dbi/branches/sqlengine/Changes
==============================================================================
--- dbi/branches/sqlengine/Changes      (original)
+++ dbi/branches/sqlengine/Changes      Mon Oct 29 14:07:20 2012
@@ -10,21 +10,23 @@
 
 =head2 Changes in DBI 1.623
 
-  Added logic to force destruction of children before parents
-    during global destruction. Currently experimental.
-
+  Fix RT#72343 and add patches for it (Martin Evans, Jens Rehsack)
+  Fix RT#64330 - ping wipes out errstr.
+    Removed _not_impl (Martin J. Evans).
   Fixed unused variable / self-assignment compiler warnings.
-
   Corrected typo in DBI->installed_versions docs RT#78825
     thanks to Jan Dubois.
 
-  Refactor table meta information management from DBD::File into
+  Refactored table meta information management from DBD::File into
     DBI::DBD::SqlEngine (H.Merijn Brand, Jens Rehsack)
   Pevent undefined f_dir being used in opendir (H.Merijn Brand)
-  DBD::File Plugin-Support for table names and data sources
-    (Jens Rehsack, #dbi Team)
 
-  Fix RT#72343 and add patches for it (Martin Evans, Jens Rehsack)
+  Added logic to force destruction of children before parents
+    during global destruction. Currently experimental.
+  Added DBD::File Plugin-Support for table names and data sources
+    (Jens Rehsack, #dbi Team)
+  Added new tests to 08keeperr for RT#64330
+   thanks to Kenichi Ishigaki.
 
 =head2 Changes in DBI 1.622 (svn r15327) 6th June 2012
 
@@ -307,7 +309,7 @@
   Fixed DBD_ATTRIB_DELETE macro for driver authors
     and updated DBI::DBD docs thanks to Martin J. Evans.
   Fixed 64bit issues in trace messages thanks to Charles Jardine.
-  Fixed FETCH_many() method to work with drivers that incorrectly return 
+  Fixed FETCH_many() method to work with drivers that incorrectly return
     an empty list from $h->FETCH. Affected gofer.
 
   Added 'sqlite_' as registered prefix for DBD::SQLite.
@@ -483,7 +485,7 @@
 =head2 Changes in DBI 1.56 (svn rev 9660),  18th June 2007
 
   Fixed printf arg warnings thanks to JDHEDDEN.
-  Fixed returning driver-private sth attributes via gofer.   
+  Fixed returning driver-private sth attributes via gofer.
 
   Changed pod docs docs to use =head3 instead of =item
     so now in html you get links to individual methods etc.
@@ -734,7 +736,7 @@
     (driver authors who have used it should rerun it).
 
   Updated docs for NULL Value placeholders thanks to Brian Campbell.
-  
+
   Added multi-keyfield nested hash fetching to fetchall_hashref()
     thanks to Zhuang (John) Li for polishing up my draft.
   Added registered driver prefixes: amzn_ for DBD::Amazon and yaswi_ for 
DBD::Yaswi.
@@ -1275,7 +1277,7 @@
   : This does not affect statements that only select one column, which is
   : usually the case when fetchrow_array is called in a scalar context.
   : FYI, this change was triggered by discovering that the fetchrow_array
-  : implementation in Driver.xst (used by most compiled drivers) 
+  : implementation in Driver.xst (used by most compiled drivers)
   : didn't match the DBI specification. Rather than change the code
   : to match, and risk breaking existing applications, I've changed the
   : specification (that part was always of dubious value anyway).
@@ -2018,12 +2020,12 @@
     DBI scripts no longer need to be modified to make use of Apache::DBI.
   Added a ping method and an experimental connect_test_perf method.
   Added a fetchhash and fetch_all methods.
-  The func method no longer pre-clears err and errstr. 
+  The func method no longer pre-clears err and errstr.
   Added ChopBlanks attribute (currently defaults to off, that may change).
     Support for the attribute needs to be implemented by individual drivers.
   Reworked tests into standard t/*.t form.
   Added more pod text.  Fixed assorted bugs.
-  
+
 
 =head2 Changes in DBI 0.79,    7th Apr 1997
 

Modified: dbi/branches/sqlengine/DBI.pm
==============================================================================
--- dbi/branches/sqlengine/DBI.pm       (original)
+++ dbi/branches/sqlengine/DBI.pm       Mon Oct 29 14:07:20 2012
@@ -390,7 +390,6 @@
        'FIRSTKEY'      => $keeperr,
        'NEXTKEY'       => $keeperr,
        'STORE'         => { O=>0x0418 | 0x4 },
-       _not_impl       => undef,
        can             => { O=>0x0100 }, # special case, see dispatch
        debug           => { U =>[1,2,'[$debug_level]'],        O=>0x0004 }, # 
old name for trace
        dump_handle     => { U =>[1,3,'[$message [, $level]]'], O=>0x0004 },
@@ -1344,12 +1343,6 @@
 
     # methods common to all handle types:
 
-    sub _not_impl {
-       my ($h, $method) = @_;
-       $h->trace_msg("Driver does not implement the $method method.\n");
-       return; # empty list / undef
-    }
-
     # generic TIEHASH default methods:
     sub FIRSTKEY { }
     sub NEXTKEY  { }
@@ -1711,7 +1704,6 @@
 
     sub ping {
        my $dbh = shift;
-       $dbh->_not_impl('ping');
        # "0 but true" is a special kind of true 0 that is used here so
        # applications can check if the ping was a real ping or not
        ($dbh->FETCH('Active')) ?  "0 but true" : 0;

Modified: dbi/branches/sqlengine/TODO_2005.txt
==============================================================================
--- dbi/branches/sqlengine/TODO_2005.txt        (original)
+++ dbi/branches/sqlengine/TODO_2005.txt        Mon Oct 29 14:07:20 2012
@@ -142,7 +142,7 @@
 
 pre and post call hooks via ima structure?
 
-Remove _not_impl. Alias debug to trace in DBI::(dr/db/st) and remove
+Alias debug to trace in DBI::(dr/db/st) and remove
 debug() method from internals.
 
 DBD::Multiplex enhancements (Thomas Kishel <[email protected]>):

Modified: dbi/branches/sqlengine/ex/unicode_test.pl
==============================================================================
--- dbi/branches/sqlengine/ex/unicode_test.pl   (original)
+++ dbi/branches/sqlengine/ex/unicode_test.pl   Mon Oct 29 14:07:20 2012
@@ -17,7 +17,8 @@
 # some do:
 #   insert into sometable (a_column) values(:fred);
 #   bind_param('fred', x);
-# This script does the latter - see unicode_param_markers
+# This script does the latter by default except for DBD::SQLite
+#   - see unicode_param_markers and $param_marker_style where you can set the :
 #
 # DBD::ODBC currently fails:
 # not ok 3 - unicode table found by qualified table_info
@@ -55,6 +56,7 @@
 my $unicode_column_type;       # 'nvarchar for MS SQL Server'
 my $blob_column_type;          # = 'image' for MS SQL Server
 my $blob_bind_type;            # type to pass to bind_param for blobs
+my $param_marker_style; # some DBDs need a column in front of param names in 
bind_param_call
 
 # may be different in different SQL support
 # if your DBD/db needs a different function to return the length in
@@ -99,6 +101,7 @@
     $blob_bind_type = SQL_BLOB;
     $unicode_column_type = 'varchar';
     $h->{sqlite_unicode} = 1;
+    $param_marker_style = ':';
 }
 elsif ($driver eq 'CSV') {
     # does not support column_info
@@ -182,8 +185,7 @@
        csv     => [ "dbi:CSV:",                  $user, $pass ],
        mysql   => [ "dbi:mysql:database=test",   $user, $pass ],
        odbc    => [ "dbi:ODBC:DSN=asus2",        $user, $pass ],
-       oracle  => [ "dbi:Oracle:host=betoracle.easysoft.local;sid=devel",
-                                                 'bet', 'b3t' ],
+       oracle  => [ "dbi:Oracle:host=xxx.easysoft.local;sid=devel", 'xxx', 
'yyy' ],
        pg      => [ "dbi:Pg:dbname=test",        $user, $pass ],
        sqlite  => [ "dbi:SQLite:dbname=unitest_8.db", "", ""       ],
        unify   => [ "dbi:Unify:",                $ENV{USCHEMA}, undef ],
@@ -195,6 +197,14 @@
     $dsn =~ m/:/ or
         ($dsn, $user, $pass) = @{$dsn{lc $dsn} || die "No connect info\n"};
 
+    if ($dsn =~ /^dbi:SQLite/) {
+        # The pod for SQLite is confusing and has changed. Initially it said 
sqlite_unicode
+        # must be set at connect time and cannot be set later on the 
connection handle
+        # and now it says
+        # "but this only works if the sqlite_unicode attribute is set before 
the first call to a perl collation sequence"
+        # so we set it here
+        $attr{sqlite_unicode} = 1;
+    }
     my $h = DBI->connect($dsn, $user, $pass, { RaiseError => 1, %attr });
     return $h;
 }
@@ -425,7 +435,7 @@
     my $param_marker = "fred\x{20ac}";
     lives_ok {
         my $s = $h->prepare(qq/insert into $table (a) values 
(:$param_marker)/);
-        $s->bind_param($param_marker, 1);
+        $s->bind_param($param_marker_style . $param_marker, 1);
         $s->execute;
     } 'bind parameter with unicode parameter marker';
 

Modified: dbi/branches/sqlengine/t/08keeperr.t
==============================================================================
--- dbi/branches/sqlengine/t/08keeperr.t        (original)
+++ dbi/branches/sqlengine/t/08keeperr.t        Mon Oct 29 14:07:20 2012
@@ -2,7 +2,7 @@
 
 use strict;
 
-use Test::More tests => 79;
+use Test::More tests => 89;
 
 ## ----------------------------------------------------------------------------
 ## 08keeperr.t
@@ -90,6 +90,31 @@
     # so here we just test that there is an error
     ok $dbh->err, "err true after failed ping";
     ok $dbh->errstr, "errstr true after failed ping";
+
+
+    # for a driver which doesn't have its own ping
+    $dbh = DBI->connect('DBI:Sponge:', undef, undef, { PrintError => 0 });
+    $dbh->STORE(Active => 1);
+
+    $dbh->set_err(42, "ERROR 42");
+    is $dbh->err, 42;
+    is $dbh->errstr, "ERROR 42";
+    ok $dbh->ping, "ping returns true: ".$dbh->ping;
+    is $dbh->err, 42, "err unchanged after ping";
+    is $dbh->errstr, "ERROR 42", "errstr unchanged after ping";
+
+    $dbh->disconnect;
+    $dbh->STORE(Active => 0);
+
+    $dbh->set_err(42, "ERROR 42");
+    is $dbh->err, 42, "err unchanged after ping";
+    is $dbh->errstr, "ERROR 42", "errstr unchanged after ping";
+    ok !$dbh->ping, "ping returns false";
+    # it's reasonable for ping() to set err/errstr if it fails
+    # so here we just test that there is an error
+    ok $dbh->err, "err true after failed ping";
+    ok $dbh->errstr, "errstr true after failed ping";
+
 }
 
 ## ----------------------------------------------------------------------------

Reply via email to