Subject: | LOBs bound with ora_field broken |
Attached patch with fix and failing test.
--
Rafael
Subject: | dbd-ora-lob.patch |
diff --git a/oci8.c b/oci8.c
index 675b795..94365ab 100644
--- a/oci8.c
+++ b/oci8.c
@@ -3675,6 +3675,7 @@ init_lob_refetch(SV *sth, imp_sth_t *imp_sth)
"Need bind_param(..., { ora_field=>... }) attribute to identify table LOB field names");
}
}
+ }
matched = 1;
sprintf(sql_field, "%s%s \"%s\"",
(SvCUR(sql_select)>7)?", ":"", p, &phs->name[1]);
@@ -3693,7 +3694,6 @@ init_lob_refetch(SV *sth, imp_sth_t *imp_sth)
fbh->desc_t = OCI_DTYPE_LOB;
OCIDescriptorAlloc_ok(imp_sth->envhp, &fbh->desc_h, fbh->desc_t);
break; /* we're done with this placeholder now */
- }
}
if (!matched) {
++unmatched_params;
diff --git a/t/31lob.t b/t/31lob.t
index e2a9b7e..bfdc6c9 100644
--- a/t/31lob.t
+++ b/t/31lob.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
-use Test::More tests => 9;
+use Test::More tests => 11;
use DBD::Oracle qw(:ora_types);
use DBI;
@@ -38,6 +38,19 @@ $sth->execute;
($loc) = $sth->fetchrow;
is (ref $loc, "OCILobLocatorPtr", "returned valid locator");
+## test inserting a large value
+$stmt = "INSERT INTO $table (id,data) VALUES (666, ?)";
+$sth = $dbh->prepare($stmt);
+my $content = join(q{}, map { chr } ( 32 .. 64 )) x 16384;
+$sth->bind_param(1, $content, { ora_type => ORA_BLOB, ora_field => 'data' });
+eval { $sth->execute($content) };
+is $@, '', 'inserted into BLOB successfully';
+{
+ local $dbh->{LongReadLen} = 1_000_000;
+ my ($fetched) = $dbh->selectrow_array("select data from $table where id = 666");
+ is $fetched, $content, 'got back what we put in';
+}
+
## test with insert empty blob returning blob to a var.
($id, $loc) = (2, undef);
$stmt = "INSERT INTO $table (id,data) VALUES (?, EMPTY_BLOB()) RETURNING data INTO ?";