Implemented VoxelStreamSQLite
This commit is contained in:
parent
137059f514
commit
01e5e18922
18
SCsub
18
SCsub
@ -10,18 +10,23 @@ env_voxel = env_modules.Clone()
|
||||
|
||||
voxel_files = [
|
||||
"*.cpp",
|
||||
|
||||
"meshers/blocky/*.cpp",
|
||||
"meshers/transvoxel/*.cpp",
|
||||
"meshers/dmc/*.cpp",
|
||||
"meshers/cubes/*.cpp",
|
||||
"meshers/*.cpp",
|
||||
|
||||
"streams/*.cpp",
|
||||
"streams/sqlite/*.cpp",
|
||||
|
||||
"storage/*.cpp",
|
||||
|
||||
"generators/*.cpp",
|
||||
"generators/graph/*.cpp",
|
||||
"generators/simple/*.cpp",
|
||||
"util/*.cpp",
|
||||
|
||||
"util/*.cpp",
|
||||
#"util/noise/*.cpp",
|
||||
"util/noise/fast_noise_lite.cpp",
|
||||
"util/noise/fast_noise_lite_gradient.cpp",
|
||||
@ -30,7 +35,9 @@ voxel_files = [
|
||||
"server/*.cpp",
|
||||
"math/*.cpp",
|
||||
"edition/*.cpp",
|
||||
"thirdparty/lz4/*.c"
|
||||
|
||||
"thirdparty/lz4/*.c",
|
||||
"thirdparty/sqlite/*.c"
|
||||
]
|
||||
|
||||
if env["tools"]:
|
||||
@ -43,6 +50,13 @@ if env["tools"]:
|
||||
]
|
||||
voxel_files += voxel_editor_files
|
||||
|
||||
if env["platform"] == "windows":
|
||||
# When compiling SQLite with Godot on Windows with MSVC, it produces the following warning:
|
||||
# `sqlite3.c(42754): warning C4996: 'GetVersionExA': was declared deprecated `
|
||||
# To fix it, let's indicate to SQLite it should not use this function, even if it is available.
|
||||
# https://stackoverflow.com/questions/20031597/error-c4996-received-when-compiling-sqlite-c-in-visual-studio-2013
|
||||
env_voxel.Append(CPPDEFINES={"SQLITE_WIN32_GETVERSIONEX": 0})
|
||||
|
||||
for f in voxel_files:
|
||||
env_voxel.add_source_files(env.modules_sources, f)
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "meshers/transvoxel/voxel_mesher_transvoxel.h"
|
||||
#include "storage/voxel_buffer.h"
|
||||
#include "storage/voxel_memory_pool.h"
|
||||
#include "streams/sqlite/voxel_stream_sqlite.h"
|
||||
#include "streams/vox_loader.h"
|
||||
#include "streams/voxel_stream_block_files.h"
|
||||
#include "streams/voxel_stream_file.h"
|
||||
@ -74,6 +75,7 @@ void register_voxel_types() {
|
||||
ClassDB::register_class<VoxelStreamBlockFiles>();
|
||||
ClassDB::register_class<VoxelStreamRegionFiles>();
|
||||
ClassDB::register_class<VoxelStreamScript>();
|
||||
ClassDB::register_class<VoxelStreamSQLite>();
|
||||
|
||||
// Generators
|
||||
ClassDB::register_virtual_class<VoxelGenerator>();
|
||||
|
@ -625,6 +625,7 @@ void VoxelServer::BlockDataRequest::run(VoxelTaskContext ctx) {
|
||||
case TYPE_LOAD: {
|
||||
voxels.instance();
|
||||
voxels->create(block_size, block_size, block_size);
|
||||
// TODO No longer using batches? If that works ok, we should get rid of batch queries in files
|
||||
const VoxelStream::Result result = stream->emerge_block(voxels, origin_in_voxels, lod);
|
||||
if (result == VoxelStream::RESULT_BLOCK_NOT_FOUND) {
|
||||
Ref<VoxelGenerator> generator = stream_dependency->generator;
|
||||
|
669
streams/sqlite/voxel_stream_sqlite.cpp
Normal file
669
streams/sqlite/voxel_stream_sqlite.cpp
Normal file
@ -0,0 +1,669 @@
|
||||
#include "voxel_stream_sqlite.h"
|
||||
#include "../../thirdparty/sqlite/sqlite3.h"
|
||||
//#include "../util/profiling.h"
|
||||
|
||||
// TODO Is the struct really useful?
|
||||
struct BlockLocation {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t z;
|
||||
uint8_t lod;
|
||||
|
||||
static uint64_t encode(BlockLocation loc) {
|
||||
// 0l xx yy zz
|
||||
return ((static_cast<uint64_t>(loc.lod) & 0xffff) << 48) |
|
||||
((static_cast<uint64_t>(loc.x) & 0xffff) << 32) |
|
||||
((static_cast<uint64_t>(loc.y) & 0xffff) << 16) |
|
||||
(static_cast<uint64_t>(loc.z) & 0xffff);
|
||||
}
|
||||
|
||||
static BlockLocation decode(uint64_t id) {
|
||||
BlockLocation b;
|
||||
b.z = (id & 0xffff);
|
||||
b.y = ((id >> 16) & 0xffff);
|
||||
b.x = ((id >> 32) & 0xffff);
|
||||
b.lod = ((id >> 48) & 0xff);
|
||||
return b;
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// One connection to the database, with our prepared statements
|
||||
class VoxelStreamSQLiteInternal {
|
||||
public:
|
||||
static const int VERSION = 0;
|
||||
|
||||
struct Meta {
|
||||
int version = -1;
|
||||
int block_size_po2 = 0;
|
||||
|
||||
struct Channel {
|
||||
VoxelBuffer::Depth depth;
|
||||
bool used = false;
|
||||
};
|
||||
|
||||
FixedArray<Channel, VoxelBuffer::MAX_CHANNELS> channels;
|
||||
};
|
||||
|
||||
VoxelStreamSQLiteInternal();
|
||||
~VoxelStreamSQLiteInternal();
|
||||
|
||||
bool open(const char *fpath);
|
||||
void close();
|
||||
|
||||
bool is_open() const { return _db != nullptr; }
|
||||
const char *get_file_path() const;
|
||||
|
||||
bool begin_transaction();
|
||||
bool end_transaction();
|
||||
|
||||
bool save_block(BlockLocation loc, const std::vector<uint8_t> &block_data);
|
||||
VoxelStream::Result load_block(BlockLocation loc, std::vector<uint8_t> &out_block_data);
|
||||
|
||||
Meta load_meta();
|
||||
void save_meta(Meta meta);
|
||||
|
||||
private:
|
||||
struct TransactionScope {
|
||||
VoxelStreamSQLiteInternal &db;
|
||||
TransactionScope(VoxelStreamSQLiteInternal &p_db) :
|
||||
db(p_db) {
|
||||
db.begin_transaction();
|
||||
}
|
||||
~TransactionScope() {
|
||||
db.end_transaction();
|
||||
}
|
||||
};
|
||||
|
||||
static bool prepare(sqlite3 *db, sqlite3_stmt **s, const char *sql) {
|
||||
const int rc = sqlite3_prepare_v2(db, sql, -1, s, nullptr);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(String("Preparing statement failed: {0}").format(varray(sqlite3_errmsg(db))));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void finalize(sqlite3_stmt *&s) {
|
||||
if (s != nullptr) {
|
||||
sqlite3_finalize(s);
|
||||
s = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
sqlite3 *_db = nullptr;
|
||||
sqlite3_stmt *_begin_statement = nullptr;
|
||||
sqlite3_stmt *_end_statement = nullptr;
|
||||
sqlite3_stmt *_update_block_statement = nullptr;
|
||||
sqlite3_stmt *_get_block_statement = nullptr;
|
||||
sqlite3_stmt *_load_meta_statement = nullptr;
|
||||
sqlite3_stmt *_save_meta_statement = nullptr;
|
||||
sqlite3_stmt *_load_channels_statement = nullptr;
|
||||
sqlite3_stmt *_save_channel_statement = nullptr;
|
||||
};
|
||||
|
||||
VoxelStreamSQLiteInternal::VoxelStreamSQLiteInternal() {
|
||||
}
|
||||
|
||||
VoxelStreamSQLiteInternal::~VoxelStreamSQLiteInternal() {
|
||||
close();
|
||||
}
|
||||
|
||||
bool VoxelStreamSQLiteInternal::open(const char *fpath) {
|
||||
close();
|
||||
|
||||
int rc = sqlite3_open_v2(fpath, &_db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, nullptr);
|
||||
if (rc != 0) {
|
||||
ERR_PRINT(String("Could not open database: {0}").format(varray(sqlite3_errmsg(_db))));
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
|
||||
sqlite3 *db = _db;
|
||||
char *error_message = nullptr;
|
||||
|
||||
// Create tables if they dont exist
|
||||
const char *tables[3] = {
|
||||
"CREATE TABLE IF NOT EXISTS meta (version INTEGER, block_size_po2 INTEGER)",
|
||||
"CREATE TABLE IF NOT EXISTS blocks (loc INTEGER PRIMARY KEY, vb BLOB, instances BLOB)",
|
||||
"CREATE TABLE IF NOT EXISTS channels (idx INTEGER PRIMARY KEY, depth INTEGER)"
|
||||
};
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
rc = sqlite3_exec(db, tables[i], nullptr, nullptr, &error_message);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(String("Failed to create table: {0}").format(varray(error_message)));
|
||||
sqlite3_free(error_message);
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare statements
|
||||
if (!prepare(db, &_update_block_statement,
|
||||
"INSERT INTO blocks VALUES (:loc, :vb, null) ON CONFLICT(loc) DO UPDATE SET vb=excluded.vb")) {
|
||||
return false;
|
||||
}
|
||||
if (!prepare(db, &_get_block_statement, "SELECT vb FROM blocks WHERE loc=:loc")) {
|
||||
return false;
|
||||
}
|
||||
if (!prepare(db, &_begin_statement, "BEGIN")) {
|
||||
return false;
|
||||
}
|
||||
if (!prepare(db, &_end_statement, "END")) {
|
||||
return false;
|
||||
}
|
||||
if (!prepare(db, &_load_meta_statement, "SELECT * FROM meta")) {
|
||||
return false;
|
||||
}
|
||||
if (!prepare(db, &_save_meta_statement, "INSERT INTO meta VALUES (:version, :block_size_po2)")) {
|
||||
return false;
|
||||
}
|
||||
if (!prepare(db, &_load_channels_statement, "SELECT * FROM channels")) {
|
||||
return false;
|
||||
}
|
||||
if (!prepare(db, &_save_channel_statement,
|
||||
"INSERT INTO channels VALUES (:idx, :depth) ON CONFLICT(idx) DO UPDATE SET depth=excluded.depth")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is the database setup?
|
||||
Meta meta = load_meta();
|
||||
if (meta.version == -1) {
|
||||
// Setup database
|
||||
meta.version = VERSION;
|
||||
// Defaults
|
||||
meta.block_size_po2 = VoxelConstants::DEFAULT_BLOCK_SIZE_PO2;
|
||||
for (int i = 0; i < meta.channels.size(); ++i) {
|
||||
Meta::Channel &channel = meta.channels[i];
|
||||
channel.used = true;
|
||||
channel.depth = VoxelBuffer::DEPTH_16_BIT;
|
||||
}
|
||||
save_meta(meta);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void VoxelStreamSQLiteInternal::close() {
|
||||
if (_db == nullptr) {
|
||||
return;
|
||||
}
|
||||
finalize(_begin_statement);
|
||||
finalize(_end_statement);
|
||||
finalize(_update_block_statement);
|
||||
finalize(_get_block_statement);
|
||||
finalize(_load_meta_statement);
|
||||
finalize(_save_meta_statement);
|
||||
finalize(_load_channels_statement);
|
||||
finalize(_save_channel_statement);
|
||||
sqlite3_close(_db);
|
||||
_db = nullptr;
|
||||
}
|
||||
|
||||
const char *VoxelStreamSQLiteInternal::get_file_path() const {
|
||||
if (_db == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return sqlite3_db_filename(_db, nullptr);
|
||||
}
|
||||
|
||||
bool VoxelStreamSQLiteInternal::begin_transaction() {
|
||||
int rc = sqlite3_reset(_begin_statement);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(_db));
|
||||
return false;
|
||||
}
|
||||
rc = sqlite3_step(_begin_statement);
|
||||
if (rc != SQLITE_DONE) {
|
||||
ERR_PRINT(sqlite3_errmsg(_db));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VoxelStreamSQLiteInternal::end_transaction() {
|
||||
int rc = sqlite3_reset(_end_statement);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(_db));
|
||||
return false;
|
||||
}
|
||||
rc = sqlite3_step(_end_statement);
|
||||
if (rc != SQLITE_DONE) {
|
||||
ERR_PRINT(sqlite3_errmsg(_db));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VoxelStreamSQLiteInternal::save_block(BlockLocation loc, const std::vector<uint8_t> &block_data) {
|
||||
sqlite3 *db = _db;
|
||||
sqlite3_stmt *update_block_statement = _update_block_statement;
|
||||
|
||||
int rc = sqlite3_reset(update_block_statement);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint64_t eloc = BlockLocation::encode(loc);
|
||||
|
||||
rc = sqlite3_bind_int64(update_block_statement, 1, eloc);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return false;
|
||||
}
|
||||
|
||||
// We use SQLITE_TRANSIENT so SQLite will make its own copy of the data
|
||||
rc = sqlite3_bind_blob(update_block_statement, 2, block_data.data(), block_data.size(), SQLITE_TRANSIENT);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = sqlite3_step(update_block_statement);
|
||||
if (rc != SQLITE_DONE) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
VoxelStream::Result VoxelStreamSQLiteInternal::load_block(BlockLocation loc, std::vector<uint8_t> &out_block_data) {
|
||||
sqlite3 *db = _db;
|
||||
sqlite3_stmt *get_block_statement = _get_block_statement;
|
||||
|
||||
int rc;
|
||||
|
||||
rc = sqlite3_reset(get_block_statement);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return VoxelStream::RESULT_ERROR;
|
||||
}
|
||||
|
||||
const uint64_t eloc = BlockLocation::encode(loc);
|
||||
|
||||
rc = sqlite3_bind_int64(get_block_statement, 1, eloc);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return VoxelStream::RESULT_ERROR;
|
||||
}
|
||||
|
||||
VoxelStream::Result result = VoxelStream::RESULT_BLOCK_NOT_FOUND;
|
||||
|
||||
while (true) {
|
||||
rc = sqlite3_step(get_block_statement);
|
||||
if (rc == SQLITE_ROW) {
|
||||
const void *blob = sqlite3_column_blob(get_block_statement, 0);
|
||||
//const uint8_t *b = reinterpret_cast<const uint8_t *>(blob);
|
||||
const size_t blob_size = sqlite3_column_bytes(get_block_statement, 0);
|
||||
if (blob_size != 0) {
|
||||
result = VoxelStream::RESULT_BLOCK_FOUND;
|
||||
out_block_data.resize(blob_size);
|
||||
memcpy(out_block_data.data(), blob, blob_size);
|
||||
}
|
||||
// The query is still ongoing, we'll need to step one more time to complete it
|
||||
continue;
|
||||
}
|
||||
if (rc != SQLITE_DONE) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return VoxelStream::RESULT_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
VoxelStreamSQLiteInternal::Meta VoxelStreamSQLiteInternal::load_meta() {
|
||||
sqlite3 *db = _db;
|
||||
sqlite3_stmt *load_meta_statement = _load_meta_statement;
|
||||
sqlite3_stmt *load_channels_statement = _load_channels_statement;
|
||||
|
||||
int rc = sqlite3_reset(load_meta_statement);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return Meta();
|
||||
}
|
||||
|
||||
TransactionScope transaction(*this);
|
||||
|
||||
Meta meta;
|
||||
|
||||
rc = sqlite3_step(load_meta_statement);
|
||||
if (rc == SQLITE_ROW) {
|
||||
meta.version = sqlite3_column_int(load_meta_statement, 0);
|
||||
meta.block_size_po2 = sqlite3_column_int(load_meta_statement, 1);
|
||||
// The query is still ongoing, we'll need to step one more time to complete it
|
||||
rc = sqlite3_step(load_meta_statement);
|
||||
|
||||
} else if (rc == SQLITE_DONE) {
|
||||
// There was no row. This database is probably not setup.
|
||||
return Meta();
|
||||
}
|
||||
if (rc != SQLITE_DONE) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return Meta();
|
||||
}
|
||||
|
||||
rc = sqlite3_reset(load_channels_statement);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return Meta();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
rc = sqlite3_step(load_channels_statement);
|
||||
if (rc == SQLITE_ROW) {
|
||||
const int index = sqlite3_column_int(load_channels_statement, 0);
|
||||
const int depth = sqlite3_column_int(load_channels_statement, 1);
|
||||
if (index < 0 || index >= meta.channels.size()) {
|
||||
ERR_PRINT(String("Channel index {0} is invalid").format(varray(index)));
|
||||
continue;
|
||||
}
|
||||
if (depth < 0 || depth >= VoxelBuffer::DEPTH_COUNT) {
|
||||
ERR_PRINT(String("Depth {0} is invalid").format(varray(depth)));
|
||||
continue;
|
||||
}
|
||||
Meta::Channel &channel = meta.channels[index];
|
||||
channel.used = true;
|
||||
channel.depth = static_cast<VoxelBuffer::Depth>(depth);
|
||||
continue;
|
||||
}
|
||||
if (rc != SQLITE_DONE) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return Meta();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
void VoxelStreamSQLiteInternal::save_meta(Meta meta) {
|
||||
sqlite3 *db = _db;
|
||||
sqlite3_stmt *save_meta_statement = _save_meta_statement;
|
||||
sqlite3_stmt *save_channel_statement = _save_channel_statement;
|
||||
|
||||
int rc = sqlite3_reset(save_meta_statement);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return;
|
||||
}
|
||||
|
||||
TransactionScope transaction(*this);
|
||||
|
||||
rc = sqlite3_bind_int(save_meta_statement, 1, meta.version);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return;
|
||||
}
|
||||
rc = sqlite3_bind_int(save_meta_statement, 2, meta.block_size_po2);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return;
|
||||
}
|
||||
|
||||
rc = sqlite3_step(save_meta_statement);
|
||||
if (rc != SQLITE_DONE) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned int channel_index = 0; channel_index < meta.channels.size(); ++channel_index) {
|
||||
const Meta::Channel &channel = meta.channels[channel_index];
|
||||
if (!channel.used) {
|
||||
// TODO Remove rows for unused channels? Or have a `used` column?
|
||||
continue;
|
||||
}
|
||||
|
||||
rc = sqlite3_reset(save_channel_statement);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return;
|
||||
}
|
||||
|
||||
rc = sqlite3_bind_int(save_channel_statement, 1, channel_index);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return;
|
||||
}
|
||||
rc = sqlite3_bind_int(save_channel_statement, 2, channel.depth);
|
||||
if (rc != SQLITE_OK) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return;
|
||||
}
|
||||
|
||||
rc = sqlite3_step(save_channel_statement);
|
||||
if (rc != SQLITE_DONE) {
|
||||
ERR_PRINT(sqlite3_errmsg(db));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
thread_local VoxelBlockSerializerInternal VoxelStreamSQLite::_voxel_block_serializer;
|
||||
thread_local std::vector<uint8_t> VoxelStreamSQLite::_temp_block_data;
|
||||
|
||||
VoxelStreamSQLite::VoxelStreamSQLite() {
|
||||
_connection_mutex = Mutex::create();
|
||||
}
|
||||
|
||||
VoxelStreamSQLite::~VoxelStreamSQLite() {
|
||||
if (!_connection_path.empty() && _cache.get_indicative_block_count() > 0) {
|
||||
flush_cache();
|
||||
}
|
||||
for (auto it = _connection_pool.begin(); it != _connection_pool.end(); ++it) {
|
||||
delete *it;
|
||||
}
|
||||
_connection_pool.clear();
|
||||
memdelete(_connection_mutex);
|
||||
}
|
||||
|
||||
void VoxelStreamSQLite::set_database_path(String path) {
|
||||
MutexLock lock(_connection_mutex);
|
||||
if (path == _connection_path) {
|
||||
return;
|
||||
}
|
||||
if (!_connection_path.empty() && _cache.get_indicative_block_count() > 0) {
|
||||
// Save cached data before changing the path.
|
||||
// Not using get_connection() because it locks.
|
||||
VoxelStreamSQLiteInternal con;
|
||||
CharString cpath = path.utf8();
|
||||
// Note, the path could be invalid,
|
||||
// Since Godot helpfully sets the property for every character typed in the inspector.
|
||||
// So there can be lots of errors in the editor if you type it.
|
||||
if (con.open(cpath)) {
|
||||
flush_cache(&con);
|
||||
}
|
||||
}
|
||||
for (auto it = _connection_pool.begin(); it != _connection_pool.end(); ++it) {
|
||||
delete *it;
|
||||
}
|
||||
_connection_pool.clear();
|
||||
_connection_path = path;
|
||||
// Don't actually open anything here. We'll do it only when necessary
|
||||
}
|
||||
|
||||
String VoxelStreamSQLite::get_database_path() const {
|
||||
MutexLock lock(_connection_mutex);
|
||||
return _connection_path;
|
||||
}
|
||||
|
||||
VoxelStream::Result VoxelStreamSQLite::emerge_block(Ref<VoxelBuffer> out_buffer, Vector3i origin_in_voxels, int lod) {
|
||||
VoxelBlockRequest r;
|
||||
r.lod = lod;
|
||||
r.origin_in_voxels = origin_in_voxels;
|
||||
r.voxel_buffer = out_buffer;
|
||||
Vector<VoxelBlockRequest> requests;
|
||||
Vector<VoxelStream::Result> results;
|
||||
requests.push_back(r);
|
||||
emerge_blocks(requests, results);
|
||||
return results[0];
|
||||
}
|
||||
|
||||
void VoxelStreamSQLite::immerge_block(Ref<VoxelBuffer> buffer, Vector3i origin_in_voxels, int lod) {
|
||||
VoxelBlockRequest r;
|
||||
r.voxel_buffer = buffer;
|
||||
r.origin_in_voxels = origin_in_voxels;
|
||||
r.lod = lod;
|
||||
Vector<VoxelBlockRequest> requests;
|
||||
requests.push_back(r);
|
||||
immerge_blocks(requests);
|
||||
}
|
||||
|
||||
void VoxelStreamSQLite::emerge_blocks(Vector<VoxelBlockRequest> &p_blocks, Vector<Result> &out_results) {
|
||||
// TODO Get block size from database
|
||||
const int bs_po2 = 4;
|
||||
|
||||
out_results.resize(p_blocks.size());
|
||||
|
||||
// Check the cache first
|
||||
Vector<int> blocks_to_load;
|
||||
for (int i = 0; i < p_blocks.size(); ++i) {
|
||||
const VoxelBlockRequest &r = p_blocks[i];
|
||||
const Vector3i pos = r.origin_in_voxels >> bs_po2;
|
||||
|
||||
Ref<VoxelBuffer> vb;
|
||||
if (_cache.load_voxel_block(pos, r.lod, vb)) {
|
||||
VoxelBlockRequest &wr = p_blocks.write[i];
|
||||
wr.voxel_buffer = vb;
|
||||
out_results.write[i] = RESULT_BLOCK_FOUND;
|
||||
} else {
|
||||
blocks_to_load.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (blocks_to_load.size() == 0) {
|
||||
// Everything was cached, no need to query the database
|
||||
return;
|
||||
}
|
||||
|
||||
VoxelStreamSQLiteInternal *con = get_connection();
|
||||
ERR_FAIL_COND(con == nullptr);
|
||||
|
||||
// TODO We should handle busy return codes
|
||||
ERR_FAIL_COND(con->begin_transaction() == false);
|
||||
|
||||
for (int i = 0; i < blocks_to_load.size(); ++i) {
|
||||
const int ri = blocks_to_load[i];
|
||||
const VoxelBlockRequest &r = p_blocks[ri];
|
||||
|
||||
BlockLocation loc;
|
||||
loc.x = r.origin_in_voxels.x >> bs_po2;
|
||||
loc.y = r.origin_in_voxels.y >> bs_po2;
|
||||
loc.z = r.origin_in_voxels.z >> bs_po2;
|
||||
loc.lod = r.lod;
|
||||
|
||||
const Result res = con->load_block(loc, _temp_block_data);
|
||||
|
||||
if (res == RESULT_BLOCK_FOUND) {
|
||||
VoxelBlockRequest &wr = p_blocks.write[ri];
|
||||
// TODO Not sure if we should actually expect non-null. There can be legit not found blocks.
|
||||
ERR_FAIL_COND(wr.voxel_buffer.is_null());
|
||||
_voxel_block_serializer.decompress_and_deserialize(_temp_block_data, **wr.voxel_buffer);
|
||||
}
|
||||
|
||||
out_results.write[i] = res;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(con->end_transaction() == false);
|
||||
|
||||
recycle_connection(con);
|
||||
}
|
||||
|
||||
void VoxelStreamSQLite::immerge_blocks(const Vector<VoxelBlockRequest> &p_blocks) {
|
||||
// TODO Get block size from database
|
||||
const int bs_po2 = 4;
|
||||
|
||||
// First put in cache
|
||||
for (int i = 0; i < p_blocks.size(); ++i) {
|
||||
const VoxelBlockRequest &r = p_blocks[i];
|
||||
const Vector3i pos = r.origin_in_voxels >> bs_po2;
|
||||
_cache.save_voxel_block(pos, r.lod, r.voxel_buffer);
|
||||
}
|
||||
|
||||
if (_cache.get_indicative_block_count() >= CACHE_SIZE) {
|
||||
flush_cache();
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelStreamSQLite::flush_cache() {
|
||||
VoxelStreamSQLiteInternal *con = get_connection();
|
||||
ERR_FAIL_COND(con == nullptr);
|
||||
flush_cache(con);
|
||||
recycle_connection(con);
|
||||
}
|
||||
|
||||
// This function does not lock any mutex for internal use.
|
||||
void VoxelStreamSQLite::flush_cache(VoxelStreamSQLiteInternal *con) {
|
||||
VoxelBlockSerializerInternal &serializer = _voxel_block_serializer;
|
||||
|
||||
ERR_FAIL_COND(con == nullptr);
|
||||
ERR_FAIL_COND(con->begin_transaction() == false);
|
||||
|
||||
_cache.flush([&serializer, con](VoxelStreamCache::Block &block) {
|
||||
BlockLocation loc;
|
||||
loc.x = block.position.x;
|
||||
loc.y = block.position.y;
|
||||
loc.z = block.position.z;
|
||||
loc.lod = block.lod;
|
||||
// TODO We might want to handle null blocks too, in case they intentionally get deleted
|
||||
ERR_FAIL_COND(block.voxels.is_null());
|
||||
const std::vector<uint8_t> &temp = serializer.serialize_and_compress(**block.voxels);
|
||||
con->save_block(loc, temp);
|
||||
});
|
||||
|
||||
ERR_FAIL_COND(con->end_transaction() == false);
|
||||
}
|
||||
|
||||
VoxelStreamSQLiteInternal *VoxelStreamSQLite::get_connection() {
|
||||
_connection_mutex->lock();
|
||||
if (_connection_path.empty()) {
|
||||
_connection_mutex->unlock();
|
||||
return nullptr;
|
||||
}
|
||||
if (_connection_pool.size() != 0) {
|
||||
VoxelStreamSQLiteInternal *s = _connection_pool.back();
|
||||
_connection_pool.pop_back();
|
||||
_connection_mutex->unlock();
|
||||
return s;
|
||||
}
|
||||
String fpath = _connection_path;
|
||||
_connection_mutex->unlock();
|
||||
|
||||
if (fpath.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
VoxelStreamSQLiteInternal *con = new VoxelStreamSQLiteInternal();
|
||||
CharString fpath_utf8 = fpath.utf8();
|
||||
if (!con->open(fpath_utf8)) {
|
||||
delete con;
|
||||
con = nullptr;
|
||||
}
|
||||
return con;
|
||||
}
|
||||
|
||||
void VoxelStreamSQLite::recycle_connection(VoxelStreamSQLiteInternal *con) {
|
||||
String con_path = con->get_file_path();
|
||||
_connection_mutex->lock();
|
||||
// If path differs, delete this connection
|
||||
if (_connection_path != con_path) {
|
||||
_connection_mutex->unlock();
|
||||
delete con;
|
||||
} else {
|
||||
_connection_pool.push_back(con);
|
||||
_connection_mutex->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelStreamSQLite::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_database_path", "path"), &VoxelStreamSQLite::set_database_path);
|
||||
ClassDB::bind_method(D_METHOD("get_database_path"), &VoxelStreamSQLite::get_database_path);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "database_path", PROPERTY_HINT_DIR),
|
||||
"set_database_path", "get_database_path");
|
||||
}
|
63
streams/sqlite/voxel_stream_sqlite.h
Normal file
63
streams/sqlite/voxel_stream_sqlite.h
Normal file
@ -0,0 +1,63 @@
|
||||
#ifndef VOXEL_STREAM_SQLITE_H
|
||||
#define VOXEL_STREAM_SQLITE_H
|
||||
|
||||
#include "../voxel_block_serializer.h"
|
||||
#include "../voxel_stream.h"
|
||||
#include "../voxel_stream_cache.h"
|
||||
#include <core/os/mutex.h>
|
||||
#include <vector>
|
||||
|
||||
class VoxelStreamSQLiteInternal;
|
||||
|
||||
// Saves voxel data into a single SQLite database file.
|
||||
class VoxelStreamSQLite : public VoxelStream {
|
||||
GDCLASS(VoxelStreamSQLite, VoxelStream)
|
||||
public:
|
||||
static const unsigned int CACHE_SIZE = 32;
|
||||
|
||||
VoxelStreamSQLite();
|
||||
~VoxelStreamSQLite();
|
||||
|
||||
void set_database_path(String path);
|
||||
String get_database_path() const;
|
||||
|
||||
Result emerge_block(Ref<VoxelBuffer> out_buffer, Vector3i origin_in_voxels, int lod) override;
|
||||
void immerge_block(Ref<VoxelBuffer> buffer, Vector3i origin_in_voxels, int lod) override;
|
||||
|
||||
void emerge_blocks(Vector<VoxelBlockRequest> &p_blocks, Vector<Result> &out_results) override;
|
||||
void immerge_blocks(const Vector<VoxelBlockRequest> &p_blocks) override;
|
||||
|
||||
void flush_cache();
|
||||
|
||||
private:
|
||||
// An SQlite3 database is safe to use with multiple threads in serialized mode,
|
||||
// but after having a look at the implementation while stepping with a debugger, here are what actually happens:
|
||||
//
|
||||
// 1) Prepared statements might be safe to use in multiple threads, but the end result isn't safe.
|
||||
// Thread A could bind a value, then thread B could bind another value replacing the first before thread A
|
||||
// executes the statement. So in the end, each thread should get its own set of statements.
|
||||
//
|
||||
// 2) Executing a statement locks the entire database with a mutex.
|
||||
// So indeed access is serialized, in the sense that CPU work will execute in series, not in parallel.
|
||||
// in other words, you loose the speed of multi-threading.
|
||||
//
|
||||
// Because of this, in our use case, it might be simpler to just leave SQLite in thread-safe mode,
|
||||
// and synchronize ourselves.
|
||||
|
||||
VoxelStreamSQLiteInternal *get_connection();
|
||||
void recycle_connection(VoxelStreamSQLiteInternal *con);
|
||||
void flush_cache(VoxelStreamSQLiteInternal *con);
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
String _connection_path;
|
||||
std::vector<VoxelStreamSQLiteInternal *> _connection_pool;
|
||||
Mutex *_connection_mutex = nullptr;
|
||||
VoxelStreamCache _cache;
|
||||
|
||||
// TODO I should consider specialized memory allocators
|
||||
static thread_local VoxelBlockSerializerInternal _voxel_block_serializer;
|
||||
static thread_local std::vector<uint8_t> _temp_block_data;
|
||||
};
|
||||
|
||||
#endif // VOXEL_STREAM_SQLITE_H
|
@ -27,6 +27,7 @@ class VoxelVoxLoader : public Reference {
|
||||
public:
|
||||
Error load_from_file(String fpath, Ref<VoxelBuffer> voxels, Ref<VoxelColorPalette> palette);
|
||||
// TODO Have chunked loading for better memory usage
|
||||
// TODO Saving
|
||||
|
||||
private:
|
||||
static void _bind_methods();
|
||||
|
@ -180,7 +180,7 @@ size_t get_size_in_bytes(const VoxelBuffer &buffer, size_t &metadata_size) {
|
||||
return size + metadata_size_with_header + BLOCK_TRAILING_MAGIC_SIZE;
|
||||
}
|
||||
|
||||
const std::vector<uint8_t> &VoxelBlockSerializerInternal::serialize(VoxelBuffer &voxel_buffer) {
|
||||
const std::vector<uint8_t> &VoxelBlockSerializerInternal::serialize(const VoxelBuffer &voxel_buffer) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
size_t metadata_size = 0;
|
||||
const size_t data_size = get_size_in_bytes(voxel_buffer, metadata_size);
|
||||
@ -201,7 +201,7 @@ const std::vector<uint8_t> &VoxelBlockSerializerInternal::serialize(VoxelBuffer
|
||||
} break;
|
||||
|
||||
case VoxelBuffer::COMPRESSION_UNIFORM: {
|
||||
uint64_t v = voxel_buffer.get_voxel(Vector3i(), channel_index);
|
||||
const uint64_t v = voxel_buffer.get_voxel(Vector3i(), channel_index);
|
||||
switch (voxel_buffer.get_channel_depth(channel_index)) {
|
||||
case VoxelBuffer::DEPTH_8_BIT:
|
||||
f->store_8(v);
|
||||
@ -306,7 +306,7 @@ bool VoxelBlockSerializerInternal::deserialize(const std::vector<uint8_t> &p_dat
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::vector<uint8_t> &VoxelBlockSerializerInternal::serialize_and_compress(VoxelBuffer &voxel_buffer) {
|
||||
const std::vector<uint8_t> &VoxelBlockSerializerInternal::serialize_and_compress(const VoxelBuffer &voxel_buffer) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
const std::vector<uint8_t> &data = serialize(voxel_buffer);
|
||||
|
||||
|
@ -11,10 +11,10 @@ class StreamPeer;
|
||||
class VoxelBlockSerializerInternal {
|
||||
// Had to be named differently to not conflict with the wrapper for Godot script API
|
||||
public:
|
||||
const std::vector<uint8_t> &serialize(VoxelBuffer &voxel_buffer);
|
||||
const std::vector<uint8_t> &serialize(const VoxelBuffer &voxel_buffer);
|
||||
bool deserialize(const std::vector<uint8_t> &p_data, VoxelBuffer &out_voxel_buffer);
|
||||
|
||||
const std::vector<uint8_t> &serialize_and_compress(VoxelBuffer &voxel_buffer);
|
||||
const std::vector<uint8_t> &serialize_and_compress(const VoxelBuffer &voxel_buffer);
|
||||
bool decompress_and_deserialize(const std::vector<uint8_t> &p_data, VoxelBuffer &out_voxel_buffer);
|
||||
bool decompress_and_deserialize(FileAccess *f, unsigned int size_to_read, VoxelBuffer &out_voxel_buffer);
|
||||
|
||||
|
@ -9,6 +9,10 @@
|
||||
// This is intented for files, so it may run in a single background thread and gets requests in batches.
|
||||
// Must be implemented in a thread-safe way.
|
||||
//
|
||||
// Functions currently don't enforce querying blocks of the same size, however it is required for every stream to
|
||||
// support querying blocks the size of the declared block size, at positions matching their origins.
|
||||
// This might be restricted in the future, because there has been no compelling use case for that.
|
||||
//
|
||||
// If you are looking for a more specialized API to generate voxels with more threads, use VoxelGenerator.
|
||||
//
|
||||
class VoxelStream : public Resource {
|
||||
@ -29,6 +33,7 @@ public:
|
||||
};
|
||||
|
||||
// TODO Rename load_block()
|
||||
// TODO Enforce block areas
|
||||
// Queries a block of voxels beginning at the given world-space voxel position and LOD.
|
||||
// If you use LOD, the result at a given coordinate must always remain the same regardless of it.
|
||||
// In other words, voxels values must solely depend on their coordinates or fixed parameters.
|
||||
@ -37,14 +42,19 @@ public:
|
||||
// TODO Rename save_block()
|
||||
virtual void immerge_block(Ref<VoxelBuffer> buffer, Vector3i origin_in_voxels, int lod);
|
||||
|
||||
// TODO Pass with ArraySlice
|
||||
// Note: vector is passed by ref for performance. Don't reorder it.
|
||||
virtual void emerge_blocks(Vector<VoxelBlockRequest> &p_blocks, Vector<Result> &out_results);
|
||||
|
||||
// TODO Pass with ArraySlice
|
||||
// Returns multiple blocks of voxels to the stream.
|
||||
// This function is recommended if you save to files, because you can batch their access.
|
||||
virtual void immerge_blocks(const Vector<VoxelBlockRequest> &p_blocks);
|
||||
|
||||
// Declares the format expected from this stream
|
||||
// Tells which channels can be found in this stream.
|
||||
// The simplest implementation is to return them all.
|
||||
// One reason to specify which channels are available is to help the editor detect configuration issues,
|
||||
// and to avoid saving some of the channels if only specific ones are meant to be saved.
|
||||
virtual int get_used_channels_mask() const;
|
||||
|
||||
// Gets which block size this stream will provide, as a power of two.
|
||||
|
43
streams/voxel_stream_cache.cpp
Normal file
43
streams/voxel_stream_cache.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#include "voxel_stream_cache.h"
|
||||
|
||||
bool VoxelStreamCache::load_voxel_block(Vector3i position, uint8_t lod_index, Ref<VoxelBuffer> &out_voxels) {
|
||||
const Lod &lod = _cache[lod_index];
|
||||
lod.rw_lock->read_lock();
|
||||
const Block *block_ptr = lod.blocks.getptr(position);
|
||||
|
||||
if (block_ptr == nullptr) {
|
||||
// Not in cache, will have to query
|
||||
lod.rw_lock->read_unlock();
|
||||
return false;
|
||||
|
||||
} else {
|
||||
// In cache, serve it
|
||||
out_voxels = block_ptr->voxels;
|
||||
lod.rw_lock->read_unlock();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelStreamCache::save_voxel_block(Vector3i position, uint8_t lod_index, Ref<VoxelBuffer> voxels) {
|
||||
Lod &lod = _cache[lod_index];
|
||||
RWLockWrite wlock(lod.rw_lock);
|
||||
Block *block_ptr = lod.blocks.getptr(position);
|
||||
|
||||
if (block_ptr == nullptr) {
|
||||
// Not cached yet, create an entry
|
||||
Block b;
|
||||
b.position = position;
|
||||
b.lod = lod_index;
|
||||
b.voxels = voxels;
|
||||
lod.blocks.set(position, b);
|
||||
++_count;
|
||||
|
||||
} else {
|
||||
// Cached already, overwrite
|
||||
block_ptr->voxels = voxels;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int VoxelStreamCache::get_indicative_block_count() const {
|
||||
return _count;
|
||||
}
|
53
streams/voxel_stream_cache.h
Normal file
53
streams/voxel_stream_cache.h
Normal file
@ -0,0 +1,53 @@
|
||||
#ifndef VOXEL_STREAM_CACHE_H
|
||||
#define VOXEL_STREAM_CACHE_H
|
||||
|
||||
#include "../storage/voxel_buffer.h"
|
||||
|
||||
// In-memory database for voxel streams.
|
||||
// It allows to cache blocks so we can save to the filesystem less frequently, or quickly reload recent blocks.
|
||||
class VoxelStreamCache {
|
||||
public:
|
||||
struct Block {
|
||||
Vector3i position;
|
||||
int lod;
|
||||
Ref<VoxelBuffer> voxels;
|
||||
};
|
||||
|
||||
bool load_voxel_block(Vector3i position, uint8_t lod_index, Ref<VoxelBuffer> &out_voxels);
|
||||
void save_voxel_block(Vector3i position, uint8_t lod_index, Ref<VoxelBuffer> voxels);
|
||||
|
||||
unsigned int get_indicative_block_count() const;
|
||||
|
||||
template <typename F>
|
||||
void flush(F save_func) {
|
||||
for (unsigned int lod_index = 0; lod_index < _cache.size(); ++lod_index) {
|
||||
Lod &lod = _cache[lod_index];
|
||||
RWLockWrite wlock(lod.rw_lock);
|
||||
const Vector3i *position = nullptr;
|
||||
while ((position = lod.blocks.next(position))) {
|
||||
Block *block = lod.blocks.getptr(*position);
|
||||
ERR_FAIL_COND(block == nullptr);
|
||||
save_func(*block);
|
||||
}
|
||||
lod.blocks.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
struct Lod {
|
||||
HashMap<Vector3i, Block, Vector3iHasher> blocks;
|
||||
RWLock *rw_lock;
|
||||
|
||||
Lod() {
|
||||
rw_lock = RWLock::create();
|
||||
}
|
||||
~Lod() {
|
||||
memdelete(rw_lock);
|
||||
}
|
||||
};
|
||||
|
||||
FixedArray<Lod, VoxelConstants::MAX_LOD> _cache;
|
||||
unsigned int _count = 0;
|
||||
};
|
||||
|
||||
#endif // VOXEL_STREAM_CACHE_H
|
@ -7,7 +7,7 @@ VoxelMap::VoxelMap() :
|
||||
_last_accessed_block(nullptr) {
|
||||
|
||||
// TODO Make it configurable in editor (with all necessary notifications and updatings!)
|
||||
set_block_size_pow2(4);
|
||||
set_block_size_pow2(VoxelConstants::DEFAULT_BLOCK_SIZE_PO2);
|
||||
|
||||
_default_voxel.fill(0);
|
||||
_default_voxel[VoxelBuffer::CHANNEL_SDF] = 255;
|
||||
|
232645
thirdparty/sqlite/sqlite3.c
vendored
Normal file
232645
thirdparty/sqlite/sqlite3.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
12247
thirdparty/sqlite/sqlite3.h
vendored
Normal file
12247
thirdparty/sqlite/sqlite3.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
663
thirdparty/sqlite/sqlite3ext.h
vendored
Normal file
663
thirdparty/sqlite/sqlite3ext.h
vendored
Normal file
@ -0,0 +1,663 @@
|
||||
/*
|
||||
** 2006 June 7
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This header file defines the SQLite interface for use by
|
||||
** shared libraries that want to be imported as extensions into
|
||||
** an SQLite instance. Shared libraries that intend to be loaded
|
||||
** as extensions by SQLite should #include this file instead of
|
||||
** sqlite3.h.
|
||||
*/
|
||||
#ifndef SQLITE3EXT_H
|
||||
#define SQLITE3EXT_H
|
||||
#include "sqlite3.h"
|
||||
|
||||
/*
|
||||
** The following structure holds pointers to all of the SQLite API
|
||||
** routines.
|
||||
**
|
||||
** WARNING: In order to maintain backwards compatibility, add new
|
||||
** interfaces to the end of this structure only. If you insert new
|
||||
** interfaces in the middle of this structure, then older different
|
||||
** versions of SQLite will not be able to load each other's shared
|
||||
** libraries!
|
||||
*/
|
||||
struct sqlite3_api_routines {
|
||||
void * (*aggregate_context)(sqlite3_context*,int nBytes);
|
||||
int (*aggregate_count)(sqlite3_context*);
|
||||
int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
|
||||
int (*bind_double)(sqlite3_stmt*,int,double);
|
||||
int (*bind_int)(sqlite3_stmt*,int,int);
|
||||
int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);
|
||||
int (*bind_null)(sqlite3_stmt*,int);
|
||||
int (*bind_parameter_count)(sqlite3_stmt*);
|
||||
int (*bind_parameter_index)(sqlite3_stmt*,const char*zName);
|
||||
const char * (*bind_parameter_name)(sqlite3_stmt*,int);
|
||||
int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));
|
||||
int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));
|
||||
int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);
|
||||
int (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
|
||||
int (*busy_timeout)(sqlite3*,int ms);
|
||||
int (*changes)(sqlite3*);
|
||||
int (*close)(sqlite3*);
|
||||
int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,
|
||||
int eTextRep,const char*));
|
||||
int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,
|
||||
int eTextRep,const void*));
|
||||
const void * (*column_blob)(sqlite3_stmt*,int iCol);
|
||||
int (*column_bytes)(sqlite3_stmt*,int iCol);
|
||||
int (*column_bytes16)(sqlite3_stmt*,int iCol);
|
||||
int (*column_count)(sqlite3_stmt*pStmt);
|
||||
const char * (*column_database_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_database_name16)(sqlite3_stmt*,int);
|
||||
const char * (*column_decltype)(sqlite3_stmt*,int i);
|
||||
const void * (*column_decltype16)(sqlite3_stmt*,int);
|
||||
double (*column_double)(sqlite3_stmt*,int iCol);
|
||||
int (*column_int)(sqlite3_stmt*,int iCol);
|
||||
sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol);
|
||||
const char * (*column_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_name16)(sqlite3_stmt*,int);
|
||||
const char * (*column_origin_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_origin_name16)(sqlite3_stmt*,int);
|
||||
const char * (*column_table_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_table_name16)(sqlite3_stmt*,int);
|
||||
const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);
|
||||
const void * (*column_text16)(sqlite3_stmt*,int iCol);
|
||||
int (*column_type)(sqlite3_stmt*,int iCol);
|
||||
sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
|
||||
void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
|
||||
int (*complete)(const char*sql);
|
||||
int (*complete16)(const void*sql);
|
||||
int (*create_collation)(sqlite3*,const char*,int,void*,
|
||||
int(*)(void*,int,const void*,int,const void*));
|
||||
int (*create_collation16)(sqlite3*,const void*,int,void*,
|
||||
int(*)(void*,int,const void*,int,const void*));
|
||||
int (*create_function)(sqlite3*,const char*,int,int,void*,
|
||||
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xFinal)(sqlite3_context*));
|
||||
int (*create_function16)(sqlite3*,const void*,int,int,void*,
|
||||
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xFinal)(sqlite3_context*));
|
||||
int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
|
||||
int (*data_count)(sqlite3_stmt*pStmt);
|
||||
sqlite3 * (*db_handle)(sqlite3_stmt*);
|
||||
int (*declare_vtab)(sqlite3*,const char*);
|
||||
int (*enable_shared_cache)(int);
|
||||
int (*errcode)(sqlite3*db);
|
||||
const char * (*errmsg)(sqlite3*);
|
||||
const void * (*errmsg16)(sqlite3*);
|
||||
int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
|
||||
int (*expired)(sqlite3_stmt*);
|
||||
int (*finalize)(sqlite3_stmt*pStmt);
|
||||
void (*free)(void*);
|
||||
void (*free_table)(char**result);
|
||||
int (*get_autocommit)(sqlite3*);
|
||||
void * (*get_auxdata)(sqlite3_context*,int);
|
||||
int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);
|
||||
int (*global_recover)(void);
|
||||
void (*interruptx)(sqlite3*);
|
||||
sqlite_int64 (*last_insert_rowid)(sqlite3*);
|
||||
const char * (*libversion)(void);
|
||||
int (*libversion_number)(void);
|
||||
void *(*malloc)(int);
|
||||
char * (*mprintf)(const char*,...);
|
||||
int (*open)(const char*,sqlite3**);
|
||||
int (*open16)(const void*,sqlite3**);
|
||||
int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
|
||||
int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
|
||||
void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);
|
||||
void (*progress_handler)(sqlite3*,int,int(*)(void*),void*);
|
||||
void *(*realloc)(void*,int);
|
||||
int (*reset)(sqlite3_stmt*pStmt);
|
||||
void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||
void (*result_double)(sqlite3_context*,double);
|
||||
void (*result_error)(sqlite3_context*,const char*,int);
|
||||
void (*result_error16)(sqlite3_context*,const void*,int);
|
||||
void (*result_int)(sqlite3_context*,int);
|
||||
void (*result_int64)(sqlite3_context*,sqlite_int64);
|
||||
void (*result_null)(sqlite3_context*);
|
||||
void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));
|
||||
void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||
void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||
void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||
void (*result_value)(sqlite3_context*,sqlite3_value*);
|
||||
void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
|
||||
int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,
|
||||
const char*,const char*),void*);
|
||||
void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
|
||||
char * (*xsnprintf)(int,char*,const char*,...);
|
||||
int (*step)(sqlite3_stmt*);
|
||||
int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,
|
||||
char const**,char const**,int*,int*,int*);
|
||||
void (*thread_cleanup)(void);
|
||||
int (*total_changes)(sqlite3*);
|
||||
void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
|
||||
int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
|
||||
void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,
|
||||
sqlite_int64),void*);
|
||||
void * (*user_data)(sqlite3_context*);
|
||||
const void * (*value_blob)(sqlite3_value*);
|
||||
int (*value_bytes)(sqlite3_value*);
|
||||
int (*value_bytes16)(sqlite3_value*);
|
||||
double (*value_double)(sqlite3_value*);
|
||||
int (*value_int)(sqlite3_value*);
|
||||
sqlite_int64 (*value_int64)(sqlite3_value*);
|
||||
int (*value_numeric_type)(sqlite3_value*);
|
||||
const unsigned char * (*value_text)(sqlite3_value*);
|
||||
const void * (*value_text16)(sqlite3_value*);
|
||||
const void * (*value_text16be)(sqlite3_value*);
|
||||
const void * (*value_text16le)(sqlite3_value*);
|
||||
int (*value_type)(sqlite3_value*);
|
||||
char *(*vmprintf)(const char*,va_list);
|
||||
/* Added ??? */
|
||||
int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);
|
||||
/* Added by 3.3.13 */
|
||||
int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
|
||||
int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
|
||||
int (*clear_bindings)(sqlite3_stmt*);
|
||||
/* Added by 3.4.1 */
|
||||
int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,
|
||||
void (*xDestroy)(void *));
|
||||
/* Added by 3.5.0 */
|
||||
int (*bind_zeroblob)(sqlite3_stmt*,int,int);
|
||||
int (*blob_bytes)(sqlite3_blob*);
|
||||
int (*blob_close)(sqlite3_blob*);
|
||||
int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,
|
||||
int,sqlite3_blob**);
|
||||
int (*blob_read)(sqlite3_blob*,void*,int,int);
|
||||
int (*blob_write)(sqlite3_blob*,const void*,int,int);
|
||||
int (*create_collation_v2)(sqlite3*,const char*,int,void*,
|
||||
int(*)(void*,int,const void*,int,const void*),
|
||||
void(*)(void*));
|
||||
int (*file_control)(sqlite3*,const char*,int,void*);
|
||||
sqlite3_int64 (*memory_highwater)(int);
|
||||
sqlite3_int64 (*memory_used)(void);
|
||||
sqlite3_mutex *(*mutex_alloc)(int);
|
||||
void (*mutex_enter)(sqlite3_mutex*);
|
||||
void (*mutex_free)(sqlite3_mutex*);
|
||||
void (*mutex_leave)(sqlite3_mutex*);
|
||||
int (*mutex_try)(sqlite3_mutex*);
|
||||
int (*open_v2)(const char*,sqlite3**,int,const char*);
|
||||
int (*release_memory)(int);
|
||||
void (*result_error_nomem)(sqlite3_context*);
|
||||
void (*result_error_toobig)(sqlite3_context*);
|
||||
int (*sleep)(int);
|
||||
void (*soft_heap_limit)(int);
|
||||
sqlite3_vfs *(*vfs_find)(const char*);
|
||||
int (*vfs_register)(sqlite3_vfs*,int);
|
||||
int (*vfs_unregister)(sqlite3_vfs*);
|
||||
int (*xthreadsafe)(void);
|
||||
void (*result_zeroblob)(sqlite3_context*,int);
|
||||
void (*result_error_code)(sqlite3_context*,int);
|
||||
int (*test_control)(int, ...);
|
||||
void (*randomness)(int,void*);
|
||||
sqlite3 *(*context_db_handle)(sqlite3_context*);
|
||||
int (*extended_result_codes)(sqlite3*,int);
|
||||
int (*limit)(sqlite3*,int,int);
|
||||
sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);
|
||||
const char *(*sql)(sqlite3_stmt*);
|
||||
int (*status)(int,int*,int*,int);
|
||||
int (*backup_finish)(sqlite3_backup*);
|
||||
sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);
|
||||
int (*backup_pagecount)(sqlite3_backup*);
|
||||
int (*backup_remaining)(sqlite3_backup*);
|
||||
int (*backup_step)(sqlite3_backup*,int);
|
||||
const char *(*compileoption_get)(int);
|
||||
int (*compileoption_used)(const char*);
|
||||
int (*create_function_v2)(sqlite3*,const char*,int,int,void*,
|
||||
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xFinal)(sqlite3_context*),
|
||||
void(*xDestroy)(void*));
|
||||
int (*db_config)(sqlite3*,int,...);
|
||||
sqlite3_mutex *(*db_mutex)(sqlite3*);
|
||||
int (*db_status)(sqlite3*,int,int*,int*,int);
|
||||
int (*extended_errcode)(sqlite3*);
|
||||
void (*log)(int,const char*,...);
|
||||
sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);
|
||||
const char *(*sourceid)(void);
|
||||
int (*stmt_status)(sqlite3_stmt*,int,int);
|
||||
int (*strnicmp)(const char*,const char*,int);
|
||||
int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);
|
||||
int (*wal_autocheckpoint)(sqlite3*,int);
|
||||
int (*wal_checkpoint)(sqlite3*,const char*);
|
||||
void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);
|
||||
int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);
|
||||
int (*vtab_config)(sqlite3*,int op,...);
|
||||
int (*vtab_on_conflict)(sqlite3*);
|
||||
/* Version 3.7.16 and later */
|
||||
int (*close_v2)(sqlite3*);
|
||||
const char *(*db_filename)(sqlite3*,const char*);
|
||||
int (*db_readonly)(sqlite3*,const char*);
|
||||
int (*db_release_memory)(sqlite3*);
|
||||
const char *(*errstr)(int);
|
||||
int (*stmt_busy)(sqlite3_stmt*);
|
||||
int (*stmt_readonly)(sqlite3_stmt*);
|
||||
int (*stricmp)(const char*,const char*);
|
||||
int (*uri_boolean)(const char*,const char*,int);
|
||||
sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);
|
||||
const char *(*uri_parameter)(const char*,const char*);
|
||||
char *(*xvsnprintf)(int,char*,const char*,va_list);
|
||||
int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
|
||||
/* Version 3.8.7 and later */
|
||||
int (*auto_extension)(void(*)(void));
|
||||
int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64,
|
||||
void(*)(void*));
|
||||
int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64,
|
||||
void(*)(void*),unsigned char);
|
||||
int (*cancel_auto_extension)(void(*)(void));
|
||||
int (*load_extension)(sqlite3*,const char*,const char*,char**);
|
||||
void *(*malloc64)(sqlite3_uint64);
|
||||
sqlite3_uint64 (*msize)(void*);
|
||||
void *(*realloc64)(void*,sqlite3_uint64);
|
||||
void (*reset_auto_extension)(void);
|
||||
void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64,
|
||||
void(*)(void*));
|
||||
void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64,
|
||||
void(*)(void*), unsigned char);
|
||||
int (*strglob)(const char*,const char*);
|
||||
/* Version 3.8.11 and later */
|
||||
sqlite3_value *(*value_dup)(const sqlite3_value*);
|
||||
void (*value_free)(sqlite3_value*);
|
||||
int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64);
|
||||
int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64);
|
||||
/* Version 3.9.0 and later */
|
||||
unsigned int (*value_subtype)(sqlite3_value*);
|
||||
void (*result_subtype)(sqlite3_context*,unsigned int);
|
||||
/* Version 3.10.0 and later */
|
||||
int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);
|
||||
int (*strlike)(const char*,const char*,unsigned int);
|
||||
int (*db_cacheflush)(sqlite3*);
|
||||
/* Version 3.12.0 and later */
|
||||
int (*system_errno)(sqlite3*);
|
||||
/* Version 3.14.0 and later */
|
||||
int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);
|
||||
char *(*expanded_sql)(sqlite3_stmt*);
|
||||
/* Version 3.18.0 and later */
|
||||
void (*set_last_insert_rowid)(sqlite3*,sqlite3_int64);
|
||||
/* Version 3.20.0 and later */
|
||||
int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,
|
||||
sqlite3_stmt**,const char**);
|
||||
int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,
|
||||
sqlite3_stmt**,const void**);
|
||||
int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*));
|
||||
void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*));
|
||||
void *(*value_pointer)(sqlite3_value*,const char*);
|
||||
int (*vtab_nochange)(sqlite3_context*);
|
||||
int (*value_nochange)(sqlite3_value*);
|
||||
const char *(*vtab_collation)(sqlite3_index_info*,int);
|
||||
/* Version 3.24.0 and later */
|
||||
int (*keyword_count)(void);
|
||||
int (*keyword_name)(int,const char**,int*);
|
||||
int (*keyword_check)(const char*,int);
|
||||
sqlite3_str *(*str_new)(sqlite3*);
|
||||
char *(*str_finish)(sqlite3_str*);
|
||||
void (*str_appendf)(sqlite3_str*, const char *zFormat, ...);
|
||||
void (*str_vappendf)(sqlite3_str*, const char *zFormat, va_list);
|
||||
void (*str_append)(sqlite3_str*, const char *zIn, int N);
|
||||
void (*str_appendall)(sqlite3_str*, const char *zIn);
|
||||
void (*str_appendchar)(sqlite3_str*, int N, char C);
|
||||
void (*str_reset)(sqlite3_str*);
|
||||
int (*str_errcode)(sqlite3_str*);
|
||||
int (*str_length)(sqlite3_str*);
|
||||
char *(*str_value)(sqlite3_str*);
|
||||
/* Version 3.25.0 and later */
|
||||
int (*create_window_function)(sqlite3*,const char*,int,int,void*,
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xFinal)(sqlite3_context*),
|
||||
void (*xValue)(sqlite3_context*),
|
||||
void (*xInv)(sqlite3_context*,int,sqlite3_value**),
|
||||
void(*xDestroy)(void*));
|
||||
/* Version 3.26.0 and later */
|
||||
const char *(*normalized_sql)(sqlite3_stmt*);
|
||||
/* Version 3.28.0 and later */
|
||||
int (*stmt_isexplain)(sqlite3_stmt*);
|
||||
int (*value_frombind)(sqlite3_value*);
|
||||
/* Version 3.30.0 and later */
|
||||
int (*drop_modules)(sqlite3*,const char**);
|
||||
/* Version 3.31.0 and later */
|
||||
sqlite3_int64 (*hard_heap_limit64)(sqlite3_int64);
|
||||
const char *(*uri_key)(const char*,int);
|
||||
const char *(*filename_database)(const char*);
|
||||
const char *(*filename_journal)(const char*);
|
||||
const char *(*filename_wal)(const char*);
|
||||
/* Version 3.32.0 and later */
|
||||
char *(*create_filename)(const char*,const char*,const char*,
|
||||
int,const char**);
|
||||
void (*free_filename)(char*);
|
||||
sqlite3_file *(*database_file_object)(const char*);
|
||||
/* Version 3.34.0 and later */
|
||||
int (*txn_state)(sqlite3*,const char*);
|
||||
};
|
||||
|
||||
/*
|
||||
** This is the function signature used for all extension entry points. It
|
||||
** is also defined in the file "loadext.c".
|
||||
*/
|
||||
typedef int (*sqlite3_loadext_entry)(
|
||||
sqlite3 *db, /* Handle to the database. */
|
||||
char **pzErrMsg, /* Used to set error string on failure. */
|
||||
const sqlite3_api_routines *pThunk /* Extension API function pointers. */
|
||||
);
|
||||
|
||||
/*
|
||||
** The following macros redefine the API routines so that they are
|
||||
** redirected through the global sqlite3_api structure.
|
||||
**
|
||||
** This header file is also used by the loadext.c source file
|
||||
** (part of the main SQLite library - not an extension) so that
|
||||
** it can get access to the sqlite3_api_routines structure
|
||||
** definition. But the main library does not want to redefine
|
||||
** the API. So the redefinition macros are only valid if the
|
||||
** SQLITE_CORE macros is undefined.
|
||||
*/
|
||||
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
||||
#define sqlite3_aggregate_context sqlite3_api->aggregate_context
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_aggregate_count sqlite3_api->aggregate_count
|
||||
#endif
|
||||
#define sqlite3_bind_blob sqlite3_api->bind_blob
|
||||
#define sqlite3_bind_double sqlite3_api->bind_double
|
||||
#define sqlite3_bind_int sqlite3_api->bind_int
|
||||
#define sqlite3_bind_int64 sqlite3_api->bind_int64
|
||||
#define sqlite3_bind_null sqlite3_api->bind_null
|
||||
#define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count
|
||||
#define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index
|
||||
#define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name
|
||||
#define sqlite3_bind_text sqlite3_api->bind_text
|
||||
#define sqlite3_bind_text16 sqlite3_api->bind_text16
|
||||
#define sqlite3_bind_value sqlite3_api->bind_value
|
||||
#define sqlite3_busy_handler sqlite3_api->busy_handler
|
||||
#define sqlite3_busy_timeout sqlite3_api->busy_timeout
|
||||
#define sqlite3_changes sqlite3_api->changes
|
||||
#define sqlite3_close sqlite3_api->close
|
||||
#define sqlite3_collation_needed sqlite3_api->collation_needed
|
||||
#define sqlite3_collation_needed16 sqlite3_api->collation_needed16
|
||||
#define sqlite3_column_blob sqlite3_api->column_blob
|
||||
#define sqlite3_column_bytes sqlite3_api->column_bytes
|
||||
#define sqlite3_column_bytes16 sqlite3_api->column_bytes16
|
||||
#define sqlite3_column_count sqlite3_api->column_count
|
||||
#define sqlite3_column_database_name sqlite3_api->column_database_name
|
||||
#define sqlite3_column_database_name16 sqlite3_api->column_database_name16
|
||||
#define sqlite3_column_decltype sqlite3_api->column_decltype
|
||||
#define sqlite3_column_decltype16 sqlite3_api->column_decltype16
|
||||
#define sqlite3_column_double sqlite3_api->column_double
|
||||
#define sqlite3_column_int sqlite3_api->column_int
|
||||
#define sqlite3_column_int64 sqlite3_api->column_int64
|
||||
#define sqlite3_column_name sqlite3_api->column_name
|
||||
#define sqlite3_column_name16 sqlite3_api->column_name16
|
||||
#define sqlite3_column_origin_name sqlite3_api->column_origin_name
|
||||
#define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16
|
||||
#define sqlite3_column_table_name sqlite3_api->column_table_name
|
||||
#define sqlite3_column_table_name16 sqlite3_api->column_table_name16
|
||||
#define sqlite3_column_text sqlite3_api->column_text
|
||||
#define sqlite3_column_text16 sqlite3_api->column_text16
|
||||
#define sqlite3_column_type sqlite3_api->column_type
|
||||
#define sqlite3_column_value sqlite3_api->column_value
|
||||
#define sqlite3_commit_hook sqlite3_api->commit_hook
|
||||
#define sqlite3_complete sqlite3_api->complete
|
||||
#define sqlite3_complete16 sqlite3_api->complete16
|
||||
#define sqlite3_create_collation sqlite3_api->create_collation
|
||||
#define sqlite3_create_collation16 sqlite3_api->create_collation16
|
||||
#define sqlite3_create_function sqlite3_api->create_function
|
||||
#define sqlite3_create_function16 sqlite3_api->create_function16
|
||||
#define sqlite3_create_module sqlite3_api->create_module
|
||||
#define sqlite3_create_module_v2 sqlite3_api->create_module_v2
|
||||
#define sqlite3_data_count sqlite3_api->data_count
|
||||
#define sqlite3_db_handle sqlite3_api->db_handle
|
||||
#define sqlite3_declare_vtab sqlite3_api->declare_vtab
|
||||
#define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache
|
||||
#define sqlite3_errcode sqlite3_api->errcode
|
||||
#define sqlite3_errmsg sqlite3_api->errmsg
|
||||
#define sqlite3_errmsg16 sqlite3_api->errmsg16
|
||||
#define sqlite3_exec sqlite3_api->exec
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_expired sqlite3_api->expired
|
||||
#endif
|
||||
#define sqlite3_finalize sqlite3_api->finalize
|
||||
#define sqlite3_free sqlite3_api->free
|
||||
#define sqlite3_free_table sqlite3_api->free_table
|
||||
#define sqlite3_get_autocommit sqlite3_api->get_autocommit
|
||||
#define sqlite3_get_auxdata sqlite3_api->get_auxdata
|
||||
#define sqlite3_get_table sqlite3_api->get_table
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_global_recover sqlite3_api->global_recover
|
||||
#endif
|
||||
#define sqlite3_interrupt sqlite3_api->interruptx
|
||||
#define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid
|
||||
#define sqlite3_libversion sqlite3_api->libversion
|
||||
#define sqlite3_libversion_number sqlite3_api->libversion_number
|
||||
#define sqlite3_malloc sqlite3_api->malloc
|
||||
#define sqlite3_mprintf sqlite3_api->mprintf
|
||||
#define sqlite3_open sqlite3_api->open
|
||||
#define sqlite3_open16 sqlite3_api->open16
|
||||
#define sqlite3_prepare sqlite3_api->prepare
|
||||
#define sqlite3_prepare16 sqlite3_api->prepare16
|
||||
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
|
||||
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
|
||||
#define sqlite3_profile sqlite3_api->profile
|
||||
#define sqlite3_progress_handler sqlite3_api->progress_handler
|
||||
#define sqlite3_realloc sqlite3_api->realloc
|
||||
#define sqlite3_reset sqlite3_api->reset
|
||||
#define sqlite3_result_blob sqlite3_api->result_blob
|
||||
#define sqlite3_result_double sqlite3_api->result_double
|
||||
#define sqlite3_result_error sqlite3_api->result_error
|
||||
#define sqlite3_result_error16 sqlite3_api->result_error16
|
||||
#define sqlite3_result_int sqlite3_api->result_int
|
||||
#define sqlite3_result_int64 sqlite3_api->result_int64
|
||||
#define sqlite3_result_null sqlite3_api->result_null
|
||||
#define sqlite3_result_text sqlite3_api->result_text
|
||||
#define sqlite3_result_text16 sqlite3_api->result_text16
|
||||
#define sqlite3_result_text16be sqlite3_api->result_text16be
|
||||
#define sqlite3_result_text16le sqlite3_api->result_text16le
|
||||
#define sqlite3_result_value sqlite3_api->result_value
|
||||
#define sqlite3_rollback_hook sqlite3_api->rollback_hook
|
||||
#define sqlite3_set_authorizer sqlite3_api->set_authorizer
|
||||
#define sqlite3_set_auxdata sqlite3_api->set_auxdata
|
||||
#define sqlite3_snprintf sqlite3_api->xsnprintf
|
||||
#define sqlite3_step sqlite3_api->step
|
||||
#define sqlite3_table_column_metadata sqlite3_api->table_column_metadata
|
||||
#define sqlite3_thread_cleanup sqlite3_api->thread_cleanup
|
||||
#define sqlite3_total_changes sqlite3_api->total_changes
|
||||
#define sqlite3_trace sqlite3_api->trace
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_transfer_bindings sqlite3_api->transfer_bindings
|
||||
#endif
|
||||
#define sqlite3_update_hook sqlite3_api->update_hook
|
||||
#define sqlite3_user_data sqlite3_api->user_data
|
||||
#define sqlite3_value_blob sqlite3_api->value_blob
|
||||
#define sqlite3_value_bytes sqlite3_api->value_bytes
|
||||
#define sqlite3_value_bytes16 sqlite3_api->value_bytes16
|
||||
#define sqlite3_value_double sqlite3_api->value_double
|
||||
#define sqlite3_value_int sqlite3_api->value_int
|
||||
#define sqlite3_value_int64 sqlite3_api->value_int64
|
||||
#define sqlite3_value_numeric_type sqlite3_api->value_numeric_type
|
||||
#define sqlite3_value_text sqlite3_api->value_text
|
||||
#define sqlite3_value_text16 sqlite3_api->value_text16
|
||||
#define sqlite3_value_text16be sqlite3_api->value_text16be
|
||||
#define sqlite3_value_text16le sqlite3_api->value_text16le
|
||||
#define sqlite3_value_type sqlite3_api->value_type
|
||||
#define sqlite3_vmprintf sqlite3_api->vmprintf
|
||||
#define sqlite3_vsnprintf sqlite3_api->xvsnprintf
|
||||
#define sqlite3_overload_function sqlite3_api->overload_function
|
||||
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
|
||||
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
|
||||
#define sqlite3_clear_bindings sqlite3_api->clear_bindings
|
||||
#define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob
|
||||
#define sqlite3_blob_bytes sqlite3_api->blob_bytes
|
||||
#define sqlite3_blob_close sqlite3_api->blob_close
|
||||
#define sqlite3_blob_open sqlite3_api->blob_open
|
||||
#define sqlite3_blob_read sqlite3_api->blob_read
|
||||
#define sqlite3_blob_write sqlite3_api->blob_write
|
||||
#define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2
|
||||
#define sqlite3_file_control sqlite3_api->file_control
|
||||
#define sqlite3_memory_highwater sqlite3_api->memory_highwater
|
||||
#define sqlite3_memory_used sqlite3_api->memory_used
|
||||
#define sqlite3_mutex_alloc sqlite3_api->mutex_alloc
|
||||
#define sqlite3_mutex_enter sqlite3_api->mutex_enter
|
||||
#define sqlite3_mutex_free sqlite3_api->mutex_free
|
||||
#define sqlite3_mutex_leave sqlite3_api->mutex_leave
|
||||
#define sqlite3_mutex_try sqlite3_api->mutex_try
|
||||
#define sqlite3_open_v2 sqlite3_api->open_v2
|
||||
#define sqlite3_release_memory sqlite3_api->release_memory
|
||||
#define sqlite3_result_error_nomem sqlite3_api->result_error_nomem
|
||||
#define sqlite3_result_error_toobig sqlite3_api->result_error_toobig
|
||||
#define sqlite3_sleep sqlite3_api->sleep
|
||||
#define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit
|
||||
#define sqlite3_vfs_find sqlite3_api->vfs_find
|
||||
#define sqlite3_vfs_register sqlite3_api->vfs_register
|
||||
#define sqlite3_vfs_unregister sqlite3_api->vfs_unregister
|
||||
#define sqlite3_threadsafe sqlite3_api->xthreadsafe
|
||||
#define sqlite3_result_zeroblob sqlite3_api->result_zeroblob
|
||||
#define sqlite3_result_error_code sqlite3_api->result_error_code
|
||||
#define sqlite3_test_control sqlite3_api->test_control
|
||||
#define sqlite3_randomness sqlite3_api->randomness
|
||||
#define sqlite3_context_db_handle sqlite3_api->context_db_handle
|
||||
#define sqlite3_extended_result_codes sqlite3_api->extended_result_codes
|
||||
#define sqlite3_limit sqlite3_api->limit
|
||||
#define sqlite3_next_stmt sqlite3_api->next_stmt
|
||||
#define sqlite3_sql sqlite3_api->sql
|
||||
#define sqlite3_status sqlite3_api->status
|
||||
#define sqlite3_backup_finish sqlite3_api->backup_finish
|
||||
#define sqlite3_backup_init sqlite3_api->backup_init
|
||||
#define sqlite3_backup_pagecount sqlite3_api->backup_pagecount
|
||||
#define sqlite3_backup_remaining sqlite3_api->backup_remaining
|
||||
#define sqlite3_backup_step sqlite3_api->backup_step
|
||||
#define sqlite3_compileoption_get sqlite3_api->compileoption_get
|
||||
#define sqlite3_compileoption_used sqlite3_api->compileoption_used
|
||||
#define sqlite3_create_function_v2 sqlite3_api->create_function_v2
|
||||
#define sqlite3_db_config sqlite3_api->db_config
|
||||
#define sqlite3_db_mutex sqlite3_api->db_mutex
|
||||
#define sqlite3_db_status sqlite3_api->db_status
|
||||
#define sqlite3_extended_errcode sqlite3_api->extended_errcode
|
||||
#define sqlite3_log sqlite3_api->log
|
||||
#define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64
|
||||
#define sqlite3_sourceid sqlite3_api->sourceid
|
||||
#define sqlite3_stmt_status sqlite3_api->stmt_status
|
||||
#define sqlite3_strnicmp sqlite3_api->strnicmp
|
||||
#define sqlite3_unlock_notify sqlite3_api->unlock_notify
|
||||
#define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint
|
||||
#define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint
|
||||
#define sqlite3_wal_hook sqlite3_api->wal_hook
|
||||
#define sqlite3_blob_reopen sqlite3_api->blob_reopen
|
||||
#define sqlite3_vtab_config sqlite3_api->vtab_config
|
||||
#define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict
|
||||
/* Version 3.7.16 and later */
|
||||
#define sqlite3_close_v2 sqlite3_api->close_v2
|
||||
#define sqlite3_db_filename sqlite3_api->db_filename
|
||||
#define sqlite3_db_readonly sqlite3_api->db_readonly
|
||||
#define sqlite3_db_release_memory sqlite3_api->db_release_memory
|
||||
#define sqlite3_errstr sqlite3_api->errstr
|
||||
#define sqlite3_stmt_busy sqlite3_api->stmt_busy
|
||||
#define sqlite3_stmt_readonly sqlite3_api->stmt_readonly
|
||||
#define sqlite3_stricmp sqlite3_api->stricmp
|
||||
#define sqlite3_uri_boolean sqlite3_api->uri_boolean
|
||||
#define sqlite3_uri_int64 sqlite3_api->uri_int64
|
||||
#define sqlite3_uri_parameter sqlite3_api->uri_parameter
|
||||
#define sqlite3_uri_vsnprintf sqlite3_api->xvsnprintf
|
||||
#define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2
|
||||
/* Version 3.8.7 and later */
|
||||
#define sqlite3_auto_extension sqlite3_api->auto_extension
|
||||
#define sqlite3_bind_blob64 sqlite3_api->bind_blob64
|
||||
#define sqlite3_bind_text64 sqlite3_api->bind_text64
|
||||
#define sqlite3_cancel_auto_extension sqlite3_api->cancel_auto_extension
|
||||
#define sqlite3_load_extension sqlite3_api->load_extension
|
||||
#define sqlite3_malloc64 sqlite3_api->malloc64
|
||||
#define sqlite3_msize sqlite3_api->msize
|
||||
#define sqlite3_realloc64 sqlite3_api->realloc64
|
||||
#define sqlite3_reset_auto_extension sqlite3_api->reset_auto_extension
|
||||
#define sqlite3_result_blob64 sqlite3_api->result_blob64
|
||||
#define sqlite3_result_text64 sqlite3_api->result_text64
|
||||
#define sqlite3_strglob sqlite3_api->strglob
|
||||
/* Version 3.8.11 and later */
|
||||
#define sqlite3_value_dup sqlite3_api->value_dup
|
||||
#define sqlite3_value_free sqlite3_api->value_free
|
||||
#define sqlite3_result_zeroblob64 sqlite3_api->result_zeroblob64
|
||||
#define sqlite3_bind_zeroblob64 sqlite3_api->bind_zeroblob64
|
||||
/* Version 3.9.0 and later */
|
||||
#define sqlite3_value_subtype sqlite3_api->value_subtype
|
||||
#define sqlite3_result_subtype sqlite3_api->result_subtype
|
||||
/* Version 3.10.0 and later */
|
||||
#define sqlite3_status64 sqlite3_api->status64
|
||||
#define sqlite3_strlike sqlite3_api->strlike
|
||||
#define sqlite3_db_cacheflush sqlite3_api->db_cacheflush
|
||||
/* Version 3.12.0 and later */
|
||||
#define sqlite3_system_errno sqlite3_api->system_errno
|
||||
/* Version 3.14.0 and later */
|
||||
#define sqlite3_trace_v2 sqlite3_api->trace_v2
|
||||
#define sqlite3_expanded_sql sqlite3_api->expanded_sql
|
||||
/* Version 3.18.0 and later */
|
||||
#define sqlite3_set_last_insert_rowid sqlite3_api->set_last_insert_rowid
|
||||
/* Version 3.20.0 and later */
|
||||
#define sqlite3_prepare_v3 sqlite3_api->prepare_v3
|
||||
#define sqlite3_prepare16_v3 sqlite3_api->prepare16_v3
|
||||
#define sqlite3_bind_pointer sqlite3_api->bind_pointer
|
||||
#define sqlite3_result_pointer sqlite3_api->result_pointer
|
||||
#define sqlite3_value_pointer sqlite3_api->value_pointer
|
||||
/* Version 3.22.0 and later */
|
||||
#define sqlite3_vtab_nochange sqlite3_api->vtab_nochange
|
||||
#define sqlite3_value_nochange sqlite3_api->value_nochange
|
||||
#define sqlite3_vtab_collation sqlite3_api->vtab_collation
|
||||
/* Version 3.24.0 and later */
|
||||
#define sqlite3_keyword_count sqlite3_api->keyword_count
|
||||
#define sqlite3_keyword_name sqlite3_api->keyword_name
|
||||
#define sqlite3_keyword_check sqlite3_api->keyword_check
|
||||
#define sqlite3_str_new sqlite3_api->str_new
|
||||
#define sqlite3_str_finish sqlite3_api->str_finish
|
||||
#define sqlite3_str_appendf sqlite3_api->str_appendf
|
||||
#define sqlite3_str_vappendf sqlite3_api->str_vappendf
|
||||
#define sqlite3_str_append sqlite3_api->str_append
|
||||
#define sqlite3_str_appendall sqlite3_api->str_appendall
|
||||
#define sqlite3_str_appendchar sqlite3_api->str_appendchar
|
||||
#define sqlite3_str_reset sqlite3_api->str_reset
|
||||
#define sqlite3_str_errcode sqlite3_api->str_errcode
|
||||
#define sqlite3_str_length sqlite3_api->str_length
|
||||
#define sqlite3_str_value sqlite3_api->str_value
|
||||
/* Version 3.25.0 and later */
|
||||
#define sqlite3_create_window_function sqlite3_api->create_window_function
|
||||
/* Version 3.26.0 and later */
|
||||
#define sqlite3_normalized_sql sqlite3_api->normalized_sql
|
||||
/* Version 3.28.0 and later */
|
||||
#define sqlite3_stmt_isexplain sqlite3_api->stmt_isexplain
|
||||
#define sqlite3_value_frombind sqlite3_api->value_frombind
|
||||
/* Version 3.30.0 and later */
|
||||
#define sqlite3_drop_modules sqlite3_api->drop_modules
|
||||
/* Version 3.31.0 and later */
|
||||
#define sqlite3_hard_heap_limit64 sqlite3_api->hard_heap_limit64
|
||||
#define sqlite3_uri_key sqlite3_api->uri_key
|
||||
#define sqlite3_filename_database sqlite3_api->filename_database
|
||||
#define sqlite3_filename_journal sqlite3_api->filename_journal
|
||||
#define sqlite3_filename_wal sqlite3_api->filename_wal
|
||||
/* Version 3.32.0 and later */
|
||||
#define sqlite3_create_filename sqlite3_api->create_filename
|
||||
#define sqlite3_free_filename sqlite3_api->free_filename
|
||||
#define sqlite3_database_file_object sqlite3_api->database_file_object
|
||||
/* Version 3.34.0 and later */
|
||||
#define sqlite3_txn_state sqlite3_api->txn_state
|
||||
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
|
||||
|
||||
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
||||
/* This case when the file really is being compiled as a loadable
|
||||
** extension */
|
||||
# define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0;
|
||||
# define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v;
|
||||
# define SQLITE_EXTENSION_INIT3 \
|
||||
extern const sqlite3_api_routines *sqlite3_api;
|
||||
#else
|
||||
/* This case when the file is being statically linked into the
|
||||
** application */
|
||||
# define SQLITE_EXTENSION_INIT1 /*no-op*/
|
||||
# define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
|
||||
# define SQLITE_EXTENSION_INIT3 /*no-op*/
|
||||
#endif
|
||||
|
||||
#endif /* SQLITE3EXT_H */
|
4
thirdparty/sqlite/version.md
vendored
Normal file
4
thirdparty/sqlite/version.md
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
SQLite 2020-12-01 (3.34.0)
|
||||
|
||||
See https://sqlite.org/changes.html
|
||||
|
@ -24,6 +24,8 @@ static const float QUANTIZED_SDF_8_BITS_SCALE_INV = 1.f / 0.1f;
|
||||
static const float QUANTIZED_SDF_16_BITS_SCALE = 0.002f;
|
||||
static const float QUANTIZED_SDF_16_BITS_SCALE_INV = 1.f / 0.002f;
|
||||
|
||||
static const unsigned int DEFAULT_BLOCK_SIZE_PO2 = 4;
|
||||
|
||||
} // namespace VoxelConstants
|
||||
|
||||
#endif // VOXEL_CONSTANTS_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user