77 lines
2.6 KiB
C
Executable File
77 lines
2.6 KiB
C
Executable File
/*
|
|
* Copyright (c) 2020 Huawei Technologies Co.,Ltd.
|
|
*
|
|
* openGauss is licensed under Mulan PSL v2.
|
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
* You may obtain a copy of Mulan PSL v2 at:
|
|
*
|
|
* http://license.coscl.org.cn/MulanPSL2
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
* See the Mulan PSL v2 for more details.
|
|
* ---------------------------------------------------------------------------------------
|
|
*
|
|
* pruning.h
|
|
*
|
|
*
|
|
*
|
|
* IDENTIFICATION
|
|
* src/include/optimizer/pruning.h
|
|
*
|
|
* ---------------------------------------------------------------------------------------
|
|
*/
|
|
|
|
#ifndef PRUNING_H_
|
|
#define PRUNING_H_
|
|
|
|
#include "nodes/parsenodes.h"
|
|
#include "nodes/relation.h"
|
|
#include "utils/partitionmap.h"
|
|
#include "utils/partitionmap_gs.h"
|
|
#include "utils/relcache.h"
|
|
|
|
typedef struct PruningContext {
|
|
PlannerInfo* root;
|
|
RangeTblEntry* rte;
|
|
Relation relation;
|
|
} PruningContext;
|
|
|
|
typedef enum PartKeyColumnRangeMode {
|
|
PARTKEY_RANGE_MODE_POINT = 0,
|
|
PARTKEY_RANGE_MODE_INCREASE,
|
|
PARTKEY_RANGE_MODE_RANGE,
|
|
PARTKEY_RANGE_MODE_UNION
|
|
} PartKeyColumnRangeMode;
|
|
|
|
typedef enum IndexesUsableType {
|
|
INDEXES_FULL_USABLE = 0,
|
|
INDEXES_PARTIAL_USABLE,
|
|
INDEXES_NONE_USABLE
|
|
} IndexesUsableType;
|
|
|
|
typedef struct PartKeyColumnRange {
|
|
PartKeyColumnRangeMode mode;
|
|
Const* prev;
|
|
Const* next;
|
|
} PartKeyColumnRange;
|
|
|
|
typedef struct PartKeyRange {
|
|
int num;
|
|
PartKeyColumnRange columnRanges[4];
|
|
} PartKeyRange;
|
|
extern IndexesUsableType eliminate_partition_index_unusable(Oid IndexOid, PruningResult* inputPruningResult,
|
|
PruningResult** indexUsablePruningResult, PruningResult** indexUnusablePruningResult);
|
|
PruningResult* getFullPruningResult(Relation relation);
|
|
PruningResult* partitionPruningForExpr(PlannerInfo* root, RangeTblEntry* rte, Relation rel, Expr* expr);
|
|
PruningResult* partitionPruningForRestrictInfo(
|
|
PlannerInfo* root, RangeTblEntry* rte, Relation rel, List* restrictInfoList);
|
|
PruningResult* singlePartitionPruningForRestrictInfo(Oid partitionOid, Relation rel);
|
|
extern PruningResult* copyPruningResult(PruningResult* srcPruningResult);
|
|
extern Oid getPartitionOidFromSequence(Relation relation, int partSeq);
|
|
extern int varIsInPartitionKey(int attrNo, int2vector* partKeyAttrs, int partKeyNum);
|
|
extern bool checkPartitionIndexUnusable(Oid indexOid, int partItrs, PruningResult* pruning_result);
|
|
|
|
#endif /* PRUNING_H_ */
|