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.
This commit is contained in:
Julien Rouhaud 2026-04-18 15:42:53 +08:00
parent 0b5782baff
commit f44074fa5e
No known key found for this signature in database
GPG key ID: F7420C4512807BCA

View file

@ -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))