| 1630 | } |
| 1631 | |
| 1632 | static void |
| 1633 | transformOfType(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 |
no test coverage detected