MCPcopy Create free account
hub / github.com/apache/cloudberry / TupleDescInitEntry

Function TupleDescInitEntry

src/backend/access/common/tupdesc.c:590–657  ·  view source on GitHub ↗

* TupleDescInitEntry * 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 attribut

Source from the content-addressed store, hash-verified

588 * TupleDescInitEntryCollation.
589 */
590void
591TupleDescInitEntry(TupleDesc desc,
592 AttrNumber attributeNumber,
593 const char *attributeName,
594 Oid oidtypeid,
595 int32 typmod,
596 int attdim)
597{
598 HeapTuple tuple;
599 Form_pg_type typeForm;
600 Form_pg_attribute att;
601
602 /*
603 * sanity checks
604 */
605 AssertArg(PointerIsValid(desc));
606 AssertArg(attributeNumber >= 1);
607 AssertArg(attributeNumber <= desc->natts);
608
609 /*
610 * initialize the attribute fields
611 */
612 att = TupleDescAttr(desc, attributeNumber - 1);
613
614 att->attrelid = 0; /* dummy value */
615
616 /*
617 * Note: attributeName can be NULL, because the planner doesn't always
618 * fill in valid resname values in targetlists, particularly for resjunk
619 * attributes. Also, do nothing if caller wants to re-use the old attname.
620 */
621 if (attributeName == NULL)
622 MemSet(NameStr(att->attname), 0, NAMEDATALEN);
623 else if (attributeName != NameStr(att->attname))
624 namestrcpy(&(att->attname), attributeName);
625
626 att->attstattarget = -1;
627 att->attcacheoff = -1;
628 att->atttypmod = typmod;
629
630 att->attnum = attributeNumber;
631 att->attndims = attdim;
632
633 att->attnotnull = false;
634 att->atthasdef = false;
635 att->atthasmissing = false;
636 att->attidentity = '\0';
637 att->attgenerated = '\0';
638 att->attisdropped = false;
639 att->attislocal = true;
640 att->attinhcount = 0;
641 /* attacl, attoptions and attfdwoptions are not present in tupledescs */
642
643 tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(oidtypeid));
644 if (!HeapTupleIsValid(tuple))
645 elog(ERROR, "cache lookup failed for type %u", oidtypeid);
646 typeForm = (Form_pg_type) GETSTRUCT(tuple);
647

Callers 15

pg_visibility_tupdescFunction · 0.85
readindexFunction · 0.85
verify_heapam_tupdescFunction · 0.85
pax_get_operatorsFunction · 0.85
ClusteringMethod · 0.85
pax_get_catalog_rowsFunction · 0.85
pg_logdir_ls_internalFunction · 0.85
materializeResultFunction · 0.85
materializeQueryResultFunction · 0.85

Calls 4

namestrcpyFunction · 0.85
SearchSysCache1Function · 0.85
ObjectIdGetDatumFunction · 0.85
ReleaseSysCacheFunction · 0.85

Tested by 8

test_predtestFunction · 0.68
assign_new_recordFunction · 0.68
describeFunction · 0.68
project_describeFunction · 0.68
userdata_describeFunction · 0.68
gp_keepalives_checkFunction · 0.68
test_xlog_aoFunction · 0.68
dirty_buffersFunction · 0.68