Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitda3df47

Browse files
committed
lmgr.c:DescribeLockTag was never taught about virtual xids, per Greg Stark.
Also a couple of minor tweaks to try to future-proof the code a bit betteragainst future locktag additions.
1 parentbbd3bdb commitda3df47

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

‎src/backend/storage/lmgr/lmgr.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.95 2008/01/01 19:45:52 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.96 2008/01/08 23:18:50 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -672,7 +672,7 @@ UnlockSharedObject(Oid classid, Oid objid, uint16 objsubid,
672672
bool
673673
LockTagIsTemp(constLOCKTAG*tag)
674674
{
675-
switch (tag->locktag_type)
675+
switch ((LockTagType)tag->locktag_type)
676676
{
677677
caseLOCKTAG_RELATION:
678678
caseLOCKTAG_RELATION_EXTEND:
@@ -686,6 +686,7 @@ LockTagIsTemp(const LOCKTAG *tag)
686686
return true;
687687
break;
688688
caseLOCKTAG_TRANSACTION:
689+
caseLOCKTAG_VIRTUALTRANSACTION:
689690
/* there are no temp transactions */
690691
break;
691692
caseLOCKTAG_OBJECT:
@@ -710,7 +711,7 @@ LockTagIsTemp(const LOCKTAG *tag)
710711
void
711712
DescribeLockTag(StringInfobuf,constLOCKTAG*tag)
712713
{
713-
switch (tag->locktag_type)
714+
switch ((LockTagType)tag->locktag_type)
714715
{
715716
caseLOCKTAG_RELATION:
716717
appendStringInfo(buf,
@@ -744,6 +745,12 @@ DescribeLockTag(StringInfo buf, const LOCKTAG *tag)
744745
_("transaction %u"),
745746
tag->locktag_field1);
746747
break;
748+
caseLOCKTAG_VIRTUALTRANSACTION:
749+
appendStringInfo(buf,
750+
_("virtual transaction %d/%u"),
751+
tag->locktag_field1,
752+
tag->locktag_field2);
753+
break;
747754
caseLOCKTAG_OBJECT:
748755
appendStringInfo(buf,
749756
_("object %u of class %u of database %u"),
@@ -770,7 +777,7 @@ DescribeLockTag(StringInfo buf, const LOCKTAG *tag)
770777
default:
771778
appendStringInfo(buf,
772779
_("unrecognized locktag type %d"),
773-
tag->locktag_type);
780+
(int)tag->locktag_type);
774781
break;
775782
}
776783
}

‎src/backend/utils/adt/lockfuncs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2002-2008, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
*$PostgreSQL: pgsql/src/backend/utils/adt/lockfuncs.c,v 1.31 2008/01/01 19:45:52 momjian Exp $
9+
*$PostgreSQL: pgsql/src/backend/utils/adt/lockfuncs.c,v 1.32 2008/01/08 23:18:51 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -206,7 +206,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
206206
MemSet(values,0,sizeof(values));
207207
MemSet(nulls,' ',sizeof(nulls));
208208

209-
if (lock->tag.locktag_type <=LOCKTAG_ADVISORY)
209+
if (lock->tag.locktag_type <=LOCKTAG_LAST_TYPE)
210210
locktypename=LockTagTypeNames[lock->tag.locktag_type];
211211
else
212212
{
@@ -217,7 +217,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
217217
values[0]=DirectFunctionCall1(textin,
218218
CStringGetDatum(locktypename));
219219

220-
switch (lock->tag.locktag_type)
220+
switch ((LockTagType)lock->tag.locktag_type)
221221
{
222222
caseLOCKTAG_RELATION:
223223
caseLOCKTAG_RELATION_EXTEND:

‎src/include/storage/lock.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.111 2008/01/01 19:45:59 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.112 2008/01/08 23:18:51 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -186,6 +186,8 @@ typedef enum LockTagType
186186
LOCKTAG_ADVISORY/* advisory user locks */
187187
}LockTagType;
188188

189+
#defineLOCKTAG_LAST_TYPELOCKTAG_ADVISORY
190+
189191
/*
190192
* The LOCKTAG struct is defined with malice aforethought to fit into 16
191193
* bytes with no padding. Note that this would need adjustment if we were

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp