Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3c99788

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 7ec8296 commit 3c99788

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

src/backend/commands/policy.c

Lines changed: 11 additions & 11 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4083,7 +4083,7 @@ _copyCreatePolicyStmt(const CreatePolicyStmt *from)
40834083

40844084
COPY_STRING_FIELD(policy_name);
40854085
COPY_NODE_FIELD(table);
4086-
COPY_STRING_FIELD(cmd);
4086+
COPY_STRING_FIELD(cmd_name);
40874087
COPY_NODE_FIELD(roles);
40884088
COPY_NODE_FIELD(qual);
40894089
COPY_NODE_FIELD(with_check);

src/backend/nodes/equalfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,7 @@ _equalCreatePolicyStmt(const CreatePolicyStmt *a, const CreatePolicyStmt *b)
20742074
{
20752075
COMPARE_STRING_FIELD(policy_name);
20762076
COMPARE_NODE_FIELD(table);
2077-
COMPARE_STRING_FIELD(cmd);
2077+
COMPARE_STRING_FIELD(cmd_name);
20782078
COMPARE_NODE_FIELD(roles);
20792079
COMPARE_NODE_FIELD(qual);
20802080
COMPARE_NODE_FIELD(with_check);

src/backend/parser/gram.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4613,7 +4613,7 @@ CreatePolicyStmt:
46134613
CreatePolicyStmt *n = makeNode(CreatePolicyStmt);
46144614
n->policy_name = $3;
46154615
n->table = $5;
4616-
n->cmd = $6;
4616+
n->cmd_name = $6;
46174617
n->roles = $7;
46184618
n->qual = $8;
46194619
n->with_check = $9;

src/include/nodes/parsenodes.h

Lines changed: 1 addition & 1 deletion
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)