Skip to content

Commit 49f9a28

Browse files
committed
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.
1 parent 0070fd8 commit 49f9a28

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

src/backend/commands/policy.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,25 @@ RangeVarCallbackForPolicy(const RangeVar *rv, Oid relid, Oid oldrelid,
108108
static char
109109
parse_policy_command(const char *cmd_name)
110110
{
111-
char cmd;
111+
char polcmd;
112112

113113
if (!cmd_name)
114114
elog(ERROR, "unrecognized policy command");
115115

116116
if (strcmp(cmd_name, "all") == 0)
117-
cmd = '*';
117+
polcmd = '*';
118118
else if (strcmp(cmd_name, "select") == 0)
119-
cmd = ACL_SELECT_CHR;
119+
polcmd = ACL_SELECT_CHR;
120120
else if (strcmp(cmd_name, "insert") == 0)
121-
cmd = ACL_INSERT_CHR;
121+
polcmd = ACL_INSERT_CHR;
122122
else if (strcmp(cmd_name, "update") == 0)
123-
cmd = ACL_UPDATE_CHR;
123+
polcmd = ACL_UPDATE_CHR;
124124
else if (strcmp(cmd_name, "delete") == 0)
125-
cmd = ACL_DELETE_CHR;
125+
polcmd = ACL_DELETE_CHR;
126126
else
127127
elog(ERROR, "unrecognized policy command");
128128

129-
return cmd;
129+
return polcmd;
130130
}
131131

132132
/*
@@ -480,7 +480,7 @@ CreatePolicy(CreatePolicyStmt *stmt)
480480
int i;
481481

482482
/* Parse command */
483-
polcmd = parse_policy_command(stmt->cmd);
483+
polcmd = parse_policy_command(stmt->cmd_name);
484484

485485
/*
486486
* If the command is SELECT or DELETE then WITH CHECK should be NULL.
@@ -674,7 +674,7 @@ AlterPolicy(AlterPolicyStmt *stmt)
674674
bool replaces[Natts_pg_policy];
675675
ObjectAddress target;
676676
ObjectAddress myself;
677-
Datum cmd_datum;
677+
Datum polcmd_datum;
678678
char polcmd;
679679
bool polcmd_isnull;
680680
int i;
@@ -775,11 +775,11 @@ AlterPolicy(AlterPolicyStmt *stmt)
775775
RelationGetRelationName(target_table))));
776776

777777
/* Get policy command */
778-
cmd_datum = heap_getattr(policy_tuple, Anum_pg_policy_polcmd,
778+
polcmd_datum = heap_getattr(policy_tuple, Anum_pg_policy_polcmd,
779779
RelationGetDescr(pg_policy_rel),
780780
&polcmd_isnull);
781781
Assert(!polcmd_isnull);
782-
polcmd = DatumGetChar(cmd_datum);
782+
polcmd = DatumGetChar(polcmd_datum);
783783

784784
/*
785785
* If the command is SELECT or DELETE then WITH CHECK should be NULL.

src/backend/nodes/copyfuncs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4071,7 +4071,7 @@ _copyCreatePolicyStmt(const CreatePolicyStmt *from)
40714071

40724072
COPY_STRING_FIELD(policy_name);
40734073
COPY_NODE_FIELD(table);
4074-
COPY_STRING_FIELD(cmd);
4074+
COPY_STRING_FIELD(cmd_name);
40754075
COPY_NODE_FIELD(roles);
40764076
COPY_NODE_FIELD(qual);
40774077
COPY_NODE_FIELD(with_check);

src/backend/nodes/equalfuncs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ _equalCreatePolicyStmt(const CreatePolicyStmt *a, const CreatePolicyStmt *b)
20642064
{
20652065
COMPARE_STRING_FIELD(policy_name);
20662066
COMPARE_NODE_FIELD(table);
2067-
COMPARE_STRING_FIELD(cmd);
2067+
COMPARE_STRING_FIELD(cmd_name);
20682068
COMPARE_NODE_FIELD(roles);
20692069
COMPARE_NODE_FIELD(qual);
20702070
COMPARE_NODE_FIELD(with_check);

src/backend/parser/gram.y

+1-1
Original file line numberDiff line numberDiff line change
@@ -4592,7 +4592,7 @@ CreatePolicyStmt:
45924592
CreatePolicyStmt *n = makeNode(CreatePolicyStmt);
45934593
n->policy_name = $3;
45944594
n->table = $5;
4595-
n->cmd = $6;
4595+
n->cmd_name = $6;
45964596
n->roles = $7;
45974597
n->qual = $8;
45984598
n->with_check = $9;

src/include/nodes/parsenodes.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2039,7 +2039,7 @@ typedef struct CreatePolicyStmt
20392039
NodeTag type;
20402040
char *policy_name; /* Policy's name */
20412041
RangeVar *table; /* the table name the policy applies to */
2042-
char *cmd; /* the command name the policy applies to */
2042+
char *cmd_name; /* the command name the policy applies to */
20432043
List *roles; /* the roles associated with the policy */
20442044
Node *qual; /* the policy's condition */
20452045
Node *with_check; /* the policy's WITH CHECK condition. */

0 commit comments

Comments
 (0)