Refactoring SearchSysCache + HeapTupleIsValid

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Refactoring SearchSysCache + HeapTupleIsValid
Дата
Msg-id 4940FB80.90303@gmx.net
обсуждение исходный текст
Ответы Re: Refactoring SearchSysCache + HeapTupleIsValid  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Our code contains about 200 copies of the following code:

tuple = SearchSysCache[Copy](FOOOID, ObjectIdGetDatum(fooid), 0, 0, 0);
if (!HeapTupleIsValid(tuple))    elog(ERROR, "cache lookup failed for foo %u", fooid);

This only counts elog() calls, not user-facing error messages 
constructed with ereport().

Shouldn't we try to refactor this, maybe like this:

HeapTuple
SearchSysCache[Copy]Oid(int cacheId, Oid key)
{    HeapTuple tuple;
    tuple = SearchSysCache[Copy](cacheId, ObjectIdGetDatum(key),                                 0, 0, 0);    if
(!HeapTupleIsValid(tuple))       elog(ERROR, "cache lookup failed in cache %d (relation %u) for 
 
OID %u",             cacheId, cacheinfo[cacheId].reloid, key);
    return tuple;
}

Maybe some other verb than "Search" could be used to make it clearer 
that this function has its own error handler.


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Zdenek Kotala
Дата:
Сообщение: Re: visibility maps
Следующее
От: "Sreejesh O S"
Дата:
Сообщение: Re: COCOMO & Indians