Re: Avoiding cycles in a directed graph

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tony Cebzanov <tonyceb(at)andrew(dot)cmu(dot)edu>
Cc: Richard Huxton <dev(at)archonet(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Avoiding cycles in a directed graph
Date: 2010-03-16 21:09:12
Message-ID: 14550.1268773752@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tony Cebzanov <tonyceb(at)andrew(dot)cmu(dot)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.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2010-03-16 22:14:52 Re: Avoiding cycles in a directed graph
Previous Message Tony Cebzanov 2010-03-16 20:49:44 Re: Avoiding cycles in a directed graph