PG18: Fix missing Planning Fast Path Query DEBUG messages (#8320)

With PG18's GROUP RTE, queries that should have been eligible for fast
path planning were skipped because the fast path planner allows exactly
one range table only. This fix extends that to account for a GROUP RTE.
pull/8300/head
Colm 2025-11-04 12:33:21 +00:00 committed by GitHub
parent 5a71f0d1ca
commit 7a7a0ba9c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

View File

@ -273,8 +273,16 @@ FastPathRouterQuery(Query *query, FastPathRestrictionContext *fastPathContext)
return true; return true;
} }
/* make sure that the only range table in FROM clause */ int numFromRels = list_length(query->rtable);
if (list_length(query->rtable) != 1)
/* make sure that there is only one range table in FROM clause */
if ((numFromRels != 1)
#if PG_VERSION_NUM >= PG_VERSION_18
/* with a PG18+ twist for GROUP rte - if present make sure there's two range tables */
&& (!query->hasGroupRTE || numFromRels != 2)
#endif
)
{ {
return false; return false;
} }

View File

@ -2192,7 +2192,11 @@ CheckAndBuildDelayedFastPathPlan(DistributedPlanningContext *planContext,
static bool static bool
ConvertToQueryOnShard(Query *query, Oid citusTableOid, Oid shardId) ConvertToQueryOnShard(Query *query, Oid citusTableOid, Oid shardId)
{ {
Assert(list_length(query->rtable) == 1); Assert(list_length(query->rtable) == 1
#if PG_VERSION_NUM >= PG_VERSION_18
|| (list_length(query->rtable) == 2 && query->hasGroupRTE)
#endif
);
RangeTblEntry *citusTableRte = (RangeTblEntry *) linitial(query->rtable); RangeTblEntry *citusTableRte = (RangeTblEntry *) linitial(query->rtable);
Assert(citusTableRte->relid == citusTableOid); Assert(citusTableRte->relid == citusTableOid);