Skip Menu |

This queue is for tickets about the DBD-DB2 CPAN distribution.

Report information
The Basics
Id: 57562
Status: resolved
Priority: 0/
Queue: DBD-DB2

People
Owner: Nobody in particular
Requestors: tolix [...] olviko.ru
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Perl DBD::DB2 v1.78 problem with the CLOB data type
Date: Mon, 17 May 2010 23:18:43 +0400
To: opendev [...] us.ibm.com, bug-DBD-DB2 [...] rt.cpan.org
From: Anatoly Davidov <tolix [...] olviko.ru>
Hello! It looks like the new version of DBD::DB2 (v1.78) has an issue with the CLOB data type (at least) on my CentOS/RedHat Linux 5.5 32bit box running DB2 Express-C v9.7, perl v5.8.8. The problem: when a SELECT statement does not contain a CLOB field in the list of fields to return, it works fine (returns rows). But when I am adding a CLOB field - the resulting data set becomes empty.($sth->fetchrow_array() returns undef immediately). The issue is not reproducible on previous versions of DBD::DB2 (v1.76, v1.1). The script to reproduce: #!/usr/bin/perl use strict; use DBI; use Data::Dumper; my $dbh = DBI->connect('dbi:DB2:o3x', '', '') || die DBI::errstr(); $dbh->{LongReadLen} = 2000000; $dbh->{LongTruncOk} = 1; $dbh->do('SET SCHEMA o3x'); # docfield.defvalue is CLOB, codepage CP1251. my $q1 = qq{ SELECT docfield.tablename, docfield.docfieldtag, docfield.tablefieldname, docfield.docfieldname, docfield.defvalue, docfield.quoteme FROM docfield WHERE docfield.doctype = 'Man' }; my $sth = $dbh->prepare($q1) || die $dbh->errstr(); $sth->execute(); while( my @row = $sth->fetchrow_array() ) { print join(', ', @row), "\n"; } die $sth->errstr() if $sth->err; $sth->finish(); $dbh->disconnect();
From: campbell.leigh [...] abc.net.au
On Mon May 17 15:19:24 2010, tolix@olviko.ru wrote: Show quoted text
> Hello! > > It looks like the new version of DBD::DB2 (v1.78) has an issue with the > CLOB data type (at least) on my CentOS/RedHat Linux 5.5 32bit box > running DB2 Express-C v9.7, perl v5.8.8. > > The problem: when a SELECT statement does not contain a CLOB field in > the list of fields to return, it works fine (returns rows). But when I > am adding a CLOB field - the resulting data set becomes > empty.($sth->fetchrow_array() returns undef immediately). > > > The issue is not reproducible on previous versions of DBD::DB2 (v1.76, > v1.1). > > The script to reproduce: > > #!/usr/bin/perl > > use strict; > use DBI; > use Data::Dumper; > > my $dbh = DBI->connect('dbi:DB2:o3x', '', '') || die DBI::errstr(); > > $dbh->{LongReadLen} = 2000000; > $dbh->{LongTruncOk} = 1; > > $dbh->do('SET SCHEMA o3x'); > > # docfield.defvalue is CLOB, codepage CP1251. > > my $q1 = qq{ > SELECT > docfield.tablename, > docfield.docfieldtag, > docfield.tablefieldname, > docfield.docfieldname, > docfield.defvalue, > docfield.quoteme > FROM > docfield > WHERE > docfield.doctype = 'Man' > }; > > my $sth = $dbh->prepare($q1) || die $dbh->errstr(); > $sth->execute(); > > while( my @row = $sth->fetchrow_array() ) > { > print join(', ', @row), "\n"; > } > > die $sth->errstr() if $sth->err; > > $sth->finish(); > $dbh->disconnect(); >
Hi I can also confirm the problem on AIX 5.2, Perl 5.12.0 (64-bit) and DB2 8.1 FP18. However, cannot repeat the problem on AIX 5.2, Perl 5.12.0 (64-bit threaded) and DB2 8.1 FP8.
Hi, I tried the use case described here and am able to retrieve the data correctly. I tried with a simple table containing 3 fields, 1 clob and other 2 varchar. Could you provide us with the CLI trace for your test case run. This will help us with more insight into the problem. Follow the link http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.admin.trb.doc/doc/c0008936.html to obtain the cli trace. Thanks Praveen
Hi Anatoly/Leigh, I was able to reproduce the issue that you are seeing. This happens when the value in the CLOB column is null. I am attaching a patch, containing the fix, to the dbdimp.c file in this defect log. Apply the same and you should be able to get away with the error. Let me know if you require any clarifications. -- Thanks Praveen IBM OpenSource Application Development Team India Software Labs, Bangalore (India)
Subject: perl_null_lob_patch.diff
--- /home/user/perl/DBD-DB2/dbdimp.c ( Version 1.78 ) +++ /home/user/perl/DBD-DB2/dbdimp.c ( Working Copy ) @@ -2562,6 +2562,11 @@ SQLHANDLE new_hstmt; SQLRETURN rc; + if( fbh->loc_ind == SQL_NULL_DATA ) { /* If column value is NULL then set rlen to -1 and return SQL_SUCCESS */ + fbh->rlen = -1; + return SQL_SUCCESS; + } + rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &new_hstmt); if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO ) {
Fix for the Problem available in version 1.79 -- Thanks Praveen IBM OpenSource Application Development Team India Software Labs, Bangalore (India)