Fix merge perminfo

naisila/check_router_fix
naisila 2023-07-21 16:14:49 +03:00
parent 06e9ea4027
commit 40c4711906
1 changed files with 16 additions and 0 deletions

View File

@ -31,6 +31,7 @@
#include "distributed/pg_version_constants.h" #include "distributed/pg_version_constants.h"
#include "distributed/query_pushdown_planning.h" #include "distributed/query_pushdown_planning.h"
#include "distributed/query_colocation_checker.h" #include "distributed/query_colocation_checker.h"
#include "distributed/relation_utils.h"
#include "distributed/repartition_executor.h" #include "distributed/repartition_executor.h"
#include "distributed/shared_library_init.h" #include "distributed/shared_library_init.h"
#include "distributed/shard_pruning.h" #include "distributed/shard_pruning.h"
@ -824,6 +825,21 @@ ConvertRelationRTEIntoSubquery(Query *mergeQuery, RangeTblEntry *sourceRte,
RangeTblEntry *newRangeTableEntry = copyObject(sourceRte); RangeTblEntry *newRangeTableEntry = copyObject(sourceRte);
sourceResultsQuery->rtable = list_make1(newRangeTableEntry); sourceResultsQuery->rtable = list_make1(newRangeTableEntry);
#if PG_VERSION_NUM >= PG_VERSION_16
sourceResultsQuery->rteperminfos = NIL;
if (newRangeTableEntry->perminfoindex != 0)
{
/* create permission info for newRangeTableEntry */
RTEPermissionInfo *perminfo = GetFilledPermissionInfo(newRangeTableEntry->relid,
newRangeTableEntry->inh,
CMD_SELECT);
/* update the subquery's rteperminfos accordingly */
newRangeTableEntry->perminfoindex = 1;
sourceResultsQuery->rteperminfos = list_make1(perminfo);
}
#endif
/* set the FROM expression to the subquery */ /* set the FROM expression to the subquery */
newRangeTableRef->rtindex = SINGLE_RTE_INDEX; newRangeTableRef->rtindex = SINGLE_RTE_INDEX;
sourceResultsQuery->jointree = makeFromExpr(list_make1(newRangeTableRef), NULL); sourceResultsQuery->jointree = makeFromExpr(list_make1(newRangeTableRef), NULL);