Rename EnumValuesCreate() single-letter variable names to useful
variable names.
This commit is contained in:
parent
c44327afa4
commit
0ef5910d6d
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_enum.c,v 1.10 2009/12/19 00:47:57 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_enum.c,v 1.11 2009/12/24 22:17:58 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -39,14 +39,14 @@ EnumValuesCreate(Oid enumTypeOid, List *vals)
|
|||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
NameData enumlabel;
|
NameData enumlabel;
|
||||||
Oid *oids;
|
Oid *oids;
|
||||||
int i,
|
int elemno,
|
||||||
n;
|
num_elems;
|
||||||
Datum values[Natts_pg_enum];
|
Datum values[Natts_pg_enum];
|
||||||
bool nulls[Natts_pg_enum];
|
bool nulls[Natts_pg_enum];
|
||||||
ListCell *lc;
|
ListCell *lc;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
n = list_length(vals);
|
num_elems = list_length(vals);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX we do not bother to check the list of values for duplicates --- if
|
* XXX we do not bother to check the list of values for duplicates --- if
|
||||||
@ -64,23 +64,23 @@ EnumValuesCreate(Oid enumTypeOid, List *vals)
|
|||||||
* counter wraps all the way around before we finish. Which seems
|
* counter wraps all the way around before we finish. Which seems
|
||||||
* unlikely.
|
* unlikely.
|
||||||
*/
|
*/
|
||||||
oids = (Oid *) palloc(n * sizeof(Oid));
|
oids = (Oid *) palloc(num_elems * sizeof(Oid));
|
||||||
for (i = 0; i < n; i++)
|
for (elemno = 0; elemno < num_elems; elemno++)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* The pg_enum.oid is stored in user tables. This oid must be
|
* The pg_enum.oid is stored in user tables. This oid must be
|
||||||
* preserved by binary upgrades.
|
* preserved by binary upgrades.
|
||||||
*/
|
*/
|
||||||
oids[i] = GetNewOid(pg_enum);
|
oids[elemno] = GetNewOid(pg_enum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sort them, just in case counter wrapped from high to low */
|
/* sort them, just in case counter wrapped from high to low */
|
||||||
qsort(oids, n, sizeof(Oid), oid_cmp);
|
qsort(oids, num_elems, sizeof(Oid), oid_cmp);
|
||||||
|
|
||||||
/* and make the entries */
|
/* and make the entries */
|
||||||
memset(nulls, false, sizeof(nulls));
|
memset(nulls, false, sizeof(nulls));
|
||||||
|
|
||||||
i = 0;
|
elemno = 0;
|
||||||
foreach(lc, vals)
|
foreach(lc, vals)
|
||||||
{
|
{
|
||||||
char *lab = strVal(lfirst(lc));
|
char *lab = strVal(lfirst(lc));
|
||||||
@ -101,13 +101,13 @@ EnumValuesCreate(Oid enumTypeOid, List *vals)
|
|||||||
values[Anum_pg_enum_enumlabel - 1] = NameGetDatum(&enumlabel);
|
values[Anum_pg_enum_enumlabel - 1] = NameGetDatum(&enumlabel);
|
||||||
|
|
||||||
tup = heap_form_tuple(tupDesc, values, nulls);
|
tup = heap_form_tuple(tupDesc, values, nulls);
|
||||||
HeapTupleSetOid(tup, oids[i]);
|
HeapTupleSetOid(tup, oids[elemno]);
|
||||||
|
|
||||||
simple_heap_insert(pg_enum, tup);
|
simple_heap_insert(pg_enum, tup);
|
||||||
CatalogUpdateIndexes(pg_enum, tup);
|
CatalogUpdateIndexes(pg_enum, tup);
|
||||||
heap_freetuple(tup);
|
heap_freetuple(tup);
|
||||||
|
|
||||||
i++;
|
elemno++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user