PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <unistd.h>
#include "access/heapam.h"
#include "access/heapam_xlog.h"
#include "access/heaptoast.h"
#include "access/rewriteheap.h"
#include "access/transam.h"
#include "access/xact.h"
#include "access/xloginsert.h"
#include "common/file_utils.h"
#include "lib/ilist.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "replication/slot.h"
#include "storage/bufmgr.h"
#include "storage/bulk_write.h"
#include "storage/fd.h"
#include "storage/procarray.h"
#include "utils/memutils.h"
#include "utils/rel.h"
Go to the source code of this file.
Data Structures | |
struct | RewriteStateData |
struct | TidHashKey |
struct | UnresolvedTupData |
struct | OldToNewMappingData |
struct | RewriteMappingFile |
struct | RewriteMappingDataEntry |
Typedefs | |
typedef struct RewriteStateData | RewriteStateData |
typedef UnresolvedTupData * | UnresolvedTup |
typedef OldToNewMappingData * | OldToNewMapping |
typedef struct RewriteMappingFile | RewriteMappingFile |
typedef struct RewriteMappingDataEntry | RewriteMappingDataEntry |
Functions | |
static void | raw_heap_insert (RewriteState state, HeapTuple tup) |
static void | logical_begin_heap_rewrite (RewriteState state) |
static void | logical_rewrite_heap_tuple (RewriteState state, ItemPointerData old_tid, HeapTuple new_tuple) |
static void | logical_end_heap_rewrite (RewriteState state) |
RewriteState | begin_heap_rewrite (Relation old_heap, Relation new_heap, TransactionId oldest_xmin, TransactionId freeze_xid, MultiXactId cutoff_multi) |
void | end_heap_rewrite (RewriteState state) |
void | rewrite_heap_tuple (RewriteState state, HeapTuple old_tuple, HeapTuple new_tuple) |
bool | rewrite_heap_dead_tuple (RewriteState state, HeapTuple old_tuple) |
static void | logical_heap_rewrite_flush_mappings (RewriteState state) |
static void | logical_rewrite_log_mapping (RewriteState state, TransactionId xid, LogicalRewriteMappingData *map) |
void | heap_xlog_logical_rewrite (XLogReaderState *r) |
void | CheckPointLogicalRewriteHeap (void) |
typedef OldToNewMappingData* OldToNewMapping |
Definition at line 185 of file rewriteheap.c.
typedef struct RewriteMappingDataEntry RewriteMappingDataEntry |
typedef struct RewriteMappingFile RewriteMappingFile |
typedef struct RewriteStateData RewriteStateData |
typedef UnresolvedTupData* UnresolvedTup |
Definition at line 177 of file rewriteheap.c.
RewriteState begin_heap_rewrite | ( | Relation | old_heap, |
Relation | new_heap, | ||
TransactionId | oldest_xmin, | ||
TransactionId | freeze_xid, | ||
MultiXactId | cutoff_multi | ||
) |
Definition at line 234 of file rewriteheap.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, CurrentMemoryContext, HASHCTL::entrysize, HASH_BLOBS, HASH_CONTEXT, hash_create(), HASH_ELEM, HASHCTL::hcxt, HASHCTL::keysize, logical_begin_heap_rewrite(), MAIN_FORKNUM, MemoryContextSwitchTo(), palloc0(), RelationGetNumberOfBlocks, and smgr_bulk_start_rel().
Referenced by heapam_relation_copy_for_cluster().
void CheckPointLogicalRewriteHeap | ( | void | ) |
Definition at line 1155 of file rewriteheap.c.
References AllocateDir(), CloseTransientFile(), dirent::d_name, data_sync_elevel(), DEBUG1, elog, ereport, errcode_for_file_access(), errmsg(), ERROR, fd(), FreeDir(), fsync_fname(), get_dirent_type(), GetRedoRecPtr(), InvalidXLogRecPtr, LOGICAL_REWRITE_FORMAT, MAXPGPATH, OpenTransientFile(), PG_BINARY, pg_fsync(), PG_LOGICAL_MAPPINGS_DIR, PGFILETYPE_ERROR, PGFILETYPE_REG, pgstat_report_wait_end(), pgstat_report_wait_start(), ReadDir(), ReplicationSlotsComputeLogicalRestartLSN(), and snprintf.
Referenced by CheckPointGuts().
void end_heap_rewrite | ( | RewriteState | state | ) |
Definition at line 297 of file rewriteheap.c.
References hash_seq_init(), hash_seq_search(), ItemPointerSetInvalid(), logical_end_heap_rewrite(), MemoryContextDelete(), raw_heap_insert(), smgr_bulk_finish(), smgr_bulk_write(), HeapTupleHeaderData::t_ctid, HeapTupleData::t_data, and UnresolvedTupData::tuple.
Referenced by heapam_relation_copy_for_cluster().
void heap_xlog_logical_rewrite | ( | XLogReaderState * | r | ) |
Definition at line 1073 of file rewriteheap.c.
References CloseTransientFile(), data, data_sync_elevel(), ereport, errcode_for_file_access(), errmsg(), ERROR, fd(), ftruncate, len, LOGICAL_REWRITE_FORMAT, LSN_FORMAT_ARGS, xl_heap_rewrite_mapping::mapped_db, xl_heap_rewrite_mapping::mapped_rel, xl_heap_rewrite_mapping::mapped_xid, MAXPGPATH, xl_heap_rewrite_mapping::num_mappings, xl_heap_rewrite_mapping::offset, OpenTransientFile(), PG_BINARY, pg_fsync(), PG_LOGICAL_MAPPINGS_DIR, pg_pwrite, pgstat_report_wait_end(), pgstat_report_wait_start(), snprintf, xl_heap_rewrite_mapping::start_lsn, XLogRecGetData, and XLogRecGetXid.
Referenced by heap2_redo().
|
static |
Definition at line 759 of file rewriteheap.c.
References HASHCTL::entrysize, GetXLogInsertRecPtr(), HASH_BLOBS, HASH_CONTEXT, hash_create(), HASH_ELEM, HASHCTL::hcxt, InvalidTransactionId, HASHCTL::keysize, ProcArrayGetReplicationSlotXmin(), and RelationIsAccessibleInLogicalDecoding.
Referenced by begin_heap_rewrite().
|
static |
Definition at line 905 of file rewriteheap.c.
References data_sync_elevel(), ereport, errcode_for_file_access(), errmsg(), ERROR, FileClose(), FileSync(), hash_seq_init(), hash_seq_search(), logical_heap_rewrite_flush_mappings(), RewriteMappingFile::path, and RewriteMappingFile::vfd.
Referenced by end_heap_rewrite().
|
static |
Definition at line 807 of file rewriteheap.c.
References Assert, dlist_mutable_iter::cur, dclist_container, dclist_count(), dclist_delete_from(), dclist_foreach_modify, DEBUG1, elog, ereport, errcode_for_file_access(), errmsg(), ERROR, FileWrite(), hash_seq_init(), hash_seq_search(), InvalidOid, len, RewriteMappingDataEntry::map, xl_heap_rewrite_mapping::mapped_db, xl_heap_rewrite_mapping::mapped_rel, xl_heap_rewrite_mapping::mapped_xid, RewriteMappingFile::mappings, MyDatabaseId, RewriteMappingDataEntry::node, xl_heap_rewrite_mapping::num_mappings, RewriteMappingFile::off, xl_heap_rewrite_mapping::offset, palloc(), RewriteMappingFile::path, pfree(), RelationGetRelid, xl_heap_rewrite_mapping::start_lsn, RewriteMappingFile::vfd, RewriteMappingFile::xid, XLOG_HEAP2_REWRITE, XLogBeginInsert(), XLogInsert(), and XLogRegisterData().
Referenced by logical_end_heap_rewrite(), and logical_rewrite_log_mapping().
|
static |
Definition at line 999 of file rewriteheap.c.
References HEAP_XMAX_IS_LOCKED_ONLY, HeapTupleHeaderGetUpdateXid, HeapTupleHeaderGetXmin, logical_rewrite_log_mapping(), LogicalRewriteMappingData::new_locator, LogicalRewriteMappingData::new_tid, LogicalRewriteMappingData::old_locator, LogicalRewriteMappingData::old_tid, HeapTupleData::t_data, HeapTupleHeaderData::t_infomask, HeapTupleData::t_self, TransactionIdEquals, TransactionIdIsNormal, and TransactionIdPrecedes().
Referenced by rewrite_heap_tuple().
|
static |
Definition at line 935 of file rewriteheap.c.
References dclist_init(), dclist_push_tail(), ereport, errcode_for_file_access(), errmsg(), ERROR, GetCurrentTransactionId(), HASH_ENTER, hash_search(), InvalidOid, logical_heap_rewrite_flush_mappings(), LOGICAL_REWRITE_FORMAT, LSN_FORMAT_ARGS, RewriteMappingDataEntry::map, RewriteMappingFile::mappings, MAXPGPATH, MemoryContextAlloc(), MyDatabaseId, RewriteMappingDataEntry::node, RewriteMappingFile::off, RewriteMappingFile::path, PathNameOpenFile(), PG_BINARY, PG_LOGICAL_MAPPINGS_DIR, RelationGetRelid, snprintf, and RewriteMappingFile::vfd.
Referenced by logical_rewrite_heap_tuple().
|
static |
Definition at line 593 of file rewriteheap.c.
References Assert, elog, ereport, errcode(), errmsg(), ERROR, HEAP_DEFAULT_FILLFACTOR, heap_freetuple(), HEAP_INSERT_NO_LOGICAL, HEAP_INSERT_SKIP_FSM, heap_toast_insert_or_update(), HeapTupleHasExternal, if(), InvalidOffsetNumber, ItemPointerIsValid(), ItemPointerSet(), len, MAXALIGN, MaxHeapTupleSize, PageAddItem, PageGetHeapFreeSpace(), PageGetItem(), PageGetItemId(), PageInit(), RelationGetTargetPageFreeSpace, smgr_bulk_get_buf(), smgr_bulk_write(), HeapTupleHeaderData::t_ctid, HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, and TOAST_TUPLE_THRESHOLD.
Referenced by end_heap_rewrite(), and rewrite_heap_tuple().
bool rewrite_heap_dead_tuple | ( | RewriteState | state, |
HeapTuple | old_tuple | ||
) |
Definition at line 543 of file rewriteheap.c.
References Assert, HASH_FIND, HASH_REMOVE, hash_search(), heap_freetuple(), HeapTupleHeaderGetXmin, HeapTupleData::t_data, HeapTupleData::t_self, TidHashKey::tid, UnresolvedTupData::tuple, and TidHashKey::xmin.
Referenced by heapam_relation_copy_for_cluster().
void rewrite_heap_tuple | ( | RewriteState | state, |
HeapTuple | old_tuple, | ||
HeapTuple | new_tuple | ||
) |
Definition at line 341 of file rewriteheap.c.
References Assert, HASH_ENTER, HASH_FIND, HASH_REMOVE, hash_search(), HEAP2_XACT_MASK, heap_copytuple(), heap_freetuple(), heap_freeze_tuple(), HEAP_UPDATED, HEAP_XACT_MASK, HEAP_XMAX_INVALID, HeapTupleHeaderGetUpdateXid, HeapTupleHeaderGetXmin, HeapTupleHeaderIndicatesMovedPartitions, HeapTupleHeaderIsOnlyLocked(), ItemPointerEquals(), ItemPointerSetInvalid(), logical_rewrite_heap_tuple(), MemoryContextSwitchTo(), OldToNewMappingData::new_tid, UnresolvedTupData::old_tid, raw_heap_insert(), HeapTupleHeaderData::t_choice, HeapTupleHeaderData::t_ctid, HeapTupleData::t_data, HeapTupleHeaderData::t_heap, HeapTupleHeaderData::t_infomask, HeapTupleHeaderData::t_infomask2, HeapTupleData::t_self, TidHashKey::tid, TransactionIdPrecedes(), UnresolvedTupData::tuple, and TidHashKey::xmin.
Referenced by reform_and_rewrite_tuple().