@@ -39,7 +39,7 @@ g_int_consistent(PG_FUNCTION_ARGS)
3939 if (strategy == BooleanSearchStrategy )
4040 PG_RETURN_BOOL (execconsistent ((QUERYTYPE * ) query ,
4141 (ArrayType * ) DatumGetPointer (entry -> key ),
42- ISLEAFKEY (( ArrayType * ) DatumGetPointer ( entry -> key ) )));
42+ GIST_LEAF ( entry )));
4343
4444 /* XXX are we sure it's safe to scribble on the query object here? */
4545 /* XXX what about toasted input? */
@@ -131,16 +131,23 @@ g_int_compress(PG_FUNCTION_ARGS)
131131 {
132132 r = (ArrayType * ) PG_DETOAST_DATUM_COPY (entry -> key );
133133 PREPAREARR (r );
134- r -> flags |= LEAFKEY ;
134+
135+ if (ARRNELEMS (r )>= 2 * MAXNUMRANGE )
136+ elog (NOTICE ,"Input array is too big (%d maximum allowed, %d current), use gist__intbig_ops opclass instead" ,
137+ 2 * MAXNUMRANGE - 1 , ARRNELEMS (r ));
138+
135139 retval = palloc (sizeof (GISTENTRY ));
136140 gistentryinit (* retval , PointerGetDatum (r ),
137141 entry -> rel , entry -> page , entry -> offset , VARSIZE (r ), FALSE);
138142
139143 PG_RETURN_POINTER (retval );
140144 }
141145
146+ /* leaf entries never compress one more time, only when entry->leafkey ==true,
147+ so now we work only with internal keys */
148+
142149 r = (ArrayType * ) PG_DETOAST_DATUM (entry -> key );
143- if (ISLEAFKEY ( r ) || ARRISVOID (r ))
150+ if (ARRISVOID (r ))
144151 {
145152 if (r != (ArrayType * ) DatumGetPointer (entry -> key ))
146153 pfree (r );
@@ -205,7 +212,7 @@ g_int_decompress(PG_FUNCTION_ARGS)
205212
206213 lenin = ARRNELEMS (in );
207214
208- if (lenin < 2 * MAXNUMRANGE || ISLEAFKEY ( in ) )
215+ if (lenin < 2 * MAXNUMRANGE )
209216 { /* not compressed value */
210217 if (in != (ArrayType * ) DatumGetPointer (entry -> key ))
211218 {
@@ -498,8 +505,6 @@ g_int_picksplit(PG_FUNCTION_ARGS)
498505 pfree (costvector );
499506 * right = * left = FirstOffsetNumber ;
500507
501- datum_l -> flags &= ~LEAFKEY ;
502- datum_r -> flags &= ~LEAFKEY ;
503508 v -> spl_ldatum = PointerGetDatum (datum_l );
504509 v -> spl_rdatum = PointerGetDatum (datum_r );
505510
0 commit comments