mirror of
https://github.com/postgres/postgres.git
synced 2025-10-29 22:49:41 +03:00
New WAL version - CRC and data blocks backup.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: htup.h,v 1.42 2000/12/27 23:59:13 tgl Exp $
|
||||
* $Id: htup.h,v 1.43 2000/12/28 13:00:25 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -71,6 +71,13 @@ typedef HeapTupleHeaderData *HeapTupleHeader;
|
||||
#define XLOG_HEAP_DELETE 0x10
|
||||
#define XLOG_HEAP_UPDATE 0x20
|
||||
#define XLOG_HEAP_MOVE 0x30
|
||||
#define XLOG_HEAP_CLEAN 0x40
|
||||
#define XLOG_HEAP_OPMASK 0x70
|
||||
/*
|
||||
* When we insert 1st item on new page in INSERT/UPDATE
|
||||
* we can (and we do) restore entire page in redo
|
||||
*/
|
||||
#define XLOG_HEAP_INIT_PAGE 0x80
|
||||
|
||||
/*
|
||||
* All what we need to find changed tuple (18 bytes)
|
||||
@@ -78,13 +85,10 @@ typedef HeapTupleHeaderData *HeapTupleHeader;
|
||||
typedef struct xl_heaptid
|
||||
{
|
||||
RelFileNode node;
|
||||
CommandId cid; /* this is for "better" tuple' */
|
||||
/* identification - it allows to avoid */
|
||||
/* "compensation" records for undo */
|
||||
ItemPointerData tid; /* changed tuple id */
|
||||
} xl_heaptid;
|
||||
|
||||
/* This is what we need to know about delete - ALIGN(18) = 24 bytes */
|
||||
/* This is what we need to know about delete */
|
||||
typedef struct xl_heap_delete
|
||||
{
|
||||
xl_heaptid target; /* deleted tuple id */
|
||||
@@ -92,35 +96,44 @@ typedef struct xl_heap_delete
|
||||
|
||||
#define SizeOfHeapDelete (offsetof(xl_heaptid, tid) + SizeOfIptrData)
|
||||
|
||||
/* This is what we need to know about insert - 26 + data */
|
||||
typedef struct xl_heap_header
|
||||
{
|
||||
Oid t_oid;
|
||||
int16 t_natts;
|
||||
uint8 t_hoff;
|
||||
uint8 mask; /* low 8 bits of t_infomask */
|
||||
} xl_heap_header;
|
||||
|
||||
#define SizeOfHeapHeader (offsetof(xl_heap_header, mask) + sizeof(uint8))
|
||||
|
||||
/* This is what we need to know about insert */
|
||||
typedef struct xl_heap_insert
|
||||
{
|
||||
xl_heaptid target; /* inserted tuple id */
|
||||
/* something from tuple header */
|
||||
int16 t_natts;
|
||||
Oid t_oid;
|
||||
uint8 t_hoff;
|
||||
uint8 mask; /* low 8 bits of t_infomask */
|
||||
/* TUPLE DATA FOLLOWS AT END OF STRUCT */
|
||||
/* xl_heap_header & TUPLE DATA FOLLOWS AT END OF STRUCT */
|
||||
} xl_heap_insert;
|
||||
|
||||
#define SizeOfHeapInsert (offsetof(xl_heap_insert, mask) + sizeof(uint8))
|
||||
#define SizeOfHeapInsert (offsetof(xl_heaptid, tid) + SizeOfIptrData)
|
||||
|
||||
/* This is what we need to know about update|move - 32|36 + data */
|
||||
/* This is what we need to know about update|move */
|
||||
typedef struct xl_heap_update
|
||||
{
|
||||
xl_heaptid target; /* deleted tuple id */
|
||||
ItemPointerData newtid; /* new inserted tuple id */
|
||||
/* something from header of new tuple version */
|
||||
Oid t_oid;
|
||||
int16 t_natts;
|
||||
uint8 t_hoff;
|
||||
uint8 mask; /* low 8 bits of t_infomask */
|
||||
/* NEW TUPLE DATA FOLLOWS AT END OF STRUCT */
|
||||
/* (AFTER XMAX FOR MOVE OP) */
|
||||
/* NEW TUPLE xl_heap_header (XMIN & XMAX FOR MOVE OP) */
|
||||
/* and TUPLE DATA FOLLOWS AT END OF STRUCT */
|
||||
} xl_heap_update;
|
||||
|
||||
#define SizeOfHeapUpdate (offsetof(xl_heap_update, mask) + sizeof(uint8))
|
||||
#define SizeOfHeapUpdate (offsetof(xl_heap_update, newtid) + SizeOfIptrData)
|
||||
|
||||
/* This is what we need to know about page cleanup */
|
||||
typedef struct xl_heap_clean
|
||||
{
|
||||
RelFileNode node;
|
||||
BlockNumber block;
|
||||
} xl_heap_clean;
|
||||
|
||||
#define SizeOfHeapClean (offsetof(xl_heap_clean, block) + sizeof(BlockNumber))
|
||||
|
||||
/*
|
||||
* MaxTupleSize is the maximum allowed size of a tuple, including header and
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: nbtree.h,v 1.48 2000/11/30 08:46:25 vadim Exp $
|
||||
* $Id: nbtree.h,v 1.49 2000/12/28 13:00:25 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -217,8 +217,10 @@ typedef BTStackData *BTStack;
|
||||
/* goes to the left sibling */
|
||||
#define XLOG_BTREE_NEWROOT 0x40 /* new root page */
|
||||
|
||||
#define XLOG_BTREE_LEAF 0x80 /* leaf/internal page was changed */
|
||||
|
||||
/*
|
||||
* All what we need to find changed index tuple (14 bytes)
|
||||
* All what we need to find changed index tuple
|
||||
*/
|
||||
typedef struct xl_btreetid
|
||||
{
|
||||
@@ -227,7 +229,7 @@ typedef struct xl_btreetid
|
||||
} xl_btreetid;
|
||||
|
||||
/*
|
||||
* This is what we need to know about delete - ALIGN(14) = 18 bytes.
|
||||
* This is what we need to know about delete
|
||||
*/
|
||||
typedef struct xl_btree_delete
|
||||
{
|
||||
@@ -237,39 +239,33 @@ typedef struct xl_btree_delete
|
||||
#define SizeOfBtreeDelete (offsetof(xl_btreetid, tid) + SizeOfIptrData)
|
||||
|
||||
/*
|
||||
* This is what we need to know about pure (without split) insert -
|
||||
* 14 + [4+8] + btitem with key data. Note that we need in CommandID
|
||||
* and HeapNode (4 + 8 bytes) only for leaf page insert.
|
||||
* This is what we need to know about pure (without split) insert
|
||||
*/
|
||||
typedef struct xl_btree_insert
|
||||
{
|
||||
xl_btreetid target; /* inserted tuple id */
|
||||
/* [CommandID, HeapNode and ] BTITEM FOLLOWS AT END OF STRUCT */
|
||||
/* BTITEM FOLLOWS AT END OF STRUCT */
|
||||
} xl_btree_insert;
|
||||
|
||||
#define SizeOfBtreeInsert (offsetof(xl_btreetid, tid) + SizeOfIptrData)
|
||||
|
||||
/*
|
||||
* This is what we need to know about insert with split -
|
||||
* 22 + {4 + 8 | left hi-key} + [btitem] + right sibling btitems. Note that
|
||||
* we need in CommandID and HeapNode (4 + 8 bytes) for leaf pages
|
||||
* and in left page hi-key for non-leaf ones.
|
||||
* On insert with split we save items of both left and right siblings
|
||||
* and restore content of both pages from log record
|
||||
*/
|
||||
typedef struct xl_btree_split
|
||||
{
|
||||
xl_btreetid target; /* inserted tuple id */
|
||||
BlockIdData otherblk; /* second block participated in split: */
|
||||
/* first one is stored in target' tid */
|
||||
BlockIdData parentblk; /* parent block */
|
||||
BlockIdData leftblk; /* prev left block */
|
||||
BlockIdData rightblk; /* next right block */
|
||||
/*
|
||||
* We log all btitems from the right sibling. If new btitem goes on
|
||||
* the left sibling then we log it too and it will be the first
|
||||
* BTItemData at the end of this struct after CommandId and HeapNode
|
||||
* on the leaf pages and left page hi-key on non-leaf ones.
|
||||
*/
|
||||
uint16 leftlen; /* len of left page items below */
|
||||
/* LEFT AND RIGHT PAGES ITEMS FOLLOW AT THE END */
|
||||
} xl_btree_split;
|
||||
|
||||
#define SizeOfBtreeSplit (offsetof(xl_btree_split, rightblk) + sizeof(BlockIdData))
|
||||
#define SizeOfBtreeSplit (offsetof(xl_btree_split, leftlen) + sizeof(uint16))
|
||||
|
||||
/*
|
||||
* New root log record.
|
||||
@@ -277,6 +273,7 @@ typedef struct xl_btree_split
|
||||
typedef struct xl_btree_newroot
|
||||
{
|
||||
RelFileNode node;
|
||||
int32 level;
|
||||
BlockIdData rootblk;
|
||||
/* 0 or 2 BTITEMS FOLLOW AT END OF STRUCT */
|
||||
} xl_btree_newroot;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* PostgreSQL transaction log manager
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/include/access/xlog.h,v 1.14 2000/12/18 00:44:48 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/include/access/xlog.h,v 1.15 2000/12/28 13:00:25 vadim Exp $
|
||||
*/
|
||||
#ifndef XLOG_H
|
||||
#define XLOG_H
|
||||
@@ -13,12 +13,19 @@
|
||||
#include "access/xlogdefs.h"
|
||||
#include "access/xlogutils.h"
|
||||
|
||||
typedef struct crc64
|
||||
{
|
||||
uint32 crc1;
|
||||
uint32 crc2;
|
||||
} crc64;
|
||||
|
||||
typedef struct XLogRecord
|
||||
{
|
||||
crc64 xl_crc;
|
||||
XLogRecPtr xl_prev; /* ptr to previous record in log */
|
||||
XLogRecPtr xl_xact_prev; /* ptr to previous record of this xact */
|
||||
TransactionId xl_xid; /* xact id */
|
||||
uint16 xl_len; /* len of record *data* on this page */
|
||||
uint16 xl_len; /* total len of record *data* */
|
||||
uint8 xl_info;
|
||||
RmgrId xl_rmid; /* resource manager inserted this record */
|
||||
|
||||
@@ -33,25 +40,30 @@ typedef struct XLogRecord
|
||||
((char*)record + SizeOfXLogRecord)
|
||||
|
||||
/*
|
||||
* When there is no space on current page we continue on the next
|
||||
* page with subrecord.
|
||||
* When there is no space on current page we continue
|
||||
* on the next page with subrecord.
|
||||
*/
|
||||
typedef struct XLogSubRecord
|
||||
{
|
||||
uint16 xl_len;
|
||||
uint8 xl_info;
|
||||
uint16 xl_len; /* len of data left */
|
||||
|
||||
/* ACTUAL LOG DATA FOLLOWS AT END OF STRUCT */
|
||||
|
||||
} XLogSubRecord;
|
||||
|
||||
#define SizeOfXLogSubRecord DOUBLEALIGN(sizeof(XLogSubRecord))
|
||||
#define SizeOfXLogSubRecord DOUBLEALIGN(sizeof(XLogSubRecord))
|
||||
|
||||
/*
|
||||
* XLOG uses only low 4 bits of xl_info. High 4 bits may be used
|
||||
* by rmgr...
|
||||
* XLOG uses only low 4 bits of xl_info.
|
||||
* High 4 bits may be used by rmgr...
|
||||
*
|
||||
* We support backup of 2 blocks per record only.
|
||||
* If we backed up some of these blocks then we use
|
||||
* flags below to signal rmgr about this on recovery.
|
||||
*/
|
||||
#define XLR_TO_BE_CONTINUED 0x01
|
||||
#define XLR_SET_BKP_BLOCK(iblk) (0x08 >> iblk)
|
||||
#define XLR_BKP_BLOCK_1 XLR_SET_BKP_BLOCK(0) /* 0x08 */
|
||||
#define XLR_BKP_BLOCK_2 XLR_SET_BKP_BLOCK(1) /* 0x04 */
|
||||
#define XLR_INFO_MASK 0x0F
|
||||
|
||||
/*
|
||||
@@ -72,6 +84,7 @@ typedef struct XLogPageHeaderData
|
||||
|
||||
typedef XLogPageHeaderData *XLogPageHeader;
|
||||
|
||||
/* When record crosses page boundary */
|
||||
#define XLP_FIRST_IS_SUBRECORD 0x0001
|
||||
|
||||
#define XLByteLT(left, right) \
|
||||
@@ -100,9 +113,22 @@ typedef struct RmgrData
|
||||
|
||||
extern RmgrData RmgrTable[];
|
||||
|
||||
extern XLogRecPtr XLogInsert(RmgrId rmid, uint8 info,
|
||||
char *hdr, uint32 hdrlen,
|
||||
char *buf, uint32 buflen);
|
||||
/*
|
||||
* List of these structs is used to pass data to XLOG.
|
||||
* If buffer is valid then XLOG will check if buffer must
|
||||
* be backup-ed. For backup-ed buffer data will not be
|
||||
* inserted into record (and XLOG sets
|
||||
* XLR_BKP_BLOCK_X bit in xl_info).
|
||||
*/
|
||||
typedef struct XLogRecData
|
||||
{
|
||||
Buffer buffer; /* buffer associated with this data */
|
||||
char *data;
|
||||
uint32 len;
|
||||
struct XLogRecData *next;
|
||||
} XLogRecData;
|
||||
|
||||
extern XLogRecPtr XLogInsert(RmgrId rmid, uint8 info, XLogRecData *rdata);
|
||||
extern void XLogFlush(XLogRecPtr RecPtr);
|
||||
|
||||
extern void CreateCheckPoint(bool shutdown);
|
||||
|
||||
Reference in New Issue
Block a user