mirror of https://github.com/citusdata/citus.git
extract table DistributeObjectOps
parent
2e0b395c26
commit
cc86236fa1
|
@ -23,15 +23,6 @@ static DistributeObjectOps NoDistributeOps = {
|
||||||
.address = NULL,
|
.address = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static DistributeObjectOps Any_AlterTableMoveAll = {
|
|
||||||
.deparse = NULL,
|
|
||||||
.qualify = NULL,
|
|
||||||
.preprocess = PreprocessAlterTableMoveAllStmt,
|
|
||||||
.postprocess = NULL,
|
|
||||||
.address = NULL,
|
|
||||||
};
|
|
||||||
REGISTER_DISTRIBUTED_OPERATION(AlterTableMoveAllStmt, Any_AlterTableMoveAll);
|
|
||||||
|
|
||||||
static DistributeObjectOps Any_Cluster = {
|
static DistributeObjectOps Any_Cluster = {
|
||||||
.deparse = NULL,
|
.deparse = NULL,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
|
@ -135,26 +126,6 @@ static DistributeObjectOps Collation_Rename = {
|
||||||
REGISTER_DISTRIBUTED_OPERATION_NESTED(RenameStmt, renameType, OBJECT_COLLATION,
|
REGISTER_DISTRIBUTED_OPERATION_NESTED(RenameStmt, renameType, OBJECT_COLLATION,
|
||||||
Collation_Rename);
|
Collation_Rename);
|
||||||
|
|
||||||
static DistributeObjectOps ForeignTable_AlterTable = {
|
|
||||||
.deparse = NULL,
|
|
||||||
.qualify = NULL,
|
|
||||||
.preprocess = PreprocessAlterTableStmt,
|
|
||||||
.postprocess = NULL,
|
|
||||||
.address = NULL,
|
|
||||||
};
|
|
||||||
REGISTER_DISTRIBUTED_OPERATION_NESTED(AlterTableStmt, relkind, OBJECT_FOREIGN_TABLE,
|
|
||||||
ForeignTable_AlterTable);
|
|
||||||
|
|
||||||
static DistributeObjectOps Index_AlterTable = {
|
|
||||||
.deparse = NULL,
|
|
||||||
.qualify = NULL,
|
|
||||||
.preprocess = PreprocessAlterTableStmt,
|
|
||||||
.postprocess = NULL,
|
|
||||||
.address = NULL,
|
|
||||||
};
|
|
||||||
REGISTER_DISTRIBUTED_OPERATION_NESTED(AlterTableStmt, relkind, OBJECT_INDEX,
|
|
||||||
Index_AlterTable);
|
|
||||||
|
|
||||||
static DistributeObjectOps Index_Drop = {
|
static DistributeObjectOps Index_Drop = {
|
||||||
.deparse = NULL,
|
.deparse = NULL,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
|
@ -182,35 +153,6 @@ static DistributeObjectOps Schema_Grant = {
|
||||||
};
|
};
|
||||||
REGISTER_DISTRIBUTED_OPERATION_NESTED(GrantStmt, objtype, OBJECT_SCHEMA, Schema_Grant);
|
REGISTER_DISTRIBUTED_OPERATION_NESTED(GrantStmt, objtype, OBJECT_SCHEMA, Schema_Grant);
|
||||||
|
|
||||||
static DistributeObjectOps Table_AlterTable = {
|
|
||||||
.deparse = NULL,
|
|
||||||
.qualify = NULL,
|
|
||||||
.preprocess = PreprocessAlterTableStmt,
|
|
||||||
.postprocess = NULL,
|
|
||||||
.address = NULL,
|
|
||||||
};
|
|
||||||
REGISTER_DISTRIBUTED_OPERATION_NESTED(AlterTableStmt, relkind, OBJECT_TABLE,
|
|
||||||
Table_AlterTable);
|
|
||||||
|
|
||||||
static DistributeObjectOps Table_AlterObjectSchema = {
|
|
||||||
.deparse = DeparseAlterTableSchemaStmt,
|
|
||||||
.qualify = QualifyAlterTableSchemaStmt,
|
|
||||||
.preprocess = PreprocessAlterTableSchemaStmt,
|
|
||||||
.postprocess = PostprocessAlterTableSchemaStmt,
|
|
||||||
.address = AlterTableSchemaStmtObjectAddress,
|
|
||||||
};
|
|
||||||
REGISTER_DISTRIBUTED_OPERATION_NESTED(AlterObjectSchemaStmt, objectType, OBJECT_TABLE,
|
|
||||||
Table_AlterObjectSchema);
|
|
||||||
|
|
||||||
static DistributeObjectOps Table_Drop = {
|
|
||||||
.deparse = NULL,
|
|
||||||
.qualify = NULL,
|
|
||||||
.preprocess = PreprocessDropTableStmt,
|
|
||||||
.postprocess = NULL,
|
|
||||||
.address = NULL,
|
|
||||||
};
|
|
||||||
REGISTER_DISTRIBUTED_OPERATION_NESTED(DropStmt, removeType, OBJECT_TABLE, Table_Drop);
|
|
||||||
|
|
||||||
/* linker provided pointers */
|
/* linker provided pointers */
|
||||||
SECTION_ARRAY(DistributedObjectOpsContainer *, opscontainer);
|
SECTION_ARRAY(DistributedObjectOpsContainer *, opscontainer);
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,56 @@ static void ErrorIfUnsupportedAlterAddConstraintStmt(AlterTableStmt *alterTableS
|
||||||
*/
|
*/
|
||||||
static bool SetupExecutionModeForAlterTable(Oid relationId, AlterTableCmd *command);
|
static bool SetupExecutionModeForAlterTable(Oid relationId, AlterTableCmd *command);
|
||||||
|
|
||||||
|
/* DistributeObjectOps */
|
||||||
|
static List * PreprocessAlterTableMoveAllStmt(Node *node, const char *queryString);
|
||||||
|
static DistributeObjectOps Any_AlterTableMoveAll = {
|
||||||
|
.deparse = NULL,
|
||||||
|
.qualify = NULL,
|
||||||
|
.preprocess = PreprocessAlterTableMoveAllStmt,
|
||||||
|
.postprocess = NULL,
|
||||||
|
.address = NULL,
|
||||||
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION(AlterTableMoveAllStmt, Any_AlterTableMoveAll);
|
||||||
|
|
||||||
|
static List * PreprocessAlterTableSchemaStmt(Node *node, const char *queryString);
|
||||||
|
static List * PostprocessAlterTableSchemaStmt(Node *node, const char *queryString);
|
||||||
|
static ObjectAddress AlterTableSchemaStmtObjectAddress(Node *node, bool missing_ok);
|
||||||
|
static DistributeObjectOps Table_AlterObjectSchema = {
|
||||||
|
.deparse = DeparseAlterTableSchemaStmt,
|
||||||
|
.qualify = QualifyAlterTableSchemaStmt,
|
||||||
|
.preprocess = PreprocessAlterTableSchemaStmt,
|
||||||
|
.postprocess = PostprocessAlterTableSchemaStmt,
|
||||||
|
.address = AlterTableSchemaStmtObjectAddress,
|
||||||
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION_NESTED(AlterObjectSchemaStmt, objectType, OBJECT_TABLE,
|
||||||
|
Table_AlterObjectSchema);
|
||||||
|
|
||||||
|
static List * PreprocessAlterTableStmt(Node *node, const char *alterTableCommand);
|
||||||
|
static DistributeObjectOps Table_AlterTable = {
|
||||||
|
.deparse = NULL,
|
||||||
|
.qualify = NULL,
|
||||||
|
.preprocess = PreprocessAlterTableStmt,
|
||||||
|
.postprocess = NULL,
|
||||||
|
.address = NULL,
|
||||||
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION_NESTED(AlterTableStmt, relkind, OBJECT_TABLE,
|
||||||
|
Table_AlterTable);
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION_NESTED(AlterTableStmt, relkind, OBJECT_FOREIGN_TABLE,
|
||||||
|
Table_AlterTable);
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION_NESTED(AlterTableStmt, relkind, OBJECT_INDEX,
|
||||||
|
Table_AlterTable);
|
||||||
|
|
||||||
|
static List * PreprocessDropTableStmt(Node *node, const char *queryString);
|
||||||
|
static DistributeObjectOps Table_Drop = {
|
||||||
|
.deparse = NULL,
|
||||||
|
.qualify = NULL,
|
||||||
|
.preprocess = PreprocessDropTableStmt,
|
||||||
|
.postprocess = NULL,
|
||||||
|
.address = NULL,
|
||||||
|
};
|
||||||
|
REGISTER_DISTRIBUTED_OPERATION_NESTED(DropStmt, removeType, OBJECT_TABLE, Table_Drop);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PreprocessDropTableStmt processes DROP TABLE commands for partitioned tables.
|
* PreprocessDropTableStmt processes DROP TABLE commands for partitioned tables.
|
||||||
* If we are trying to DROP partitioned tables, we first need to go to MX nodes
|
* If we are trying to DROP partitioned tables, we first need to go to MX nodes
|
||||||
|
@ -63,7 +113,7 @@ static bool SetupExecutionModeForAlterTable(Oid relationId, AlterTableCmd *comma
|
||||||
* Postgres catalogs via performDeletion function, thus we need to be cautious
|
* Postgres catalogs via performDeletion function, thus we need to be cautious
|
||||||
* about not processing same DROP command twice.
|
* about not processing same DROP command twice.
|
||||||
*/
|
*/
|
||||||
List *
|
static List *
|
||||||
PreprocessDropTableStmt(Node *node, const char *queryString)
|
PreprocessDropTableStmt(Node *node, const char *queryString)
|
||||||
{
|
{
|
||||||
DropStmt *dropTableStatement = castNode(DropStmt, node);
|
DropStmt *dropTableStatement = castNode(DropStmt, node);
|
||||||
|
@ -258,7 +308,7 @@ PostprocessAlterTableStmtAttachPartition(AlterTableStmt *alterTableStatement,
|
||||||
* can now use the new dependencies of the table to ensure all its dependencies exist on
|
* can now use the new dependencies of the table to ensure all its dependencies exist on
|
||||||
* the workers before we apply the commands remotely.
|
* the workers before we apply the commands remotely.
|
||||||
*/
|
*/
|
||||||
List *
|
static List *
|
||||||
PostprocessAlterTableSchemaStmt(Node *node, const char *queryString)
|
PostprocessAlterTableSchemaStmt(Node *node, const char *queryString)
|
||||||
{
|
{
|
||||||
AlterObjectSchemaStmt *stmt = castNode(AlterObjectSchemaStmt, node);
|
AlterObjectSchemaStmt *stmt = castNode(AlterObjectSchemaStmt, node);
|
||||||
|
@ -285,7 +335,7 @@ PostprocessAlterTableSchemaStmt(Node *node, const char *queryString)
|
||||||
* during the worker node portion of DDL execution before returning that DDLJob
|
* during the worker node portion of DDL execution before returning that DDLJob
|
||||||
* in a List. If no distributed table is involved, this function returns NIL.
|
* in a List. If no distributed table is involved, this function returns NIL.
|
||||||
*/
|
*/
|
||||||
List *
|
static List *
|
||||||
PreprocessAlterTableStmt(Node *node, const char *alterTableCommand)
|
PreprocessAlterTableStmt(Node *node, const char *alterTableCommand)
|
||||||
{
|
{
|
||||||
AlterTableStmt *alterTableStatement = castNode(AlterTableStmt, node);
|
AlterTableStmt *alterTableStatement = castNode(AlterTableStmt, node);
|
||||||
|
@ -490,7 +540,7 @@ PreprocessAlterTableStmt(Node *node, const char *alterTableCommand)
|
||||||
* AlterTableMoveAllStmt. At the moment we do not support this functionality in
|
* AlterTableMoveAllStmt. At the moment we do not support this functionality in
|
||||||
* the distributed environment. We warn out here.
|
* the distributed environment. We warn out here.
|
||||||
*/
|
*/
|
||||||
List *
|
static List *
|
||||||
PreprocessAlterTableMoveAllStmt(Node *node, const char *queryString)
|
PreprocessAlterTableMoveAllStmt(Node *node, const char *queryString)
|
||||||
{
|
{
|
||||||
ereport(WARNING, (errmsg("not propagating ALTER TABLE ALL IN TABLESPACE "
|
ereport(WARNING, (errmsg("not propagating ALTER TABLE ALL IN TABLESPACE "
|
||||||
|
@ -508,7 +558,7 @@ PreprocessAlterTableMoveAllStmt(Node *node, const char *queryString)
|
||||||
*
|
*
|
||||||
* In this stage we can prepare the commands that will alter the schemas of the shards.
|
* In this stage we can prepare the commands that will alter the schemas of the shards.
|
||||||
*/
|
*/
|
||||||
List *
|
static List *
|
||||||
PreprocessAlterTableSchemaStmt(Node *node, const char *queryString)
|
PreprocessAlterTableSchemaStmt(Node *node, const char *queryString)
|
||||||
{
|
{
|
||||||
AlterObjectSchemaStmt *stmt = castNode(AlterObjectSchemaStmt, node);
|
AlterObjectSchemaStmt *stmt = castNode(AlterObjectSchemaStmt, node);
|
||||||
|
@ -1462,7 +1512,7 @@ ErrorIfUnsupportedAlterAddConstraintStmt(AlterTableStmt *alterTableStatement)
|
||||||
* new schema. Errors if missing_ok is false and the table cannot be found in either of the
|
* new schema. Errors if missing_ok is false and the table cannot be found in either of the
|
||||||
* schemas.
|
* schemas.
|
||||||
*/
|
*/
|
||||||
ObjectAddress
|
static ObjectAddress
|
||||||
AlterTableSchemaStmtObjectAddress(Node *node, bool missing_ok)
|
AlterTableSchemaStmtObjectAddress(Node *node, bool missing_ok)
|
||||||
{
|
{
|
||||||
AlterObjectSchemaStmt *stmt = castNode(AlterObjectSchemaStmt, node);
|
AlterObjectSchemaStmt *stmt = castNode(AlterObjectSchemaStmt, node);
|
||||||
|
|
|
@ -226,16 +226,11 @@ extern Node * ProcessCreateSubscriptionStmt(CreateSubscriptionStmt *createSubStm
|
||||||
|
|
||||||
|
|
||||||
/* table.c - forward declarations */
|
/* table.c - forward declarations */
|
||||||
extern List * PreprocessDropTableStmt(Node *stmt, const char *queryString);
|
|
||||||
extern List * PostprocessCreateTableStmtPartitionOf(CreateStmt *createStatement,
|
extern List * PostprocessCreateTableStmtPartitionOf(CreateStmt *createStatement,
|
||||||
const char *queryString);
|
const char *queryString);
|
||||||
extern List * PostprocessAlterTableStmtAttachPartition(
|
extern List * PostprocessAlterTableStmtAttachPartition(
|
||||||
AlterTableStmt *alterTableStatement,
|
AlterTableStmt *alterTableStatement,
|
||||||
const char *queryString);
|
const char *queryString);
|
||||||
extern List * PostprocessAlterTableSchemaStmt(Node *node, const char *queryString);
|
|
||||||
extern List * PreprocessAlterTableStmt(Node *node, const char *alterTableCommand);
|
|
||||||
extern List * PreprocessAlterTableMoveAllStmt(Node *node, const char *queryString);
|
|
||||||
extern List * PreprocessAlterTableSchemaStmt(Node *node, const char *queryString);
|
|
||||||
extern Node * WorkerProcessAlterTableStmt(AlterTableStmt *alterTableStatement,
|
extern Node * WorkerProcessAlterTableStmt(AlterTableStmt *alterTableStatement,
|
||||||
const char *alterTableCommand);
|
const char *alterTableCommand);
|
||||||
extern bool IsAlterTableRenameStmt(RenameStmt *renameStmt);
|
extern bool IsAlterTableRenameStmt(RenameStmt *renameStmt);
|
||||||
|
@ -245,9 +240,6 @@ extern void ErrorUnsupportedAlterTableAddColumn(Oid relationId, AlterTableCmd *c
|
||||||
Constraint *constraint);
|
Constraint *constraint);
|
||||||
extern void ErrorIfUnsupportedConstraint(Relation relation, char distributionMethod,
|
extern void ErrorIfUnsupportedConstraint(Relation relation, char distributionMethod,
|
||||||
Var *distributionColumn, uint32 colocationId);
|
Var *distributionColumn, uint32 colocationId);
|
||||||
extern ObjectAddress AlterTableSchemaStmtObjectAddress(Node *stmt,
|
|
||||||
bool missing_ok);
|
|
||||||
|
|
||||||
|
|
||||||
/* truncate.c - forward declarations */
|
/* truncate.c - forward declarations */
|
||||||
extern void PostprocessTruncateStatement(TruncateStmt *truncateStatement);
|
extern void PostprocessTruncateStatement(TruncateStmt *truncateStatement);
|
||||||
|
|
Loading…
Reference in New Issue