> On Jan 4, 2026, at 15:35, David Rowley <dgrowleyml@gmail.com> wrote:
>
> On Sun, 4 Jan 2026 at 19:28, David Rowley <dgrowleyml@gmail.com> wrote:
>> I can take care of the overflow issue. I feel the test is a step too
>> far as it seems unlikely ever to be rebroken, but thanks for the
>> SQL-based test case to demonstrate the issue.
>
> Pushed.
>
> David
I searched over the source tree to see if there is a similar buggy bsearch comparator and didn’t find any. However, I
founda set of comparators in common/int.h, so I think it’s better to use them here:
```
diff --git a/contrib/intarray/_int_selfuncs.c b/contrib/intarray/_int_selfuncs.c
index c3e19cdf27f..80faac8ae71 100644
--- a/contrib/intarray/_int_selfuncs.c
+++ b/contrib/intarray/_int_selfuncs.c
@@ -19,6 +19,7 @@
#include "catalog/pg_operator.h"
#include "catalog/pg_statistic.h"
#include "catalog/pg_type.h"
+#include "common/int.h"
#include "miscadmin.h"
#include "utils/fmgrprotos.h"
#include "utils/lsyscache.h"
@@ -331,10 +332,5 @@ compare_val_int4(const void *a, const void *b)
int32 key = *(int32 *) a;
int32 value = DatumGetInt32(*(const Datum *) b);
- if (key < value)
- return -1;
- else if (key > value)
- return 1;
- else
- return 0;
+ return pg_cmp_s32(key, value);
}
```
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/