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

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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-30 12:29:51
Message-ID: CAEudQArvAuxx7peM3JfrD8mGLv09e=s2HYn_MtDei0Aa_TyMFA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em seg., 30 de mar. de 2020 às 06:06, Magnus Hagander <magnus(at)hagander(dot)net>
escreveu:

> On Sat, Mar 28, 2020 at 11:49 AM Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
> wrote:
> >
> > Em sex., 27 de mar. de 2020 às 20:49, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
> escreveu:
> >>
> >> 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.
> >
> > Neither you nor I can say with 100% certainty that the original author's
> intention.
>
> Given that Tom is the original author, I think it's a lot more likely
> that he knows what the original authors intention was. It's certainly
> been a few years, so it probably isn't 100%, but the likelihood is
> pretty good.
>
Of course, now we all know..

>
>
> >> > 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.)
> >
> > I completely disagree. My tools have proven their worth, including
> finding serious errors in the code, which fortunately have been fixed by
> other committers.
> > When issuing this alert, the tool does not value judgment regarding
> performance or optimization, but it does an excellent job of finding
> similar patterns in adjacent lines, and the only thing it asked for was to
> be asked if this was really the case. original author's intention.
>
> All tools will give false positives. This simply seems one of those --
> it certainly could have been indicating a problem, but in this case it
> didn't.
>
that's what you said, it could be a big problem, if it were the case of
copy-past error.
I do not consider it a false positive, since the tool did not claim it was
a bug, she warned and asked to question.

regards,
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2020-03-30 12:30:32 Re: truncating timestamps on arbitrary intervals
Previous Message Ranier Vilela 2020-03-30 12:25:27 Re: Possible copy and past error? (\usr\backend\commands\analyze.c)