code for Global-Partition-Index feature

Signed-off-by: xiliu <xiliu_h@163.com>
This commit is contained in:
xiliu
2020-08-25 15:10:14 +08:00
parent 339cd59f26
commit c040d78287
157 changed files with 12502 additions and 939 deletions

View File

@ -83,5 +83,20 @@ void releaseDummyRelation(Relation* relation);
extern void PartitionSetNewRelfilenode(Relation parent, Partition part, TransactionId freezeXid);
/*
* Routines for global partition index open partition
*/
extern PartStatus PartitionGetMetadataStatus(Oid partOid, bool vacuumFlag);
extern Datum SetWaitCleanGpiRelOptions(Datum oldOptions, bool enable);
extern void PartitionedSetWaitCleanGpi(const char* parentName, Oid parentPartOid, bool enable, bool inplace);
extern void PartitionSetWaitCleanGpi(Oid partOid, bool enable, bool inplace);
extern bool PartitionInvisibleMetadataKeep(Datum datumRelOptions);
extern void PartitionedSetEnabledClean(Oid parentOid);
extern void PartitionSetEnabledClean(
Oid parentOid, const Bitmapset* cleanedParts, const Bitmapset* invisibleParts, bool updatePartitioned);
extern void PartitionSetAllEnabledClean(Oid parentOid);
extern void PartitionGetAllInvisibleParts(Oid parentOid, Bitmapset** invisibleParts);
extern bool PartitionMetadataDisabledClean(Relation pgPartition);
#endif /* RELCACHE_H */

16
src/include/utils/rel.h Normal file → Executable file
View File

@ -154,6 +154,7 @@ typedef struct RelationData {
bytea* rd_options; /* parsed pg_class.reloptions */
/* These are non-NULL only for an index relation: */
Oid rd_partHeapOid; /* partition index's partition oid */
Form_pg_index rd_index; /* pg_index tuple describing this index */
/* use "struct" here to avoid needing to include htup.h: */
struct HeapTupleData* rd_indextuple; /* all of pg_index tuple */
@ -302,6 +303,7 @@ typedef struct StdRdOptions {
char* ttl; /* time to live for tsdb data management */
char* period; /* partition range for tsdb data management */
char* version;
char* wait_clean_gpi; /* pg_partition system catalog wait gpi-clean or not */
/* item for online expand */
char* append_mode;
char* start_ctid_internal;
@ -388,10 +390,22 @@ typedef struct StdRdOptions {
/*
* RelationGetNumberOfAttributes
* Returns the number of attributes in a relation.
* Returns the total number of attributes in a relation.
*/
#define RelationGetNumberOfAttributes(relation) ((relation)->rd_rel->relnatts)
/*
* IndexRelationGetNumberOfAttributes
* Returns the number of attributes in an index.
*/
#define IndexRelationGetNumberOfAttributes(relation) ((relation)->rd_index->indnatts)
/*
* IndexRelationGetNumberOfKeyAttributes
* Returns the number of key attributes in an index.
*/
#define IndexRelationGetNumberOfKeyAttributes(relation) ((relation)->rd_index->indnkeyatts)
/*
* RelationGetDescr
* Returns tuple descriptor for a relation.

View File

@ -171,6 +171,9 @@ typedef struct RelationMetaData {
#define OptIgnoreEnableHadoopEnv "ignore_enable_hadoop_env"
#define OptEnabledWaitCleanGpi "y"
#define OptDisabledWaitCleanGpi "n"
#define INTERNAL_MASK_DISABLE 0x0
#define INTERNAL_MASK_ENABLE 0x8000
#define INTERNAL_MASK_DINSERT 0x01 // disable insert
@ -329,6 +332,12 @@ static inline RedisHtlAction RelationGetAppendMode(Relation rel)
RelationGetMaxBatchRows(relation))) \
: RelDefaultPartialClusterRows)
/* Relation whether create in current xact */
static inline bool RelationCreateInCurrXact(Relation rel)
{
return rel->rd_createSubid != InvalidTransactionId;
}
/* RelationGetPgClassOid
* return the pg_class OID of this relation.
* if this is a PARTITION, return its parent oid;
@ -445,7 +454,9 @@ extern void PartitionDecrementReferenceCount(Partition part);
#define RelationIsUnlogged(relation) ((relation)->rd_rel->relnamespace == RELPERSISTENCE_UNLOGGED)
#define RelationIsIndex(relation) (RELKIND_INDEX == (relation)->rd_rel->relkind)
#define RelationIsGlobalIndex(relation) (RELKIND_GLOBAL_INDEX == (relation)->rd_rel->relkind)
#define RelationIsIndex(relation) (RELKIND_INDEX == (relation)->rd_rel->relkind || RelationIsGlobalIndex(relation))
#define RelationIsSequnce(relation) (RELKIND_SEQUENCE == (relation)->rd_rel->relkind)
@ -569,6 +580,33 @@ static inline bool IsCompressedByCmprsInPgclass(const RelCompressType cmprInPgcl
#define RelationGetRelMergeList(relation) \
StdRdOptionsGetStringData((relation)->rd_options, merge_list, NULL)
#define ParitionGetWaitCleanGpi(partition) StdRdOptionsGetStringData((partition)->rd_options, wait_clean_gpi, OptDisabledWaitCleanGpi)
#define RelationGetWaitCleanGpi(relation) StdRdOptionsGetStringData((relation)->rd_options, wait_clean_gpi, OptDisabledWaitCleanGpi)
/* Partition get reloptions whether have wait_clean_gpi for parition */
static inline bool PartitionEnableWaitCleanGpi(Partition partition)
{
if (PointerIsValid(partition) && partition->rd_options != NULL) {
if (pg_strcasecmp(OptEnabledWaitCleanGpi, ParitionGetWaitCleanGpi(partition)) == 0) {
return true;
}
}
return false;
}
/* Relation get reloptions whether have wait_clean_gpi for relation */
static inline bool RelationEnableWaitCleanGpi(Relation relation)
{
if (PointerIsValid(relation) && relation->rd_options != NULL) {
if (pg_strcasecmp(OptEnabledWaitCleanGpi, RelationGetWaitCleanGpi(relation)) == 0) {
return true;
}
}
return false;
}
/* routines in utils/cache/relcache.c */
extern bool RelationIsDfsStore(Relation relatioin);
extern bool RelationIsPaxFormatByOid(Oid relid);

View File

@ -16,6 +16,7 @@
#include "access/tupdesc.h"
#include "nodes/bitmapset.h"
#include "utils/hsearch.h"
typedef struct RelationData* Relation;
typedef struct PartitionData* Partition;
@ -51,6 +52,7 @@ extern void RelationClose(Relation relation);
*/
extern List* PartitionGetPartIndexList(Partition part);
extern List* RelationGetIndexList(Relation relation);
extern List* RelationGetSpecificKindIndexList(Relation relation, bool isGlobal);
extern List* RelationGetIndexInfoList(Relation relation);
extern int RelationGetIndexNum(Relation relation);
extern Oid RelationGetOidIndex(Relation relation);
@ -67,6 +69,13 @@ typedef enum IndexAttrBitmapKind {
INDEX_ATTR_BITMAP_IDENTITY_KEY
} IndexAttrBitmapKind;
typedef enum PartitionMetadataStatus {
PART_METADATA_NOEXIST, /* partition is not exists */
PART_METADATA_LIVE, /* partition is live, normal use */
PART_METADATA_CREATING, /* partition is being created */
PART_METADATA_INVISIBLE /* partition is invisible, being droped */
} PartStatus;
extern Bitmapset* RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind keyAttrs);
extern void RelationGetExclusionInfo(Relation indexRelation, Oid** operators, Oid** procs, uint16** strategies);