Semjon Mössinger
Semjon Mössinger

Reputation: 1890

Is it safe to append some data at end of the binary firebird database file?

My main intent is to add some version information to a Firebird database file, since I will use Firebird as embedded database and installers/update mechanism will need this information.

The information should be available platform independent and I would prefer a solution not needing any database access.

I figured out it is possible to simply append manually some ascii data at the end of the db file (see picture below). This would be my preferred solution. It seems to work (I can still read and write to the database and even manipulate the database structure). But maybe this is only luck? So my question is:

* Of course it is reasonable to store the version information inside the database in a special table, I think. But a kind of release-script could read this information, append it to the binary db file and any installer/updater does not need to search inside the database.

Binary edited database

Upvotes: 0

Views: 144

Answers (1)

Mark Rotteveel
Mark Rotteveel

Reputation: 109090

You should not do this. A Firebird database consists of pages and the engine keeps track of which pages are used and unused, the type of pages, etc. Arbitrarily appending data to the end of a Firebird database is either a form of corruption which might "break" database, or Firebird might just silently overwrite it when it needs to extend the database when it needs to allocate more space.

And as Val Marinov indicated in his comment, doing a backup and restore of the database would erase this version information (assuming that creating the back up is even possible).

You either need to store your extra data in a normal table in the Firebird database, or you should keep this separate from the Firebird database file itself.

Upvotes: 2

Related Questions