File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -32,17 +32,19 @@ Datum
32
32
g_int_consistent (PG_FUNCTION_ARGS )
33
33
{
34
34
GISTENTRY * entry = (GISTENTRY * ) PG_GETARG_POINTER (0 );
35
- ArrayType * query = (ArrayType * ) PG_GETARG_POINTER (1 );
35
+ ArrayType * query = (ArrayType * ) PG_DETOAST_DATUM_COPY ( PG_GETARG_POINTER (1 ) );
36
36
StrategyNumber strategy = (StrategyNumber ) PG_GETARG_UINT16 (2 );
37
37
bool retval ;
38
38
39
- if (strategy == BooleanSearchStrategy )
40
- PG_RETURN_BOOL ( execconsistent ((QUERYTYPE * ) query ,
39
+ if (strategy == BooleanSearchStrategy ) {
40
+ retval = execconsistent ((QUERYTYPE * ) query ,
41
41
(ArrayType * ) DatumGetPointer (entry -> key ),
42
- GIST_LEAF (entry )));
42
+ GIST_LEAF (entry ));
43
+
44
+ pfree ( query );
45
+ PG_RETURN_BOOL (retval );
46
+ }
43
47
44
- /* XXX are we sure it's safe to scribble on the query object here? */
45
- /* XXX what about toasted input? */
46
48
/* sort query for fast search, key is already sorted */
47
49
CHECKARRVALID (query );
48
50
if (ARRISVOID (query ))
@@ -82,6 +84,7 @@ g_int_consistent(PG_FUNCTION_ARGS)
82
84
default :
83
85
retval = FALSE;
84
86
}
87
+ pfree ( query );
85
88
PG_RETURN_BOOL (retval );
86
89
}
87
90
Original file line number Diff line number Diff line change @@ -497,7 +497,7 @@ Datum
497
497
g_intbig_consistent (PG_FUNCTION_ARGS )
498
498
{
499
499
GISTENTRY * entry = (GISTENTRY * ) PG_GETARG_POINTER (0 );
500
- ArrayType * query = (ArrayType * ) PG_GETARG_POINTER (1 );
500
+ ArrayType * query = (ArrayType * ) PG_DETOAST_DATUM ( PG_GETARG_POINTER (1 ) );
501
501
StrategyNumber strategy = (StrategyNumber ) PG_GETARG_UINT16 (2 );
502
502
bool retval ;
503
503
@@ -506,12 +506,13 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
506
506
507
507
if (strategy == BooleanSearchStrategy )
508
508
{
509
- PG_RETURN_BOOL ( signconsistent ((QUERYTYPE * ) query ,
509
+ retval = signconsistent ((QUERYTYPE * ) query ,
510
510
GETSIGN (DatumGetPointer (entry -> key )),
511
- false));
511
+ false);
512
+ PG_FREE_IF_COPY ( query , 1 );
513
+ return retval ;
512
514
}
513
515
514
- /* XXX what about toasted input? */
515
516
CHECKARRVALID (query );
516
517
if (ARRISVOID (query ))
517
518
return FALSE;
@@ -597,5 +598,6 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
597
598
default :
598
599
retval = FALSE;
599
600
}
601
+ PG_FREE_IF_COPY ( query , 1 );
600
602
PG_RETURN_BOOL (retval );
601
603
}
You can’t perform that action at this time.
0 commit comments