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

Commit5468533

Browse files
committed
Move log_newpage and log_newpage_buffer to xlog.c.
log_newpage is used by many indexams, in addition to heap, but forhistorical reasons it's always been part of the heapam rmgr. Starting with9.3, we have another WAL record type for logging an image of a page,XLOG_FPI. Simplify things by moving log_newpage and log_newpage_buffer toxlog.c, and switch to using the XLOG_FPI record type.Bump the WAL version number because the code to replay the old HEAP_NEWPAGErecords is removed.
1 parentf51ead0 commit5468533

File tree

15 files changed

+139
-225
lines changed

15 files changed

+139
-225
lines changed

‎src/backend/access/gin/gindatapage.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include"postgres.h"
1616

1717
#include"access/gin_private.h"
18-
#include"access/heapam_xlog.h"
1918
#include"lib/ilist.h"
2019
#include"miscadmin.h"
2120
#include"utils/memutils.h"

‎src/backend/access/gin/gininsert.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include"postgres.h"
1616

1717
#include"access/gin_private.h"
18-
#include"access/heapam_xlog.h"
1918
#include"catalog/index.h"
2019
#include"miscadmin.h"
2120
#include"storage/bufmgr.h"

‎src/backend/access/gin/ginxlog.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,8 @@ ginRedoSplit(XLogRecPtr lsn, XLogRecord *record)
558558
}
559559

560560
/*
561-
* This is functionally the same as heap_xlog_newpage.
561+
* VACUUM_PAGE record contains simply a full image of the page, similar to
562+
* a XLOG_FPI record.
562563
*/
563564
staticvoid
564565
ginRedoVacuumPage(XLogRecPtrlsn,XLogRecord*record)

‎src/backend/access/gist/gist.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include"access/genam.h"
1818
#include"access/gist_private.h"
19-
#include"access/heapam_xlog.h"
2019
#include"catalog/index.h"
2120
#include"catalog/pg_collation.h"
2221
#include"miscadmin.h"

‎src/backend/access/heap/heapam.c

Lines changed: 0 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -6921,133 +6921,6 @@ log_heap_update(Relation reln, Buffer oldbuf,
69216921
returnrecptr;
69226922
}
69236923

6924-
/*
6925-
* Perform XLogInsert of a HEAP_NEWPAGE record to WAL. Caller is responsible
6926-
* for writing the page to disk after calling this routine.
6927-
*
6928-
* Note: If you're using this function, you should be building pages in private
6929-
* memory and writing them directly to smgr. If you're using buffers, call
6930-
* log_newpage_buffer instead.
6931-
*
6932-
* If the page follows the standard page layout, with a PageHeader and unused
6933-
* space between pd_lower and pd_upper, set 'page_std' to TRUE. That allows
6934-
* the unused space to be left out from the WAL record, making it smaller.
6935-
*/
6936-
XLogRecPtr
6937-
log_newpage(RelFileNode*rnode,ForkNumberforkNum,BlockNumberblkno,
6938-
Pagepage,boolpage_std)
6939-
{
6940-
xl_heap_newpagexlrec;
6941-
XLogRecPtrrecptr;
6942-
XLogRecDatardata[3];
6943-
6944-
/*
6945-
* Note: the NEWPAGE log record is used for both heaps and indexes, so do
6946-
* not do anything that assumes we are touching a heap.
6947-
*/
6948-
6949-
/* NO ELOG(ERROR) from here till newpage op is logged */
6950-
START_CRIT_SECTION();
6951-
6952-
xlrec.node=*rnode;
6953-
xlrec.forknum=forkNum;
6954-
xlrec.blkno=blkno;
6955-
6956-
if (page_std)
6957-
{
6958-
/* Assume we can omit data between pd_lower and pd_upper */
6959-
uint16lower= ((PageHeader)page)->pd_lower;
6960-
uint16upper= ((PageHeader)page)->pd_upper;
6961-
6962-
if (lower >=SizeOfPageHeaderData&&
6963-
upper>lower&&
6964-
upper <=BLCKSZ)
6965-
{
6966-
xlrec.hole_offset=lower;
6967-
xlrec.hole_length=upper-lower;
6968-
}
6969-
else
6970-
{
6971-
/* No "hole" to compress out */
6972-
xlrec.hole_offset=0;
6973-
xlrec.hole_length=0;
6974-
}
6975-
}
6976-
else
6977-
{
6978-
/* Not a standard page header, don't try to eliminate "hole" */
6979-
xlrec.hole_offset=0;
6980-
xlrec.hole_length=0;
6981-
}
6982-
6983-
rdata[0].data= (char*)&xlrec;
6984-
rdata[0].len=SizeOfHeapNewpage;
6985-
rdata[0].buffer=InvalidBuffer;
6986-
rdata[0].next=&(rdata[1]);
6987-
6988-
if (xlrec.hole_length==0)
6989-
{
6990-
rdata[1].data= (char*)page;
6991-
rdata[1].len=BLCKSZ;
6992-
rdata[1].buffer=InvalidBuffer;
6993-
rdata[1].next=NULL;
6994-
}
6995-
else
6996-
{
6997-
/* must skip the hole */
6998-
rdata[1].data= (char*)page;
6999-
rdata[1].len=xlrec.hole_offset;
7000-
rdata[1].buffer=InvalidBuffer;
7001-
rdata[1].next=&rdata[2];
7002-
7003-
rdata[2].data= (char*)page+ (xlrec.hole_offset+xlrec.hole_length);
7004-
rdata[2].len=BLCKSZ- (xlrec.hole_offset+xlrec.hole_length);
7005-
rdata[2].buffer=InvalidBuffer;
7006-
rdata[2].next=NULL;
7007-
}
7008-
7009-
recptr=XLogInsert(RM_HEAP_ID,XLOG_HEAP_NEWPAGE,rdata);
7010-
7011-
/*
7012-
* The page may be uninitialized. If so, we can't set the LSN because that
7013-
* would corrupt the page.
7014-
*/
7015-
if (!PageIsNew(page))
7016-
{
7017-
PageSetLSN(page,recptr);
7018-
}
7019-
7020-
END_CRIT_SECTION();
7021-
7022-
returnrecptr;
7023-
}
7024-
7025-
/*
7026-
* Perform XLogInsert of a HEAP_NEWPAGE record to WAL.
7027-
*
7028-
* Caller should initialize the buffer and mark it dirty before calling this
7029-
* function. This function will set the page LSN and TLI.
7030-
*
7031-
* If the page follows the standard page layout, with a PageHeader and unused
7032-
* space between pd_lower and pd_upper, set 'page_std' to TRUE. That allows
7033-
* the unused space to be left out from the WAL record, making it smaller.
7034-
*/
7035-
XLogRecPtr
7036-
log_newpage_buffer(Bufferbuffer,boolpage_std)
7037-
{
7038-
Pagepage=BufferGetPage(buffer);
7039-
RelFileNodernode;
7040-
ForkNumberforkNum;
7041-
BlockNumberblkno;
7042-
7043-
/* Shared buffers should be modified in a critical section. */
7044-
Assert(CritSectionCount>0);
7045-
7046-
BufferGetTag(buffer,&rnode,&forkNum,&blkno);
7047-
7048-
returnlog_newpage(&rnode,forkNum,blkno,page,page_std);
7049-
}
7050-
70516924
/*
70526925
* Perform XLogInsert of a XLOG_HEAP2_NEW_CID record
70536926
*
@@ -7515,56 +7388,6 @@ heap_xlog_freeze_page(XLogRecPtr lsn, XLogRecord *record)
75157388
UnlockReleaseBuffer(buffer);
75167389
}
75177390

7518-
staticvoid
7519-
heap_xlog_newpage(XLogRecPtrlsn,XLogRecord*record)
7520-
{
7521-
xl_heap_newpage*xlrec= (xl_heap_newpage*)XLogRecGetData(record);
7522-
char*blk= ((char*)xlrec)+sizeof(xl_heap_newpage);
7523-
Bufferbuffer;
7524-
Pagepage;
7525-
7526-
/* Backup blocks are not used in newpage records */
7527-
Assert(!(record->xl_info&XLR_BKP_BLOCK_MASK));
7528-
7529-
Assert(record->xl_len==SizeOfHeapNewpage+BLCKSZ-xlrec->hole_length);
7530-
7531-
/*
7532-
* Note: the NEWPAGE log record is used for both heaps and indexes, so do
7533-
* not do anything that assumes we are touching a heap.
7534-
*/
7535-
buffer=XLogReadBufferExtended(xlrec->node,xlrec->forknum,xlrec->blkno,
7536-
RBM_ZERO);
7537-
Assert(BufferIsValid(buffer));
7538-
LockBuffer(buffer,BUFFER_LOCK_EXCLUSIVE);
7539-
page= (Page)BufferGetPage(buffer);
7540-
7541-
if (xlrec->hole_length==0)
7542-
{
7543-
memcpy((char*)page,blk,BLCKSZ);
7544-
}
7545-
else
7546-
{
7547-
memcpy((char*)page,blk,xlrec->hole_offset);
7548-
/* must zero-fill the hole */
7549-
MemSet((char*)page+xlrec->hole_offset,0,xlrec->hole_length);
7550-
memcpy((char*)page+ (xlrec->hole_offset+xlrec->hole_length),
7551-
blk+xlrec->hole_offset,
7552-
BLCKSZ- (xlrec->hole_offset+xlrec->hole_length));
7553-
}
7554-
7555-
/*
7556-
* The page may be uninitialized. If so, we can't set the LSN because that
7557-
* would corrupt the page.
7558-
*/
7559-
if (!PageIsNew(page))
7560-
{
7561-
PageSetLSN(page,lsn);
7562-
}
7563-
7564-
MarkBufferDirty(buffer);
7565-
UnlockReleaseBuffer(buffer);
7566-
}
7567-
75687391
/*
75697392
* Given an "infobits" field from an XLog record, set the correct bits in the
75707393
* given infomask and infomask2 for the tuple touched by the record.
@@ -8421,9 +8244,6 @@ heap_redo(XLogRecPtr lsn, XLogRecord *record)
84218244
caseXLOG_HEAP_HOT_UPDATE:
84228245
heap_xlog_update(lsn,record, true);
84238246
break;
8424-
caseXLOG_HEAP_NEWPAGE:
8425-
heap_xlog_newpage(lsn,record);
8426-
break;
84278247
caseXLOG_HEAP_LOCK:
84288248
heap_xlog_lock(lsn,record);
84298249
break;

‎src/backend/access/nbtree/nbtree.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
#include"postgres.h"
2020

21-
#include"access/heapam_xlog.h"
2221
#include"access/nbtree.h"
2322
#include"access/relscan.h"
2423
#include"catalog/index.h"

‎src/backend/access/nbtree/nbtsort.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666

6767
#include"postgres.h"
6868

69-
#include"access/heapam_xlog.h"
7069
#include"access/nbtree.h"
7170
#include"miscadmin.h"
7271
#include"storage/smgr.h"

‎src/backend/access/rmgrdesc/heapdesc.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,6 @@ heap_desc(StringInfo buf, XLogRecord *record)
9898
ItemPointerGetOffsetNumber(&(xlrec->newtid)),
9999
xlrec->new_xmax);
100100
}
101-
elseif (info==XLOG_HEAP_NEWPAGE)
102-
{
103-
xl_heap_newpage*xlrec= (xl_heap_newpage*)rec;
104-
105-
appendStringInfo(buf,"newpage: rel %u/%u/%u; fork %u, blk %u",
106-
xlrec->node.spcNode,xlrec->node.dbNode,
107-
xlrec->node.relNode,xlrec->forknum,
108-
xlrec->blkno);
109-
}
110101
elseif (info==XLOG_HEAP_LOCK)
111102
{
112103
xl_heap_lock*xlrec= (xl_heap_lock*)rec;

‎src/backend/access/spgist/spginsert.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include"postgres.h"
1818

1919
#include"access/genam.h"
20-
#include"access/heapam_xlog.h"
2120
#include"access/spgist_private.h"
2221
#include"catalog/index.h"
2322
#include"miscadmin.h"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp