Re: [GENERAL] Re: [HACKERS] TRANSACTIONS

From: <kaiq(at)realtyideas(dot)com>
To: Karl DeBisschop <kdebisschop(at)range(dot)infoplease(dot)com>
Cc: lylyeoh(at)mecomb(dot)com, pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Re: [HACKERS] TRANSACTIONS
Date: 2000-02-25 20:49:19
Message-ID: Pine.LNX.4.10.10002251447090.16512-100000@picasso.realtyideas.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Fri, 25 Feb 2000, Karl DeBisschop wrote:

>
> >>To summarize, I stated that the following does not work with
> >>postgresql:
> >>
> >>> $dbh->{AutoCommit} = 0;
> >>> $dbh->do("CREATE TABLE tmp (a int unique,b int)");
> >>> $rtv = $dbh->do("INSERT INTO tmp VALUES ($1,$2)");
> >>> if ($rtv) {$dbh->do("UPDATE tmp SET b=$2 where a=$1")};
> >>> $dbh->commit;
> >>> $dbh->disconnect;
> >>
>
> The usefulness of the idion is that in a mutli-user environment, this
> is a basic way to update data that may or may not already have a key
> in the table. You can't do a "SELECT COUNT" because in the time
> between when you SELECT and INSERT (assuming the key is not already
> there) someone may have done a separate insert. The only other way I
> know to do this is to lock the entire table against INSERTs which has
> obvious performance effects.
sounds right, but ;-) why you use the transaction in the first place?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dana Burd 2000-02-25 21:03:12 Set DateStyle not working
Previous Message Keith G. Murphy 2000-02-25 20:18:24 Re: [GENERAL] Re: [HACKERS] TRANSACTIONS

Browse pgsql-hackers by date

  From Date Subject
Next Message The Hermit Hacker 2000-02-25 21:14:25 Re: [HACKERS] LZTEXT for rule plan stings
Previous Message Jan Wieck 2000-02-25 20:36:34 LZTEXT for rule plan stings