Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2272 closed defect (fixed)

shp2pgsql-gui crashes when given filenames with dots

Reported by: robe Owned by: mcayland
Priority: medium Milestone: PostGIS 2.0.4
Component: utils/loader-dumper Version: master
Keywords: history Cc:

Description

I'm not sure if it's the length of the file or because there is an extra ., I suspect its the dot that is the problem.

I downloaded this file: http://osm-extracted-metros.s3.amazonaws.com/taipei.osm2pgsql-shapefiles.zip

And extracted them and then tried to load up the

taipei.osm-line one (using table name osm_line in a schema taipei) and was rudely awoken from my daze it claimed it couldn't find the corresponding .dbf file and then promptly crashed.

After various renamings of all the files, I was able to successfully load by renaming

taipei.osm-line.* to: osm_line.*

I haven't tried with the command line, since I have since forgotten how to use a command line and too lazy to relookup the instructions.

I'm using the 2.1.0 version 64-bit version on my windows 7 64-bit. I'll try to check next if its the same issue with the 32-bit.

Change History (7)

comment:1 by robe, 11 years ago

Priority: highmedium

Same issue with shp2pgsql except shp2pgsql doesn't crash, just gives a can't locate .dbf. However with shp2pgsql I can work around the issue by explicitly referencing the .dbf file and weirdly it has not problems finding the companion .shp file.

If I try to do the same with shp2pgsql-gui (pointing it at the dbf instead of shp)and it STILL complains it can't find the .dbf and crashes.

comment:2 by pramsey, 11 years ago

Both GUI and CLI carefully strip off the trailing .shp extension by walking from the end back to the first '.'

This is fine, except then shpopen tries the same trick on the string *it* receives.

I think the solution is for our code to stop trying to strip the extension and leave it to shpopen to do.

comment:3 by mcayland, 11 years ago

There are actually 2 bugs here, and I'm just about to commit a fix for them in the next few minutes…

comment:4 by mcayland, 11 years ago

Okay - I've fixed the crasher and the GUI in trunk r11292 and 2.0 branch at r11293. Paul - your observation is absolutely correct about the .shp extension, however it's going to require a little bit more thought as the result is reused for the table name. Let me see if I can untangle the CLI in a slightly more sensible way.

comment:5 by mcayland, 11 years ago

I've committed a fix for this as r11294 for trunk and r11295 for 2.0 branch. Please test and feel free to close if it works for you.

comment:6 by robe, 11 years ago

Resolution: fixed
Status: newclosed

okay that seems to work for shp2pgsql-gui on trunk. Haven't retried shp2pgsql.

I was able to make it crash again by selecting filter to .dbf and doing something stupid like load in geography (even though I also checked only dbf). I can't replicate the crash conditions though so I'm going to close this out. I'll opne a separate ticket or reopen this one if I discover other issues.

Would be nice if we had a regress test to stress these unusual file names though.

comment:7 by robe, 11 years ago

Keywords: history added
Note: See TracTickets for help on using tickets.