Fix compiler warning
authorPeter Eisentraut <peter@eisentraut.org>
Fri, 5 Apr 2019 07:23:07 +0000 (09:23 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 5 Apr 2019 07:23:07 +0000 (09:23 +0200)
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>
src/backend/utils/cache/lsyscache.c

index 10895567c09d0c1ec971cbd43c32f0c373f8f2a2..b4f2d0f35ab692f9504d3723fdf3becda14ce9f3 100644 (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;
 }
 
 /*