code for Global-Partition-Index feature
Signed-off-by: xiliu <xiliu_h@163.com>
This commit is contained in:
@ -51,9 +51,11 @@ typedef struct UtilityDesc {
|
||||
* entries for a particular index. Used for both index_build and
|
||||
* retail creation of index entries.
|
||||
*
|
||||
* NumIndexAttrs number of columns in this index
|
||||
* NumIndexAttrs total number of columns in this index
|
||||
* NumIndexKeyAttrs number of key columns in index
|
||||
* KeyAttrNumbers underlying-rel attribute numbers used as keys
|
||||
* (zeroes indicate expressions)
|
||||
* (zeroes indicate expressions). It also contains
|
||||
* info about included columns.
|
||||
* Expressions expr trees for expression entries, or NIL if none
|
||||
* ExpressionsState exec state for expressions, or NIL if none
|
||||
* Predicate partial-index predicate, or NIL if none
|
||||
@ -75,7 +77,8 @@ typedef struct UtilityDesc {
|
||||
*/
|
||||
typedef struct IndexInfo {
|
||||
NodeTag type;
|
||||
int ii_NumIndexAttrs;
|
||||
int ii_NumIndexAttrs; /* total number of columns in index */
|
||||
int ii_NumIndexKeyAttrs; /* number of key columns in index */
|
||||
AttrNumber ii_KeyAttrNumbers[INDEX_MAX_KEYS];
|
||||
List* ii_Expressions; /* list of Expr */
|
||||
List* ii_ExpressionsState; /* list of ExprState */
|
||||
@ -391,6 +394,7 @@ typedef struct MergeState {
|
||||
* RangeTableIndex result relation's range table index
|
||||
* RelationDesc relation descriptor for result relation
|
||||
* NumIndices # of indices existing on result relation
|
||||
* ri_ContainGPI indices whether contain global parition index
|
||||
* IndexRelationDescs array of relation descriptors for indices
|
||||
* IndexRelationInfo array of key/attr info for indices
|
||||
* TrigDesc triggers to be fired, if any
|
||||
@ -410,6 +414,7 @@ typedef struct ResultRelInfo {
|
||||
Index ri_RangeTableIndex;
|
||||
Relation ri_RelationDesc;
|
||||
int ri_NumIndices;
|
||||
bool ri_ContainGPI;
|
||||
RelationPtr ri_IndexRelationDescs;
|
||||
IndexInfo** ri_IndexRelationInfo;
|
||||
TriggerDesc* ri_TrigDesc;
|
||||
@ -1696,6 +1701,7 @@ typedef struct BitmapHeapScanState {
|
||||
TBMIterator* prefetch_iterator;
|
||||
int prefetch_pages;
|
||||
int prefetch_target;
|
||||
GPIScanDesc gpi_scan; /* global partition index scan use information */
|
||||
} BitmapHeapScanState;
|
||||
|
||||
/* ----------------
|
||||
@ -2451,6 +2457,16 @@ TupleTableSlot* ExecMakeTupleSlot(HeapTuple tuple, HeapScanDesc heapScan, TupleT
|
||||
return ExecClearTuple(slot);
|
||||
}
|
||||
|
||||
/*
|
||||
* When the global partition index is used for bitmap scanning,
|
||||
* checks whether the partition table needs to be
|
||||
* switched each time an tbmres is obtained.
|
||||
*/
|
||||
inline bool BitmapNodeNeedSwitchPartRel(BitmapHeapScanState* node)
|
||||
{
|
||||
return tbm_is_global(node->tbm) && GPIScanCheckPartOid(node->gpi_scan, node->tbmres->partitionOid);
|
||||
}
|
||||
|
||||
extern bool reset_scan_qual(Relation currHeapRel, ScanState *node);
|
||||
|
||||
#endif /* EXECNODES_H */
|
||||
|
||||
@ -2028,7 +2028,8 @@ typedef struct Constraint {
|
||||
char* cooked_expr; /* expr, as nodeToString representation */
|
||||
|
||||
/* Fields used for unique constraints (UNIQUE and PRIMARY KEY) or cluster partial key for colstore: */
|
||||
List* keys; /* String nodes naming referenced column(s) */
|
||||
List* keys; /* String nodes naming referenced key column(s) */
|
||||
List* including; /* String nodes naming referenced nonkey column(s) */
|
||||
|
||||
/* Fields used for EXCLUSION constraints: */
|
||||
List* exclusions; /* list of (IndexElem, operator name) pairs */
|
||||
@ -2598,6 +2599,7 @@ typedef struct IndexStmt {
|
||||
char* accessMethod; /* name of access method (eg. btree) */
|
||||
char* tableSpace; /* tablespace, or NULL for default */
|
||||
List* indexParams; /* columns to index: a list of IndexElem */
|
||||
List* indexIncludingParams; /* additional columns to index: a list of IndexElem */
|
||||
List* options; /* WITH clause options: a list of DefElem */
|
||||
Node* whereClause; /* qualification (partial-index predicate) */
|
||||
List* excludeOpNames; /* exclusion operator names, or NIL if none */
|
||||
@ -2614,6 +2616,7 @@ typedef struct IndexStmt {
|
||||
* value is false when relation is a foreign table.
|
||||
*/
|
||||
bool isPartitioned;
|
||||
bool isGlobal; /* is GLOBAL partition index */
|
||||
bool unique; /* is index unique? */
|
||||
bool primary; /* is index a primary key? */
|
||||
bool isconstraint; /* is it for a pkey/unique constraint? */
|
||||
|
||||
@ -664,6 +664,7 @@ typedef struct IndexOptInfo {
|
||||
|
||||
/* index descriptor information */
|
||||
int ncolumns; /* number of columns in index */
|
||||
int nkeycolumns; /* number of key columns in index */
|
||||
int* indexkeys; /* column numbers of index's keys, or 0 */
|
||||
Oid* indexcollations; /* OIDs of collations of index columns */
|
||||
Oid* opfamily; /* OIDs of operator families for columns */
|
||||
@ -680,6 +681,7 @@ typedef struct IndexOptInfo {
|
||||
|
||||
List* indextlist; /* targetlist representing index columns */
|
||||
|
||||
bool isGlobal; /* true if index is global partition index */
|
||||
bool predOK; /* true if predicate matches query */
|
||||
bool unique; /* true if a unique index */
|
||||
bool immediate; /* is uniqueness enforced immediately? */
|
||||
|
||||
@ -36,6 +36,7 @@ typedef struct TBMIterator TBMIterator;
|
||||
/* Result structure for tbm_iterate */
|
||||
typedef struct {
|
||||
BlockNumber blockno; /* page number containing tuples */
|
||||
Oid partitionOid;
|
||||
int ntuples; /* -1 indicates lossy result */
|
||||
bool recheck; /* should the tuples be rechecked? */
|
||||
/* Note: recheck is always true if ntuples < 0 */
|
||||
@ -46,7 +47,8 @@ typedef struct {
|
||||
extern TIDBitmap* tbm_create(long maxbytes);
|
||||
extern void tbm_free(TIDBitmap* tbm);
|
||||
|
||||
extern void tbm_add_tuples(TIDBitmap* tbm, const ItemPointer tids, int ntids, bool recheck);
|
||||
extern void tbm_add_tuples(
|
||||
TIDBitmap* tbm, const ItemPointer tids, int ntids, bool recheck, Oid partitionOid = InvalidOid);
|
||||
extern void tbm_add_page(TIDBitmap* tbm, BlockNumber pageno);
|
||||
|
||||
extern void tbm_union(TIDBitmap* a, const TIDBitmap* b);
|
||||
@ -57,5 +59,6 @@ extern bool tbm_is_empty(const TIDBitmap* tbm);
|
||||
extern TBMIterator* tbm_begin_iterate(TIDBitmap* tbm);
|
||||
extern TBMIterateResult* tbm_iterate(TBMIterator* iterator);
|
||||
extern void tbm_end_iterate(TBMIterator* iterator);
|
||||
|
||||
extern bool tbm_is_global(const TIDBitmap* tbm);
|
||||
extern void tbm_set_global(TIDBitmap* tbm, bool isGlobal);
|
||||
#endif /* TIDBITMAP_H */
|
||||
|
||||
Reference in New Issue
Block a user