mirror of https://github.com/citusdata/citus.git
extract extension DistributeObjectOps
parent
28c523cb1a
commit
ee964dde3d
|
@ -23,24 +23,6 @@ static DistributeObjectOps NoDistributeOps = {
|
|||
.address = NULL,
|
||||
};
|
||||
|
||||
static DistributeObjectOps Any_AlterExtension = {
|
||||
.deparse = DeparseAlterExtensionStmt,
|
||||
.qualify = NULL,
|
||||
.preprocess = PreprocessAlterExtensionUpdateStmt,
|
||||
.postprocess = NULL,
|
||||
.address = AlterExtensionUpdateStmtObjectAddress,
|
||||
};
|
||||
REGISTER_DISTRIBUTED_OPERATION(AlterExtensionStmt, Any_AlterExtension);
|
||||
|
||||
static DistributeObjectOps Any_AlterExtensionContents = {
|
||||
.deparse = NULL,
|
||||
.qualify = NULL,
|
||||
.preprocess = PreprocessAlterExtensionContentsStmt,
|
||||
.postprocess = NULL,
|
||||
.address = NULL,
|
||||
};
|
||||
REGISTER_DISTRIBUTED_OPERATION(AlterExtensionContentsStmt, Any_AlterExtensionContents);
|
||||
|
||||
static DistributeObjectOps Any_AlterFunction = {
|
||||
.deparse = DeparseAlterFunctionStmt,
|
||||
.qualify = QualifyAlterFunctionStmt,
|
||||
|
@ -86,15 +68,6 @@ static DistributeObjectOps Any_Cluster = {
|
|||
};
|
||||
REGISTER_DISTRIBUTED_OPERATION(ClusterStmt, Any_Cluster);
|
||||
|
||||
static DistributeObjectOps Any_CreateExtension = {
|
||||
.deparse = DeparseCreateExtensionStmt,
|
||||
.qualify = NULL,
|
||||
.preprocess = NULL,
|
||||
.postprocess = PostprocessCreateExtensionStmt,
|
||||
.address = CreateExtensionStmtObjectAddress,
|
||||
};
|
||||
REGISTER_DISTRIBUTED_OPERATION(CreateExtensionStmt, Any_CreateExtension);
|
||||
|
||||
static DistributeObjectOps Any_CreateFunction = {
|
||||
.deparse = NULL,
|
||||
.qualify = NULL,
|
||||
|
@ -207,26 +180,6 @@ static DistributeObjectOps Collation_Rename = {
|
|||
REGISTER_DISTRIBUTED_OPERATION_NESTED(RenameStmt, renameType, OBJECT_COLLATION,
|
||||
Collation_Rename);
|
||||
|
||||
static DistributeObjectOps Extension_AlterObjectSchema = {
|
||||
.deparse = DeparseAlterExtensionSchemaStmt,
|
||||
.qualify = NULL,
|
||||
.preprocess = PreprocessAlterExtensionSchemaStmt,
|
||||
.postprocess = PostprocessAlterExtensionSchemaStmt,
|
||||
.address = AlterExtensionSchemaStmtObjectAddress,
|
||||
};
|
||||
REGISTER_DISTRIBUTED_OPERATION_NESTED(AlterObjectSchemaStmt, objectType, OBJECT_EXTENSION,
|
||||
Extension_AlterObjectSchema);
|
||||
|
||||
static DistributeObjectOps Extension_Drop = {
|
||||
.deparse = DeparseDropExtensionStmt,
|
||||
.qualify = NULL,
|
||||
.preprocess = PreprocessDropExtensionStmt,
|
||||
.postprocess = NULL,
|
||||
.address = NULL,
|
||||
};
|
||||
REGISTER_DISTRIBUTED_OPERATION_NESTED(DropStmt, removeType, OBJECT_EXTENSION,
|
||||
Extension_Drop);
|
||||
|
||||
static DistributeObjectOps ForeignTable_AlterTable = {
|
||||
.deparse = NULL,
|
||||
.qualify = NULL,
|
||||
|
|
|
@ -39,6 +39,63 @@ static bool IsAlterExtensionSetSchemaCitus(Node *parseTree);
|
|||
static Node * RecreateExtensionStmt(Oid extensionOid);
|
||||
|
||||
|
||||
/* DistributeObjectOps */
|
||||
static List * PreprocessAlterExtensionUpdateStmt(Node *node, const char *queryString);
|
||||
static ObjectAddress AlterExtensionUpdateStmtObjectAddress(Node *node, bool missing_ok);
|
||||
static DistributeObjectOps Any_AlterExtension = {
|
||||
.deparse = DeparseAlterExtensionStmt,
|
||||
.qualify = NULL,
|
||||
.preprocess = PreprocessAlterExtensionUpdateStmt,
|
||||
.postprocess = NULL,
|
||||
.address = AlterExtensionUpdateStmtObjectAddress,
|
||||
};
|
||||
REGISTER_DISTRIBUTED_OPERATION(AlterExtensionStmt, Any_AlterExtension);
|
||||
|
||||
static List * PreprocessAlterExtensionContentsStmt(Node *node, const char *queryString);
|
||||
static DistributeObjectOps Any_AlterExtensionContents = {
|
||||
.deparse = NULL,
|
||||
.qualify = NULL,
|
||||
.preprocess = PreprocessAlterExtensionContentsStmt,
|
||||
.postprocess = NULL,
|
||||
.address = NULL,
|
||||
};
|
||||
REGISTER_DISTRIBUTED_OPERATION(AlterExtensionContentsStmt, Any_AlterExtensionContents);
|
||||
|
||||
static List * PostprocessCreateExtensionStmt(Node *node, const char *queryString);
|
||||
static ObjectAddress CreateExtensionStmtObjectAddress(Node *node, bool missing_ok);
|
||||
static DistributeObjectOps Any_CreateExtension = {
|
||||
.deparse = DeparseCreateExtensionStmt,
|
||||
.qualify = NULL,
|
||||
.preprocess = NULL,
|
||||
.postprocess = PostprocessCreateExtensionStmt,
|
||||
.address = CreateExtensionStmtObjectAddress,
|
||||
};
|
||||
REGISTER_DISTRIBUTED_OPERATION(CreateExtensionStmt, Any_CreateExtension);
|
||||
|
||||
static List * PreprocessAlterExtensionSchemaStmt(Node *node, const char *queryString);
|
||||
static List * PostprocessAlterExtensionSchemaStmt(Node *node, const char *queryString);
|
||||
static ObjectAddress AlterExtensionSchemaStmtObjectAddress(Node *node, bool missing_ok);
|
||||
static DistributeObjectOps Extension_AlterObjectSchema = {
|
||||
.deparse = DeparseAlterExtensionSchemaStmt,
|
||||
.qualify = NULL,
|
||||
.preprocess = PreprocessAlterExtensionSchemaStmt,
|
||||
.postprocess = PostprocessAlterExtensionSchemaStmt,
|
||||
.address = AlterExtensionSchemaStmtObjectAddress,
|
||||
};
|
||||
REGISTER_DISTRIBUTED_OPERATION_NESTED(AlterObjectSchemaStmt, objectType, OBJECT_EXTENSION,
|
||||
Extension_AlterObjectSchema);
|
||||
|
||||
static List * PreprocessDropExtensionStmt(Node *node, const char *queryString);
|
||||
static DistributeObjectOps Extension_Drop = {
|
||||
.deparse = DeparseDropExtensionStmt,
|
||||
.qualify = NULL,
|
||||
.preprocess = PreprocessDropExtensionStmt,
|
||||
.postprocess = NULL,
|
||||
.address = NULL,
|
||||
};
|
||||
REGISTER_DISTRIBUTED_OPERATION_NESTED(DropStmt, removeType, OBJECT_EXTENSION,
|
||||
Extension_Drop);
|
||||
|
||||
/*
|
||||
* ErrorIfUnstableCreateOrAlterExtensionStmt compares CITUS_EXTENSIONVERSION
|
||||
* and version given CREATE/ALTER EXTENSION statement will create/update to. If
|
||||
|
@ -124,7 +181,7 @@ ExtractNewExtensionVersion(Node *parseTree)
|
|||
* created, we can mark it as distributed to make sure that its
|
||||
* dependencies exist on all nodes.
|
||||
*/
|
||||
List *
|
||||
static List *
|
||||
PostprocessCreateExtensionStmt(Node *node, const char *queryString)
|
||||
{
|
||||
CreateExtensionStmt *stmt = castNode(CreateExtensionStmt, node);
|
||||
|
@ -232,7 +289,7 @@ AddSchemaFieldIfMissing(CreateExtensionStmt *createExtensionStmt)
|
|||
* If no extensions in the drop list are distributed, then no calls will
|
||||
* be made to the workers.
|
||||
*/
|
||||
List *
|
||||
static List *
|
||||
PreprocessDropExtensionStmt(Node *node, const char *queryString)
|
||||
{
|
||||
DropStmt *stmt = castNode(DropStmt, node);
|
||||
|
@ -384,7 +441,7 @@ ExtensionNameListToObjectAddressList(List *extensionObjectList)
|
|||
/*
|
||||
* PreprocessAlterExtensionSchemaStmt is invoked for alter extension set schema statements.
|
||||
*/
|
||||
List *
|
||||
static List *
|
||||
PreprocessAlterExtensionSchemaStmt(Node *node, const char *queryString)
|
||||
{
|
||||
if (!ShouldPropagateExtensionCommand(node))
|
||||
|
@ -429,7 +486,7 @@ PreprocessAlterExtensionSchemaStmt(Node *node, const char *queryString)
|
|||
* locally, we can now use the new dependencies (schema) of the extension to ensure
|
||||
* all its dependencies exist on the workers before we apply the commands remotely.
|
||||
*/
|
||||
List *
|
||||
static List *
|
||||
PostprocessAlterExtensionSchemaStmt(Node *node, const char *queryString)
|
||||
{
|
||||
ObjectAddress extensionAddress = GetObjectAddressFromParseTree(node, false);
|
||||
|
@ -449,7 +506,7 @@ PostprocessAlterExtensionSchemaStmt(Node *node, const char *queryString)
|
|||
/*
|
||||
* PreprocessAlterExtensionUpdateStmt is invoked for alter extension update statements.
|
||||
*/
|
||||
List *
|
||||
static List *
|
||||
PreprocessAlterExtensionUpdateStmt(Node *node, const char *queryString)
|
||||
{
|
||||
AlterExtensionStmt *alterExtensionStmt = castNode(AlterExtensionStmt, node);
|
||||
|
@ -494,7 +551,7 @@ PreprocessAlterExtensionUpdateStmt(Node *node, const char *queryString)
|
|||
/*
|
||||
* PreprocessAlterExtensionContentsStmt issues a notice. It does not propagate.
|
||||
*/
|
||||
List *
|
||||
static List *
|
||||
PreprocessAlterExtensionContentsStmt(Node *node, const char *queryString)
|
||||
{
|
||||
ereport(NOTICE, (errmsg(
|
||||
|
@ -741,7 +798,7 @@ RecreateExtensionStmt(Oid extensionOid)
|
|||
* AlterExtensionSchemaStmtObjectAddress returns the ObjectAddress of the extension that is
|
||||
* the subject of the AlterObjectSchemaStmt. Errors if missing_ok is false.
|
||||
*/
|
||||
ObjectAddress
|
||||
static ObjectAddress
|
||||
AlterExtensionSchemaStmtObjectAddress(Node *node, bool missing_ok)
|
||||
{
|
||||
AlterObjectSchemaStmt *stmt = castNode(AlterObjectSchemaStmt, node);
|
||||
|
@ -769,7 +826,7 @@ AlterExtensionSchemaStmtObjectAddress(Node *node, bool missing_ok)
|
|||
* AlterExtensionUpdateStmtObjectAddress returns the ObjectAddress of the extension that is
|
||||
* the subject of the AlterExtensionStmt. Errors if missing_ok is false.
|
||||
*/
|
||||
ObjectAddress
|
||||
static ObjectAddress
|
||||
AlterExtensionUpdateStmtObjectAddress(Node *node, bool missing_ok)
|
||||
{
|
||||
AlterExtensionStmt *stmt = castNode(AlterExtensionStmt, node);
|
||||
|
@ -789,3 +846,35 @@ AlterExtensionUpdateStmtObjectAddress(Node *node, bool missing_ok)
|
|||
|
||||
return address;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* CreateExtensionStmtObjectAddress finds the ObjectAddress for the extension described
|
||||
* by the CreateExtensionStmt. If missing_ok is false, then this function throws an
|
||||
* error if the extension does not exist.
|
||||
*
|
||||
* Never returns NULL, but the objid in the address could be invalid if missing_ok was set
|
||||
* to true.
|
||||
*/
|
||||
static ObjectAddress
|
||||
CreateExtensionStmtObjectAddress(Node *node, bool missing_ok)
|
||||
{
|
||||
CreateExtensionStmt *stmt = castNode(CreateExtensionStmt, node);
|
||||
ObjectAddress address = { 0 };
|
||||
|
||||
const char *extensionName = stmt->extname;
|
||||
|
||||
Oid extensionoid = get_extension_oid(extensionName, missing_ok);
|
||||
|
||||
/* if we couldn't find the extension, error if missing_ok is false */
|
||||
if (!missing_ok && extensionoid == InvalidOid)
|
||||
{
|
||||
ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("extension \"%s\" does not exist",
|
||||
extensionName)));
|
||||
}
|
||||
|
||||
ObjectAddressSet(address, ExtensionRelationId, extensionoid);
|
||||
|
||||
return address;
|
||||
}
|
||||
|
|
|
@ -59,38 +59,6 @@ RenameAttributeStmtObjectAddress(Node *node, bool missing_ok)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* CreateExtensionStmtObjectAddress finds the ObjectAddress for the extension described
|
||||
* by the CreateExtensionStmt. If missing_ok is false, then this function throws an
|
||||
* error if the extension does not exist.
|
||||
*
|
||||
* Never returns NULL, but the objid in the address could be invalid if missing_ok was set
|
||||
* to true.
|
||||
*/
|
||||
ObjectAddress
|
||||
CreateExtensionStmtObjectAddress(Node *node, bool missing_ok)
|
||||
{
|
||||
CreateExtensionStmt *stmt = castNode(CreateExtensionStmt, node);
|
||||
ObjectAddress address = { 0 };
|
||||
|
||||
const char *extensionName = stmt->extname;
|
||||
|
||||
Oid extensionoid = get_extension_oid(extensionName, missing_ok);
|
||||
|
||||
/* if we couldn't find the extension, error if missing_ok is false */
|
||||
if (!missing_ok && extensionoid == InvalidOid)
|
||||
{
|
||||
ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("extension \"%s\" does not exist",
|
||||
extensionName)));
|
||||
}
|
||||
|
||||
ObjectAddressSet(address, ExtensionRelationId, extensionoid);
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* AlterExtensionStmtObjectAddress finds the ObjectAddress for the extension described
|
||||
* by the AlterExtensionStmt. If missing_ok is false, then this function throws an
|
||||
|
|
|
@ -148,21 +148,7 @@ extern List * PostprocessDefineCollationStmt(Node *stmt, const char *queryString
|
|||
/* extension.c - forward declarations */
|
||||
extern bool IsCreateAlterExtensionUpdateCitusStmt(Node *parsetree);
|
||||
extern void ErrorIfUnstableCreateOrAlterExtensionStmt(Node *parsetree);
|
||||
extern List * PostprocessCreateExtensionStmt(Node *stmt, const char *queryString);
|
||||
extern List * PreprocessDropExtensionStmt(Node *stmt, const char *queryString);
|
||||
extern List * PreprocessAlterExtensionSchemaStmt(Node *stmt,
|
||||
const char *queryString);
|
||||
extern List * PostprocessAlterExtensionSchemaStmt(Node *stmt,
|
||||
const char *queryString);
|
||||
extern List * PreprocessAlterExtensionUpdateStmt(Node *stmt,
|
||||
const char *queryString);
|
||||
extern List * PreprocessAlterExtensionContentsStmt(Node *node,
|
||||
const char *queryString);
|
||||
extern List * CreateExtensionDDLCommand(const ObjectAddress *extensionAddress);
|
||||
extern ObjectAddress AlterExtensionSchemaStmtObjectAddress(Node *stmt,
|
||||
bool missing_ok);
|
||||
extern ObjectAddress AlterExtensionUpdateStmtObjectAddress(Node *stmt,
|
||||
bool missing_ok);
|
||||
|
||||
|
||||
/* foreign_constraint.c - forward declarations */
|
||||
|
@ -204,7 +190,6 @@ extern List * PostprocessIndexStmt(Node *node,
|
|||
extern void ErrorIfUnsupportedAlterIndexStmt(AlterTableStmt *alterTableStatement);
|
||||
|
||||
/* objectaddress.c - forward declarations */
|
||||
extern ObjectAddress CreateExtensionStmtObjectAddress(Node *stmt, bool missing_ok);
|
||||
extern ObjectAddress AlterExtensionStmtObjectAddress(Node *stmt, bool missing_ok);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue