From 33679ff52a4937d9e0f1bbaafb08aa3e675b2a72 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Fri, 9 Dec 2016 17:09:10 +0000 Subject: [PATCH] #3645, do not load logically deleted records from shape files git-svn-id: http://svn.osgeo.org/postgis/trunk@15271 b70326c6-7e19-0410-871a-916f4a2858ee --- loader/dbfopen.c | 4 ++-- loader/shp2pgsql-core.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/loader/dbfopen.c b/loader/dbfopen.c index f8fc26586..e2054831b 100644 --- a/loader/dbfopen.c +++ b/loader/dbfopen.c @@ -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; /* -------------------------------------------------------------------- */ diff --git a/loader/shp2pgsql-core.c b/loader/shp2pgsql-core.c index 4b96a6f61..b80aace4b 100644 --- a/loader/shp2pgsql-core.c +++ b/loader/shp2pgsql-core.c @@ -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; -- 2.40.0