aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-09-22 23:20:14 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-09-22 23:20:14 +0000
commitd40d34863e23bbfce2fbdc05e85b92e7ae321ecd (patch)
treeab2087db4b6334af3722fbc74227dacbc23c4197
parentbeca984e5f1c315d02064e69861be112f5a69b3d (diff)
downloadpostgresql-d40d34863e23bbfce2fbdc05e85b92e7ae321ecd.tar.gz
postgresql-d40d34863e23bbfce2fbdc05e85b92e7ae321ecd.zip
Fix pg_locks view to call advisory locks advisory locks, while preserving
backward compatibility for anyone using the old userlock code that's now on pgfoundry --- locks from that code still show as 'userlock'.
-rw-r--r--doc/src/sgml/catalogs.sgml12
-rw-r--r--src/backend/storage/lmgr/deadlock.c12
-rw-r--r--src/backend/storage/lmgr/lmgr.c3
-rw-r--r--src/backend/utils/adt/lockfuncs.c16
-rw-r--r--src/include/storage/lock.h9
5 files changed, 33 insertions, 19 deletions
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index bc5592ce746..ff4fb64bcab 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.133 2006/09/18 22:40:36 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.134 2006/09/22 23:20:13 tgl Exp $ -->
<!--
Documentation of the system catalogs, directed toward PostgreSQL developers
-->
@@ -4890,8 +4890,9 @@
<literal>page</>,
<literal>tuple</>,
<literal>transactionid</>,
- <literal>object</>, or
- <literal>userlock</>
+ <literal>object</>,
+ <literal>userlock</>, or
+ <literal>advisory</>
</entry>
</row>
<row>
@@ -5029,14 +5030,15 @@
</para>
<para>
- User-defined locks can be acquired on keys consisting of either a single
+ Advisory locks can be acquired on keys consisting of either a single
bigint value or two integer values. A bigint key is displayed with its
high-order half in the <structfield>classid</> column, its low-order half
in the <structfield>objid</> column, and <structfield>objsubid</> equal
to 1. Integer keys are displayed with the first key in the
<structfield>classid</> column, the second key in the <structfield>objid</>
column, and <structfield>objsubid</> equal to 2. The actual meaning of
- the keys is up to the user.
+ the keys is up to the user. Advisory locks are local to each database,
+ so the <structfield>database</> column is meaningful for an advisory lock.
</para>
<para>
diff --git a/src/backend/storage/lmgr/deadlock.c b/src/backend/storage/lmgr/deadlock.c
index f75ca1da4cf..de8f8fe99c1 100644
--- a/src/backend/storage/lmgr/deadlock.c
+++ b/src/backend/storage/lmgr/deadlock.c
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/lmgr/deadlock.c,v 1.42 2006/09/18 22:40:36 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/lmgr/deadlock.c,v 1.43 2006/09/22 23:20:13 tgl Exp $
*
* Interface:
*
@@ -872,8 +872,16 @@ DescribeLockTag(StringInfo buf, const LOCKTAG *lock)
lock->locktag_field1);
break;
case LOCKTAG_USERLOCK:
+ /* reserved for old contrib code, now on pgfoundry */
appendStringInfo(buf,
- _("user lock [%u,%u,%u,%u]"),
+ _("user lock [%u,%u,%u]"),
+ lock->locktag_field1,
+ lock->locktag_field2,
+ lock->locktag_field3);
+ break;
+ case LOCKTAG_ADVISORY:
+ appendStringInfo(buf,
+ _("advisory lock [%u,%u,%u,%u]"),
lock->locktag_field1,
lock->locktag_field2,
lock->locktag_field3,
diff --git a/src/backend/storage/lmgr/lmgr.c b/src/backend/storage/lmgr/lmgr.c
index 4442d3909f0..28e862533df 100644
--- a/src/backend/storage/lmgr/lmgr.c
+++ b/src/backend/storage/lmgr/lmgr.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.87 2006/08/18 16:09:09 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.88 2006/09/22 23:20:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -629,6 +629,7 @@ LockTagIsTemp(const LOCKTAG *tag)
/* there are currently no non-table temp objects */
break;
case LOCKTAG_USERLOCK:
+ case LOCKTAG_ADVISORY:
/* assume these aren't temp */
break;
}
diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c
index f7c7deca8d9..a9d8b8b88f4 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -6,7 +6,7 @@
* Copyright (c) 2002-2006, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/lockfuncs.c,v 1.25 2006/09/18 22:40:37 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/lockfuncs.c,v 1.26 2006/09/22 23:20:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -28,7 +28,8 @@ static const char *const LockTagTypeNames[] = {
"tuple",
"transactionid",
"object",
- "userlock"
+ "userlock",
+ "advisory"
};
/* Working status for pg_lock_status */
@@ -181,7 +182,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
MemSet(values, 0, sizeof(values));
MemSet(nulls, ' ', sizeof(nulls));
- if (lock->tag.locktag_type <= LOCKTAG_USERLOCK)
+ if (lock->tag.locktag_type <= LOCKTAG_ADVISORY)
locktypename = LockTagTypeNames[lock->tag.locktag_type];
else
{
@@ -238,6 +239,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
break;
case LOCKTAG_OBJECT:
case LOCKTAG_USERLOCK:
+ case LOCKTAG_ADVISORY:
default: /* treat unknown locktags like OBJECT */
values[1] = ObjectIdGetDatum(lock->tag.locktag_field1);
values[6] = ObjectIdGetDatum(lock->tag.locktag_field2);
@@ -270,7 +272,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
/*
- * Functions for manipulating USERLOCK locks
+ * Functions for manipulating advisory locks
*
* We make use of the locktag fields as follows:
*
@@ -280,13 +282,13 @@ pg_lock_status(PG_FUNCTION_ARGS)
* field4: 1 if using an int8 key, 2 if using 2 int4 keys
*/
#define SET_LOCKTAG_INT64(tag, key64) \
- SET_LOCKTAG_USERLOCK(tag, \
+ SET_LOCKTAG_ADVISORY(tag, \
MyDatabaseId, \
(uint32) ((key64) >> 32), \
(uint32) (key64), \
1)
#define SET_LOCKTAG_INT32(tag, key1, key2) \
- SET_LOCKTAG_USERLOCK(tag, MyDatabaseId, key1, key2, 2)
+ SET_LOCKTAG_ADVISORY(tag, MyDatabaseId, key1, key2, 2)
/*
* pg_advisory_lock(int8) - acquire exclusive lock on an int8 key
@@ -511,7 +513,7 @@ pg_advisory_unlock_shared_int4(PG_FUNCTION_ARGS)
}
/*
- * pg_advisory_unlock_all() - release all userlocks
+ * pg_advisory_unlock_all() - release all advisory locks
*/
Datum
pg_advisory_unlock_all(PG_FUNCTION_ARGS)
diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h
index ac9a71b8760..9717c3f2558 100644
--- a/src/include/storage/lock.h
+++ b/src/include/storage/lock.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.99 2006/09/18 22:40:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.100 2006/09/22 23:20:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -146,7 +146,8 @@ typedef enum LockTagType
* pg_description, but notice that we are constraining SUBID to 16 bits.
* Also, we use DB OID = 0 for shared objects such as tablespaces.
*/
- LOCKTAG_USERLOCK /* advisory "user" locks */
+ LOCKTAG_USERLOCK, /* reserved for old contrib/userlock code */
+ LOCKTAG_ADVISORY /* advisory user locks */
} LockTagType;
/*
@@ -220,12 +221,12 @@ typedef struct LOCKTAG
(locktag).locktag_type = LOCKTAG_OBJECT, \
(locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
-#define SET_LOCKTAG_USERLOCK(locktag,id1,id2,id3,id4) \
+#define SET_LOCKTAG_ADVISORY(locktag,id1,id2,id3,id4) \
((locktag).locktag_field1 = (id1), \
(locktag).locktag_field2 = (id2), \
(locktag).locktag_field3 = (id3), \
(locktag).locktag_field4 = (id4), \
- (locktag).locktag_type = LOCKTAG_USERLOCK, \
+ (locktag).locktag_type = LOCKTAG_ADVISORY, \
(locktag).locktag_lockmethodid = USER_LOCKMETHOD)