[postgis-devel] [PostGIS] #393: shp2pgsql returns "fseek(-xxx) failed on DBF file." for large (>2GB) DBF files
PostGIS
trac at osgeo.org
Thu Jan 19 14:39:32 PST 2012
#393: shp2pgsql returns "fseek(-xxx) failed on DBF file." for large (>2GB) DBF
files
-----------------------------------------------+----------------------------
Reporter: maximeguillaud | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: loader/dumper | Version: 1.5.X
Keywords: shp2pgsql fseek failed large file |
-----------------------------------------------+----------------------------
Comment(by dfuhry2):
Regarding previous patches, changing "int" to "long" has no effect on
Linux at least, since both are 4 bytes with a 32-bit OS and 8 bytes with a
64-bit OS. One can write a simple C program to printf("sizeof(int): %d,
sizeof(long): %d\n", sizeof(int), sizeof(long)) to verify.
My attached 6-line large_dbf.v1.patch fixes my problems writing > 2GB DBF
files with shp2pgsql on 32-bit Linux.
1. Add -D_FILE_OFFSET_BITS=64 to Makefile's CFLAGS, which makes off_t an
unsigned 8 byte integer (equivalent to unsigned long long type).
2. In shapefil.h, change typedef of SAOffset from unsigned long (which is
4-byte on 32-bit systems) to off_t.
3. In safileio.c, change fseek call to fseeko, and cast offset to off_t
rather than long. fseek always takes a long, and a long can't be made 8
bytes on a 32-bit system.
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/393#comment:10>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-devel
mailing list