aboutsummaryrefslogtreecommitdiff
path: root/contrib/intarray/_intbig_gist.c
diff options
context:
space:
mode:
authorTeodor Sigaev <teodor@sigaev.ru>2006-04-03 10:27:28 +0000
committerTeodor Sigaev <teodor@sigaev.ru>2006-04-03 10:27:28 +0000
commite314c3f53f2ff8e58f459fb3211ae87fce460be7 (patch)
treecbfe9afa0b6895fa468969d93bee836d18c968d9 /contrib/intarray/_intbig_gist.c
parente243ba23d3abf0c844659b87403fa9ee55340ee8 (diff)
downloadpostgresql-e314c3f53f2ff8e58f459fb3211ae87fce460be7.tar.gz
postgresql-e314c3f53f2ff8e58f459fb3211ae87fce460be7.zip
Detoast query in g_intbig_consistent and copy query in g_int_consistent.
Minor cleanups.
Diffstat (limited to 'contrib/intarray/_intbig_gist.c')
-rw-r--r--contrib/intarray/_intbig_gist.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/contrib/intarray/_intbig_gist.c b/contrib/intarray/_intbig_gist.c
index e4588a0d4bb..a6cc6b4f24d 100644
--- a/contrib/intarray/_intbig_gist.c
+++ b/contrib/intarray/_intbig_gist.c
@@ -440,22 +440,27 @@ Datum
g_intbig_consistent(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
- ArrayType *query = (ArrayType *) PG_GETARG_POINTER(1);
+ ArrayType *query = (ArrayType *) PG_DETOAST_DATUM(PG_GETARG_POINTER(1));
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
bool retval;
- if ( ISALLTRUE(DatumGetPointer(entry->key)) )
+ if ( ISALLTRUE(DatumGetPointer(entry->key)) ) {
+ PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(true);
+ }
if (strategy == BooleanSearchStrategy) {
- PG_RETURN_BOOL(signconsistent((QUERYTYPE *) query,
+ retval = signconsistent((QUERYTYPE *) query,
GETSIGN(DatumGetPointer(entry->key)),
- false));
+ false);
+ PG_FREE_IF_COPY(query, 1);
+ PG_RETURN_BOOL( retval );
}
- /* XXX what about toasted input? */
- if (ARRISVOID(query))
- return FALSE;
+ if (ARRISVOID(query)) {
+ PG_FREE_IF_COPY(query, 1);
+ PG_RETURN_BOOL( FALSE );
+ }
switch (strategy)
{
@@ -520,6 +525,8 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
default:
retval = FALSE;
}
+
+ PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(retval);
}