mirror of https://github.com/citusdata/citus.git
beginning on using linker for dist ops collection
parent
d5433400f9
commit
fa6f2ed382
|
@ -22,13 +22,18 @@ static DistributeObjectOps NoDistributeOps = {
|
||||||
.postprocess = NULL,
|
.postprocess = NULL,
|
||||||
.address = NULL,
|
.address = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static DistributeObjectOps Aggregate_AlterObjectSchema = {
|
static DistributeObjectOps Aggregate_AlterObjectSchema = {
|
||||||
|
.statementTag = T_AlterObjectSchemaStmt,
|
||||||
|
.subObjectType = OBJECT_AGGREGATE,
|
||||||
|
|
||||||
.deparse = DeparseAlterFunctionSchemaStmt,
|
.deparse = DeparseAlterFunctionSchemaStmt,
|
||||||
.qualify = QualifyAlterFunctionSchemaStmt,
|
.qualify = QualifyAlterFunctionSchemaStmt,
|
||||||
.preprocess = PreprocessAlterFunctionSchemaStmt,
|
.preprocess = PreprocessAlterFunctionSchemaStmt,
|
||||||
.postprocess = PostprocessAlterFunctionSchemaStmt,
|
.postprocess = PostprocessAlterFunctionSchemaStmt,
|
||||||
.address = AlterFunctionSchemaStmtObjectAddress,
|
.address = AlterFunctionSchemaStmtObjectAddress,
|
||||||
};
|
};
|
||||||
|
|
||||||
static DistributeObjectOps Aggregate_AlterOwner = {
|
static DistributeObjectOps Aggregate_AlterOwner = {
|
||||||
.deparse = DeparseAlterFunctionOwnerStmt,
|
.deparse = DeparseAlterFunctionOwnerStmt,
|
||||||
.qualify = QualifyAlterFunctionOwnerStmt,
|
.qualify = QualifyAlterFunctionOwnerStmt,
|
||||||
|
@ -57,97 +62,150 @@ static DistributeObjectOps Aggregate_Rename = {
|
||||||
.postprocess = NULL,
|
.postprocess = NULL,
|
||||||
.address = RenameFunctionStmtObjectAddress,
|
.address = RenameFunctionStmtObjectAddress,
|
||||||
};
|
};
|
||||||
|
|
||||||
static DistributeObjectOps Any_AlterEnum = {
|
static DistributeObjectOps Any_AlterEnum = {
|
||||||
|
.statementTag = T_AlterEnumStmt,
|
||||||
|
|
||||||
.deparse = DeparseAlterEnumStmt,
|
.deparse = DeparseAlterEnumStmt,
|
||||||
.qualify = QualifyAlterEnumStmt,
|
.qualify = QualifyAlterEnumStmt,
|
||||||
.preprocess = PreprocessAlterEnumStmt,
|
.preprocess = PreprocessAlterEnumStmt,
|
||||||
.postprocess = PostprocessAlterEnumStmt,
|
.postprocess = PostprocessAlterEnumStmt,
|
||||||
.address = AlterEnumStmtObjectAddress,
|
.address = AlterEnumStmtObjectAddress,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_AlterEnum);
|
||||||
|
|
||||||
static DistributeObjectOps Any_AlterExtension = {
|
static DistributeObjectOps Any_AlterExtension = {
|
||||||
|
.statementTag = T_AlterExtensionStmt,
|
||||||
|
|
||||||
.deparse = DeparseAlterExtensionStmt,
|
.deparse = DeparseAlterExtensionStmt,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
.preprocess = PreprocessAlterExtensionUpdateStmt,
|
.preprocess = PreprocessAlterExtensionUpdateStmt,
|
||||||
.postprocess = NULL,
|
.postprocess = NULL,
|
||||||
.address = AlterExtensionUpdateStmtObjectAddress,
|
.address = AlterExtensionUpdateStmtObjectAddress,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_AlterExtension);
|
||||||
|
|
||||||
static DistributeObjectOps Any_AlterExtensionContents = {
|
static DistributeObjectOps Any_AlterExtensionContents = {
|
||||||
|
.statementTag = T_AlterExtensionContentsStmt,
|
||||||
|
|
||||||
.deparse = NULL,
|
.deparse = NULL,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
.preprocess = PreprocessAlterExtensionContentsStmt,
|
.preprocess = PreprocessAlterExtensionContentsStmt,
|
||||||
.postprocess = NULL,
|
.postprocess = NULL,
|
||||||
.address = NULL,
|
.address = NULL,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_AlterExtensionContents);
|
||||||
|
|
||||||
static DistributeObjectOps Any_AlterFunction = {
|
static DistributeObjectOps Any_AlterFunction = {
|
||||||
|
.statementTag = T_AlterFunctionStmt,
|
||||||
|
|
||||||
.deparse = DeparseAlterFunctionStmt,
|
.deparse = DeparseAlterFunctionStmt,
|
||||||
.qualify = QualifyAlterFunctionStmt,
|
.qualify = QualifyAlterFunctionStmt,
|
||||||
.preprocess = PreprocessAlterFunctionStmt,
|
.preprocess = PreprocessAlterFunctionStmt,
|
||||||
.postprocess = NULL,
|
.postprocess = NULL,
|
||||||
.address = AlterFunctionStmtObjectAddress,
|
.address = AlterFunctionStmtObjectAddress,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_AlterFunction);
|
||||||
|
|
||||||
static DistributeObjectOps Any_AlterPolicy = {
|
static DistributeObjectOps Any_AlterPolicy = {
|
||||||
|
.statementTag = T_AlterPolicyStmt,
|
||||||
|
|
||||||
.deparse = NULL,
|
.deparse = NULL,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
.preprocess = PreprocessAlterPolicyStmt,
|
.preprocess = PreprocessAlterPolicyStmt,
|
||||||
.postprocess = NULL,
|
.postprocess = NULL,
|
||||||
.address = NULL,
|
.address = NULL,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_AlterPolicy);
|
||||||
|
|
||||||
static DistributeObjectOps Any_AlterRole = {
|
static DistributeObjectOps Any_AlterRole = {
|
||||||
|
.statementTag = T_AlterRoleStmt,
|
||||||
|
|
||||||
.deparse = DeparseAlterRoleStmt,
|
.deparse = DeparseAlterRoleStmt,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
.preprocess = NULL,
|
.preprocess = NULL,
|
||||||
.postprocess = PostprocessAlterRoleStmt,
|
.postprocess = PostprocessAlterRoleStmt,
|
||||||
.address = NULL,
|
.address = NULL,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_AlterRole);
|
||||||
|
|
||||||
static DistributeObjectOps Any_AlterTableMoveAll = {
|
static DistributeObjectOps Any_AlterTableMoveAll = {
|
||||||
|
.statementTag = T_AlterTableMoveAllStmt,
|
||||||
|
|
||||||
.deparse = NULL,
|
.deparse = NULL,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
.preprocess = PreprocessAlterTableMoveAllStmt,
|
.preprocess = PreprocessAlterTableMoveAllStmt,
|
||||||
.postprocess = NULL,
|
.postprocess = NULL,
|
||||||
.address = NULL,
|
.address = NULL,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_AlterTableMoveAll);
|
||||||
|
|
||||||
static DistributeObjectOps Any_Cluster = {
|
static DistributeObjectOps Any_Cluster = {
|
||||||
|
.statementTag = T_ClusterStmt,
|
||||||
|
|
||||||
.deparse = NULL,
|
.deparse = NULL,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
.preprocess = PreprocessClusterStmt,
|
.preprocess = PreprocessClusterStmt,
|
||||||
.postprocess = NULL,
|
.postprocess = NULL,
|
||||||
.address = NULL,
|
.address = NULL,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_Cluster);
|
||||||
|
|
||||||
static DistributeObjectOps Any_CompositeType = {
|
static DistributeObjectOps Any_CompositeType = {
|
||||||
|
.statementTag = T_CompositeTypeStmt,
|
||||||
|
|
||||||
.deparse = DeparseCompositeTypeStmt,
|
.deparse = DeparseCompositeTypeStmt,
|
||||||
.qualify = QualifyCompositeTypeStmt,
|
.qualify = QualifyCompositeTypeStmt,
|
||||||
.preprocess = PreprocessCompositeTypeStmt,
|
.preprocess = PreprocessCompositeTypeStmt,
|
||||||
.postprocess = PostprocessCompositeTypeStmt,
|
.postprocess = PostprocessCompositeTypeStmt,
|
||||||
.address = CompositeTypeStmtObjectAddress,
|
.address = CompositeTypeStmtObjectAddress,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_CompositeType);
|
||||||
|
|
||||||
static DistributeObjectOps Any_CreateEnum = {
|
static DistributeObjectOps Any_CreateEnum = {
|
||||||
|
.statementTag = T_CreateEnumStmt,
|
||||||
|
|
||||||
.deparse = DeparseCreateEnumStmt,
|
.deparse = DeparseCreateEnumStmt,
|
||||||
.qualify = QualifyCreateEnumStmt,
|
.qualify = QualifyCreateEnumStmt,
|
||||||
.preprocess = PreprocessCreateEnumStmt,
|
.preprocess = PreprocessCreateEnumStmt,
|
||||||
.postprocess = PostprocessCreateEnumStmt,
|
.postprocess = PostprocessCreateEnumStmt,
|
||||||
.address = CreateEnumStmtObjectAddress,
|
.address = CreateEnumStmtObjectAddress,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_CreateEnum);
|
||||||
|
|
||||||
static DistributeObjectOps Any_CreateExtension = {
|
static DistributeObjectOps Any_CreateExtension = {
|
||||||
|
.statementTag = T_CreateExtensionStmt,
|
||||||
|
|
||||||
.deparse = DeparseCreateExtensionStmt,
|
.deparse = DeparseCreateExtensionStmt,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
.preprocess = NULL,
|
.preprocess = NULL,
|
||||||
.postprocess = PostprocessCreateExtensionStmt,
|
.postprocess = PostprocessCreateExtensionStmt,
|
||||||
.address = CreateExtensionStmtObjectAddress,
|
.address = CreateExtensionStmtObjectAddress,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_CreateExtension);
|
||||||
|
|
||||||
static DistributeObjectOps Any_CreateFunction = {
|
static DistributeObjectOps Any_CreateFunction = {
|
||||||
|
.statementTag = T_CreateFunctionStmt,
|
||||||
|
|
||||||
.deparse = NULL,
|
.deparse = NULL,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
.preprocess = PreprocessCreateFunctionStmt,
|
.preprocess = PreprocessCreateFunctionStmt,
|
||||||
.postprocess = PostprocessCreateFunctionStmt,
|
.postprocess = PostprocessCreateFunctionStmt,
|
||||||
.address = CreateFunctionStmtObjectAddress,
|
.address = CreateFunctionStmtObjectAddress,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_CreateFunction);
|
||||||
|
|
||||||
static DistributeObjectOps Any_CreatePolicy = {
|
static DistributeObjectOps Any_CreatePolicy = {
|
||||||
|
.statementTag = T_CreatePolicyStmt,
|
||||||
|
|
||||||
.deparse = NULL,
|
.deparse = NULL,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
.preprocess = PreprocessCreatePolicyStmt,
|
.preprocess = PreprocessCreatePolicyStmt,
|
||||||
.postprocess = NULL,
|
.postprocess = NULL,
|
||||||
.address = NULL,
|
.address = NULL,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_CreatePolicy);
|
||||||
|
|
||||||
static DistributeObjectOps Any_Grant = {
|
static DistributeObjectOps Any_Grant = {
|
||||||
.deparse = NULL,
|
.deparse = NULL,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
|
@ -155,20 +213,29 @@ static DistributeObjectOps Any_Grant = {
|
||||||
.postprocess = NULL,
|
.postprocess = NULL,
|
||||||
.address = NULL,
|
.address = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static DistributeObjectOps Any_Index = {
|
static DistributeObjectOps Any_Index = {
|
||||||
|
.statementTag = T_IndexStmt,
|
||||||
|
|
||||||
.deparse = NULL,
|
.deparse = NULL,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
.preprocess = PreprocessIndexStmt,
|
.preprocess = PreprocessIndexStmt,
|
||||||
.postprocess = PostprocessIndexStmt,
|
.postprocess = PostprocessIndexStmt,
|
||||||
.address = NULL,
|
.address = NULL,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_Index);
|
||||||
|
|
||||||
static DistributeObjectOps Any_Reindex = {
|
static DistributeObjectOps Any_Reindex = {
|
||||||
|
.statementTag = T_ReindexStmt,
|
||||||
|
|
||||||
.deparse = NULL,
|
.deparse = NULL,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
.preprocess = PreprocessReindexStmt,
|
.preprocess = PreprocessReindexStmt,
|
||||||
.postprocess = NULL,
|
.postprocess = NULL,
|
||||||
.address = NULL,
|
.address = NULL,
|
||||||
};
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(Any_Reindex);
|
||||||
|
|
||||||
static DistributeObjectOps Any_Rename = {
|
static DistributeObjectOps Any_Rename = {
|
||||||
.deparse = NULL,
|
.deparse = NULL,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
|
@ -436,6 +503,8 @@ static DistributeObjectOps Type_Rename = {
|
||||||
.address = RenameTypeStmtObjectAddress,
|
.address = RenameTypeStmtObjectAddress,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* linker provided pointers */
|
||||||
|
SECTION_ARRAY(DistributeObjectOps *, dist_object_ops);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GetDistributeObjectOps looks up the DistributeObjectOps which handles the node.
|
* GetDistributeObjectOps looks up the DistributeObjectOps which handles the node.
|
||||||
|
@ -445,28 +514,20 @@ static DistributeObjectOps Type_Rename = {
|
||||||
const DistributeObjectOps *
|
const DistributeObjectOps *
|
||||||
GetDistributeObjectOps(Node *node)
|
GetDistributeObjectOps(Node *node)
|
||||||
{
|
{
|
||||||
|
int i = 0;
|
||||||
|
size_t sz = SECTION_SIZE(dist_object_ops);
|
||||||
|
for (i = 0; i < sz; i++)
|
||||||
|
{
|
||||||
|
DistributeObjectOps *ops = dist_object_ops_array[i];
|
||||||
|
if (node->type == ops->statementTag)
|
||||||
|
{
|
||||||
|
return ops;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* multi level statements */
|
||||||
switch (nodeTag(node))
|
switch (nodeTag(node))
|
||||||
{
|
{
|
||||||
case T_AlterEnumStmt:
|
|
||||||
{
|
|
||||||
return &Any_AlterEnum;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_AlterExtensionStmt:
|
|
||||||
{
|
|
||||||
return &Any_AlterExtension;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_AlterExtensionContentsStmt:
|
|
||||||
{
|
|
||||||
return &Any_AlterExtensionContents;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_AlterFunctionStmt:
|
|
||||||
{
|
|
||||||
return &Any_AlterFunction;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_AlterObjectDependsStmt:
|
case T_AlterObjectDependsStmt:
|
||||||
{
|
{
|
||||||
AlterObjectDependsStmt *stmt = castNode(AlterObjectDependsStmt, node);
|
AlterObjectDependsStmt *stmt = castNode(AlterObjectDependsStmt, node);
|
||||||
|
@ -588,16 +649,6 @@ GetDistributeObjectOps(Node *node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case T_AlterPolicyStmt:
|
|
||||||
{
|
|
||||||
return &Any_AlterPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_AlterRoleStmt:
|
|
||||||
{
|
|
||||||
return &Any_AlterRole;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_AlterTableStmt:
|
case T_AlterTableStmt:
|
||||||
{
|
{
|
||||||
AlterTableStmt *stmt = castNode(AlterTableStmt, node);
|
AlterTableStmt *stmt = castNode(AlterTableStmt, node);
|
||||||
|
@ -630,41 +681,6 @@ GetDistributeObjectOps(Node *node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case T_AlterTableMoveAllStmt:
|
|
||||||
{
|
|
||||||
return &Any_AlterTableMoveAll;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_ClusterStmt:
|
|
||||||
{
|
|
||||||
return &Any_Cluster;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_CompositeTypeStmt:
|
|
||||||
{
|
|
||||||
return &Any_CompositeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_CreateEnumStmt:
|
|
||||||
{
|
|
||||||
return &Any_CreateEnum;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_CreateExtensionStmt:
|
|
||||||
{
|
|
||||||
return &Any_CreateExtension;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_CreateFunctionStmt:
|
|
||||||
{
|
|
||||||
return &Any_CreateFunction;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_CreatePolicyStmt:
|
|
||||||
{
|
|
||||||
return &Any_CreatePolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_DefineStmt:
|
case T_DefineStmt:
|
||||||
{
|
{
|
||||||
DefineStmt *stmt = castNode(DefineStmt, node);
|
DefineStmt *stmt = castNode(DefineStmt, node);
|
||||||
|
@ -771,16 +787,6 @@ GetDistributeObjectOps(Node *node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case T_IndexStmt:
|
|
||||||
{
|
|
||||||
return &Any_Index;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_ReindexStmt:
|
|
||||||
{
|
|
||||||
return &Any_Reindex;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_RenameStmt:
|
case T_RenameStmt:
|
||||||
{
|
{
|
||||||
RenameStmt *stmt = castNode(RenameStmt, node);
|
RenameStmt *stmt = castNode(RenameStmt, node);
|
||||||
|
|
|
@ -30,7 +30,7 @@ DeparseTreeNode(Node *stmt)
|
||||||
|
|
||||||
if (!ops->deparse)
|
if (!ops->deparse)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errmsg("unsupported statement for deparsing")));
|
ereport(ERROR, (errmsg("unsupported statement for deparsing: %d", stmt->type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ops->deparse(stmt);
|
return ops->deparse(stmt);
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
*/
|
*/
|
||||||
typedef struct DistributeObjectOps
|
typedef struct DistributeObjectOps
|
||||||
{
|
{
|
||||||
|
NodeTag statementTag;
|
||||||
|
ObjectType subObjectType;
|
||||||
char * (*deparse)(Node *);
|
char * (*deparse)(Node *);
|
||||||
void (*qualify)(Node *);
|
void (*qualify)(Node *);
|
||||||
List * (*preprocess)(Node *, const char *);
|
List * (*preprocess)(Node *, const char *);
|
||||||
|
@ -44,6 +46,22 @@ typedef struct DistributeObjectOps
|
||||||
ObjectAddress (*address)(Node *, bool);
|
ObjectAddress (*address)(Node *, bool);
|
||||||
} DistributeObjectOps;
|
} DistributeObjectOps;
|
||||||
|
|
||||||
|
/* Marco for registering a DistributedObjectOps struct */
|
||||||
|
/* works for mac */
|
||||||
|
#define REGISTER_DISTRIBUTED_OPERATION(_ops) \
|
||||||
|
DistributeObjectOps *p_ ## _ops __attribute__((section("__DATA,dist_object_ops"))) = \
|
||||||
|
&_ops
|
||||||
|
|
||||||
|
#define SECTION_ARRAY(_type, _section) \
|
||||||
|
extern _type __start_ ## _section[] __asm("section$start$__DATA$" # _section); \
|
||||||
|
extern _type __stop_ ## _section[] __asm("section$end$__DATA$" # _section); \
|
||||||
|
_type *_section ## _array = __start_ ## _section;
|
||||||
|
|
||||||
|
#define TESTMACRO(_section) "section$end$__DATA$" # _section
|
||||||
|
|
||||||
|
#define SECTION_SIZE(sect) \
|
||||||
|
((size_t) ((__stop_ ## sect - __start_ ## sect)))
|
||||||
|
|
||||||
const DistributeObjectOps * GetDistributeObjectOps(Node *node);
|
const DistributeObjectOps * GetDistributeObjectOps(Node *node);
|
||||||
|
|
||||||
/* cluster.c - forward declarations */
|
/* cluster.c - forward declarations */
|
||||||
|
|
Loading…
Reference in New Issue