Re: BUG #19603: Vuln47: distance_taxicab and distance_chebyshev silently return 0 instead of NaN when a cube coordin

From: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
To: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, 1217816127(at)qq(dot)com
Subject: Re: BUG #19603: Vuln47: distance_taxicab and distance_chebyshev silently return 0 instead of NaN when a cube coordin
Date: 2026-11-06 09:56:46
Message-ID: CAJTYsWUiikmNW9t+qohPHv9JPzbeckTwKZECQpLSJO_6vDUCLg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On Fri, 6 Nov 2026 at 14:30, Aleksander Alekseev
<aleksander(at)tigerdata(dot)com> wrote:
>
> > Thanks, I've changed the test in v3. I just wanted not to overboard
> > the test suite hence had left a few things out.
> >
> > v3 attached.
>
> v3 is a significant improvement over v2. One thing that catches my eye:
>
> ```
> @@ -1145,7 +1152,7 @@ SELECT cube_is_point('(0,1,2)'::cube);
> t
> (1 row)
>
> -SELECT cube_is_point('(0,1,2),(0,1,2)'::cube);
> +SELECT cube_is_point(cube(ARRAY['NaN'::float8], ARRAY['NaN'::float8]));
> cube_is_point
> ---------------
> t
> @@ -1375,7 +1382,7 @@ SELECT cube_size('(4,8),(15,16)'::cube);
> 88
> (1 row)
>
> -SELECT cube_size('(42,137)'::cube);
> +SELECT cube_size(cube_subset('(NaN,0),(NaN,1)'::cube, ARRAY[1]));
> cube_size
> -----------
> 0
> ```
>
> The patch shouldn't remove any existing tests, only add new ones.

Hmm, I was thinking of making it shorter by removing some older
ones which did have some coverage, but you are right. Added it back.

> IMO two patches should be squashed into one. They are addressing
> basically one issue. One patch would be much easier to test and
> review. In particular, one shouldn't make sure that 0001 is a correct
> patch without 0002 applied.

Yeah that was for ease of review, incase earlier someone was just
referring to the bug details for review. Squashed into one now.

v4 attached. Thanks again for the review.

Regards,
Ayush

Attachment Content-Type Size
v4-0001-Fix-NaN-handling-in-cube.patch application/octet-stream 21.6 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Hironobu SUZUKI 2026-11-06 10:39:16 EXPLAIN (ANALYZE, FORMAT JSON) emits invalid output for MERGE on a partitioned table
Previous Message Aleksander Alekseev 2026-11-06 09:00:14 Re: BUG #19603: Vuln47: distance_taxicab and distance_chebyshev silently return 0 instead of NaN when a cube coordin