Warn we are not propagating GRANT/REVOKE to workers

warn_grant
Hadi Moshayedi 2019-03-22 11:03:44 -07:00 committed by Philip Dubé
parent c436f1b668
commit 6094b830de
1 changed files with 55 additions and 0 deletions

View File

@ -8,12 +8,67 @@
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "catalog/namespace.h"
#include "distributed/commands.h"
#include "distributed/metadata_cache.h"
/* placeholder for PreprocessGrantStmt */
List *
PreprocessGrantStmt(Node *node, const char *queryString)
{
bool showPropagationWarning = false;
if (grantStmt->targtype == ACL_TARGET_ALL_IN_SCHEMA)
{
showPropagationWarning = true;
}
else if (grantStmt->targtype == ACL_TARGET_OBJECT)
{
switch (grantStmt->objtype)
{
case OBJECT_SCHEMA:
case OBJECT_DATABASE:
{
showPropagationWarning = true;
break;
}
case OBJECT_TABLE:
{
ListCell *rangeVarCell = NULL;
foreach(rangeVarCell, grantStmt->objects)
{
RangeVar *rangeVar = (RangeVar *) lfirst(rangeVarCell);
Oid relationId = RangeVarGetRelid(rangeVar, NoLock, false);
if (OidIsValid(relationId) && IsDistributedTable(relationId))
{
showPropagationWarning = true;
break;
}
}
break;
}
/* no need to warn when object is sequence, domain, function, etc. */
default:
{
break;
}
}
}
if (showPropagationWarning)
{
const char *type = grantStmt->is_grant ? "GRANT" : "REVOKE";
ereport(WARNING, (errmsg("not propagating %s command to worker nodes", type)));
}
return NIL;
}