]> granicus.if.org Git - postgis/commitdiff
Fix ND-GiST picksplit method to split on the best plane (#3058)
authorSandro Santilli <strk@keybit.net>
Mon, 2 Mar 2015 17:33:40 +0000 (17:33 +0000)
committerSandro Santilli <strk@keybit.net>
Mon, 2 Mar 2015 17:33:40 +0000 (17:33 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13294 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/gserialized_gist_nd.c

index 066b780fed88501258bb09355c4f218e4c88ab96..bce01132446dc5a3c497161e947bd4c428337748 100644 (file)
@@ -1293,7 +1293,7 @@ Datum gserialized_gist_picksplit(PG_FUNCTION_ARGS)
        bool all_entries_equal = true;
        OffsetNumber max_offset;
        int nbytes, ndims_pageunion, d;
-       int posmax = -1;
+       int posmin = entryvec->n;
 
        POSTGIS_DEBUG(4, "[GIST] 'picksplit' function called");
 
@@ -1447,13 +1447,13 @@ Datum gserialized_gist_picksplit(PG_FUNCTION_ARGS)
        for ( d = 0; d < ndims_pageunion; d++ )
        {
                int posd = Max(pos[ABOVE(d)],pos[BELOW(d)]);
-               if ( posd > posmax )
+               if ( posd < posmin )
                {
                        direction = d;
-                       posmax = posd;
+                       posmin = posd;
                }
        }
-       if ( direction == -1 || posmax == -1 )
+       if ( direction == -1 || posmin == entryvec->n )
        {
                /* ERROR OUT HERE */
                elog(ERROR, "Error in building split, unable to determine split direction.");