Re: minor nodeIndexScan tweak

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: minor nodeIndexScan tweak
Date: 2005-07-08 05:37:48
Message-ID: 9134.1120801068@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Neil Conway <neilc(at)samurai(dot)com> writes:
> Per EDB's Coverity analysis, "runtimeKeyInfo" is only non-NULL if
> "econtext" is also non-NULL, so we can eliminate a conditional on the
> former by moving it inside an "if" block for the latter.

This is premature optimization par excellance --- it saves one if-test,
in a not very performance-critical routine. I disagree that it improves
the code clarity: it's far from obvious that being-passed-an-outer-tuple
is the same condition as has-runtime-keys, and I can think of numerous
possible future changes that would render the conditions distinct again.
So please, don't do it.

> ! if (!(IsA(leftop, Var) &&
> ! var_is_rel((Var *) leftop)))
> elog(ERROR, "indexqual doesn't have key on left side");

> ! if (!(IsA(leftop, Var) && var_is_rel((Var *) leftop)))
> elog(ERROR, "indexqual doesn't have key on left side");

Just FYI, the reason for the line break is that pgindent will make it
look uglier if it's all on one line. The IsA construct seems to confuse
pgindent somehow ...

regards, tom lane

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message jtv 2005-07-08 05:41:02 Re: patch: garbage error strings in libpq
Previous Message Neil Conway 2005-07-08 05:15:37 minor nodeIndexScan tweak