From: Karl DeBisschop <kdebisschop@range.infoplease.com>
To: oleg@sai.msu.su
Cc: ZeugswetterA@wien.spardat.at
Cc: hackers@postgreSQL.org
Subject: Re: AW: [GENERAL] Re: [HACKERS] TRANSACTIONS
Date: Thu, 24 Feb 2000 10:23:23 -0500
Message-ID: <200002241523.KAA02174@skillet.infoplease.com> (raw)
In-Reply-To: <Pine.GSO.3.96.SK.1000224134525.22930M-100000@ra>
References: <Pine.GSO.3.96.SK.1000224134525.22930M-100000@ra>
>Here is my example:
>
>package Apache::Hits;
>
>use strict;
>use Apache::Constants qw(:common);
>
>my ($sth_lock, $sth_upd, $sth_ins );
>
>
>sub handler {
> my $r = shift;
> if ( $r->args() =~ /msg_id=(\d+)/o ) {
> $HTML::Mason::Commands::dbs ||= My::DB->new(1);
> my $dbh = $HTML::Mason::Commands::dbs->{dbh};
> $sth_lock ||= $dbh->prepare("LOCK TABLE hits IN SHARE ROW EXCLUSIVE MODE");
> $sth_upd ||= $dbh->prepare("UPDATE hits SET count=count+1,last_access=now() WHERE msg_id=?");
> $sth_ins ||= $dbh->prepare("INSERT INTO hits (msg_id,count) VALUES (?, 1)");
> $dbh->{AutoCommit} = 0;
> my $success = 1;
> $success &&= $sth_lock->execute();
> $success &&= $sth_upd->execute( $1 );
> $success &&= $sth_ins->execute( $1 ) if ( $success eq '0E0');
> my $result = ($success ? $dbh->commit : $dbh->rollback);
> unless ( $result ) {
> $r->log_error("Unable to process transaction: ". $dbh->errstr ."\n");
> }
> }
> return OK;
>}
>
>1;
>__END__
Maybe I'm missing something - I don't use the Apache module, nor the
mason module, so it's difficult for me to decode this. But I looks to
me like this commits or rolls back one statement at a time.
What I want to be able to do is run a multi-statement transaction, and
for each statement in the transaction try to fix it if an error is
generated. If I cannot fix it, I want to roll back all of the
previous statements in the transaction. If I can fix it, I want to
clear the error status and continue on to the next statement in the
transaction.
Does your counter example do this in some way that I am not seeing?
--
Karl DeBisschop <kdebisschop@alert.infoplease.com>
617.832.0332 (Fax: 617.956.2696)
Information Please - your source for FREE online reference
http://www.infoplease.com - Your Ultimate Fact Finder
http://kids.infoplease.com - The Great Homework Helper
Netsaint Plugins Development
http://netsaintplug.sourceforge.net
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: kdebisschop@range.infoplease.com, oleg@sai.msu.su, ZeugswetterA@wien.spardat.at, hackers@postgreSQL.org
Subject: Re: AW: [GENERAL] Re: [HACKERS] TRANSACTIONS
In-Reply-To: <200002241523.KAA02174@skillet.infoplease.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox