Re: [HACKERS] Compiler warning in costsize.c - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] Compiler warning in costsize.c
Date
Msg-id 11157.1491583350@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] Compiler warning in costsize.c  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: [HACKERS] Compiler warning in costsize.c  (David Rowley <david.rowley@2ndquadrant.com>)
List pgsql-hackers
Michael Paquier <michael.paquier@gmail.com> writes:
> Bah. This actually fixes nothing. Attached is a different patch that
> really addresses the problem, by removing the variable because we
> don't want planner_rt_fetch() to run for non-Assert builds.

I don't really like any of these fixes, because they take the code
further away from the structure used by all the other similar functions
in costsize.c, and they will be hard to undo whenever these functions
grow a reason to look at the RTE normally (outside asserts).

I'd be happier with something along the line of
RangeTblEntry *rte;ListCell   *lc;
/* Should only be applied to base relations that are subqueries */Assert(rel->relid > 0);rte =
planner_rt_fetch(rel->relid,root);
 
#ifdef USE_ASSERT_CHECKINGAssert(rte->rtekind == RTE_SUBQUERY);
#else(void) rte;  /* silence unreferenced-variable complaints */
#endif

assuming that that actually does silence the warning on MSVC.

BTW, is it really true that only these two places produce such warnings
on MSVC?  I see about three dozen uses of PG_USED_FOR_ASSERTS_ONLY in our
tree, and I'd have expected all of those places to be causing warnings on
a compiler that doesn't have a way to understand that annotation.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: [HACKERS] Performance issue with postgres9.6
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] ExecPrepareExprList and per-query context