1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-15 05:46:52 +03:00

Grab the low-hanging fruit from forcing USE_FLOAT8_BYVAL to true.

Remove conditionally-compiled code for the other case.

Replace uses of FLOAT8PASSBYVAL with constant "true", mainly because
it was quite confusing in cases where the type we were dealing with
wasn't float8.

I left the associated pg_control and Pg_magic_struct fields in place.
Perhaps we should get rid of them, but it would save little, so it
doesn't seem worth thinking hard about the compatibility implications.
I just labeled them "vestigial" in places where that seemed helpful.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/1749799.1752797397@sss.pgh.pa.us
This commit is contained in:
Tom Lane
2025-08-13 17:18:13 -04:00
parent 6aebedc384
commit ee54046601
22 changed files with 100 additions and 313 deletions

View File

@@ -31,13 +31,6 @@ PG_FUNCTION_INFO_V1(gbt_time_sortsupport);
PG_FUNCTION_INFO_V1(gbt_timetz_sortsupport);
#ifdef USE_FLOAT8_BYVAL
#define TimeADTGetDatumFast(X) TimeADTGetDatum(X)
#else
#define TimeADTGetDatumFast(X) PointerGetDatum(&(X))
#endif
static bool
gbt_timegt(const void *a, const void *b, FmgrInfo *flinfo)
{
@@ -45,8 +38,8 @@ gbt_timegt(const void *a, const void *b, FmgrInfo *flinfo)
const TimeADT *bb = (const TimeADT *) b;
return DatumGetBool(DirectFunctionCall2(time_gt,
TimeADTGetDatumFast(*aa),
TimeADTGetDatumFast(*bb)));
TimeADTGetDatum(*aa),
TimeADTGetDatum(*bb)));
}
static bool
@@ -56,8 +49,8 @@ gbt_timege(const void *a, const void *b, FmgrInfo *flinfo)
const TimeADT *bb = (const TimeADT *) b;
return DatumGetBool(DirectFunctionCall2(time_ge,
TimeADTGetDatumFast(*aa),
TimeADTGetDatumFast(*bb)));
TimeADTGetDatum(*aa),
TimeADTGetDatum(*bb)));
}
static bool
@@ -67,8 +60,8 @@ gbt_timeeq(const void *a, const void *b, FmgrInfo *flinfo)
const TimeADT *bb = (const TimeADT *) b;
return DatumGetBool(DirectFunctionCall2(time_eq,
TimeADTGetDatumFast(*aa),
TimeADTGetDatumFast(*bb)));
TimeADTGetDatum(*aa),
TimeADTGetDatum(*bb)));
}
static bool
@@ -78,8 +71,8 @@ gbt_timele(const void *a, const void *b, FmgrInfo *flinfo)
const TimeADT *bb = (const TimeADT *) b;
return DatumGetBool(DirectFunctionCall2(time_le,
TimeADTGetDatumFast(*aa),
TimeADTGetDatumFast(*bb)));
TimeADTGetDatum(*aa),
TimeADTGetDatum(*bb)));
}
static bool
@@ -89,8 +82,8 @@ gbt_timelt(const void *a, const void *b, FmgrInfo *flinfo)
const TimeADT *bb = (const TimeADT *) b;
return DatumGetBool(DirectFunctionCall2(time_lt,
TimeADTGetDatumFast(*aa),
TimeADTGetDatumFast(*bb)));
TimeADTGetDatum(*aa),
TimeADTGetDatum(*bb)));
}
static int
@@ -100,9 +93,9 @@ gbt_timekey_cmp(const void *a, const void *b, FmgrInfo *flinfo)
timeKEY *ib = (timeKEY *) (((const Nsrt *) b)->t);
int res;
res = DatumGetInt32(DirectFunctionCall2(time_cmp, TimeADTGetDatumFast(ia->lower), TimeADTGetDatumFast(ib->lower)));
res = DatumGetInt32(DirectFunctionCall2(time_cmp, TimeADTGetDatum(ia->lower), TimeADTGetDatum(ib->lower)));
if (res == 0)
return DatumGetInt32(DirectFunctionCall2(time_cmp, TimeADTGetDatumFast(ia->upper), TimeADTGetDatumFast(ib->upper)));
return DatumGetInt32(DirectFunctionCall2(time_cmp, TimeADTGetDatum(ia->upper), TimeADTGetDatum(ib->upper)));
return res;
}
@@ -115,8 +108,8 @@ gbt_time_dist(const void *a, const void *b, FmgrInfo *flinfo)
Interval *i;
i = DatumGetIntervalP(DirectFunctionCall2(time_mi_time,
TimeADTGetDatumFast(*aa),
TimeADTGetDatumFast(*bb)));
TimeADTGetDatum(*aa),
TimeADTGetDatum(*bb)));
return fabs(INTERVAL_TO_SEC(i));
}
@@ -279,14 +272,14 @@ gbt_time_penalty(PG_FUNCTION_ARGS)
double res2;
intr = DatumGetIntervalP(DirectFunctionCall2(time_mi_time,
TimeADTGetDatumFast(newentry->upper),
TimeADTGetDatumFast(origentry->upper)));
TimeADTGetDatum(newentry->upper),
TimeADTGetDatum(origentry->upper)));
res = INTERVAL_TO_SEC(intr);
res = Max(res, 0);
intr = DatumGetIntervalP(DirectFunctionCall2(time_mi_time,
TimeADTGetDatumFast(origentry->lower),
TimeADTGetDatumFast(newentry->lower)));
TimeADTGetDatum(origentry->lower),
TimeADTGetDatum(newentry->lower)));
res2 = INTERVAL_TO_SEC(intr);
res2 = Max(res2, 0);
@@ -297,8 +290,8 @@ gbt_time_penalty(PG_FUNCTION_ARGS)
if (res > 0)
{
intr = DatumGetIntervalP(DirectFunctionCall2(time_mi_time,
TimeADTGetDatumFast(origentry->upper),
TimeADTGetDatumFast(origentry->lower)));
TimeADTGetDatum(origentry->upper),
TimeADTGetDatum(origentry->lower)));
*result += FLT_MIN;
*result += (float) (res / (res + INTERVAL_TO_SEC(intr)));
*result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
@@ -334,8 +327,8 @@ gbt_timekey_ssup_cmp(Datum x, Datum y, SortSupport ssup)
/* for leaf items we expect lower == upper, so only compare lower */
return DatumGetInt32(DirectFunctionCall2(time_cmp,
TimeADTGetDatumFast(arg1->lower),
TimeADTGetDatumFast(arg2->lower)));
TimeADTGetDatum(arg1->lower),
TimeADTGetDatum(arg2->lower)));
}
Datum