Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading the database header #210

Closed
IRETD opened this issue Jul 2, 2019 · 6 comments
Closed

Reading the database header #210

IRETD opened this issue Jul 2, 2019 · 6 comments
Assignees

Comments

@IRETD
Copy link

IRETD commented Jul 2, 2019

Why are there no functions for working with the database header?
For instance, it could be useful to get the total number of free list pages (offset 36) to calculate the actual database size before deciding whether to vacuum.

@SRombauts SRombauts self-assigned this Jul 3, 2019
@ptrks
Copy link
Contributor

ptrks commented Dec 28, 2019

@SRombauts I was thinking of tackling this (as I have done it before in personal projects) - but wanted your thoughts on specific implementation within SQLiteCPP. What do you think of creating a structure to contain the header fields and then having a getHeaderInfo() function within the Database class that returns that struct?

@SRombauts
Copy link
Owner

SRombauts commented Dec 28, 2019

Hello, I don't have a knowledge of the database header. How do you access it?
What you propose seems reasonable

Edit: I see that you need to read directly the raw file, using something along the line of this: https://stackoverflow.com/questions/18678931/reading-sqlite-header

@ptrks
Copy link
Contributor

ptrks commented Dec 28, 2019

Exactly! It's very similar to how you check if the database file is encrypted or not - except we would be parsing the entire header range for all of the different fields.

Here is a version I did in C: https://github.com/patrick--/sqlite_header_parse

I'll put an implementation / some tests together and submit a PR for your review and we can discuss further.

Thanks!

@ptrks
Copy link
Contributor

ptrks commented Dec 31, 2019

@SRombauts would you like me to add getHeaderInfo() usage in the main.cpp example file?

@SRombauts
Copy link
Owner

Hello, yes why not, to end the year well :)

@SRombauts
Copy link
Owner

Closing this since it has been implemented by @patrick-- in #249 Added SQLite header parsing functionality and associated tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants