postgrespro.git / summary / log / commit / refs

commit    edda32ee250fe480701083d4e072e06929991bf9
Author:   Peter Eisentraut <peter@eisentraut.org>
Date:     Fri Apr 05 07:23:07 2019 +0000

    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>


src/backend/utils/cache/lsyscache.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 10895567c0..b4f2d0f35a 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -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; } /* [parent: 82150a05be0d]