diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c new file mode 100644 index 0a68be6..154e45b *** a/src/backend/utils/adt/geo_ops.c --- b/src/backend/utils/adt/geo_ops.c *************** Datum *** 4380,4394 **** poly_center(PG_FUNCTION_ARGS) { POLYGON *poly = PG_GETARG_POLYGON_P(0); - Datum result; - CIRCLE *circle; ! circle = DatumGetCircleP(DirectFunctionCall1(poly_circle, ! PolygonPGetDatum(poly))); ! result = DirectFunctionCall1(circle_center, ! CirclePGetDatum(circle)); - PG_RETURN_DATUM(result); } --- 4380,4413 ---- poly_center(PG_FUNCTION_ARGS) { POLYGON *poly = PG_GETARG_POLYGON_P(0); ! if (poly->npts == 1) ! { ! /* ! * For some reason we don't support the conversion of single-point ! * polygons to zero-radius circles, so we just return a point. ! */ ! Point *result; ! ! result = (Point *) palloc(sizeof(Point)); ! result->x = poly->p[0].x; ! result->y = poly->p[0].y; ! ! PG_RETURN_POINT_P(result); ! } ! else ! { ! CIRCLE *circle; ! Datum result; ! ! circle = DatumGetCircleP(DirectFunctionCall1(poly_circle, ! PolygonPGetDatum(poly))); ! result = DirectFunctionCall1(circle_center, ! CirclePGetDatum(circle)); ! ! PG_RETURN_DATUM(result); ! } }