*
**********************************************************************
* $Log$
+ * Revision 1.12 2003/11/20 15:34:02 strk
+ * expected in-transaction memory release for btree operators
+ *
* Revision 1.11 2003/11/19 15:26:57 strk
* Added geometry_le, geometry_ge, geometry_cmp functions,
* modified geometry_lt, geometry_gt, geometry_eq to be consistent.
GEOMETRY *geom1 = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
GEOMETRY *geom2 = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
+ //elog(NOTICE, "geometry_lt called");
+
if (geom1->SRID != geom2->SRID)
{
elog(ERROR,
GEOMETRY *geom1 = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
GEOMETRY *geom2 = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
+ //elog(NOTICE, "geometry_le called");
+
if (geom1->SRID != geom2->SRID)
{
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
elog(ERROR,
"Operation on two GEOMETRIES with different SRIDs\n");
PG_RETURN_NULL();
if ( ! FPeq(geom1->bvol.LLB.x , geom2->bvol.LLB.x) ) {
if (geom1->bvol.LLB.x < geom2->bvol.LLB.x)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(FALSE);
}
if ( ! FPeq(geom1->bvol.LLB.y , geom2->bvol.LLB.y) ) {
if (geom1->bvol.LLB.y < geom2->bvol.LLB.y)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(FALSE);
}
if ( ! FPeq(geom1->bvol.LLB.z , geom2->bvol.LLB.z) ) {
if (geom1->bvol.LLB.z < geom2->bvol.LLB.z)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(FALSE);
}
if ( ! FPeq(geom1->bvol.URT.x , geom2->bvol.URT.x) ) {
if (geom1->bvol.URT.x < geom2->bvol.URT.x)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(FALSE);
}
if ( ! FPeq(geom1->bvol.URT.y , geom2->bvol.URT.y) ) {
if (geom1->bvol.URT.y < geom2->bvol.URT.y)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(FALSE);
}
if ( ! FPeq(geom1->bvol.URT.z , geom2->bvol.URT.z) ) {
if (geom1->bvol.URT.z < geom2->bvol.URT.z)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(FALSE);
}
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
+
PG_RETURN_BOOL(TRUE);
}
GEOMETRY *geom1 = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
GEOMETRY *geom2 = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
+ //elog(NOTICE, "geometry_eq called");
+
if (geom1->SRID != geom2->SRID)
{
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
elog(ERROR,
"Operation on two GEOMETRIES with different SRIDs\n");
PG_RETURN_NULL();
}
if ( ! FPeq(geom1->bvol.LLB.x , geom2->bvol.LLB.x) )
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(FALSE);
+ }
if ( ! FPeq(geom1->bvol.LLB.y , geom2->bvol.LLB.y) )
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(FALSE);
+ }
if ( ! FPeq(geom1->bvol.LLB.z , geom2->bvol.LLB.z) )
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(FALSE);
+ }
if ( ! FPeq(geom1->bvol.URT.x , geom2->bvol.URT.x) )
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(FALSE);
+ }
if ( ! FPeq(geom1->bvol.URT.y , geom2->bvol.URT.y) )
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(FALSE);
+ }
if ( ! FPeq(geom1->bvol.URT.z , geom2->bvol.URT.z) )
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(FALSE);
+ }
+
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
}
GEOMETRY *geom1 = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
GEOMETRY *geom2 = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
+ //elog(NOTICE, "geometry_ge called");
+
if (geom1->SRID != geom2->SRID)
{
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
elog(ERROR,
"Operation on two GEOMETRIES with different SRIDs\n");
PG_RETURN_NULL();
if ( ! FPeq(geom1->bvol.LLB.x , geom2->bvol.LLB.x) ) {
if (geom1->bvol.LLB.x > geom2->bvol.LLB.x)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
PG_RETURN_BOOL(FALSE);
}
if ( ! FPeq(geom1->bvol.LLB.y , geom2->bvol.LLB.y) ) {
if (geom1->bvol.LLB.y > geom2->bvol.LLB.y)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
PG_RETURN_BOOL(FALSE);
}
if ( ! FPeq(geom1->bvol.LLB.z , geom2->bvol.LLB.z) ) {
if (geom1->bvol.LLB.z > geom2->bvol.LLB.z)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
PG_RETURN_BOOL(FALSE);
}
if ( ! FPeq(geom1->bvol.URT.x , geom2->bvol.URT.x) ) {
if (geom1->bvol.URT.x > geom2->bvol.URT.x)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
PG_RETURN_BOOL(FALSE);
}
if ( ! FPeq(geom1->bvol.URT.y , geom2->bvol.URT.y) ) {
if (geom1->bvol.URT.y > geom2->bvol.URT.y)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
PG_RETURN_BOOL(FALSE);
}
if ( ! FPeq(geom1->bvol.URT.z , geom2->bvol.URT.z) ) {
if (geom1->bvol.URT.z > geom2->bvol.URT.z)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
PG_RETURN_BOOL(FALSE);
}
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
+
PG_RETURN_BOOL(TRUE);
}
GEOMETRY *geom1 = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
GEOMETRY *geom2 = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
+ //elog(NOTICE, "geometry_gt called");
+
if (geom1->SRID != geom2->SRID)
{
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 )
+ pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 )
+ pfree(geom2);
elog(ERROR,
"Operation on two GEOMETRIES with different SRIDs\n");
PG_RETURN_NULL();
if ( ! FPeq(geom1->bvol.LLB.x , geom2->bvol.LLB.x) ) {
if (geom1->bvol.LLB.x > geom2->bvol.LLB.x)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
}
if ( ! FPeq(geom1->bvol.LLB.y , geom2->bvol.LLB.y) ) {
if (geom1->bvol.LLB.y > geom2->bvol.LLB.y)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
}
if ( ! FPeq(geom1->bvol.LLB.z , geom2->bvol.LLB.z) ) {
if (geom1->bvol.LLB.z > geom2->bvol.LLB.z)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
}
if ( ! FPeq(geom1->bvol.URT.x , geom2->bvol.URT.x) ) {
if (geom1->bvol.URT.x > geom2->bvol.URT.x)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
}
if ( ! FPeq(geom1->bvol.URT.y , geom2->bvol.URT.y) ) {
if (geom1->bvol.URT.y > geom2->bvol.URT.y)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
}
if ( ! FPeq(geom1->bvol.URT.z , geom2->bvol.URT.z) ) {
if (geom1->bvol.URT.z > geom2->bvol.URT.z)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_BOOL(TRUE);
+ }
}
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
+
PG_RETURN_BOOL(FALSE);
}
GEOMETRY *geom1 = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
GEOMETRY *geom2 = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
+ //elog(NOTICE, "geometry_cmp called");
+
if (geom1->SRID != geom2->SRID)
{
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 )
+ pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 )
+ pfree(geom2);
elog(ERROR,
"Operation on two GEOMETRIES with different SRIDs\n");
PG_RETURN_NULL();
if ( ! FPeq(geom1->bvol.LLB.x , geom2->bvol.LLB.x) ) {
if (geom1->bvol.LLB.x < geom2->bvol.LLB.x)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_INT32(-1);
+ }
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_INT32(1);
}
if ( ! FPeq(geom1->bvol.LLB.y , geom2->bvol.LLB.y) ) {
if (geom1->bvol.LLB.y < geom2->bvol.LLB.y)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_INT32(-1);
+ }
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_INT32(1);
}
if ( ! FPeq(geom1->bvol.LLB.z , geom2->bvol.LLB.z) ) {
if (geom1->bvol.LLB.z < geom2->bvol.LLB.z)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_INT32(-1);
+ }
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_INT32(1);
}
if ( ! FPeq(geom1->bvol.URT.x , geom2->bvol.URT.x) ) {
if (geom1->bvol.URT.x < geom2->bvol.URT.x)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_INT32(-1);
+ }
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_INT32(1);
}
if ( ! FPeq(geom1->bvol.URT.y , geom2->bvol.URT.y) ) {
if (geom1->bvol.URT.y < geom2->bvol.URT.y)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_INT32(-1);
+ }
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_INT32(1);
}
if ( ! FPeq(geom1->bvol.URT.z , geom2->bvol.URT.z) ) {
if (geom1->bvol.URT.z < geom2->bvol.URT.z)
+ {
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_INT32(-1);
+ }
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
PG_RETURN_INT32(1);
}
+ if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1);
+ if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2);
+
PG_RETURN_INT32(0);
}
-
-
-
-
//order of points in a ring IS important
//order of rings is also important
bool is_same_polygon(POLYGON3D *poly1, POLYGON3D *poly2)