diff options
author | Tom Lane | 2023-06-08 17:11:49 +0000 |
---|---|---|
committer | Tom Lane | 2023-06-08 17:11:49 +0000 |
commit | fbf80421ead55deaafbefa808960a2695de492c9 (patch) | |
tree | 05af1683340c8c565e69a51734a5708e20eadf99 | |
parent | d98ed080bb31fd3d46281127871b7886288686d9 (diff) |
Re-allow INDEX_VAR as rt_index in ChangeVarNodes().
Apparently some extensions are in the habit of calling
ChangeVarNodes() with INDEX_VAR as the rt_index to replace.
That worked before 2489d76c4, at least as long as there were
not PlaceHolderVars in the expression; but now it fails
because bms_is_member spits up. Add a test to avoid that.
Per report from Anton Melnikov, though this is not his
proposed patch.
Discussion: https://postgr.es/m/[email protected]
-rw-r--r-- | src/backend/rewrite/rewriteManip.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/rewrite/rewriteManip.c b/src/backend/rewrite/rewriteManip.c index 52b3f77078..32bd2f1dc9 100644 --- a/src/backend/rewrite/rewriteManip.c +++ b/src/backend/rewrite/rewriteManip.c @@ -719,11 +719,16 @@ ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up) /* * Substitute newrelid for oldrelid in a Relid set + * + * Note: some extensions may pass a special varno such as INDEX_VAR for + * oldrelid. bms_is_member won't like that, but we should tolerate it. + * (Perhaps newrelid could also be a special varno, but there had better + * not be a reason to inject that into a nullingrels or phrels set.) */ static Relids adjust_relid_set(Relids relids, int oldrelid, int newrelid) { - if (bms_is_member(oldrelid, relids)) + if (!IS_SPECIAL_VARNO(oldrelid) && bms_is_member(oldrelid, relids)) { /* Ensure we have a modifiable copy */ relids = bms_copy(relids); |