On Thu, May 13, 2004 at 01:46:28PM +0100, Lauder, Andy wrote:
> All,
>
> The clone method copies across the connection parameter values from the
> original connection parameter values. It does not copy across the
> connection parameter values as they are at the time of the clone.
>
> This is shown in the two examples below.
>
> It is working as described in the manual pages but what is the reasoning
> behind this?
Implementation complexity. A fix is for drivers to keep a copy of any set
attribute values in the "attribute cache" so the DBI can see them.
(Either that, or to override the clone method to manage the cloning of
attributes, but that's much harder.)
I'll fix dbd_db_STORE_attrib() in DBD::Oracle. I've appended an -untested- patch.
Other driver authors should check their code.
Tim.
===================================================================
--- dbdimp.c (revision 329)
+++ dbdimp.c (working copy)
@@ -799,8 +799,8 @@
{
STRLEN kl;
char *key = SvPV(keysv,kl);
- SV *cachesv = NULL;
int on = SvTRUE(valuesv);
+ int cacheit = 1;
if (kl==10 && strEQ(key, "AutoCommit")) {
DBIc_set(imp_dbh,DBIcf_AutoCommit, on);
@@ -821,8 +821,8 @@
else {
return FALSE;
}
- if (cachesv) /* cache value for later DBI 'quick' fetch? */
- hv_store((HV*)SvRV(dbh), key, kl, cachesv, 0);
+ if (cacheit) /* cache value for later DBI 'quick' fetch? */
+ hv_store((HV*)SvRV(dbh), key, kl, newSVsv(valuesv), 0);
return TRUE;
}
> DBI-1.42 DBD-Oracle-1.15
>
>
> Example 1 - (Shows working as described in manual pages):
>
> use DBI;
> use DBD::Oracle qw(:ora_types);
>
> $dbh =
> DBI->connect("dbi:Oracle:","username","password",{ora_ph_type=>ORA_CHAR});
> $ph_type = $dbh->{ora_ph_type};
> print "ora_ph_type for original is :$ph_type:\n"; # prints 96
>
> $dbh2 = $dbh->clone();
> $ph_type = $dbh2->{ora_ph_type};
> print "ora_ph_type for clone is :$ph_type:\n"; # prints 96
>
>
> Example 2 (Shows case where ora_ph_type is copied from original connection
> parameter values, not the values at the time of the clone):
>
> use DBI;
> use DBD::Oracle qw(:ora_types);
>
> $dbh = DBI->connect("dbi:Oracle:","username","password");
> $ph_type = $dbh->{ora_ph_type};
> print "ora_ph_type for original is :$ph_type:\n"; # prints 1
>
> $dbh->{ora_ph_type} = ORA_CHAR;
> $ph_type = $dbh->{ora_ph_type};
> print "reset ora_ph_type for original to :$ph_type:\n"; # prints 96
>
> $dbh2 = $dbh->clone();
> $ph_type = $dbh2->{ora_ph_type};
> print "ora_ph_type for clone is :$ph_type:\n"; # prints 1
>
>
>
> This e-mail is intended only for the above addressee. It may contain
> privileged information. If you are not the addressee you must not copy,
> distribute, disclose or use any of the information in it. If you have
> received it in error please delete it and immediately notify the sender.
> Security Notice: all e-mail, sent to or from this address, may be
> accessed by someone other than the recipient, for system management and
> security reasons. This access is controlled under Regulation of
> Investigatory Powers Act 2000, Lawful Business Practises.