Re: Refactoring SearchSysCache + HeapTupleIsValid

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Refactoring SearchSysCache + HeapTupleIsValid
Date: 2008-12-11 13:28:08
Message-ID: 6051.1229002088@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zdenek Kotala 2008-12-11 13:33:32 Re: visibility maps
Previous Message Pavan Deolasee 2008-12-11 13:24:18 Re: visibility maps