Possible data corruption with LOAD RECORD

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Possible data corruption with LOAD RECORD

aparajita
Administrator
Folks,

The following code will cause your data file to become corrupted:

READ WRITE([Archive])
CREATE RECORD([Archive])
[Archive]Field1 := "foo"
SAVE RECORD([Archive])
READ ONLY([Archive])
UNLOAD RECORD([Archive])

ALL RECORDS([Archive])
LOAD RECORD([Archive])

The problem is LOAD RECORD. My LOAD RECORD calls the 4D plugin API
version of LOAD RECORD, which mistakenly deletes the copy in the cache
before loading. If the record is newly created in the cache and the
cache has not been flushed, the data file will be corrupted.

I will work around this in v2.1. Until that comes out, you have two
ways to avoid this problem:

1. Call FLUSH BUFFERS after SAVE RECORD
2. Make a 4D method wrapper for LOAD RECORD and call that.

    Aparajita
    Victory-Heart Productions
    [hidden email]
    www.aparajitaworld.com