- #4249, Fix undefined behaviour in raster intersection (Raúl Marín)
- #4246, Fix undefined behaviour in ST_3DDistance (Raúl Marín)
- #4244, Avoid unaligned memory access in BOX2D_out (Raúl Marín)
+ - #4139, Make mixed-dimension ND index build tree correctly (Darafei Praliaskouski,
+ Arthur Lesuisse, Andrew Gierth, Raúl Marín)
PostGIS 2.5.0
2018/09/23
SET_VARSIZE(a, VARHDRSZ);
}
-/* Enlarge b_union to contain b_new. If b_new contains more
- dimensions than b_union, expand b_union to contain those dimensions. */
+/* Enlarge b_union to contain b_new. */
void
gidx_merge(GIDX **b_union, GIDX *b_new)
{
Assert(b_new);
/* Can't merge an unknown into any thing */
+ /* Q: Unknown is 0 dimensions. Should we reset result to unknown instead? (ticket #4232) */
if (gidx_is_unknown(b_new))
return;
/* Merge of unknown and known is known */
+ /* Q: Unknown is 0 dimensions. Should we never modify unknown instead? (ticket #4232) */
if (gidx_is_unknown(*b_union))
{
*b_union = b_new;
dims_union = GIDX_NDIMS(*b_union);
dims_new = GIDX_NDIMS(b_new);
- POSTGIS_DEBUGF(4, "merging gidx (%s) into gidx (%s)", gidx_to_string(b_new), gidx_to_string(*b_union));
-
- if (dims_new > dims_union)
+ /* Shrink unshared dimensions.
+ * Unset dimension is essentially [-FLT_MAX, FLT_MAX], so we can either trim it or reset to that range.*/
+ if (dims_new < dims_union)
{
- POSTGIS_DEBUGF(5, "reallocating b_union from %d dims to %d dims", dims_union, dims_new);
*b_union = (GIDX *)repalloc(*b_union, GIDX_SIZE(dims_new));
SET_VARSIZE(*b_union, VARSIZE(b_new));
dims_union = dims_new;
}
- for (i = 0; i < dims_new; i++)
+ for (i = 0; i < dims_union; i++)
{
/* Adjust minimums */
GIDX_SET_MIN(*b_union, i, Min(GIDX_GET_MIN(*b_union, i), GIDX_GET_MIN(b_new, i)));
/* Adjust maximums */
GIDX_SET_MAX(*b_union, i, Max(GIDX_GET_MAX(*b_union, i), GIDX_GET_MAX(b_new, i)));
}
-
- POSTGIS_DEBUGF(5, "merge complete (%s)", gidx_to_string(*b_union));
- return;
}
/* Calculate the volume (in n-d units) of the GIDX */
retval = false;
}
- return (retval);
+ return retval;
}
/*
retval = false;
}
- return (retval);
+ return retval;
}
/*
if (*pos)
gidx_merge(box_union, box_current);
else
- memcpy((void *)(*box_union), (void *)box_current, VARSIZE(box_current));
+ {
+ pfree(*box_union);
+ *box_union = gidx_copy(box_current);
+ }
+
list[*pos] = num;
(*pos)++;
}
** sides of the page union box can occasionally all end up in one place, leading
** to this condition.
*/
- if (gserialized_gist_picksplit_badratios(pos, ndims_pageunion) == true)
+ if (gserialized_gist_picksplit_badratios(pos, ndims_pageunion))
{
/*
** Instead we split on center points and see if we do better.