Missing dependency tracking for TableFunc nodes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Missing dependency tracking for TableFunc nodes
Date: 2019-11-11 21:41:41
Message-ID: 18427.1573508501@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I happened to notice that find_expr_references_walker has not
been taught anything about TableFunc nodes, which means it will
miss the type and collation OIDs embedded in such a node.

This can be demonstrated to be a problem by the attached script,
which will end up with a "cache lookup failed for type NNNNN"
error because we allow dropping a type the XMLTABLE construct
references.

This isn't hard to fix, as per the attached patch, but it makes
me nervous. I wonder what other dependencies we might be missing.

Would it be a good idea to move find_expr_references_walker to
nodeFuncs.c, in hopes of making it more visible to people adding
new node types? We could decouple it from the specific use-case
of recordDependencyOnExpr by having it call a callback function
for each identified OID; although maybe there's no point in that,
since I'm not sure there are any other use-cases.

Another thought is that maybe the code could be automatically
generated, as Andres has been threatening to do with respect
to the other stuff in backend/nodes/.

In practice, this bug is probably not a huge problem, because a
view that involves a column of type X will likely have some other
dependencies on X. I had to tweak the example view a bit to get
it to not have any other dependencies on "seg". So I'm not feeling
that this is a stop-ship problem for today's releases --- I'll plan
on installing the fix after the releases are tagged.

regards, tom lane

Attachment Content-Type Size
tablefunc-dependency-bug.sql text/plain 624 bytes
fix-tablefunc-dependencies.patch text/x-diff 925 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2019-11-11 22:18:39 Re: PHJ file leak.
Previous Message Mark Dilger 2019-11-11 21:28:37 Re: TestLib::command_fails_like enhancement