|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "common/blkreftable.h"#include "common/hashfn.h"#include "port/pg_crc32c.h"#include "lib/simplehash.h"
Go to the source code of this file.
Data Structures | |
| struct | BlockRefTableKey |
| struct | BlockRefTableEntry |
| struct | BlockRefTable |
| struct | BlockRefTableSerializedEntry |
| struct | BlockRefTableBuffer |
| struct | BlockRefTableReader |
| struct | BlockRefTableWriter |
Macros | |
| #define | BLOCKS_PER_CHUNK (1 << 16) |
| #define | BLOCKS_PER_ENTRY (BITS_PER_BYTE * sizeof(uint16)) |
| #define | MAX_ENTRIES_PER_CHUNK (BLOCKS_PER_CHUNK / BLOCKS_PER_ENTRY) |
| #define | INITIAL_ENTRIES_PER_CHUNK 16 |
| #define | SH_PREFIX blockreftable |
| #define | SH_ELEMENT_TYPE BlockRefTableEntry |
| #define | SH_KEY_TYPE BlockRefTableKey |
| #define | SH_KEY key |
| #define | SH_HASH_KEY(tb, key) hash_bytes((const unsigned char *) &key, sizeof(BlockRefTableKey)) |
| #define | SH_EQUAL(tb, a, b) (memcmp(&a, &b, sizeof(BlockRefTableKey)) == 0) |
| #define | SH_SCOPE static inline |
| #define | SH_DEFINE |
| #define | SH_DECLARE |
| #define | BUFSIZE 65536 |
Typedefs | |
| typedef struct BlockRefTableKey | BlockRefTableKey |
| typedef uint16 * | BlockRefTableChunk |
| typedef struct BlockRefTableSerializedEntry | BlockRefTableSerializedEntry |
| typedef struct BlockRefTableBuffer | BlockRefTableBuffer |
| #define BLOCKS_PER_CHUNK (1 << 16) |
Definition at line 78 of file blkreftable.c.
| #define BLOCKS_PER_ENTRY (BITS_PER_BYTE * sizeof(uint16)) |
Definition at line 79 of file blkreftable.c.
| #define BUFSIZE 65536 |
Definition at line 166 of file blkreftable.c.
| #define INITIAL_ENTRIES_PER_CHUNK 16 |
Definition at line 81 of file blkreftable.c.
| #define MAX_ENTRIES_PER_CHUNK (BLOCKS_PER_CHUNK / BLOCKS_PER_ENTRY) |
Definition at line 80 of file blkreftable.c.
| #define SH_DECLARE |
Definition at line 134 of file blkreftable.c.
| #define SH_DEFINE |
Definition at line 133 of file blkreftable.c.
| #define SH_ELEMENT_TYPE BlockRefTableEntry |
Definition at line 123 of file blkreftable.c.
| #define SH_EQUAL | ( | tb, | |
| a, | |||
| b | |||
| ) | (memcmp(&a, &b, sizeof(BlockRefTableKey)) == 0) |
Definition at line 128 of file blkreftable.c.
| #define SH_HASH_KEY | ( | tb, | |
| key | |||
| ) | hash_bytes((const unsigned char *) &key, sizeof(BlockRefTableKey)) |
Definition at line 126 of file blkreftable.c.
| #define SH_KEY key |
Definition at line 125 of file blkreftable.c.
| #define SH_KEY_TYPE BlockRefTableKey |
Definition at line 124 of file blkreftable.c.
| #define SH_PREFIX blockreftable |
Definition at line 122 of file blkreftable.c.
| #define SH_SCOPE static inline |
Definition at line 129 of file blkreftable.c.
| typedef struct BlockRefTableBuffer BlockRefTableBuffer |
| typedef uint16* BlockRefTableChunk |
Definition at line 82 of file blkreftable.c.
| typedef struct BlockRefTableKey BlockRefTableKey |
| typedef struct BlockRefTableSerializedEntry BlockRefTableSerializedEntry |
|
static |
Definition at line 1152 of file blkreftable.c.
References a, b, RelFileLocator::dbOid, BlockRefTableSerializedEntry::forknum, RelFileLocator::relNumber, BlockRefTableSerializedEntry::rlocator, and RelFileLocator::spcOid.
Referenced by WriteBlockRefTable().
| int BlockRefTableEntryGetBlocks | ( | BlockRefTableEntry * | entry, |
| BlockNumber | start_blkno, | ||
| BlockNumber | stop_blkno, | ||
| BlockNumber * | blocks, | ||
| int | nblocks | ||
| ) |
Definition at line 369 of file blkreftable.c.
References Assert(), BLOCKS_PER_CHUNK, BLOCKS_PER_ENTRY, BlockRefTableEntry::chunk_data, BlockRefTableEntry::chunk_usage, i, MAX_ENTRIES_PER_CHUNK, and BlockRefTableEntry::nchunks.
Referenced by GetFileBackupMethod().
| void BlockRefTableEntryMarkBlockModified | ( | BlockRefTableEntry * | entry, |
| ForkNumber | forknum, | ||
| BlockNumber | blknum | ||
| ) |
Definition at line 965 of file blkreftable.c.
References Assert(), BLOCKS_PER_CHUNK, BLOCKS_PER_ENTRY, BlockRefTableEntry::chunk_data, BlockRefTableEntry::chunk_size, BlockRefTableEntry::chunk_usage, i, INITIAL_ENTRIES_PER_CHUNK, j, Max, MAX_ENTRIES_PER_CHUNK, BlockRefTableEntry::nchunks, palloc(), palloc0(), pfree(), and repalloc().
Referenced by BlockRefTableMarkBlockModified().
| void BlockRefTableEntrySetLimitBlock | ( | BlockRefTableEntry * | entry, |
| BlockNumber | limit_block | ||
| ) |
Definition at line 894 of file blkreftable.c.
References Assert(), BLOCKS_PER_CHUNK, BLOCKS_PER_ENTRY, BlockRefTableEntry::chunk_data, BlockRefTableEntry::chunk_usage, i, if(), j, BlockRefTableEntry::limit_block, MAX_ENTRIES_PER_CHUNK, and BlockRefTableEntry::nchunks.
Referenced by BlockRefTableSetLimitBlock().
|
static |
Definition at line 1292 of file blkreftable.c.
References BlockRefTableFlush(), BlockRefTableWrite(), BlockRefTableBuffer::crc, crc, and FIN_CRC32C.
Referenced by DestroyBlockRefTableWriter(), and WriteBlockRefTable().
|
static |
Definition at line 1184 of file blkreftable.c.
References BlockRefTableBuffer::data, BlockRefTableBuffer::io_callback, BlockRefTableBuffer::io_callback_arg, and BlockRefTableBuffer::used.
Referenced by BlockRefTableFileTerminate().
| void BlockRefTableFreeEntry | ( | BlockRefTableEntry * | entry | ) |
Definition at line 1122 of file blkreftable.c.
References BlockRefTableEntry::chunk_data, BlockRefTableEntry::chunk_size, BlockRefTableEntry::chunk_usage, and pfree().
| BlockRefTableEntry * BlockRefTableGetEntry | ( | BlockRefTable * | brtab, |
| const RelFileLocator * | rlocator, | ||
| ForkNumber | forknum, | ||
| BlockNumber * | limit_block | ||
| ) |
Definition at line 340 of file blkreftable.c.
References Assert(), BlockRefTable::hash, sort-test::key, and BlockRefTableEntry::limit_block.
Referenced by GetFileBackupMethod().
| void BlockRefTableMarkBlockModified | ( | BlockRefTable * | brtab, |
| const RelFileLocator * | rlocator, | ||
| ForkNumber | forknum, | ||
| BlockNumber | blknum | ||
| ) |
Definition at line 297 of file blkreftable.c.
References BlockRefTableEntryMarkBlockModified(), BlockRefTableEntry::chunk_data, BlockRefTableEntry::chunk_size, BlockRefTableEntry::chunk_usage, BlockRefTable::hash, InvalidBlockNumber, sort-test::key, BlockRefTableEntry::limit_block, BlockRefTable::mcxt, MemoryContextSwitchTo(), and BlockRefTableEntry::nchunks.
Referenced by PrepareForIncrementalBackup(), and SummarizeWAL().
|
static |
Definition at line 1196 of file blkreftable.c.
References BlockRefTableReader::buffer, BUFSIZE, COMP_CRC32C, BlockRefTableBuffer::crc, BlockRefTableBuffer::cursor, BlockRefTableBuffer::data, data, BlockRefTableReader::error_callback, BlockRefTableReader::error_callback_arg, BlockRefTableReader::error_filename, BlockRefTableBuffer::io_callback, BlockRefTableBuffer::io_callback_arg, Min, and BlockRefTableBuffer::used.
Referenced by BlockRefTableReaderGetBlocks(), BlockRefTableReaderNextRelation(), and CreateBlockRefTableReader().
| unsigned BlockRefTableReaderGetBlocks | ( | BlockRefTableReader * | reader, |
| BlockNumber * | blocks, | ||
| int | nblocks | ||
| ) |
Definition at line 689 of file blkreftable.c.
References Assert(), BlockRefTableRead(), BLOCKS_PER_CHUNK, BLOCKS_PER_ENTRY, BlockRefTableReader::chunk_data, BlockRefTableReader::chunk_position, BlockRefTableReader::chunk_size, BlockRefTableReader::consumed_chunks, MAX_ENTRIES_PER_CHUNK, and BlockRefTableReader::total_chunks.
Referenced by dump_one_relation(), pg_wal_summary_contents(), and PrepareForIncrementalBackup().
| bool BlockRefTableReaderNextRelation | ( | BlockRefTableReader * | reader, |
| RelFileLocator * | rlocator, | ||
| ForkNumber * | forknum, | ||
| BlockNumber * | limit_block | ||
| ) |
Definition at line 613 of file blkreftable.c.
References Assert(), BlockRefTableRead(), BlockRefTableReader::buffer, BlockRefTableReader::chunk_size, BlockRefTableReader::consumed_chunks, BlockRefTableBuffer::crc, EQ_CRC32C, BlockRefTableReader::error_callback, BlockRefTableReader::error_callback_arg, BlockRefTableReader::error_filename, FIN_CRC32C, BlockRefTableSerializedEntry::forknum, BlockRefTableSerializedEntry::limit_block, BlockRefTableSerializedEntry::nchunks, palloc(), pfree(), BlockRefTableSerializedEntry::rlocator, and BlockRefTableReader::total_chunks.
Referenced by main(), pg_wal_summary_contents(), and PrepareForIncrementalBackup().
| void BlockRefTableSetLimitBlock | ( | BlockRefTable * | brtab, |
| const RelFileLocator * | rlocator, | ||
| ForkNumber | forknum, | ||
| BlockNumber | limit_block | ||
| ) |
Definition at line 262 of file blkreftable.c.
References BlockRefTableEntrySetLimitBlock(), BlockRefTableEntry::chunk_data, BlockRefTableEntry::chunk_size, BlockRefTableEntry::chunk_usage, BlockRefTable::hash, sort-test::key, BlockRefTableEntry::limit_block, and BlockRefTableEntry::nchunks.
Referenced by PrepareForIncrementalBackup(), SummarizeDbaseRecord(), SummarizeSmgrRecord(), and SummarizeXactRecord().
|
static |
Definition at line 1261 of file blkreftable.c.
References Assert(), BUFSIZE, COMP_CRC32C, BlockRefTableBuffer::crc, BlockRefTableBuffer::data, data, BlockRefTableBuffer::io_callback, BlockRefTableBuffer::io_callback_arg, and BlockRefTableBuffer::used.
Referenced by BlockRefTableFileTerminate(), BlockRefTableWriteEntry(), CreateBlockRefTableWriter(), and WriteBlockRefTable().
| void BlockRefTableWriteEntry | ( | BlockRefTableWriter * | writer, |
| BlockRefTableEntry * | entry | ||
| ) |
Definition at line 817 of file blkreftable.c.
References BlockRefTableWrite(), BlockRefTableWriter::buffer, BlockRefTableEntry::chunk_data, BlockRefTableEntry::chunk_usage, BlockRefTableKey::forknum, BlockRefTableSerializedEntry::forknum, j, BlockRefTableEntry::key, BlockRefTableEntry::limit_block, BlockRefTableSerializedEntry::limit_block, BlockRefTableEntry::nchunks, BlockRefTableSerializedEntry::nchunks, BlockRefTableKey::rlocator, and BlockRefTableSerializedEntry::rlocator.
| BlockRefTableEntry * CreateBlockRefTableEntry | ( | RelFileLocator | rlocator, |
| ForkNumber | forknum | ||
| ) |
Definition at line 875 of file blkreftable.c.
References BlockRefTableKey::forknum, InvalidBlockNumber, BlockRefTableEntry::key, BlockRefTableEntry::limit_block, palloc0(), and BlockRefTableKey::rlocator.
| BlockRefTableReader * CreateBlockRefTableReader | ( | io_callback_fn | read_callback, |
| void * | read_callback_arg, | ||
| char * | error_filename, | ||
| report_error_fn | error_callback, | ||
| void * | error_callback_arg | ||
| ) |
Definition at line 577 of file blkreftable.c.
References BLOCKREFTABLE_MAGIC, BlockRefTableRead(), BlockRefTableReader::buffer, BlockRefTableBuffer::crc, BlockRefTableReader::error_callback, BlockRefTableReader::error_callback_arg, BlockRefTableReader::error_filename, INIT_CRC32C, BlockRefTableBuffer::io_callback, BlockRefTableBuffer::io_callback_arg, and palloc0().
Referenced by main(), pg_wal_summary_contents(), and PrepareForIncrementalBackup().
| BlockRefTableWriter * CreateBlockRefTableWriter | ( | io_callback_fn | write_callback, |
| void * | write_callback_arg | ||
| ) |
Definition at line 790 of file blkreftable.c.
References BLOCKREFTABLE_MAGIC, BlockRefTableWrite(), BlockRefTableWriter::buffer, BlockRefTableBuffer::crc, INIT_CRC32C, BlockRefTableBuffer::io_callback, BlockRefTableBuffer::io_callback_arg, and palloc0().
| BlockRefTable * CreateEmptyBlockRefTable | ( | void | ) |
Definition at line 235 of file blkreftable.c.
References CurrentMemoryContext, BlockRefTable::hash, BlockRefTable::mcxt, and palloc().
| void DestroyBlockRefTableReader | ( | BlockRefTableReader * | reader | ) |
Definition at line 773 of file blkreftable.c.
References BlockRefTableReader::chunk_size, and pfree().
Referenced by main(), pg_wal_summary_contents(), and PrepareForIncrementalBackup().
| void DestroyBlockRefTableWriter | ( | BlockRefTableWriter * | writer | ) |
Definition at line 855 of file blkreftable.c.
References BlockRefTableFileTerminate(), BlockRefTableWriter::buffer, and pfree().
| void WriteBlockRefTable | ( | BlockRefTable * | brtab, |
| io_callback_fn | write_callback, | ||
| void * | write_callback_arg | ||
| ) |
Definition at line 474 of file blkreftable.c.
References Assert(), BLOCKREFTABLE_MAGIC, BlockRefTableComparator(), BlockRefTableFileTerminate(), BlockRefTableWrite(), BlockRefTableEntry::chunk_data, BlockRefTableEntry::chunk_usage, BlockRefTableBuffer::crc, BlockRefTableKey::forknum, BlockRefTableSerializedEntry::forknum, BlockRefTable::hash, i, INIT_CRC32C, BlockRefTableBuffer::io_callback, BlockRefTableBuffer::io_callback_arg, j, BlockRefTableEntry::key, sort-test::key, BlockRefTableEntry::limit_block, BlockRefTableSerializedEntry::limit_block, BlockRefTableEntry::nchunks, BlockRefTableSerializedEntry::nchunks, palloc(), qsort, BlockRefTableKey::rlocator, and BlockRefTableSerializedEntry::rlocator.
Referenced by SummarizeWAL().