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

Function transformColumnNameList

src/backend/commands/tablecmds.c:12826–12857  ·  view source on GitHub ↗

* transformColumnNameList - transform list of column names * * Lookup each name and return its attnum and type OID */

Source from the content-addressed store, hash-verified

12824 * Lookup each name and return its attnum and type OID
12825 */
12826static int
12827transformColumnNameList(Oid relId, List *colList,
12828 int16 *attnums, Oid *atttypids)
12829{
12830 ListCell *l;
12831 int attnum;
12832
12833 attnum = 0;
12834 foreach(l, colList)
12835 {
12836 char *attname = strVal(lfirst(l));
12837 HeapTuple atttuple;
12838
12839 atttuple = SearchSysCacheAttName(relId, attname);
12840 if (!HeapTupleIsValid(atttuple))
12841 ereport(ERROR,
12842 (errcode(ERRCODE_UNDEFINED_COLUMN),
12843 errmsg("column \"%s\" referenced in foreign key constraint does not exist",
12844 attname)));
12845 if (attnum >= INDEX_MAX_KEYS)
12846 ereport(ERROR,
12847 (errcode(ERRCODE_TOO_MANY_COLUMNS),
12848 errmsg("cannot have more than %d keys in a foreign key",
12849 INDEX_MAX_KEYS)));
12850 attnums[attnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->attnum;
12851 atttypids[attnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->atttypid;
12852 ReleaseSysCache(atttuple);
12853 attnum++;
12854 }
12855
12856 return attnum;
12857}
12858
12859/*
12860 * transformFkeyGetPrimaryKey -

Callers 1

Calls 5

SearchSysCacheAttNameFunction · 0.85
ReleaseSysCacheFunction · 0.85
foreachFunction · 0.50
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected