Re: How to mark a transaction as SERIALIZABLE?

From: Chris Browne <cbbrowne(at)acm(dot)org>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to mark a transaction as SERIALIZABLE?
Date: 2010-11-02 14:34:01
Message-ID: 87d3qnu752.fsf@cbbrowne.afilias-int.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

joe(dot)carr(at)gmail(dot)com (Joe Carr) writes:
> so that select is executed prior to the SET TRANSACTION. If I remove the SET
> TRANSACTION command from the function, and then call it by :
>
> SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; 
> select * from test('test');
>
> that works. So, is that the correct way to set the isolation level for a
> function? Thanks again for your help.

In effect, it's an illusion that you "set the isolation level for a
function."

Functions run in the pre-existing context of an existing transaction.
(Yes, "existing" is pretty redundant there :-).)

You already set the isolation level for the transaction - the function
just uses the isolation already defined.

If a function expects a particular isolation level, one could mandate
this by checking the isolation level in the function, and raising an
error if it doesn't meet up with expectations.

The Postgres TODO list has an item, "Implement stored procedures" where
the work suggested indicates:

"This might involve the control of transaction state and the return
of multiple result sets"

That control of transaction state is what you're trying to do; it's not
done, so that functionality doesn't exist at this time.
--
wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','gmail.com').
http://www3.sympatico.ca/cbbrowne/postgresql.html
"If you give a man a fish, he will eat for a day. If you teach him how
to fish, he will sit in a boat and drink beer all day."

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Brian Neu 2010-11-03 19:50:33 PANIC: pg_xlog/000blah Invalid argument pg_resetxlog gives no relief
Previous Message Tom Lane 2010-11-02 14:15:07 Re: How to mark a transaction as SERIALIZABLE?