Skip site navigation (1) Skip section navigation (2)

Re: pg_depend explained

From: Florian Pflug <fgp(at)phlo(dot)org>
To: Joel Jacobson <joel(at)gluefinance(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_depend explained
Date: 2011-01-12 02:25:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On Jan11, 2011, at 23:55 , Joel Jacobson wrote:
> 2011/1/11 Florian Pflug <fgp(at)phlo(dot)org>:
>> Could you give an example of the kind of trouble you're experiencing trying
>> to use a topological sort?
> Let's say you have a table t and a view v.
> The view v is defined as select * from t;
> If we put all objects in a tree, with the public schema as the root,
> both v and t will directly under the root, but in reality, v cannot be
> created before t.

AFAICS, you get the following dependencies (apart from the obvious
NORMAL dependencies from the pg_class entries of t and v on public)

  t (pg_class) <--[INTERNAL]-- t (pg_type)
_RETURN (pg_rewrite)
     |        |
     |        |  
    \./      \./
    v (pg_class) <--[INTERNAL]-- v (pg_type)

INTERNAL dependencies mark objects which spring into existence once the
referenced (target in my diagram) object is created. You can thus fold a
node I (the INTERNALly-depending object) into a node O (the object created
by the user) if there is an INTERNAL dependency from I to O.
The diagram then becomes

v (pg_class) --[NORMAL]--> t (pg_class)

Which correctly states that t must be created before v.

> This is the reason why a normal topological sort doesn't work.
> You have to look at the deptype and sort nodes having "internal" edges
> between them differently.

I suggest you try to node-folding strategy and see how far it gets you.

> I guess it's time for plan B, sorting based on oid, no biggie, it will
> work for my purpose, but it's damn ugly.

That will probably crash and burn once the OIDs have wrapped around once.

best regards,
Florian Pflug

In response to


pgsql-hackers by date

Next:From: Robert HaasDate: 2011-01-12 02:41:35
Subject: Re: ALTER TYPE 0: Introduction; test cases
Previous:From: Robert HaasDate: 2011-01-12 02:24:08
Subject: Re: WIP: Range Types

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group