* This function initializes a single attribute structure in
* a previously allocated tuple descriptor.
*
+ * If attributeName is NULL, the attname field is set to an empty string
+ * (this is for cases where we don't know or need a name for the field).
+ * Also, some callers use this function to change the datatype-related fields
+ * in an existing tupdesc; they pass attributeName = NameStr(att->attname)
+ * to indicate that the attname field shouldn't be modified.
+ *
* Note that attcollation is set to the default for the specified datatype.
* If a nondefault collation is needed, insert it afterwards using
* TupleDescInitEntryCollation.
/*
* Note: attributeName can be NULL, because the planner doesn't always
* fill in valid resname values in targetlists, particularly for resjunk
- * attributes.
+ * attributes. Also, do nothing if caller wants to re-use the old attname.
*/
- if (attributeName != NULL)
- namestrcpy(&(att->attname), attributeName);
- else
+ if (attributeName == NULL)
MemSet(NameStr(att->attname), 0, NAMEDATALEN);
+ else if (attributeName != NameStr(att->attname))
+ namestrcpy(&(att->attname), attributeName);
att->attstattarget = -1;
att->attcacheoff = -1;
}
-# resolve_polymorphic_tupdesc(), a subroutine of internal_get_result_type(),
-# can instigate a memcpy() call where the two pointer arguments are exactly
-# equal. The behavior thereof is formally undefined, but implementations
-# where it's anything other than a no-op are thought unlikely.
-{
- noopmemcpy_internal_get_result_type
- Memcheck:Overlap
-
- fun:*strncpy*
- fun:namestrcpy
- fun:TupleDescInitEntry
- ...
- fun:internal_get_result_type
-}
-
-
# gcc on ppc64 can generate a four-byte read to fetch the final "char" fields
# of a FormData_pg_cast. This is valid compiler behavior, because a proper
# FormData_pg_cast has trailing padding. Tuples we treat as structures omit