PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/brin.h"
#include "access/brin_page.h"
#include "access/brin_pageops.h"
#include "access/brin_xlog.h"
#include "access/relation.h"
#include "access/reloptions.h"
#include "access/relscan.h"
#include "access/table.h"
#include "access/tableam.h"
#include "access/xloginsert.h"
#include "catalog/index.h"
#include "catalog/pg_am.h"
#include "commands/vacuum.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "postmaster/autovacuum.h"
#include "storage/bufmgr.h"
#include "storage/freespace.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/datum.h"
#include "utils/guc.h"
#include "utils/index_selfuncs.h"
#include "utils/memutils.h"
#include "utils/rel.h"
Go to the source code of this file.
Data Structures | |
struct | BrinBuildState |
struct | BrinOpaque |
Macros | |
#define | BRIN_ALL_BLOCKRANGES InvalidBlockNumber |
Typedefs | |
typedef struct BrinBuildState | BrinBuildState |
typedef struct BrinOpaque | BrinOpaque |
#define BRIN_ALL_BLOCKRANGES InvalidBlockNumber |
typedef struct BrinBuildState BrinBuildState |
typedef struct BrinOpaque BrinOpaque |
|
static |
Definition at line 1776 of file brin.c.
References Assert(), BrinDesc::bd_info, BrinDesc::bd_tupdesc, BRIN_PROCNUM_ADDVALUE, BrinMemTuple::bt_columns, BrinMemTuple::bt_empty_range, BrinValues::bv_allnulls, BrinValues::bv_hasnulls, DatumGetBool(), FunctionCall4Coll(), index_getprocinfo(), TupleDescData::natts, BrinOpcInfo::oi_regular_nulls, PointerGetDatum(), RelationData::rd_indcollation, and values.
Referenced by brinbuildCallback(), and brininsert().
Definition at line 1203 of file brin.c.
References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, BrinDesc::bd_context, BrinDesc::bd_disktdesc, BrinDesc::bd_index, BrinDesc::bd_info, BrinDesc::bd_totalstored, BrinDesc::bd_tupdesc, BRIN_PROCNUM_OPCINFO, CurrentMemoryContext, DatumGetPointer(), FunctionCall1, index_getprocinfo(), MemoryContextSwitchTo(), TupleDescData::natts, BrinOpcInfo::oi_nstored, palloc(), palloc_array, pfree(), RelationGetDescr, and TupleDescAttr.
Referenced by brin_page_items(), brinbeginscan(), brininsert(), and initialize_brin_buildstate().
Datum brin_desummarize_range | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1122 of file brin.c.
References aclcheck_error(), ACLCHECK_NOT_OWNER, brinRevmapDesummarizeRange(), ereport, errcode(), ERRCODE_UNDEFINED_TABLE, errhint(), errmsg(), ERROR, GetUserId(), index_open(), IndexGetRelation(), MaxBlockNumber, OBJECT_INDEX, object_ownercheck(), OidIsValid, PG_GETARG_INT64, PG_GETARG_OID, PG_RETURN_VOID, RelationData::rd_rel, RecoveryInProgress(), relation_close(), RelationGetRelationName, ShareUpdateExclusiveLock, and table_open().
void brin_free_desc | ( | BrinDesc * | bdesc | ) |
Definition at line 1258 of file brin.c.
References Assert(), BrinDesc::bd_context, BrinDesc::bd_tupdesc, MemoryContextDelete(), and TupleDescData::tdrefcount.
Referenced by brin_page_items(), brinendscan(), and terminate_brin_buildstate().
Datum brin_summarize_new_values | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1003 of file brin.c.
References BRIN_ALL_BLOCKRANGES, brin_summarize_range(), DirectFunctionCall2, Int64GetDatum(), and PG_GETARG_DATUM.
Datum brin_summarize_range | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1018 of file brin.c.
References aclcheck_error(), ACLCHECK_NOT_OWNER, AtEOXact_GUC(), BRIN_ALL_BLOCKRANGES, brinsummarize(), ereport, errcode(), ERRCODE_UNDEFINED_TABLE, errhint(), errmsg(), ERROR, GetUserIdAndSecContext(), index_open(), IndexGetRelation(), InvalidOid, NewGUCNestLevel(), OBJECT_INDEX, object_ownercheck(), OidIsValid, PG_GETARG_INT64, PG_GETARG_OID, PG_RETURN_INT32, RelationData::rd_rel, RecoveryInProgress(), relation_close(), RelationGetRelationName, SECURITY_RESTRICTED_OPERATION, SetUserIdAndSecContext(), ShareUpdateExclusiveLock, and table_open().
Referenced by brin_summarize_new_values(), and perform_work_item().
|
static |
Definition at line 1743 of file brin.c.
References brin_page_cleanup(), buf, CHECK_FOR_INTERRUPTS, FreeSpaceMapVacuum(), MAIN_FORKNUM, RBM_NORMAL, ReadBufferExtended(), RelationGetNumberOfBlocks, and ReleaseBuffer().
Referenced by brinvacuumcleanup().
IndexScanDesc brinbeginscan | ( | Relation | r, |
int | nkeys, | ||
int | norderbys | ||
) |
Definition at line 327 of file brin.c.
References BrinOpaque::bo_bdesc, BrinOpaque::bo_pagesPerRange, BrinOpaque::bo_rmAccess, brin_build_desc(), brinRevmapInitialize(), IndexScanDescData::opaque, palloc_object, and RelationGetIndexScan().
Referenced by brinhandler().
IndexBuildResult* brinbuild | ( | Relation | heap, |
Relation | index, | ||
IndexInfo * | indexInfo | ||
) |
Definition at line 827 of file brin.c.
References Assert(), BMR_REL, BRIN_CURRENT_VERSION, BRIN_METAPAGE_BLKNO, brin_metapage_init(), brinbuildCallback(), BrinGetPagesPerRange, brinRevmapInitialize(), brinRevmapTerminate(), BufferGetBlockNumber(), BufferGetPage(), EB_LOCK_FIRST, EB_SKIP_EXTENSION_LOCK, elog(), ERROR, ExtendBufferedRel(), form_and_insert_tuple(), IndexBuildResult::heap_tuples, IndexBuildResult::index_tuples, initialize_brin_buildstate(), MAIN_FORKNUM, MarkBufferDirty(), PageSetLSN(), xl_brin_createidx::pagesPerRange, palloc_object, REGBUF_STANDARD, REGBUF_WILL_INIT, RelationGetNumberOfBlocks, RelationGetRelationName, RelationNeedsWAL, SizeOfBrinCreateIdx, table_index_build_scan(), terminate_brin_buildstate(), UnlockReleaseBuffer(), xl_brin_createidx::version, XLOG_BRIN_CREATE_INDEX, XLogBeginInsert(), XLogInsert(), XLogRegisterBuffer(), and XLogRegisterData().
Referenced by brinhandler().
|
static |
Definition at line 782 of file brin.c.
References add_values_to_range(), BRIN_elog, brin_memtuple_initialize(), DEBUG2, form_and_insert_tuple(), ItemPointerGetBlockNumber(), and values.
Referenced by brinbuild(), and summarize_range().
void brinbuildempty | ( | Relation | index | ) |
Definition at line 911 of file brin.c.
References BMR_REL, BRIN_CURRENT_VERSION, brin_metapage_init(), BrinGetPagesPerRange, BufferGetPage(), EB_LOCK_FIRST, EB_SKIP_EXTENSION_LOCK, END_CRIT_SECTION, ExtendBufferedRel(), INIT_FORKNUM, log_newpage_buffer(), MarkBufferDirty(), START_CRIT_SECTION, and UnlockReleaseBuffer().
Referenced by brinhandler().
IndexBulkDeleteResult* brinbulkdelete | ( | IndexVacuumInfo * | info, |
IndexBulkDeleteResult * | stats, | ||
IndexBulkDeleteCallback | callback, | ||
void * | callback_state | ||
) |
Definition at line 940 of file brin.c.
References palloc0_object.
Referenced by brinhandler().
void brinendscan | ( | IndexScanDesc | scan | ) |
Definition at line 765 of file brin.c.
References BrinOpaque::bo_bdesc, BrinOpaque::bo_rmAccess, brin_free_desc(), brinRevmapTerminate(), IndexScanDescData::opaque, and pfree().
Referenced by brinhandler().
int64 bringetbitmap | ( | IndexScanDesc | scan, |
TIDBitmap * | tbm | ||
) |
Definition at line 355 of file brin.c.
References AccessShareLock, addrange(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), BrinDesc::bd_info, BrinDesc::bd_tupdesc, BrinOpaque::bo_bdesc, BrinOpaque::bo_pagesPerRange, BrinOpaque::bo_rmAccess, brin_copy_tuple(), brin_deform_tuple(), brin_new_memtuple(), BRIN_PROCNUM_CONSISTENT, brinGetTupleForHeapBlock(), BrinMemTuple::bt_columns, BrinMemTuple::bt_empty_range, BrinMemTuple::bt_placeholder, buf, BUFFER_LOCK_SHARE, BUFFER_LOCK_UNLOCK, BrinValues::bv_allnulls, CHECK_FOR_INTERRUPTS, check_null_keys(), CurrentMemoryContext, DatumGetBool(), fmgr_info_copy(), FunctionCall3Coll(), FunctionCall4Coll(), i, index_getprocinfo(), IndexGetRelation(), IndexScanDescData::indexRelation, Int32GetDatum(), InvalidBuffer, InvalidOid, sort-test::key, IndexScanDescData::keyData, len, LockBuffer(), MAXALIGN, MemoryContextDelete(), MemoryContextResetAndDeleteChildren, MemoryContextSwitchTo(), Min, TupleDescData::natts, IndexScanDescData::numberOfKeys, BrinOpcInfo::oi_regular_nulls, IndexScanDescData::opaque, palloc(), palloc0_array, PG_USED_FOR_ASSERTS_ONLY, pgstat_count_index_scan, PointerGetDatum(), RelationGetNumberOfBlocks, RelationGetRelid, ReleaseBuffer(), ScanKeyData::sk_collation, SK_ISNULL, table_close(), table_open(), tbm_add_page(), and TupleDescAttr.
Referenced by brinhandler().
void brinGetStats | ( | Relation | index, |
BrinStatsData * | stats | ||
) |
Definition at line 1270 of file brin.c.
References BRIN_METAPAGE_BLKNO, BUFFER_LOCK_SHARE, BufferGetPage(), BrinMetaPageData::lastRevmapPage, LockBuffer(), PageGetContents(), BrinStatsData::pagesPerRange, BrinMetaPageData::pagesPerRange, ReadBuffer(), BrinStatsData::revmapNumPages, and UnlockReleaseBuffer().
Referenced by brincostestimate().
Datum brinhandler | ( | PG_FUNCTION_ARGS | ) |
Definition at line 91 of file brin.c.
References IndexAmRoutine::amadjustmembers, IndexAmRoutine::ambeginscan, IndexAmRoutine::ambuild, IndexAmRoutine::ambuildempty, IndexAmRoutine::ambuildphasename, IndexAmRoutine::ambulkdelete, IndexAmRoutine::amcanbackward, IndexAmRoutine::amcaninclude, IndexAmRoutine::amcanmulticol, IndexAmRoutine::amcanorder, IndexAmRoutine::amcanorderbyop, IndexAmRoutine::amcanparallel, IndexAmRoutine::amcanreturn, IndexAmRoutine::amcanunique, IndexAmRoutine::amclusterable, IndexAmRoutine::amcostestimate, IndexAmRoutine::amendscan, IndexAmRoutine::amestimateparallelscan, IndexAmRoutine::amgetbitmap, IndexAmRoutine::amgettuple, IndexAmRoutine::aminitparallelscan, IndexAmRoutine::aminsert, IndexAmRoutine::amkeytype, IndexAmRoutine::ammarkpos, IndexAmRoutine::amoptionalkey, IndexAmRoutine::amoptions, IndexAmRoutine::amoptsprocnum, IndexAmRoutine::amparallelrescan, IndexAmRoutine::amparallelvacuumoptions, IndexAmRoutine::ampredlocks, IndexAmRoutine::amproperty, IndexAmRoutine::amrescan, IndexAmRoutine::amrestrpos, IndexAmRoutine::amsearcharray, IndexAmRoutine::amsearchnulls, IndexAmRoutine::amstorage, IndexAmRoutine::amstrategies, IndexAmRoutine::amsummarizing, IndexAmRoutine::amsupport, IndexAmRoutine::amusemaintenanceworkmem, IndexAmRoutine::amvacuumcleanup, IndexAmRoutine::amvalidate, BRIN_LAST_OPTIONAL_PROCNUM, BRIN_PROCNUM_OPTIONS, brinbeginscan(), brinbuild(), brinbuildempty(), brinbulkdelete(), brincostestimate(), brinendscan(), bringetbitmap(), brininsert(), brinoptions(), brinrescan(), brinvacuumcleanup(), brinvalidate(), InvalidOid, makeNode, PG_RETURN_POINTER, and VACUUM_OPTION_PARALLEL_CLEANUP.
bool brininsert | ( | Relation | idxRel, |
Datum * | values, | ||
bool * | nulls, | ||
ItemPointer | heaptid, | ||
Relation | heapRel, | ||
IndexUniqueCheck | checkUnique, | ||
bool | indexUnchanged, | ||
IndexInfo * | indexInfo | ||
) |
Definition at line 156 of file brin.c.
References add_values_to_range(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, AutoVacuumRequestWork(), AVW_BRINSummarizeRange, brin_build_desc(), brin_can_do_samepage_update(), brin_copy_tuple(), brin_deform_tuple(), brin_doupdate(), brin_form_tuple(), BrinGetAutoSummarize, brinGetTupleForHeapBlock(), brinRevmapInitialize(), brinRevmapTerminate(), buf, BUFFER_LOCK_SHARE, BUFFER_LOCK_UNLOCK, BufferGetPage(), BufferIsValid(), CHECK_FOR_INTERRUPTS, CurrentMemoryContext, ereport, errcode(), errmsg(), FirstOffsetNumber, IndexInfo::ii_AmCache, IndexInfo::ii_Context, InvalidBuffer, ItemIdGetLength, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), LockBuffer(), LOG, MemoryContextDelete(), MemoryContextResetAndDeleteChildren, MemoryContextSwitchTo(), PageGetItemId(), RelationGetRelationName, RelationGetRelid, ReleaseBuffer(), and values.
Referenced by brinhandler().
Definition at line 985 of file brin.c.
References build_reloptions(), lengthof, RELOPT_KIND_BRIN, RELOPT_TYPE_BOOL, and RELOPT_TYPE_INT.
Referenced by brinhandler().
void brinrescan | ( | IndexScanDesc | scan, |
ScanKey | scankey, | ||
int | nscankeys, | ||
ScanKey | orderbys, | ||
int | norderbys | ||
) |
Definition at line 745 of file brin.c.
References IndexScanDescData::keyData, and IndexScanDescData::numberOfKeys.
Referenced by brinhandler().
|
static |
Definition at line 1485 of file brin.c.
References Assert(), BRIN_ALL_BLOCKRANGES, brin_memtuple_initialize(), brinGetTupleForHeapBlock(), brinRevmapInitialize(), brinRevmapTerminate(), buf, BUFFER_LOCK_SHARE, BUFFER_LOCK_UNLOCK, BufferIsValid(), BuildIndexInfo(), CHECK_FOR_INTERRUPTS, initialize_brin_buildstate(), InvalidBuffer, LockBuffer(), Min, pfree(), RelationGetNumberOfBlocks, ReleaseBuffer(), summarize_range(), and terminate_brin_buildstate().
Referenced by brin_summarize_range(), and brinvacuumcleanup().
IndexBulkDeleteResult* brinvacuumcleanup | ( | IndexVacuumInfo * | info, |
IndexBulkDeleteResult * | stats | ||
) |
Definition at line 955 of file brin.c.
References AccessShareLock, IndexVacuumInfo::analyze_only, BRIN_ALL_BLOCKRANGES, brin_vacuum_scan(), brinsummarize(), IndexVacuumInfo::index, IndexGetRelation(), IndexBulkDeleteResult::num_index_tuples, IndexBulkDeleteResult::num_pages, palloc0_object, RelationGetNumberOfBlocks, RelationGetRelid, IndexVacuumInfo::strategy, table_close(), and table_open().
Referenced by brinhandler().
|
static |
Definition at line 1870 of file brin.c.
References Assert(), BrinValues::bv_allnulls, BrinValues::bv_attno, BrinValues::bv_hasnulls, sort-test::key, SK_ISNULL, SK_SEARCHNOTNULL, and SK_SEARCHNULL.
Referenced by bringetbitmap().
|
static |
Definition at line 1582 of file brin.c.
References brin_doinsert(), brin_form_tuple(), and pfree().
Referenced by brinbuild(), and brinbuildCallback().
|
static |
Definition at line 1291 of file brin.c.
References brin_build_desc(), brin_new_memtuple(), InvalidBuffer, and palloc_object.
Referenced by brinbuild(), and brinsummarize().
|
static |
Definition at line 1359 of file brin.c.
References Assert(), brin_can_do_samepage_update(), brin_copy_tuple(), brin_doinsert(), brin_doupdate(), brin_form_placeholder_tuple(), brin_form_tuple(), brin_free_tuple(), brinbuildCallback(), brinGetTupleForHeapBlock(), BUFFER_LOCK_SHARE, BUFFER_LOCK_UNLOCK, CHECK_FOR_INTERRUPTS, elog(), ERROR, InvalidBuffer, LockBuffer(), Min, RelationGetNumberOfBlocks, ReleaseBuffer(), table_index_build_range_scan(), and union_tuples().
Referenced by brinsummarize().
|
static |
Definition at line 1314 of file brin.c.
References brin_free_desc(), BufferGetBlockNumber(), BufferGetPage(), BufferIsInvalid, FreeSpaceMapVacuumRange(), PageGetFreeSpace(), pfree(), RecordPageWithFreeSpace(), and ReleaseBuffer().
Referenced by brinbuild(), and brinsummarize().
|
static |
Definition at line 1602 of file brin.c.
References a, ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, b, BrinDesc::bd_index, BrinDesc::bd_info, BrinDesc::bd_tupdesc, brin_deform_tuple(), BRIN_PROCNUM_UNION, BrinMemTuple::bt_columns, BrinMemTuple::bt_empty_range, BrinValues::bv_allnulls, BrinValues::bv_hasnulls, BrinValues::bv_values, CurrentMemoryContext, datumCopy(), FunctionCall3Coll(), i, index_getprocinfo(), MemoryContextDelete(), MemoryContextSwitchTo(), TupleDescData::natts, BrinOpcInfo::oi_nstored, BrinOpcInfo::oi_regular_nulls, BrinOpcInfo::oi_typcache, PointerGetDatum(), RelationData::rd_indcollation, TypeCacheEntry::typbyval, and TypeCacheEntry::typlen.
Referenced by summarize_range().