]> granicus.if.org Git - postgresql/commitdiff
Widen the nLocks counts in local lock tables from int to int64. This
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 16 Sep 2008 01:56:49 +0000 (01:56 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 16 Sep 2008 01:56:49 +0000 (01:56 +0000)
forestalls potential overflow when the same table (or other object, but
usually tables) is accessed by very many successive queries within a single
transaction.  Per report from Michael Milligan.

Back-patch to 8.0, which is as far back as the patch conveniently applies.
There have been no reports of overflow in pre-8.3 releases, but clearly the
risk existed all along.  (Michael's report suggests that 8.3 may consume lock
counts faster than prior releases, but with no test case to look at it's hard
to be sure about that.  Widening the counts seems a good future-proofing
measure in any event.)

src/include/storage/lock.h

index e6b9e94b6573f84ce148ad92d04067888642a0d6..c3c75afbbcc7212c2ff2c28a7e4f46d5053a9ca5 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.91 2005/10/15 02:49:46 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.91.2.1 2008/09/16 01:56:49 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -314,7 +314,7 @@ typedef struct LOCALLOCKOWNER
         * Must use a forward struct reference to avoid circularity.
         */
        struct ResourceOwnerData *owner;
-       int                     nLocks;                 /* # of times held by this owner */
+       int64           nLocks;                 /* # of times held by this owner */
 } LOCALLOCKOWNER;
 
 typedef struct LOCALLOCK
@@ -326,7 +326,7 @@ typedef struct LOCALLOCK
        LOCK       *lock;                       /* associated LOCK object in shared mem */
        PROCLOCK   *proclock;           /* associated PROCLOCK object in shmem */
        bool            isTempObject;   /* true if lock is on a temporary object */
-       int                     nLocks;                 /* total number of times lock is held */
+       int64           nLocks;                 /* total number of times lock is held */
        int                     numLockOwners;  /* # of relevant ResourceOwners */
        int                     maxLockOwners;  /* allocated size of array */
        LOCALLOCKOWNER *lockOwners; /* dynamically resizable array */