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

Commit27d2693

Browse files
committed
Avoid unsatisfied-external-reference errors in static inlines.
Commit9c72736 neglected the lesson we've learned before:protect references to backend global variables with #ifndef FRONTEND.Since there's already a place for static inlines in this file,move the just-converted functions to that stanza. Undo theentirely gratuitous de-macroization of RelationGetNumberOfBlocks(that one may be okay, since it has no global variable references,but it's also pointless).Per buildfarm.
1 parent617d691 commit27d2693

File tree

1 file changed

+80
-86
lines changed

1 file changed

+80
-86
lines changed

‎src/include/storage/bufmgr.h

Lines changed: 80 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -97,86 +97,6 @@ extern PGDLLIMPORT int32 *LocalRefCount;
9797
#defineBUFFER_LOCK_SHARE1
9898
#defineBUFFER_LOCK_EXCLUSIVE2
9999

100-
/*
101-
* These routines are beaten on quite heavily, hence inline.
102-
*/
103-
104-
/*
105-
* BufferIsValid
106-
*True iff the given buffer number is valid (either as a shared
107-
*or local buffer).
108-
*
109-
* Note: For a long time this was defined the same as BufferIsPinned,
110-
* that is it would say False if you didn't hold a pin on the buffer.
111-
* I believe this was bogus and served only to mask logic errors.
112-
* Code should always know whether it has a buffer reference,
113-
* independently of the pin state.
114-
*
115-
* Note: For a further long time this was not quite the inverse of the
116-
* BufferIsInvalid() macro, in that it also did sanity checks to verify
117-
* that the buffer number was in range. Most likely, this macro was
118-
* originally intended only to be used in assertions, but its use has
119-
* since expanded quite a bit, and the overhead of making those checks
120-
* even in non-assert-enabled builds can be significant. Thus, we've
121-
* now demoted the range checks to assertions within the macro itself.
122-
*/
123-
staticinlinebool
124-
BufferIsValid(Bufferbufnum)
125-
{
126-
Assert(bufnum <=NBuffers);
127-
Assert(bufnum >=-NLocBuffer);
128-
129-
returnbufnum!=InvalidBuffer;
130-
}
131-
132-
/*
133-
* BufferGetBlock
134-
*Returns a reference to a disk page image associated with a buffer.
135-
*
136-
* Note:
137-
*Assumes buffer is valid.
138-
*/
139-
staticinlineBlock
140-
BufferGetBlock(Bufferbuffer)
141-
{
142-
Assert(BufferIsValid(buffer));
143-
144-
if (BufferIsLocal(buffer))
145-
returnLocalBufferBlockPointers[-buffer-1];
146-
else
147-
return (Block) (BufferBlocks+ ((Size) (buffer-1))*BLCKSZ);
148-
}
149-
150-
/*
151-
* BufferGetPageSize
152-
*Returns the page size within a buffer.
153-
*
154-
* Notes:
155-
*Assumes buffer is valid.
156-
*
157-
*The buffer can be a raw disk block and need not contain a valid
158-
*(formatted) disk page.
159-
*/
160-
/* XXX should dig out of buffer descriptor */
161-
staticinlineSize
162-
BufferGetPageSize(Bufferbuffer)
163-
{
164-
AssertMacro(BufferIsValid(buffer));
165-
return (Size)BLCKSZ;
166-
}
167-
168-
/*
169-
* BufferGetPage
170-
*Returns the page associated with a buffer.
171-
*
172-
* When this is called as part of a scan, there may be a need for a nearby
173-
* call to TestForOldSnapshot(). See the definition of that for details.
174-
*/
175-
staticinlinePage
176-
BufferGetPage(Bufferbuffer)
177-
{
178-
return (Page)BufferGetBlock(buffer);
179-
}
180100

181101
/*
182102
* prototypes for functions in bufmgr.c
@@ -211,12 +131,6 @@ extern void CheckPointBuffers(int flags);
211131
externBlockNumberBufferGetBlockNumber(Bufferbuffer);
212132
externBlockNumberRelationGetNumberOfBlocksInFork(Relationrelation,
213133
ForkNumberforkNum);
214-
staticinlineBlockNumber
215-
RelationGetNumberOfBlocks(Relationreln)
216-
{
217-
returnRelationGetNumberOfBlocksInFork(reln,MAIN_FORKNUM);
218-
}
219-
220134
externvoidFlushOneBuffer(Bufferbuffer);
221135
externvoidFlushRelationBuffers(Relationrel);
222136
externvoidFlushRelationsAllBuffers(structSMgrRelationData**smgrs,intnrels);
@@ -231,6 +145,9 @@ extern void DropRelationsAllBuffers(struct SMgrRelationData **smgr_reln,
231145
intnlocators);
232146
externvoidDropDatabaseBuffers(Oiddbid);
233147

148+
#defineRelationGetNumberOfBlocks(reln) \
149+
RelationGetNumberOfBlocksInFork(reln, MAIN_FORKNUM)
150+
234151
externboolBufferIsPermanent(Bufferbuffer);
235152
externXLogRecPtrBufferGetLSNAtomic(Bufferbuffer);
236153

@@ -276,6 +193,83 @@ extern void FreeAccessStrategy(BufferAccessStrategy strategy);
276193

277194
#ifndefFRONTEND
278195

196+
/*
197+
* BufferIsValid
198+
*True iff the given buffer number is valid (either as a shared
199+
*or local buffer).
200+
*
201+
* Note: For a long time this was defined the same as BufferIsPinned,
202+
* that is it would say False if you didn't hold a pin on the buffer.
203+
* I believe this was bogus and served only to mask logic errors.
204+
* Code should always know whether it has a buffer reference,
205+
* independently of the pin state.
206+
*
207+
* Note: For a further long time this was not quite the inverse of the
208+
* BufferIsInvalid() macro, in that it also did sanity checks to verify
209+
* that the buffer number was in range. Most likely, this macro was
210+
* originally intended only to be used in assertions, but its use has
211+
* since expanded quite a bit, and the overhead of making those checks
212+
* even in non-assert-enabled builds can be significant. Thus, we've
213+
* now demoted the range checks to assertions within the macro itself.
214+
*/
215+
staticinlinebool
216+
BufferIsValid(Bufferbufnum)
217+
{
218+
Assert(bufnum <=NBuffers);
219+
Assert(bufnum >=-NLocBuffer);
220+
221+
returnbufnum!=InvalidBuffer;
222+
}
223+
224+
/*
225+
* BufferGetBlock
226+
*Returns a reference to a disk page image associated with a buffer.
227+
*
228+
* Note:
229+
*Assumes buffer is valid.
230+
*/
231+
staticinlineBlock
232+
BufferGetBlock(Bufferbuffer)
233+
{
234+
Assert(BufferIsValid(buffer));
235+
236+
if (BufferIsLocal(buffer))
237+
returnLocalBufferBlockPointers[-buffer-1];
238+
else
239+
return (Block) (BufferBlocks+ ((Size) (buffer-1))*BLCKSZ);
240+
}
241+
242+
/*
243+
* BufferGetPageSize
244+
*Returns the page size within a buffer.
245+
*
246+
* Notes:
247+
*Assumes buffer is valid.
248+
*
249+
*The buffer can be a raw disk block and need not contain a valid
250+
*(formatted) disk page.
251+
*/
252+
/* XXX should dig out of buffer descriptor */
253+
staticinlineSize
254+
BufferGetPageSize(Bufferbuffer)
255+
{
256+
AssertMacro(BufferIsValid(buffer));
257+
return (Size)BLCKSZ;
258+
}
259+
260+
/*
261+
* BufferGetPage
262+
*Returns the page associated with a buffer.
263+
*
264+
* When this is called as part of a scan, there may be a need for a nearby
265+
* call to TestForOldSnapshot(). See the definition of that for details.
266+
*/
267+
staticinlinePage
268+
BufferGetPage(Bufferbuffer)
269+
{
270+
return (Page)BufferGetBlock(buffer);
271+
}
272+
279273
/*
280274
* Check whether the given snapshot is too old to have safely read the given
281275
* page from the given table. If so, throw a "snapshot too old" error.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp