Re: [PATCH] Fix division by zero (explain.c) - Mailing list pgsql-hackers

From Ranier Vilela
Subject Re: [PATCH] Fix division by zero (explain.c)
Date
Msg-id CAEudQAp+7qoS92-4V1vLChpdY3vEkLCbf+gye6P-4cirE-0z0A@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Fix division by zero (explain.c)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [PATCH] Fix division by zero (explain.c)
List pgsql-hackers
Em sáb., 9 de mai. de 2020 às 01:45, Tom Lane <tgl@sss.pgh.pa.us> escreveu:
James Coleman <jtc331@gmail.com> writes:
> There are always full sort groups before any prefix groups can happen,
> so we know (even though the tooling doesn't) that the 2nd test can
> never contradict the first.

So maybe an assertion enforcing that would be appropriate?
Untested, but:

-                       if (fullsortGroupInfo->groupCount == 0 &&
-                               prefixsortGroupInfo->groupCount == 0)
+                       if (fullsortGroupInfo->groupCount == 0)
+                       {
+                               Assert(prefixsortGroupInfo->groupCount == 0);
                                continue;
+                       }
I agree, asserts always help.

regards,
Ranier Vilela
Attachment

pgsql-hackers by date:

Previous
From: Juan José Santamaría Flecha
Date:
Subject: Re: stat() on Windows might cause error if target file is larger than 4GB
Next
From: Etsuro Fujita
Date:
Subject: Re: PG 13 release notes, first draft