summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/prep/prepsecurity.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-03-15 18:41:47 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-03-15 18:41:47 -0400
commit7b8b8a43317e9e59eca8b511b714a0ab7da5f1cb (patch)
tree3a487b80bbc6d874fc72f556298d7e29680a4005 /src/backend/optimizer/prep/prepsecurity.c
parent9fac5fd741ec17ae24dde6b8e82064f13c148ddf (diff)
downloadpostgresql-7b8b8a43317e9e59eca8b511b714a0ab7da5f1cb.tar.gz
Improve representation of PlanRowMark.
This patch fixes two inadequacies of the PlanRowMark representation. First, that the original LockingClauseStrength isn't stored (and cannot be inferred for foreign tables, which always get ROW_MARK_COPY). Since some PlanRowMarks are created out of whole cloth and don't actually have an ancestral RowMarkClause, this requires adding a dummy LCS_NONE value to enum LockingClauseStrength, which is fairly annoying but the alternatives seem worse. This fix allows getting rid of the use of get_parse_rowmark() in FDWs (as per the discussion around commits 462bd95705a0c23b and 8ec8760fc87ecde0), and it simplifies some things elsewhere. Second, that the representation assumed that all child tables in an inheritance hierarchy would use the same RowMarkType. That's true today but will soon not be true. We add an "allMarkTypes" field that identifies the union of mark types used in all a parent table's children, and use that where appropriate (currently, only in preprocess_targetlist()). In passing fix a couple of minor infelicities left over from the SKIP LOCKED patch, notably that _outPlanRowMark still thought waitPolicy is a bool. Catversion bump is required because the numeric values of enum LockingClauseStrength can appear in on-disk rules. Extracted from a much larger patch to support foreign table inheritance; it seemed worth breaking this out, since it's a separable concern. Shigeru Hanada and Etsuro Fujita, somewhat modified by me
Diffstat (limited to 'src/backend/optimizer/prep/prepsecurity.c')
-rw-r--r--src/backend/optimizer/prep/prepsecurity.c33
1 files changed, 7 insertions, 26 deletions
diff --git a/src/backend/optimizer/prep/prepsecurity.c b/src/backend/optimizer/prep/prepsecurity.c
index b382f13504..0be44c1c2f 100644
--- a/src/backend/optimizer/prep/prepsecurity.c
+++ b/src/backend/optimizer/prep/prepsecurity.c
@@ -73,8 +73,8 @@ expand_security_quals(PlannerInfo *root, List *tlist)
rt_index = 0;
foreach(cell, parse->rtable)
{
- bool targetRelation = false;
- RangeTblEntry *rte = (RangeTblEntry *) lfirst(cell);
+ bool targetRelation = false;
+ RangeTblEntry *rte = (RangeTblEntry *) lfirst(cell);
rt_index++;
@@ -241,30 +241,10 @@ expand_security_qual(PlannerInfo *root, List *tlist, int rt_index,
rc = get_plan_rowmark(root->rowMarks, rt_index);
if (rc != NULL)
{
- switch (rc->markType)
- {
- case ROW_MARK_EXCLUSIVE:
- applyLockingClause(subquery, 1, LCS_FORUPDATE,
- rc->waitPolicy, false);
- break;
- case ROW_MARK_NOKEYEXCLUSIVE:
- applyLockingClause(subquery, 1, LCS_FORNOKEYUPDATE,
- rc->waitPolicy, false);
- break;
- case ROW_MARK_SHARE:
- applyLockingClause(subquery, 1, LCS_FORSHARE,
- rc->waitPolicy, false);
- break;
- case ROW_MARK_KEYSHARE:
- applyLockingClause(subquery, 1, LCS_FORKEYSHARE,
- rc->waitPolicy, false);
- break;
- case ROW_MARK_REFERENCE:
- case ROW_MARK_COPY:
- /* No locking needed */
- break;
- }
- root->rowMarks = list_delete(root->rowMarks, rc);
+ if (rc->strength != LCS_NONE)
+ applyLockingClause(subquery, 1, rc->strength,
+ rc->waitPolicy, false);
+ root->rowMarks = list_delete_ptr(root->rowMarks, rc);
}
/*
@@ -276,6 +256,7 @@ expand_security_qual(PlannerInfo *root, List *tlist, int rt_index,
if (targetRelation)
applyLockingClause(subquery, 1, LCS_FORUPDATE,
LockWaitBlock, false);
+
/*
* Replace any variables in the outer query that refer to the
* original relation RTE with references to columns that we will