1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-18 04:29:09 +03:00

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
This commit is contained in:
Tom Lane
2011-06-16 17:03:58 -04:00
parent 7357558fc8
commit bfcb9328e5
5 changed files with 114 additions and 121 deletions

View File

@@ -1603,21 +1603,23 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
replaces[i] = true;
}
i = 0;
values[i++] = ObjectIdGetDatum(relid); /* starelid */
values[i++] = Int16GetDatum(stats->attr->attnum); /* staattnum */
values[i++] = BoolGetDatum(inh); /* stainherit */
values[i++] = Float4GetDatum(stats->stanullfrac); /* stanullfrac */
values[i++] = Int32GetDatum(stats->stawidth); /* stawidth */
values[i++] = Float4GetDatum(stats->stadistinct); /* stadistinct */
values[Anum_pg_statistic_starelid - 1] = ObjectIdGetDatum(relid);
values[Anum_pg_statistic_staattnum - 1] = Int16GetDatum(stats->attr->attnum);
values[Anum_pg_statistic_stainherit - 1] = BoolGetDatum(inh);
values[Anum_pg_statistic_stanullfrac - 1] = Float4GetDatum(stats->stanullfrac);
values[Anum_pg_statistic_stawidth - 1] = Int32GetDatum(stats->stawidth);
values[Anum_pg_statistic_stadistinct - 1] = Float4GetDatum(stats->stadistinct);
i = Anum_pg_statistic_stakind1 - 1;
for (k = 0; k < STATISTIC_NUM_SLOTS; k++)
{
values[i++] = Int16GetDatum(stats->stakind[k]); /* stakindN */
}
i = Anum_pg_statistic_staop1 - 1;
for (k = 0; k < STATISTIC_NUM_SLOTS; k++)
{
values[i++] = ObjectIdGetDatum(stats->staop[k]); /* staopN */
}
i = Anum_pg_statistic_stanumbers1 - 1;
for (k = 0; k < STATISTIC_NUM_SLOTS; k++)
{
int nnum = stats->numnumbers[k];
@@ -1641,6 +1643,7 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
values[i++] = (Datum) 0;
}
}
i = Anum_pg_statistic_stavalues1 - 1;
for (k = 0; k < STATISTIC_NUM_SLOTS; k++)
{
if (stats->numvalues[k] > 0)

View File

@@ -157,11 +157,10 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
nulls[i] = false;
replaces[i] = true;
}
i = 0;
values[i++] = ObjectIdGetDatum(oid);
values[i++] = ObjectIdGetDatum(classoid);
values[i++] = Int32GetDatum(subid);
values[i++] = CStringGetTextDatum(comment);
values[Anum_pg_description_objoid - 1] = ObjectIdGetDatum(oid);
values[Anum_pg_description_classoid - 1] = ObjectIdGetDatum(classoid);
values[Anum_pg_description_objsubid - 1] = Int32GetDatum(subid);
values[Anum_pg_description_description - 1] = CStringGetTextDatum(comment);
}
/* Use the index to search for a matching old tuple */
@@ -257,10 +256,9 @@ CreateSharedComments(Oid oid, Oid classoid, char *comment)
nulls[i] = false;
replaces[i] = true;
}
i = 0;
values[i++] = ObjectIdGetDatum(oid);
values[i++] = ObjectIdGetDatum(classoid);
values[i++] = CStringGetTextDatum(comment);
values[Anum_pg_shdescription_objoid - 1] = ObjectIdGetDatum(oid);
values[Anum_pg_shdescription_classoid - 1] = ObjectIdGetDatum(classoid);
values[Anum_pg_shdescription_description - 1] = CStringGetTextDatum(comment);
}
/* Use the index to search for a matching old tuple */