Author: timbo
Date: Mon Apr 30 05:10:59 2007
New Revision: 9475
Modified:
dbi/trunk/Changes
dbi/trunk/DBI.pm
dbi/trunk/ex/perl_dbi_nulls_test.pl
Log:
Added details for SQLite 3.3 to NULL handling docs thanks to Alex Teslik
Modified: dbi/trunk/Changes
==============================================================================
--- dbi/trunk/Changes (original)
+++ dbi/trunk/Changes Mon Apr 30 05:10:59 2007
@@ -68,6 +68,7 @@
Added support for DBI Profile Path to contain refs to scalars
which will be de-ref'd for each profile sample.
Added dbilogstrip utility to edit DBI logs for diff'ing (gets installed)
+ Added details for SQLite 3.3 to NULL handling docs thanks to Alex Teslik.
Gofer related changes:
Fixed gofer pipeone & stream transports to avoid risk of hanging.
@@ -78,7 +79,7 @@
Added header to request and response packets for sanity checking
and to enable version skew between client and server.
Added forced_single_resultset, max_cached_sth_per_dbh and
max_cached_dbh_per_drh
- ro gofer executor config.
+ to gofer executor config.
Driver-private methods installed with install_method are now proxied.
No longer does a round-trip to the server for methods it knows
have not been overridden by the remote driver.
Modified: dbi/trunk/DBI.pm
==============================================================================
--- dbi/trunk/DBI.pm (original)
+++ dbi/trunk/DBI.pm Mon Apr 30 05:10:59 2007
@@ -2438,6 +2438,7 @@
MS SQL N N Y N Y ? Y
Sybase Y N N N N N Y
AnyData,DBM,CSV Y N N N Y Y* Y
+ SQLite 3.3 N N N N Y N N
* Works only because Example 0 works.
Modified: dbi/trunk/ex/perl_dbi_nulls_test.pl
==============================================================================
--- dbi/trunk/ex/perl_dbi_nulls_test.pl (original)
+++ dbi/trunk/ex/perl_dbi_nulls_test.pl Mon Apr 30 05:10:59 2007
@@ -41,14 +41,14 @@
# We expect the non-null test to return row 3 (Marge)
# and the null test to return rows 2 and 4 (the undefs).
-my $homer = "Homer ";
-my $marge = "Marge ";
+my $homer = "Homer";
+my $marge = "Marge";
my @char_column_values = (
- $homer,
- undef,
- $marge,
- undef
+ $homer, # 1
+ undef, # 2
+ $marge, # 3
+ undef, # 4
);
# Define the SQL statements with the various WHERE clause styles we want to
test
@@ -89,16 +89,12 @@
my @ok;
print "=> Drop table '$tablename', if it already exists...\n";
-$sth = $dbh->do("DROP TABLE $tablename");
+do { local $dbh->{PrintError}=0; $dbh->do("DROP TABLE $tablename"); };
print "=> Create table '$tablename'...\n";
-$sth = $dbh->prepare("CREATE TABLE $tablename (myid int NOT NULL, mycol
char(8))");
-
-# Use this if your database does not support NULL columns by default.
-#$sth = $dbh->prepare("CREATE TABLE $tablename (myid int NOT NULL, mycol
char(8) NULL)");
-
-$sth->execute()
- || $sth->errstr;
+$dbh->do("CREATE TABLE $tablename (myid int NOT NULL, mycol char(5))");
+# Use this if your database does not support NULL columns by default:
+#$dbh->do("CREATE TABLE $tablename (myid int NOT NULL, mycol char(5) NULL)");
print "=> Insert 4 rows into the table...\n";
@@ -106,16 +102,18 @@
for my $i (0..$#char_column_values)
{
my $val = $char_column_values[$i];
- printf "Values %d %s\n", $i+1, defined($val)? $val : "";
- $sth->execute($i+1, $val)
- || $sth->errstr;
+ printf "Inserting values (%d, %s)\n", $i+1, $dbh->quote($val);
+ $sth->execute($i+1, $val);
}
+print "(Driver bug: statement handle should not be Active after an INSERT.)\n"
+ if $sth->{Active};
+
# Run the tests...
for my $i (0..$#select_clauses)
{
my $sel = $select_clauses[$i];
- print "\n=> Testing clause style $i: ".$sel->{clause}."\n";
+ print "\n=> Testing clause style $i: ".$sel->{clause}." to match $marge\n";
$sth = $dbh->prepare("SELECT myid,mycol FROM $tablename ".$sel->{clause})
or next;
@@ -123,49 +121,52 @@
$sth->execute(@{$sel->{nonnull}})
or next;
my $r1 = $sth->fetchall_arrayref();
- my $n1r = $sth->rows;
+ my $n1_rows = $sth->rows;
my $n1 = @$r1;
$sth->execute(@{$sel->{null}})
or next;
my $r2 = $sth->fetchall_arrayref();
- my $n2r = $sth->rows;
+ my $n2_rows = $sth->rows;
my $n2 = @$r2;
# Complain a bit...
print "\n=>Your DBD driver doesn't support the 'rows' method very
well.\n\n"
- unless ($n1r == $n1 && $n2r == $n2);
+ unless ($n1_rows == $n1 && $n2_rows == $n2);
# Did we get back the expected "n"umber of rows?
# Did we get back the specific "r"ows we expected as identifed by the myid
column?
- if ( $n1 == 1
- && $n2 == 2
- && $r1->[0][0] == 3
- && $r2->[0][0] == 2
- && $r2->[1][0] == 4)
- {
+ if ( $n1 == 1 # one row for Marge
+ && $n2 == 2 # two rows for nulls
+ && $r1->[0][0] == 3 # Marge is myid 3
+ && $r2->[0][0] == 2 # NULL for myid 2
+ && $r2->[1][0] == 4 # NULL for myid 4
+ ) {
print "=> WHERE clause style $i is supported.\n";
- push @ok, "$i: ".$sel->{clause};
+ push @ok, "\tStyle $i: ".$sel->{clause};
}
else
{
print "=> WHERE clause style $i returned incorrect results.\n";
if ($n1 > 0 || $n2 > 0)
{
- print " Non-Null test rows returned: ";
- print " ", $r1->[$_][0] for (0..$#{$r1});
- print "\n";
- print " Null test rows returned: ";
- print " ", $r2->[$_][0] for (0..$#{$r2});
- print "\n";
+ print " Non-NULL test rows returned these row ids: ".
+ join(", ", map { $r1->[$_][0] } (0..$#{$r1}))."\n";
+ print " The NULL test rows returned these row ids: ".
+ join(", ", map { $r2->[$_][0] } (0..$#{$r1}))."\n";
}
}
}
$dbh->disconnect();
-printf "\n%d styles are supported\n", scalar @ok;
+printf "\n%d styles are supported $tag:\n", scalar @ok;
print "$_\n" for @ok;
print "\n";
+print "If these results don't match what's in the 'Placeholders and Bind
Values'\n";
+print "section of the DBI documentation, or are for a database that not
already listed,\n";
+print "please email the results to [EMAIL PROTECTED] Thank you.\n";
+
+exit 0;