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

Commita7fcadd

Browse files
committed
WAL
1 parent7c177a4 commita7fcadd

File tree

21 files changed

+942
-457
lines changed

21 files changed

+942
-457
lines changed

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.62 2000/07/14 22:17:28 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.63 2000/10/21 15:43:09 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -23,6 +23,12 @@
2323
#include"miscadmin.h"
2424
#include"utils/syscache.h"
2525

26+
#ifdefXLOG
27+
#include"access/xlogutils.h"
28+
voidgist_redo(XLogRecPtrlsn,XLogRecord*record);
29+
voidgist_undo(XLogRecPtrlsn,XLogRecord*record);
30+
voidgist_desc(char*buf,uint8xl_info,char*rec);
31+
#endif
2632

2733
/* non-export function prototypes */
2834
staticInsertIndexResultgistdoinsert(Relationr,IndexTupleitup,
@@ -1344,3 +1350,22 @@ int_range_out(INTRANGE *r)
13441350
}
13451351

13461352
#endif/* defined GISTDEBUG */
1353+
1354+
#ifdefXLOG
1355+
void
1356+
gist_redo(XLogRecPtrlsn,XLogRecord*record)
1357+
{
1358+
elog(STOP,"gist_redo: unimplemented");
1359+
}
1360+
1361+
void
1362+
gist_undo(XLogRecPtrlsn,XLogRecord*record)
1363+
{
1364+
elog(STOP,"gist_undo: unimplemented");
1365+
}
1366+
1367+
void
1368+
gist_desc(char*buf,uint8xl_info,char*rec)
1369+
{
1370+
}
1371+
#endif

‎src/backend/access/hash/hash.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.42 2000/07/14 22:17:28 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.43 2000/10/21 15:43:11 vadim Exp $
1212
*
1313
* NOTES
1414
* This file contains only the public interface routines.
@@ -25,9 +25,16 @@
2525
#include"executor/executor.h"
2626
#include"miscadmin.h"
2727

28-
2928
boolBuildingHash= false;
3029

30+
#ifdefXLOG
31+
#include"access/xlogutils.h"
32+
voidhash_redo(XLogRecPtrlsn,XLogRecord*record);
33+
voidhash_undo(XLogRecPtrlsn,XLogRecord*record);
34+
voidhash_desc(char*buf,uint8xl_info,char*rec);
35+
#endif
36+
37+
3138
/*
3239
*hashbuild() -- build a new hash index.
3340
*
@@ -478,3 +485,22 @@ hashdelete(PG_FUNCTION_ARGS)
478485

479486
PG_RETURN_VOID();
480487
}
488+
489+
#ifdefXLOG
490+
void
491+
hash_redo(XLogRecPtrlsn,XLogRecord*record)
492+
{
493+
elog(STOP,"hash_redo: unimplemented");
494+
}
495+
496+
void
497+
hash_undo(XLogRecPtrlsn,XLogRecord*record)
498+
{
499+
elog(STOP,"hash_undo: unimplemented");
500+
}
501+
502+
void
503+
hash_desc(char*buf,uint8xl_info,char*rec)
504+
{
505+
}
506+
#endif

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

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.89 2000/10/20 11:01:02 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.90 2000/10/21 15:43:14 vadim Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -86,12 +86,14 @@
8686
#include"utils/inval.h"
8787
#include"utils/relcache.h"
8888

89-
#ifdefXLOG/* comments are in heap_update */
89+
#ifdefXLOG
9090
#include"access/xlogutils.h"
9191

9292
voidheap_redo(XLogRecPtrlsn,XLogRecord*record);
9393
voidheap_undo(XLogRecPtrlsn,XLogRecord*record);
94+
voidheap_desc(char*buf,uint8xl_info,char*rec);
9495

96+
/* comments are in heap_update */
9597
staticxl_heaptid_locked_tuple_;
9698
staticvoid_heap_unlock_tuple(void*data);
9799

@@ -2480,4 +2482,53 @@ HeapPageCleanup(Buffer buffer)
24802482
PageRepairFragmentation(page);
24812483
}
24822484

2485+
staticvoid
2486+
out_target(char*buf,xl_heaptid*target)
2487+
{
2488+
sprintf(buf+strlen(buf),"node %u/%u; cid %u; tid %u/%u",
2489+
target->node.tblNode,target->node.relNode,
2490+
target->cid,
2491+
ItemPointerGetBlockNumber(&(target->tid)),
2492+
ItemPointerGetOffsetNumber(&(target->tid)));
2493+
}
2494+
2495+
void
2496+
heap_desc(char*buf,uint8xl_info,char*rec)
2497+
{
2498+
uint8info=xl_info& ~XLR_INFO_MASK;
2499+
2500+
if (info==XLOG_HEAP_INSERT)
2501+
{
2502+
xl_heap_insert*xlrec= (xl_heap_insert*)rec;
2503+
strcat(buf,"insert: ");
2504+
out_target(buf,&(xlrec->target));
2505+
}
2506+
elseif (info==XLOG_HEAP_DELETE)
2507+
{
2508+
xl_heap_delete*xlrec= (xl_heap_delete*)rec;
2509+
strcat(buf,"delete: ");
2510+
out_target(buf,&(xlrec->target));
2511+
}
2512+
elseif (info==XLOG_HEAP_UPDATE)
2513+
{
2514+
xl_heap_update*xlrec= (xl_heap_update*)rec;
2515+
strcat(buf,"update: ");
2516+
out_target(buf,&(xlrec->target));
2517+
sprintf(buf+strlen(buf),"; new %u/%u",
2518+
ItemPointerGetBlockNumber(&(xlrec->newtid)),
2519+
ItemPointerGetOffsetNumber(&(xlrec->newtid)));
2520+
}
2521+
elseif (info==XLOG_HEAP_MOVE)
2522+
{
2523+
xl_heap_move*xlrec= (xl_heap_move*)rec;
2524+
strcat(buf,"move: ");
2525+
out_target(buf,&(xlrec->target));
2526+
sprintf(buf+strlen(buf),"; new %u/%u",
2527+
ItemPointerGetBlockNumber(&(xlrec->newtid)),
2528+
ItemPointerGetOffsetNumber(&(xlrec->newtid)));
2529+
}
2530+
else
2531+
strcat(buf,"UNKNOWN");
2532+
}
2533+
24832534
#endif/* XLOG */

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

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.66 2000/10/13 12:05:20 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.67 2000/10/21 15:43:18 vadim Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -527,12 +527,13 @@ _bt_insertonpg(Relation rel,
527527
{
528528
charxlbuf[sizeof(xl_btree_insert)+
529529
sizeof(CommandId)+sizeof(RelFileNode)];
530-
xl_btree_insert*xlrec=xlbuf;
530+
xl_btree_insert*xlrec=(xl_btree_insert*)xlbuf;
531531
inthsize=SizeOfBtreeInsert;
532532
BTItemDatatruncitem;
533533
BTItemxlitem=btitem;
534534
Sizexlsize=IndexTupleDSize(btitem->bti_itup)+
535535
(sizeof(BTItemData)-sizeof(IndexTupleData));
536+
XLogRecPtrrecptr;
536537

537538
xlrec->target.node=rel->rd_node;
538539
ItemPointerSet(&(xlrec->target.tid),BufferGetBlockNumber(buf),newitemoff);
@@ -555,7 +556,7 @@ _bt_insertonpg(Relation rel,
555556
xlsize=sizeof(BTItemData);
556557
}
557558

558-
XLogRecPtrrecptr=XLogInsert(RM_BTREE_ID,XLOG_BTREE_INSERT,
559+
recptr=XLogInsert(RM_BTREE_ID,XLOG_BTREE_INSERT,
559560
xlbuf,hsize, (char*)xlitem,xlsize);
560561

561562
PageSetLSN(page,recptr);
@@ -785,17 +786,19 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
785786
{
786787
charxlbuf[sizeof(xl_btree_split)+
787788
sizeof(CommandId)+sizeof(RelFileNode)+BLCKSZ];
788-
xl_btree_split*xlrec=xlbuf;
789+
xl_btree_split*xlrec=(xl_btree_split*)xlbuf;
789790
inthsize=SizeOfBtreeSplit;
790791
intflag= (newitemonleft) ?
791792
XLOG_BTREE_SPLEFT :XLOG_BTREE_SPLIT;
793+
BlockNumberblkno;
794+
XLogRecPtrrecptr;
792795

793796
xlrec->target.node=rel->rd_node;
794-
ItemPointerSet(&(xlrec->target.tid),itup_blkno,itup_off);
797+
ItemPointerSet(&(xlrec->target.tid),*itup_blkno,*itup_off);
795798
if (P_ISLEAF(lopaque))
796799
{
797800
CommandIdcid=GetCurrentCommandId();
798-
memcpy(xlbuf+hsize,&(char*)cid,sizeof(CommandId));
801+
memcpy(xlbuf+hsize,&cid,sizeof(CommandId));
799802
hsize+=sizeof(CommandId);
800803
memcpy(xlbuf+hsize,&(_xlheapRel->rd_node),sizeof(RelFileNode));
801804
hsize+=sizeof(RelFileNode);
@@ -814,7 +817,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
814817
* Actually, seems that in non-leaf splits newitem shouldn't
815818
* go to first data key position on left page.
816819
*/
817-
if (!P_ISLEAF(lopaque)&&itup_off==P_FIRSTDATAKEY(lopaque))
820+
if (!P_ISLEAF(lopaque)&&*itup_off==P_FIRSTDATAKEY(lopaque))
818821
{
819822
BTItemDatatruncitem=*newitem;
820823
truncitem.bti_itup.t_info=sizeof(BTItemData);
@@ -828,20 +831,24 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
828831
memcpy(xlbuf+hsize, (char*)newitem,itemsz);
829832
hsize+=itemsz;
830833
}
831-
xlrec->otherblk=BufferGetBlockNumber(rbuf);
834+
blkno=BufferGetBlockNumber(rbuf);
835+
BlockIdSet(&(xlrec->otherblk),blkno);
832836
}
833837
else
834-
xlrec->otherblk=BufferGetBlockNumber(buf);
838+
{
839+
blkno=BufferGetBlockNumber(buf);
840+
BlockIdSet(&(xlrec->otherblk),blkno);
841+
}
835842

836-
xlrec->rightblk=ropaque->btpo_next;
843+
BlockIdSet(&(xlrec->rightblk),ropaque->btpo_next);
837844

838845
/*
839846
* Dirrect access to page is not good but faster - we should
840847
* implement some new func in page API.
841848
*/
842-
XLogRecPtrrecptr=XLogInsert(RM_BTREE_ID,flag,xlbuf,
843-
hsize, (char*)rightpage+ (PageHeader)rightpage)->pd_upper,
844-
((PageHeader)rightpage)->pd_special- ((PageHeader)rightpage)->upper);
849+
recptr=XLogInsert(RM_BTREE_ID,flag,xlbuf,
850+
hsize, (char*)rightpage+ ((PageHeader)rightpage)->pd_upper,
851+
((PageHeader)rightpage)->pd_special- ((PageHeader)rightpage)->pd_upper);
845852

846853
PageSetLSN(leftpage,recptr);
847854
PageSetSUI(leftpage,ThisStartUpID);
@@ -1070,7 +1077,7 @@ static Buffer
10701077
_bt_getstackbuf(Relationrel,BTStackstack)
10711078
{
10721079
BlockNumberblkno;
1073-
Bufferbuf,newbuf;
1080+
Bufferbuf;
10741081
OffsetNumberstart,
10751082
offnum,
10761083
maxoff;
@@ -1236,6 +1243,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
12361243
xl_btree_newrootxlrec;
12371244
Pagemetapg=BufferGetPage(metabuf);
12381245
BTMetaPageData*metad=BTPageGetMeta(metapg);
1246+
XLogRecPtrrecptr;
12391247

12401248
xlrec.node=rel->rd_node;
12411249
BlockIdSet(&(xlrec.rootblk),rootblknum);
@@ -1244,10 +1252,10 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
12441252
* Dirrect access to page is not good but faster - we should
12451253
* implement some new func in page API.
12461254
*/
1247-
XLogRecPtrrecptr=XLogInsert(RM_BTREE_ID,XLOG_BTREE_NEWROOT,
1248-
&xlrec,SizeOfBtreeNewroot,
1249-
(char*)rootpage+ (PageHeader)rootpage)->pd_upper,
1250-
((PageHeader)rootpage)->pd_special- ((PageHeader)rootpage)->upper);
1255+
recptr=XLogInsert(RM_BTREE_ID,XLOG_BTREE_NEWROOT,
1256+
(char*)&xlrec,SizeOfBtreeNewroot,
1257+
(char*)rootpage+ ((PageHeader)rootpage)->pd_upper,
1258+
((PageHeader)rootpage)->pd_special- ((PageHeader)rootpage)->pd_upper);
12511259

12521260
metad->btm_root=rootblknum;
12531261
(metad->btm_level)++;

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.39 2000/10/13 02:03:00 vadim Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.40 2000/10/21 15:43:18 vadim Exp $
1313
*
1414
*NOTES
1515
* Postgres btree pages look like ordinary relation pages.The opaque
@@ -171,13 +171,14 @@ _bt_getroot(Relation rel, int access)
171171
#ifdefXLOG
172172
/* XLOG stuff */
173173
{
174-
xl_btree_newrootxlrec;
174+
xl_btree_newrootxlrec;
175+
XLogRecPtrrecptr;
175176

176177
xlrec.node=rel->rd_node;
177178
BlockIdSet(&(xlrec.rootblk),rootblkno);
178179

179-
XLogRecPtrrecptr=XLogInsert(RM_BTREE_ID,XLOG_BTREE_NEWROOT,
180-
&xlrec,SizeOfBtreeNewroot,NULL,0);
180+
recptr=XLogInsert(RM_BTREE_ID,XLOG_BTREE_NEWROOT,
181+
(char*)&xlrec,SizeOfBtreeNewroot,NULL,0);
181182

182183
PageSetLSN(rootpage,recptr);
183184
PageSetSUI(rootpage,ThisStartUpID);
@@ -404,10 +405,12 @@ _bt_pagedel(Relation rel, ItemPointer tid)
404405
/* XLOG stuff */
405406
{
406407
xl_btree_deletexlrec;
408+
XLogRecPtrrecptr;
409+
407410
xlrec.target.node=rel->rd_node;
408411
xlrec.target.tid=*tid;
409-
XLogRecPtrrecptr=XLogInsert(RM_BTREE_ID,XLOG_BTREE_DELETE,
410-
(char*)xlrec,SizeOfBtreeDelete,NULL,0);
412+
recptr=XLogInsert(RM_BTREE_ID,XLOG_BTREE_DELETE,
413+
(char*)&xlrec,SizeOfBtreeDelete,NULL,0);
411414

412415
PageSetLSN(page,recptr);
413416
PageSetSUI(page,ThisStartUpID);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp