]> granicus.if.org Git - postgresql/commitdiff
1. LocalBufferSync(): set nextFreeLocalBuf to 0 - we're freeing
authorVadim B. Mikheev <vadim4o@yahoo.com>
Tue, 20 May 1997 11:30:32 +0000 (11:30 +0000)
committerVadim B. Mikheev <vadim4o@yahoo.com>
Tue, 20 May 1997 11:30:32 +0000 (11:30 +0000)
   all local buffers @ xact commit, so accordingly nextFreeLocalBuf
   is first local buffer now.
   It helps to avoid unnecessary local buffer allocations in LocalBufferAlloc()
   latter ("memmory leaks" in 'order by').
2. ResetLocalBufferPool() lost allocated local buffers:

   memset(LocalBufferDescriptors, 0, sizeof(BufferDesc) * NLocBuffer);

   (local buffers leak @ xact aborts).

src/backend/storage/buffer/localbuf.c

index 3e7f7e2c77602d9c67daaaeaa84914d223e441af..0081b5fa1ddaf418084f85e2f34af912c66bbc36 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.6 1997/04/18 02:53:37 vadim Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.7 1997/05/20 11:30:32 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -273,6 +273,7 @@ LocalBufferSync(void)
     }
 
     memset(LocalRefCount, 0, sizeof(long) * NLocBuffer);
+    nextFreeLocalBuf = 0;
 }
 
 void
@@ -280,15 +281,15 @@ ResetLocalBufferPool(void)
 {
     int i;
 
-    memset(LocalBufferDescriptors, 0, sizeof(BufferDesc) * NLocBuffer);
-    nextFreeLocalBuf = 0;
-
-    for (i = 0; i < NLocBuffer; i++) {
+    for (i = 0; i < NLocBuffer; i++)
+    {
        BufferDesc *buf = &LocalBufferDescriptors[i];
 
-       /* just like InitLocalBuffer() */
+       buf->tag.relId.relId = InvalidOid;
+       buf->flags &= ~BM_DIRTY;
        buf->buf_id = - i - 2;  
     }
 
     memset(LocalRefCount, 0, sizeof(long) * NLocBuffer);
+    nextFreeLocalBuf = 0;
 }