Opened 13 years ago

Closed 10 years ago

#1521 closed defect (fixed)

Delete feature - .dbf file getting deleted

Reported by: vdharan2001@… Owned by: Mateusz Łoskot
Priority: highest Milestone:
Component: OGR_SF Version: 1.7.1
Severity: critical Keywords:
Cc:

Description (last modified by Mateusz Łoskot)

I want to delete features from a shape file. When i try repack after deleting the features, the .dbf file it self is getting deleted.

When i trace down the repack function, i could find that in ogrshapelayer.cpp VSIRename(.....) returns OGRERR_FAILURE.

/* -------------------------------------------------------------------- */
/*      Cleanup the old .dbf and rename the new one.                    */
/* -------------------------------------------------------------------- */

    DBFClose( hDBF );
    hDBF = hNewDBF;

    VSIUnlink( CPLResetExtension( pszFullName, "dbf" ) );
    if( VSIRename( oTempFile, CPLResetExtension( pszFullName, "dbf" ) ) != 0 )
        return OGRERR_FAILURE;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Iam calling the delete feature and repack as follows

.....
poLayer->DeleteFeature(iField)
poDS->ExecuteSQL("REPACK myshapefile", NULL, NULL);

Change History (6)

comment:1 Changed 13 years ago by Mateusz Łoskot

The problem occurs because during REPACK operation, copy of a shapefile is not closed properly, what causes sharing violation error.
What's interesting, the problem seems to leak on Windows only.

I'm fixing it.

comment:2 Changed 13 years ago by Mateusz Łoskot

The bug is fixed, so I resolve it changing the state to FIXED.

Here is detailed changeset:
http://trac.osgeo.org/gdal/changeset/10969

Vidhiyadharan,
Please, verify and confirm if deleting features from a shapefile
does work for you too.

comment:3 Changed 13 years ago by vdharan2001@…

(In reply to comment #2)
Yes I have tested. Now iam able to delete features. 

Thank you very much.

comment:4 Changed 13 years ago by Mateusz Łoskot

The bug has been verified so I can close it.

comment:5 Changed 10 years ago by Mateusz Łoskot

Description: modified (diff)
Resolution: fixed
Status: closedreopened
Version: 1.4.01.7.1

This recent report is directly related to this ticket and submitted fix. I've have made mistake by using Windows path separator instead of using native one.

comment:6 Changed 10 years ago by Mateusz Łoskot

Description: modified (diff)
Resolution: fixed
Status: reopenedclosed

Fixed in trunk (r18897)

Note: See TracTickets for help on using tickets.