aboutsummaryrefslogtreecommitdiff
path: root/contrib/intarray/_int_gist.c
diff options
context:
space:
mode:
authorTeodor Sigaev <teodor@sigaev.ru>2006-04-03 10:45:28 +0000
committerTeodor Sigaev <teodor@sigaev.ru>2006-04-03 10:45:28 +0000
commit2ba15dbfc38ab89e07fe399af4d601579f211fdb (patch)
tree658f710d5d8580f3735197638fed7f3694a67413 /contrib/intarray/_int_gist.c
parent1750f60ef3e730faf72ecfa7fbd7ee6ad799f293 (diff)
downloadpostgresql-2ba15dbfc38ab89e07fe399af4d601579f211fdb.tar.gz
postgresql-2ba15dbfc38ab89e07fe399af4d601579f211fdb.zip
Detoast query in g_intbig_consistent and copy query in g_int_consistent.
Minor cleanups.
Diffstat (limited to 'contrib/intarray/_int_gist.c')
-rw-r--r--contrib/intarray/_int_gist.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/contrib/intarray/_int_gist.c b/contrib/intarray/_int_gist.c
index 2d5e82a4596..b534a358e6b 100644
--- a/contrib/intarray/_int_gist.c
+++ b/contrib/intarray/_int_gist.c
@@ -32,20 +32,24 @@ Datum
g_int_consistent(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
- ArrayType *query = (ArrayType *) PG_GETARG_POINTER(1);
+ ArrayType *query = (ArrayType *) PG_DETOAST_DATUM_COPY(PG_GETARG_POINTER(1));
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
bool retval;
- if (strategy == BooleanSearchStrategy)
- PG_RETURN_BOOL(execconsistent((QUERYTYPE *) query,
+ if (strategy == BooleanSearchStrategy) {
+ retval =execconsistent((QUERYTYPE *) query,
(ArrayType *) DatumGetPointer(entry->key),
- ISLEAFKEY((ArrayType *) DatumGetPointer(entry->key))));
+ ISLEAFKEY((ArrayType *) DatumGetPointer(entry->key)));
+ pfree( query );
+
+ PG_RETURN_BOOL(retval);
+ }
- /* XXX are we sure it's safe to scribble on the query object here? */
- /* XXX what about toasted input? */
/* sort query for fast search, key is already sorted */
- if (ARRISVOID(query))
+ if (ARRISVOID(query)) {
+ pfree( query );
PG_RETURN_BOOL(false);
+ }
PREPAREARR(query);
switch (strategy)
@@ -81,6 +85,7 @@ g_int_consistent(PG_FUNCTION_ARGS)
default:
retval = FALSE;
}
+ pfree( query );
PG_RETURN_BOOL(retval);
}