Header And Logo

PostgreSQL
| The world's most advanced open source database.

Data Structures | Defines | Typedefs | Functions

heapam_xlog.h File Reference

#include "access/htup.h"
#include "access/xlog.h"
#include "storage/bufpage.h"
#include "storage/relfilenode.h"
#include "utils/relcache.h"
Include dependency graph for heapam_xlog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  xl_heaptid
struct  xl_heap_delete
struct  xl_heap_header
struct  xl_heap_insert
struct  xl_heap_multi_insert
struct  xl_multi_insert_tuple
struct  xl_heap_update
struct  xl_heap_clean
struct  xl_heap_cleanup_info
struct  xl_heap_newpage
struct  xl_heap_lock
struct  xl_heap_lock_updated
struct  xl_heap_inplace
struct  xl_heap_freeze
struct  xl_heap_visible

Defines

#define XLOG_HEAP_INSERT   0x00
#define XLOG_HEAP_DELETE   0x10
#define XLOG_HEAP_UPDATE   0x20
#define XLOG_HEAP_HOT_UPDATE   0x40
#define XLOG_HEAP_NEWPAGE   0x50
#define XLOG_HEAP_LOCK   0x60
#define XLOG_HEAP_INPLACE   0x70
#define XLOG_HEAP_OPMASK   0x70
#define XLOG_HEAP_INIT_PAGE   0x80
#define XLOG_HEAP2_FREEZE   0x00
#define XLOG_HEAP2_CLEAN   0x10
#define XLOG_HEAP2_CLEANUP_INFO   0x30
#define XLOG_HEAP2_VISIBLE   0x40
#define XLOG_HEAP2_MULTI_INSERT   0x50
#define XLOG_HEAP2_LOCK_UPDATED   0x60
#define SizeOfHeapTid   (offsetof(xl_heaptid, tid) + SizeOfIptrData)
#define SizeOfHeapDelete   (offsetof(xl_heap_delete, all_visible_cleared) + sizeof(bool))
#define SizeOfHeapHeader   (offsetof(xl_heap_header, t_hoff) + sizeof(uint8))
#define SizeOfHeapInsert   (offsetof(xl_heap_insert, all_visible_cleared) + sizeof(bool))
#define SizeOfHeapMultiInsert   offsetof(xl_heap_multi_insert, offsets)
#define SizeOfMultiInsertTuple   (offsetof(xl_multi_insert_tuple, t_hoff) + sizeof(uint8))
#define SizeOfHeapUpdate   (offsetof(xl_heap_update, new_all_visible_cleared) + sizeof(bool))
#define SizeOfHeapClean   (offsetof(xl_heap_clean, ndead) + sizeof(uint16))
#define SizeOfHeapCleanupInfo   (sizeof(xl_heap_cleanup_info))
#define SizeOfHeapNewpage   (offsetof(xl_heap_newpage, blkno) + sizeof(BlockNumber))
#define XLHL_XMAX_IS_MULTI   0x01
#define XLHL_XMAX_LOCK_ONLY   0x02
#define XLHL_XMAX_EXCL_LOCK   0x04
#define XLHL_XMAX_KEYSHR_LOCK   0x08
#define XLHL_KEYS_UPDATED   0x10
#define SizeOfHeapLock   (offsetof(xl_heap_lock, infobits_set) + sizeof(int8))
#define SizeOfHeapLockUpdated   (offsetof(xl_heap_lock_updated, infobits_set) + sizeof(uint8))
#define SizeOfHeapInplace   (offsetof(xl_heap_inplace, target) + SizeOfHeapTid)
#define SizeOfHeapFreeze   (offsetof(xl_heap_freeze, cutoff_multi) + sizeof(MultiXactId))
#define SizeOfHeapVisible   (offsetof(xl_heap_visible, cutoff_xid) + sizeof(TransactionId))

Typedefs

typedef struct xl_heaptid xl_heaptid
typedef struct xl_heap_delete xl_heap_delete
typedef struct xl_heap_header xl_heap_header
typedef struct xl_heap_insert xl_heap_insert
typedef struct xl_heap_multi_insert xl_heap_multi_insert
typedef struct
xl_multi_insert_tuple 
xl_multi_insert_tuple
typedef struct xl_heap_update xl_heap_update
typedef struct xl_heap_clean xl_heap_clean
typedef struct xl_heap_cleanup_info xl_heap_cleanup_info
typedef struct xl_heap_newpage xl_heap_newpage
typedef struct xl_heap_lock xl_heap_lock
typedef struct xl_heap_lock_updated xl_heap_lock_updated
typedef struct xl_heap_inplace xl_heap_inplace
typedef struct xl_heap_freeze xl_heap_freeze
typedef struct xl_heap_visible xl_heap_visible

Functions

void HeapTupleHeaderAdvanceLatestRemovedXid (HeapTupleHeader tuple, TransactionId *latestRemovedXid)
void heap_redo (XLogRecPtr lsn, XLogRecord *rptr)
void heap_desc (StringInfo buf, uint8 xl_info, char *rec)
void heap2_redo (XLogRecPtr lsn, XLogRecord *rptr)
void heap2_desc (StringInfo buf, uint8 xl_info, char *rec)
XLogRecPtr log_heap_cleanup_info (RelFileNode rnode, TransactionId latestRemovedXid)
XLogRecPtr log_heap_clean (Relation reln, Buffer buffer, OffsetNumber *redirected, int nredirected, OffsetNumber *nowdead, int ndead, OffsetNumber *nowunused, int nunused, TransactionId latestRemovedXid)
XLogRecPtr log_heap_freeze (Relation reln, Buffer buffer, TransactionId cutoff_xid, MultiXactId cutoff_multi, OffsetNumber *offsets, int offcnt)
XLogRecPtr log_heap_visible (RelFileNode rnode, Buffer heap_buffer, Buffer vm_buffer, TransactionId cutoff_xid)
XLogRecPtr log_newpage (RelFileNode *rnode, ForkNumber forkNum, BlockNumber blk, Page page)
XLogRecPtr log_newpage_buffer (Buffer buffer)

Define Documentation

#define SizeOfHeapClean   (offsetof(xl_heap_clean, ndead) + sizeof(uint16))

Definition at line 179 of file heapam_xlog.h.

#define SizeOfHeapCleanupInfo   (sizeof(xl_heap_cleanup_info))

Definition at line 192 of file heapam_xlog.h.

#define SizeOfHeapDelete   (offsetof(xl_heap_delete, all_visible_cleared) + sizeof(bool))

Definition at line 84 of file heapam_xlog.h.

#define SizeOfHeapFreeze   (offsetof(xl_heap_freeze, cutoff_multi) + sizeof(MultiXactId))

Definition at line 252 of file heapam_xlog.h.

Referenced by heap_xlog_freeze().

#define SizeOfHeapHeader   (offsetof(xl_heap_header, t_hoff) + sizeof(uint8))

Definition at line 101 of file heapam_xlog.h.

#define SizeOfHeapInplace   (offsetof(xl_heap_inplace, target) + SizeOfHeapTid)

Definition at line 240 of file heapam_xlog.h.

Referenced by heap_xlog_inplace().

#define SizeOfHeapInsert   (offsetof(xl_heap_insert, all_visible_cleared) + sizeof(bool))

Definition at line 111 of file heapam_xlog.h.

Referenced by heap_xlog_insert().

#define SizeOfHeapLock   (offsetof(xl_heap_lock, infobits_set) + sizeof(int8))

Definition at line 221 of file heapam_xlog.h.

#define SizeOfHeapLockUpdated   (offsetof(xl_heap_lock_updated, infobits_set) + sizeof(uint8))

Definition at line 231 of file heapam_xlog.h.

#define SizeOfHeapMultiInsert   offsetof(xl_heap_multi_insert, offsets)

Definition at line 130 of file heapam_xlog.h.

#define SizeOfHeapNewpage   (offsetof(xl_heap_newpage, blkno) + sizeof(BlockNumber))

Definition at line 204 of file heapam_xlog.h.

Referenced by heap_xlog_newpage().

#define SizeOfHeapTid   (offsetof(xl_heaptid, tid) + SizeOfIptrData)

Definition at line 73 of file heapam_xlog.h.

#define SizeOfHeapUpdate   (offsetof(xl_heap_update, new_all_visible_cleared) + sizeof(bool))

Definition at line 156 of file heapam_xlog.h.

Referenced by heap_xlog_update().

#define SizeOfHeapVisible   (offsetof(xl_heap_visible, cutoff_xid) + sizeof(TransactionId))

Definition at line 262 of file heapam_xlog.h.

#define SizeOfMultiInsertTuple   (offsetof(xl_multi_insert_tuple, t_hoff) + sizeof(uint8))

Definition at line 141 of file heapam_xlog.h.

#define XLHL_KEYS_UPDATED   0x10

Definition at line 211 of file heapam_xlog.h.

Referenced by compute_infobits(), fix_infomask_from_infobits(), and out_infobits().

#define XLHL_XMAX_EXCL_LOCK   0x04

Definition at line 209 of file heapam_xlog.h.

Referenced by compute_infobits(), fix_infomask_from_infobits(), and out_infobits().

#define XLHL_XMAX_IS_MULTI   0x01

Definition at line 207 of file heapam_xlog.h.

Referenced by compute_infobits(), fix_infomask_from_infobits(), and out_infobits().

#define XLHL_XMAX_KEYSHR_LOCK   0x08

Definition at line 210 of file heapam_xlog.h.

Referenced by compute_infobits(), fix_infomask_from_infobits(), and out_infobits().

#define XLHL_XMAX_LOCK_ONLY   0x02

Definition at line 208 of file heapam_xlog.h.

Referenced by compute_infobits(), fix_infomask_from_infobits(), and out_infobits().

#define XLOG_HEAP2_CLEAN   0x10

Definition at line 52 of file heapam_xlog.h.

Referenced by heap2_desc(), and heap2_redo().

#define XLOG_HEAP2_CLEANUP_INFO   0x30

Definition at line 54 of file heapam_xlog.h.

Referenced by heap2_desc(), heap2_redo(), and log_heap_cleanup_info().

#define XLOG_HEAP2_FREEZE   0x00

Definition at line 51 of file heapam_xlog.h.

Referenced by heap2_desc(), heap2_redo(), and log_heap_freeze().

#define XLOG_HEAP2_LOCK_UPDATED   0x60

Definition at line 57 of file heapam_xlog.h.

Referenced by heap2_desc(), heap2_redo(), and heap_lock_updated_tuple_rec().

#define XLOG_HEAP2_MULTI_INSERT   0x50

Definition at line 56 of file heapam_xlog.h.

Referenced by heap2_desc(), and heap2_redo().

#define XLOG_HEAP2_VISIBLE   0x40

Definition at line 55 of file heapam_xlog.h.

Referenced by heap2_desc(), heap2_redo(), and log_heap_visible().

#define XLOG_HEAP_DELETE   0x10

Definition at line 31 of file heapam_xlog.h.

Referenced by heap_delete(), heap_desc(), and heap_redo().

#define XLOG_HEAP_HOT_UPDATE   0x40

Definition at line 34 of file heapam_xlog.h.

Referenced by heap_desc(), and heap_redo().

#define XLOG_HEAP_INIT_PAGE   0x80

Definition at line 44 of file heapam_xlog.h.

Referenced by heap2_desc(), heap_desc(), heap_xlog_insert(), and heap_xlog_update().

#define XLOG_HEAP_INPLACE   0x70

Definition at line 37 of file heapam_xlog.h.

Referenced by heap_desc(), heap_inplace_update(), and heap_redo().

#define XLOG_HEAP_INSERT   0x00

Definition at line 30 of file heapam_xlog.h.

Referenced by heap_desc(), and heap_redo().

#define XLOG_HEAP_LOCK   0x60

Definition at line 36 of file heapam_xlog.h.

Referenced by heap_desc(), heap_lock_tuple(), and heap_redo().

#define XLOG_HEAP_NEWPAGE   0x50

Definition at line 35 of file heapam_xlog.h.

Referenced by heap_desc(), heap_redo(), log_newpage(), and log_newpage_buffer().

#define XLOG_HEAP_OPMASK   0x70

Definition at line 39 of file heapam_xlog.h.

Referenced by heap2_redo(), and heap_redo().

#define XLOG_HEAP_UPDATE   0x20

Definition at line 32 of file heapam_xlog.h.

Referenced by heap_desc(), and heap_redo().


Typedef Documentation

typedef struct xl_heap_clean xl_heap_clean
typedef struct xl_heap_lock xl_heap_lock
typedef struct xl_heaptid xl_heaptid

Function Documentation

void heap2_desc ( StringInfo  buf,
uint8  xl_info,
char *  rec 
)

Definition at line 129 of file heapdesc.c.

References appendStringInfo(), xl_heap_multi_insert::blkno, xl_heap_visible::block, xl_heap_clean::block, xl_heap_freeze::block, xl_heap_freeze::cutoff_multi, xl_heap_freeze::cutoff_xid, RelFileNode::dbNode, xl_heap_lock_updated::infobits_set, xl_heap_cleanup_info::latestRemovedXid, xl_heap_clean::latestRemovedXid, xl_heap_multi_insert::node, xl_heap_visible::node, xl_heap_clean::node, xl_heap_freeze::node, xl_heap_multi_insert::ntuples, out_target(), RelFileNode::relNode, RelFileNode::spcNode, xl_heap_lock_updated::target, XLOG_HEAP2_CLEAN, XLOG_HEAP2_CLEANUP_INFO, XLOG_HEAP2_FREEZE, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_VISIBLE, XLOG_HEAP_INIT_PAGE, and xl_heap_lock_updated::xmax.

{
    uint8       info = xl_info & ~XLR_INFO_MASK;

    info &= XLOG_HEAP_OPMASK;
    if (info == XLOG_HEAP2_FREEZE)
    {
        xl_heap_freeze *xlrec = (xl_heap_freeze *) rec;

        appendStringInfo(buf, "freeze: rel %u/%u/%u; blk %u; cutoff xid %u multi %u",
                         xlrec->node.spcNode, xlrec->node.dbNode,
                         xlrec->node.relNode, xlrec->block,
                         xlrec->cutoff_xid, xlrec->cutoff_multi);
    }
    else if (info == XLOG_HEAP2_CLEAN)
    {
        xl_heap_clean *xlrec = (xl_heap_clean *) rec;

        appendStringInfo(buf, "clean: rel %u/%u/%u; blk %u remxid %u",
                         xlrec->node.spcNode, xlrec->node.dbNode,
                         xlrec->node.relNode, xlrec->block,
                         xlrec->latestRemovedXid);
    }
    else if (info == XLOG_HEAP2_CLEANUP_INFO)
    {
        xl_heap_cleanup_info *xlrec = (xl_heap_cleanup_info *) rec;

        appendStringInfo(buf, "cleanup info: remxid %u",
                         xlrec->latestRemovedXid);
    }
    else if (info == XLOG_HEAP2_VISIBLE)
    {
        xl_heap_visible *xlrec = (xl_heap_visible *) rec;

        appendStringInfo(buf, "visible: rel %u/%u/%u; blk %u",
                         xlrec->node.spcNode, xlrec->node.dbNode,
                         xlrec->node.relNode, xlrec->block);
    }
    else if (info == XLOG_HEAP2_MULTI_INSERT)
    {
        xl_heap_multi_insert *xlrec = (xl_heap_multi_insert *) rec;

        if (xl_info & XLOG_HEAP_INIT_PAGE)
            appendStringInfo(buf, "multi-insert (init): ");
        else
            appendStringInfo(buf, "multi-insert: ");
        appendStringInfo(buf, "rel %u/%u/%u; blk %u; %d tuples",
                xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode,
                         xlrec->blkno, xlrec->ntuples);
    }
    else if (info == XLOG_HEAP2_LOCK_UPDATED)
    {
        xl_heap_lock_updated *xlrec = (xl_heap_lock_updated *) rec;

        appendStringInfo(buf, "lock updated: xmax %u msk %04x; ", xlrec->xmax,
                         xlrec->infobits_set);
        out_target(buf, &(xlrec->target));
    }
    else
        appendStringInfo(buf, "UNKNOWN");
}

void heap2_redo ( XLogRecPtr  lsn,
XLogRecord rptr 
)
void heap_desc ( StringInfo  buf,
uint8  xl_info,
char *  rec 
)

Definition at line 44 of file heapdesc.c.

References appendStringInfo(), appendStringInfoChar(), xl_heap_newpage::blkno, RelFileNode::dbNode, xl_heap_newpage::forknum, xl_heap_lock::infobits_set, xl_heap_delete::infobits_set, ItemPointerGetBlockNumber, ItemPointerGetOffsetNumber, xl_heap_lock::locking_xid, xl_heap_update::new_xmax, xl_heap_update::newtid, xl_heap_newpage::node, xl_heap_update::old_infobits_set, xl_heap_update::old_xmax, out_infobits(), out_target(), RelFileNode::relNode, RelFileNode::spcNode, xl_heap_inplace::target, xl_heap_lock::target, xl_heap_update::target, xl_heap_delete::target, xl_heap_insert::target, XLOG_HEAP_DELETE, XLOG_HEAP_HOT_UPDATE, XLOG_HEAP_INIT_PAGE, XLOG_HEAP_INPLACE, XLOG_HEAP_INSERT, XLOG_HEAP_LOCK, XLOG_HEAP_NEWPAGE, and XLOG_HEAP_UPDATE.

{
    uint8       info = xl_info & ~XLR_INFO_MASK;

    info &= XLOG_HEAP_OPMASK;
    if (info == XLOG_HEAP_INSERT)
    {
        xl_heap_insert *xlrec = (xl_heap_insert *) rec;

        if (xl_info & XLOG_HEAP_INIT_PAGE)
            appendStringInfo(buf, "insert(init): ");
        else
            appendStringInfo(buf, "insert: ");
        out_target(buf, &(xlrec->target));
    }
    else if (info == XLOG_HEAP_DELETE)
    {
        xl_heap_delete *xlrec = (xl_heap_delete *) rec;

        appendStringInfo(buf, "delete: ");
        out_target(buf, &(xlrec->target));
        appendStringInfoChar(buf, ' ');
        out_infobits(buf, xlrec->infobits_set);
    }
    else if (info == XLOG_HEAP_UPDATE)
    {
        xl_heap_update *xlrec = (xl_heap_update *) rec;

        if (xl_info & XLOG_HEAP_INIT_PAGE)
            appendStringInfo(buf, "update(init): ");
        else
            appendStringInfo(buf, "update: ");
        out_target(buf, &(xlrec->target));
        appendStringInfo(buf, " xmax %u ", xlrec->old_xmax);
        out_infobits(buf, xlrec->old_infobits_set);
        appendStringInfo(buf, "; new tid %u/%u xmax %u",
                         ItemPointerGetBlockNumber(&(xlrec->newtid)),
                         ItemPointerGetOffsetNumber(&(xlrec->newtid)),
                         xlrec->new_xmax);
    }
    else if (info == XLOG_HEAP_HOT_UPDATE)
    {
        xl_heap_update *xlrec = (xl_heap_update *) rec;

        if (xl_info & XLOG_HEAP_INIT_PAGE)      /* can this case happen? */
            appendStringInfo(buf, "hot_update(init): ");
        else
            appendStringInfo(buf, "hot_update: ");
        out_target(buf, &(xlrec->target));
        appendStringInfo(buf, " xmax %u ", xlrec->old_xmax);
        out_infobits(buf, xlrec->old_infobits_set);
        appendStringInfo(buf, "; new tid %u/%u xmax %u",
                         ItemPointerGetBlockNumber(&(xlrec->newtid)),
                         ItemPointerGetOffsetNumber(&(xlrec->newtid)),
                         xlrec->new_xmax);
    }
    else if (info == XLOG_HEAP_NEWPAGE)
    {
        xl_heap_newpage *xlrec = (xl_heap_newpage *) rec;

        appendStringInfo(buf, "newpage: rel %u/%u/%u; fork %u, blk %u",
                         xlrec->node.spcNode, xlrec->node.dbNode,
                         xlrec->node.relNode, xlrec->forknum,
                         xlrec->blkno);
    }
    else if (info == XLOG_HEAP_LOCK)
    {
        xl_heap_lock *xlrec = (xl_heap_lock *) rec;

        appendStringInfo(buf, "lock %u: ", xlrec->locking_xid);
        out_target(buf, &(xlrec->target));
        appendStringInfoChar(buf, ' ');
        out_infobits(buf, xlrec->infobits_set);
    }
    else if (info == XLOG_HEAP_INPLACE)
    {
        xl_heap_inplace *xlrec = (xl_heap_inplace *) rec;

        appendStringInfo(buf, "inplace: ");
        out_target(buf, &(xlrec->target));
    }
    else
        appendStringInfo(buf, "UNKNOWN");
}

void heap_redo ( XLogRecPtr  lsn,
XLogRecord rptr 
)

Definition at line 7066 of file heapam.c.

References elog, heap_xlog_delete(), heap_xlog_inplace(), heap_xlog_insert(), heap_xlog_lock(), heap_xlog_newpage(), heap_xlog_update(), PANIC, XLogRecord::xl_info, XLOG_HEAP_DELETE, XLOG_HEAP_HOT_UPDATE, XLOG_HEAP_INPLACE, XLOG_HEAP_INSERT, XLOG_HEAP_LOCK, XLOG_HEAP_NEWPAGE, XLOG_HEAP_OPMASK, and XLOG_HEAP_UPDATE.

{
    uint8       info = record->xl_info & ~XLR_INFO_MASK;

    /*
     * These operations don't overwrite MVCC data so no conflict processing is
     * required. The ones in heap2 rmgr do.
     */

    switch (info & XLOG_HEAP_OPMASK)
    {
        case XLOG_HEAP_INSERT:
            heap_xlog_insert(lsn, record);
            break;
        case XLOG_HEAP_DELETE:
            heap_xlog_delete(lsn, record);
            break;
        case XLOG_HEAP_UPDATE:
            heap_xlog_update(lsn, record, false);
            break;
        case XLOG_HEAP_HOT_UPDATE:
            heap_xlog_update(lsn, record, true);
            break;
        case XLOG_HEAP_NEWPAGE:
            heap_xlog_newpage(lsn, record);
            break;
        case XLOG_HEAP_LOCK:
            heap_xlog_lock(lsn, record);
            break;
        case XLOG_HEAP_INPLACE:
            heap_xlog_inplace(lsn, record);
            break;
        default:
            elog(PANIC, "heap_redo: unknown op code %u", info);
    }
}

void HeapTupleHeaderAdvanceLatestRemovedXid ( HeapTupleHeader  tuple,
TransactionId latestRemovedXid 
)

Definition at line 5554 of file heapam.c.

References HEAP_MOVED, HEAP_XMIN_COMMITTED, HEAP_XMIN_INVALID, HeapTupleHeaderGetUpdateXid, HeapTupleHeaderGetXmin, HeapTupleHeaderGetXvac, HeapTupleHeaderData::t_infomask, TransactionIdDidCommit(), TransactionIdFollows(), and TransactionIdPrecedes().

Referenced by btree_xlog_delete_get_latestRemovedXid(), heap_prune_chain(), and lazy_scan_heap().

{
    TransactionId xmin = HeapTupleHeaderGetXmin(tuple);
    TransactionId xmax = HeapTupleHeaderGetUpdateXid(tuple);
    TransactionId xvac = HeapTupleHeaderGetXvac(tuple);

    if (tuple->t_infomask & HEAP_MOVED)
    {
        if (TransactionIdPrecedes(*latestRemovedXid, xvac))
            *latestRemovedXid = xvac;
    }

    /*
     * Ignore tuples inserted by an aborted transaction or if the tuple was
     * updated/deleted by the inserting transaction.
     *
     * Look for a committed hint bit, or if no xmin bit is set, check clog.
     * This needs to work on both master and standby, where it is used to
     * assess btree delete records.
     */
    if ((tuple->t_infomask & HEAP_XMIN_COMMITTED) ||
        (!(tuple->t_infomask & HEAP_XMIN_COMMITTED) &&
         !(tuple->t_infomask & HEAP_XMIN_INVALID) &&
         TransactionIdDidCommit(xmin)))
    {
        if (xmax != xmin &&
            TransactionIdFollows(xmax, *latestRemovedXid))
            *latestRemovedXid = xmax;
    }

    /* *latestRemovedXid may still be invalid at end */
}

XLogRecPtr log_heap_clean ( Relation  reln,
Buffer  buffer,
OffsetNumber redirected,
int  nredirected,
OffsetNumber nowdead,
int  ndead,
OffsetNumber nowunused,
int  nunused,
TransactionId  latestRemovedXid 
)

Definition at line 5627 of file heapam.c.

References Assert, xl_heap_clean::block, XLogRecData::buffer, XLogRecData::buffer_std, BufferGetBlockNumber(), XLogRecData::data, xl_heap_clean::latestRemovedXid, XLogRecData::len, xl_heap_clean::ndead, XLogRecData::next, xl_heap_clean::node, xl_heap_clean::nredirected, RelationData::rd_node, RelationNeedsWAL, and XLogInsert().

Referenced by heap_page_prune(), and lazy_vacuum_page().

{
    xl_heap_clean xlrec;
    uint8       info;
    XLogRecPtr  recptr;
    XLogRecData rdata[4];

    /* Caller should not call me on a non-WAL-logged relation */
    Assert(RelationNeedsWAL(reln));

    xlrec.node = reln->rd_node;
    xlrec.block = BufferGetBlockNumber(buffer);
    xlrec.latestRemovedXid = latestRemovedXid;
    xlrec.nredirected = nredirected;
    xlrec.ndead = ndead;

    rdata[0].data = (char *) &xlrec;
    rdata[0].len = SizeOfHeapClean;
    rdata[0].buffer = InvalidBuffer;
    rdata[0].next = &(rdata[1]);

    /*
     * The OffsetNumber arrays are not actually in the buffer, but we pretend
     * that they are.  When XLogInsert stores the whole buffer, the offset
     * arrays need not be stored too.  Note that even if all three arrays are
     * empty, we want to expose the buffer as a candidate for whole-page
     * storage, since this record type implies a defragmentation operation
     * even if no item pointers changed state.
     */
    if (nredirected > 0)
    {
        rdata[1].data = (char *) redirected;
        rdata[1].len = nredirected * sizeof(OffsetNumber) * 2;
    }
    else
    {
        rdata[1].data = NULL;
        rdata[1].len = 0;
    }
    rdata[1].buffer = buffer;
    rdata[1].buffer_std = true;
    rdata[1].next = &(rdata[2]);

    if (ndead > 0)
    {
        rdata[2].data = (char *) nowdead;
        rdata[2].len = ndead * sizeof(OffsetNumber);
    }
    else
    {
        rdata[2].data = NULL;
        rdata[2].len = 0;
    }
    rdata[2].buffer = buffer;
    rdata[2].buffer_std = true;
    rdata[2].next = &(rdata[3]);

    if (nunused > 0)
    {
        rdata[3].data = (char *) nowunused;
        rdata[3].len = nunused * sizeof(OffsetNumber);
    }
    else
    {
        rdata[3].data = NULL;
        rdata[3].len = 0;
    }
    rdata[3].buffer = buffer;
    rdata[3].buffer_std = true;
    rdata[3].next = NULL;

    info = XLOG_HEAP2_CLEAN;
    recptr = XLogInsert(RM_HEAP2_ID, info, rdata);

    return recptr;
}

XLogRecPtr log_heap_cleanup_info ( RelFileNode  rnode,
TransactionId  latestRemovedXid 
)

Definition at line 5595 of file heapam.c.

References XLogRecData::buffer, XLogRecData::data, xl_heap_cleanup_info::latestRemovedXid, XLogRecData::len, XLogRecData::next, xl_heap_cleanup_info::node, XLOG_HEAP2_CLEANUP_INFO, and XLogInsert().

Referenced by vacuum_log_cleanup_info().

{
    xl_heap_cleanup_info xlrec;
    XLogRecPtr  recptr;
    XLogRecData rdata;

    xlrec.node = rnode;
    xlrec.latestRemovedXid = latestRemovedXid;

    rdata.data = (char *) &xlrec;
    rdata.len = SizeOfHeapCleanupInfo;
    rdata.buffer = InvalidBuffer;
    rdata.next = NULL;

    recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_CLEANUP_INFO, &rdata);

    return recptr;
}

XLogRecPtr log_heap_freeze ( Relation  reln,
Buffer  buffer,
TransactionId  cutoff_xid,
MultiXactId  cutoff_multi,
OffsetNumber offsets,
int  offcnt 
)

Definition at line 5713 of file heapam.c.

References Assert, xl_heap_freeze::block, XLogRecData::buffer, XLogRecData::buffer_std, BufferGetBlockNumber(), xl_heap_freeze::cutoff_multi, xl_heap_freeze::cutoff_xid, XLogRecData::data, XLogRecData::len, XLogRecData::next, xl_heap_freeze::node, RelationData::rd_node, RelationNeedsWAL, XLOG_HEAP2_FREEZE, and XLogInsert().

Referenced by lazy_scan_heap().

{
    xl_heap_freeze xlrec;
    XLogRecPtr  recptr;
    XLogRecData rdata[2];

    /* Caller should not call me on a non-WAL-logged relation */
    Assert(RelationNeedsWAL(reln));
    /* nor when there are no tuples to freeze */
    Assert(offcnt > 0);

    xlrec.node = reln->rd_node;
    xlrec.block = BufferGetBlockNumber(buffer);
    xlrec.cutoff_xid = cutoff_xid;
    xlrec.cutoff_multi = cutoff_multi;

    rdata[0].data = (char *) &xlrec;
    rdata[0].len = SizeOfHeapFreeze;
    rdata[0].buffer = InvalidBuffer;
    rdata[0].next = &(rdata[1]);

    /*
     * The tuple-offsets array is not actually in the buffer, but pretend that
     * it is.  When XLogInsert stores the whole buffer, the offsets array need
     * not be stored too.
     */
    rdata[1].data = (char *) offsets;
    rdata[1].len = offcnt * sizeof(OffsetNumber);
    rdata[1].buffer = buffer;
    rdata[1].buffer_std = true;
    rdata[1].next = NULL;

    recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_FREEZE, rdata);

    return recptr;
}

XLogRecPtr log_heap_visible ( RelFileNode  rnode,
Buffer  heap_buffer,
Buffer  vm_buffer,
TransactionId  cutoff_xid 
)

Definition at line 5762 of file heapam.c.

References Assert, xl_heap_visible::block, XLogRecData::buffer, XLogRecData::buffer_std, BufferGetBlockNumber(), BufferIsValid, xl_heap_visible::cutoff_xid, XLogRecData::data, DataChecksumsEnabled(), XLogRecData::len, XLogRecData::next, xl_heap_visible::node, XLOG_HEAP2_VISIBLE, and XLogInsert().

Referenced by visibilitymap_set().

{
    xl_heap_visible xlrec;
    XLogRecPtr  recptr;
    XLogRecData rdata[3];

    Assert(BufferIsValid(heap_buffer));
    Assert(BufferIsValid(vm_buffer));

    xlrec.node = rnode;
    xlrec.block = BufferGetBlockNumber(heap_buffer);
    xlrec.cutoff_xid = cutoff_xid;

    rdata[0].data = (char *) &xlrec;
    rdata[0].len = SizeOfHeapVisible;
    rdata[0].buffer = InvalidBuffer;
    rdata[0].next = &(rdata[1]);

    rdata[1].data = NULL;
    rdata[1].len = 0;
    rdata[1].buffer = vm_buffer;
    rdata[1].buffer_std = false;
    rdata[1].next = NULL;

    if (DataChecksumsEnabled())
    {
        rdata[1].next = &(rdata[2]);

        rdata[2].data = NULL;
        rdata[2].len = 0;
        rdata[2].buffer = heap_buffer;
        rdata[2].buffer_std = true;
        rdata[2].next = NULL;
    }

    recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_VISIBLE, rdata);

    return recptr;
}

XLogRecPtr log_newpage ( RelFileNode rnode,
ForkNumber  forkNum,
BlockNumber  blk,
Page  page 
)

Definition at line 5894 of file heapam.c.

References xl_heap_newpage::blkno, XLogRecData::buffer, XLogRecData::data, END_CRIT_SECTION, xl_heap_newpage::forknum, XLogRecData::len, XLogRecData::next, xl_heap_newpage::node, PageIsNew, PageSetLSN, START_CRIT_SECTION, XLOG_HEAP_NEWPAGE, and XLogInsert().

Referenced by _bt_blwritepage(), btbuildempty(), copy_relation_data(), end_heap_rewrite(), raw_heap_insert(), SetMatViewToPopulated(), and spgbuildempty().

{
    xl_heap_newpage xlrec;
    XLogRecPtr  recptr;
    XLogRecData rdata[2];

    /* NO ELOG(ERROR) from here till newpage op is logged */
    START_CRIT_SECTION();

    xlrec.node = *rnode;
    xlrec.forknum = forkNum;
    xlrec.blkno = blkno;

    rdata[0].data = (char *) &xlrec;
    rdata[0].len = SizeOfHeapNewpage;
    rdata[0].buffer = InvalidBuffer;
    rdata[0].next = &(rdata[1]);

    rdata[1].data = (char *) page;
    rdata[1].len = BLCKSZ;
    rdata[1].buffer = InvalidBuffer;
    rdata[1].next = NULL;

    recptr = XLogInsert(RM_HEAP_ID, XLOG_HEAP_NEWPAGE, rdata);

    /*
     * The page may be uninitialized. If so, we can't set the LSN and TLI
     * because that would corrupt the page.
     */
    if (!PageIsNew(page))
    {
        PageSetLSN(page, recptr);
    }

    END_CRIT_SECTION();

    return recptr;
}

XLogRecPtr log_newpage_buffer ( Buffer  buffer  ) 

Definition at line 5944 of file heapam.c.

References Assert, xl_heap_newpage::blkno, XLogRecData::buffer, BufferGetPage, BufferGetTag(), CritSectionCount, XLogRecData::data, xl_heap_newpage::forknum, XLogRecData::len, XLogRecData::next, xl_heap_newpage::node, PageIsNew, PageSetLSN, XLOG_HEAP_NEWPAGE, and XLogInsert().

Referenced by ginbuildempty(), and gistbuildempty().

{
    xl_heap_newpage xlrec;
    XLogRecPtr  recptr;
    XLogRecData rdata[2];
    Page        page = BufferGetPage(buffer);

    /* We should be in a critical section. */
    Assert(CritSectionCount > 0);

    BufferGetTag(buffer, &xlrec.node, &xlrec.forknum, &xlrec.blkno);

    rdata[0].data = (char *) &xlrec;
    rdata[0].len = SizeOfHeapNewpage;
    rdata[0].buffer = InvalidBuffer;
    rdata[0].next = &(rdata[1]);

    rdata[1].data = page;
    rdata[1].len = BLCKSZ;
    rdata[1].buffer = InvalidBuffer;
    rdata[1].next = NULL;

    recptr = XLogInsert(RM_HEAP_ID, XLOG_HEAP_NEWPAGE, rdata);

    /*
     * The page may be uninitialized. If so, we can't set the LSN and TLI
     * because that would corrupt the page.
     */
    if (!PageIsNew(page))
    {
        PageSetLSN(page, recptr);
    }

    return recptr;
}