Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#4209 closed defect (fixed)

Issues using pgsql2shp with a postgis table with null geometries

Reported by: gabrimonfa Owned by: pramsey
Priority: medium Milestone: PostGIS 2.4.8
Component: postgis Version: master
Keywords: Cc:

Description

The table has 7120 rows, 50 have null geometries and some of them are at the beginning of the table. Server is PostgreSQL 9.5 with postgis version "2.2 USE_GEOS=1 USE_PROJ=1 USE_STATS=1".

Desired behaviour

The shape is created with all the rows, null geometries in the table are null geometries in the shapefile.
Or it would be possible to add a null handling policy as in shp2pgsql.

Actual behaviour

pgsql2shp 2.4.4 (ubuntu 18.10 package)
The exported shapefile has 7070 rows (as the number of rows with not null geometry in original table), but apparently they are the first 7070 rows, some rows with not null geometry are missing.
All is working correctly if I use a "where geom is not null" clause.

pgsql2shp 2.5.0 (package from apt.postgresql.org in ubuntu 18.04)
Segmentation fault
All is working correctly if I use a "where geom is not null" clause.

pgsql2shp 3.0.0 trunk from svn
Segmentation fault

Program received signal SIGSEGV, Segmentation fault.
geometry_type_from_string (str=0x5555557d21f8 "", type=type@entry=0x7fffffffd9bb "", z=z@entry=0x7fffffffd9bc, m=m@entry=0x7fffffffd9bc) at g_util.c:203
203                     tmpstr[i - tmpstartpos] = dump_toupper(str[i]);

All is working correctly if I use a "where geom is not null" clause.

Change History (8)

comment:1 by pramsey, 6 years ago

Could you attach a link to data file, or some SQL to synthetically generate a table that demonstrates the behaviour?

comment:2 by gabrimonfa, 6 years ago

Table creation:

CREATE TABLE public.ticket_4209 (
    id integer NOT NULL,
    geom public.geometry(Polygon)
);

COPY public.ticket_4209 (id, geom) FROM stdin;
1       \N
2       \N
3       0103000000010000000500000000000000000000000000000000000000000000000000F03F0000000000000000000000000000F03F000000000000F03F0000000000000000000000000000F03F00000000000000000000000000000000
\.

Command invocation:

pgsql2shp -f /tmp/test.shp -h host -u user -P password -g geom dbhame "SELECT * FROM public.ticket_4209"

comment:3 by Algunenano, 5 years ago

Milestone: PostGIS 2.4.8

comment:4 by pramsey, 5 years ago

In 17639:

Handle NULL geometry values in pgsql2shp
References #4209

comment:5 by pramsey, 5 years ago

In 17641:

Handle NULL geometry values in pgsql2shp
References #4209

comment:6 by pramsey, 5 years ago

In 17642:

Handle NULL geometry values in pgsql2shp
References #4209

comment:7 by pramsey, 5 years ago

Resolution: fixed
Status: newclosed

In 17643:

Handle NULL geometry values in pgsql2shp
Closes #4209

comment:8 by pramsey, 5 years ago

In 17645:

Add test case and update test case for null-handling behaviour
References #4209

Note: See TracTickets for help on using tickets.