PostGIS 3.0.0alpha4
-comming next
+2019/xx/xx
+For full changes and enhancements, refer to PostGIS 3.0.0.
+This version requires PostgreSQL 9.5+-12 and GEOS >= 3.6+
+Additional features enabled if you are running Proj6+ and PostgreSQL 12
+
+* Major highlights *
+ - #4433 32-bit hash fix (requires reindexing your data if on 32-bit OS) (Raúl Marín)
PostGIS 3.0.0alpha3
* in the GSERIALIZED. Ignores metadata like flags and optional
* boxes, etc.
*/
-uint64_t gserialized_hash(const GSERIALIZED *g)
+int32_t
+gserialized_hash(const GSERIALIZED *g)
{
if (GFLAGS_GET_VERSION(g->gflags))
return gserialized2_hash(g);
* in the GSERIALIZED. Ignores metadata like flags and optional
* boxes, etc.
*/
-extern uint64_t gserialized_hash(const GSERIALIZED *g);
+extern int32_t gserialized_hash(const GSERIALIZED *g);
/**
* Extract the SRID from the serialized form (it is packed into
/* pb = IN: secondary initval, OUT: secondary hash */
void hashlittle2(const void *key, size_t length, uint32_t *pc, uint32_t *pb);
-
-uint64_t gserialized1_hash(const GSERIALIZED *g1)
+int32_t
+gserialized1_hash(const GSERIALIZED *g1)
{
- uint64_t hval;
- uint32_t pb = 0, pc = 0;
+ int32_t hval;
+ int32_t pb = 0, pc = 0;
/* Point to just the type/coordinate part of buffer */
size_t hsz1 = gserialized1_header_size(g1);
uint8_t *b1 = (uint8_t*)g1 + hsz1;
/* Copy type/coordinates into rest of combined buffer */
memcpy(b2+sizeof(int), b1, bsz1);
/* Hash combined buffer */
- hashlittle2(b2, bsz1, &pb, &pc);
+ hashlittle2(b2, bsz2, (uint32_t *)&pb, (uint32_t *)&pc);
lwfree(b2);
- hval = pc + (((uint64_t)pb)<<32);
+ hval = pb ^ pc;
return hval;
}
* in the GSERIALIZED. Ignores metadata like flags and optional
* boxes, etc.
*/
-uint64_t gserialized1_hash(const GSERIALIZED *g);
+int32_t gserialized1_hash(const GSERIALIZED *g);
/**
* Extract the SRID from the serialized form (it is packed into
/* pb = IN: secondary initval, OUT: secondary hash */
void hashlittle2(const void *key, size_t length, uint32_t *pc, uint32_t *pb);
-
-uint64_t gserialized2_hash(const GSERIALIZED *g)
+int32_t
+gserialized2_hash(const GSERIALIZED *g1)
{
- uint64_t hval;
- uint32_t pb = 0, pc = 0;
+ int32_t hval;
+ int32_t pb = 0, pc = 0;
/* Point to just the type/coordinate part of buffer */
- size_t hsz1 = gserialized2_header_size(g);
- uint8_t *b1 = (uint8_t*)g + hsz1;
+ size_t hsz1 = gserialized2_header_size(g1);
+ uint8_t *b1 = (uint8_t *)g1 + hsz1;
/* Calculate size of type/coordinate buffer */
- size_t sz1 = SIZE_GET(g->size);
+ size_t sz1 = SIZE_GET(g1->size);
size_t bsz1 = sz1 - hsz1;
/* Calculate size of srid/type/coordinate buffer */
- int32_t srid = gserialized2_get_srid(g);
+ int32_t srid = gserialized2_get_srid(g1);
size_t bsz2 = bsz1 + sizeof(int);
uint8_t *b2 = lwalloc(bsz2);
/* Copy srid into front of combined buffer */
/* Copy type/coordinates into rest of combined buffer */
memcpy(b2+sizeof(int), b1, bsz1);
/* Hash combined buffer */
- hashlittle2(b2, bsz1, &pb, &pc);
+ hashlittle2(b2, bsz2, (uint32_t *)&pb, (uint32_t *)&pc);
lwfree(b2);
- hval = pc + (((uint64_t)pb)<<32);
+ hval = pb ^ pc;
return hval;
}
* in the GSERIALIZED. Ignores metadata like flags and optional
* boxes, etc.
*/
-uint64_t gserialized2_hash(const GSERIALIZED *g);
+int32_t gserialized2_hash(const GSERIALIZED *g);
/**
* Extract the SRID from the serialized form (it is packed into
* in the GSERIALIZED. Ignores metadata like flags and optional
* boxes, etc.
*/
-extern uint64_t gserialized_hash(const GSERIALIZED *g);
+extern int32_t gserialized_hash(const GSERIALIZED *g);
/**
* Extract the SRID from the serialized form (it is packed into
Datum lwgeom_hash(PG_FUNCTION_ARGS)
{
GSERIALIZED *g1 = PG_GETARG_GSERIALIZED_P(0);
- uint64_t hval = gserialized_hash(g1);
+ int32_t hval = gserialized_hash(g1);
PG_FREE_IF_COPY(g1, 0);
- PG_RETURN_DATUM(Int64GetDatum(hval));
+ PG_RETURN_INT32(hval);
}