]> granicus.if.org Git - postgis/commitdiff
#3645, do not load logically deleted records from shape files
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 9 Dec 2016 17:09:10 +0000 (17:09 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 9 Dec 2016 17:09:10 +0000 (17:09 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@15271 b70326c6-7e19-0410-871a-916f4a2858ee

loader/dbfopen.c
loader/shp2pgsql-core.c

index f8fc2658647cc6d0b78d58ebb898391f220591bd..e2054831b7cbe56a8671b492996af78ab27b690e 100644 (file)
@@ -1727,13 +1727,13 @@ int SHPAPI_CALL DBFIsRecordDeleted( DBFHandle psDBF, int iShape )
 /* -------------------------------------------------------------------- */
 /*      Verify selection.                                               */
 /* -------------------------------------------------------------------- */
-    if( iShape < 0 || iShape >= psDBF->nRecords )
+    if( iShape < 0 || (psDBF->nRecords > 0 && iShape >= psDBF->nRecords) )
         return TRUE;
 
 /* -------------------------------------------------------------------- */
 /*     Have we read the record?                                        */
 /* -------------------------------------------------------------------- */
-    if( !DBFLoadRecord( psDBF, iShape ) )
+    if( psDBF->nRecords > 0 && !DBFLoadRecord( psDBF, iShape ) )
         return FALSE;
 
 /* -------------------------------------------------------------------- */
index 4b96a6f6105adcdbb5603a072375ce6e36fe5300..b80aace4b513862dd47e9e4390ef737983f8939e 100644 (file)
@@ -1522,8 +1522,8 @@ ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strreco
        sb = stringbuffer_create();
        stringbuffer_clear(sb);
 
-       /* If we are reading the DBF only and the record has been marked deleted, return deleted record status */
-       if (state->config->readshape == 0 && DBFIsRecordDeleted(state->hDBFHandle, item))
+       /* Skip deleted records */
+       if (state->hDBFHandle && DBFIsRecordDeleted(state->hDBFHandle, item))
        {
                *strrecord = NULL;
                return SHPLOADERRECDELETED;