Hello all,
I'm currently designing a new file format using sqlite for some
specialized hardware; previously it wasn't possible, but the new WAL
mode fulfills my needs.
Except for some small summary info, the data is appended only.

I have some other simple requirement to preallocate a file size:
I allocate some space (e.g. 1GB or more) in a db file on start
recording data, and want to truncate to real size on stop recording.
The initial size does NOT need to be precise in any way...

It is not for any optimization or something, but as a simple way to
guarantee that nobody/nothing messes with disk space while a recording
takes place.
I already searched about this, and people suggested other means of
solving the problem (partitioning, etc); while it might be possible,
this solution is very simple, works very well for my case and I was
already using it for the previous file format. Additionally, it is
already used internally in sqlite.

A few months ago (I don't remember which version) I tried using
SQLITE_FCNTL_SIZE_HINT, and today I tried again (with 3.7.10).
I found that the behavior changed, therefore I have to ask here.

The file allocation worked and works. But in the older attempt the
file was quickly truncated to the real needed size as soon as some
data has been written.
In the new attempt, the file size remains as allocated no matter how
much I write to it, and even if I close it. I can't seem to find a way
to force it down, except using "vacuum" (which is not an option).
Can anyone explain why? From the source code it seems that the "older"
behavior was intended, but I can't quickly see why it is different
now.
I actually want a combination: leave it allocated (but extend if
needed) until I close it (or specify something else)...
Is my requirement that unusual??

I might work around using SQLITE_FCNTL_CHUNK_SIZE (which I'm already
using to avoid fragmentation) and pass the allocation value.
On stop/close I reset it and it properly truncates.
However I feel that the SQLITE_FCNTL_SIZE_HINT is the proper way, so
please comment on this.


Thanks and regards,
Gabriel
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to