Datum LWGEOM_in(PG_FUNCTION_ARGS)
{
char *input = PG_GETARG_CSTRING(0);
+ int32 geom_typmod = -1;
char *str = input;
LWGEOM_PARSER_RESULT lwg_parser_result;
LWGEOM *lwgeom;
GSERIALIZED *ret;
int srid = 0;
+ if ( (PG_NARGS()>2) && (!PG_ARGISNULL(2)) ) {
+ geom_typmod = PG_GETARG_INT32(2);
+ }
+
lwgeom_parser_result_init(&lwg_parser_result);
/* Empty string. */
ret = geometry_serialize(lwgeom);
lwgeom_parser_result_free(&lwg_parser_result);
}
+
+ if ( geom_typmod >= 0 )
+ {
+ postgis_valid_typmod(lwgeom, geom_typmod);
+ POSTGIS_DEBUG(3, "typmod and geometry were consistent");
+ }
+ else
+ {
+ POSTGIS_DEBUG(3, "typmod was -1");
+ }
+
PG_RETURN_POINTER(ret);
select '#877.4', st_estimated_extent('t','g');
drop table t;
+-- #1320
+SELECT '<#1320>';
+CREATE TABLE A ( geom geometry(MultiPolygon, 4326),
+ geog geography(MultiPolygon, 4326) );
+-- Valid inserts
+INSERT INTO a(geog) VALUES('SRID=4326;MULTIPOLYGON (((0 0, 10 0, 10 10, 0 0)))'::geography);
+INSERT INTO a(geom) VALUES('SRID=4326;MULTIPOLYGON (((0 0, 10 0, 10 10, 0 0)))'::geometry);
+SELECT '#1320.geog.1', geometrytype(geog::geometry), st_srid(geog::geometry) FROM a where geog is not null;
+SELECT '#1320.geom.1', geometrytype(geom), st_srid(geom) FROM a where geom is not null;
+-- Type mismatches is not allowed
+INSERT INTO a(geog) VALUES('SRID=4326;POLYGON ((0 0, 10 0, 10 10, 0 0))'::geography);
+INSERT INTO a(geom) VALUES('SRID=4326;POLYGON ((0 0, 10 0, 10 10, 0 0))'::geometry);
+SELECT '#1320.geog.2', geometrytype(geog::geometry), st_srid(geog::geometry) FROM a where geog is not null;
+SELECT '#1320.geom.2', geometrytype(geom), st_srid(geom) FROM a where geom is not null;
+-- Even if it's a trigger changing the type
+CREATE OR REPLACE FUNCTION triga() RETURNS trigger AS
+$$ BEGIN
+ NEW.geom = ST_GeometryN(New.geom,1);
+ NEW.geog = ST_GeometryN(New.geog::geometry,1)::geography;
+ RETURN NEW;
+END; $$ language plpgsql VOLATILE;
+CREATE TRIGGER triga_before
+ BEFORE INSERT ON a FOR EACH ROW
+ EXECUTE PROCEDURE triga();
+INSERT INTO a(geog) VALUES('SRID=4326;MULTIPOLYGON (((0 0, 10 0, 10 10, 0 0)))'::geography);
+INSERT INTO a(geom) VALUES('SRID=4326;MULTIPOLYGON (((0 0, 10 0, 10 10, 0 0)))'::geometry);
+SELECT '#1320.geog.3', geometrytype(geog::geometry), st_srid(geog::geometry) FROM a where geog is not null;
+SELECT '#1320.geom.3', geometrytype(geom), st_srid(geom) FROM a where geom is not null;
+DROP TABLE A;
+DROP FUNCTION triga();
+SELECT '</#1320>';
+
+-- st_AsText POLYGON((0 0,10 0,10 10,0 0))
+
+
-- Clean up
DELETE FROM spatial_ref_sys;
WARNING: No stats for "<current>"."t"."g" (empty or not analyzed)
#877.3|
#877.4|BOX(-10 -50,20 30)
+<#1320>
+#1320.geog.1|MULTIPOLYGON|4326
+#1320.geom.1|MULTIPOLYGON|4326
+ERROR: Geometry type (Polygon) does not match column type (MultiPolygon)
+ERROR: Geometry type (Polygon) does not match column type (MultiPolygon)
+#1320.geog.2|MULTIPOLYGON|4326
+#1320.geom.2|MULTIPOLYGON|4326
+ERROR: Geometry type (Polygon) does not match column type (MultiPolygon)
+ERROR: Geometry type (Polygon) does not match column type (MultiPolygon)
+#1320.geog.3|MULTIPOLYGON|4326
+#1320.geom.3|MULTIPOLYGON|4326
+</#1320>