mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-11-27 07:21:09 +08:00
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'.
This commit is contained in:
parent
beca984e5f
commit
d40d34863e
@ -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>
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user