Re: Avoiding cycles in a directed graph - Mailing list pgsql-sql

From Tony Cebzanov
Subject Re: Avoiding cycles in a directed graph
Date
Msg-id 4BA1211C.20800@andrew.cmu.edu
Whole thread Raw
In response to Re: Avoiding cycles in a directed graph  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
On 3/16/10 6:22 PM, Tom Lane wrote:
> Richard Huxton <dev@archonet.com> writes:
> 
> 
> Um, what if the cycle is being formed from whole cloth?  For instance
> T1 inserts an edge A->B while T2 is inserting B->A.  There are no
> pre-existing rows to lock, but there will still be a cycle after they
> both commit.

For what it's worth, when I did give the "FOR UPDATE" strategy a try,
but with the recursive query rather than the simpler approach Richard
suggested, I got the following error (v8.4.2):

ERROR:  FOR UPDATE/SHARE in a recursive query is not implemented

I'm sticking with the recursive query, because it seems to me the only
way to ensure there are no cycles is to check the whole graph for
cycles, and the only way I know how to do that is the recursive
approach.  Since "FOR UPDATE" isn't implemented for recursive queries,
I'll just lock the entire table for now.

Thanks, all!
-Tony


pgsql-sql by date:

Previous
From: Rob Sargent
Date:
Subject: Re: strange issue with UUID data types
Next
From: "Ignacio Balcarce"
Date:
Subject: MSSQL to PostgreSQL - Issue trying to generate unique ID using actual date