Re: Possible copy and past error? (\usr\backend\commands\analyze.c)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Possible copy and past error? (\usr\backend\commands\analyze.c)
Date: 2020-03-27 23:49:25
Message-ID: 31619.1585352965@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> writes:
> Can someone check if there is a copy and paste error, at file:
> \usr\backend\commands\analyze.c, at lines 2225 and 2226?
> int num_mcv = stats->attr->attstattarget;
> int num_bins = stats->attr->attstattarget;

No, that's intentional I believe. Those are independent variables
that just happen to start out with the same value.

> If they really are the same values, it could be changed to:

> int num_mcv = stats->attr->attstattarget;
> int num_bins = num_mcv;

That would make it look like they are interdependent, which they are not.

> To silence this alert.

If you have a tool that complains about that coding, I think the
tool needs a solid whack upside the head. There's nothing wrong
with the code, and it clearly expresses the intent, which the other
way doesn't. (Or in other words: it's the compiler's job to
optimize away the duplicate fetch. Not the programmer's.)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-03-27 23:57:12 Re: pgbench - refactor init functions with buffers
Previous Message Alvaro Herrera 2020-03-27 23:39:11 Re: allow online change primary_conninfo