diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index e9955707fa..79439a0c66 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -312,6 +312,14 @@ ConstructTupleDescriptor(Relation heapRelation, to->attcollation = (i < numkeyatts) ? collationObjectId[i] : InvalidOid; + /* + * Set the attribute name as specified by caller. + */ + if (colnames_item == NULL) /* shouldn't happen */ + elog(ERROR, "too few entries in colnames list"); + namestrcpy(&to->attname, (const char *) lfirst(colnames_item)); + colnames_item = lnext(indexColNames, colnames_item); + /* * For simple index columns, we copy some pg_attribute fields from the * parent relation. For expressions we have to look at the expression @@ -329,7 +337,6 @@ ConstructTupleDescriptor(Relation heapRelation, from = TupleDescAttr(heapTupDesc, AttrNumberGetAttrOffset(atnum)); - namecpy(&to->attname, &from->attname); to->atttypid = from->atttypid; to->attlen = from->attlen; to->attndims = from->attndims; @@ -390,14 +397,6 @@ ConstructTupleDescriptor(Relation heapRelation, */ to->attrelid = InvalidOid; - /* - * Set the attribute name as specified by caller. - */ - if (colnames_item == NULL) /* shouldn't happen */ - elog(ERROR, "too few entries in colnames list"); - namestrcpy(&to->attname, (const char *) lfirst(colnames_item)); - colnames_item = lnext(indexColNames, colnames_item); - /* * Check the opclass and index AM to see if either provides a keytype * (overriding the attribute type). Opclass (if exists) takes