Re: index on function confuses drop table cascade on child

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: index on function confuses drop table cascade on child
Date: 2010-11-02 14:51:32
Message-ID: 26599.1288709492@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> writes:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> 3. Or, perhaps we could change recordDependencyOnSingleRelExpr so
>> that it generates a whole-table dependency on the target relation
>> even if there are no Vars in the expression. This would make it
>> act much more like the regular-query context that
>> find_expr_references_walker is expecting --- in essence, since
>> we're fabricating a single-element rtable for
>> find_expr_references_walker to work with, we should fabricate the
>> implied whole-table dependency entry too. But that seems a bit
>> weird too, and in particular it's not obvious whether to do that
>> if in fact the expression is empty, or doesn't contain any Var at
>> all.

> This one seems sensible *if* you assume that by the time it is
> called there is a known dependency on the particular relation -- for
> example, you are dealing with an index on that relation. Is that a
> reasonable restriction on the use of the
> recordDependencyOnSingleRelExpr function? If this was done, would
> it allow simplification of the index_create code you showed in #1?

Well, it doesn't really improve matters for the index_create code.
What it basically accomplishes so far as that's concerned is to
guarantee that there will be a (likely redundant) whole-table
dependency; which we could equally well guarantee from the other end,
a la my fix #1.

After sleeping on it I'm pretty well convinced that fix #1 is the
way to go; it's simple and gets rid of some code that was just trying
to be too cute. If we had a clear example of some future use of
recordDependencyOnSingleRelExpr that would require a different behavior
for the expression-dependency-extraction code, I might want to change
that code instead; but we don't.

(Obviously some more comments around the dependency-extraction code will
be a good idea in any case.)

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Dirk Heinrichs 2010-11-02 15:14:01 BUG #5740: contrib/spi/moddatetime.c doesn't work with timezones.
Previous Message Kevin Grittner 2010-11-02 14:39:26 Fwd: ***SPAM*** Re: BUG #5739: postgresql will not start