Rename 'cmd' to 'cmd_name' in CreatePolicyStmt
authorStephen Frost
Fri, 21 Aug 2015 12:22:29 +0000 (08:22 -0400)
committerStephen Frost
Fri, 21 Aug 2015 12:22:29 +0000 (08:22 -0400)
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.

src/backend/commands/policy.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/parser/gram.y
src/include/nodes/parsenodes.h

index bcf4a8f35d1f08587d6cf727d11c436ab9ef579a..45326a3bec40d1a9bbefd2916b6a77c140187977 100644 (file)
@@ -108,25 +108,25 @@ RangeVarCallbackForPolicy(const RangeVar *rv, Oid relid, Oid oldrelid,
 static char
 parse_policy_command(const char *cmd_name)
 {
-   char        cmd;
+   char        polcmd;
 
    if (!cmd_name)
        elog(ERROR, "unrecognized policy command");
 
    if (strcmp(cmd_name, "all") == 0)
-       cmd = '*';
+       polcmd = '*';
    else if (strcmp(cmd_name, "select") == 0)
-       cmd = ACL_SELECT_CHR;
+       polcmd = ACL_SELECT_CHR;
    else if (strcmp(cmd_name, "insert") == 0)
-       cmd = ACL_INSERT_CHR;
+       polcmd = ACL_INSERT_CHR;
    else if (strcmp(cmd_name, "update") == 0)
-       cmd = ACL_UPDATE_CHR;
+       polcmd = ACL_UPDATE_CHR;
    else if (strcmp(cmd_name, "delete") == 0)
-       cmd = ACL_DELETE_CHR;
+       polcmd = ACL_DELETE_CHR;
    else
        elog(ERROR, "unrecognized policy command");
 
-   return cmd;
+   return polcmd;
 }
 
 /*
@@ -480,7 +480,7 @@ CreatePolicy(CreatePolicyStmt *stmt)
    int         i;
 
    /* 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.
@@ -674,7 +674,7 @@ AlterPolicy(AlterPolicyStmt *stmt)
    bool        replaces[Natts_pg_policy];
    ObjectAddress target;
    ObjectAddress myself;
-   Datum       cmd_datum;
+   Datum       polcmd_datum;
    char        polcmd;
    bool        polcmd_isnull;
    int         i;
@@ -775,11 +775,11 @@ AlterPolicy(AlterPolicyStmt *stmt)
                        RelationGetRelationName(target_table))));
 
    /* 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),
                             &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.
index 0070976bc0f32a8cf255cb919a6a7c75825eb447..573afb4f2ae037beef3b9c2f78f9a4fe1610ee7a 100644 (file)
@@ -4071,7 +4071,7 @@ _copyCreatePolicyStmt(const CreatePolicyStmt *from)
 
    COPY_STRING_FIELD(policy_name);
    COPY_NODE_FIELD(table);
-   COPY_STRING_FIELD(cmd);
+   COPY_STRING_FIELD(cmd_name);
    COPY_NODE_FIELD(roles);
    COPY_NODE_FIELD(qual);
    COPY_NODE_FIELD(with_check);
index 7f2049638eb9e2da6afda408f67e2b1c08b507d0..2938add10d01bcba3d53c5905a03f8e602715905 100644 (file)
@@ -2064,7 +2064,7 @@ _equalCreatePolicyStmt(const CreatePolicyStmt *a, const CreatePolicyStmt *b)
 {
    COMPARE_STRING_FIELD(policy_name);
    COMPARE_NODE_FIELD(table);
-   COMPARE_STRING_FIELD(cmd);
+   COMPARE_STRING_FIELD(cmd_name);
    COMPARE_NODE_FIELD(roles);
    COMPARE_NODE_FIELD(qual);
    COMPARE_NODE_FIELD(with_check);
index 3b5cef4ff41f9a6cf5c58e717e41d40bcf53cf83..554e7bb8e2f89c8336fcb1c94c7235e65f77f941 100644 (file)
@@ -4592,7 +4592,7 @@ CreatePolicyStmt:
                    CreatePolicyStmt *n = makeNode(CreatePolicyStmt);
                    n->policy_name = $3;
                    n->table = $5;
-                   n->cmd = $6;
+                   n->cmd_name = $6;
                    n->roles = $7;
                    n->qual = $8;
                    n->with_check = $9;
index c5fa78b71c6720e9420d27aafe0219016fcd8d53..4ba7cc4ba3d28ee22756320ddd986da4ef0e38ee 100644 (file)
@@ -2039,7 +2039,7 @@ typedef struct CreatePolicyStmt
    NodeTag     type;
    char       *policy_name;    /* Policy's name */
    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 */
    Node       *qual;           /* the policy's condition */
    Node       *with_check;     /* the policy's WITH CHECK condition. */