Re: A few questions about ltree

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Alban Hertroys <alban(at)magproductions(dot)nl>
Cc: Teodor Sigaev <teodor(at)sigaev(dot)ru>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: A few questions about ltree
Date: 2006-04-21 16:04:21
Message-ID: 20060421090200.J15440@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 21 Apr 2006, Alban Hertroys wrote:

> Teodor Sigaev wrote:
> >> Maybe something along the lines of the following is possible?:
> >
> > Exact, it's for what ltree was developed.
>
> Cool, looks like it is what I need then.
>
> > contrib_regression=# select 'a.b.c' <@ 'a.b'::ltree;
> > ?column?
> > ----------
> > t
> > (1 row)
>
> How would you use this to constrain a foreign key?
>
> We've been experimenting with a table containing a branch 'a', 'a.b' and
> 'a.b.c', but deleting 'a.b' didn't cause a constraint violation.
>
> SQL> CREATE TABLE ltree_test (path ltree PRIMARY KEY REFERENCES
> ltree_test(path));
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "ltree_test_pkey" for table "ltree_test"
> CREATE TABLE
> SQL> INSERT INTO ltree_test VALUES ('a'::ltree);
> INSERT 84117368 1
> SQL> INSERT INTO ltree_test VALUES ('a.b'::ltree);
> INSERT 84117369 1
> SQL> INSERT INTO ltree_test VALUES ('a.b.c'::ltree);
> INSERT 84117370 1
> SQL> DELETE FROM ltree_test WHERE path = 'a.b'::ltree;
> DELETE 1

I'm not sure why you expect this to error. Any row that would reference
a.b would be removed by the delete AFAICS.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2006-04-21 16:12:42 Re: A few questions about ltree
Previous Message Brandon Metcalf 2006-04-21 15:40:47 IDT timezone