Incompatibility with DBI v1.56 / DBD::Sybase v1.08 / DBIx::ContextualFetch v1.03
Incompatibility with DBI v1.56 / DBD::Sybase v1.08 / DBIx::ContextualFetch v1.03
am 30.05.2007 04:45:37 von David.Wood
Hello,
We're running Perl v5.8.6 on Linux, Solaris Sparc, and Solaris x86.
We're using the latest DBI/DBD related modules:
o DBI v1.56
o DBD::Sybase v1.08
o DBIx::ContextualFetch v1.03
o Class::DBI v3.0.16
o Class::DBI::Sybase v0.5
o Ima::DBI v0.34
o etc
We recently upgraded DBD::Sybase from v1.07 to v1.08. The upgrade
resulted in the following problem on all platforms:
Undefined subroutine &DBIx::ContextualFetch::st::DELETE
I mentioned the problem to Michael Peppler; however, I don't think he's
very familiar with DBIx::ContextualFetch and friends ... nor am I sure
this is a DBD::Sybase problem. I narrowed down the failure to this
piece of code (DBD-Sybase/dbdimp.c):
static void clear_cache(SV *sth, imp_sth_t *imp_sth)
{
dTHX;
/* Code from DBI::DBD */
/* Clear cached statement handle attributes, if necessary */
hv_delete((HV*)SvRV(sth), "NAME", 4, G_DISCARD);
hv_delete((HV*)SvRV(sth), "NULLABLE", 8, G_DISCARD);
hv_delete((HV*)SvRV(sth), "NUM_OF_FIELDS", 13, G_DISCARD);
hv_delete((HV*)SvRV(sth), "PRECISION", 9, G_DISCARD);
hv_delete((HV*)SvRV(sth), "SCALE", 5, G_DISCARD);
hv_delete((HV*)SvRV(sth), "TYPE", 4, G_DISCARD);
}
It seems Michael was implementing the changes described here:
http://www.mail-archive.com/dbi-dev@perl.org/msg04663.html
=20
http://search.cpan.org/~timb/DBI-1.56/lib/DBI/DBD.pm#The_mor e_results_me
thod
I decided to e-mail dbi-users since the motivation for this change came
from here. If this isn't the correct list ... hopefully someone can
direct me to a more appropriate list. David
Re: Incompatibility with DBI v1.56 / DBD::Sybase v1.08 / DBIx::ContextualFetch v1.03
am 30.05.2007 12:00:16 von Tim.Bunce
Thanks for the report David.
I believe clear_cache() is only called on an 'inner' handle, which is
not tied. So I can't see why you'd get this error. (Or why the error
would say "Undefined subroutine" and not "Can't find method".)
To be able to look into this I'll need a very small test case that uses as
few modules as possible. Ideally just DBI + DBD::Sybase + DBIx::ContextualFetch.
Tim.
On Tue, May 29, 2007 at 10:45:37PM -0400, Wood, David wrote:
> Hello,
>
> We're running Perl v5.8.6 on Linux, Solaris Sparc, and Solaris x86.
> We're using the latest DBI/DBD related modules:
> o DBI v1.56
> o DBD::Sybase v1.08
> o DBIx::ContextualFetch v1.03
> o Class::DBI v3.0.16
> o Class::DBI::Sybase v0.5
> o Ima::DBI v0.34
> o etc
>
> We recently upgraded DBD::Sybase from v1.07 to v1.08. The upgrade
> resulted in the following problem on all platforms:
>
> Undefined subroutine &DBIx::ContextualFetch::st::DELETE
>
> I mentioned the problem to Michael Peppler; however, I don't think he's
> very familiar with DBIx::ContextualFetch and friends ... nor am I sure
> this is a DBD::Sybase problem. I narrowed down the failure to this
> piece of code (DBD-Sybase/dbdimp.c):
>
> static void clear_cache(SV *sth, imp_sth_t *imp_sth)
> {
> dTHX;
>
> /* Code from DBI::DBD */
> /* Clear cached statement handle attributes, if necessary */
>
> hv_delete((HV*)SvRV(sth), "NAME", 4, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "NULLABLE", 8, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "NUM_OF_FIELDS", 13, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "PRECISION", 9, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "SCALE", 5, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "TYPE", 4, G_DISCARD);
> }
>
> It seems Michael was implementing the changes described here:
>
> http://www.mail-archive.com/dbi-dev@perl.org/msg04663.html
>
> http://search.cpan.org/~timb/DBI-1.56/lib/DBI/DBD.pm#The_mor e_results_me
> thod
>
> I decided to e-mail dbi-users since the motivation for this change came
> from here. If this isn't the correct list ... hopefully someone can
> direct me to a more appropriate list. David
RE: Incompatibility with DBI v1.56 / DBD::Sybase v1.08 / DBIx::ContextualFetch v1.03
am 07.06.2007 01:45:45 von David.Wood
It took us a while to whittle this down into a small test case; however,
the fruits of labour seem to have paid off:=20
% perl -MDBI -e 'my $dbh =3D
DBI->connect("dbi:Sybase:server=3DMYSERVER","janedoe","janep ass"); my
$arr_ref =3D $dbh->selectall_arrayref("execute sp_who"); print
@{$arr_ref->[0]},"\n";=20
Can't locate object method "DELETE" via package "DBI::st" at -e line 1.
%
The problem only seems to occur executing stored procedures ... notice a
"select" is fine:
% perl -MDBI -e 'my $dbh =3D
DBI->connect("dbi:Sybase:server=3DMYSERVER","janedoe","janep ass"); my
$arr_ref =3D $dbh->selectall_arrayref("select 1"); print
@{$arr_ref->[0]},"\n";=20
1
%
The error with this small test case is different than the original
problem report ... but I'm hoping it uncovers whatever the underlying
problem is. David
-----Original Message-----
From: Tim Bunce [mailto:Tim.Bunce@pobox.com]=20
Sent: Wednesday, May 30, 2007 6:00 AM
To: Wood, David
Cc: dbi-users@perl.org
Subject: Re: Incompatibility with DBI v1.56 / DBD::Sybase v1.08 /
DBIx::ContextualFetch v1.03
Thanks for the report David.
I believe clear_cache() is only called on an 'inner' handle, which is
not tied. So I can't see why you'd get this error. (Or why the error
would say "Undefined subroutine" and not "Can't find method".)
To be able to look into this I'll need a very small test case that uses
as
few modules as possible. Ideally just DBI + DBD::Sybase +
DBIx::ContextualFetch.
Tim.
On Tue, May 29, 2007 at 10:45:37PM -0400, Wood, David wrote:
> Hello,
>=20
> We're running Perl v5.8.6 on Linux, Solaris Sparc, and Solaris x86.
> We're using the latest DBI/DBD related modules:
> o DBI v1.56
> o DBD::Sybase v1.08
> o DBIx::ContextualFetch v1.03
> o Class::DBI v3.0.16
> o Class::DBI::Sybase v0.5
> o Ima::DBI v0.34
> o etc
>=20
> We recently upgraded DBD::Sybase from v1.07 to v1.08. The upgrade
> resulted in the following problem on all platforms:
>=20
> Undefined subroutine &DBIx::ContextualFetch::st::DELETE
>=20
> I mentioned the problem to Michael Peppler; however, I don't think
he's
> very familiar with DBIx::ContextualFetch and friends ... nor am I sure
> this is a DBD::Sybase problem. I narrowed down the failure to this
> piece of code (DBD-Sybase/dbdimp.c):
>=20
> static void clear_cache(SV *sth, imp_sth_t *imp_sth)
> {
> dTHX;
>=20
> /* Code from DBI::DBD */
> /* Clear cached statement handle attributes, if necessary */
>=20
> hv_delete((HV*)SvRV(sth), "NAME", 4, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "NULLABLE", 8, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "NUM_OF_FIELDS", 13, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "PRECISION", 9, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "SCALE", 5, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "TYPE", 4, G_DISCARD);
> }
>=20
> It seems Michael was implementing the changes described here:
>=20
> http://www.mail-archive.com/dbi-dev@perl.org/msg04663.html
> =20
>
http://search.cpan.org/~timb/DBI-1.56/lib/DBI/DBD.pm#The_mor e_results_me
> thod
>=20
> I decided to e-mail dbi-users since the motivation for this change
came
> from here. If this isn't the correct list ... hopefully someone can
> direct me to a more appropriate list. David
Re: Incompatibility with DBI v1.56 / DBD::Sybase v1.08 / DBIx::ContextualFetch v1.03
am 07.06.2007 03:11:03 von mgainty
Good Evening David-
You will need BOTH DBI and DBIx::Procedure::DBName packages (where DBName is
name of DBVendor)
*assume* both of these packages are available from CPAN
so the 1st 3 lines of your perl script should look something like
#@/usr/local/bin/perl -w
use DBI:
use DBIx::Procedure::DBName
#then the code which works for Oracle....
my $dbh = DBI->connect( 'dbi:Oracle:',
qq{$db_username/$db_password@(DESCRIPTION=(ADDRESS=(PROTOCOL =TCP)(HOST=$db_host)(PORT=1521))(CONNECT_DATA=(SID=$db_SID)) )}
)|| die "Database connection not made: $DBI::errstr";
print 'About to my $proc = DBIx::Procedure::Oracle->new($dbh, object_name =>
NameOfProcedure)';
#first set the object (change NameOfProcedure to actual NameOfProcedure)
my $proc = DBIx::Procedure::Oracle->new($dbh, object_name =>
'NameOfProcedure');
HTH/
Martin--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed. If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy. Thank you.
----- Original Message -----
From: "Wood, David"
To: "Tim Bunce"
Cc: ;
Sent: Wednesday, June 06, 2007 7:45 PM
Subject: RE: Incompatibility with DBI v1.56 / DBD::Sybase v1.08 /
DBIx::ContextualFetch v1.03
It took us a while to whittle this down into a small test case; however,
the fruits of labour seem to have paid off:
% perl -MDBI -e 'my $dbh =
DBI->connect("dbi:Sybase:server=MYSERVER","janedoe","janepas s"); my
$arr_ref = $dbh->selectall_arrayref("execute sp_who"); print
@{$arr_ref->[0]},"\n";
Can't locate object method "DELETE" via package "DBI::st" at -e line 1.
%
The problem only seems to occur executing stored procedures ... notice a
"select" is fine:
% perl -MDBI -e 'my $dbh =
DBI->connect("dbi:Sybase:server=MYSERVER","janedoe","janepas s"); my
$arr_ref = $dbh->selectall_arrayref("select 1"); print
@{$arr_ref->[0]},"\n";
1
%
The error with this small test case is different than the original
problem report ... but I'm hoping it uncovers whatever the underlying
problem is. David
-----Original Message-----
From: Tim Bunce [mailto:Tim.Bunce@pobox.com]
Sent: Wednesday, May 30, 2007 6:00 AM
To: Wood, David
Cc: dbi-users@perl.org
Subject: Re: Incompatibility with DBI v1.56 / DBD::Sybase v1.08 /
DBIx::ContextualFetch v1.03
Thanks for the report David.
I believe clear_cache() is only called on an 'inner' handle, which is
not tied. So I can't see why you'd get this error. (Or why the error
would say "Undefined subroutine" and not "Can't find method".)
To be able to look into this I'll need a very small test case that uses
as
few modules as possible. Ideally just DBI + DBD::Sybase +
DBIx::ContextualFetch.
Tim.
On Tue, May 29, 2007 at 10:45:37PM -0400, Wood, David wrote:
> Hello,
>
> We're running Perl v5.8.6 on Linux, Solaris Sparc, and Solaris x86.
> We're using the latest DBI/DBD related modules:
> o DBI v1.56
> o DBD::Sybase v1.08
> o DBIx::ContextualFetch v1.03
> o Class::DBI v3.0.16
> o Class::DBI::Sybase v0.5
> o Ima::DBI v0.34
> o etc
>
> We recently upgraded DBD::Sybase from v1.07 to v1.08. The upgrade
> resulted in the following problem on all platforms:
>
> Undefined subroutine &DBIx::ContextualFetch::st::DELETE
>
> I mentioned the problem to Michael Peppler; however, I don't think
he's
> very familiar with DBIx::ContextualFetch and friends ... nor am I sure
> this is a DBD::Sybase problem. I narrowed down the failure to this
> piece of code (DBD-Sybase/dbdimp.c):
>
> static void clear_cache(SV *sth, imp_sth_t *imp_sth)
> {
> dTHX;
>
> /* Code from DBI::DBD */
> /* Clear cached statement handle attributes, if necessary */
>
> hv_delete((HV*)SvRV(sth), "NAME", 4, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "NULLABLE", 8, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "NUM_OF_FIELDS", 13, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "PRECISION", 9, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "SCALE", 5, G_DISCARD);
> hv_delete((HV*)SvRV(sth), "TYPE", 4, G_DISCARD);
> }
>
> It seems Michael was implementing the changes described here:
>
> http://www.mail-archive.com/dbi-dev@perl.org/msg04663.html
>
>
http://search.cpan.org/~timb/DBI-1.56/lib/DBI/DBD.pm#The_mor e_results_me
> thod
>
> I decided to e-mail dbi-users since the motivation for this change
came
> from here. If this isn't the correct list ... hopefully someone can
> direct me to a more appropriate list. David
Re: Incompatibility with DBI v1.56 / DBD::Sybase v1.08 / DBIx::ContextualFetch v1.03
am 07.06.2007 12:54:53 von Tim.Bunce
On Wed, Jun 06, 2007 at 07:45:45PM -0400, Wood, David wrote:
> It took us a while to whittle this down into a small test case; however,
> the fruits of labour seem to have paid off:
>
> % perl -MDBI -e 'my $dbh =
> DBI->connect("dbi:Sybase:server=MYSERVER","janedoe","janepas s"); my
> $arr_ref = $dbh->selectall_arrayref("execute sp_who"); print
> @{$arr_ref->[0]},"\n";
> Can't locate object method "DELETE" via package "DBI::st" at -e line 1.
Excellent! Good small test cases lead to quick fixes...
The real bug here is an old one - almost 5 years old - in the DBI.
Here's a quick fix for DBD::Sybase 1.08 till DBI 1.57 is released:
--- dbdimp.c.orig 2007-04-19 11:31:19.000000000 -0700
+++ dbdimp.c 2007-06-07 03:40:57.000000000 -0700
@@ -3834,6 +3834,11 @@
return Nullav;
}
+ /* workaround for bug in DBI < 1.57: fetch was called with outer */
+ /* handle by XS versions of selectall_arrayref() etc. */
+ if (SvMAGICAL(SvRV(sth)) && mg_find(SvRV(sth),'P'))
+ sth = mg_find(SvRV(sth),'P')->mg_obj; /* switch to inner handle */
+
ChopBlanks = DBIc_has(imp_sth, DBIcf_ChopBlanks);
TryAgain:
Tim.
RE: Incompatibility with DBI v1.56 / DBD::Sybase v1.08 / DBIx::ContextualFetch v1.03
am 08.06.2007 04:01:52 von David.Wood
Much obliged for the quick fix Tim! I found another problem with
DBD::Sybase v1.08 and Ima::DBI ... although it was easy to work around.
I created these bug reports:
http://www.peppler.org/bugdb/view?bug_id=3D632=20
http://www.peppler.org/bugdb/view?bug_id=3D633
Everything now seems to be working with both of these patches. Yippee
:-). David
-----Original Message-----
From: Tim Bunce [mailto:Tim.Bunce@pobox.com]=20
Sent: Thursday, June 07, 2007 6:55 AM
To: Wood, David
Cc: Tim Bunce; dbi-users@perl.org; mpeppler@peppler.org
Subject: Re: Incompatibility with DBI v1.56 / DBD::Sybase v1.08 /
DBIx::ContextualFetch v1.03
On Wed, Jun 06, 2007 at 07:45:45PM -0400, Wood, David wrote:
> It took us a while to whittle this down into a small test case;
however,
> the fruits of labour seem to have paid off:=20
>=20
> % perl -MDBI -e 'my $dbh =3D
> DBI->connect("dbi:Sybase:server=3DMYSERVER","janedoe","janep ass"); my
> $arr_ref =3D $dbh->selectall_arrayref("execute sp_who"); print
> @{$arr_ref->[0]},"\n";=20
> Can't locate object method "DELETE" via package "DBI::st" at -e line
1.
Excellent! Good small test cases lead to quick fixes...
The real bug here is an old one - almost 5 years old - in the DBI.
Here's a quick fix for DBD::Sybase 1.08 till DBI 1.57 is released:
--- dbdimp.c.orig 2007-04-19 11:31:19.000000000 -0700
+++ dbdimp.c 2007-06-07 03:40:57.000000000 -0700
@@ -3834,6 +3834,11 @@
return Nullav;
}
=20
+ /* workaround for bug in DBI < 1.57: fetch was called with outer
*/
+ /* handle by XS versions of selectall_arrayref() etc.
*/
+ if (SvMAGICAL(SvRV(sth)) && mg_find(SvRV(sth),'P'))
+ sth =3D mg_find(SvRV(sth),'P')->mg_obj; /* switch to inner
handle */
+
ChopBlanks =3D DBIc_has(imp_sth, DBIcf_ChopBlanks);
=20
TryAgain:
Tim.