lmgr.c:DescribeLockTag was never taught about virtual xids, per Greg Stark.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 8 Jan 2008 23:18:51 +0000 (23:18 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 8 Jan 2008 23:18:51 +0000 (23:18 +0000)
Also a couple of minor tweaks to try to future-proof the code a bit better
against future locktag additions.

src/backend/storage/lmgr/lmgr.c
src/backend/utils/adt/lockfuncs.c
src/include/storage/lock.h

index ed72c489bdfda6b2fa5d70dbf961e892647650c7..e216363b9836479549e8f06bcef7312c9808abe4 100644 (file)
@@ -672,7 +672,7 @@ UnlockSharedObject(Oid classid, Oid objid, uint16 objsubid,
 bool
 LockTagIsTemp(const LOCKTAG *tag)
 {
-       switch (tag->locktag_type)
+       switch ((LockTagType) tag->locktag_type)
        {
                case LOCKTAG_RELATION:
                case LOCKTAG_RELATION_EXTEND:
@@ -686,6 +686,7 @@ LockTagIsTemp(const LOCKTAG *tag)
                                return true;
                        break;
                case LOCKTAG_TRANSACTION:
+               case LOCKTAG_VIRTUALTRANSACTION:
                        /* there are no temp transactions */
                        break;
                case LOCKTAG_OBJECT:
@@ -710,7 +711,7 @@ LockTagIsTemp(const LOCKTAG *tag)
 void
 DescribeLockTag(StringInfo buf, const LOCKTAG *tag)
 {
-       switch (tag->locktag_type)
+       switch ((LockTagType) tag->locktag_type)
        {
                case LOCKTAG_RELATION:
                        appendStringInfo(buf,
@@ -744,6 +745,12 @@ DescribeLockTag(StringInfo buf, const LOCKTAG *tag)
                                                         _("transaction %u"),
                                                         tag->locktag_field1);
                        break;
+               case LOCKTAG_VIRTUALTRANSACTION:
+                       appendStringInfo(buf,
+                                                        _("virtual transaction %d/%u"),
+                                                        tag->locktag_field1,
+                                                        tag->locktag_field2);
+                       break;
                case LOCKTAG_OBJECT:
                        appendStringInfo(buf,
                                                         _("object %u of class %u of database %u"),
@@ -770,7 +777,7 @@ DescribeLockTag(StringInfo buf, const LOCKTAG *tag)
                default:
                        appendStringInfo(buf,
                                                         _("unrecognized locktag type %d"),
-                                                        tag->locktag_type);
+                                                        (int) tag->locktag_type);
                        break;
        }
 }
index 85a9c36ee2af594b32ce502774bba516d401ea79..f628e3780c1d88841b667fe56029f6b2a5433db9 100644 (file)
@@ -206,7 +206,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
                MemSet(values, 0, sizeof(values));
                MemSet(nulls, ' ', sizeof(nulls));
 
-               if (lock->tag.locktag_type <= LOCKTAG_ADVISORY)
+               if (lock->tag.locktag_type <= LOCKTAG_LAST_TYPE)
                        locktypename = LockTagTypeNames[lock->tag.locktag_type];
                else
                {
@@ -217,7 +217,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
                values[0] = DirectFunctionCall1(textin,
                                                                                CStringGetDatum(locktypename));
 
-               switch (lock->tag.locktag_type)
+               switch ((LockTagType) lock->tag.locktag_type)
                {
                        case LOCKTAG_RELATION:
                        case LOCKTAG_RELATION_EXTEND:
index 4b7bb0021f28cc8da7dca4cfc79c74b073b84eb6..e335d753303ba3ef3148555d5ed0ae02f3f780fb 100644 (file)
@@ -186,6 +186,8 @@ typedef enum LockTagType
        LOCKTAG_ADVISORY                        /* advisory user locks */
 } LockTagType;
 
+#define LOCKTAG_LAST_TYPE      LOCKTAG_ADVISORY
+
 /*
  * The LOCKTAG struct is defined with malice aforethought to fit into 16
  * bytes with no padding.  Note that this would need adjustment if we were