1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

Cleanup of GiST extensions in contrib/: now that we always invoke GiST

methods in a short-lived memory context, there is no need for GiST methods
to do their own manual (and error-prone) memory management.
This commit is contained in:
Neil Conway
2005-05-21 12:08:06 +00:00
parent 875813439d
commit 36ab600511
16 changed files with 18 additions and 174 deletions

View File

@ -98,16 +98,12 @@ gbt_numeric_consistent(PG_FUNCTION_ARGS)
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
void *qtst = (void *) PG_GETARG_POINTER(1);
void *query = (void *) DatumGetNumeric(PG_GETARG_DATUM(1));
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
bool retval = FALSE;
bool retval;
GBT_VARKEY_R r = gbt_var_key_readable(key);
retval = gbt_var_consistent(&r, query, &strategy, GIST_LEAF(entry), &tinfo);
if (qtst != query)
pfree(query);
PG_RETURN_BOOL(retval);
}
@ -164,8 +160,6 @@ gbt_numeric_penalty(PG_FUNCTION_ARGS)
PointerGetDatum(uk.lower)
));
pfree(DatumGetPointer(uni));
os = DatumGetNumeric(DirectFunctionCall2(
numeric_sub,
PointerGetDatum(ok.upper),
@ -178,27 +172,21 @@ gbt_numeric_penalty(PG_FUNCTION_ARGS)
NumericGetDatum(os)
));
pfree(os);
if (NUMERIC_IS_NAN(us))
{
if (NUMERIC_IS_NAN(os))
*result = 0.0;
else
*result = 1.0;
}
else
{
Numeric nul = DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(0)));
*result = 0.0;
if (DirectFunctionCall2(numeric_gt, NumericGetDatum(ds), NumericGetDatum(nul)))
{
*result += FLT_MIN;
os = DatumGetNumeric(DirectFunctionCall2(
numeric_div,
@ -206,19 +194,12 @@ gbt_numeric_penalty(PG_FUNCTION_ARGS)
NumericGetDatum(us)
));
*result += (float4) DatumGetFloat8(DirectFunctionCall1(numeric_float8_no_overflow, NumericGetDatum(os)));
pfree(os);
}
pfree(nul);
}
if (*result > 0)
*result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
pfree(us);
pfree(ds);
PG_RETURN_POINTER(result);
}