minetest/minetest — pull request #1845 by ShadowNinja (2014-11-16 21:23:31+00:00)
Title: Split block position into separate fields in SQLite3 database

Old databases are automagically converted when they're loaded.

Other changes:
* Clean up the database API a bit by removing unused ServerMap.
* Use _v2 variant of sqlite3_prepare().
* Add default Database methods.
* Fix deletion statement not being finalized on Android.
* Misc cleanup.

Rationale: Cramming all of the position fields into one field is just messy. But besides that, it's also a lot harder to process, so many tools that operate on databases have to iterate over a large portion of the database, decoding and checking positions, rather than using a simple SQL statement to fetch only the blocks they need.

Real-world improvements:
1. The mapper(s) can load only the blocks that they need. The C++ mapper currently loads whole Z-slices at a time, rather than just blocks in it's generation range, because it can't limit the selection through SQL.
2. Some map editing tools that I've written would be substantially shorter or could be done with only SQL. Eg, a script that removed all block that were more that a certain distance from the origin could be done with `DELETE FROM blocks WHERE ABS(x) > 3 OR ABS(y) > 3 ABS(z) > 3;`.
3. Corrupted blocks can be deleted without having to write a script to convert the block position to a position hash.

This *may* also have a general speed improvement for fetching and saving blocks, I haven't tested this though.