提交 b7683d6d 编写于 作者: D Daniel Gustafsson

Remove unused functions and typedefs

Commit ff3474e2 which removed the gp_partition_* catalog functions
left some auxiliary code behind which is now unused. Remove the now
dead functions and while in there, put back the filename in the file
headercomment to match other files.
上级 81bdc15c
/*
* gp_partition_functions.c
*
* Copyright(c) 2012 - present, EMC/Greenplum
*/
......@@ -16,13 +18,6 @@
#include "utils/elog.h"
#include "utils/guc.h"
#define PARTITION_INVERSE_RECORD_NUM_ATTRS 5
#define PARTITION_INVERSE_RECORD_PARCHILDRELID_ATTNO 1
#define PARTITION_INVERSE_RECORD_MINKEY_ATTNO 2
#define PARTITION_INVERSE_RECORD_MININCLUDED_ATTNO 3
#define PARTITION_INVERSE_RECORD_MAXKEY_ATTNO 4
#define PARTITION_INVERSE_RECORD_MAXINCLUDED_ATTNO 5
/*
* increaseScanArraySize
* Increase the array size for dynamic table scans.
......@@ -144,225 +139,6 @@ InsertPidIntoDynamicTableScanInfo(int32 index, Oid partOid, int32 selectorId)
MemoryContextSwitchTo(oldCxt);
}
/*
* PartitionIterator
* Contains the state that are necessary to iterate through all
* child partitions, one at a time.
*
* This is used by set-returning partition functions.
*/
typedef struct PartitionIterator
{
PartitionNode *partsAndRules;
/*
* The cell to the next PartitionRule.
*/
ListCell *nextRuleCell;
/*
* The current child partition that is being processed.
*/
PartitionRule *currentRule;
/*
* Indicate whether the information about the default partition
* has been returned.
*/
bool defaultPartReturned;
} PartitionIterator;
/*
* createPartitionIterator
* create a new PartitionIterator object for a given parent oid.
*
* The metadata information for the given parent oid is found in
* dynamicTableScanInfo.
*/
static PartitionIterator *
createPartitionIterator(Oid parentOid)
{
PartitionIterator *partitionIterator = palloc(sizeof(PartitionIterator));
PartitionAccessMethods *accessMethods = NULL;
findPartitionMetadataEntry(dynamicTableScanInfo->partsMetadata,
parentOid,
&(partitionIterator->partsAndRules),
&accessMethods);
partitionIterator->currentRule = NULL;
partitionIterator->nextRuleCell = NULL;
Assert(NULL != partitionIterator->partsAndRules);
partitionIterator->nextRuleCell = list_head(partitionIterator->partsAndRules->rules);
partitionIterator->defaultPartReturned = true;
if (NULL != partitionIterator->partsAndRules->default_part)
{
partitionIterator->defaultPartReturned = false;
}
return partitionIterator;
}
/*
* setInverseRecordForRange
* Set the record value array for the inverse function on a range partition, based
* on the given partition rule.
*
* This function does not handle the default partition.
*
* Range partitions can be of the form:
*
* (-inf ,e], (-inf, e), (s, e), [s, e], (s,e], [s,e), (s,inf),
* and [s, inf).
*/
static void
setInverseRecordForRange(PartitionRule *rule,
Datum *values,
bool *nulls,
int numAttrs)
{
Assert(numAttrs == PARTITION_INVERSE_RECORD_NUM_ATTRS);
Assert(rule != NULL);
/* Default partitions should not be handled here. */
Assert(!rule->parisdefault);
MemSet(nulls, true, sizeof(bool) * PARTITION_INVERSE_RECORD_NUM_ATTRS);
MemSet(values, 0, sizeof(Datum) * PARTITION_INVERSE_RECORD_NUM_ATTRS);
if (NULL != rule->parrangestart)
{
Assert(IsA(rule->parrangestart, List) &&
list_length((List *)rule->parrangestart) == 1);
Node *rangeStart = (Node *)linitial((List *)rule->parrangestart);
Assert(IsA(rangeStart, Const));
Const *rangeStartConst = (Const *)rangeStart;
values[PARTITION_INVERSE_RECORD_MINKEY_ATTNO - 1] = rangeStartConst->constvalue;
nulls[PARTITION_INVERSE_RECORD_MINKEY_ATTNO - 1] = rangeStartConst->constisnull;
values[PARTITION_INVERSE_RECORD_MININCLUDED_ATTNO - 1] = BoolGetDatum(rule->parrangestartincl);
nulls[PARTITION_INVERSE_RECORD_MININCLUDED_ATTNO - 1] = false;
}
if (NULL != rule->parrangeend)
{
Assert(IsA(rule->parrangeend, List) &&
list_length((List *)rule->parrangeend) == 1);
Node *rangeEnd = (Node *)linitial((List *)rule->parrangeend);
Assert(IsA(rangeEnd, Const));
Const *rangeEndConst = (Const *)rangeEnd;
values[PARTITION_INVERSE_RECORD_MAXKEY_ATTNO - 1] = rangeEndConst->constvalue;
nulls[PARTITION_INVERSE_RECORD_MAXKEY_ATTNO - 1] = rangeEndConst->constisnull;
values[PARTITION_INVERSE_RECORD_MAXINCLUDED_ATTNO - 1] = BoolGetDatum(rule->parrangeendincl);
nulls[PARTITION_INVERSE_RECORD_MAXKEY_ATTNO - 1] = false;
}
values[PARTITION_INVERSE_RECORD_PARCHILDRELID_ATTNO - 1] = ObjectIdGetDatum(rule->parchildrelid);
nulls[PARTITION_INVERSE_RECORD_PARCHILDRELID_ATTNO - 1] = false;
}
/*
* setInverseRecordForList
* Set the record value array for the inverse function on a list partition, based
* on the given partition rule.
*
* This function only supports single-column partition key in the partition level.
*/
static void
setInverseRecordForList(PartitionRule *rule,
ListCell *listValueCell,
Datum *values,
bool *nulls,
int numAttrs)
{
Assert(numAttrs == PARTITION_INVERSE_RECORD_NUM_ATTRS);
Assert(rule != NULL &&
rule->parlistvalues != NULL &&
listValueCell != NULL);
/*
* Note that in partition rule, list values are stored in a list of lists to support
* multi-column partitions.
*/
List *listValue = (List *)lfirst(listValueCell);
/* This function only supports single-column partition key. */
Assert(list_length(listValue) == 1);
Const *listValueConst = (Const *)linitial(listValue);
Assert(IsA(listValueConst, Const));
values[PARTITION_INVERSE_RECORD_PARCHILDRELID_ATTNO - 1] = ObjectIdGetDatum(rule->parchildrelid);
nulls[PARTITION_INVERSE_RECORD_PARCHILDRELID_ATTNO - 1] = false;
values[PARTITION_INVERSE_RECORD_MINKEY_ATTNO - 1] = listValueConst->constvalue;
nulls[PARTITION_INVERSE_RECORD_MINKEY_ATTNO - 1] = listValueConst->constisnull;
values[PARTITION_INVERSE_RECORD_MININCLUDED_ATTNO - 1] = BoolGetDatum(true);
nulls[PARTITION_INVERSE_RECORD_MININCLUDED_ATTNO - 1] = false;
values[PARTITION_INVERSE_RECORD_MAXKEY_ATTNO - 1] = listValueConst->constvalue;
nulls[PARTITION_INVERSE_RECORD_MAXKEY_ATTNO - 1] = false;
values[PARTITION_INVERSE_RECORD_MAXINCLUDED_ATTNO - 1] = BoolGetDatum(true);
nulls[PARTITION_INVERSE_RECORD_MAXINCLUDED_ATTNO - 1] = false;
}
/*
* setInverseRecordForDefaultPart
* Set the record value array for the inverse function on both range and list default partitions.
*
* The default partition does not contain any constraint information,
* this function simple returns the default partition oid with null values on other
* columns in the return record.
*/
static void
setInverseRecordForDefaultPart(PartitionRule *rule,
Datum *values,
bool *nulls,
int numAttrs)
{
Assert(numAttrs == PARTITION_INVERSE_RECORD_NUM_ATTRS);
Assert(rule != NULL &&
((rule->parrangestart == NULL &&
rule->parrangeend == NULL) ||
(rule->parlistvalues == NULL)));
MemSet(nulls, true, sizeof(bool) * PARTITION_INVERSE_RECORD_NUM_ATTRS);
MemSet(values, 0, sizeof(Datum) * PARTITION_INVERSE_RECORD_NUM_ATTRS);
values[PARTITION_INVERSE_RECORD_PARCHILDRELID_ATTNO - 1] = ObjectIdGetDatum(rule->parchildrelid);
nulls[PARTITION_INVERSE_RECORD_PARCHILDRELID_ATTNO - 1] = false;
}
/*
* findPartitionKeyType
* Find the type oid and typeMod for the given partition key.
*/
static void
findPartitionKeyType(Oid parentOid,
int keyAttNo,
Oid *typeOid,
int32 *typeMod)
{
Relation rel = relation_open(parentOid, NoLock);
TupleDesc tupDesc = RelationGetDescr(rel);
Assert(tupDesc->natts >= keyAttNo);
*typeOid = tupDesc->attrs[keyAttNo - 1]->atttypid;
*typeMod = tupDesc->attrs[keyAttNo - 1]->atttypmod;
relation_close(rel, NoLock);
}
/*
* dumpDynamicTableScanPidIndex
* Write out pids for a given dynamic table scan.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册