Update function dep check

velioglu/tmpfuncprop
Burak Velioglu 2022-02-13 17:17:46 +03:00
parent e249aa2d62
commit a58c15268b
No known key found for this signature in database
GPG Key ID: F6827E620F6549C6
2 changed files with 19 additions and 15 deletions

View File

@ -1328,13 +1328,13 @@ PostprocessCreateFunctionStmt(Node *node, const char *queryString)
}
ObjectAddress address = GetObjectAddressFromParseTree((Node *) stmt, false);
if (FunctionDependsOnNonDistributedRelation(&address))
if (!DependentRelationsOfFunctionCanBeDistributed(&address))
{
ereport(WARNING, (errmsg("Citus can't distribute functions having dependency on"
" non-distributed relations or sequences"),
" non-distributed relations"),
errdetail("Function will be created only locally"),
errhint("To distribute function, distribute dependent relations"
" and sequences first")));
" first")));
return NIL;
}
@ -1349,11 +1349,11 @@ PostprocessCreateFunctionStmt(Node *node, const char *queryString)
/*
* FunctionDependsOnNonDistributedRelation checks whether the given function depends
* on non-distributed relation.
* DependentRelationsOfFunctionCanBeDistributed checks whether Citus can distribute
* dependent relations of the given function.
*/
bool
FunctionDependsOnNonDistributedRelation(ObjectAddress *functionAddress)
DependentRelationsOfFunctionCanBeDistributed(ObjectAddress *functionAddress)
{
Assert(getObjectClass(functionAddress) == OCLASS_PROC);
@ -1366,19 +1366,23 @@ FunctionDependsOnNonDistributedRelation(ObjectAddress *functionAddress)
continue;
}
/*
* Since GetDependenciesForObject returns only non-distributed ones, any
* relation comes to that point is must be a non-distributed one.
*
* Citus can only distribute dependent non-distributed sequence and composite
* types.
*/
char relKind = get_rel_relkind(dependency->objectId);
/* only distributed ones are allowed */
if (relKind == RELKIND_RELATION ||
relKind == RELKIND_PARTITIONED_TABLE ||
relKind == RELKIND_FOREIGN_TABLE ||
relKind == RELKIND_SEQUENCE)
if (relKind == RELKIND_SEQUENCE || relKind == RELKIND_COMPOSITE_TYPE)
{
return true;
continue;
}
return false;
}
return false;
return true;
}

View File

@ -259,7 +259,7 @@ extern List * PreprocessCreateFunctionStmt(Node *stmt, const char *queryString,
ProcessUtilityContext processUtilityContext);
extern List * PostprocessCreateFunctionStmt(Node *stmt,
const char *queryString);
extern bool FunctionDependsOnNonDistributedRelation(ObjectAddress *functionAddress);
extern bool DependentRelationsOfFunctionCanBeDistributed(ObjectAddress *functionAddress);
extern ObjectAddress CreateFunctionStmtObjectAddress(Node *stmt,
bool missing_ok);
extern ObjectAddress DefineAggregateStmtObjectAddress(Node *stmt,