70#include "utils/fmgroids.h"
80#include "utils/wait_event_types.h"
97#define WORKER_FILE_SNAPSHOT 0
203 const char *indexname);
248 if (
strcmp(opt->defname,
"verbose") == 0)
250 else if (
strcmp(opt->defname,
"analyze") == 0 ||
251 strcmp(opt->defname,
"analyse") == 0)
253 else if (
strcmp(opt->defname,
"concurrently") == 0 &&
259 errmsg(
"CONCURRENTLY option not supported for %s",
266 errmsg(
"unrecognized %s option \"%s\"",
308 errmsg(
"cannot execute %s on multiple tables",
309 "REPACK (ANALYZE)"));
324 errmsg(
"REPACK (CONCURRENTLY) is not supported for partitioned tables"),
325 errhint(
"Consider running the command on individual partitions."));
330 errmsg(
"REPACK (CONCURRENTLY) requires an explicit table name"));
376 if (
stmt->usingindex)
382 if (!
stmt->indexname)
387 errmsg(
"there is no previously clustered index for table \"%s\"",
393 errmsg(
"cannot execute %s on partitioned table \"%s\" USING INDEX with no index name",
401 elog(
ERROR,
"unable to determine index to cluster on");
509 int save_sec_context;
565 errmsg(
"cannot execute %s on a shared catalog",
582 errmsg(
"cannot execute %s on temporary tables of other sessions",
615 errmsg(
"permission denied: \"%s\" is a system catalog",
617 errdetail(
"System catalogs can only be clustered by the index they're already clustered on, if any, unless \"%s\" is enabled.",
618 "allow_system_table_mods"));
764 errmsg(
"\"%s\" is not an index for table \"%s\"",
769 if (!
OldIndex->rd_indam->amclusterable)
772 errmsg(
"cannot cluster on index \"%s\" because access method does not support clustering",
784 errmsg(
"cannot cluster on partial index \"%s\"",
795 if (!
OldIndex->rd_index->indisvalid)
798 errmsg(
"cannot cluster on invalid index \"%s\"",
857 elog(
ERROR,
"cannot cluster on invalid index %u", indexOid);
887 errmsg(
"cannot repack relation \"%s\"",
889 errhint(
"REPACK CONCURRENTLY is not supported for catalog relations."));
898 errmsg(
"cannot repack relation \"%s\"",
900 errhint(
"REPACK CONCURRENTLY is not supported for TOAST relations"));
902 relpersistence = rel->
rd_rel->relpersistence;
906 errmsg(
"cannot repack relation \"%s\"",
908 errhint(
"REPACK CONCURRENTLY is only allowed for permanent relations."));
911 replident = rel->
rd_rel->relreplident;
915 errmsg(
"cannot repack relation \"%s\"",
917 errhint(
"Relation \"%s\" has insufficient replication identity.",
933 errmsg(
"cannot process relation \"%s\"",
935 errhint(
"Relation \"%s\" has no identity index.",
966 Oid tableSpace =
OldHeap->rd_rel->reltablespace;
975#if USE_ASSERT_CHECKING
1025 relpersistence =
OldHeap->rd_rel->relpersistence;
1109 char relpersistence,
LOCKMODE lockmode)
1140 reloptions = (
Datum) 0;
1213 reloptions = (
Datum) 0;
1249 double num_tuples = 0,
1256 bool concurrent = snapshot !=
NULL;
1287 if (
OldHeap->rd_rel->reltoastrelid)
1297 if (
OldHeap->rd_rel->reltoastrelid &&
NewHeap->rd_rel->reltoastrelid &&
1376 errmsg(
"repacking \"%s.%s\" using index scan on \"%s\"",
1382 errmsg(
"repacking \"%s.%s\" using sequential scan and sort",
1387 errmsg(
"repacking \"%s.%s\" in physical order",
1419 (
errmsg(
"\"%s.%s\": found %.0f removable, %.0f nonremovable row versions in %u pages",
1424 errdetail(
"%.0f dead row versions cannot be removed yet.\n"
1435 elog(
ERROR,
"cache lookup failed for relation %u",
1439 relform->relpages = num_pages;
1440 relform->reltuples = num_tuples;
1507 elog(
ERROR,
"cache lookup failed for relation %u",
r1);
1512 elog(
ERROR,
"cache lookup failed for relation %u",
r2);
1561 elog(
ERROR,
"cannot swap mapped relation \"%s\" with non-mapped relation",
1572 elog(
ERROR,
"cannot change tablespace of mapped relation \"%s\"",
1575 elog(
ERROR,
"cannot change persistence of mapped relation \"%s\"",
1578 elog(
ERROR,
"cannot change access method of mapped relation \"%s\"",
1582 elog(
ERROR,
"cannot swap toast by links for mapped relation \"%s\"",
1590 elog(
ERROR,
"could not find relation mapping for relation \"%s\", OID %u",
1594 elog(
ERROR,
"could not find relation mapping for relation \"%s\", OID %u",
1619 rel2->rd_createSubid =
rel1->rd_createSubid;
1620 rel2->rd_newRelfilelocatorSubid =
rel1->rd_newRelfilelocatorSubid;
1621 rel2->rd_firstRelfilelocatorSubid =
rel1->rd_firstRelfilelocatorSubid;
1707 elog(
ERROR,
"could not change access method dependency for relation \"%s.%s\"",
1715 elog(
ERROR,
"could not change access method dependency for relation \"%s.%s\"",
1752 elog(
ERROR,
"cannot swap toast files by content when there's only one");
1779 elog(
ERROR,
"cannot swap toast files by links for system catalogs");
1788 elog(
ERROR,
"expected one dependency record for TOAST table, found %ld",
1797 elog(
ERROR,
"expected one dependency record for TOAST table, found %ld",
1873 char newrelpersistence)
1984 object.objectSubId = 0;
2195 rtc->tableOid =
class->oid;
2287 errmsg(
"permission denied to execute %s on \"%s\", skipping it",
2323 errmsg(
"ANALYZE option must be specified when a column list is provided"));
2341 errmsg(
"cannot execute %s on temporary tables of other sessions",
2380 stmt->relation->va_cols,
true,
NULL);
2402 if (indexname ==
NULL && usingindex)
2421 errmsg(
"there is no previously clustered index for table \"%s\"",
2424 else if (indexname !=
NULL)
2431 errmsg(
"index \"%s\" for table \"%s\" does not exist",
2534 elog(
ERROR,
"failed to find target tuple");
2550 elog(
ERROR,
"failed to find target tuple");
2567 elog(
ERROR,
"unrecognized kind of change: %d", kind);
2627 errmsg(
"failed to apply concurrent UPDATE"));
2663 errmsg(
"failed to apply concurrent DELETE"));
2709 for (
int i = 0;
i < desc->
natts;
i++)
2716 char data[
sizeof(
void *)];
2742 errmsg(
"insufficient number of attributes stored separately"));
2754 TupleDesc desc = dest->tts_tupleDescriptor;
2756 for (
int i = 0;
i < desc->
natts;
i++)
2801 for (
int i = 0;
i <
chgcxt->cc_ident_key_nentries;
i++)
2841 shared->
done = done;
2861 if (last_exported ==
chgcxt->cc_file_seq)
2887 chgcxt->cc_rel = relation;
2901 for (
int i = 0;
i <
chgcxt->cc_rri->ri_NumIndices;
i++)
2913 elog(
ERROR,
"failed to find identity index");
2930 entry = &
chgcxt->cc_ident_key[
i];
2932 opfamily =
chgcxt->cc_ident_index->rd_opfamily[
i];
2933 opcintype =
chgcxt->cc_ident_index->rd_opcintype[
i];
2937 elog(
ERROR,
"failed to find = operator for type %u", opcintype);
2940 elog(
ERROR,
"failed to find = operator for operator %u", opno);
2986 char relpersistence;
3026 elog(
ERROR,
"list of new indexes too short");
3032 elog(
ERROR,
"could not find index matching \"%s\" at the new relation",
3117 relpersistence =
OldHeap->rd_rel->relpersistence;
3142#ifdef USE_ASSERT_CHECKING
3148 for (
int i = 0;
i < 4;
i++)
3319 shared->
done =
false;
3330 shared->
relid = relid;
3343 "REPACK decoding worker for relation \"%s\"",
3359 errmsg(
"out of background worker slots"),
3360 errhint(
"You might need to increase \"%s\".",
"max_worker_processes"));
3416 errmsg(
"postmaster exited during REPACK command"));
3547 "ProcessRepackMessages",
3630 _(
"REPACK decoding worker"));
3642 elog(
ERROR,
"unrecognized message type received from decoding worker: %c (message length %d bytes)",
Datum idx(PG_FUNCTION_ARGS)
AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode)
void pgstat_progress_start_command(ProgressCommandType cmdtype, Oid relid)
void pgstat_progress_incr_param(int index, int64 incr)
void pgstat_progress_update_param(int index, int64 val)
void pgstat_progress_end_command(void)
@ PROGRESS_COMMAND_REPACK
void TerminateBackgroundWorker(BackgroundWorkerHandle *handle)
BgwHandleStatus WaitForBackgroundWorkerShutdown(BackgroundWorkerHandle *handle)
bool RegisterDynamicBackgroundWorker(BackgroundWorker *worker, BackgroundWorkerHandle **handle)
#define BGW_NEVER_RESTART
@ BgWorkerStart_RecoveryFinished
#define BGWORKER_BACKEND_DATABASE_CONNECTION
#define BGWORKER_SHMEM_ACCESS
static Datum values[MAXATTR]
BufFile * BufFileOpenFileSet(FileSet *fileset, const char *name, int mode, bool missing_ok)
void BufFileReadExact(BufFile *file, void *ptr, size_t size)
size_t BufFileReadMaybeEOF(BufFile *file, void *ptr, size_t size, bool eofOK)
void BufFileClose(BufFile *file)
#define RelationGetNumberOfBlocks(reln)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
TransactionId MultiXactId
#define OidIsValid(objectId)
bool IsToastRelation(Relation relation)
bool IsSystemRelation(Relation relation)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
bool IsCatalogRelation(Relation relation)
bool IsSystemClass(Oid relid, Form_pg_class reltuple)
void analyze_rel(Oid relid, RangeVar *relation, const VacuumParams *params, List *va_cols, bool in_outer_xact, BufferAccessStrategy bstrategy)
bool ConditionVariableCancelSleep(void)
void ConditionVariablePrepareToSleep(ConditionVariable *cv)
void ConditionVariableInit(ConditionVariable *cv)
void ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
bool defGetBoolean(DefElem *def)
void performDeletion(const ObjectAddress *object, DropBehavior behavior, int flags)
#define PERFORM_DELETION_INTERNAL
dsm_handle dsm_segment_handle(dsm_segment *seg)
void dsm_detach(dsm_segment *seg)
void * dsm_segment_address(dsm_segment *seg)
dsm_segment * dsm_create(Size size, int flags)
void ThrowErrorData(ErrorData *edata)
int errcode(int sqlerrcode)
int errhint(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
void ExecCloseIndices(ResultRelInfo *resultRelInfo)
List * ExecInsertIndexTuples(ResultRelInfo *resultRelInfo, EState *estate, uint32 flags, TupleTableSlot *slot, List *arbiterIndexes, bool *specConflict)
void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative)
void InitResultRelInfo(ResultRelInfo *resultRelInfo, Relation resultRelationDesc, Index resultRelationIndex, ResultRelInfo *partition_root_rri, int instrument_options)
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
const TupleTableSlotOps TTSOpsVirtual
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
void ExecForceStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
void FreeExecutorState(EState *estate)
EState * CreateExecutorState(void)
#define ResetPerTupleExprContext(estate)
#define GetPerTupleMemoryContext(estate)
#define EIIT_ONLY_SUMMARIZING
#define palloc_object(type)
#define palloc_array(type, count)
#define palloc0_object(type)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
volatile sig_atomic_t InterruptPending
bool allowSystemTableMods
int NewGUCNestLevel(void)
void RestrictSearchPath(void)
void AtEOXact_GUC(bool isCommit, int nestLevel)
void RelationClearMissing(Relation rel)
Oid heap_create_with_catalog(const char *relname, Oid relnamespace, Oid reltablespace, Oid relid, Oid reltypeid, Oid reloftypeid, Oid ownerid, Oid accessmtd, TupleDesc tupdesc, List *cooked_constraints, char relkind, char relpersistence, bool shared_relation, bool mapped_relation, OnCommitAction oncommit, Datum reloptions, bool use_user_acl, bool allow_system_table_mods, bool is_internal, Oid relrewrite, ObjectAddress *typaddress)
HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
void heap_freetuple(HeapTuple htup)
HeapTupleData * HeapTuple
HeapTupleHeaderData * HeapTupleHeader
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
Oid IndexGetRelation(Oid indexId, bool missing_ok)
bool reindex_relation(const ReindexStmt *stmt, Oid relid, int flags, const ReindexParams *params)
Oid index_create_copy(Relation heapRelation, uint16 flags, Oid oldIndexId, Oid tablespaceOid, const char *newName)
#define INDEX_CREATE_SUPPRESS_PROGRESS
#define REINDEX_REL_FORCE_INDEXES_UNLOGGED
#define REINDEX_REL_SUPPRESS_INDEX_USE
#define REINDEX_REL_FORCE_INDEXES_PERMANENT
#define REINDEX_REL_CHECK_CONSTRAINTS
bool index_getnext_slot(IndexScanDesc scan, ScanDirection direction, TupleTableSlot *slot)
IndexScanDesc index_beginscan(Relation heapRelation, Relation indexRelation, Snapshot snapshot, IndexScanInstrumentation *instrument, int nkeys, int norderbys, uint32 flags)
void index_close(Relation relation, LOCKMODE lockmode)
void index_endscan(IndexScanDesc scan)
Relation index_open(Oid relationId, LOCKMODE lockmode)
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
char * ChooseRelationName(const char *name1, const char *name2, const char *label, Oid namespaceid, bool isconstraint)
void CatalogTupleUpdateWithInfo(Relation heapRel, const ItemPointerData *otid, HeapTuple tup, CatalogIndexState indstate)
void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
void CatalogCloseIndexes(CatalogIndexState indstate)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
CatalogIndexState CatalogOpenIndexes(Relation heapRel)
#define INJECTION_POINT(name, arg)
void CacheInvalidateCatalog(Oid catalogId)
void CacheInvalidateRelcacheByTuple(HeapTuple classTuple)
static void ItemPointerSetInvalid(ItemPointerData *pointer)
void SetLatch(Latch *latch)
List * lappend(List *list, void *datum)
List * lappend_oid(List *list, Oid datum)
void list_free(List *list)
bool ConditionalLockRelationOid(Oid relid, LOCKMODE lockmode)
void UnlockRelationOid(Oid relid, LOCKMODE lockmode)
void LockRelationOid(Oid relid, LOCKMODE lockmode)
bool CheckRelationLockedByMe(Relation relation, LOCKMODE lockmode, bool orstronger)
bool CheckRelationOidLockedByMe(Oid relid, LOCKMODE lockmode, bool orstronger)
#define AccessExclusiveLock
#define ShareUpdateExclusiveLock
char * get_rel_name(Oid relid)
char get_rel_relkind(Oid relid)
Oid get_rel_namespace(Oid relid)
RegProcedure get_opcode(Oid opno)
bool get_index_isclustered(Oid index_oid)
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
char * get_namespace_name(Oid nspid)
Oid get_relname_relid(const char *relname, Oid relnamespace)
void MemoryContextReset(MemoryContext context)
char * pstrdup(const char *in)
void pfree(void *pointer)
MemoryContext TopMemoryContext
void MemoryContextDelete(MemoryContext context)
MemoryContext PortalContext
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define RESUME_INTERRUPTS()
#define SECURITY_RESTRICTED_OPERATION
#define CHECK_FOR_INTERRUPTS()
#define HOLD_INTERRUPTS()
void GetUserIdAndSecContext(Oid *userid, int *sec_context)
void SetUserIdAndSecContext(Oid userid, int sec_context)
bool MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2)
#define MultiXactIdIsValid(multi)
#define InvalidMultiXactId
Oid LookupCreationNamespace(const char *nspname)
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
#define InvokeObjectPostAlterHookArg(classId, objectId, subId, auxiliaryId, is_internal)
#define ObjectAddressSet(addr, class_id, object_id)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
int parser_errposition(ParseState *pstate, int location)
@ REPACK_COMMAND_VACUUMFULL
#define ERRCODE_DATA_CORRUPTED
FormData_pg_class * Form_pg_class
END_CATALOG_STRUCT typedef FormData_pg_constraint * Form_pg_constraint
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
long changeDependencyFor(Oid classId, Oid objectId, Oid refClassId, Oid oldRefObjectId, Oid newRefObjectId)
long deleteDependencyRecordsFor(Oid classId, Oid objectId, bool skipExtensionDeps)
END_CATALOG_STRUCT typedef FormData_pg_index * Form_pg_index
List * find_all_inheritors(Oid parentrelId, LOCKMODE lockmode, List **numparents)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
#define foreach_current_index(var_or_cell)
static Oid list_nth_oid(const List *list, int n)
#define foreach_ptr(type, var, lst)
#define foreach_node(type, var, lst)
#define foreach_oid(var, lst)
const char * pg_rusage_show(const PGRUsage *ru0)
void pg_rusage_init(PGRUsage *ru0)
bool plan_cluster_use_sort(Oid tableOid, Oid indexOid)
static Datum PointerGetDatum(const void *X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
static Datum UInt32GetDatum(uint32 X)
void pq_parse_errornotice(StringInfo msg, ErrorData *edata)
void TransferPredicateLocksToHeapRelation(Relation relation)
#define PROGRESS_REPACK_PHASE_CATCH_UP
#define PROGRESS_REPACK_PHASE
#define PROGRESS_REPACK_COMMAND
#define PROGRESS_REPACK_PHASE_SWAP_REL_FILES
#define PROGRESS_REPACK_HEAP_TUPLES_DELETED
#define PROGRESS_REPACK_HEAP_TUPLES_UPDATED
#define PROGRESS_REPACK_PHASE_FINAL_CLEANUP
#define PROGRESS_REPACK_PHASE_REBUILD_INDEX
#define PROGRESS_REPACK_HEAP_TUPLES_INSERTED
#define PqMsg_ErrorResponse
#define PqMsg_NoticeResponse
char * psprintf(const char *fmt,...)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationIsMapped(relation)
#define RelationGetRelationName(relation)
#define RelationIsPopulated(relation)
#define RELATION_IS_OTHER_TEMP(relation)
#define RelationGetNamespace(relation)
List * RelationGetIndexList(Relation relation)
Oid RelationGetReplicaIndex(Relation relation)
void RelationAssumeNewRelfilelocator(Relation relation)
void RelationMapRemoveMapping(Oid relationId)
RelFileNumber RelationMapOidToFilenumber(Oid relationId, bool shared)
void RelationMapUpdateMap(Oid relationId, RelFileNumber fileNumber, bool shared, bool immediate)
#define RelFileNumberIsValid(relnumber)
static bool cluster_rel_recheck(RepackCommand cmd, Relation OldHeap, Oid indexOid, Oid userid, LOCKMODE lmode, int options)
static void restore_tuple(BufFile *file, Relation relation, TupleTableSlot *slot)
static void start_repack_decoding_worker(Oid relid)
static void check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
static List * get_tables_to_repack_partitioned(RepackCommand cmd, Oid relid, bool rel_is_index, MemoryContext permcxt)
void finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap, bool is_system_catalog, bool swap_toast_by_content, bool check_constraints, bool is_internal, bool reindex, TransactionId frozenXid, MultiXactId cutoffMulti, char newrelpersistence)
static Relation process_single_relation(RepackStmt *stmt, LOCKMODE lockmode, bool isTopLevel, ClusterParams *params)
void check_index_is_clusterable(Relation OldHeap, Oid indexOid, LOCKMODE lockmode)
static void release_change_context(ChangeContext *chgcxt)
static bool find_target_tuple(Relation rel, ChangeContext *chgcxt, TupleTableSlot *locator, TupleTableSlot *received)
static bool repack_is_permitted_for_relation(RepackCommand cmd, Oid relid, Oid userid)
void ExecRepack(ParseState *pstate, RepackStmt *stmt, bool isTopLevel)
static void stop_repack_decoding_worker(void)
static LOCKMODE RepackLockLevel(bool concurrent)
static void apply_concurrent_delete(Relation rel, TupleTableSlot *slot)
static void ProcessRepackMessage(StringInfo msg)
volatile sig_atomic_t RepackMessagePending
void cluster_rel(RepackCommand cmd, Relation OldHeap, Oid indexOid, ClusterParams *params, bool isTopLevel)
static List * get_tables_to_repack(RepackCommand cmd, bool usingindex, MemoryContext permcxt)
static const char * RepackCommandAsString(RepackCommand cmd)
void DecodingWorkerFileName(char *fname, Oid relid, uint32 seq)
Oid make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, Oid NewAccessMethod, char relpersistence, LOCKMODE lockmode)
static void initialize_change_context(ChangeContext *chgcxt, Relation relation, Oid ident_index_id)
static void process_concurrent_changes(XLogRecPtr end_of_wal, ChangeContext *chgcxt, bool done)
static void copy_table_data(Relation NewHeap, Relation OldHeap, Relation OldIndex, Snapshot snapshot, bool verbose, bool *pSwapToastByContent, TransactionId *pFreezeXid, MultiXactId *pCutoffMulti)
static void rebuild_relation_finish_concurrent(Relation NewHeap, Relation OldHeap, Oid identIdx, TransactionId frozenXid, MultiXactId cutoffMulti)
static void apply_concurrent_insert(Relation rel, TupleTableSlot *slot, ChangeContext *chgcxt)
static void apply_concurrent_changes(BufFile *file, ChangeContext *chgcxt)
static void rebuild_relation(Relation OldHeap, Relation index, bool verbose, Oid ident_idx)
void HandleRepackMessageInterrupt(void)
static Snapshot get_initial_snapshot(DecodingWorker *worker)
void mark_index_clustered(Relation rel, Oid indexOid, bool is_internal)
static void adjust_toast_pointers(Relation relation, TupleTableSlot *dest, TupleTableSlot *src)
#define WORKER_FILE_SNAPSHOT
static void swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class, bool swap_toast_by_content, bool is_internal, TransactionId frozenXid, MultiXactId cutoffMulti, Oid *mapped_tables)
static Oid determine_clustered_index(Relation rel, bool usingindex, const char *indexname)
void ProcessRepackMessages(void)
static void copy_index_constraints(Relation old_index, Oid new_index_id, Oid new_heap_id)
static void apply_concurrent_update(Relation rel, TupleTableSlot *spilled_tuple, TupleTableSlot *ondisk_tuple, ChangeContext *chgcxt)
static DecodingWorker * decoding_worker
static List * build_new_indexes(Relation NewHeap, Relation OldHeap, List *OldIndexes)
#define CLUOPT_CONCURRENT
#define CLUOPT_RECHECK_ISCLUSTERED
#define CHANGE_UPDATE_OLD
#define CHANGE_UPDATE_NEW
char ConcurrentChangeKind
#define REPACK_ERROR_QUEUE_SIZE
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
void SharedFileSetInit(SharedFileSet *fileset, dsm_segment *seg)
shm_mq * shm_mq_create(void *address, Size size)
void shm_mq_detach(shm_mq_handle *mqh)
void shm_mq_set_receiver(shm_mq *mq, PGPROC *proc)
shm_mq_result shm_mq_receive(shm_mq_handle *mqh, Size *nbytesp, void **datap, bool nowait)
shm_mq_handle * shm_mq_attach(shm_mq *mq, dsm_segment *seg, BackgroundWorkerHandle *handle)
Snapshot GetTransactionSnapshot(void)
void PushActiveSnapshot(Snapshot snapshot)
Snapshot RestoreSnapshot(char *start_address)
void UpdateActiveSnapshotCommandId(void)
void PopActiveSnapshot(void)
Snapshot GetActiveSnapshot(void)
static void SpinLockRelease(volatile slock_t *lock)
static void SpinLockAcquire(volatile slock_t *lock)
static void SpinLockInit(volatile slock_t *lock)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
void BecomeLockGroupLeader(void)
#define BTEqualStrategyNumber
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
void initStringInfo(StringInfo str)
int cc_ident_key_nentries
char error_queue[FLEXIBLE_ARRAY_MEMBER]
ProcNumber backend_proc_number
BackgroundWorkerHandle * handle
shm_mq_handle * error_mqh
TupleDesc tts_tupleDescriptor
TransactionId FreezeLimit
TransactionId relfrozenxid
MultiXactId MultiXactCutoff
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
Datum SysCacheGetAttr(SysCacheIdentifier cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
#define SearchSysCacheCopy1(cacheId, key1)
#define SearchSysCacheExists1(cacheId, key1)
Relation try_table_open(Oid relationId, LOCKMODE lockmode)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
TableScanDesc table_beginscan_catalog(Relation relation, int nkeys, ScanKeyData *key)
const TupleTableSlotOps * table_slot_callbacks(Relation relation)
static void table_endscan(TableScanDesc scan)
#define TABLE_INSERT_NO_LOGICAL
static void table_relation_copy_for_cluster(Relation OldTable, Relation NewTable, Relation OldIndex, bool use_sort, TransactionId OldestXmin, Snapshot snapshot, TransactionId *xid_cutoff, MultiXactId *multi_cutoff, double *num_tuples, double *tups_vacuumed, double *tups_recently_dead)
static void table_tuple_insert(Relation rel, TupleTableSlot *slot, CommandId cid, uint32 options, BulkInsertStateData *bistate)
#define TABLE_DELETE_NO_LOGICAL
#define TABLE_UPDATE_NO_LOGICAL
static TM_Result table_tuple_update(Relation rel, ItemPointer otid, TupleTableSlot *slot, CommandId cid, uint32 options, Snapshot snapshot, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode, TU_UpdateIndexes *update_indexes)
static TM_Result table_tuple_delete(Relation rel, ItemPointer tid, CommandId cid, uint32 options, Snapshot snapshot, Snapshot crosscheck, bool wait, TM_FailureData *tmfd)
void ResetRelRewrite(Oid myrelid)
void CheckTableNotInUse(Relation rel, const char *stmt)
void RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bool is_index)
void RangeVarCallbackMaintainsTable(const RangeVar *relation, Oid relId, Oid oldRelId, void *arg)
Oid toast_get_valid_index(Oid toastoid, LOCKMODE lock)
void NewHeapCreateToastTable(Oid relOid, Datum reloptions, LOCKMODE lockmode, Oid OIDOldToast)
#define InvalidTransactionId
#define TransactionIdIsValid(xid)
#define TransactionIdIsNormal(xid)
static bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)
static void slot_getsomeattrs(TupleTableSlot *slot, int attnum)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
static bool slot_attisnull(TupleTableSlot *slot, int attnum)
bool vacuum_get_cutoffs(Relation rel, const VacuumParams *params, struct VacuumCutoffs *cutoffs)
static bool VARATT_IS_EXTERNAL_ONDISK(const void *PTR)
static Size VARSIZE_ANY(const void *PTR)
static bool VARATT_IS_EXTERNAL_INDIRECT(const void *PTR)
static void SET_VARSIZE(void *PTR, Size len)
void CommandCounterIncrement(void)
void PreventInTransactionBlock(bool isTopLevel, const char *stmtType)
void StartTransactionCommand(void)
void CommitTransactionCommand(void)
CommandId GetCurrentCommandId(bool used)
XLogRecPtr GetFlushRecPtr(TimeLineID *insertTLI)
XLogRecPtr GetXLogInsertEndRecPtr(void)
void XLogFlush(XLogRecPtr record)
#define InvalidXLogRecPtr