Re: Are rules transaction safe?

From: Doug McNaught <doug(at)mcnaught(dot)org>
To: Oliver Fürst <ofuerst(at)tsak(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Are rules transaction safe?
Date: 2006-01-27 23:18:26
Message-ID: 87d5idcla5.fsf@asmodeus.mcnaught.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Oliver Fürst <ofuerst(at)tsak(dot)net> writes:

> But is nowhere stated if (multiple) commands inside a rule are treated
> as an implicit transaction as a whole.

If you don't specifically open a transaction at the top level (i.e. in
'psql' or SQL from your application's code), PG will encapsulate every
query you execute within its own transaction. The statements in any
rules called will execute in the context of that transaction, along
with any other operations such as trigger calls, table updates,
whatever. If something in that implicit transaction fails, it will be
rolled back; otherwise, it will be committed once the statement is
finished.

Also, you need to think of rules as 'query rewrites' rather than
'code that executes', because that's what they are.

I hope that helps.

-Doug

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Roderick A. Anderson 2006-01-27 23:52:10 SQL Lint
Previous Message Oliver Fürst 2006-01-27 22:34:35 Re: Are rules transaction safe?