Documentation
¶
Index ¶
- Constants
- Variables
- func NewInvalidPageHeaderError() error
- func NewNotEnoughDataToShrinkError(dataRemained int, toShrink int) error
- func NewZeroPageHeaderError() error
- func SetBlockSize(sizeByte uint64)
- func SetWalPageSize(sizeByte uint64)
- func WriteLocationsTo(writer io.Writer, locations []BlockLocation) error
- type AlignedReader
- type BlockLocation
- func ExtractBlockLocations(records []XLogRecord) []BlockLocation
- func ExtractLocationsFromWalFile(parser *WalParser, walFile io.ReadCloser) ([]BlockLocation, error)
- func NewBlockLocation(spcNode, dbNode, relNode Oid, blockNo uint32) *BlockLocation
- func ReadLocationsFrom(reader io.Reader) ([]BlockLocation, error)
- type BlockLocationReader
- type BlockLocationWriter
- type CantSavePartialParserError
- type ContinuationNotFoundError
- type InconsistentBlockDataStateError
- type InconsistentBlockImageHoleStateError
- type InconsistentBlockImageLengthError
- type InconsistentXLogRecordTotalLengthError
- type InvalidPageHeaderError
- type InvalidRecordBlockIDError
- type InvalidXLogRecordResourceManagerIDError
- type NoPrevRelFileNodeError
- type NotEnoughDataToShrinkError
- type Oid
- type OutOfOrderBlockIDError
- type PartialPageError
- type RelFileNode
- type ShrinkableReader
- type TimeLineID
- type WalPageReader
- type WalParser
- type XLogPage
- type XLogPageHeader
- type XLogRecord
- type XLogRecordBlock
- type XLogRecordBlockHeader
- type XLogRecordBlockImageHeader
- type XLogRecordHeader
- type XLogRecordPtr
- type ZeroPageError
- type ZeroPageHeaderError
- type ZeroRecordHeaderError
Constants ¶
const ( RmXlogID = iota RmXactID RmSmgrID RmClogID RmDBaseID RmTblSpcID RmMultiXactID RmRelMapID RmStandbyID RmHeap2ID RmHeapID RmBTreeID RmHashID RmGinID RmGistID RmSeqID RmSPGistID RmBrinID RmCommitTSID RmReplOriginID RmGenericID RmLogicalMsgID RmNextFreeID )
const ( /* When record crosses page boundary, set this flag in new page's header */ XlpFirstIsContRecord = 0x0001 /* This flag indicates a "long" page header */ XlpLongHeader = 0x0002 /* This flag indicates backup blocks starting in this page are optional */ XlpBkpRemovable = 0x0004 /* All defined flag bits in xlp_info (used for validity checking of header) */ XlpAllFlags = 0x0007 )
const ( XLogSwitch = 0x40 WalSwitchRecordSize = XLogRecordHeaderSize )
const ( XlrMaxBlockID = 32 XlrBlockIDDataShort = 255 XlrBlockIDDataLong = 254 XlrBlockIDOrigin = 253 BkpBlockForkMask uint8 = 0x0F BkpBlockFlagMask uint8 = 0xF0 BkpBlockHasImage uint8 = 0x10 BkpBlockHasData uint8 = 0x20 BkpBlockWillInit uint8 = 0x40 BkpBlockSameRel uint8 = 0x80 )
const ( BkpImageHasHole uint8 = 0x01 BkpImageIsCompressed uint8 = 0x02 BkpImageApply uint8 = 0x04 )
const ( XlrInfoMask = 0x0F XlrRmgrInfoMask = 0xF0 XlrSpecialRelUpdate = 0x01 XlrCheckConsistency = 0x02 XLogRecordHeaderSize = 24 )
const XLogRecordAlignment = 8
Variables ¶
var ( WalPageSize uint16 = 8192 BlockSize uint16 = 8192 )
var TerminalLocation = *NewBlockLocation(0, 0, 0, 0)
Functions ¶
func NewInvalidPageHeaderError ¶
func NewInvalidPageHeaderError() error
func NewZeroPageHeaderError ¶
func NewZeroPageHeaderError() error
func SetBlockSize ¶
func SetBlockSize(sizeByte uint64)
func SetWalPageSize ¶
func SetWalPageSize(sizeByte uint64)
func WriteLocationsTo ¶
func WriteLocationsTo(writer io.Writer, locations []BlockLocation) error
Types ¶
type AlignedReader ¶
type AlignedReader struct {
// contains filtered or unexported fields
}
func NewAlignedReader ¶
func NewAlignedReader(source io.Reader, alignment int) *AlignedReader
func (*AlignedReader) ReadToAlignment ¶
func (reader *AlignedReader) ReadToAlignment() error
type BlockLocation ¶
type BlockLocation struct {
RelationFileNode RelFileNode
BlockNo uint32
}
func ExtractBlockLocations ¶
func ExtractBlockLocations(records []XLogRecord) []BlockLocation
func ExtractLocationsFromWalFile ¶
func ExtractLocationsFromWalFile(parser *WalParser, walFile io.ReadCloser) ([]BlockLocation, error)
func NewBlockLocation ¶
func NewBlockLocation(spcNode, dbNode, relNode Oid, blockNo uint32) *BlockLocation
func ReadLocationsFrom ¶
func ReadLocationsFrom(reader io.Reader) ([]BlockLocation, error)
type BlockLocationReader ¶
type BlockLocationReader struct {
// contains filtered or unexported fields
}
func NewBlockLocationReader ¶
func NewBlockLocationReader(underlying io.Reader) *BlockLocationReader
func (*BlockLocationReader) ReadNextLocation ¶
func (reader *BlockLocationReader) ReadNextLocation() (*BlockLocation, error)
type BlockLocationWriter ¶
func NewBlockLocationWriter ¶
func NewBlockLocationWriter(underlying io.Writer) *BlockLocationWriter
func (*BlockLocationWriter) WriteLocation ¶
func (locationWriter *BlockLocationWriter) WriteLocation(location BlockLocation) error
type CantSavePartialParserError ¶
type CantSavePartialParserError struct {
// contains filtered or unexported fields
}
func NewCantSavePartialParserError ¶
func NewCantSavePartialParserError() CantSavePartialParserError
func (CantSavePartialParserError) Error ¶
func (err CantSavePartialParserError) Error() string
type ContinuationNotFoundError ¶
type ContinuationNotFoundError struct {
// contains filtered or unexported fields
}
func NewContinuationNotFoundError ¶
func NewContinuationNotFoundError() ContinuationNotFoundError
type InconsistentBlockDataStateError ¶
type InconsistentBlockDataStateError struct {
// contains filtered or unexported fields
}
func NewInconsistentBlockDataStateError ¶
func NewInconsistentBlockDataStateError(hasData bool, dataLength uint16) InconsistentBlockDataStateError
func (InconsistentBlockDataStateError) Error ¶
func (err InconsistentBlockDataStateError) Error() string
type InconsistentBlockImageHoleStateError ¶
type InconsistentBlockImageHoleStateError struct {
// contains filtered or unexported fields
}
func NewInconsistentBlockImageHoleStateError ¶
func NewInconsistentBlockImageHoleStateError(holeOffset uint16, holeLength uint16, imageLength uint16, hasHole bool) InconsistentBlockImageHoleStateError
func (InconsistentBlockImageHoleStateError) Error ¶
func (err InconsistentBlockImageHoleStateError) Error() string
type InconsistentBlockImageLengthError ¶
type InconsistentBlockImageLengthError struct {
// contains filtered or unexported fields
}
func NewInconsistentBlockImageLengthError ¶
func NewInconsistentBlockImageLengthError(hasHole bool, isCompressed bool, length uint16) InconsistentBlockImageLengthError
func (InconsistentBlockImageLengthError) Error ¶
func (err InconsistentBlockImageLengthError) Error() string
type InconsistentXLogRecordTotalLengthError ¶
type InconsistentXLogRecordTotalLengthError struct {
// contains filtered or unexported fields
}
func NewInconsistentXLogRecordTotalLengthError ¶
func NewInconsistentXLogRecordTotalLengthError(totalRecordLength uint32) InconsistentXLogRecordTotalLengthError
func (InconsistentXLogRecordTotalLengthError) Error ¶
func (err InconsistentXLogRecordTotalLengthError) Error() string
type InvalidPageHeaderError ¶
type InvalidPageHeaderError struct {
// contains filtered or unexported fields
}
func (InvalidPageHeaderError) Error ¶
func (err InvalidPageHeaderError) Error() string
type InvalidRecordBlockIDError ¶
type InvalidRecordBlockIDError struct {
// contains filtered or unexported fields
}
func NewInvalidRecordBlockIDError ¶
func NewInvalidRecordBlockIDError(blockID uint8) InvalidRecordBlockIDError
func (InvalidRecordBlockIDError) Error ¶
func (err InvalidRecordBlockIDError) Error() string
type InvalidXLogRecordResourceManagerIDError ¶
type InvalidXLogRecordResourceManagerIDError struct {
// contains filtered or unexported fields
}
func NewInvalidXLogRecordResourceManagerIDError ¶
func NewInvalidXLogRecordResourceManagerIDError(resourceManagerID uint8) InvalidXLogRecordResourceManagerIDError
func (InvalidXLogRecordResourceManagerIDError) Error ¶
func (err InvalidXLogRecordResourceManagerIDError) Error() string
type NoPrevRelFileNodeError ¶
type NoPrevRelFileNodeError struct {
// contains filtered or unexported fields
}
func NewNoPrevRelFileNodeError ¶
func NewNoPrevRelFileNodeError() NoPrevRelFileNodeError
func (NoPrevRelFileNodeError) Error ¶
func (err NoPrevRelFileNodeError) Error() string
type NotEnoughDataToShrinkError ¶
type NotEnoughDataToShrinkError struct {
// contains filtered or unexported fields
}
func (NotEnoughDataToShrinkError) Error ¶
func (err NotEnoughDataToShrinkError) Error() string
type OutOfOrderBlockIDError ¶
type OutOfOrderBlockIDError struct {
// contains filtered or unexported fields
}
func NewOutOfOrderBlockIDError ¶
func NewOutOfOrderBlockIDError(actualBlockID int, expectedBlockID int) OutOfOrderBlockIDError
func (OutOfOrderBlockIDError) Error ¶
func (err OutOfOrderBlockIDError) Error() string
type PartialPageError ¶
type PartialPageError struct {
// contains filtered or unexported fields
}
func NewPartialPageError ¶
func NewPartialPageError() PartialPageError
func (PartialPageError) Error ¶
func (err PartialPageError) Error() string
type RelFileNode ¶
This struct corresponds to postgres struct RelFileNode. * For clarification you can find it in postgres: * src/include/storage/relfilenode.h
type ShrinkableReader ¶
type ShrinkableReader struct {
// contains filtered or unexported fields
}
func (*ShrinkableReader) Shrink ¶
func (reader *ShrinkableReader) Shrink(length int) error
type TimeLineID ¶
type TimeLineID uint32
type WalPageReader ¶
type WalPageReader struct {
// contains filtered or unexported fields
}
func NewWalPageReader ¶
func NewWalPageReader(walFileReader io.Reader) *WalPageReader
func (*WalPageReader) ReadPageData ¶
func (reader *WalPageReader) ReadPageData() ([]byte, error)
ReadPageData reads data corresponding to one page
type WalParser ¶
type WalParser struct {
// contains filtered or unexported fields
}
func NewWalParser ¶
func NewWalParser() *WalParser
func (*WalParser) GetCurrentRecordData ¶
func (*WalParser) Invalidate ¶
func (parser *WalParser) Invalidate()
func (*WalParser) ParseRecordsFromPage ¶
type XLogPage ¶
type XLogPage struct {
Header XLogPageHeader
PrevRecordTrailingData []byte
Records []XLogRecord
NextRecordHeadingData []byte
}
type XLogPageHeader ¶
type XLogPageHeader struct {
Magic uint16
Info uint16
TimeLineID TimeLineID
PageAddress XLogRecordPtr
RemainingDataLen uint32
}
This struct corresponds to postgres struct XLogPageHeaderData. * For clarification you can find it in postgres: * src/include/access/xlog_internal.h
func (*XLogPageHeader) HasContinuationRecord ¶
func (pageHeader *XLogPageHeader) HasContinuationRecord() bool
func (*XLogPageHeader) IsLong ¶
func (pageHeader *XLogPageHeader) IsLong() bool
func (*XLogPageHeader) IsValid ¶
func (pageHeader *XLogPageHeader) IsValid() bool
type XLogRecord ¶
type XLogRecord struct {
Header XLogRecordHeader
MainDataLen uint32
Origin uint16
Blocks []XLogRecordBlock
MainData []byte
}
func NewXLogRecord ¶
func NewXLogRecord(header XLogRecordHeader) *XLogRecord
func ParseXLogRecordFromBytes ¶
func ParseXLogRecordFromBytes(data []byte) (*XLogRecord, error)
func (*XLogRecord) IsZero ¶
func (record *XLogRecord) IsZero() bool
type XLogRecordBlock ¶
type XLogRecordBlock struct {
Header XLogRecordBlockHeader
Image []byte
Data []byte
}
type XLogRecordBlockHeader ¶
type XLogRecordBlockHeader struct {
BlockID uint8
ForkFlags uint8
DataLength uint16
ImageHeader XLogRecordBlockImageHeader
BlockLocation BlockLocation
}
func NewXLogRecordBlockHeader ¶
func NewXLogRecordBlockHeader(blockID uint8) *XLogRecordBlockHeader
func (*XLogRecordBlockHeader) ForkNum ¶
func (blockHeader *XLogRecordBlockHeader) ForkNum() uint8
func (*XLogRecordBlockHeader) HasData ¶
func (blockHeader *XLogRecordBlockHeader) HasData() bool
func (*XLogRecordBlockHeader) HasImage ¶
func (blockHeader *XLogRecordBlockHeader) HasImage() bool
func (*XLogRecordBlockHeader) HasSameRel ¶
func (blockHeader *XLogRecordBlockHeader) HasSameRel() bool
func (*XLogRecordBlockHeader) WillInit ¶
func (blockHeader *XLogRecordBlockHeader) WillInit() bool
type XLogRecordBlockImageHeader ¶
type XLogRecordBlockImageHeader struct {
ImageLength uint16
HoleOffset uint16
HoleLength uint16
Info uint8
}
func (*XLogRecordBlockImageHeader) ApplyImage ¶
func (imageHeader *XLogRecordBlockImageHeader) ApplyImage() bool
func (*XLogRecordBlockImageHeader) HasHole ¶
func (imageHeader *XLogRecordBlockImageHeader) HasHole() bool
func (*XLogRecordBlockImageHeader) IsCompressed ¶
func (imageHeader *XLogRecordBlockImageHeader) IsCompressed() bool
type XLogRecordHeader ¶
type XLogRecordHeader struct {
TotalRecordLength uint32
XactID uint32
PrevRecordPtr XLogRecordPtr
Info uint8
ResourceManagerID uint8
/* 2 bytes of padding here, initialize to zero */
Crc32Hash uint32
}
This struct corresponds to postgres struct XLogRecord. * For clarification you can find it in postgres: * src/include/access/xlogrecord.h
type XLogRecordPtr ¶
type XLogRecordPtr uint64
type ZeroPageError ¶
type ZeroPageError struct {
// contains filtered or unexported fields
}
func NewZeroPageError ¶
func NewZeroPageError() ZeroPageError
func (ZeroPageError) Error ¶
func (err ZeroPageError) Error() string
type ZeroPageHeaderError ¶
type ZeroPageHeaderError struct {
// contains filtered or unexported fields
}
func (ZeroPageHeaderError) Error ¶
func (err ZeroPageHeaderError) Error() string
type ZeroRecordHeaderError ¶
type ZeroRecordHeaderError struct {
// contains filtered or unexported fields
}
func NewZeroRecordHeaderError ¶
func NewZeroRecordHeaderError() ZeroRecordHeaderError
func (ZeroRecordHeaderError) Error ¶
func (err ZeroRecordHeaderError) Error() string
Source Files
¶
- aligned_reader.go
- block_location.go
- block_location_reader.go
- block_location_writer.go
- block_locations_util.go
- parsing_errors.go
- read_xlog_page.go
- read_xlog_record.go
- rel_file_node.go
- resource_manager_list.go
- shrinkable_reader.go
- util.go
- wal_file_page_reader.go
- wal_parser.go
- xlog_page.go
- xlog_page_header.go
- xlog_record.go
- xlog_record_block.go
- xlog_record_block_header.go
- xlog_record_block_image_header.go
- xlog_record_header.go