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

Function transformOfType

src/backend/parser/parse_utilcmd.c:1632–1675  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1630}
1631
1632static void
1633transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
1634{
1635 HeapTuple tuple;
1636 TupleDesc tupdesc;
1637 int i;
1638 Oid ofTypeId;
1639
1640 AssertArg(ofTypename);
1641
1642 tuple = typenameType(NULL, ofTypename, NULL);
1643 check_of_type(tuple);
1644 ofTypeId = ((Form_pg_type) GETSTRUCT(tuple))->oid;
1645 ofTypename->typeOid = ofTypeId; /* cached for later */
1646
1647 tupdesc = lookup_rowtype_tupdesc(ofTypeId, -1);
1648 for (i = 0; i < tupdesc->natts; i++)
1649 {
1650 Form_pg_attribute attr = TupleDescAttr(tupdesc, i);
1651 ColumnDef *n;
1652
1653 if (attr->attisdropped)
1654 continue;
1655
1656 n = makeNode(ColumnDef);
1657 n->colname = pstrdup(NameStr(attr->attname));
1658 n->typeName = makeTypeNameFromOid(attr->atttypid, attr->atttypmod);
1659 n->inhcount = 0;
1660 n->is_local = true;
1661 n->is_not_null = false;
1662 n->is_from_type = true;
1663 n->storage = 0;
1664 n->raw_default = NULL;
1665 n->cooked_default = NULL;
1666 n->collClause = NULL;
1667 n->collOid = attr->attcollation;
1668 n->constraints = NIL;
1669 n->location = -1;
1670 cxt->columns = lappend(cxt->columns, n);
1671 }
1672 DecrTupleDescRefCount(tupdesc);
1673
1674 ReleaseSysCache(tuple);
1675}
1676
1677/*
1678 * Generate an IndexStmt node using information from an already existing index

Callers 1

transformCreateStmtFunction · 0.85

Calls 8

typenameTypeFunction · 0.85
check_of_typeFunction · 0.85
lookup_rowtype_tupdescFunction · 0.85
makeTypeNameFromOidFunction · 0.85
lappendFunction · 0.85
DecrTupleDescRefCountFunction · 0.85
ReleaseSysCacheFunction · 0.85
pstrdupFunction · 0.50

Tested by

no test coverage detected