diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-28 21:47:18 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-28 21:47:18 +0000 |
commit | bedb78d386a47fd66b6cda2040e0a5fb545ee371 (patch) | |
tree | 0db0af8556ff82d94423e8e21362900afb18b7b6 /src/include/nodes/parsenodes.h | |
parent | d902e7d63ba2dc9cf0a1b051b2911b96831ef227 (diff) |
Implement sharable row-level locks, and use them for foreign key references
to eliminate unnecessary deadlocks. This commit adds SELECT ... FOR SHARE
paralleling SELECT ... FOR UPDATE. The implementation uses a new SLRU
data structure (managed much like pg_subtrans) to represent multiple-
transaction-ID sets. When more than one transaction is holding a shared
lock on a particular row, we create a MultiXactId representing that set
of transactions and store its ID in the row's XMAX. This scheme allows
an effectively unlimited number of row locks, just as we did before,
while not costing any extra overhead except when a shared lock actually
has to be shared. Still TODO: use the regular lock manager to control
the grant order when multiple backends are waiting for a row lock.
Alvaro Herrera and Tom Lane.
Diffstat (limited to 'src/include/nodes/parsenodes.h')
-rw-r--r-- | src/include/nodes/parsenodes.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index e8a44c34b2f..97d5df935ac 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.277 2005/04/07 01:51:40 neilc Exp $ + * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.278 2005/04/28 21:47:17 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -50,7 +50,7 @@ typedef uint32 AclMode; /* a bitmask of privilege bits */ #define N_ACL_RIGHTS 11 /* 1 plus the last 1<<x */ #define ACL_ALL_RIGHTS (-1) /* all-privileges marker in GRANT list */ #define ACL_NO_RIGHTS 0 -/* Currently, SELECT ... FOR UPDATE requires UPDATE privileges */ +/* Currently, SELECT ... FOR UPDATE/FOR SHARE requires UPDATE privileges */ #define ACL_SELECT_FOR_UPDATE ACL_UPDATE @@ -91,7 +91,10 @@ typedef struct Query * clauses) */ List *rowMarks; /* integer list of RT indexes of relations - * that are selected FOR UPDATE */ + * that are selected FOR UPDATE/SHARE */ + + bool forUpdate; /* true if rowMarks are FOR UPDATE, + * false if they are FOR SHARE */ List *targetList; /* target list (of TargetEntry) */ @@ -688,7 +691,8 @@ typedef struct SelectStmt List *sortClause; /* sort clause (a list of SortBy's) */ Node *limitOffset; /* # of result tuples to skip */ Node *limitCount; /* # of result tuples to return */ - List *forUpdate; /* FOR UPDATE clause */ + List *lockedRels; /* FOR UPDATE or FOR SHARE relations */ + bool forUpdate; /* true = FOR UPDATE, false = FOR SHARE */ /* * These fields are used only in upper-level SelectStmts. |