On Tue, Dec 08, 2009 at 01:32:33PM +0000, Martin Evans wrote: > > Done and one last (I'm hoping) thing. The PurePerl version that was > added does not match the XS version as the success of the cast (or not) > is not reflected in the return value.
That PurePerl one I did was just a rough sketch. > The following change fixes it but > I'd rather see some comment on it before committing: > > Index: lib/DBI/PurePerl.pm > =================================================================== > --- lib/DBI/PurePerl.pm (revision 13653) > +++ lib/DBI/PurePerl.pm (working copy) > @@ -682,21 +682,30 @@ > > return -1 unless defined $_[0]; > > - my $cast_ok = 0; > + my $cast_ok = 1; > > - if ($sql_type == SQL_INTEGER) { > - my $dummy = $_[0] + 0; > - } > - elsif ($sql_type == SQL_DOUBLE) { > - my $dummy = $_[0] + 0.0; > - } > - elsif ($sql_type == SQL_NUMERIC) { > - my $dummy = $_[0] + 0.0; > - } > - else { > - return -2; > - } > + my $evalret = eval { > + use warnings FATAL => qw(numeric); > + if ($sql_type == SQL_INTEGER) { > + my $dummy = $_[0] + 0; > + return 1; > + } > + elsif ($sql_type == SQL_DOUBLE) { > + my $dummy = $_[0] + 0.0; > + return 1; > + } > + elsif ($sql_type == SQL_NUMERIC) { > + my $dummy = $_[0] + 0.0; > + return 1; > + } > + else { > + return -2; > + } > + } or warn $@; > > + return $evalret if defined($evalret) && ($evalret == -2); > + $cast_ok = 0 unless $evalret; > + > # DBIstcf_DISCARD_STRING not supported for PurePerl currently > > return 2 if $cast_ok; > > With this in place all the tests pass on 5.10.1 and 5.10.0. use warnings FATAL => qw(numeric); is s nice approach. I don't think that'll affect the minimum perl version (5.8.1) The lack of difference in the code between SQL_DOUBLE and SQL_NUMERIC is a little troubling, though I've no time to think about it right now. Go ahead and commit anyway. I think docs for DBI::sql_type_cast are the next thing we need. Tim.