]> granicus.if.org Git - postgresql/commitdiff
Rename 'cmd' to 'cmd_name' in CreatePolicyStmt
authorStephen Frost <sfrost@snowman.net>
Fri, 21 Aug 2015 12:22:22 +0000 (08:22 -0400)
committerStephen Frost <sfrost@snowman.net>
Fri, 21 Aug 2015 12:22:22 +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 1c8425d37d4cf100d12eec30046ef1b6f27d7962..bd2e80e2d1dd06e8c43993bc0ef4728fd1ad1cb7 100644 (file)
@@ -4083,7 +4083,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 1d6c43c2d6b0b3af93f5672dbc1e4c7fc56815a8..19412fee662823ef33c2cbb026e2226921fad646 100644 (file)
@@ -2074,7 +2074,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 426a09dac381a53a1745ff04f8ab52776bd0dae3..1efc6d66d709744733b890457ace5e8ccf6c7957 100644 (file)
@@ -4613,7 +4613,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 151c93a078ea009aa8bd229a64581cb6cce79fc9..f0dcd2fa6e2b1d716281d52b2c7786c50896c47b 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. */