Re: Latest DBI::PurePerl

2002-04-05 Thread Jeff Zucker

Tim Bunce wrote:
> 

[other good advice snipped but heeded]

I've added the bitmask checking for IMA_STUB, IMA_KEEP_ERR,
IMA_COPY_STMT, and IMA_FUNC_REDIRECT.

> > sub set_err {
> > my($h,$errnum,$msg,$state)=@_;
> > $msg = $errnum unless defined $msg;
> > #z
> > # Avert your eyes if you don't want to see a horrendous kludge
> > #   (and check DBI::var::FETCH for the other half)
> > $DBI::zerr= $errnum;
> >  ...
> 
> You can reasonably assume that's going in the wrong direction :)
> Talk to me about the problems you were trying to solve here.
> There's bound to be a better way.

The problem is that $DBI::err and friends are not being set.  Another
way I can get around that with almost as good results and without
inventing any new variables like $DBI::zerr, is to patch DBI.pm like so:

sub DBI::var::STORE{
return $DBI::var::STORE_PP(@_) if $DBI::PurePerl;
Carp::croak("Can't modify \$DBI::${$_[0]} special variable") 
}

But maybe I'm missing a more obvious way to let $DBI::err be set on its
own. Or maybe I'm just not fetching it via the pointers correctly.

-- 
Jeff



Who's the current maintainer for DBD::Pg?

2002-04-05 Thread Thomas A. Lowery

Who is currently maintaining DBD::Pg? 


Tom



Re: Latest DBI::PurePerl

2002-04-05 Thread Tim Bunce

On Fri, Apr 05, 2002 at 11:01:10AM +0100, Tim Bunce wrote:
> 
> > sub preparse {
> 
> Do go there!

Ooops, make that Don't go there!

:)

Tim.



Re: Latest DBI::PurePerl

2002-04-05 Thread Tim Bunce

On Thu, Apr 04, 2002 at 01:28:06PM -0800, Jeff Zucker wrote:
> Here's the latest DBI::PurePerl.  I'm sure I've taken some inappropriate
> shortcuts, but the results on DBI-1.21/t/* are looking pretty good, much
> improved over last version:
> 
> Failed Test   Total Fail  Failed 
> -
> 
> t\basics.t   369  25.00%
> t\examp.t   201   40  19.90%  # strange $@ behaviour here
> t\preparse.t 23   16  69.57%
> t\subclass.t 153  20.00%
> 
> 1 test skipped. (proxy.t)
> 
> Failed 4/8 test scripts, 50.00% okay. 68/301 subtests failed, 77.41%
> okay.
> 
> 233 down, 68 to go :-)

Great work!

Some random comments...

> use constant IMA_HAS_USAGE=> 0x0001; #/* check parameter usage*/
> use constant IMA_FUNC_REDIRECT=> 0x0002; #/* is $h->func(..., "method")*/
> use constant IMA_KEEP_ERR => 0x0004; #/* don't reset err & errstr */
> use constant IMA_spare=> 0x0008; #/* */
> use constant IMA_NO_TAINT_IN  => 0x0010; #/* don't check for tainted args*/
> use constant IMA_NO_TAINT_OUT   => 0x0020; #/* don't taint results*/
> use constant IMA_COPY_STMT=> 0x0040; #/* copy sth Statement to dbh */
> use constant IMA_END_WORK => 0x0080; #/* set on commit & rollback */
> use constant IMA_STUB => 0x0100; #/* donothing eg $dbh->connected */

You need to use IMA_KEEP_ERR and IMA_COPY_STMT in _install_method now.
The others can wait. That'll probably fix more tests.

Try to emulate more of what the dispatch() code in DBI.xs is doing.

> if ( $param_hash and defined $param_hash->{'U'}

Don't bother with usage checking.

>and $param_hash->{'O'} == 0x0080

Test bit fields with "... | IMA_...", not ==

> sub set_err {
> my($h,$errnum,$msg,$state)=@_;
> $msg = $errnum unless defined $msg;
> #z
> # Avert your eyes if you don't want to see a horrendous kludge
> #   (and check DBI::var::FETCH for the other half)
> $DBI::zerr= $errnum;
> $DBI::zerrstr = $msg;
> $DBI::zstate  = $state;
> $h->{'zerrstr'}=$msg;
> $h->{'errstr'}=$msg;
> $h->{'state'}=$state if $state;
> $h->{'err'}=$errnum;

You can reasonably assume that's going in the wrong direction :)
Talk to me about the problems you were trying to solve here.
There's bound to be a better way.

> sub preparse {

Do go there! Just have PurePerl.pm set $DBI::PurePerl = 1;
and have t/preparse.t skip the tests if that's set.

Tim.