Re: Refactoring SearchSysCache + HeapTupleIsValid
| От | Tom Lane |
|---|---|
| Тема | Re: Refactoring SearchSysCache + HeapTupleIsValid |
| Дата | |
| Msg-id | 6051.1229002088@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Refactoring SearchSysCache + HeapTupleIsValid (Peter Eisentraut <peter_e@gmx.net>) |
| Ответы |
Re: Refactoring SearchSysCache + HeapTupleIsValid
Re: Refactoring SearchSysCache + HeapTupleIsValid |
| Список | pgsql-hackers |
Peter Eisentraut <peter_e@gmx.net> writes:
> 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);
> ...
> Shouldn't we try to refactor this, maybe like this:
I can't get excited about it, and I definitely do not like your
suggestion of embedding particular assumptions about the lookup keys
into the API. What you've got here is a worse error message and a
recipe for proliferation of ad-hoc wrappers around SearchSysCache,
in return for saving a couple of lines per call site.
If we could just move the error into SearchSysCache it might be worth
doing, but I think there are callers that need the flexibility to not
fail.
regards, tom lane
В списке pgsql-hackers по дате отправления: