change_h4reindexconcurrently

This commit is contained in:
jiajunchang 2021-11-25 19:03:30 +08:00
parent e654bc313b
commit 1c3940ee3a
3 changed files with 44 additions and 6 deletions

View File

@ -213,6 +213,7 @@ typedef enum ObjectClass {
#define PERFORM_DELETION_INVALID 0x0000
#define PERFORM_DELETION_INTERNAL 0x0001
#define PERFORM_DELETION_CONCURRENTLY 0x0002
#define PERFORM_DELETION_CONCURRENTLY_LOCK 0x0020 /* normal drop with concurrent lock mode */
/* ObjectAddressExtra flag bits */
#define DEPFLAG_ORIGINAL 0x0001 /* an original deletion target */
@ -294,6 +295,9 @@ extern long changeDependencyFor(Oid classId,
Oid oldRefObjectId,
Oid newRefObjectId);
/*use for reindex concurrently*/
extern long changeDependenciesOn(Oid refClassId,Oid oldRefObjectId,Oid newRefObjectId);
extern Oid getExtensionOfObject(Oid classId, Oid objectId);
extern bool sequenceIsOwned(Oid seqId, Oid *tableId, int32 *colId);
@ -306,6 +310,9 @@ extern Oid get_constraint_index(Oid constraintId);
extern Oid get_index_constraint(Oid indexId);
/* use for reindex concurrently */
extern List *get_index_ref_constraints(Oid indexId);
/* in pg_shdepend.c */
extern void recordSharedDependencyOn(ObjectAddress *depender,
ObjectAddress *referenced,

View File

@ -125,12 +125,36 @@ extern Oid index_create(Relation heapRelation, const char *indexRelationName, Oi
IndexCreateExtraArgs *extra, bool useLowLockLevel = false,
int8 relindexsplit = 0);
/* ues for reindex concurrently*/
extern Oid index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId, const char *newName);
/* use for reindex concurrently*/
extern void index_concurrently_build(Oid heapRelationId, Oid indexRelationId, bool isPrimary, AdaptMem* memInfo = NULL, bool dbWide = false);
/* use for reindex concurrently*/
extern void index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName);
/* use for reindex concurrently*/
extern void index_concurrently_set_dead(Oid heapId, Oid indexId);
/* use for reindex concurrently partition */
extern Oid index_concurrently_part_create_copy(Oid oldIndexPartId, const char *newName);
/* use for reindex concurrently partition */
extern void index_concurrently_part_build(Oid heapRelationId, Oid heapPartitionId, Oid indexRelationId, Oid IndexPartitionId, AdaptMem* memInfo = NULL, bool dbWide = false);
/* use for reindex concurrently partition */
extern void index_concurrently_part_swap(Relation indexRelation, Oid newIndexPartId, Oid oldIndexPartId, const char *oldName);
extern void index_constraint_create(Relation heapRelation, Oid indexRelationId, IndexInfo *indexInfo,
const char *constraintName, char constraintType, bool deferrable,
bool initdeferred, bool mark_as_primary, bool update_pgindex,
bool remove_old_dependencies, bool allow_system_table_mods);
extern void index_drop(Oid indexId, bool concurrent);
/* change input: add concurrent_lock_mode */
extern void index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode = false);
extern IndexInfo *BuildIndexInfo(Relation index);
extern IndexInfo *BuildDummyIndexInfo(Relation index);
@ -173,7 +197,7 @@ extern double IndexBuildVectorBatchScan(Relation heapRelation, Relation indexRel
void *transferFuncs);
extern void validate_index(Oid heapId, Oid indexId, Snapshot snapshot);
extern void validate_index(Oid heapId, Oid indexId, Snapshot snapshot, bool isPart = false);
extern void validate_index_heapscan(
Relation heapRelation, Relation indexRelation, IndexInfo* indexInfo, Snapshot snapshot, v_i_state* state);
@ -201,6 +225,9 @@ extern bool ReindexIsProcessingHeap(Oid heapOid);
extern bool ReindexIsProcessingIndex(Oid indexOid);
extern Oid IndexGetRelation(Oid indexId, bool missing_ok);
extern Oid PartIndexGetPartition(Oid partIndexId, bool missing_ok);
extern Oid PartIdGetParentId(Oid partIndexId, bool missing_ok);
typedef struct
{
Oid existingPSortOid;
@ -232,6 +259,7 @@ extern void PartitionNameCallbackForIndexPartition(Oid partitionedRelationOid,
LOCKMODE callbackobj_lockMode);
extern void reindex_partIndex(Relation heapRel, Partition heapPart, Relation indexRel , Partition indexPart);
extern bool reindexPartition(Oid relid, Oid partOid, int flags, int reindexType);
extern Oid heapPartitionIdGetindexPartitionId(Oid indexId, Oid partOid);
extern void AddGPIForPartition(Oid partTableOid, Oid partOid);
void AddCBIForPartition(Relation partTableRel, Relation tempTableRel, const List* indexRelList,
const List* indexDestOidList);

View File

@ -23,11 +23,14 @@ extern void RemoveObjects(DropStmt* stmt, bool missing_ok, bool is_securityadmin
/* commands/indexcmds.c */
extern Oid DefineIndex(Oid relationId, IndexStmt* stmt, Oid indexRelationId, bool is_alter_table, bool check_rights,
bool skip_build, bool quiet);
extern void ReindexIndex(RangeVar* indexRelation, const char* partition_name, AdaptMem* mem_info);
extern void ReindexTable(RangeVar* relation, const char* partition_name, AdaptMem* mem_info);
extern void ReindexInternal(RangeVar* relation, const char* partition_name);
extern void ReindexDatabase(const char* databaseName, bool do_system, bool do_user, AdaptMem* mem_info);
/*add input for reindex concurrently*/
extern void ReindexIndex(RangeVar* indexRelation, const char* partition_name, AdaptMem* mem_info, bool concurrent);
extern void ReindexTable(RangeVar* relation, const char* partition_name, AdaptMem* mem_info, bool concurrent);
extern void ReindexInternal(RangeVar* relation, const char* partition_name, bool concurrent);
/*add input for reindex concurrently */
extern void ReindexDatabase(const char* databaseName, bool do_system, bool do_user, AdaptMem* mem_info, bool concurrent);
extern char* makeObjectName(const char* name1, const char* name2, const char* label, bool reverseTruncate = false);
extern char* ChooseRelationName(
const char* name1, const char* name2, const char* label, size_t labelLength, Oid namespaceid,