diff options
Diffstat (limited to 'src/include/nodes/parsenodes.h')
-rw-r--r-- | src/include/nodes/parsenodes.h | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 56cf592e0ce..d8678e5b3fd 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -74,7 +74,7 @@ typedef uint32 AclMode; /* a bitmask of privilege bits */ #define ACL_CONNECT (1<<11) /* for databases */ #define N_ACL_RIGHTS 12 /* 1 plus the last 1<<x */ #define ACL_NO_RIGHTS 0 -/* Currently, SELECT ... FOR UPDATE/FOR SHARE requires UPDATE privileges */ +/* Currently, SELECT ... FOR [KEY] UPDATE/SHARE requires UPDATE privileges */ #define ACL_SELECT_FOR_UPDATE ACL_UPDATE @@ -119,7 +119,7 @@ typedef struct Query bool hasDistinctOn; /* distinctClause is from DISTINCT ON */ bool hasRecursive; /* WITH RECURSIVE was specified */ bool hasModifyingCTE; /* has INSERT/UPDATE/DELETE in WITH */ - bool hasForUpdate; /* FOR UPDATE or FOR SHARE was specified */ + bool hasForUpdate; /* FOR [KEY] UPDATE/SHARE was specified */ List *cteList; /* WITH list (of CommonTableExpr's) */ @@ -572,18 +572,28 @@ typedef struct DefElem } DefElem; /* - * LockingClause - raw representation of FOR UPDATE/SHARE options + * LockingClause - raw representation of FOR [NO KEY] UPDATE/[KEY] SHARE + * options * * Note: lockedRels == NIL means "all relations in query". Otherwise it * is a list of RangeVar nodes. (We use RangeVar mainly because it carries * a location field --- currently, parse analysis insists on unqualified * names in LockingClause.) */ +typedef enum LockClauseStrength +{ + /* order is important -- see applyLockingClause */ + LCS_FORKEYSHARE, + LCS_FORSHARE, + LCS_FORNOKEYUPDATE, + LCS_FORUPDATE +} LockClauseStrength; + typedef struct LockingClause { NodeTag type; - List *lockedRels; /* FOR UPDATE or FOR SHARE relations */ - bool forUpdate; /* true = FOR UPDATE, false = FOR SHARE */ + List *lockedRels; /* FOR [KEY] UPDATE/SHARE relations */ + LockClauseStrength strength; bool noWait; /* NOWAIT option */ } LockingClause; @@ -865,21 +875,21 @@ typedef struct WindowClause /* * RowMarkClause - - * parser output representation of FOR UPDATE/SHARE clauses + * parser output representation of FOR [KEY] UPDATE/SHARE clauses * * Query.rowMarks contains a separate RowMarkClause node for each relation - * identified as a FOR UPDATE/SHARE target. If FOR UPDATE/SHARE is applied - * to a subquery, we generate RowMarkClauses for all normal and subquery rels - * in the subquery, but they are marked pushedDown = true to distinguish them - * from clauses that were explicitly written at this query level. Also, - * Query.hasForUpdate tells whether there were explicit FOR UPDATE/SHARE - * clauses in the current query level. + * identified as a FOR [KEY] UPDATE/SHARE target. If one of these clauses + * is applied to a subquery, we generate RowMarkClauses for all normal and + * subquery rels in the subquery, but they are marked pushedDown = true to + * distinguish them from clauses that were explicitly written at this query + * level. Also, Query.hasForUpdate tells whether there were explicit FOR + * UPDATE/SHARE/KEY SHARE clauses in the current query level. */ typedef struct RowMarkClause { NodeTag type; Index rti; /* range table index of target relation */ - bool forUpdate; /* true = FOR UPDATE, false = FOR SHARE */ + LockClauseStrength strength; bool noWait; /* NOWAIT option */ bool pushedDown; /* pushed down from higher query level? */ } RowMarkClause; |