提交 ff3474e2 编写于 作者: V Venkatesh Raghavan

Remove unused catalog function gp_partition_*. #132714995

上级 a711280e
......@@ -3194,10 +3194,6 @@ remove_subquery_in_RTEs(Node *node)
}
}
#define GP_PARTITION_SELECTION_OID 6084
#define GP_PARTITION_EXPANSION_OID 6085
#define GP_PARTITION_INVERSE_OID 6086
/*
* Let's evaluate all STABLE functions that have constant args before
* dispatch, so we get a consistent view across QEs
......@@ -3304,18 +3300,6 @@ pre_dispatch_function_evaluation_mutator(Node *node,
return (Node *)newexpr;
}
/*
* Ignored evaluation of gp_partition stable functions.
* TODO: refactor gp_partition stable functions to be truly
* stable
*/
if (funcid == GP_PARTITION_SELECTION_OID
|| funcid == GP_PARTITION_EXPANSION_OID
|| funcid == GP_PARTITION_INVERSE_OID)
{
return (Node *)newexpr;
}
/*
* Here we want to mark any statement that is
* going to use a sequence as dirty. Doing this means that the
......
/*
* gp_partition_functions.c
* Define dynamic partition selection related functions in GPDB.
*
* gp_partition_propagation: This function accumulates unique partition
* oids for a specified dynamic table scan. A dynamic table scan node
* will be executed only after this function is called.
*
* gp_partition_selection: This function finds the child partition of
* a given parent partition oid, which satisfies a given partition
* key value.
*
* gp_partition_expansion: This function finds all child partition oids
* for the given parent oid.
*
* gp_partition_inverse: This function returns all child partitition oids
* with their constarints for a given parent oid.
*
* Copyright(c) 2012 - present, EMC/Greenplum
*/
......@@ -161,110 +144,6 @@ InsertPidIntoDynamicTableScanInfo(int32 index, Oid partOid, int32 selectorId)
MemoryContextSwitchTo(oldCxt);
}
PG_FUNCTION_INFO_V1(gp_partition_propagation);
/*
* gp_partition_propagation
* Insert a partition oid into its pid-index.
*/
Datum
gp_partition_propagation(PG_FUNCTION_ARGS)
{
int32 index = PG_GETARG_INT32(0);
Oid partOid = PG_GETARG_OID(1);
InsertPidIntoDynamicTableScanInfo(index, partOid, InvalidPartitionSelectorId);
PG_RETURN_VOID();
}
PG_FUNCTION_INFO_V1(gp_partition_selection);
/*
* gp_partition_selection
* Find the child partition oid for a given parent partition, which
* satisfies the given partition key value.
*
* This function assumes that there is only one partition key in this level.
*
* If no such a child partition is found, return NULL.
*/
Datum
gp_partition_selection(PG_FUNCTION_ARGS)
{
Oid parentOid = PG_GETARG_OID(0);
Assert(dynamicTableScanInfo != NULL);
Assert(dynamicTableScanInfo->memoryContext != NULL);
if (dynamicTableScanInfo->partsMetadata == NULL)
{
PG_RETURN_NULL();
}
PartitionNode *partsAndRules = NULL;
PartitionAccessMethods *accessMethods = NULL;
findPartitionMetadataEntry(dynamicTableScanInfo->partsMetadata,
parentOid,
&partsAndRules,
&accessMethods);
if (NULL == partsAndRules)
{
PG_RETURN_NULL();
}
Assert(partsAndRules != NULL);
Assert(accessMethods != NULL);
Partition *part = partsAndRules->part;
Assert(part->parnatts == 1);
AttrNumber partAttno = part->paratts[0];
Relation rel = relation_open(parentOid, NoLock);
TupleDesc tupDesc = RelationGetDescr(rel);
Assert(tupDesc->natts >= partAttno);
Datum *values = NULL;
bool *isnull = NULL;
createValueArrays(partAttno, &values, &isnull);
isnull[partAttno - 1] = PG_ARGISNULL(1);
if (!isnull[partAttno - 1])
{
values[partAttno - 1] = PG_GETARG_DATUM(1);
}
/* set the memory context for the access methods */
accessMethods->part_cxt = dynamicTableScanInfo->memoryContext;
MemoryContext oldCxt = MemoryContextSwitchTo(dynamicTableScanInfo->memoryContext);
Oid childOid = selectPartition(partsAndRules,
values,
isnull,
tupDesc,
accessMethods);
MemoryContextSwitchTo(oldCxt);
freeValueArrays(values, isnull);
relation_close(rel, NoLock);
/*
* There might not be a child partition that satisfies the given
* value. In that case, this function returns NULL.
*/
if (OidIsValid(childOid))
{
PG_RETURN_OID(childOid);
}
PG_RETURN_NULL();
}
/*
* PartitionIterator
* Contains the state that are necessary to iterate through all
......@@ -326,158 +205,6 @@ createPartitionIterator(Oid parentOid)
return partitionIterator;
}
PG_FUNCTION_INFO_V1(gp_partition_expansion);
/*
* gp_partition_expansion
* Find all child partition oids for the given parent oid.
*
* This function is a set-returning function, returning a set of
* child oids.
*/
Datum
gp_partition_expansion(PG_FUNCTION_ARGS)
{
FuncCallContext *funcCallContext = NULL;
/*
* Setup the function call context for set-returning functions.
* At the first time of calling this function, we find the partition
* metadata for the given parent oid, and store that in an PartitionIterator
* structure.
*/
if (SRF_IS_FIRSTCALL())
{
funcCallContext = SRF_FIRSTCALL_INIT();
Oid parentOid = PG_GETARG_OID(0);
MemoryContext oldContext = MemoryContextSwitchTo(funcCallContext->multi_call_memory_ctx);
funcCallContext->user_fctx = createPartitionIterator(parentOid);
MemoryContextSwitchTo(oldContext);
}
funcCallContext = SRF_PERCALL_SETUP();
PartitionIterator *partitionIterator = (PartitionIterator *)funcCallContext->user_fctx;
Assert(partitionIterator != NULL);
ListCell *ruleCell = partitionIterator->nextRuleCell;
if (ruleCell != NULL)
{
partitionIterator->nextRuleCell = lnext(ruleCell);
partitionIterator->currentRule = (PartitionRule *)lfirst(ruleCell);
Oid childOid = partitionIterator->currentRule->parchildrelid;
SRF_RETURN_NEXT(funcCallContext, ObjectIdGetDatum(childOid));
}
/*
* Return default partition oid if any.
*/
if (!partitionIterator->defaultPartReturned)
{
Assert(NULL != partitionIterator->partsAndRules);
Assert(NULL != partitionIterator->partsAndRules->default_part);
PartitionRule *defaultPart = partitionIterator->partsAndRules->default_part;
Oid childOid = defaultPart->parchildrelid;
partitionIterator->defaultPartReturned = true;
SRF_RETURN_NEXT(funcCallContext, ObjectIdGetDatum(childOid));
}
pfree(partitionIterator);
SRF_RETURN_DONE(funcCallContext);
}
/*
* createInverseTupleDesc
* Create a tuple descriptor for the record returned by gp_partition_inverse.
*
* The record has the following format:
* Oid: child partition oid
* typeOid: the date type for the low end of a range partition;
* the data type for the value in a list partition
* bool: whether to include the low end of a range partition;
* always true for a list partition
* typeOid: used by range partitions only;
* represents the data type for the high end of a range partition
* bool: used by range partitions only;
* represents whether to include the high end of a range partition.
*/
static TupleDesc
createInverseTupleDesc(Oid typeOid, int32 typeMod)
{
TupleDesc tupleDesc = CreateTemplateTupleDesc(PARTITION_INVERSE_RECORD_NUM_ATTRS, false);
TupleDescInitEntry(tupleDesc, (AttrNumber) PARTITION_INVERSE_RECORD_PARCHILDRELID_ATTNO,
"partchildrelid", OIDOID, -1, 0);
TupleDescInitEntry(tupleDesc, (AttrNumber) PARTITION_INVERSE_RECORD_MINKEY_ATTNO,
"minkey", typeOid, typeMod, 0);
TupleDescInitEntry(tupleDesc, (AttrNumber) PARTITION_INVERSE_RECORD_MININCLUDED_ATTNO,
"minincluded", BOOLOID, -1, 0);
TupleDescInitEntry(tupleDesc, (AttrNumber) PARTITION_INVERSE_RECORD_MAXKEY_ATTNO,
"maxkey", typeOid, typeMod, 0);
TupleDescInitEntry(tupleDesc, (AttrNumber) PARTITION_INVERSE_RECORD_MAXINCLUDED_ATTNO,
"maxincluded", BOOLOID, -1, 0);
return tupleDesc;
}
/*
* InverseContext
* Context data for gp_partition_inverse function.
*
* This is the base structure to maintain context information for
* various partition types.
*/
typedef struct InverseContext InverseContext;
struct InverseContext
{
/*
* The iterator to iterate through all child partitions,
* one at a time.
*/
PartitionIterator *partitionIterator;
/*
* The arrays to hold output record.
*/
Datum values[PARTITION_INVERSE_RECORD_NUM_ATTRS];
bool nulls[PARTITION_INVERSE_RECORD_NUM_ATTRS];
/*
* The pointer to the function that produces the next output record.
* The function returns false when no record is found. Otherwise, this
* function returns true.
*/
bool (*findNextRecord)(InverseContext *inverseContext);
};
/*
* InverseContextForRange
* Context data for gp_partition_inverse function on range partitions.
*/
typedef InverseContext InverseContextForRange;
/*
* InverseContextForList
* Context data for gp_partition_inverse function on list partitions.
*/
typedef struct InverseContextForList
{
InverseContext context;
/*
* The cell for the next value in a list partition.
*/
ListCell *listValueCell;
}InverseContextForList;
/*
* setInverseRecordForRange
* Set the record value array for the inverse function on a range partition, based
......@@ -614,174 +341,7 @@ setInverseRecordForDefaultPart(PartitionRule *rule,
nulls[PARTITION_INVERSE_RECORD_PARCHILDRELID_ATTNO - 1] = false;
}
/*
* findNextRecordForRange
* Find the next return record for range partitions in gp_partition_inverse() calls,
* and store the record in the given values/nulls array pair.
*
* This function returns false when no record is found. Otherwise, this function
* returns true.
*/
static bool
findNextRecordForRange(InverseContext *inverseContext)
{
Assert(inverseContext != NULL &&
inverseContext->partitionIterator);
PartitionIterator *partitionIterator = inverseContext->partitionIterator;
bool hasNext = false;
ListCell *ruleCell = partitionIterator->nextRuleCell;
if (ruleCell != NULL)
{
partitionIterator->nextRuleCell = lnext(ruleCell);
partitionIterator->currentRule = (PartitionRule *)lfirst(ruleCell);
setInverseRecordForRange(partitionIterator->currentRule,
inverseContext->values,
inverseContext->nulls,
PARTITION_INVERSE_RECORD_NUM_ATTRS);
hasNext = true;
}
/* Return the default partition if any. */
else if (!partitionIterator->defaultPartReturned)
{
Assert(NULL != partitionIterator->partsAndRules);
Assert(NULL != partitionIterator->partsAndRules->default_part);
PartitionRule *defaultPart = partitionIterator->partsAndRules->default_part;
setInverseRecordForDefaultPart(defaultPart,
inverseContext->values,
inverseContext->nulls,
PARTITION_INVERSE_RECORD_NUM_ATTRS);
partitionIterator->defaultPartReturned = true;
hasNext = true;
}
return hasNext;
}
/*
* findNextRecordForList
* Find the next return record for list partitions in gp_partition_inverse() calls,
* and store it into the values/nulls array pair.
*
* This function returns false when no record is found. Otherwise, this function
* returns true.
*/
static bool
findNextRecordForList(InverseContext *inverseContext)
{
Assert(inverseContext != NULL);
PartitionIterator *partitionIterator = inverseContext->partitionIterator;
Assert(partitionIterator != NULL);
InverseContextForList *contextForList = (InverseContextForList *)inverseContext;
bool hasNext = false;
/*
* There might be multiple values for the same partition. Each call to
* gp_partition_inverse() will produce a record containing one such value.
*/
if (contextForList->listValueCell != NULL)
{
ListCell *currentListValueCell = contextForList->listValueCell;
contextForList->listValueCell = lnext(contextForList->listValueCell);
setInverseRecordForList(partitionIterator->currentRule, currentListValueCell,
inverseContext->values, inverseContext->nulls,
PARTITION_INVERSE_RECORD_NUM_ATTRS);
hasNext = true;
}
/*
* After processing all values in a partition, if there are more partitions
* left, process the next one.
*/
else if (partitionIterator->nextRuleCell != NULL)
{
ListCell *ruleCell = partitionIterator->nextRuleCell;
partitionIterator->nextRuleCell = lnext(ruleCell);
partitionIterator->currentRule = (PartitionRule *)lfirst(ruleCell);
Assert(partitionIterator->currentRule->parlistvalues != NULL);
ListCell *currentListValueCell = list_head(partitionIterator->currentRule->parlistvalues);
contextForList->listValueCell = lnext(currentListValueCell);
setInverseRecordForList(partitionIterator->currentRule, currentListValueCell,
inverseContext->values, inverseContext->nulls,
PARTITION_INVERSE_RECORD_NUM_ATTRS);
hasNext = true;
}
/* Return the default partition if any. */
else if (!partitionIterator->defaultPartReturned)
{
Assert(NULL != partitionIterator->partsAndRules);
Assert(NULL != partitionIterator->partsAndRules->default_part);
PartitionRule *defaultPart = partitionIterator->partsAndRules->default_part;
setInverseRecordForDefaultPart(defaultPart,
inverseContext->values,
inverseContext->nulls,
PARTITION_INVERSE_RECORD_NUM_ATTRS);
partitionIterator->defaultPartReturned = true;
hasNext = true;
}
return hasNext;
}
/*
* createInverseContext
* Create the context for gp_partition_inverse for a given parent oid.
*/
static InverseContext*
createInverseContext(Oid parentOid)
{
InverseContext *inverseContext = NULL;
PartitionIterator *partitionIterator = createPartitionIterator(parentOid);
Assert(NULL != partitionIterator->partsAndRules);
Assert(NULL != partitionIterator->partsAndRules->part);
switch(partitionIterator->partsAndRules->part->parkind)
{
case 'r':
inverseContext = palloc(sizeof(InverseContextForRange));
inverseContext->partitionIterator = partitionIterator;
inverseContext->findNextRecord = findNextRecordForRange;
break;
case 'l':
inverseContext = palloc(sizeof(InverseContextForList));
inverseContext->partitionIterator = partitionIterator;
inverseContext->findNextRecord = findNextRecordForList;
((InverseContextForList *)inverseContext)->listValueCell = NULL;
break;
default:
elog(ERROR, "partitioning kind '%c' not allowed",
partitionIterator->partsAndRules->part->parkind);
}
return inverseContext;
}
/*
* freeInverseContext
* Free the context for gp_partition_inverse.
*/
static void
freeInverseContext(InverseContext *inverseContext)
{
Assert(inverseContext != NULL);
pfree(inverseContext->partitionIterator);
pfree(inverseContext);
}
/*
* findPartitionKeyType
* Find the type oid and typeMod for the given partition key.
......@@ -803,73 +363,6 @@ findPartitionKeyType(Oid parentOid,
relation_close(rel, NoLock);
}
/*
* gp_partition_inverse
* Returns all child partition oids with their constraints for a given parent oid.
*
* Currently, this function assumes that the parent partition is the root partition.
*
* This function is a set-returning function.
*/
Datum
gp_partition_inverse(PG_FUNCTION_ARGS)
{
FuncCallContext *funcCallContext = NULL;
InverseContext *inverseContext = NULL;
/*
* Setup the function call context for set-returning functions.
* At the first time of calling this function, we create and initialize
* necessary context data in inverseContext, such as finding the partition
* metadata for the given parent oid.
*/
if (SRF_IS_FIRSTCALL())
{
funcCallContext = SRF_FIRSTCALL_INIT();
Oid parentOid = PG_GETARG_OID(0);
MemoryContext oldContext = MemoryContextSwitchTo(funcCallContext->multi_call_memory_ctx);
funcCallContext->user_fctx = createInverseContext(parentOid);
inverseContext = (InverseContext *)funcCallContext->user_fctx;
Assert(NULL != inverseContext);
Assert(NULL != inverseContext->partitionIterator);
Assert(NULL != inverseContext->partitionIterator->partsAndRules);
Partition *part = inverseContext->partitionIterator->partsAndRules->part;
Assert(NULL != part);
Oid typeOid = 0;
int32 typeMod = 0;
findPartitionKeyType(parentOid, part->paratts[0], &typeOid, &typeMod);
TupleDesc tupleDesc = createInverseTupleDesc(typeOid, typeMod);
funcCallContext->tuple_desc = BlessTupleDesc(tupleDesc);
MemoryContextSwitchTo(oldContext);
}
funcCallContext = SRF_PERCALL_SETUP();
inverseContext = (InverseContext *)funcCallContext->user_fctx;
Assert(inverseContext != NULL &&
inverseContext->partitionIterator != NULL);
if (inverseContext->findNextRecord(inverseContext))
{
HeapTuple tuple = heap_form_tuple(funcCallContext->tuple_desc,
inverseContext->values,
inverseContext->nulls);
Datum result = HeapTupleGetDatum(tuple);
SRF_RETURN_NEXT(funcCallContext, result);
}
freeInverseContext(inverseContext);
SRF_RETURN_DONE(funcCallContext);
}
/*
* dumpDynamicTableScanPidIndex
* Write out pids for a given dynamic table scan.
......
......@@ -25,16 +25,6 @@
#include "optimizer/clauses.h"
#include "parser/parsetree.h"
/*
* OIDs of partition functions that we mark as non-memory intensive.
* TODO caragg 03/04/2014: Revert these changes when ORCA has the new partition
* operator (MPP-22799)
*/
#define GP_PARTITION_PROPAGATION_OID 6083
#define GP_PARTITION_SELECTION_OID 6084
#define GP_PARTITION_EXPANSION_OID 6085
#define GP_PARTITION_INVERSE_OID 6086
/**
* Policy Auto. This contains information that will be used by Policy AUTO
*/
......@@ -234,16 +224,6 @@ IsBlockingOperator(Node *node)
static bool
isMemoryIntensiveFunction(Oid funcid)
{
if ((GP_PARTITION_PROPAGATION_OID == funcid) ||
(GP_PARTITION_SELECTION_OID == funcid) ||
(GP_PARTITION_EXPANSION_OID == funcid) ||
(GP_PARTITION_INVERSE_OID == funcid))
{
return false;
}
return true;
}
......
......@@ -56,6 +56,6 @@
*/
/* 3yyymmddN */
#define CATALOG_VERSION_NO 301610201
#define CATALOG_VERSION_NO 301610211
#endif
......@@ -1752,14 +1752,6 @@ CREATE FUNCTION gp_nondbspecific_ptcat_verification() RETURNS bool LANGUAGE inte
CREATE FUNCTION lead_lag_frame_maker(internal) RETURNS internal LANGUAGE internal VOLATILE STRICT AS 'lead_lag_frame_maker' WITH (OID=5081);
CREATE FUNCTION gp_partition_propagation(int4, oid) RETURNS void LANGUAGE internal VOLATILE STRICT AS 'gp_partition_propagation' WITH (OID=6083, DESCRIPTION="inserts a partition oid into specified pid-index");
CREATE FUNCTION gp_partition_selection(oid, anyelement) RETURNS oid LANGUAGE internal STABLE STRICT AS 'gp_partition_selection' WITH (OID=6084, DESCRIPTION="selects the child partition oid which satisfies a given partition key value");
CREATE FUNCTION gp_partition_expansion(oid) RETURNS setof oid LANGUAGE internal STABLE STRICT AS 'gp_partition_expansion' WITH (OID=6085, DESCRIPTION="finds all child partition oids for the given parent oid");
CREATE FUNCTION gp_partition_inverse(oid) RETURNS setof record LANGUAGE internal STABLE STRICT AS 'gp_partition_inverse' WITH (OID=6086, DESCRIPTION="returns all child partitition oids with their constraints for a given parent oid");
CREATE FUNCTION disable_xform(text) RETURNS text LANGUAGE internal IMMUTABLE STRICT AS 'disable_xform' WITH (OID=6087, DESCRIPTION="disables transformations in the optimizer");
CREATE FUNCTION enable_xform(text) RETURNS text LANGUAGE internal IMMUTABLE STRICT AS 'enable_xform' WITH (OID=6088, DESCRIPTION="enables transformations in the optimizer");
......
......@@ -2897,22 +2897,6 @@ DESCR("linear interpolation: x, x0,y0, x1,y1");
/* lead_lag_frame_maker(internal) => internal */
DATA(insert OID = 5081 ( lead_lag_frame_maker PGNSP PGUID 12 1 0 0 f f t f v 1 0 2281 f "2281" _null_ _null_ _null_ _null_ lead_lag_frame_maker _null_ _null_ _null_ n ));
/* gp_partition_propagation(int4, oid) => void */
DATA(insert OID = 6083 ( gp_partition_propagation PGNSP PGUID 12 1 0 0 f f t f v 2 0 2278 f "23 26" _null_ _null_ _null_ _null_ gp_partition_propagation _null_ _null_ _null_ n ));
DESCR("inserts a partition oid into specified pid-index");
/* gp_partition_selection(oid, anyelement) => oid */
DATA(insert OID = 6084 ( gp_partition_selection PGNSP PGUID 12 1 0 0 f f t f s 2 0 26 f "26 2283" _null_ _null_ _null_ _null_ gp_partition_selection _null_ _null_ _null_ n ));
DESCR("selects the child partition oid which satisfies a given partition key value");
/* gp_partition_expansion(oid) => setof oid */
DATA(insert OID = 6085 ( gp_partition_expansion PGNSP PGUID 12 1 1000 0 f f t t s 1 0 26 f "26" _null_ _null_ _null_ _null_ gp_partition_expansion _null_ _null_ _null_ n ));
DESCR("finds all child partition oids for the given parent oid");
/* gp_partition_inverse(oid) => setof record */
DATA(insert OID = 6086 ( gp_partition_inverse PGNSP PGUID 12 1 1000 0 f f t t s 1 0 2249 f "26" _null_ _null_ _null_ _null_ gp_partition_inverse _null_ _null_ _null_ n ));
DESCR("returns all child partitition oids with their constraints for a given parent oid");
/* disable_xform(text) => text */
DATA(insert OID = 6087 ( disable_xform PGNSP PGUID 12 1 0 0 f f t f i 1 0 25 f "25" _null_ _null_ _null_ _null_ disable_xform _null_ _null_ _null_ n ));
DESCR("disables transformations in the optimizer");
......
......@@ -1252,11 +1252,7 @@ extern Datum percentile_disc_trans(PG_FUNCTION_ARGS);
/* utils/workfile_manager/workfile_mgr_test.c */
extern Datum gp_workfile_mgr_test_harness(PG_FUNCTION_ARGS);
/* gp_partition_funtions.c */
extern Datum gp_partition_propagation(PG_FUNCTION_ARGS);
extern void dumpDynamicTableScanPidIndex(int index);
extern Datum gp_partition_selection(PG_FUNCTION_ARGS);
extern Datum gp_partition_expansion(PG_FUNCTION_ARGS);
extern Datum gp_partition_inverse(PG_FUNCTION_ARGS);
/* XForms */
extern Datum disable_xform(PG_FUNCTION_ARGS);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册