Rename 'cmd' to 'cmd_name' in CreatePolicyStmt

To avoid confusion, rename CreatePolicyStmt's 'cmd' to 'cmd_name',
parse_policy_command's 'cmd' to 'polcmd', and AlterPolicy's 'cmd_datum'
to 'polcmd_datum', per discussion with Noah and as a follow-up to his
correction of copynodes/equalnodes handling of the CreatePolicyStmt
'cmd' field.

Back-patch to 9.5 where the CreatePolicyStmt was introduced, as we
are still only in alpha.
This commit is contained in:
Stephen Frost 2015-08-21 08:22:22 -04:00
parent 7ec8296e70
commit 3c99788797
5 changed files with 15 additions and 15 deletions

View File

@ -108,25 +108,25 @@ RangeVarCallbackForPolicy(const RangeVar *rv, Oid relid, Oid oldrelid,
static char static char
parse_policy_command(const char *cmd_name) parse_policy_command(const char *cmd_name)
{ {
char cmd; char polcmd;
if (!cmd_name) if (!cmd_name)
elog(ERROR, "unrecognized policy command"); elog(ERROR, "unrecognized policy command");
if (strcmp(cmd_name, "all") == 0) if (strcmp(cmd_name, "all") == 0)
cmd = '*'; polcmd = '*';
else if (strcmp(cmd_name, "select") == 0) else if (strcmp(cmd_name, "select") == 0)
cmd = ACL_SELECT_CHR; polcmd = ACL_SELECT_CHR;
else if (strcmp(cmd_name, "insert") == 0) else if (strcmp(cmd_name, "insert") == 0)
cmd = ACL_INSERT_CHR; polcmd = ACL_INSERT_CHR;
else if (strcmp(cmd_name, "update") == 0) else if (strcmp(cmd_name, "update") == 0)
cmd = ACL_UPDATE_CHR; polcmd = ACL_UPDATE_CHR;
else if (strcmp(cmd_name, "delete") == 0) else if (strcmp(cmd_name, "delete") == 0)
cmd = ACL_DELETE_CHR; polcmd = ACL_DELETE_CHR;
else else
elog(ERROR, "unrecognized policy command"); elog(ERROR, "unrecognized policy command");
return cmd; return polcmd;
} }
/* /*
@ -480,7 +480,7 @@ CreatePolicy(CreatePolicyStmt *stmt)
int i; int i;
/* Parse command */ /* Parse command */
polcmd = parse_policy_command(stmt->cmd); polcmd = parse_policy_command(stmt->cmd_name);
/* /*
* If the command is SELECT or DELETE then WITH CHECK should be NULL. * If the command is SELECT or DELETE then WITH CHECK should be NULL.
@ -674,7 +674,7 @@ AlterPolicy(AlterPolicyStmt *stmt)
bool replaces[Natts_pg_policy]; bool replaces[Natts_pg_policy];
ObjectAddress target; ObjectAddress target;
ObjectAddress myself; ObjectAddress myself;
Datum cmd_datum; Datum polcmd_datum;
char polcmd; char polcmd;
bool polcmd_isnull; bool polcmd_isnull;
int i; int i;
@ -775,11 +775,11 @@ AlterPolicy(AlterPolicyStmt *stmt)
RelationGetRelationName(target_table)))); RelationGetRelationName(target_table))));
/* Get policy command */ /* Get policy command */
cmd_datum = heap_getattr(policy_tuple, Anum_pg_policy_polcmd, polcmd_datum = heap_getattr(policy_tuple, Anum_pg_policy_polcmd,
RelationGetDescr(pg_policy_rel), RelationGetDescr(pg_policy_rel),
&polcmd_isnull); &polcmd_isnull);
Assert(!polcmd_isnull); Assert(!polcmd_isnull);
polcmd = DatumGetChar(cmd_datum); polcmd = DatumGetChar(polcmd_datum);
/* /*
* If the command is SELECT or DELETE then WITH CHECK should be NULL. * If the command is SELECT or DELETE then WITH CHECK should be NULL.

View File

@ -4083,7 +4083,7 @@ _copyCreatePolicyStmt(const CreatePolicyStmt *from)
COPY_STRING_FIELD(policy_name); COPY_STRING_FIELD(policy_name);
COPY_NODE_FIELD(table); COPY_NODE_FIELD(table);
COPY_STRING_FIELD(cmd); COPY_STRING_FIELD(cmd_name);
COPY_NODE_FIELD(roles); COPY_NODE_FIELD(roles);
COPY_NODE_FIELD(qual); COPY_NODE_FIELD(qual);
COPY_NODE_FIELD(with_check); COPY_NODE_FIELD(with_check);

View File

@ -2074,7 +2074,7 @@ _equalCreatePolicyStmt(const CreatePolicyStmt *a, const CreatePolicyStmt *b)
{ {
COMPARE_STRING_FIELD(policy_name); COMPARE_STRING_FIELD(policy_name);
COMPARE_NODE_FIELD(table); COMPARE_NODE_FIELD(table);
COMPARE_STRING_FIELD(cmd); COMPARE_STRING_FIELD(cmd_name);
COMPARE_NODE_FIELD(roles); COMPARE_NODE_FIELD(roles);
COMPARE_NODE_FIELD(qual); COMPARE_NODE_FIELD(qual);
COMPARE_NODE_FIELD(with_check); COMPARE_NODE_FIELD(with_check);

View File

@ -4613,7 +4613,7 @@ CreatePolicyStmt:
CreatePolicyStmt *n = makeNode(CreatePolicyStmt); CreatePolicyStmt *n = makeNode(CreatePolicyStmt);
n->policy_name = $3; n->policy_name = $3;
n->table = $5; n->table = $5;
n->cmd = $6; n->cmd_name = $6;
n->roles = $7; n->roles = $7;
n->qual = $8; n->qual = $8;
n->with_check = $9; n->with_check = $9;

View File

@ -2039,7 +2039,7 @@ typedef struct CreatePolicyStmt
NodeTag type; NodeTag type;
char *policy_name; /* Policy's name */ char *policy_name; /* Policy's name */
RangeVar *table; /* the table name the policy applies to */ RangeVar *table; /* the table name the policy applies to */
char *cmd; /* the command name the policy applies to */ char *cmd_name; /* the command name the policy applies to */
List *roles; /* the roles associated with the policy */ List *roles; /* the roles associated with the policy */
Node *qual; /* the policy's condition */ Node *qual; /* the policy's condition */
Node *with_check; /* the policy's WITH CHECK condition. */ Node *with_check; /* the policy's WITH CHECK condition. */