Ah, I was actually completely wrong here. Sorry.
The problem was that $dbh->{Statement} is being set to a "readonly
undef" (&sv_undef) and so could not be modified.
I'll fix the DBI, but a workaround for drivers is to delete Statement
before assigning to it:
sub do {
my ($dbh, $statement, ...) = @_
delete $dbh->{Statement};
$dbh->{Statement} = $statement;
...perform the do...
The Statement attribute should be left set on the dbh after the do(),
so don't undef it before returning.
Tim.
On Thu, Jul 03, 2003 at 08:42:37AM +0200, Henrik Tougaard wrote:
> On Wed, Jul 02, 2003 at 04:43:17PM +0100, Tim Bunce wrote:
> > On Wed, Jul 02, 2003 at 12:09:04PM +0100, Tim Bunce wrote:
> > > On Tue, Jul 01, 2003 at 09:59:10PM -0400, David Coulthart wrote:
> > > > > A DBI trace may help. And send me the code around Ingres.pm line
> 116.
> > > >
> > > > The code from Ingres.pm (for both 0.32 and 0.36) around line 116 is
> the
> > > > do routine:
> > > >
> > > > { package DBD::Ingres::db; # ====== DATABASE ======
> > > > use strict;
> > > >
> > > > sub do {
> > > > my($dbh, $statement, $attribs, @params) = @_;
> > > > Carp::carp "DBD::Ingres::\$dbh->do() attribs unused\n" if
> > > > $attribs;
> > > > Carp::carp "DBD::Ingres::\$dbh->do() params unused\n" if
> > > > @params;
> > > > $dbh->{Statement} = $statement;
> > >
> > > That's just plain wrong. The DBI manages the Statement attribute on
> > > behalf of the drivers. Drivers almost never have to touch it.
>
> Normally yes - $dbh->{Statment} is handled by DBI::_new_sth and DBI::lasth,
> but in this case the driver 'do'es the statement without the use of
> a statement handle.
> So my big question was where do I put the Statement text in this case?
> Experimenting (a long time ago) showed that this approach worked (it
> was before $h->{ShowErrorStatement} etc were implemented).
> What is the 'right way' to do it?
>
> > >
> > > Delete that line.
> > >
> > > > my $numrows = DBD::Ingres::db::_do($dbh, $statement);
> > > > undef $dbh->{Statement};
> >
> > And that one.
>
> Will do for now, so that the error goes away.
>
> Henrik Touggard. DBD::Ingres