Wednesday, July 23, 2008

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

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/

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

No comments: