diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-08-01 20:31:16 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-08-01 20:31:16 +0000 |
commit | 2a4fad1a0e43d6375ffa8eddb2d8dfa1ed36593f (patch) | |
tree | bb2bc2208507b0ab2403850e8dd01003a4ed73e9 /src/include | |
parent | ca7abcd89dbeecb82cde50fccf4f6c483244fdf7 (diff) | |
download | postgresql-2a4fad1a0e43d6375ffa8eddb2d8dfa1ed36593f.tar.gz postgresql-2a4fad1a0e43d6375ffa8eddb2d8dfa1ed36593f.zip |
Add NOWAIT option to SELECT FOR UPDATE/SHARE.
Original patch by Hans-Juergen Schoenig, revisions by Karel Zak
and Tom Lane.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/access/heapam.h | 5 | ||||
-rw-r--r-- | src/include/access/multixact.h | 3 | ||||
-rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
-rw-r--r-- | src/include/nodes/execnodes.h | 7 | ||||
-rw-r--r-- | src/include/nodes/nodes.h | 3 | ||||
-rw-r--r-- | src/include/nodes/parsenodes.h | 21 | ||||
-rw-r--r-- | src/include/parser/parse_node.h | 8 | ||||
-rw-r--r-- | src/include/storage/lmgr.h | 5 |
8 files changed, 39 insertions, 17 deletions
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index dde6fe8ecd8..9c040b0dfd4 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.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/access/heapam.h,v 1.102 2005/06/20 18:37:01 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.103 2005/08/01 20:31:13 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -163,7 +163,8 @@ extern HTSU_Result heap_delete(Relation relation, ItemPointer tid, ItemPointer c extern HTSU_Result heap_update(Relation relation, ItemPointer otid, HeapTuple tup, ItemPointer ctid, CommandId cid, Snapshot crosscheck, bool wait); extern HTSU_Result heap_lock_tuple(Relation relation, HeapTuple tup, - Buffer *userbuf, CommandId cid, LockTupleMode mode); + Buffer *userbuf, CommandId cid, + LockTupleMode mode, bool nowait); extern Oid simple_heap_insert(Relation relation, HeapTuple tup); extern void simple_heap_delete(Relation relation, ItemPointer tid); diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h index 2199b05f2c5..8a4d2101e75 100644 --- a/src/include/access/multixact.h +++ b/src/include/access/multixact.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/multixact.h,v 1.3 2005/06/08 15:50:28 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/multixact.h,v 1.4 2005/08/01 20:31:13 tgl Exp $ */ #ifndef MULTIXACT_H #define MULTIXACT_H @@ -42,6 +42,7 @@ extern MultiXactId MultiXactIdCreate(TransactionId xid1, TransactionId xid2); extern MultiXactId MultiXactIdExpand(MultiXactId multi, TransactionId xid); extern bool MultiXactIdIsRunning(MultiXactId multi); extern void MultiXactIdWait(MultiXactId multi); +extern bool ConditionalMultiXactIdWait(MultiXactId multi); extern void MultiXactIdSetOldestMember(void); extern void AtEOXact_MultiXact(void); diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index c7584968a36..2ce578b3f41 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.294 2005/07/31 17:19:20 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.295 2005/08/01 20:31:14 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200507301 +#define CATALOG_VERSION_NO 200508011 #endif diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 46d27a56f53..73648f93ade 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.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/execnodes.h,v 1.136 2005/06/26 22:05:41 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.137 2005/08/01 20:31:15 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -319,8 +319,9 @@ typedef struct EState uint32 es_processed; /* # of tuples processed */ Oid es_lastoid; /* last oid processed (by INSERT) */ - List *es_rowMark; /* not good place, but there is no other */ - bool es_forUpdate; /* was it FOR UPDATE or FOR SHARE */ + List *es_rowMarks; /* not good place, but there is no other */ + bool es_forUpdate; /* true = FOR UPDATE, false = FOR SHARE */ + bool es_rowNoWait; /* FOR UPDATE/SHARE NOWAIT option */ bool es_instrument; /* true requests runtime instrumentation */ bool es_select_into; /* true if doing SELECT INTO */ diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index 24480f1281a..bc980757121 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.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/nodes.h,v 1.174 2005/08/01 04:03:58 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.175 2005/08/01 20:31:15 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -315,6 +315,7 @@ typedef enum NodeTag T_CompositeTypeStmt, T_InhRelation, T_FunctionParameter, + T_LockingClause, /* * TAGS FOR RANDOM OTHER STUFF diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index fc88dec5351..90a282e1632 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.288 2005/08/01 04:03:58 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.289 2005/08/01 20:31:15 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -95,6 +95,7 @@ typedef struct Query bool forUpdate; /* true if rowMarks are FOR UPDATE, * false if they are FOR SHARE */ + bool rowNoWait; /* FOR UPDATE/SHARE NOWAIT option */ List *targetList; /* target list (of TargetEntry) */ @@ -415,6 +416,20 @@ typedef struct DefElem Node *arg; /* a (Value *) or a (TypeName *) */ } DefElem; +/* + * LockingClause - raw representation of FOR UPDATE/SHARE options + * + * Note: lockedRels == NIL means "all relations in query". Otherwise it + * is a list of String nodes giving relation eref names. + */ +typedef struct LockingClause +{ + NodeTag type; + List *lockedRels; /* FOR UPDATE or FOR SHARE relations */ + bool forUpdate; /* true = FOR UPDATE, false = FOR SHARE */ + bool nowait; /* NOWAIT option */ +} LockingClause; + /**************************************************************************** * Nodes for a Query tree @@ -686,8 +701,7 @@ 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 *lockedRels; /* FOR UPDATE or FOR SHARE relations */ - bool forUpdate; /* true = FOR UPDATE, false = FOR SHARE */ + LockingClause *lockingClause; /* FOR UPDATE/FOR SHARE */ /* * These fields are used only in upper-level SelectStmts. @@ -699,6 +713,7 @@ typedef struct SelectStmt /* Eventually add fields for CORRESPONDING spec here */ } SelectStmt; + /* ---------------------- * Set Operation node for post-analysis query trees * diff --git a/src/include/parser/parse_node.h b/src/include/parser/parse_node.h index 291282e0920..c864f5714f8 100644 --- a/src/include/parser/parse_node.h +++ b/src/include/parser/parse_node.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/parser/parse_node.h,v 1.44 2005/06/05 00:38:11 tgl Exp $ + * $PostgreSQL: pgsql/src/include/parser/parse_node.h,v 1.45 2005/08/01 20:31:16 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -61,9 +61,9 @@ typedef struct ParseState Oid *p_paramtypes; /* OIDs of types for $n parameter symbols */ int p_numparams; /* allocated size of p_paramtypes[] */ int p_next_resno; /* next targetlist resno to assign */ - List *p_lockedRels; /* FOR UPDATE/SHARE, if any (see gram.y) */ - Node *p_value_substitute; /* what to replace VALUE with, if - * any */ + LockingClause *p_locking_clause; /* FOR UPDATE/FOR SHARE info */ + Node *p_value_substitute; /* what to replace VALUE with, + * if any */ bool p_variableparams; bool p_hasAggs; bool p_hasSubLinks; diff --git a/src/include/storage/lmgr.h b/src/include/storage/lmgr.h index 3a83c26c7df..72504ee2ab5 100644 --- a/src/include/storage/lmgr.h +++ b/src/include/storage/lmgr.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/storage/lmgr.h,v 1.50 2005/06/17 22:32:50 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/lmgr.h,v 1.51 2005/08/01 20:31:16 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -64,12 +64,15 @@ extern void UnlockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode); /* Lock a tuple (see heap_lock_tuple before assuming you understand this) */ extern void LockTuple(Relation relation, ItemPointer tid, LOCKMODE lockmode); +extern bool ConditionalLockTuple(Relation relation, ItemPointer tid, + LOCKMODE lockmode); extern void UnlockTuple(Relation relation, ItemPointer tid, LOCKMODE lockmode); /* Lock an XID (used to wait for a transaction to finish) */ extern void XactLockTableInsert(TransactionId xid); extern void XactLockTableDelete(TransactionId xid); extern void XactLockTableWait(TransactionId xid); +extern bool ConditionalXactLockTableWait(TransactionId xid); /* Lock a general object (other than a relation) of the current database */ extern void LockDatabaseObject(Oid classid, Oid objid, uint16 objsubid, |