|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "access/gin_private.h"#include "access/gin_tuple.h"#include "access/parallel.h"#include "access/table.h"#include "access/tableam.h"#include "access/xloginsert.h"#include "catalog/index.h"#include "catalog/pg_collation.h"#include "commands/progress.h"#include "miscadmin.h"#include "nodes/execnodes.h"#include "pgstat.h"#include "storage/bufmgr.h"#include "storage/predicate.h"#include "tcop/tcopprot.h"#include "utils/datum.h"#include "utils/memutils.h"#include "utils/builtins.h"#include "utils/rel.h"#include "utils/typcache.h"
Go to the source code of this file.
Data Structures | |
| struct | GinBuildShared |
| struct | GinLeader |
| struct | GinBuildState |
| struct | GinBuffer |
| struct | GinSegmentInfo |
Macros | |
| #define | PARALLEL_KEY_GIN_SHARED UINT64CONST(0xB000000000000001) |
| #define | PARALLEL_KEY_TUPLESORT UINT64CONST(0xB000000000000002) |
| #define | PARALLEL_KEY_QUERY_TEXT UINT64CONST(0xB000000000000003) |
| #define | PARALLEL_KEY_WAL_USAGE UINT64CONST(0xB000000000000004) |
| #define | PARALLEL_KEY_BUFFER_USAGE UINT64CONST(0xB000000000000005) |
| #define | ParallelTableScanFromGinBuildShared(shared) (ParallelTableScanDesc) ((char *) (shared) + BUFFERALIGN(sizeof(GinBuildShared))) |
Typedefs | |
| typedef struct GinBuildShared | GinBuildShared |
| typedef struct GinLeader | GinLeader |
| typedef struct GinBuffer | GinBuffer |
| #define PARALLEL_KEY_BUFFER_USAGE UINT64CONST(0xB000000000000005) |
Definition at line 44 of file gininsert.c.
| #define PARALLEL_KEY_GIN_SHARED UINT64CONST(0xB000000000000001) |
Definition at line 40 of file gininsert.c.
| #define PARALLEL_KEY_QUERY_TEXT UINT64CONST(0xB000000000000003) |
Definition at line 42 of file gininsert.c.
| #define PARALLEL_KEY_TUPLESORT UINT64CONST(0xB000000000000002) |
Definition at line 41 of file gininsert.c.
| #define PARALLEL_KEY_WAL_USAGE UINT64CONST(0xB000000000000004) |
Definition at line 43 of file gininsert.c.
| #define ParallelTableScanFromGinBuildShared | ( | shared | ) | (ParallelTableScanDesc) ((char *) (shared) + BUFFERALIGN(sizeof(GinBuildShared))) |
Definition at line 105 of file gininsert.c.
|
static |
Definition at line 928 of file gininsert.c.
References _gin_end_parallel(), _gin_leader_participate_as_worker(), _gin_parallel_estimate_shared(), Assert, ConditionVariableInit(), CreateParallelContext(), debug_query_string, DestroyParallelContext(), EnterParallelMode(), ParallelContext::estimator, ExitParallelMode(), fb(), GetTransactionSnapshot(), GinBuildShared::heaprelid, GinBuildShared::indexrelid, GinBuildShared::indtuples, InitializeParallelDSM(), GinBuildShared::isconcurrent, IsMVCCSnapshot, LaunchParallelWorkers(), mul_size(), GinBuildShared::mutex, GinBuildShared::nparticipantsdone, ParallelContext::nworkers, ParallelContext::nworkers_launched, palloc0_object, PARALLEL_KEY_BUFFER_USAGE, PARALLEL_KEY_GIN_SHARED, PARALLEL_KEY_QUERY_TEXT, PARALLEL_KEY_TUPLESORT, PARALLEL_KEY_WAL_USAGE, ParallelTableScanFromGinBuildShared, RegisterSnapshot(), RelationGetRelid, GinBuildShared::reltuples, GinBuildShared::scantuplesortstates, ParallelContext::seg, shm_toc_allocate(), shm_toc_estimate_chunk, shm_toc_estimate_keys, shm_toc_insert(), SnapshotAny, SpinLockInit, table_parallelscan_initialize(), ParallelContext::toc, tuplesort_estimate_shared(), tuplesort_initialize_shared(), UnregisterSnapshot(), WaitForParallelWorkersToAttach(), and GinBuildShared::workersdonecv.
Referenced by ginbuild().
|
static |
Definition at line 2232 of file gininsert.c.
References GinTuple::attrnum, GinTuple::category, dlist_mutable_iter::cur, GinTuple::data, data, DatumGetPointer(), dlist_container, dlist_delete(), dlist_foreach_modify, dlist_init(), dlist_push_tail(), elog, ERROR, fb(), GIN_CAT_NORM_KEY, ginCompressPostingList(), items, GinTuple::keylen, len, GinTuple::nitems, nitems, palloc0(), palloc_object, pfree(), SHORTALIGN, SizeOfGinPostingList, GinTuple::tuplen, GinTuple::typbyval, GinTuple::typlen, and VARSIZE_ANY().
Referenced by _gin_process_worker_data(), and ginFlushBuildState().
| int _gin_compare_tuples | ( | GinTuple * | a, |
| GinTuple * | b, | ||
| SortSupport | ssup | ||
| ) |
Definition at line 2434 of file gininsert.c.
References _gin_parse_tuple_key(), a, ApplySortComparator(), b, fb(), GIN_CAT_NORM_KEY, GinTupleGetFirst(), and ItemPointerCompare().
Referenced by comparetup_index_gin().
|
static |
Definition at line 1107 of file gininsert.c.
References DestroyParallelContext(), ExitParallelMode(), fb(), i, InstrAccumParallelQuery(), IsMVCCSnapshot, UnregisterSnapshot(), and WaitForParallelWorkersToFinish().
Referenced by _gin_begin_parallel(), and ginbuild().
|
static |
Definition at line 1812 of file gininsert.c.
References _gin_parallel_scan_and_build(), fb(), maintenance_work_mem, and GinLeader::nparticipanttuplesorts.
Referenced by _gin_begin_parallel().
| void _gin_parallel_build_main | ( | dsm_segment * | seg, |
| shm_toc * | toc | ||
| ) |
Definition at line 2101 of file gininsert.c.
References _gin_parallel_scan_and_build(), AccessExclusiveLock, ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, CurrentMemoryContext, debug_query_string, fb(), ginInitBA(), GinBuildShared::heaprelid, index_close(), index_open(), GinBuildShared::indexrelid, initGinState(), InstrEndParallelQuery(), InstrStartParallelQuery(), GinBuildShared::isconcurrent, maintenance_work_mem, MyProc, PARALLEL_KEY_BUFFER_USAGE, PARALLEL_KEY_GIN_SHARED, PARALLEL_KEY_QUERY_TEXT, PARALLEL_KEY_TUPLESORT, PARALLEL_KEY_WAL_USAGE, ParallelWorkerNumber, pgstat_report_activity(), PROC_IN_SAFE_IC, RowExclusiveLock, GinBuildShared::scantuplesortstates, ShareLock, ShareUpdateExclusiveLock, shm_toc_lookup(), STATE_RUNNING, PGPROC::statusFlags, table_close(), table_open(), and tuplesort_attach_shared().
Definition at line 1801 of file gininsert.c.
References add_size(), BUFFERALIGN, and table_parallelscan_estimate().
Referenced by _gin_begin_parallel().
|
static |
Definition at line 1138 of file gininsert.c.
References ConditionVariableCancelSleep(), ConditionVariableSleep(), fb(), GinBuildShared::indtuples, GinBuildShared::mutex, GinBuildShared::nparticipantsdone, GinBuildShared::reltuples, SpinLockAcquire, SpinLockRelease, and GinBuildShared::workersdonecv.
Referenced by _gin_parallel_merge().
|
static |
Definition at line 1639 of file gininsert.c.
References _gin_parallel_heapscan(), Assert, AssertCheckItemPointers(), GinBuffer::attnum, GinBuffer::category, CHECK_FOR_INTERRUPTS, fb(), GinBufferCanAddKey(), GinBufferFree(), GinBufferInit(), GinBufferIsEmpty(), GinBufferReset(), GinBufferShouldTrim(), GinBufferStoreTuple(), GinBufferTrim(), ginEntryInsert(), GinBuffer::items, GinBuffer::key, MemoryContextReset(), MemoryContextSwitchTo(), GinBuffer::nfrozen, GinBuffer::nitems, pgstat_progress_update_multi_param(), pgstat_progress_update_param(), PROGRESS_CREATEIDX_SUBPHASE, PROGRESS_CREATEIDX_TUPLES_DONE, PROGRESS_CREATEIDX_TUPLES_TOTAL, PROGRESS_GIN_PHASE_MERGE_2, PROGRESS_GIN_PHASE_PERFORMSORT_2, PROGRESS_SCAN_BLOCKS_DONE, PROGRESS_SCAN_BLOCKS_TOTAL, tuplesort_end(), tuplesort_getgintuple(), and tuplesort_performsort().
Referenced by ginbuild().
|
static |
Definition at line 2023 of file gininsert.c.
References _gin_process_worker_data(), BuildIndexInfo(), ConditionVariableSignal(), fb(), ginBuildCallbackParallel(), ginFlushBuildState(), IndexInfo::ii_Concurrent, GinBuildShared::indtuples, GinBuildShared::isconcurrent, GinBuildShared::mutex, GinBuildShared::nparticipantsdone, palloc0_object, ParallelTableScanFromGinBuildShared, progress, GinBuildShared::reltuples, GinBuildShared::scantuplesortstates, SpinLockAcquire, SpinLockRelease, table_beginscan_parallel(), table_index_build_scan(), tuplesort_begin_index_gin(), tuplesort_end(), TUPLESORT_NONE, tuplesort_performsort(), and GinBuildShared::workersdonecv.
Referenced by _gin_leader_participate_as_worker(), and _gin_parallel_build_main().
|
static |
Definition at line 2402 of file gininsert.c.
References a, Assert, data, fb(), ginPostingListDecodeAllSegments(), items, len, and SHORTALIGN.
Referenced by GinBufferStoreTuple().
Definition at line 2381 of file gininsert.c.
References a, fb(), GIN_CAT_NORM_KEY, and PointerGetDatum().
Referenced by _gin_compare_tuples(), and GinBufferStoreTuple().
|
static |
Definition at line 1845 of file gininsert.c.
References _gin_build_tuple(), Assert, AssertCheckItemPointers(), GinBuffer::attnum, GinBuffer::category, CHECK_FOR_INTERRUPTS, fb(), GinBufferCanAddKey(), GinBufferFree(), GinBufferInit(), GinBufferIsEmpty(), GinBufferReset(), GinBufferShouldTrim(), GinBufferStoreTuple(), GinBufferTrim(), GinBuffer::items, GinBuffer::key, GinBuffer::nfrozen, GinBuffer::nitems, pfree(), pgstat_progress_update_param(), progress, PROGRESS_CREATEIDX_SUBPHASE, PROGRESS_GIN_PHASE_MERGE_1, PROGRESS_GIN_PHASE_PERFORMSORT_1, tuplesort_end(), tuplesort_getgintuple(), tuplesort_performsort(), tuplesort_putgintuple(), GinBuffer::typbyval, and GinBuffer::typlen.
Referenced by _gin_parallel_scan_and_build().
|
static |
Definition at line 212 of file gininsert.c.
References Assert, attnum, createPostingTree(), fb(), ginCompressPostingList(), GinFormTuple(), ginInsertItemPointers(), GinIsPostingTree, GinMaxItemSize, ginMergeItemPointers(), ginReadTuple(), GinSetPostingTree, gintuple_get_attrnum(), gintuple_get_key(), GinState::index, items, pfree(), and SizeOfGinPostingList.
Referenced by ginEntryInsert().
Definition at line 1232 of file gininsert.c.
References Assert, AssertCheckItemPointers(), fb(), GinBuffer::items, and GinBuffer::nitems.
Referenced by GinBufferKeyEquals(), and GinBufferStoreTuple().
Definition at line 1205 of file gininsert.c.
References Assert, fb(), i, ItemPointerCompare(), ItemPointerIsValid(), GinBuffer::items, and GinBuffer::nitems.
Referenced by _gin_parallel_merge(), _gin_process_worker_data(), AssertCheckGinBuffer(), and GinBufferStoreTuple().
|
static |
Definition at line 294 of file gininsert.c.
References attnum, createPostingTree(), fb(), ginCompressPostingList(), GinFormTuple(), GinMaxItemSize, GinSetPostingTree, GinState::index, items, pfree(), and SizeOfGinPostingList.
Referenced by ginEntryInsert().
Definition at line 1617 of file gininsert.c.
References fb(), GinBufferIsEmpty(), and GinBufferKeyEquals().
Referenced by _gin_parallel_merge(), and _gin_process_worker_data().
Definition at line 1597 of file gininsert.c.
References GinBuffer::category, DatumGetPointer(), GIN_CAT_NORM_KEY, GinBufferIsEmpty(), GinBuffer::items, GinBuffer::key, pfree(), and GinBuffer::typbyval.
Referenced by _gin_parallel_merge(), and _gin_process_worker_data().
Definition at line 1261 of file gininsert.c.
References Assert, TypeCacheEntry::cmp_proc_finfo, CurrentMemoryContext, ereport, errcode(), errmsg(), ERROR, fb(), FmgrInfo::fn_oid, format_type_be(), GIN_COMPARE_PROC, i, index_getprocid(), IndexRelationGetNumberOfKeyAttributes, InvalidOid, lookup_type_cache(), GinBuffer::maxitems, OidIsValid, palloc0_array, palloc0_object, PrepareSortSupportComparisonShim(), RelationGetDescr, GinBuffer::ssup, TupleDescAttr(), and TYPECACHE_CMP_PROC_FINFO.
Referenced by _gin_parallel_merge(), and _gin_process_worker_data().
Definition at line 1329 of file gininsert.c.
References GinBuffer::nitems.
Referenced by _gin_parallel_merge(), _gin_process_worker_data(), GinBufferCanAddKey(), GinBufferFree(), GinBufferReset(), and GinBufferStoreTuple().
Definition at line 1345 of file gininsert.c.
References ApplySortComparator(), Assert, AssertCheckGinBuffer(), GinBuffer::attnum, GinBuffer::category, fb(), GIN_CAT_NORM_KEY, GinBuffer::key, PointerGetDatum(), GinBuffer::ssup, GinBuffer::typbyval, and GinBuffer::typlen.
Referenced by GinBufferCanAddKey().
Definition at line 1551 of file gininsert.c.
References Assert, GinBuffer::attnum, GinBuffer::category, DatumGetPointer(), GIN_CAT_NORM_KEY, GinBufferIsEmpty(), GinBuffer::key, GinBuffer::keylen, GinBuffer::nfrozen, GinBuffer::nitems, pfree(), GinBuffer::typbyval, and GinBuffer::typlen.
Referenced by _gin_parallel_merge(), and _gin_process_worker_data().
Definition at line 1411 of file gininsert.c.
References fb(), GinTupleGetFirst(), i, ItemPointerCompare(), GinBuffer::items, GinBuffer::maxitems, GinBuffer::nfrozen, and GinBuffer::nitems.
Referenced by _gin_parallel_merge(), and _gin_process_worker_data().
Definition at line 1484 of file gininsert.c.
References _gin_parse_tuple_items(), _gin_parse_tuple_key(), Assert, AssertCheckGinBuffer(), AssertCheckItemPointers(), GinBuffer::attnum, GinBuffer::category, datumCopy(), fb(), GIN_CAT_NORM_KEY, GinBufferIsEmpty(), ginMergeItemPointers(), GinBuffer::items, items, GinBuffer::key, GinBuffer::keylen, GinBuffer::nfrozen, GinBuffer::nitems, palloc(), pfree(), repalloc(), GinBuffer::typbyval, and GinBuffer::typlen.
Referenced by _gin_parallel_merge(), and _gin_process_worker_data().
Definition at line 1581 of file gininsert.c.
References Assert, fb(), GinBuffer::items, GinBuffer::nfrozen, and GinBuffer::nitems.
Referenced by _gin_parallel_merge(), and _gin_process_worker_data().
| IndexBuildResult * ginbuild | ( | Relation | heap, |
| Relation | index, | ||
| IndexInfo * | indexInfo | ||
| ) |
Definition at line 613 of file gininsert.c.
References _gin_begin_parallel(), _gin_end_parallel(), _gin_parallel_merge(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, attnum, CHECK_FOR_INTERRUPTS, CurrentMemoryContext, elog, END_CRIT_SECTION, ERROR, fb(), GIN_LEAF, ginBeginBAScan(), ginBuildCallback(), ginEntryInsert(), ginGetBAEntry(), ginInitBA(), GinInitBuffer(), GinInitMetabuffer(), GinNewBuffer(), ginUpdateStats(), IndexBuildResult::heap_tuples, IndexInfo::ii_Concurrent, IndexInfo::ii_ParallelWorkers, IndexBuildResult::index_tuples, initGinState(), log_newpage_range(), MAIN_FORKNUM, maintenance_work_mem, MarkBufferDirty(), MemoryContextDelete(), MemoryContextSwitchTo(), palloc0_object, palloc_object, pgstat_progress_update_param(), PROGRESS_CREATEIDX_SUBPHASE, PROGRESS_GIN_PHASE_INDEXBUILD_TABLESCAN, RelationGetNumberOfBlocks, RelationGetRelationName, RelationNeedsWAL, START_CRIT_SECTION, table_index_build_scan(), tuplesort_begin_index_gin(), TUPLESORT_NONE, and UnlockReleaseBuffer().
Referenced by ginhandler().
|
static |
Definition at line 447 of file gininsert.c.
References attnum, CHECK_FOR_INTERRUPTS, fb(), ginBeginBAScan(), ginEntryInsert(), ginGetBAEntry(), ginHeapTupleBulkInsert(), ginInitBA(), i, maintenance_work_mem, MemoryContextReset(), MemoryContextSwitchTo(), and values.
Referenced by ginbuild().
|
static |
Definition at line 565 of file gininsert.c.
References fb(), ginFlushBuildState(), ginHeapTupleBulkInsert(), i, ItemPointerCompare(), MemoryContextSwitchTo(), and values.
Referenced by _gin_parallel_scan_and_build().
Definition at line 807 of file gininsert.c.
References BMR_REL, EB_LOCK_FIRST, EB_SKIP_EXTENSION_LOCK, END_CRIT_SECTION, ExtendBufferedRel(), fb(), GIN_LEAF, GinInitBuffer(), GinInitMetabuffer(), INIT_FORKNUM, log_newpage_buffer(), MarkBufferDirty(), START_CRIT_SECTION, and UnlockReleaseBuffer().
Referenced by ginhandler().
| void ginEntryInsert | ( | GinState * | ginstate, |
| OffsetNumber | attnum, | ||
| Datum | key, | ||
| GinNullCategory | category, | ||
| ItemPointerData * | items, | ||
| uint32 | nitem, | ||
| GinStatsData * | buildStats | ||
| ) |
Definition at line 346 of file gininsert.c.
References addItemPointersToLeafTuple(), attnum, GinBtreeStack::buffer, BufferGetBlockNumber(), BufferGetPage(), buildFreshLeafTuple(), CheckForSerializableConflictIn(), fb(), GinBtreeData::findItem, freeGinBtreeStack(), GIN_UNLOCK, ginFindLeafPage(), GinGetPostingTree, ginInsertItemPointers(), ginInsertValue(), GinIsPostingTree, ginPrepareEntryScan(), GinState::index, GinBtreeData::isBuild, items, LockBuffer(), GinStatsData::nEntries, GinBtreeStack::off, PageGetItem(), PageGetItemId(), and pfree().
Referenced by _gin_parallel_merge(), ginbuild(), ginBuildCallback(), ginHeapTupleInsert(), and ginInsertCleanup().
|
static |
Definition at line 500 of file gininsert.c.
References _gin_build_tuple(), CompactAttribute::attbyval, CompactAttribute::attlen, attnum, CHECK_FOR_INTERRUPTS, fb(), ginBeginBAScan(), ginGetBAEntry(), ginInitBA(), len, MaxAllocSize, MemoryContextReset(), Min, pfree(), RelationGetDescr, TupleDescCompactAttr(), and tuplesort_putgintuple().
Referenced by _gin_parallel_scan_and_build(), and ginBuildCallbackParallel().
|
static |
Definition at line 423 of file gininsert.c.
References attnum, fb(), ginExtractEntries(), ginInsertBAEntries(), MemoryContextReset(), MemoryContextSwitchTo(), and value.
Referenced by ginBuildCallback(), and ginBuildCallbackParallel().
|
static |
Definition at line 838 of file gininsert.c.
References attnum, fb(), ginEntryInsert(), ginExtractEntries(), i, and value.
Referenced by gininsert().
| bool gininsert | ( | Relation | index, |
| Datum * | values, | ||
| bool * | isnull, | ||
| ItemPointer | ht_ctid, | ||
| Relation | heapRel, | ||
| IndexUniqueCheck | checkUnique, | ||
| bool | indexUnchanged, | ||
| IndexInfo * | indexInfo | ||
| ) |
Definition at line 856 of file gininsert.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, CurrentMemoryContext, fb(), GinGetUseFastUpdate, ginHeapTupleFastCollect(), ginHeapTupleFastInsert(), ginHeapTupleInsert(), i, IndexInfo::ii_AmCache, IndexInfo::ii_Context, initGinState(), MemoryContextDelete(), MemoryContextSwitchTo(), TupleDescData::natts, GinState::origTupdesc, palloc_object, and values.
Referenced by ginhandler().