Author: timbo
Date: Tue Feb 17 03:21:24 2004
New Revision: 65

Modified:
   dbi/trunk/DBI.pm
   dbi/trunk/ToDo
   dbi/trunk/lib/DBD/ExampleP.pm
   dbi/trunk/lib/DBD/Sponge.pm
   dbi/trunk/lib/DBI/DBD.pm
   dbi/trunk/lib/DBI/PurePerl.pm
Log:
Fix $dbh->DBI::set_err(...) to be $dbh->set_err(...)


Modified: dbi/trunk/DBI.pm
==============================================================================
--- dbi/trunk/DBI.pm    (original)
+++ dbi/trunk/DBI.pm    Tue Feb 17 03:21:24 2004
@@ -1480,7 +1480,7 @@
 
     sub begin_work {
        my $dbh = shift;
-       return $dbh->DBI::set_err(1, "Already in a transaction")
+       return $dbh->set_err(1, "Already in a transaction")
                unless $dbh->FETCH('AutoCommit');
        $dbh->STORE('AutoCommit', 0); # will croak if driver doesn't support it
        $dbh->STORE('BegunWork',  1); # trigger post commit/rollback action
@@ -1598,10 +1598,10 @@
        my $sth = shift;
        my ($p_id, $value_array, $attr) = @_;
 
-       return $sth->DBI::set_err(1, "Value for parameter $p_id must be a scalar or an 
arrayref, not a ".ref($value_array))
+       return $sth->set_err(1, "Value for parameter $p_id must be a scalar or an 
arrayref, not a ".ref($value_array))
            if defined $value_array and ref $value_array and ref $value_array ne 
'ARRAY';
 
-       return $sth->DBI::set_err(1, "Can't use named placeholders for non-driver 
supported bind_param_array")
+       return $sth->set_err(1, "Can't use named placeholders for non-driver supported 
bind_param_array")
            unless DBI::looks_like_number($p_id); # because we rely on execute(@ary) 
here
 
        # get/create arrayref to hold params
@@ -1613,7 +1613,7 @@
            foreach (keys %$hash_of_arrays) {
                my $v = $$hash_of_arrays{$_};
                next unless ref $v eq 'ARRAY';
-               return $sth->DBI::set_err(1,
+               return $sth->set_err(1,
                        "Arrayref for parameter $p_id has "[EMAIL PROTECTED]" elements"
                        ." but parameter $_ has "[EMAIL PROTECTED])
                    if @$value_array != @$v;
@@ -1639,7 +1639,7 @@
        # and then return an error
        my ($p_num, $value_array, $attr) = @_;
        $sth->bind_param_array($p_num, $value_array, $attr);
-       return $sth->DBI::set_err(1, "bind_param_inout_array not supported");
+       return $sth->set_err(1, "bind_param_inout_array not supported");
     }
 
     sub bind_columns {
@@ -1670,13 +1670,13 @@
 
        # get tuple status array or hash attribute
        my $tuple_sts = $attr->{ArrayTupleStatus};
-       return $sth->DBI::set_err(1, "ArrayTupleStatus attribute must be an arrayref")
+       return $sth->set_err(1, "ArrayTupleStatus attribute must be an arrayref")
                if $tuple_sts and ref $tuple_sts ne 'ARRAY';
 
        # bind all supplied arrays
        if (@array_of_arrays) {
            $sth->{ParamArrays} = { };  # clear out old params
-           return $sth->DBI::set_err(1,
+           return $sth->set_err(1,
                    @array_of_arrays." bind values supplied but $NUM_OF_PARAMS 
expected")
                if defined ($NUM_OF_PARAMS) && @array_of_arrays != $NUM_OF_PARAMS;
            $sth->bind_param_array($_, $array_of_arrays[$_-1]) or return
@@ -1687,31 +1687,31 @@
 
        if ($fetch_tuple_sub = $attr->{ArrayTupleFetch}) {      # fetch on demand
 
-           return $sth->DBI::set_err(1,
+           return $sth->set_err(1,
                    "Can't use both ArrayTupleFetch and explicit bind values")
                if @array_of_arrays; # previous bind_param_array calls will simply be 
ignored
 
            if (UNIVERSAL::isa($fetch_tuple_sub,'DBI::st')) {
                my $fetch_sth = $fetch_tuple_sub;
-               return $sth->DBI::set_err(1,
+               return $sth->set_err(1,
                        "ArrayTupleFetch sth is not Active, need to execute() it 
first")
                    unless $fetch_sth->{Active};
                # check column count match to give more friendly message
                my $NUM_OF_FIELDS = $fetch_sth->{NUM_OF_FIELDS};
-               return $sth->DBI::set_err(1,
+               return $sth->set_err(1,
                        "$NUM_OF_FIELDS columns from ArrayTupleFetch sth but 
$NUM_OF_PARAMS expected")
                    if defined($NUM_OF_FIELDS) && defined($NUM_OF_PARAMS)
                    && $NUM_OF_FIELDS != $NUM_OF_PARAMS;
                $fetch_tuple_sub = sub { $fetch_sth->fetchrow_arrayref };
            }
            elsif (!UNIVERSAL::isa($fetch_tuple_sub,'CODE')) {
-               return $sth->DBI::set_err(1, "ArrayTupleFetch '$fetch_tuple_sub' is 
not a code ref or statement handle");
+               return $sth->set_err(1, "ArrayTupleFetch '$fetch_tuple_sub' is not a 
code ref or statement handle");
            }
 
        }
        else {
            my $NUM_OF_PARAMS_given = keys %{ $sth->{ParamArrays} || {} };
-           return $sth->DBI::set_err(1,
+           return $sth->set_err(1,
                    "$NUM_OF_PARAMS_given bind values supplied but $NUM_OF_PARAMS 
expected")
                if defined($NUM_OF_PARAMS) && $NUM_OF_PARAMS != $NUM_OF_PARAMS_given;
 
@@ -1811,7 +1811,7 @@
        my $index = $names_hash->{$key_field};  # perl index not column number
        ++$index if defined $index;             # convert to column number
        $index ||= $key_field if DBI::looks_like_number($key_field) && $key_field>=1;
-       return $sth->DBI::set_err(1, "Field '$key_field' does not exist (not one of 
@{[keys %$names_hash]})")
+       return $sth->set_err(1, "Field '$key_field' does not exist (not one of @{[keys 
%$names_hash]})")
                unless defined $index;
        my $key_value;
        $sth->bind_col($index, \$key_value) or return;

Modified: dbi/trunk/ToDo
==============================================================================
--- dbi/trunk/ToDo      (original)
+++ dbi/trunk/ToDo      Tue Feb 17 03:21:24 2004
@@ -157,9 +157,6 @@
 (check if error count has been incremented by set_err).
 Then FETCH would have just CHECK_NEW_ERR.
 
-Change $h->DBI::set_err calls to $h->set_err (re subclassing etc)
-Check for other $h->DBI::foo calls
-
 Trace to tied file handle.
 
 Hooks for method entry and exit.

Modified: dbi/trunk/lib/DBD/ExampleP.pm
==============================================================================
--- dbi/trunk/lib/DBD/ExampleP.pm       (original)
+++ dbi/trunk/lib/DBD/ExampleP.pm       Tue Feb 17 03:21:24 2004
@@ -85,7 +85,7 @@
 
        my($fields, $dir)
                = $statement =~ m/^\s*select\s+(.*?)\s+from\s+(\S*)/i;
-       return $dbh->DBI::set_err(1, "Syntax error in select statement 
(\"$statement\")")
+       return $dbh->set_err(1, "Syntax error in select statement (\"$statement\")")
                unless defined $fields and defined $dir;
 
        my ($outer, $inner) = DBI::_new_sth($dbh, {
@@ -99,7 +99,7 @@
        my @bad = map {
            defined $DBD::ExampleP::statnames{$_} ? () : $_
        } @fields;
-       return $dbh->DBI::set_err(1, "Unknown field names: @bad")
+       return $dbh->set_err(1, "Unknown field names: @bad")
                if @bad;
 
        $inner->{dbd_param} = [];
@@ -137,7 +137,7 @@
        if ($types{TABLE}) {
            no strict 'refs';
            opendir($dh, $dir)
-               or return $dbh->DBI::set_err(int($!),
+               or return $dbh->set_err(int($!),
                                        "Failed to open directory $dir: $!");
            while (defined(my $file = readdir($dh))) {
                next unless -d $file;
@@ -150,7 +150,7 @@
        # We would like to simply do a DBI->connect() here. However,
        # this is wrong if we are in a subclass like DBI::ProxyServer.
        $dbh->{'dbd_sponge_dbh'} ||= DBI->connect("DBI:Sponge:", '','')
-           or return $dbh->DBI::set_err($DBI::err,
+           or return $dbh->set_err($DBI::err,
                        "Failed to connect to DBI::Sponge: $DBI::errstr");
 
        my $attr = {
@@ -164,7 +164,7 @@
        };
        my $sdbh = $dbh->{'dbd_sponge_dbh'};
        my $sth = $sdbh->prepare("SHOW TABLES FROM $dir", $attr)
-           or return $dbh->DBI::set_err($sdbh->err(), $sdbh->errstr());
+           or return $dbh->set_err($sdbh->err(), $sdbh->errstr());
        $sth;
     }
 
@@ -274,11 +274,11 @@
        }
 
        my $dbd_param = $sth->{'dbd_param'} || [];
-       return $sth->DBI::set_err(2, @$dbd_param." values bound when 1 expected")
+       return $sth->set_err(2, @$dbd_param." values bound when 1 expected")
            unless @$dbd_param == 1;
 
        $dir = $dbd_param->[0];
-       return $sth->DBI::set_err(2, "No bind parameter supplied")
+       return $sth->set_err(2, "No bind parameter supplied")
            unless defined $dir;
 
        $sth->finish;
@@ -296,7 +296,7 @@
            $sth->{dbd_dir} = $dir;
            $sth->{dbd_datahandle} = Symbol::gensym(); # 
"DBD::ExampleP::".++$DBD::ExampleP::gensym;
            opendir($sth->{dbd_datahandle}, $dir)
-               or return $sth->DBI::set_err(2, "opendir($dir): $!");
+               or return $sth->set_err(2, "opendir($dir): $!");
        }
        $sth->STORE(Active => 1);
        return 1;

Modified: dbi/trunk/lib/DBD/Sponge.pm
==============================================================================
--- dbi/trunk/lib/DBD/Sponge.pm (original)
+++ dbi/trunk/lib/DBD/Sponge.pm Tue Feb 17 03:21:24 2004
@@ -83,8 +83,7 @@
            } elsif (my $firstrow = $rows->[0]) {
                $numFields = scalar @$firstrow;
            } else {
-               DBI::set_err($dbh, 1, 'Cannot determine NUM_OF_FIELDS');
-               return undef;
+               return $dbh->set_err(1, 'Cannot determine NUM_OF_FIELDS');
            }
            $sth->STORE('NUM_OF_FIELDS' => $numFields);
            $sth->{NAME} = $attribs->{NAME}

Modified: dbi/trunk/lib/DBI/DBD.pm
==============================================================================
--- dbi/trunk/lib/DBI/DBD.pm    (original)
+++ dbi/trunk/lib/DBI/DBD.pm    Tue Feb 17 03:21:24 2004
@@ -977,9 +977,9 @@
 current directory to something not existent by using the
 (driver-specific) f_dir attribute.
 
-To report an error, you use the C<DBI::set_err> method:
+To report an error, you use the C<set_err> method:
 
-  $h->DBI::set_err($errcode, $errmsg);
+  $h->set_err($err, $errmsg, $state);
 
 This will ensure that the error is recorded correctly and that
 RaiseError and PrintError etc are handled correctly.
@@ -989,7 +989,7 @@
 As set_err always returns undef your error handling code can
 usually be simplified to something like this:
 
-  return $h->DBI::set_err($errcode, $errmsg) if ...;
+  return $h->set_err($err, $errmsg, $state) if ...;
 
 =cut
 

Modified: dbi/trunk/lib/DBI/PurePerl.pm
==============================================================================
--- dbi/trunk/lib/DBI/PurePerl.pm       (original)
+++ dbi/trunk/lib/DBI/PurePerl.pm       Tue Feb 17 03:21:24 2004
@@ -632,7 +632,7 @@
 sub state  { return shift->{state}  }
 sub set_err {
     my ($h, $errnum,$msg,$state, $method, $rv) = @_;
-    $h = tied(%$h) || $h; # for code that calls $h->DBI::set_err(...)
+    $h = tied(%$h) || $h;
 
     if (my $hss = $h->{HandleSetErr}) {
        return if $hss->($h, $errnum, $msg, $state, $method);

Reply via email to