compiler warning in set_tablefunc_size_estimates

Started by Robert Haasabout 9 years ago3 messageshackers
Jump to latest
#1Robert Haas
robertmhaas@gmail.com

I tried a non-cassert compile on a machine that has a pickier compiler
than my laptop, and got:

costsize.c: In function ‘set_tablefunc_size_estimates’:
costsize.c:4574:17: error: variable ‘rte’ set but not used
[-Werror=unused-but-set-variable]

That appears to be a legitimate gripe. Perhaps:

diff --git a/src/backend/optimizer/path/costsize.c
b/src/backend/optimizer/path/costsize.c
index e78f3a8..c23f681 100644
--- a/src/backend/optimizer/path/costsize.c
+++ b/src/backend/optimizer/path/costsize.c
@@ -4571,12 +4571,9 @@ set_function_size_estimates(PlannerInfo *root,
RelOptInfo *rel)
 void
 set_tablefunc_size_estimates(PlannerInfo *root, RelOptInfo *rel)
 {
-       RangeTblEntry *rte;
-
        /* Should only be applied to base relations that are functions */
        Assert(rel->relid > 0);
-       rte = planner_rt_fetch(rel->relid, root);
-       Assert(rte->rtekind == RTE_TABLEFUNC);
+       Assert(planner_rt_fetch(rel->relid, root)->rtekind == RTE_TABLEFUNC);

rel->tuples = 100;

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Robert Haas (#1)
Re: compiler warning in set_tablefunc_size_estimates

Robert Haas <robertmhaas@gmail.com> writes:

I tried a non-cassert compile on a machine that has a pickier compiler
than my laptop, and got:

costsize.c: In function ‘set_tablefunc_size_estimates’:
costsize.c:4574:17: error: variable ‘rte’ set but not used
[-Werror=unused-but-set-variable]

That appears to be a legitimate gripe. Perhaps:

I think PG_USED_FOR_ASSERTS_ONLY would be a better solution. It's
only happenstance that the function currently uses the RTE just
for this; if it grows another use, your approach would be harder
to clean up.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Robert Haas
robertmhaas@gmail.com
In reply to: Tom Lane (#2)
Re: compiler warning in set_tablefunc_size_estimates

On Thu, Mar 9, 2017 at 4:39 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Robert Haas <robertmhaas@gmail.com> writes:

I tried a non-cassert compile on a machine that has a pickier compiler
than my laptop, and got:

costsize.c: In function ‘set_tablefunc_size_estimates’:
costsize.c:4574:17: error: variable ‘rte’ set but not used
[-Werror=unused-but-set-variable]

That appears to be a legitimate gripe. Perhaps:

I think PG_USED_FOR_ASSERTS_ONLY would be a better solution. It's
only happenstance that the function currently uses the RTE just
for this; if it grows another use, your approach would be harder
to clean up.

Yeah, we might have to revert the entire -4/+1 line patch.

Actually, the thing I don't like about that is that that then we're
still emitting code for the planner_rt_fetch. That probably doesn't
cost much, but why do it?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers