Skip to content

Dummy PR to test fix for BABEL-5703 #558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: BABEL_5_X_DEV__PG_17_X
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/backend/executor/execMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ ExecCheckPermissions(List *rangeTable, List *rteperminfos,
{
ListCell *l;
bool result = true;
Bitmapset *temprelids = NULL;

#ifdef USE_ASSERT_CHECKING
Bitmapset *indexset = NULL;
Expand All @@ -587,6 +588,10 @@ ExecCheckPermissions(List *rangeTable, List *rteperminfos,
{
RangeTblEntry *rte = lfirst_node(RangeTblEntry, l);

/* TODO: Add explaination */
if (IsBabelfishParallelWorker() && rte->relpersistence == RELPERSISTENCE_TEMP)
temprelids = bms_add_member(temprelids, rte->relid);

if (rte->perminfoindex != 0)
{
/* Sanity checks */
Expand Down Expand Up @@ -615,6 +620,10 @@ ExecCheckPermissions(List *rangeTable, List *rteperminfos,
RTEPermissionInfo *perminfo = lfirst_node(RTEPermissionInfo, l);

Assert(OidIsValid(perminfo->relid));

if (IsBabelfishParallelWorker() && bms_is_member(perminfo->relid, temprelids))
continue;

result = ExecCheckOneRelPerms(perminfo);
if (!result)
{
Expand Down Expand Up @@ -840,10 +849,9 @@ InitPlan(QueryDesc *queryDesc, int eflags)
int i;

/*
* Do permissions checks if not Babelfish parallel worker
* Do permissions checks
*/
if (!IsBabelfishParallelWorker())
ExecCheckPermissions(rangeTable, plannedstmt->permInfos, true);
ExecCheckPermissions(rangeTable, plannedstmt->permInfos, true);

/*
* initialize the node's execution state
Expand Down
1 change: 1 addition & 0 deletions src/backend/nodes/outfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
WRITE_OID_FIELD(relid);
WRITE_BOOL_FIELD(inh);
WRITE_CHAR_FIELD(relkind);
WRITE_CHAR_FIELD(relpersistence);
WRITE_INT_FIELD(rellockmode);
WRITE_UINT_FIELD(perminfoindex);
WRITE_NODE_FIELD(tablesample);
Expand Down
1 change: 1 addition & 0 deletions src/backend/nodes/readfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ _readRangeTblEntry(void)
READ_OID_FIELD(relid);
READ_BOOL_FIELD(inh);
READ_CHAR_FIELD(relkind);
READ_CHAR_FIELD(relpersistence);
READ_INT_FIELD(rellockmode);
READ_UINT_FIELD(perminfoindex);
READ_NODE_FIELD(tablesample);
Expand Down
15 changes: 15 additions & 0 deletions src/backend/optimizer/path/allpaths.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "optimizer/plancat.h"
#include "optimizer/planner.h"
#include "optimizer/tlist.h"
#include "parser/parser.h"
#include "parser/parse_clause.h"
#include "parser/parsetree.h"
#include "partitioning/partbounds.h"
Expand Down Expand Up @@ -617,7 +618,21 @@ set_rel_consider_parallel(PlannerInfo *root, RelOptInfo *rel,
* for now, bail out if we see a temporary table.
*/
if (get_rel_persistence(rte->relid) == RELPERSISTENCE_TEMP)
{
/*
* Babelfish Temp tables are created under ENRs which is not
* shared with other backend (with parallel workwer for example).
* Here, we are marking rte->relpersistence = RELPERSISTENCE_TEMP
* for Babelfish temp table so that we can avoid rechecking the
* permission check of Babelfish temp table on Parallel worker.
* This is safe because scanning of temp table won't be done
* under parallel worker. And we have to wait til all the
* optimisation and rewriting is done.
*/
if (sql_dialect == SQL_DIALECT_TSQL)
rte->relpersistence = RELPERSISTENCE_TEMP;
return;
}
Comment on lines 620 to +635
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably not needed


/*
* Table sampling can be pushed down to workers if the sample
Expand Down
1 change: 1 addition & 0 deletions src/backend/parser/parse_relation.c
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,7 @@ addRangeTableEntry(ParseState *pstate,
rte->relid = RelationGetRelid(rel);
rte->inh = inh;
rte->relkind = rel->rd_rel->relkind;
rte->relpersistence = rel->rd_rel->relpersistence;
rte->rellockmode = lockmode;

/*
Expand Down
2 changes: 2 additions & 0 deletions src/include/nodes/parsenodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,8 @@ typedef struct RangeTblEntry
bool inh;
/* relation kind (see pg_class.relkind) */
char relkind pg_node_attr(query_jumble_ignore);
/* relation kind (see pg_class.relpersistence) */
char relpersistence pg_node_attr(query_jumble_ignore);
/* lock level that query requires on the rel */
int rellockmode pg_node_attr(query_jumble_ignore);
/* index of RTEPermissionInfo entry, or 0 */
Expand Down