Documentation ¶
Index ¶
- Constants
- type Cursor
- type DeleteData
- func (d DeleteData) DatabaseID() uint32
- func (d DeleteData) FromBlock() uint32
- func (d DeleteData) FromOffset() uint16
- func (d DeleteData) RelationID() uint32
- func (d DeleteData) String() string
- func (d DeleteData) TablespaceID() uint32
- func (d DeleteData) ToBlock() uint32
- func (d DeleteData) ToOffset() uint16
- type Entry
- type HeapData
- type InsertData
- func (d InsertData) DatabaseID() uint32
- func (d InsertData) FromBlock() uint32
- func (d InsertData) FromOffset() uint16
- func (d InsertData) RelationID() uint32
- func (d InsertData) String() string
- func (d InsertData) TablespaceID() uint32
- func (d InsertData) ToBlock() uint32
- func (d InsertData) ToOffset() uint16
- type Location
- func (l Location) Add(amount uint64) Location
- func (l Location) Aligned() Location
- func (l Location) Difference(other Location) uint64
- func (l Location) Filename() string
- func (l Location) FromStartOfFile() uint64
- func (l Location) FromStartOfPage() uint64
- func (l Location) IsOnSamePageAs(other Location) bool
- func (l Location) LogID() uint32
- func (l Location) Offset() uint64
- func (l Location) RecordOffset() uint32
- func (l Location) SegmentID() uint32
- func (l Location) StartOfFile() Location
- func (l Location) StartOfNextFile() Location
- func (l Location) StartOfNextPage() Location
- func (l Location) StartOfPage() Location
- func (l Location) StartOfPreviousFile() Location
- func (l Location) StartOfPreviousPage() Location
- func (l Location) String() string
- func (l Location) Subtract(amount uint64) Location
- func (l Location) ToEndOfFile() uint64
- func (l Location) ToEndOfPage() uint64
- type MultiInsertData
- func (d MultiInsertData) DatabaseID() uint32
- func (d MultiInsertData) FromBlock() uint32
- func (d MultiInsertData) FromOffset() uint16
- func (d MultiInsertData) RelationID() uint32
- func (d MultiInsertData) String() string
- func (d MultiInsertData) TablespaceID() uint32
- func (d MultiInsertData) ToBlock() uint32
- func (d MultiInsertData) ToOffset() uint16
- type Page
- func (p Page) BlockSize() uint32
- func (p Page) Continuation() []byte
- func (p Page) HeaderLength() uint64
- func (p Page) Info() uint16
- func (p Page) Is91() bool
- func (p Page) Is94() bool
- func (p Page) IsCont() bool
- func (p Page) IsLong() bool
- func (p Page) Location() Location
- func (p Page) Magic() uint16
- func (p Page) MagicValueIsValid() bool
- func (p Page) SegmentSize() uint32
- func (p Page) SystemID() uint64
- func (p Page) TimelineID() uint32
- type RecordBody
- type RecordHeader
- func (r RecordHeader) AlignedSize() uint64
- func (r RecordHeader) Crc() uint32
- func (r RecordHeader) Info() uint8
- func (r RecordHeader) IsInit() bool
- func (r RecordHeader) Length() uint32
- func (r RecordHeader) Previous() Location
- func (r RecordHeader) ResourceManagerID() uint8
- func (r RecordHeader) Size() uint64
- func (r RecordHeader) TotalLength() uint32
- func (r RecordHeader) TransactionID() uint32
- func (r RecordHeader) Type() RecordType
- type RecordType
- type UpdateData
- func (d UpdateData) DatabaseID() uint32
- func (d UpdateData) FromBlock() uint32
- func (d UpdateData) FromOffset() uint16
- func (d UpdateData) RelationID() uint32
- func (d UpdateData) String() string
- func (d UpdateData) TablespaceID() uint32
- func (d UpdateData) ToBlock() uint32
- func (d UpdateData) ToOffset() uint16
Constants ¶
const ( Unknown = iota // Unknown describes an entry in the WAL that is not interesting to us Insert // Insert describes a tuple being inserted into a heap Update // Update describes a tuple (either regular or heap-only) being updated in the heap Delete // Delete describes a tuple being deleted from the heap Commit // Commit describes a transaction being committed (either normally or compact) Abort // Abort describes a transaction being aborted MultiInsert // MultiInsert describes a block of tuples being inserted into a heap )
These constants describe the type of heap tuple found in the WAL
const EntryBytesSize = 61
EntryBytesSize is the size of the entries.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor models a position in the WAL of a PostgreSQL system
func NewCursorAtCheckpoint ¶
NewCursorAtCheckpoint creates a new cursor pointing at the current checkpoint
func NewCursorAtPrevCheckpoint ¶
NewCursorAtPrevCheckpoint creates a new cursor pointing at the current checkpoint
func (Cursor) MoveTo ¶
MoveTo sets the cursor to point at the specified location in the WAL even if its invalid
func (Cursor) ReadEntries ¶
ReadEntries will read the XLogRecord at the current location and if successful return the entries and a new cursor at the next location
type DeleteData ¶
type DeleteData []byte
DeleteData reads heap data as a delete
func (DeleteData) DatabaseID ¶
func (d DeleteData) DatabaseID() uint32
DatabaseID is the id of the database this tuple is found in
func (DeleteData) FromBlock ¶
func (d DeleteData) FromBlock() uint32
FromBlock is the page number where this tuple previously resided
func (DeleteData) FromOffset ¶
func (d DeleteData) FromOffset() uint16
FromOffset is the item number where this tuple previously resided
func (DeleteData) RelationID ¶
func (d DeleteData) RelationID() uint32
RelationID is the id of the relation this tuple is found in
func (DeleteData) String ¶
func (d DeleteData) String() string
func (DeleteData) TablespaceID ¶
func (d DeleteData) TablespaceID() uint32
TablespaceID is the id of the tablespace this tuple is found in
func (DeleteData) ToBlock ¶
func (d DeleteData) ToBlock() uint32
ToBlock is not available for deletes
func (DeleteData) ToOffset ¶
func (d DeleteData) ToOffset() uint16
ToOffset is not available for deletes
type Entry ¶
type Entry struct { Type RecordType ReadFrom Location Previous Location TimelineID uint32 LogID uint32 TransactionID uint32 TablespaceID uint32 DatabaseID uint32 RelationID uint32 FromBlock uint32 FromOffset uint16 ToBlock uint32 ToOffset uint16 ParseTime int64 }
Entry contains the data extracted from insert/update/delete/commit records
func EntryFromBytes ¶
EntryFromBytes reconstructs an entry from a slice of bytes
func NewEntries ¶
func NewEntries(page *Page, recordHeader *RecordHeader, recordBody *RecordBody) (entries []Entry)
NewEntries builds an entry from a page, record header, record body and a location
type HeapData ¶
type HeapData interface { TablespaceID() uint32 DatabaseID() uint32 RelationID() uint32 FromBlock() uint32 FromOffset() uint16 ToBlock() uint32 ToOffset() uint16 fmt.Stringer }
HeapData describes heap resource manager specific details from a record
func NewHeapData ¶
func NewHeapData(recordType RecordType, isInit bool, data []byte, version uint16) []HeapData
NewHeapData will interpret the heap data based on record type
type InsertData ¶
type InsertData []byte
InsertData reads heap data as an insert
func (InsertData) DatabaseID ¶
func (d InsertData) DatabaseID() uint32
DatabaseID is the id of the database this tuple is found in
func (InsertData) FromBlock ¶
func (d InsertData) FromBlock() uint32
FromBlock is not available for inserts
func (InsertData) FromOffset ¶
func (d InsertData) FromOffset() uint16
FromOffset is not available for inserts
func (InsertData) RelationID ¶
func (d InsertData) RelationID() uint32
RelationID is the id of the relation this tuple is found in
func (InsertData) String ¶
func (d InsertData) String() string
func (InsertData) TablespaceID ¶
func (d InsertData) TablespaceID() uint32
TablespaceID is the id of the tablespace this tuple is found in
func (InsertData) ToBlock ¶
func (d InsertData) ToBlock() uint32
ToBlock is the page number where this tuple now resides
func (InsertData) ToOffset ¶
func (d InsertData) ToOffset() uint16
ToOffset is the item number where this tuple now resides
type Location ¶
type Location struct {
// contains filtered or unexported fields
}
Location models a 64 bit address in the WAL
func LocationFromUint32s ¶
LocationFromUint32s constructs a location from two parts
func NewLocation ¶
NewLocation constructs a new location from an offset
func NewLocationWithDefaults ¶
NewLocationWithDefaults constructs a new location from an offset with common defaults
func (Location) Difference ¶
Difference calculates how much larger this offset is than another
func (Location) FromStartOfFile ¶
FromStartOfFile calculates the number of bytes from the start of the file to the location
func (Location) FromStartOfPage ¶
FromStartOfPage calculates the number of bytes from the start of the page to the location
func (Location) IsOnSamePageAs ¶
IsOnSamePageAs determines if a location is on the same page as this one
func (Location) RecordOffset ¶
RecordOffset is the lower 32 bits of the location
func (Location) StartOfFile ¶
StartOfFile calculates the location of the first byte in the file this location is in
func (Location) StartOfNextFile ¶
StartOfNextFile calculates the location of the first byte in the next file after the one this location is in
func (Location) StartOfNextPage ¶
StartOfNextPage calculates the location of the first byte in the next page after the one this location is in
func (Location) StartOfPage ¶
StartOfPage calculates the location of the first byte in the page this location is in
func (Location) StartOfPreviousFile ¶
StartOfPreviousFile calculates the location of the first byte in the prevous file before the one this location is in
func (Location) StartOfPreviousPage ¶
StartOfPreviousPage calculates the location of the first byte in the previous page before the one this location is in
func (Location) ToEndOfFile ¶
ToEndOfFile calculates the number of bytes from the location to the end of the file
func (Location) ToEndOfPage ¶
ToEndOfPage calculates the number of bytes from the location to the end of the page
type MultiInsertData ¶
type MultiInsertData struct {
// contains filtered or unexported fields
}
MultiInsertData reads heap data as an insert
func (MultiInsertData) DatabaseID ¶
func (d MultiInsertData) DatabaseID() uint32
DatabaseID is the id of the database this tuple is found in
func (MultiInsertData) FromBlock ¶
func (d MultiInsertData) FromBlock() uint32
FromBlock is not available for inserts
func (MultiInsertData) FromOffset ¶
func (d MultiInsertData) FromOffset() uint16
FromOffset is not available for inserts
func (MultiInsertData) RelationID ¶
func (d MultiInsertData) RelationID() uint32
RelationID is the id of the relation this tuple is found in
func (MultiInsertData) String ¶
func (d MultiInsertData) String() string
func (MultiInsertData) TablespaceID ¶
func (d MultiInsertData) TablespaceID() uint32
TablespaceID is the id of the tablespace this tuple is found in
func (MultiInsertData) ToBlock ¶
func (d MultiInsertData) ToBlock() uint32
ToBlock is the page number where this tuple now resides
func (MultiInsertData) ToOffset ¶
func (d MultiInsertData) ToOffset() uint16
ToOffset is the item number where this tuple now resides
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Page contains methods for reading values from a WAL page header and for detecting/reading a continuation
func (Page) Continuation ¶
Continuation will return the bytes of a continuation of the previous record's body if present on the page
func (Page) HeaderLength ¶
HeaderLength returns the size in bytes of the portion of the page used for its header
func (Page) Info ¶
Info can be used to determine if a page header is long (bit 2 is set) or if it contains a continuation (bit 1 is set)
func (Page) IsLong ¶
IsLong checks if the page has extra fields which is typical in the beginning of a file
func (Page) MagicValueIsValid ¶
MagicValueIsValid indicates if a Page is correct or not
func (Page) SegmentSize ¶
SegmentSize is the size in bytes of a single WAL file
func (Page) SystemID ¶
SystemID can be used to determine if a page was written by a particular server
func (Page) TimelineID ¶
TimelineID is the timeline this page is found on
type RecordBody ¶
type RecordBody struct {
// contains filtered or unexported fields
}
RecordBody collects the bytes that make up the body of a record
func NewRecordBody ¶
func NewRecordBody(recordHeader *RecordHeader) *RecordBody
NewRecordBody creates a new RecordBody based on a RecordHeader
func (*RecordBody) AppendBodyAfterHeader ¶
func (r *RecordBody) AppendBodyAfterHeader(block []byte, location Location) uint64
AppendBodyAfterHeader reads what is available of the body on the same page and appends it to the body
func (*RecordBody) AppendContinuation ¶
func (r *RecordBody) AppendContinuation(page Page) uint64
AppendContinuation reads a continuation from a page and appends it to the body
func (*RecordBody) HeapData ¶
func (r *RecordBody) HeapData() []HeapData
HeapData interprets the body based on the type indicated in the record header
func (*RecordBody) IsComplete ¶
func (r *RecordBody) IsComplete() bool
IsComplete indicates that needs to be read of a body has been read
type RecordHeader ¶
type RecordHeader struct {
// contains filtered or unexported fields
}
RecordHeader contains methods to read fields of an xlog record header
func NewRecordHeader ¶
func NewRecordHeader(block []byte, location Location, version uint16, reader blockReader) *RecordHeader
NewRecordHeader creates a new RecordHeader from a block and a location
func (RecordHeader) AlignedSize ¶
func (r RecordHeader) AlignedSize() uint64
AlignedSize will return the size of the header plus alignment
func (RecordHeader) Info ¶
func (r RecordHeader) Info() uint8
Info contains resource manager specific data
func (RecordHeader) IsInit ¶
func (r RecordHeader) IsInit() bool
IsInit indicates if this record initializes a page
func (RecordHeader) Length ¶
func (r RecordHeader) Length() uint32
Length is the length of resource manager specific data after the header
func (RecordHeader) Previous ¶
func (r RecordHeader) Previous() Location
Previous is the location of the record that preceeds this one
func (RecordHeader) ResourceManagerID ¶
func (r RecordHeader) ResourceManagerID() uint8
ResourceManagerID is the ID of the resource manager that created this record
func (RecordHeader) Size ¶
func (r RecordHeader) Size() uint64
Size will return the size of the header
func (RecordHeader) TotalLength ¶
func (r RecordHeader) TotalLength() uint32
TotalLength is the length of the body after the header but before the next record
func (RecordHeader) TransactionID ¶
func (r RecordHeader) TransactionID() uint32
TransactionID is the transaction that this record is apart of
func (RecordHeader) Type ¶
func (r RecordHeader) Type() RecordType
Type indicates how the resource data should be interpreted
type RecordType ¶
type RecordType uint8
RecordType is a constant representing how an xlog record should be interpreted
type UpdateData ¶
type UpdateData struct {
// contains filtered or unexported fields
}
UpdateData reads heap data as an update
func (UpdateData) DatabaseID ¶
func (d UpdateData) DatabaseID() uint32
DatabaseID is the id of the database this tuple is found in
func (UpdateData) FromBlock ¶
func (d UpdateData) FromBlock() uint32
FromBlock is the page number of the old version of this tuple
func (UpdateData) FromOffset ¶
func (d UpdateData) FromOffset() uint16
FromOffset is the item number of the old version of this tuple
func (UpdateData) RelationID ¶
func (d UpdateData) RelationID() uint32
RelationID is the id of the relation this tuple is found in
func (UpdateData) String ¶
func (d UpdateData) String() string
func (UpdateData) TablespaceID ¶
func (d UpdateData) TablespaceID() uint32
TablespaceID is the id of the tablespace this tuple is found in
func (UpdateData) ToBlock ¶
func (d UpdateData) ToBlock() uint32
ToBlock is the page number of the new version of this tuple
func (UpdateData) ToOffset ¶
func (d UpdateData) ToOffset() uint16
ToOffset is item number of the new version of this tuple