Fix compiler warning

Rewrite get_attgenerated() to avoid compiler warning if the compiler
does not recognize that elog(ERROR) does not return.

Reported-by: David Rowley <david.rowley@2ndquadrant.com>
This commit is contained in:
Peter Eisentraut 2019-04-05 09:23:07 +02:00
parent 82150a05be
commit edda32ee25
1 changed files with 7 additions and 10 deletions

View File

@ -836,22 +836,19 @@ char
get_attgenerated(Oid relid, AttrNumber attnum)
{
HeapTuple tp;
Form_pg_attribute att_tup;
char result;
tp = SearchSysCache2(ATTNUM,
ObjectIdGetDatum(relid),
Int16GetDatum(attnum));
if (HeapTupleIsValid(tp))
{
Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
char result;
result = att_tup->attgenerated;
ReleaseSysCache(tp);
return result;
}
else
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
att_tup = (Form_pg_attribute) GETSTRUCT(tp);
result = att_tup->attgenerated;
ReleaseSysCache(tp);
return result;
}
/*