[postgis-tickets] r15271 - #3645, do not load logically deleted records from shape files

Paul Ramsey pramsey at cleverelephant.ca
Fri Dec 9 09:09:11 PST 2016


Author: pramsey
Date: 2016-12-09 09:09:10 -0800 (Fri, 09 Dec 2016)
New Revision: 15271

Modified:
   trunk/loader/dbfopen.c
   trunk/loader/shp2pgsql-core.c
Log:
#3645, do not load logically deleted records from shape files


Modified: trunk/loader/dbfopen.c
===================================================================
--- trunk/loader/dbfopen.c	2016-12-03 22:32:07 UTC (rev 15270)
+++ trunk/loader/dbfopen.c	2016-12-09 17:09:10 UTC (rev 15271)
@@ -1727,13 +1727,13 @@
 /* -------------------------------------------------------------------- */
 /*      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;
 
 /* -------------------------------------------------------------------- */

Modified: trunk/loader/shp2pgsql-core.c
===================================================================
--- trunk/loader/shp2pgsql-core.c	2016-12-03 22:32:07 UTC (rev 15270)
+++ trunk/loader/shp2pgsql-core.c	2016-12-09 17:09:10 UTC (rev 15271)
@@ -1522,8 +1522,8 @@
 	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;



More information about the postgis-tickets mailing list