* get_attgenerated * * Given the relation id and the attribute number, * return the "attgenerated" field from the attribute relation. * * Errors if not found. * * Since not generated is represented by '\0', this can also be used as a * Boolean test. */
| 1060 | * Boolean test. |
| 1061 | */ |
| 1062 | char |
| 1063 | get_attgenerated(Oid relid, AttrNumber attnum) |
| 1064 | { |
| 1065 | HeapTuple tp; |
| 1066 | Form_pg_attribute att_tup; |
| 1067 | char result; |
| 1068 | |
| 1069 | tp = SearchSysCache2(ATTNUM, |
| 1070 | ObjectIdGetDatum(relid), |
| 1071 | Int16GetDatum(attnum)); |
| 1072 | if (!HeapTupleIsValid(tp)) |
| 1073 | elog(ERROR, "cache lookup failed for attribute %d of relation %u", |
| 1074 | attnum, relid); |
| 1075 | att_tup = (Form_pg_attribute) GETSTRUCT(tp); |
| 1076 | result = att_tup->attgenerated; |
| 1077 | ReleaseSysCache(tp); |
| 1078 | return result; |
| 1079 | } |
| 1080 | |
| 1081 | /* |
| 1082 | * get_atttype |
no test coverage detected