提交 bcc8fbd6 编写于 作者: G Gang Xiong

Move slice related functions to execUtils.c

上级 49a50cfe
......@@ -15,6 +15,7 @@
#include "cdb/cdbexplain.h" /* me */
#include "cdb/cdbpartition.h"
#include "cdb/cdbvars.h" /* Gp_segment */
#include "executor/execUtils.h"
#include "executor/executor.h" /* ExecStateTreeWalker */
#include "executor/instrument.h" /* Instrumentation */
#include "lib/stringinfo.h" /* StringInfo */
......@@ -23,7 +24,6 @@
#include "libpq/pqformat.h" /* pq_beginmessage() etc. */
#include "utils/memutils.h" /* MemoryContextGetPeakSpace() */
#include "cdb/memquota.h"
#include "cdb/cdbgang.h"
#include "inttypes.h"
#include "utils/vmem_tracker.h"
#include "parser/parsetree.h"
......
......@@ -2221,82 +2221,3 @@ int largestGangsize(void)
{
return largest_gangsize;
}
#ifdef USE_ASSERT_CHECKING
/**
* Assert that slicetable is valid. Must be called after ExecInitMotion, which sets up the slice table
*/
void AssertSliceTableIsValid(SliceTable *st, struct PlannedStmt *pstmt)
{
if (!st)
return;
Assert(pstmt);
Assert(pstmt->nMotionNodes == st->nMotions);
Assert(pstmt->nInitPlans == st->nInitPlans);
ListCell *lc = NULL;
int i = 0;
int maxIndex = st->nMotions + st->nInitPlans + 1;
Assert(maxIndex == list_length(st->slices));
foreach (lc, st->slices)
{
Slice *s = (Slice *) lfirst(lc);
/* The n-th slice entry has sliceIndex of n */
Assert(s->sliceIndex == i++ && "slice index incorrect");
/* The root index of a slice is either 0 or is a slice corresponding to an init plan */
Assert((s->rootIndex == 0) || (s->rootIndex > st->nMotions && s->rootIndex < maxIndex));
/* Parent slice index */
if (s->sliceIndex == s->rootIndex)
{
/* Current slice is a root slice. It will have parent index -1.*/
Assert(s->parentIndex == -1 && "expecting parent index of -1");
}
else
{
/* All other slices must have a valid parent index */
Assert(s->parentIndex >= 0 && s->parentIndex < maxIndex && "slice's parent index out of range");
}
/* Current slice's children must consider it the parent */
ListCell *lc1 = NULL;
foreach (lc1, s->children)
{
int childIndex = lfirst_int(lc1);
Assert(childIndex >= 0 && childIndex < maxIndex && "invalid child slice");
Slice *sc = (Slice *) list_nth(st->slices, childIndex);
Assert(sc->parentIndex == s->sliceIndex && "slice's child does not consider it the parent");
}
/* Current slice must be in its parent's children list */
if (s->parentIndex >= 0)
{
Slice *sp = (Slice *) list_nth(st->slices, s->parentIndex);
bool found = false;
foreach (lc1, sp->children)
{
int childIndex = lfirst_int(lc1);
Assert(childIndex >= 0 && childIndex < maxIndex && "invalid child slice");
Slice *sc = (Slice *) list_nth(st->slices, childIndex);
if (sc->sliceIndex == s->sliceIndex)
{
found = true;
break;
}
}
Assert(found && "slice's parent does not consider it a child");
}
}
}
#endif
......@@ -20,6 +20,7 @@
#include "commands/explain.h"
#include "commands/prepare.h"
#include "commands/trigger.h"
#include "executor/execUtils.h"
#include "executor/instrument.h"
#include "nodes/pg_list.h"
#include "nodes/print.h"
......@@ -44,7 +45,6 @@
#include "cdb/cdbpathlocus.h"
#include "cdb/memquota.h"
#include "miscadmin.h"
#include "cdb/cdbgang.h"
#ifdef USE_ORCA
extern char *SzDXLPlan(Query *parse);
......
......@@ -57,6 +57,7 @@
#include "commands/trigger.h"
#include "executor/execDML.h"
#include "executor/execdebug.h"
#include "executor/execUtils.h"
#include "executor/instrument.h"
#include "executor/nodeSubplan.h"
#include "libpq/pqformat.h"
......@@ -93,7 +94,6 @@
#include "cdb/ml_ipc.h"
#include "cdb/cdbmotion.h"
#include "cdb/cdbtm.h"
#include "cdb/cdbgang.h"
#include "cdb/cdboidsync.h"
#include "cdb/cdbmirroredbufferpool.h"
#include "cdb/cdbpersistentstore.h"
......
......@@ -48,6 +48,7 @@
#include "access/appendonlywriter.h"
#include "catalog/index.h"
#include "executor/execdebug.h"
#include "executor/execUtils.h"
#include "parser/parsetree.h"
#include "utils/memutils.h"
#include "utils/relcache.h"
......@@ -58,7 +59,6 @@
#include "nodes/execnodes.h"
#include "cdb/cdbutil.h"
#include "cdb/cdbgang.h"
#include "cdb/cdbvars.h"
#include "cdb/cdbdisp_query.h"
#include "cdb/cdbdispatchresult.h"
......@@ -2448,3 +2448,81 @@ int RootSliceIndex(EState *estate)
return result;
}
#ifdef USE_ASSERT_CHECKING
/**
* Assert that slicetable is valid. Must be called after ExecInitMotion, which sets up the slice table
*/
void AssertSliceTableIsValid(SliceTable *st, struct PlannedStmt *pstmt)
{
if (!st)
return;
Assert(pstmt);
Assert(pstmt->nMotionNodes == st->nMotions);
Assert(pstmt->nInitPlans == st->nInitPlans);
ListCell *lc = NULL;
int i = 0;
int maxIndex = st->nMotions + st->nInitPlans + 1;
Assert(maxIndex == list_length(st->slices));
foreach (lc, st->slices)
{
Slice *s = (Slice *) lfirst(lc);
/* The n-th slice entry has sliceIndex of n */
Assert(s->sliceIndex == i++ && "slice index incorrect");
/* The root index of a slice is either 0 or is a slice corresponding to an init plan */
Assert((s->rootIndex == 0) || (s->rootIndex > st->nMotions && s->rootIndex < maxIndex));
/* Parent slice index */
if (s->sliceIndex == s->rootIndex)
{
/* Current slice is a root slice. It will have parent index -1.*/
Assert(s->parentIndex == -1 && "expecting parent index of -1");
}
else
{
/* All other slices must have a valid parent index */
Assert(s->parentIndex >= 0 && s->parentIndex < maxIndex && "slice's parent index out of range");
}
/* Current slice's children must consider it the parent */
ListCell *lc1 = NULL;
foreach (lc1, s->children)
{
int childIndex = lfirst_int(lc1);
Assert(childIndex >= 0 && childIndex < maxIndex && "invalid child slice");
Slice *sc = (Slice *) list_nth(st->slices, childIndex);
Assert(sc->parentIndex == s->sliceIndex && "slice's child does not consider it the parent");
}
/* Current slice must be in its parent's children list */
if (s->parentIndex >= 0)
{
Slice *sp = (Slice *) list_nth(st->slices, s->parentIndex);
bool found = false;
foreach (lc1, sp->children)
{
int childIndex = lfirst_int(lc1);
Assert(childIndex >= 0 && childIndex < maxIndex && "invalid child slice");
Slice *sc = (Slice *) list_nth(st->slices, childIndex);
if (sc->sliceIndex == s->sliceIndex)
{
found = true;
break;
}
}
Assert(found && "slice's parent does not consider it a child");
}
}
}
#endif
......@@ -153,20 +153,6 @@ typedef struct CdbProcess
int contentid;
} CdbProcess;
extern void InitSliceTable(struct EState *estate, int nMotions, int nSubplans);
extern Slice *getCurrentSlice(struct EState *estate, int sliceIndex);
extern bool sliceRunsOnQD(Slice *slice);
extern bool sliceRunsOnQE(Slice *slice);
extern int sliceCalculateNumSendingProcesses(Slice *slice);
extern void InitRootSlices(QueryDesc *queryDesc);
extern void AssignGangs(QueryDesc *queryDesc);
extern void ReleaseGangs(QueryDesc *queryDesc);
#ifdef USE_ASSERT_CHECKING
struct PlannedStmt;
extern void AssertSliceTableIsValid(SliceTable *st, struct PlannedStmt *pstmt);
#endif
#endif /* _CDBGANG_H_ */
/*-------------------------------------------------------------------------
*
* execUtils.h
*
* Copyright (c) 2005-2008, Greenplum inc
*
*-------------------------------------------------------------------------
*/
#ifndef _EXECUTILS_H_
#define _EXECUTILS_H_
#include "executor/execdesc.h"
struct EState;
struct QueryDesc;
extern void InitSliceTable(struct EState *estate, int nMotions, int nSubplans);
extern Slice *getCurrentSlice(struct EState *estate, int sliceIndex);
extern bool sliceRunsOnQD(Slice *slice);
extern bool sliceRunsOnQE(Slice *slice);
extern int sliceCalculateNumSendingProcesses(Slice *slice);
extern void InitRootSlices(QueryDesc *queryDesc);
extern void AssignGangs(QueryDesc *queryDesc);
extern void ReleaseGangs(QueryDesc *queryDesc);
#ifdef USE_ASSERT_CHECKING
struct PlannedStmt;
extern void AssertSliceTableIsValid(SliceTable *st, struct PlannedStmt *pstmt);
#endif
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册