From f44074fa5e4f1ceaf90c2cfafe6a089ac06d2ee2 Mon Sep 17 00:00:00 2001 From: Julien Rouhaud Date: Sat, 18 Apr 2026 15:42:53 +0800 Subject: [PATCH] Fix long standing Int8GetDatum bugs A plain SQL integer (int4) should use Int32GetDatum. Also, pg_amproc.amprocnum is a smallint (int2), so the correct macro to get a Datum is Int16GetDatum. --- hypopg_index.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hypopg_index.c b/hypopg_index.c index d631429..9a6a299 100644 --- a/hypopg_index.c +++ b/hypopg_index.c @@ -1249,7 +1249,7 @@ hypopg(PG_FUNCTION_ARGS) values[i++] = CStringGetTextDatum(entry->indexname); values[i++] = ObjectIdGetDatum(entry->oid); values[i++] = ObjectIdGetDatum(entry->relid); - values[i++] = Int8GetDatum(entry->ncolumns); + values[i++] = Int32GetDatum(entry->ncolumns); values[i++] = BoolGetDatum(entry->unique); values[i++] = PointerGetDatum(buildint2vector(entry->indexkeys, entry->ncolumns)); values[i++] = PointerGetDatum(buildoidvector(entry->indexcollations, entry->ncolumns)); @@ -2290,7 +2290,7 @@ hypo_can_return(hypoIndex * entry, Oid atttype, int i, char *amname) ObjectIdGetDatum(entry->opfamily[i]), ObjectIdGetDatum(entry->opcintype[i]), ObjectIdGetDatum(entry->opcintype[i]), - Int8GetDatum(GIST_FETCH_PROC)); + Int16GetDatum(GIST_FETCH_PROC)); if (!HeapTupleIsValid(tuple)) return false; @@ -2315,7 +2315,7 @@ hypo_can_return(hypoIndex * entry, Oid atttype, int i, char *amname) ObjectIdGetDatum(entry->opfamily[i]), ObjectIdGetDatum(entry->opcintype[i]), ObjectIdGetDatum(entry->opcintype[i]), - Int8GetDatum(SPGIST_CONFIG_PROC)); + Int16GetDatum(SPGIST_CONFIG_PROC)); /* just in case */ if (!HeapTupleIsValid(tuple))