From e7f7cf4a1c25178bf7df6f61d6908ffd22370ee2 Mon Sep 17 00:00:00 2001 From: "Vadim B. Mikheev" Date: Tue, 20 May 1997 11:30:32 +0000 Subject: [PATCH] 1. LocalBufferSync(): set nextFreeLocalBuf to 0 - we're freeing 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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/buffer/localbuf.c index 3e7f7e2c77..0081b5fa1d 100644 --- a/src/backend/storage/buffer/localbuf.c +++ b/src/backend/storage/buffer/localbuf.c @@ -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; } -- 2.40.0