Re: pg_query transaction: auto rollback? begin or start?? commit or end???

From: Chris <dmagick(at)gmail(dot)com>
To: Bill Wordsworth <bill(dot)wordsworth(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pg_query transaction: auto rollback? begin or start?? commit or end???
Date: 2008-07-24 03:17:18
Message-ID: 4887F43E.7010104@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bill Wordsworth wrote:
> Thanks Chris and Karsten. I still don't quite understand why invalid
> state/record-mismatch would also not trigger auto rollback.

If you should have put id 5 instead of id 2 as a foreign key, how is the
database going to know the difference? Both are valid id's and valid
data for an "int" type field.

How can I
> even include something *outside* a transaction *inside* it- shouldn't
> everything between "begin" and "end" be subject to auto rollback no
> matter what?

Most things in postgres are transaction safe, some aren't like "cluster"
or "vacuum full". I couldn't find a list of things that won't work in a
transaction but it's a pretty short list. Even table changes (alter
table, create index etc) are transaction safe.

Maybe I misunderstand the question.

> Also what is the best way to check if transaction is 'read write'
> after doing 'pg_query("begin transaction read write;", $connection);'.
> pg_transaction_status() doesn't quite do it (read write=?=2).

That's going to report if you're inside a transaction or not, it's not
going to report what transaction level you are in. I don't think there's
a way to show that.

--
Postgresql & php tutorials
http://www.designmagick.com/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Shane Ambler 2008-07-24 04:02:49 Re: mac install question
Previous Message Craig Ringer 2008-07-24 02:09:59 Re: mac install question