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

Commit8247f47

Browse files
committed
Hope that this is valid localbuf.c version
1 parentb73eceb commit8247f47

File tree

2 files changed

+11
-59
lines changed

2 files changed

+11
-59
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*-------------------------------------------------------------------------
22
*
3-
*xlog_bufmgr.c
3+
*bufmgr.c
44
* buffer manager interface routines
55
*
66
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.97 2000/11/3008:46:23 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.98 2000/11/3019:03:25 vadim Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/

‎src/backend/storage/buffer/localbuf.c

Lines changed: 9 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,10 @@
1414
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
1515
* Portions Copyright (c) 1994-5, Regents of the University of California
1616
*
17-
*
18-
* IDENTIFICATION
19-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.36 2000/11/30 01:39:07 tgl Exp $
20-
*
2117
*-------------------------------------------------------------------------
2218
*/
23-
2419
#include"postgres.h"
2520

26-
#ifdefXLOG
27-
#include"xlog_localbuf.c"
28-
#else
29-
3021
#include<sys/types.h>
3122
#include<sys/file.h>
3223
#include<math.h>
@@ -109,7 +100,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
109100
* transaction to touch it doesn't need its contents but has not
110101
* flushed it). if that's the case, write it out before reusing it!
111102
*/
112-
if (bufHdr->flags&BM_DIRTY)
103+
if (bufHdr->flags&BM_DIRTY||bufHdr->cntxDirty)
113104
{
114105
Relationbufrel=RelationNodeCacheGetRelation(bufHdr->tag.rnode);
115106

@@ -136,6 +127,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
136127
bufHdr->tag.rnode=reln->rd_node;
137128
bufHdr->tag.blockNum=blockNum;
138129
bufHdr->flags &= ~BM_DIRTY;
130+
bufHdr->cntxDirty= false;
139131

140132
/*
141133
* lazy memory allocation: allocate space on first use of a buffer.
@@ -189,50 +181,6 @@ WriteLocalBuffer(Buffer buffer, bool release)
189181
return true;
190182
}
191183

192-
/*
193-
* FlushLocalBuffer -
194-
* flushes a local buffer
195-
*/
196-
int
197-
FlushLocalBuffer(Bufferbuffer,boolsync,boolrelease)
198-
{
199-
intbufid;
200-
Relationbufrel;
201-
BufferDesc*bufHdr;
202-
203-
Assert(BufferIsLocal(buffer));
204-
205-
#ifdefLBDEBUG
206-
fprintf(stderr,"LB FLUSH %d\n",buffer);
207-
#endif
208-
209-
bufid=-(buffer+1);
210-
bufHdr=&LocalBufferDescriptors[bufid];
211-
bufHdr->flags &= ~BM_DIRTY;
212-
bufrel=RelationNodeCacheGetRelation(bufHdr->tag.rnode);
213-
Assert(bufrel!=NULL);
214-
215-
if (sync)
216-
smgrflush(DEFAULT_SMGR,bufrel,bufHdr->tag.blockNum,
217-
(char*)MAKE_PTR(bufHdr->data));
218-
else
219-
smgrwrite(DEFAULT_SMGR,bufrel,bufHdr->tag.blockNum,
220-
(char*)MAKE_PTR(bufHdr->data));
221-
222-
LocalBufferFlushCount++;
223-
224-
/* drop relcache refcount incremented by RelationNodeCacheGetRelation */
225-
RelationDecrementReferenceCount(bufrel);
226-
227-
if (release)
228-
{
229-
Assert(LocalRefCount[bufid]>0);
230-
LocalRefCount[bufid]--;
231-
}
232-
233-
return true;
234-
}
235-
236184
/*
237185
* InitLocalBuffer -
238186
* init the local buffer cache. Since most queries (esp. multi-user ones)
@@ -273,6 +221,9 @@ InitLocalBuffer(void)
273221
* Flush all dirty buffers in the local buffer cache at commit time.
274222
* Since the buffer cache is only used for keeping relations visible
275223
* during a transaction, we will not need these buffers again.
224+
*
225+
* Note that we have to *flush* local buffers because of them are not
226+
* visible to checkpoint makers. But we can skip XLOG flush check.
276227
*/
277228
void
278229
LocalBufferSync(void)
@@ -284,7 +235,7 @@ LocalBufferSync(void)
284235
BufferDesc*buf=&LocalBufferDescriptors[i];
285236
Relationbufrel;
286237

287-
if (buf->flags&BM_DIRTY)
238+
if (buf->flags&BM_DIRTY||buf->cntxDirty)
288239
{
289240
#ifdefLBDEBUG
290241
fprintf(stderr,"LB SYNC %d\n",-i-1);
@@ -295,12 +246,14 @@ LocalBufferSync(void)
295246

296247
smgrwrite(DEFAULT_SMGR,bufrel,buf->tag.blockNum,
297248
(char*)MAKE_PTR(buf->data));
249+
smgrmarkdirty(DEFAULT_SMGR,bufrel,buf->tag.blockNum);
298250
LocalBufferFlushCount++;
299251

300252
/* drop relcache refcount from RelationIdCacheGetRelation */
301253
RelationDecrementReferenceCount(bufrel);
302254

303255
buf->flags &= ~BM_DIRTY;
256+
buf->cntxDirty= false;
304257
}
305258
}
306259

@@ -319,10 +272,9 @@ ResetLocalBufferPool(void)
319272

320273
buf->tag.rnode.relNode=InvalidOid;
321274
buf->flags &= ~BM_DIRTY;
275+
buf->cntxDirty= false;
322276
}
323277

324278
MemSet(LocalRefCount,0,sizeof(long)*NLocBuffer);
325279
nextFreeLocalBuf=0;
326280
}
327-
328-
#endif/* XLOG */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp