working around setQuerySnapshot limitations in functions

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: working around setQuerySnapshot limitations in functions
Date: 2002-12-16 16:23:33
Message-ID: 1040055813.19398.49.camel@camel
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

I have a function called move_tree() which moves a node from 1 parent to
another (in a nested set tree) by computing some necessary values, then
updating the nodes as needed. The problem I have is that when the
function is called multiple times simultaneously, each function does a
setQuerySnapshot at the start of the function, and then cannot see the
changes made by the other function calls. I had thought to do a lock on
the table at the start of my function, but due to the fact
setQuerySnapshot is called at the function start (before I can acquire a
lock) I can't guarantee no changes have been made before the function
tries to make changes. ISTM the only way around this is to do a lock on
the table before calling the function. The major downside to that it
requires me to put that logic inside any apps that use the function,
rather than being able to keep it inside the database. Does anyone see
another work-around?

Robert Treat

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2002-12-16 16:30:35 Re: how to find referenced column and table
Previous Message scott.marlowe 2002-12-16 16:23:29 Re: Total crash of my db-server

Browse pgsql-sql by date

  From Date Subject
Next Message Ludwig Lim 2002-12-16 16:41:16 CHECKS vs. BEFORE INSERT OR UPDATE TRIGGER
Previous Message Tim Perdue 2002-12-16 02:29:40 Re: ON DELETE CASCADE