From: Richard Huxton <dev@archonet.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Tony Cebzanov <tonyceb@andrew.cmu.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: Avoiding cycles in a directed graph
Date: Tue, 16 Mar 2010 22:14:52 +0000
Message-ID: <4BA002DC.1050700@archonet.com> (raw)
In-Reply-To: <14550.1268773752@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>
On 16/03/10 21:09, Tom Lane wrote:
> Tony Cebzanov<tonyceb@andrew.cmu.edu> writes:
>> I'm okay with running the big, fat WITH RECURSIVE query in my insert
>> trigger if I have to -- it won't be great for performance, but I don't
>> expect this to be a frequent operation, so I'll accept the performance
>> hit if it works.
>
>> Unfortunately I can't even get that working. Here's the (not at all
>> functional) trigger I've got right now, which only detects the cycle
>> *after* it's been inserted, which is of no help at all. Any way I can
>> modify this to do the right thing?
>
> Run it in an AFTER trigger?
>
> If you don't expect this to be common, maybe you could fix the
> concurrency issue by taking a table-wide lock that locks out
> other writers.
Surely SELECT FOR UPDATE on the parents would be sufficient? If there's
no overlap between (currently non-cyclic) graphs being altered then
there can't be any conflict.
--
Richard Huxton
Archonet Ltd
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: dev@archonet.com, tgl@sss.pgh.pa.us, tonyceb@andrew.cmu.edu
Subject: Re: Avoiding cycles in a directed graph
In-Reply-To: <4BA002DC.1050700@archonet.com>
* 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