Re: remove the unneeded header file math.h in binaryheap.c

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: zengman <zengman@halodbtech.com>
Cc: Álvaro Herrera <alvherre@kurilemu.de>, pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-01-15T15:16:13Z
Lists: pgsql-hackers
Hi,

On 2026-01-15 23:08:28 +0800, zengman wrote:
> I removed the <math.h> include from two files `dt_common.c` and `timestamp.c`, and the code compiles successfully in my environment.
> Would you consider adding this to the patch?

Just because removing a platform include file works in some environment is
*NOT* sufficient to remove platform include files. There are a lot of
variations between platforms about when some include files are implicitly
included via other include files. Just removing them because it works on one
platform ends up with more niche operating systems failing to build, which we
may only figure out months or even years down the road.

At the very least you need to figure out why the includes where added and why
that reason is not present anymore.

Greetings,

Andres Freund



Commits

  1. Remove #include <math.h> where not needed

  2. Remove unnecessary uses of Abs()

  3. Basic binary heap implementation.