Author: byterock
Date: Fri Apr 23 09:13:19 2010
New Revision: 13924
Modified:
dbd-oracle/trunk/Oracle.pm
dbd-oracle/trunk/Oracle.xs
dbd-oracle/trunk/t/31lob.t
Log:
Fix for rt.cpan.org Ticket #55028: DBD INVALID_HANDLE: OCILobGetLength
While not a bug I have added in OCILobLocatorIsInit as the fnction
ora_lob_is_init
so the user can test for a condion before an error is thrown
Modified: dbd-oracle/trunk/Oracle.pm
==============================================================================
--- dbd-oracle/trunk/Oracle.pm (original)
+++ dbd-oracle/trunk/Oracle.pm Fri Apr 23 09:13:19 2010
@@ -74,6 +74,7 @@
DBD::Oracle::db->install_method("ora_lob_trim");
DBD::Oracle::db->install_method("ora_lob_length");
DBD::Oracle::db->install_method("ora_lob_chunk_size");
+ DBD::Oracle::db->install_method("ora_lob_is_init");
DBD::Oracle::db->install_method("ora_nls_parameters");
DBD::Oracle::db->install_method("ora_can_unicode");
DBD::Oracle::st->install_method("ora_fetch_scroll");
@@ -3605,6 +3606,15 @@
Returns the length of the LOB.
Uses the Oracle OCILobGetLength function.
+
+=item ora_lob_is_init
+
+ $is_init = $dbh->ora_lob_is_init($lob_locator);
+
+Returns true(1) if the Lob Locator is initialized false(0) if it is not, or
'undef'
+if there is an error.
+Uses the Oracle OCILobLocatorIsInit function.
+
=item ora_lob_chunk_size
$chunk_size = $dbh->ora_lob_chunk_size($lob_locator);
Modified: dbd-oracle/trunk/Oracle.xs
==============================================================================
--- dbd-oracle/trunk/Oracle.xs (original)
+++ dbd-oracle/trunk/Oracle.xs Fri Apr 23 09:13:19 2010
@@ -469,6 +469,24 @@
}
void
+ora_lob_is_init(dbh, locator)
+ SV *dbh
+ OCILobLocator *locator
+ PREINIT:
+ D_imp_dbh(dbh);
+ sword status;
+ boolean is_init = 0;
+ CODE:
+
OCILobLocatorIsInit_log_stat(imp_dbh->envhp,imp_dbh->errhp,locator,&is_init,status);
+ if (status != OCI_SUCCESS) {
+ oci_error(dbh, imp_dbh->errhp, status, "OCILobLocatorIsInit
ora_lob_is_init");
+ ST(0) = &sv_undef;
+ }
+ else {
+ ST(0) = sv_2mortal(newSVuv(is_init));
+ }
+
+void
ora_lob_length(dbh, locator)
SV *dbh
OCILobLocator *locator
@@ -479,7 +497,7 @@
CODE:
OCILobGetLength_log_stat(imp_dbh->svchp, imp_dbh->errhp, locator, &len,
status);
if (status != OCI_SUCCESS) {
- oci_error(dbh, imp_dbh->errhp, status, "OCILobGetLength");
+ oci_error(dbh, imp_dbh->errhp, status, "OCILobGetLength
ora_lob_length");
ST(0) = &sv_undef;
}
else {
Modified: dbd-oracle/trunk/t/31lob.t
==============================================================================
--- dbd-oracle/trunk/t/31lob.t (original)
+++ dbd-oracle/trunk/t/31lob.t Fri Apr 23 09:13:19 2010
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
-use Test::More tests => 11;
+use Test::More tests => 12;
use DBD::Oracle qw(:ora_types);
use DBI;
@@ -103,6 +103,9 @@
is( ref $loc, "OCILobLocatorPtr", "returned valid locator" );
+ is( $dbh->ora_lob_is_init($loc), 1, "returned initialized locator" );
+
+
# write string > 32k
$large_value = 'ABCD' x 10_000;