Author: timbo
Date: Wed Jul 5 16:03:40 2006
New Revision: 6618
Modified:
dbi/trunk/DBI.pm
dbi/trunk/DBI.xs
dbi/trunk/lib/DBD/Sponge.pm
dbi/trunk/t/15array.t
Log:
Added basic ParamValues support to DBD::Sponge.
Added IMA flag so methods could prevent ParamValues being shown by
ShowErrorStatement
Applied flag to execute_array and execute_for_fetch.
Modified: dbi/trunk/DBI.pm
==============================================================================
--- dbi/trunk/DBI.pm (original)
+++ dbi/trunk/DBI.pm Wed Jul 5 16:03:40 2006
@@ -437,8 +437,8 @@
bind_param_array => { U =>[3,4,'$parameter, $var [, \%attr]'] },
bind_param_inout_array => { U =>[4,5,'$parameter, [EMAIL PROTECTED],
$maxlen, [, \%attr]'] },
- execute_array => { U =>[2,0,'\\%attribs [, @args]'],
O=>0x1040 },
- execute_for_fetch => { U =>[2,3,'$fetch_sub [, $tuple_status]'],
O=>0x1040 },
+ execute_array => { U =>[2,0,'\\%attribs [, @args]'],
O=>0x1040|0x4000 },
+ execute_for_fetch => { U =>[2,3,'$fetch_sub [, $tuple_status]'],
O=>0x1040|0x4000 },
fetch => undef, # alias for fetchrow_arrayref
fetchrow_arrayref => undef,
Modified: dbi/trunk/DBI.xs
==============================================================================
--- dbi/trunk/DBI.xs (original)
+++ dbi/trunk/DBI.xs Wed Jul 5 16:03:40 2006
@@ -118,6 +118,7 @@
#define IMA_NOT_FOUND_OKAY 0x0800 /* no error if not found */
#define IMA_EXECUTE 0x1000 /* do/execute: DBIcf_Executed */
#define IMA_SHOW_ERR_STMT 0x2000 /* dbh meth relates to Statement*/
+#define IMA_HIDE_ERR_PARAMVALUES 0x4000 /* ParamValues are not relevant
*/
#define DBIc_STATE_adjust(imp_xxh, state) \
(SvOK(state) /* SQLSTATE is implemented by driver */ \
@@ -3167,15 +3168,17 @@
&& (statement_svp = hv_fetch((HV*)SvRV(h), "Statement", 9, 0))
&& statement_svp && SvOK(*statement_svp)
) {
- SV **svp;
+ SV **svp = 0;
sv_catpv(msg, " [for Statement \"");
sv_catsv(msg, *statement_svp);
/* fetch from tied outer handle to trigger FETCH magic */
/* could add DBIcf_ShowErrorParams (default to on?) */
- svp = hv_fetch((HV*)DBIc_MY_H(imp_xxh),"ParamValues",11,FALSE);
- if (svp && SvMAGICAL(*svp))
- mg_get(*svp); /* XXX may recurse, may croak. could use eval */
+ if (!(ima_flags & IMA_HIDE_ERR_PARAMVALUES)) {
+ svp = hv_fetch((HV*)DBIc_MY_H(imp_xxh),"ParamValues",11,FALSE);
+ if (svp && SvMAGICAL(*svp))
+ mg_get(*svp); /* XXX may recurse, may croak. could use
eval */
+ }
if (svp && SvRV(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVHV &&
HvKEYS(SvRV(*svp))>0 ) {
HV *bvhv = (HV*)SvRV(*svp);
SV *sv;
Modified: dbi/trunk/lib/DBD/Sponge.pm
==============================================================================
--- dbi/trunk/lib/DBD/Sponge.pm (original)
+++ dbi/trunk/lib/DBD/Sponge.pm Wed Jul 5 16:03:40 2006
@@ -161,6 +161,10 @@
sub execute {
my $sth = shift;
+
+ # hack to support ParamValues (when not using bind_param)
+ $sth->{ParamValues} = (@_) ? { map { $_ => $_[$_-1] } [EMAIL
PROTECTED] } : undef;
+
if (my $hook = $sth->{execute_hook}) {
&$hook($sth, @_) or return;
}
Modified: dbi/trunk/t/15array.t
==============================================================================
--- dbi/trunk/t/15array.t (original)
+++ dbi/trunk/t/15array.t Wed Jul 5 16:03:40 2006
@@ -15,11 +15,11 @@
}
# create a database handle
-my $dbh = DBI->connect("dbi:Sponge:dummy", '', '',
- {
- RaiseError=>1,
- AutoCommit=>1
- });
+my $dbh = DBI->connect("dbi:Sponge:dummy", '', '', {
+ RaiseError => 1,
+ ShowErrorStatement => 1,
+ AutoCommit => 1
+});
# check that our db handle is good
isa_ok($dbh, "DBI::db");
@@ -45,7 +45,9 @@
# -----------------------------------------------
-ok(! eval { $sth->execute_array(
+ok(! eval {
+ local $sth->{PrintError} = 0;
+ $sth->execute_array(
{
ArrayTupleStatus => $tuple_status
},