Opened 9 years ago

Closed 4 years ago

#3372 closed defect (fixed)

TopoElementArray cannot be null

Reported by: strk Owned by: strk
Priority: medium Milestone: PostGIS 3.1.0
Component: topology Version: 2.0.x
Keywords: Cc:

Description

Trying to GetTopoElementArray for an empty TopoGeometry fails due to NULL not passing the TopoElementArray domain constraint:

t=# select null::topoelementarray;
ERROR:  value for domain topoelementarray violates check constraint "dimensions"

I think the check should allow for null…

Change History (11)

comment:1 by strk, 9 years ago

Now this is funny, I can create a NULL TopoElementArray like this:

SELECT topology.TopoElementArray_agg(e)::TopoElementArray IS NULL from (        
  SELECT '{1,1}'::TopoElement WHERE false                                       
) as foo(e);

Now I wonder why the "dimensions" constraint only kicks in with a literal ! This is PostgreSQL 9.3.6.

The domain definition is here: https://trac.osgeo.org/postgis/browser/tags/2.2.0/topology/topology.sql.in#L384

comment:2 by pramsey, 7 years ago

Milestone: PostGIS 2.0.8PostGIS 2.2.6

comment:3 by pramsey, 7 years ago

Milestone: PostGIS 2.2.6PostGIS 2.2.7

comment:4 by robe, 7 years ago

Milestone: PostGIS 2.2.7PostGIS 2.2.8

comment:5 by Algunenano, 5 years ago

Milestone: PostGIS 2.2.8PostGIS 2.3.10

Moving to a non EOL release.

comment:6 by robe, 5 years ago

Milestone: PostGIS 2.3.10PostGIS 2.5.4

comment:7 by pramsey, 5 years ago

Milestone: PostGIS 2.5.4PostGIS 2.5.5

comment:8 by robe, 4 years ago

Milestone: PostGIS 2.5.5PostGIS 3.0.3

comment:9 by robe, 4 years ago

Still doesn't work on PostgreSQL 13.

Is there a reason we can't just change the constraint to:

ALTER DOMAIN topology.topoelementarray DROP CONSTRAINT  dimensions;
ALTER DOMAIN topology.topoelementarray
    ADD CONSTRAINT dimensions CHECK ( array_upper(VALUE, 2) = 2 AND array_upper(VALUE, 3) IS NULL);
	

Then the NULL thing wouldn't violate because NULL is special. Then the below works.

SELECT null::topoelementarray;

comment:10 by robe, 4 years ago

Milestone: PostGIS 3.0.3PostGIS 3.1.0

strk said on IRC okay to make the change, but I feel it's not kosher to do in a micro release so pushing to 3.1.0.

comment:11 by Regina Obe <lr@…>, 4 years ago

Resolution: fixed
Status: newclosed

In 5829c16/git:

Change TopologyElementArray constraint to not exclude null and minor cleanup on news. Closes #3372 for PostGIS 3.1

Note: See TracTickets for help on using tickets.