[postgis-users] Small question about GEOMETRY typmod registration in geometry_columns

Jorge Gustavo Rocha jgr at di.uminho.pt
Sun May 3 15:05:30 PDT 2020


Hi Postgisers,

If I create a new table with a generic GEOMETRY column, it is properly
registered in geometry_columns view as type GEOMETRY.

Example:

CREATE TABLE place (
	id uuid NOT NULL DEFAULT uuid_generate_v1mc() PRIMARY KEY,
	name varchar(255) not NULL,
	geom geometry(GEOMETRY,3763) NOT NULL
);

select f_table_name, type from geometry_columns gc where f_table_name =
'place';

Perfect, as expected!

f_table_name|type    |
------------|--------|
place       |GEOMETRY|

Problem

I want to restrict this generic GEOMETRY column just to LINESTRING and
POLYGON geometries.

To do so, I use the same typmod geometry(GEOMETRY,3763) and an
additional CONSTRAINT, like:

CREATE TABLE place (
	id uuid NOT NULL DEFAULT uuid_generate_v1mc() PRIMARY KEY,
	name varchar(255) not NULL,
	geom geometry(GEOMETRY,3763) NOT null,
	CONSTRAINT line_or_polygon CHECK (geometrytype(geom) = 'LINESTRING' OR
geometrytype(geom) = 'POLYGON')
);

If I do so, the column is registered as LINESTRING and not GEOMETRY.

select f_table_name, type from geometry_columns gc where f_table_name =
'place';

f_table_name|type      |
------------|----------|
place       |LINESTRING|

For me, it would make sense to have it registered as GEOMETRY, not
LINESTRING (or POLYGON). Shouldn't it be based just on the typmod?

Best regards,

J. Gustavo
-- 
Jorge Gustavo Rocha
Departamento de Informática
Universidade do Minho
4710-057 Braga
Gabinete 3.29 (Piso 3)
Tel: +351 253604480
Fax: +351 253604471
Móvel: +351 910333888
skype: nabocudnosor


More information about the postgis-users mailing list