X-Sharp / XSharpPublic

Public repository for the source code for the XSharp Compiler, Runtime, Project System and Tools.
Apache License 2.0
112 stars 38 forks source link

DbZap() problem with DBFNTX #1509

Closed cpyrgas closed 3 months ago

cpyrgas commented 3 months ago

Following code creates and zaps a dbf with an NTX index and then adds some new records. When skipping through the records, they appear twice, showing that the index is corrupted. Output:

TEST4
TEST5
TEST6
TEST4
TEST5
TEST6

Problem happens with DBFNTX only, DBFCDX works well.

FUNCTION Start() AS VOID
    LOCAL cDbf AS STRING

    RddSetDefault("DBFNTX")
//  RddSetDefault("DBFCDX") // works ok with DBFCDX

    cDbf := "C:\Dbf\TestZap"

    FErase(cDbf + ".DBF")
    FErase(cDbf + ".NTX")
    FErase(cDbf + ".CDX")

    DbCreate(cDbf, {{"LANDLORD","C",10,0}})
    DbUseArea(TRUE,, cDbf)
    DbCreateIndex( cDbf,"LANDLORD" )
    DbAppend()
    FieldPut(1,"TEST1")
    DbAppend()
    FieldPut(1,"TEST2")
    DbAppend()
    FieldPut(1,"TEST3")

// same if dbf is reopened
/*DbCloseArea()

DbUseArea(TRUE,, cDbf)
DbSetIndex( cDbf,"LANDLORD" )*/

    DbZap()

    DbAppend()
    FieldPut(1,"TEST4")
    DbAppend()
    FieldPut(1,"TEST5")
    DbAppend()
    FieldPut(1,"TEST6")
    DbCommit()

// same if dbf is reopened
/*DbCloseArea()

DbUseArea(TRUE,, cDbf)
DbSetIndex( cDbf,"LANDLORD" )*/

    DbGoTop()
    ? RecCount() // 3, correct
    DbGoTop()
    DO WHILE !Eof()
        ? FieldGet(1)
        DbSkip()
    ENDDO
    ?
    DbCloseArea()
cpyrgas commented 3 months ago

Confirmed fixed, also by customer (Leigh)