-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Matt wrote:
> Given a sqlite database file I would like to create two lists: one of bytes 
> which are in use and one of bytes which are "free".
> What would be the most efficient way to do this?

What are you actually trying to achieve?  If you are trying to work out how
much slack space there is in the file then just turn on auto-vacuum which
will remove slack space as appropriate.

This inefficient method will give you an answer:

 - Make a backup using the backup API
 - Run vacuum on the backup
 - Compare that file size to current file size

You should also note that SQLite works on pages not bytes.

If you are trying to do steganography then you really do have to understand
the file format.

> I have taken a look over the file format documentation but can't see a clear 
> way to achieve this.

The information is there.  Look at the list of page types.  Section 2.4
describes the free page list including a single field in the header saying
how many free page list members there are.  If you are also trying to find
partially used pages then you'll have to iterate over each page of each type
(section 2.2.2).

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAksEX30ACgkQmOOfHg372QQs/gCfWF7CG+UBXvxKagln+2xeB6d5
CbAAnjyIH1YROJNFqH2Qq7fGdOYv+rkE
=25Ux
-----END PGP SIGNATURE-----
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to