Skip to content

Commit eb5784c

Browse files
author
Dipesh Dhameliya
committed
Revert "Avoid checking permission of Babelfish temp tables on parallel worker (babelfish-for-postgresql#560)"
This reverts commit 4cd4eb8.
1 parent 4cd4eb8 commit eb5784c

File tree

5 files changed

+7
-61
lines changed

5 files changed

+7
-61
lines changed

src/backend/executor/execMain.c

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ TriggerRecuresiveCheck_hook_type TriggerRecuresiveCheck_hook = NULL;
7979
/* Hook for plugin to get control in ExecCheckRTPerms() */
8080
ExecutorCheckPerms_hook_type ExecutorCheckPerms_hook = NULL;
8181

82-
/* Hook for plugin to get control in ExecCheckRTEPerms() */
83-
ExecCheckRTEPerms_hook_type ExecCheckRTEPerms_hook = NULL;
84-
8582
/* decls for local routines only used within this module */
8683
static void InitPlan(QueryDesc *queryDesc, int eflags);
8784
static void CheckValidRowMarkRel(Relation rel, RowMarkType markType);
@@ -621,19 +618,6 @@ ExecCheckRTEPerms(RangeTblEntry *rte)
621618

622619
relOid = rte->relid;
623620

624-
/*
625-
* Babelfish specific logic - Babelfish temp table is implemented
626-
* using ENR which is not shared with parallel worker and parallel
627-
* operations are not allowed for temp table in Postgres. Babelfish
628-
* can skip permission check for such use cases under parallel worker
629-
* using this hook.
630-
* Note - This hook must not be used outside of Babelfish parallel worker
631-
*/
632-
if (ExecCheckRTEPerms_hook &&
633-
IsBabelfishParallelWorker() &&
634-
(*ExecCheckRTEPerms_hook)(rte))
635-
return true;
636-
637621
/*
638622
* userid to check as: current user unless we have a setuid indication.
639623
*
@@ -826,9 +810,10 @@ InitPlan(QueryDesc *queryDesc, int eflags)
826810
int i;
827811

828812
/*
829-
* Do permissions checks
813+
* Do permissions checks if not Babelfish parallel worker
830814
*/
831-
ExecCheckRTPerms(rangeTable, true);
815+
if (!IsBabelfishParallelWorker())
816+
ExecCheckRTPerms(rangeTable, true);
832817

833818
/*
834819
* initialize the node's execution state
@@ -2959,12 +2944,3 @@ EvalPlanQualEnd(EPQState *epqstate)
29592944
epqstate->relsubs_done = NULL;
29602945
epqstate->epqExtra->relsubs_blocked = NULL;
29612946
}
2962-
2963-
/*
2964-
* ExecCheckRTEPerms_wrapper - wrapper around ExecCheckRTEPerms
2965-
*/
2966-
bool
2967-
ExecCheckRTEPerms_wrapper(RangeTblEntry *rte)
2968-
{
2969-
return ExecCheckRTEPerms(rte);
2970-
}

src/backend/executor/execParallel.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ typedef struct ExecParallelInitializeDSMContext
124124
int nnodes;
125125
} ExecParallelInitializeDSMContext;
126126

127-
ExecInitParallelPlan_hook_type ExecInitParallelPlan_hook = NULL;
128-
ParallelQueryMain_hook_type ParallelQueryMain_hook = NULL;
129-
130127
/* Helper functions that run in the parallel leader. */
131128
static char *ExecSerializePlan(Plan *plan, EState *estate);
132129
static bool ExecParallelEstimate(PlanState *node,
@@ -687,10 +684,6 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate,
687684
mul_size(PARALLEL_TUPLE_QUEUE_SIZE, pcxt->nworkers));
688685
shm_toc_estimate_keys(&pcxt->estimator, 1);
689686

690-
/* Let extension estimate a dynamic shared memory needed to communicate additional context */
691-
if (ExecInitParallelPlan_hook)
692-
(*ExecInitParallelPlan_hook)(estate, pcxt, true);
693-
694687
/*
695688
* Give parallel-aware nodes a chance to add to the estimates, and get a
696689
* count of how many PlanState nodes there are.
@@ -774,12 +767,6 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate,
774767
shm_toc_insert(pcxt->toc, PARALLEL_KEY_WAL_USAGE, walusage_space);
775768
pei->wal_usage = walusage_space;
776769

777-
/* Give extension a chance to share additional context */
778-
if (ExecInitParallelPlan_hook)
779-
{
780-
(*ExecInitParallelPlan_hook)(estate, pcxt,false);
781-
}
782-
783770
/* Set up the tuple queues that the workers will write into. */
784771
pei->tqueue = ExecParallelSetupTupleQueues(pcxt, false);
785772

@@ -1440,12 +1427,6 @@ ParallelQueryMain(dsm_segment *seg, shm_toc *toc)
14401427
area_space = shm_toc_lookup(toc, PARALLEL_KEY_DSA, false);
14411428
area = dsa_attach_in_place(area_space, seg);
14421429

1443-
/* Give extension chance to retrieve additional context shared by leader node */
1444-
if (ParallelQueryMain_hook)
1445-
{
1446-
(*ParallelQueryMain_hook)(toc);
1447-
}
1448-
14491430
/* Start up the executor */
14501431
queryDesc->plannedstmt->jitFlags = fpes->jit_flags;
14511432
ExecutorStart(queryDesc, fpes->eflags);

src/include/access/parallel.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,15 @@ extern void ParallelWorkerMain(Datum main_arg);
8282
/* Below helpers are added to support parallel workers in Babelfish context */
8383
extern bool IsBabelfishParallelWorker(void);
8484

85+
/* Key for BabelfishFixedParallelState */
86+
#define BABELFISH_PARALLEL_KEY_FIXED UINT64CONST(0xBBF0000000000001)
87+
8588
/* Hooks for communicating babelfish related information to parallel worker */
8689
typedef void (*bbf_InitializeParallelDSM_hook_type)(ParallelContext *pcxt, bool estimate);
8790
extern PGDLLIMPORT bbf_InitializeParallelDSM_hook_type bbf_InitializeParallelDSM_hook;
8891

8992
typedef void (*bbf_ParallelWorkerMain_hook_type)(shm_toc *toc);
9093
extern PGDLLIMPORT bbf_ParallelWorkerMain_hook_type bbf_ParallelWorkerMain_hook;
9194

95+
9296
#endif /* PARALLEL_H */

src/include/executor/execParallel.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,4 @@ extern void ExecParallelReinitialize(PlanState *planstate,
4848

4949
extern void ParallelQueryMain(dsm_segment *seg, shm_toc *toc);
5050

51-
typedef void (*ParallelQueryMain_hook_type)(shm_toc *toc);
52-
extern PGDLLIMPORT ParallelQueryMain_hook_type ParallelQueryMain_hook;
53-
54-
/*
55-
* When estimate = true passed then caller wants extension to estimate a dynamic shared memory (DSM)
56-
* needed by that extension to communicate additional context with Parallel worker.
57-
* When estimate = false then caller wants to insert additional context to DSM.
58-
*/
59-
typedef void (*ExecInitParallelPlan_hook_type)(EState *estate, ParallelContext *pcxt, bool estimate);
60-
extern PGDLLIMPORT ExecInitParallelPlan_hook_type ExecInitParallelPlan_hook;
61-
6251
#endif /* EXECPARALLEL_H */

src/include/executor/executor.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ extern PGDLLIMPORT ExecutorCheckPerms_hook_type ExecutorCheckPerms_hook;
8787
typedef bool (*TriggerRecuresiveCheck_hook_type) (ResultRelInfo *resultRelInfo);
8888
extern PGDLLIMPORT TriggerRecuresiveCheck_hook_type TriggerRecuresiveCheck_hook;
8989

90-
typedef bool (*ExecCheckRTEPerms_hook_type) (RangeTblEntry *rte);
91-
extern PGDLLEXPORT ExecCheckRTEPerms_hook_type ExecCheckRTEPerms_hook;
92-
9390
/*
9491
* prototypes from functions in execAmi.c
9592
*/
@@ -203,7 +200,6 @@ extern void standard_ExecutorEnd(QueryDesc *queryDesc);
203200
extern void ExecutorRewind(QueryDesc *queryDesc);
204201
extern bool ExecCheckRTPerms(List *rangeTable, bool ereport_on_violation);
205202
extern void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation);
206-
extern bool ExecCheckRTEPerms_wrapper(RangeTblEntry *rte);
207203
extern void InitResultRelInfo(ResultRelInfo *resultRelInfo,
208204
Relation resultRelationDesc,
209205
Index resultRelationIndex,

0 commit comments

Comments
 (0)