From c10b1083c93de0ad50fc075afda1f21f9163cace Mon Sep 17 00:00:00 2001 From: naisila Date: Thu, 22 May 2025 12:53:52 +0200 Subject: [PATCH] Separate 15.13 condition for future pg15 drop --- .../distributed/planner/multi_router_planner.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/backend/distributed/planner/multi_router_planner.c b/src/backend/distributed/planner/multi_router_planner.c index b767f599a..19d386343 100644 --- a/src/backend/distributed/planner/multi_router_planner.c +++ b/src/backend/distributed/planner/multi_router_planner.c @@ -2245,16 +2245,24 @@ SelectsFromDistributedTable(List *rangeTableList, Query *query) continue; } +#if PG_VERSION_NUM >= 150013 && PG_VERSION_NUM < PG_VERSION_16 + if (rangeTableEntry->rtekind == RTE_SUBQUERY && rangeTableEntry->relkind == 0) + { + /* + * In PG15.13 commit https://github.com/postgres/postgres/commit/317aba70e + * relid is retained when converting views to subqueries, + * so we need an extra check identifying those views + */ + continue; + } +#endif + if (rangeTableEntry->relkind == RELKIND_VIEW || - rangeTableEntry->relkind == RELKIND_MATVIEW || - (rangeTableEntry->rtekind == RTE_SUBQUERY && rangeTableEntry->relkind == 0)) + rangeTableEntry->relkind == RELKIND_MATVIEW) { /* * Skip over views, which would error out in GetCitusTableCacheEntry. * Distributed tables within (regular) views are already in rangeTableList. - * In PG15.13 commit https://github.com/postgres/postgres/commit/317aba70e - * relid is retained when converting views to subqueries, - * so we need an extra check identifying those views */ continue; }