pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tony Cebzanov <tonyceb@andrew.cmu.edu>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Richard Huxton <dev@archonet.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Avoiding cycles in a directed graph
Date: Wed, 17 Mar 2010 14:36:12 -0400
Message-ID: <4BA1211C.20800@andrew.cmu.edu> (raw)
In-Reply-To: <15827.1268778132@sss.pgh.pa.us>
References: <4B9FDFDE.5030005@andrew.cmu.edu>
	<4B9FE752.4080709@archonet.com>
	<14113.1268771643@sss.pgh.pa.us>
	<4B9FEEE8.1060404@andrew.cmu.edu>
	<14550.1268773752@sss.pgh.pa.us>
	<4BA002DC.1050700@archonet.com>
	<15827.1268778132@sss.pgh.pa.us>

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



view thread (8+ messages)

Message-ID: <4BA1211C.20800@andrew.cmu.edu>
Permalink:  ../4BA1211C.20800@andrew.cmu.edu/
Also on:    postgresql.org/message-id/4BA1211C.20800@andrew.cmu.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tonyceb@andrew.cmu.edu, tgl@sss.pgh.pa.us, dev@archonet.com
  Subject: Re: Avoiding cycles in a directed graph
  In-Reply-To: <4BA1211C.20800@andrew.cmu.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox