summaryrefslogtreecommitdiff
path: root/src/backend/rewrite/rewriteDefine.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-06-16 17:03:58 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-06-16 17:04:40 -0400
commitbfcb9328e51eaaa21c92a1f2d7262758afb843e8 (patch)
tree20a30f7595e14acd9840dedce9be50d742afb069 /src/backend/rewrite/rewriteDefine.c
parent7357558fc8866e3a449aa9473c419b593d67b5b6 (diff)
Index tuple data arrays using Anum_xxx symbolic constants instead of "i++".
We had already converted most places to this style, but this patch gets the last few that were still doing it the old way. The main advantage is that this exposes a greppable name for each target column, rather than having to rely on comments (which a couple of places failed to provide anyhow). Richard Hopkins, additional work by me to clean up update_attstats() too
Diffstat (limited to 'src/backend/rewrite/rewriteDefine.c')
-rw-r--r--src/backend/rewrite/rewriteDefine.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c
index 52c55def155..bb7d468d19d 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -60,7 +60,6 @@ InsertRule(char *rulname,
{
char *evqual = nodeToString(event_qual);
char *actiontree = nodeToString((Node *) action);
- int i;
Datum values[Natts_pg_rewrite];
bool nulls[Natts_pg_rewrite];
bool replaces[Natts_pg_rewrite];
@@ -78,16 +77,15 @@ InsertRule(char *rulname,
*/
MemSet(nulls, false, sizeof(nulls));
- i = 0;
namestrcpy(&rname, rulname);
- values[i++] = NameGetDatum(&rname); /* rulename */
- values[i++] = ObjectIdGetDatum(eventrel_oid); /* ev_class */
- values[i++] = Int16GetDatum(evslot_index); /* ev_attr */
- values[i++] = CharGetDatum(evtype + '0'); /* ev_type */
- values[i++] = CharGetDatum(RULE_FIRES_ON_ORIGIN); /* ev_enabled */
- values[i++] = BoolGetDatum(evinstead); /* is_instead */
- values[i++] = CStringGetTextDatum(evqual); /* ev_qual */
- values[i++] = CStringGetTextDatum(actiontree); /* ev_action */
+ values[Anum_pg_rewrite_rulename - 1] = NameGetDatum(&rname);
+ values[Anum_pg_rewrite_ev_class - 1] = ObjectIdGetDatum(eventrel_oid);
+ values[Anum_pg_rewrite_ev_attr - 1] = Int16GetDatum(evslot_index);
+ values[Anum_pg_rewrite_ev_type - 1] = CharGetDatum(evtype + '0');
+ values[Anum_pg_rewrite_ev_enabled - 1] = CharGetDatum(RULE_FIRES_ON_ORIGIN);
+ values[Anum_pg_rewrite_is_instead - 1] = BoolGetDatum(evinstead);
+ values[Anum_pg_rewrite_ev_qual - 1] = CStringGetTextDatum(evqual);
+ values[Anum_pg_rewrite_ev_action - 1] = CStringGetTextDatum(actiontree);
/*
* Ready to store new pg_rewrite tuple