diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-10-01 16:40:05 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-10-01 16:40:05 +0000 |
| commit | 4c5e810fcda57940d1a7178389129591eb93d68e (patch) | |
| tree | 71677cf693a93449b45fc082fc7c571452ef4459 /src/backend | |
| parent | 392b187a214272937557af695692b6586375cc66 (diff) | |
| download | postgresql-4c5e810fcda57940d1a7178389129591eb93d68e.tar.gz | |
Code review for NOWAIT patch: downgrade NOWAIT from fully reserved keyword
to unreserved keyword, use ereport not elog, assign a separate error code
for 'could not obtain lock' so that applications will be able to detect
that case cleanly.
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/access/heap/heapam.c | 14 | ||||
| -rw-r--r-- | src/backend/parser/gram.y | 4 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index b8d38cc86b..a5426d089a 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.176 2004/09/17 18:09:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.177 2004/10/01 16:39:54 tgl Exp $ * * * INTERFACE ROUTINES @@ -465,6 +465,13 @@ relation_open(Oid relationId, LOCKMODE lockmode) return r; } +/* ---------------- + * conditional_relation_open - open with option not to wait + * + * As above, but if nowait is true, then throw an error rather than + * waiting when the lock is not immediately obtainable. + * ---------------- + */ Relation conditional_relation_open(Oid relationId, LOCKMODE lockmode, bool nowait) { @@ -483,7 +490,10 @@ conditional_relation_open(Oid relationId, LOCKMODE lockmode, bool nowait) if (nowait) { if (!ConditionalLockRelation(r, lockmode)) - elog(ERROR, "could not acquire relation lock"); + ereport(ERROR, + (errcode(ERRCODE_LOCK_NOT_AVAILABLE), + errmsg("could not obtain lock on \"%s\"", + RelationGetRelationName(r)))); } else LockRelation(r, lockmode); diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 8f1b393d29..5a12bf1189 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.477 2004/09/30 00:24:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.478 2004/10/01 16:39:59 tgl Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -7727,6 +7727,7 @@ unreserved_keyword: | NOCREATEUSER | NOTHING | NOTIFY + | NOWAIT | OBJECT_P | OF | OIDS @@ -7944,7 +7945,6 @@ reserved_keyword: | LOCALTIMESTAMP | NEW | NOT - | NOWAIT | NULL_P | OFF | OFFSET |
