Fixes review notes

pull/7404/head
gurkanindibay 2024-02-07 14:07:17 +03:00
parent 78d850950b
commit 94450cd391
1 changed files with 42 additions and 42 deletions

View File

@ -1672,48 +1672,6 @@ RunPostprocessMainDBCommand(Node *parsetree)
}
/*
* GetObjectInfo returns ObjectInfo for the target object of given parsetree.
*/
static ObjectInfo
GetObjectInfo(Node *parsetree)
{
if (IsA(parsetree, CreateRoleStmt))
{
CreateRoleStmt *stmt = castNode(CreateRoleStmt, parsetree);
ObjectInfo info = {
.name = stmt->role,
.id = get_role_oid(stmt->role, false)
};
return info;
}
/* Add else if branches for other statement types */
elog(ERROR, "unsupported statement type");
}
/*
* MarkObjectDistributedInNonMainDb marks the given object as distributed on the
* non-main database.
*/
static void
MarkObjectDistributedInNonMainDb(Node *parsetree)
{
ObjectInfo objectInfo = GetObjectInfo(parsetree);
StringInfo mainDBQuery = makeStringInfo();
appendStringInfo(mainDBQuery,
MARK_OBJECT_DISTRIBUTED,
AuthIdRelationId,
quote_literal_cstr(objectInfo.name),
objectInfo.id,
quote_literal_cstr(CurrentUserName()));
RunCitusMainDBQuery(mainDBQuery->data);
}
/*
* IsStatementSupportedInNonMainDb returns true if the statement is supported from a
* non-main database.
@ -1756,3 +1714,45 @@ StatementRequiresMarkDistributedFromNonMainDb(Node *parsetree)
return false;
}
/*
* MarkObjectDistributedInNonMainDb marks the given object as distributed on the
* non-main database.
*/
static void
MarkObjectDistributedInNonMainDb(Node *parsetree)
{
ObjectInfo objectInfo = GetObjectInfo(parsetree);
StringInfo mainDBQuery = makeStringInfo();
appendStringInfo(mainDBQuery,
MARK_OBJECT_DISTRIBUTED,
AuthIdRelationId,
quote_literal_cstr(objectInfo.name),
objectInfo.id,
quote_literal_cstr(CurrentUserName()));
RunCitusMainDBQuery(mainDBQuery->data);
}
/*
* GetObjectInfo returns ObjectInfo for the target object of given parsetree.
*/
static ObjectInfo
GetObjectInfo(Node *parsetree)
{
if (IsA(parsetree, CreateRoleStmt))
{
CreateRoleStmt *stmt = castNode(CreateRoleStmt, parsetree);
ObjectInfo info = {
.name = stmt->role,
.id = get_role_oid(stmt->role, false)
};
return info;
}
/* Add else if branches for other statement types */
elog(ERROR, "unsupported statement type");
}