mirror of https://github.com/citusdata/citus.git
Manage special case for "GRANT ALL" with columns
`GRANT/REVOKE ALL (col, ...)` cannot be mixed with other privilege and because there is at least one column defined, the privileges node is defined so the existing code is valid for table but not for columns. Add a condition to ensure `ALL` is defined alone and added to the privilege string when needed. Comment added based on: https://github.com/citusdata/citus/pull/7918#discussion_r1994929886pull/7918/head
parent
7766bcbd85
commit
0338d0af32
|
@ -73,6 +73,7 @@ PreprocessGrantStmt(Node *node, const char *queryString,
|
|||
/* deparse the privileges */
|
||||
if (grantStmt->privileges == NIL)
|
||||
{
|
||||
/* this is used for table level only */
|
||||
appendStringInfo(&privsString, "ALL");
|
||||
}
|
||||
else
|
||||
|
@ -88,11 +89,35 @@ PreprocessGrantStmt(Node *node, const char *queryString,
|
|||
{
|
||||
appendStringInfoString(&privsString, ", ");
|
||||
}
|
||||
isFirst = false;
|
||||
|
||||
Assert(priv->priv_name != NULL);
|
||||
|
||||
if (priv->priv_name)
|
||||
{
|
||||
appendStringInfo(&privsString, "%s", priv->priv_name);
|
||||
}
|
||||
/*
|
||||
* ALL can only be set alone.
|
||||
* And ALL is not added as a keyword in priv_name by parser, but
|
||||
* because there are column(s) defined, a grantStmt->privileges is
|
||||
* defined. So we need to handle this special case here (see if
|
||||
* condition above).
|
||||
*/
|
||||
else if (isFirst)
|
||||
{
|
||||
/* this is used for column level only */
|
||||
appendStringInfo(&privsString, "ALL");
|
||||
}
|
||||
/*
|
||||
* Instead of relying only on the syntax check done by Postgres and
|
||||
* adding an assert here, add a default ERROR if ALL is not first
|
||||
* and no priv_name is defined.
|
||||
*/
|
||||
else
|
||||
{
|
||||
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR),
|
||||
errmsg("Cannot parse GRANT/REVOKE privileges")));
|
||||
}
|
||||
|
||||
isFirst = false;
|
||||
|
||||
if (priv->cols != NIL)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue