From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de>, Amit Langote <amitlangote09(at)gmail(dot)com>, Peter Geoghegan <pg(at)bowt(dot)ie> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Bogus rte->relkind for EXCLUDED pseudo-relation |
Date: | 2022-12-02 17:34:36 |
Message-ID: | 1999471.1670002476@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
In the wake of b23cd185f (pushed just now), I tried adding Asserts
to rewriteHandler.c that relkinds in RTEs don't change, as attached.
This blew up the regression tests immediately. On investigation,
I find that
(1) ON CONFLICT's EXCLUDED pseudo-relation is assigned
rte->relkind = RELKIND_COMPOSITE, a rather horrid hack
installed by commit ad2278379.
(2) If a stored rule involves ON CONFLICT, then while loading
the rule AcquireRewriteLocks overwrites that with the actual
relkind, ie RELKIND_RELATION. Or it did without the
attached Assert, anyway.
It appears to me that this means whatever safeguards are created
by the use of RELKIND_COMPOSITE will fail to apply in a rule.
Maybe that's okay because the relevant behaviors only occur at
parse time not rewrite/planning/execution, but even to write that
is to doubt how reliable and future-proof the assumption is.
I'm inclined to think we'd be well advised to undo that aspect of
ad2278379 and solve it some other way. Maybe a new RTEKind would
be a better idea. Alternatively, we could drop rewriteHandler.c's
attempts to update relkind. Theoretically that's safe now, but
I hadn't quite wanted to just pull that trigger right away ...
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
assert-rte-relkind-is-stable.patch | text/x-diff | 867 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-12-02 17:40:35 | Re: pg_dump: Remove "blob" terminology |
Previous Message | Andres Freund | 2022-12-02 17:28:29 | Re: refactor ExecGrant_*() functions |