Author: timbo
Date: Thu Apr 1 07:01:04 2004
New Revision: 253
Modified:
dbi/trunk/Changes
dbi/trunk/ToDo
dbi/trunk/dbd_xsh.h
dbi/trunk/lib/DBD/Proxy.pm
Log:
Fixed propagation of scalar/list context into proxied methods.
Tweaks to ToDo
Include dbd_xsh.h change for last_insert_id missed from previous submit
Modified: dbi/trunk/Changes
==============================================================================
--- dbi/trunk/Changes (original)
+++ dbi/trunk/Changes Thu Apr 1 07:01:04 2004
@@ -13,6 +13,7 @@
Fixed DBD::DBM $dbh->{dbm_tables}->{...} to be keyed by the
table name not the file name thanks to Jeff Zucker.
Fixed last_insert_id(...) thanks to Rudy Lippan.
+ Fixed propagation of scalar/list context into proxied methods.
Changed selectall_arrayref() to call finish() if
$attr->{MaxRows} is defined.
Modified: dbi/trunk/ToDo
==============================================================================
--- dbi/trunk/ToDo (original)
+++ dbi/trunk/ToDo Thu Apr 1 07:01:04 2004
@@ -14,6 +14,7 @@
(where the driver name is the 4th parameter).
Remove undocumented DBI->err and DBI->errstr methods.
+Or maybe add DBI->state for consistency? Or maybe keep but warn?
Remove old informix fudge in tables() (would only impact people
using very old DBD::Informix versions as it now has it's own).
@@ -37,8 +38,8 @@
%DBI::TraceTopics & %DBD::Foo::TraceTopics
"Lint" topic for extra checking, eg warn on $sth DESTROY if still Active
"Verbose" topic adds verbosity to any other enabled topics
-Change macro to get debug level to only return last 4 bits.
-Add macro framework for 'topic' bits.
+"Connect" topic to log connect/disconnect/reconnect/failed-ping
+Add topic flags to ima struct and log when bits match?
Use one bit for logging just the SQL statement executed
(with no extra text) ideally in a way that lets the text
file be parsed again later. Perhaps append ";\n\n\n" to each.
@@ -192,6 +193,8 @@
--- Other things to consider
+Add $h->err_errstr_state method that returns all three in one go.
+
Study alternate DBI's:
ruby
python
@@ -217,6 +220,9 @@
make lasth return outer handle?
+update lasth on return from method so handles used by the implementation
+of the called method don't affect it?
+
document dbi_fetchall_arrayref_attr attr of selectall_arrayref().
ODBC 3.5 date and intervals types and subtypes (from unixODBC?)
@@ -257,6 +263,35 @@
OTHERS:
+Add method like
+ sub perform_transaction {
+ my ($dbh, $attr, $coderef, @args) = @_;
+ my $wantarray = wantarray;
+ my $use_transaction = 1;
+ my $orig_AutoCommit = $dbh->{AutoCommit};
+ if ($orig_AutoCommit) {
+ unless (eval { $dbh->{AutoCommit} = 0; 1 }) {
+ die unless $allow_non_transaction;
+ $use_transaction = 0;
+ }
+ }
+ local $dbh->{RaiseError} = 1;
+ eval {
+ @result = ($wantarray) ? $coderef->(@args) : scalar $coderef->(@args);
+ $dbh->commit if $use_transaction;
+ $attr->{OnCommit}->() if $attr->{OnCommit}->();
+ };
+ if ($@) {
+ local $@; protect original error
+ my $rv = eval { ($use_transaction) ? $dbh->rollback : 0 };
+ $attr->{OnRollback}->($rv) if $attr->{OnRollback};
+ }
+ die if $@; # propagate original error
+ $dbh->{AutoCommit} = 1 if $orig_AutoCommit;
+ return $result[0] unless $wantarray;
+ return @result;
+ }
+
Change bind_column to save the info for get_fbav to use when
first called. Thus making bind before execute work for all drivers.
Modified: dbi/trunk/dbd_xsh.h
==============================================================================
--- dbi/trunk/dbd_xsh.h (original)
+++ dbi/trunk/dbd_xsh.h Thu Apr 1 07:01:04 2004
@@ -33,7 +33,7 @@
void dbd_db_destroy _((SV *dbh, imp_dbh_t *imp_dbh));
int dbd_db_STORE_attrib _((SV *dbh, imp_dbh_t *imp_dbh, SV *keysv, SV *valuesv));
SV *dbd_db_FETCH_attrib _((SV *dbh, imp_dbh_t *imp_dbh, SV *keysv));
-SV *dbd_db_last_insert_id _((SV *dbh, SV *imp_dbh, SV *catalog, SV *schema, SV
*table, SV *field, SV *attr));
+SV *dbd_db_last_insert_id _((SV *dbh, imp_dbh_t *imp_dbh, SV *catalog, SV
*schema, SV *table, SV *field, SV *attr));
AV *dbd_db_data_sources _((SV *dbh, imp_dbh_t *imp_dbh, SV *attr));
int dbd_st_prepare _((SV *sth, imp_sth_t *imp_sth, char *statement, SV
*attribs));
Modified: dbi/trunk/lib/DBD/Proxy.pm
==============================================================================
--- dbi/trunk/lib/DBD/Proxy.pm (original)
+++ dbi/trunk/lib/DBD/Proxy.pm Thu Apr 1 07:01:04 2004
@@ -241,7 +241,9 @@
q/package ~class~;
sub ~method~ {
my $h = shift;
- my @result = eval { $h->{'proxy_~type~h'}->~method~(@_) };
+ my @result = wantarray
+ ? eval { $h->{'proxy_~type~h'}->~method~(@_) }
+ : eval { scalar $h->{'proxy_~type~h'}->~method~(@_) };
return DBD::Proxy::proxy_set_err($h, $@) if $@;
wantarray ? @result : $result[0];
}
@@ -249,7 +251,9 @@
q/package ~class~;
sub ~method~ {
my $h = shift;
- my @result = eval { $h->{'proxy_~type~h'}->func(@_, '~method~') };
+ my @result = wantarray
+ ? eval { $h->{'proxy_~type~h'}->func(@_, '~method~') }
+ : eval { scalar $h->{'proxy_~type~h'}->func(@_, '~method~') };
return DBD::Proxy::proxy_set_err($h, $@) if $@;
wantarray ? @result : $result[0];
}