Commit info for scoop/lib/Scoop:

Modified Files:
	DB.pm 
Log Message:
Getting transaction support into the *rest* of Scoop now. -j



Index: DB.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/DB.pm,v
retrieving revision 1.21
retrieving revision 1.22
diff -r1.21 -r1.22
31a32,33
>         } elsif ($args->{SHARED_USER}) {
>                 $dbh = $S->{SHARED_USER_DB};
165a168,169
>         } elsif ($args->{SHARED_USER}) {
>                 $dbh = $S->{SHARED_USER_DB};
199a204,205
>         } elsif ($args->{SHARED_USER}) {
>                 $dbh = $S->{SHARED_USER_DB};
235a242,243
>         } elsif ($args->{SHARED_USER}) {
>                 $dbh = $S->{SHARED_USER_DB};
266a275,276
>         } elsif ($args->{SHARED_USER}) {
>                 $dbh = $S->{SHARED_USER_DB};
287c297
< 	if ($args->{DEBUG} || $DEBUG) {warn "in db_unlock_tables: Query is $query\n"};
---
> 	if ($args->{DEBUG} || $DEBUG) {warn "in db_unlock_tables: Query is $query\n";}
291a302,303
>         } elsif ($args->{SHARED_USER}) {
>                 $dbh = $S->{SHARED_USER_DB};
301a314,406
> }
> 
> # Add functions for transactions. Can only be used with versions of mysql
> # that use transactions, of course.
> 
> sub db_start_transaction {
>         my $S = shift;
>         my $args = shift;
> 
> 	unless ($S->{CONFIG}->{mysql_version} =~ /^4/) {
> 		return "Transactions not supported in this version of MySQL.\n";
> 		}
>         $Scoop::DB_QUERY_COUNT++ if ($Scoop::COUNT_DEBUG);
>                                                                                 
>         my $query = "START TRANSACTION";
>                                                                                 
>         if ($args->{DEBUG} || $DEBUG) {warn "in db_start_transaction: Query is $query\n";}
>                                                                                 
>         my $dbh;
>         if ($args->{ARCHIVE}) {
>                 $dbh = $S->{DBHARCHIVE};
> 	} elsif ($args->{SHARED_USER}) {
> 		$dbh = $S->{SHARED_USER_DB};
>         } else {
>                 $dbh = $S->{DBH};
>         }
>         return('0E0',undef) unless ($dbh);
>                                                                                 
>         my $sth = $dbh->prepare($query);
>         my $rv = $sth->execute();
>                                                                                 
>         warn "<<ERROR>> in db_start_transaction: $DBI::errstr (Query is $query)\n" unless $rv;
>         return ($rv, $sth);
> }
> 
> sub db_commit {
>         my $S = shift;
>         my $args = shift;
>                                                                                 
> 	unless ($S->{CONFIG}->{mysql_version} =~ /^4/) {
>                 return "Transactions not supported in this version of MySQL.\n";
>                 }
>         $Scoop::DB_QUERY_COUNT++ if ($Scoop::COUNT_DEBUG);
>                                                                                 
>         my $query = "COMMIT";
>                                                                                 
>         if ($args->{DEBUG} || $DEBUG) {warn "in db_commit: Query is $query\n";}
>                                                                                 
>         my $dbh;
>         if ($args->{ARCHIVE}) {
>                 $dbh = $S->{DBHARCHIVE};
>         } elsif ($args->{SHARED_USER}) {
>                 $dbh = $S->{SHARED_USER_DB};
>         } else {
>                 $dbh = $S->{DBH};
>         }
>         return('0E0',undef) unless ($dbh);
>                                                                                 
>         my $sth = $dbh->prepare($query);
>         my $rv = $sth->execute();
>                                                                                 
>         warn "<<ERROR>> in db_commit: $DBI::errstr (Query is $query)\n" unless $rv;
>         return ($rv, $sth);
> }
> 
> sub db_rollback {
>         my $S = shift;
>         my $args = shift;
>                                                                                 
> 	unless ($S->{CONFIG}->{mysql_version} =~ /^4/) {
>                 return "Transactions not supported in this version of MySQL.\n";
>                 }
>         $Scoop::DB_QUERY_COUNT++ if ($Scoop::COUNT_DEBUG);
>                                                                                 
>         my $query = "ROLLBACK";
>                                                                                 
>         if ($args->{DEBUG} || $DEBUG) {warn "in db_rollback: Query is $query\n";}
>                                                                                 
>         my $dbh;
>         if ($args->{ARCHIVE}) {
>                 $dbh = $S->{DBHARCHIVE};
>         } elsif ($args->{SHARED_USER}) {
>                 $dbh = $S->{SHARED_USER_DB};
>         } else {
>                 $dbh = $S->{DBH};
>         }
>         return('0E0',undef) unless ($dbh);
>                                                                                 
>         my $sth = $dbh->prepare($query);
>         my $rv = $sth->execute();
>                                                                                 
>         warn "<<ERROR>> in db_rollback: $DBI::errstr (Query is $query)\n" unless $rv;
>         return ($rv, $sth);