This commit is contained in:
Marcel Admiraal 2021-11-10 22:44:27 -03:00 committed by GitHub
commit c91b6eea8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 245958 additions and 0 deletions

View file

@ -393,6 +393,12 @@ Comment: SPIRV-Reflect
Copyright: 2017-2018, Google Inc.
License: Apache-2.0
Files: ./thirdparty/sqlite/spmemvfs.c
./thirdparty/sqlite/spmemvfs.h
Comment: A memory vfs implementation for SQLite
Copyright: Copyright 2009, Stephen Liu
License: BSD-2-clause
Files: ./thirdparty/squish/
Comment: libSquish
Copyright: 2006, Simon Brown

View file

@ -177,6 +177,7 @@ opts.Add(BoolVariable("builtin_pcre2", "Use the built-in PCRE2 library", True))
opts.Add(BoolVariable("builtin_pcre2_with_jit", "Use JIT compiler for the built-in PCRE2 library", True))
opts.Add(BoolVariable("builtin_recast", "Use the built-in Recast library", True))
opts.Add(BoolVariable("builtin_rvo2", "Use the built-in RVO2 library", True))
opts.Add(BoolVariable("builtin_sqlite", "Use the built-in SQLite library", True))
opts.Add(BoolVariable("builtin_squish", "Use the built-in squish library", True))
opts.Add(BoolVariable("builtin_xatlas", "Use the built-in xatlas library", True))
opts.Add(BoolVariable("builtin_zlib", "Use the built-in zlib library", True))

19
modules/sqlite/SCsub Normal file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env python
Import("env")
Import("env_modules")
env_sqlite = env_modules.Clone()
if env["builtin_sqlite"]:
env_sqlite.Prepend(CPPPATH=["#thirdparty_dir"])
thirdparty_dir = "#thirdparty/sqlite/"
thirdparty_sources = ["spmemvfs.c", "sqlite3.c"]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env_thirdparty = env_sqlite.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)
# Godot source files
env_sqlite.add_source_files(env.modules_sources, "*.cpp")

19
modules/sqlite/config.py Normal file
View file

@ -0,0 +1,19 @@
# config.py
def can_build(env, platform):
return True
def configure(env):
pass
def get_doc_classes():
return [
"SQLite",
]
def get_doc_path():
return "doc_classes"

View file

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SQLite" inherits="Reference" version="4.0">
<brief_description>
Wrapper class for SQLite databases.
</brief_description>
<description>
A wrapper class that lets you perform SQL statements on an SQLite database file.
For queries that involve arbitrary user input, you should use methods that end in [code]*_with_args[/code], as these protect against SQL injection.
</description>
<tutorials>
</tutorials>
<methods>
<method name="close">
<return type="void">
</return>
<description>
Closes the database handle.
</description>
</method>
<method name="fetch_array">
<return type="Array">
</return>
<argument index="0" name="statement" type="String">
</argument>
<description>
Returns the result of [code]statement[/code] as an [Array] of rows.
Each row is a [Dictionary], and each column can be accessed with either its name or its column position.
</description>
</method>
<method name="fetch_array_with_args">
<return type="Array">
</return>
<argument index="0" name="statement" type="String">
</argument>
<argument index="1" name="args" type="Array">
</argument>
<description>
Returns the result of [code]statement[/code] as an [Array] of rows, substituting each [code]?[/code] with [code]args[/code].
Each row is a [Dictionary], and each column can be accessed with either its name or its column position.
</description>
</method>
<method name="fetch_assoc">
<return type="Array">
</return>
<argument index="0" name="statement" type="String">
</argument>
<description>
Returns the result of [code]statement[/code] as an [Array] of rows.
Each row is a [Dictionary], and the keys are the names of the columns.
</description>
</method>
<method name="fetch_assoc_with_args">
<return type="Array">
</return>
<argument index="0" name="statement" type="String">
</argument>
<argument index="1" name="args" type="Array">
</argument>
<description>
Returns the result of [code]statement[/code] as an [Array] of rows, substituting each [code]?[/code] with [code]args[/code].
Each row is a [Dictionary], and the keys are the names of the columns.
</description>
</method>
<method name="open">
<return type="bool">
</return>
<argument index="0" name="path" type="String">
</argument>
<description>
Opens the database file at the given path. Returns [code]true[/code] if the database was successfully opened, [code]false[/code] otherwise.
If the path starts with "res://", it will use [method open_buffered] implicitly.
</description>
</method>
<method name="open_buffered">
<return type="bool">
</return>
<argument index="0" name="path" type="String">
</argument>
<argument index="1" name="buffers" type="PackedByteArray">
</argument>
<argument index="2" name="size" type="int">
</argument>
<description>
Opens a temporary database with the data in [code]buffer[/code]. Used for opening databases stored in res:// or compressed databases. Returns [code]true[/code] if the database was opened successfully.
Can be written to, but the changes are NOT saved!
</description>
</method>
<method name="query">
<return type="bool">
</return>
<argument index="0" name="statement" type="String">
</argument>
<description>
Queries the database with the given SQL statement. Returns [code]true[/code] if no errors occurred.
</description>
</method>
<method name="query_with_args">
<return type="bool">
</return>
<argument index="0" name="statement" type="String">
</argument>
<argument index="1" name="args" type="Array">
</argument>
<description>
Queries the database with the given SQL statement, replacing any [code]?[/code] with arguments supplied by [code]args[/code]. Returns [code]true[/code] if no errors occurred.
</description>
</method>
</methods>
<constants>
</constants>
</class>

View file

@ -0,0 +1,40 @@
/*************************************************************************/
/* register_types.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_types.h"
#include "sqlite.h"
void register_sqlite_types() {
ClassDB::register_class<SQLite>();
}
void unregister_sqlite_types() {
}

View file

@ -0,0 +1,32 @@
/*************************************************************************/
/* register_types.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
void register_sqlite_types();
void unregister_sqlite_types();

349
modules/sqlite/sqlite.cpp Normal file
View file

@ -0,0 +1,349 @@
/*************************************************************************/
/* sqlite.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
// Original author: @Khairul Hidayat
// Copyright (c) 2017-2019
#include "sqlite.h"
#include "core/core_bind.h"
#include "core/os/os.h"
#include "editor/project_settings_editor.h"
SQLite::SQLite() {
db = nullptr;
memory_read = false;
}
/*
Open a database file.
If this is running outside of the editor, databases under res:// are assumed to be packed.
@param path The database resource path.
@return status
*/
bool SQLite::open(String path) {
if (!path.strip_edges().length())
return false;
if (!Engine::get_singleton()->is_editor_hint() && path.begins_with("res://")) {
Ref<_File> dbfile;
dbfile.instance();
if (dbfile->open(path, _File::READ) != Error::OK) {
print_error("Cannot open packed database!");
return false;
}
int64_t size = dbfile->get_len();
PackedByteArray buffer = dbfile->get_buffer(size);
return open_buffered(path, buffer, size);
}
String real_path = ProjectSettings::get_singleton()->globalize_path(path.strip_edges());
int result = sqlite3_open(real_path.utf8().get_data(), &db);
if (result != SQLITE_OK) {
print_error("Cannot open database!");
return false;
}
return true;
}
/*
Open the database and initialize memory buffer.
@param name Name of the database.
@param buffers The database buffer.
@param size Size of the database;
@return status
*/
bool SQLite::open_buffered(String name, PackedByteArray buffers, int64_t size) {
if (!name.strip_edges().length()) {
return false;
}
if (!buffers.size() || !size) {
return false;
}
spmembuffer_t *p_mem = (spmembuffer_t *)calloc(1, sizeof(spmembuffer_t));
p_mem->total = p_mem->used = size;
p_mem->data = (char *)malloc(size + 1);
memcpy(p_mem->data, buffers.ptr(), size);
p_mem->data[size] = '\0';
//
spmemvfs_env_init();
int err = spmemvfs_open_db(&p_db, name.utf8().get_data(), p_mem);
if (err != SQLITE_OK || p_db.mem != p_mem) {
print_error("Cannot open buffered database!");
return false;
}
memory_read = true;
return true;
}
void SQLite::close() {
if (db) {
// Cannot close database!
if (sqlite3_close_v2(db) != SQLITE_OK) {
print_error("Cannot close database!");
} else {
db = nullptr;
}
}
if (memory_read) {
// Close virtual filesystem database
spmemvfs_close_db(&p_db);
spmemvfs_env_fini();
memory_read = false;
}
}
sqlite3_stmt *SQLite::prepare(const char *query) {
// Get database pointer
sqlite3 *dbs = get_handler();
if (!dbs) {
print_error("Cannot prepare query! Database is not opened.");
return nullptr;
}
// Prepare the statement
sqlite3_stmt *stmt;
int result = sqlite3_prepare_v2(dbs, query, -1, &stmt, nullptr);
// Cannot prepare query!
if (result != SQLITE_OK) {
print_error("SQL Error: " + String(sqlite3_errmsg(dbs)));
return nullptr;
}
return stmt;
}
bool SQLite::bind_args(sqlite3_stmt *stmt, Array args) {
// Check parameter count
int param_count = sqlite3_bind_parameter_count(stmt);
if (param_count != args.size()) {
print_error("Query failed; expected " + itos(param_count) + " arguments, got " + itos(args.size()));
return false;
}
/**
* SQLite data types:
* - NULL
* - INTEGER (signed, max 8 bytes)
* - REAL (stored as a double-precision float)
* - TEXT (stored in database encoding of UTF-8, UTF-16BE or UTF-16LE)
* - BLOB (1:1 storage)
*/
for (int i = 0; i < param_count; i++) {
int retcode;
switch (args[i].get_type()) {
case Variant::Type::NIL:
retcode = sqlite3_bind_null(stmt, i + 1);
break;
case Variant::Type::BOOL:
case Variant::Type::INT:
retcode = sqlite3_bind_int(stmt, i + 1, (int)args[i]);
break;
case Variant::Type::FLOAT:
retcode = sqlite3_bind_double(stmt, i + 1, (double)args[i]);
break;
case Variant::Type::STRING:
retcode = sqlite3_bind_text(stmt, i + 1, String(args[i]).utf8().get_data(), -1, SQLITE_TRANSIENT);
break;
case Variant::Type::PACKED_BYTE_ARRAY:
retcode = sqlite3_bind_blob(stmt, i + 1, PackedByteArray(args[i]).ptr(), PackedByteArray(args[i]).size(), SQLITE_TRANSIENT);
break;
default:
print_error("SQLite was passed unhandled Variant with TYPE_* enum " + itos(args[i].get_type()) + ". Please serialize your object into a String or a PoolByteArray.\n");
return false;
}
if (retcode != SQLITE_OK) {
print_error("Query failed, an error occured while binding argument" + itos(i + 1) + " of " + itos(args.size()) + " (SQLite errcode " + itos(retcode) + ")");
return false;
}
}
return true;
}
bool SQLite::query_with_args(String query, Array args) {
sqlite3_stmt *stmt = prepare(query.utf8().get_data());
// Failed to prepare the query
if (!stmt) {
return false;
}
// Error occurred during argument binding
if (!bind_args(stmt, args)) {
sqlite3_finalize(stmt);
return false;
}
// Evaluate the sql query
sqlite3_step(stmt);
sqlite3_finalize(stmt);
return true;
}
bool SQLite::query(String query) {
return this->query_with_args(query, Array());
}
Array SQLite::fetch_rows(String statement, Array args, int result_type) {
Array result;
// Empty statement
if (!statement.strip_edges().length()) {
return result;
}
// Cannot prepare query
sqlite3_stmt *stmt = prepare(statement.strip_edges().utf8().get_data());
if (!stmt) {
return result;
}
// Bind arguments
if (!bind_args(stmt, args)) {
sqlite3_finalize(stmt);
return result;
}
// Fetch rows
while (sqlite3_step(stmt) == SQLITE_ROW) {
// Do a step
result.append(parse_row(stmt, result_type));
}
// Delete prepared statement
sqlite3_finalize(stmt);
// Return the result
return result;
}
Dictionary SQLite::parse_row(sqlite3_stmt *stmt, int result_type) {
Dictionary result;
// Get column count
int col_count = sqlite3_column_count(stmt);
// Fetch all column
for (int i = 0; i < col_count; i++) {
// Key name
const char *col_name = sqlite3_column_name(stmt, i);
String key = String(col_name);
// Value
int col_type = sqlite3_column_type(stmt, i);
Variant value;
// Get column value
switch (col_type) {
case SQLITE_INTEGER:
value = Variant(sqlite3_column_int(stmt, i));
break;
case SQLITE_FLOAT:
value = Variant(sqlite3_column_double(stmt, i));
break;
case SQLITE_TEXT: {
int size = sqlite3_column_bytes(stmt, i);
String str = String::utf8((const char *)sqlite3_column_text(stmt, i), size);
value = Variant(str);
break;
}
case SQLITE_BLOB: {
PackedByteArray arr;
int size = sqlite3_column_bytes(stmt, i);
arr.resize(size);
memcpy((void *)arr.ptr(), sqlite3_column_blob(stmt, i), size);
value = Variant(arr);
break;
}
default:
break;
}
// Set dictionary value
if (result_type == RESULT_NUM)
result[i] = value;
else if (result_type == RESULT_ASSOC)
result[key] = value;
else {
result[i] = value;
result[key] = value;
}
}
return result;
}
Array SQLite::fetch_array(String query) {
return fetch_rows(query, Array(), RESULT_BOTH);
}
Array SQLite::fetch_array_with_args(String query, Array args) {
return fetch_rows(query, args, RESULT_BOTH);
}
Array SQLite::fetch_assoc(String query) {
return fetch_rows(query, Array(), RESULT_ASSOC);
}
Array SQLite::fetch_assoc_with_args(String query, Array args) {
return fetch_rows(query, args, RESULT_ASSOC);
}
SQLite::~SQLite() {
// Close database
close();
}
void SQLite::_bind_methods() {
ClassDB::bind_method(D_METHOD("open", "path"), &SQLite::open);
ClassDB::bind_method(D_METHOD("open_buffered", "path", "buffers", "size"), &SQLite::open_buffered);
ClassDB::bind_method(D_METHOD("query", "statement"), &SQLite::query);
ClassDB::bind_method(D_METHOD("query_with_args", "statement", "args"), &SQLite::query_with_args);
ClassDB::bind_method(D_METHOD("close"), &SQLite::close);
ClassDB::bind_method(D_METHOD("fetch_array", "statement"), &SQLite::fetch_array);
ClassDB::bind_method(D_METHOD("fetch_array_with_args", "statement", "args"), &SQLite::fetch_array_with_args);
ClassDB::bind_method(D_METHOD("fetch_assoc", "statement"), &SQLite::fetch_assoc);
ClassDB::bind_method(D_METHOD("fetch_assoc_with_args", "statement", "args"), &SQLite::fetch_assoc_with_args);
}

88
modules/sqlite/sqlite.h Normal file
View file

@ -0,0 +1,88 @@
/*************************************************************************/
/* sqlite.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
// Original author: @Khairul Hidayat
// Copyright (c) 2017-2019
#ifndef SQLITE_H
#define SQLITE_H
#include "core/object/reference.h"
// SQLite3
#include "thirdparty/sqlite/spmemvfs.h"
#include "thirdparty/sqlite/sqlite3.h"
class SQLite : public Reference {
GDCLASS(SQLite, Reference);
private:
// sqlite handler
sqlite3 *db;
// vfs
spmemvfs_db_t p_db;
bool memory_read;
sqlite3_stmt *prepare(const char *statement);
Array fetch_rows(String query, Array args, int result_type = RESULT_BOTH);
Dictionary parse_row(sqlite3_stmt *stmt, int result_type);
sqlite3 *get_handler() { return (memory_read ? p_db.handle : db); }
bool bind_args(sqlite3_stmt *stmt, Array args);
protected:
static void _bind_methods();
public:
enum {
RESULT_BOTH = 0,
RESULT_NUM,
RESULT_ASSOC
};
// constructor
SQLite();
~SQLite();
void _init() {}
// methods
bool open(String path);
bool open_buffered(String name, PackedByteArray buffers, int64_t size);
void close();
bool query(String statement);
bool query_with_args(String statement, Array args);
Array fetch_array(String statement);
Array fetch_array_with_args(String statement, Array args);
Array fetch_assoc(String statement);
Array fetch_assoc_with_args(String statement, Array args);
};
#endif // SQLITE_H

24
thirdparty/README.md vendored
View file

@ -581,6 +581,30 @@ They can be reapplied using the patch included in the `patches`
folder.
## sqlite
### sqlite
- Upstream: https://sqlite.org/download.html
- Version: 3.31.1.
- License: Public Domain
Files extracted from upstream source:
- sqlite3.h
- sqlite3ext.h
- sqlite3.c
### spmemvfs
- Upstream: https://github.com/spsoft/spmemvfs
- Version: git (9921e0b, 2016)
- License: BSD 2-Clause
Files extracted from upstream source:
- spmemvfs.h
- spmemvfs.c
## squish
- Upstream: https://sourceforge.net/projects/libsquish

549
thirdparty/sqlite/spmemvfs.c vendored Normal file
View file

@ -0,0 +1,549 @@
/*
* BSD 2-Clause License
*
* Copyright 2009 Stephen Liu
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma warning(disable: 4996) // Fixes "unsafe" warnings for strdup and strncpy
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "spmemvfs.h"
#include "sqlite3.h"
/* Useful macros used in several places */
#define SPMEMVFS_MIN(x,y) ((x)<(y)?(x):(y))
#define SPMEMVFS_MAX(x,y) ((x)>(y)?(x):(y))
static void spmemvfsDebug(const char *format, ...){
#if defined(SPMEMVFS_DEBUG)
char logTemp[ 1024 ] = { 0 };
va_list vaList;
va_start( vaList, format );
vsnprintf( logTemp, sizeof( logTemp ), format, vaList );
va_end ( vaList );
if( strchr( logTemp, '\n' ) ) {
printf( "%s", logTemp );
} else {
printf( "%s\n", logTemp );
}
#endif
}
//===========================================================================
typedef struct spmemfile_t {
sqlite3_file base;
char * path;
int flags;
spmembuffer_t * mem;
} spmemfile_t;
static int spmemfileClose( sqlite3_file * file );
static int spmemfileRead( sqlite3_file * file, void * buffer, int len, sqlite3_int64 offset );
static int spmemfileWrite( sqlite3_file * file, const void * buffer, int len, sqlite3_int64 offset );
static int spmemfileTruncate( sqlite3_file * file, sqlite3_int64 size );
static int spmemfileSync( sqlite3_file * file, int flags );
static int spmemfileFileSize( sqlite3_file * file, sqlite3_int64 * size );
static int spmemfileLock( sqlite3_file * file, int type );
static int spmemfileUnlock( sqlite3_file * file, int type );
static int spmemfileCheckReservedLock( sqlite3_file * file, int * result );
static int spmemfileFileControl( sqlite3_file * file, int op, void * arg );
static int spmemfileSectorSize( sqlite3_file * file );
static int spmemfileDeviceCharacteristics( sqlite3_file * file );
static sqlite3_io_methods g_spmemfile_io_memthods = {
1, /* iVersion */
spmemfileClose, /* xClose */
spmemfileRead, /* xRead */
spmemfileWrite, /* xWrite */
spmemfileTruncate, /* xTruncate */
spmemfileSync, /* xSync */
spmemfileFileSize, /* xFileSize */
spmemfileLock, /* xLock */
spmemfileUnlock, /* xUnlock */
spmemfileCheckReservedLock, /* xCheckReservedLock */
spmemfileFileControl, /* xFileControl */
spmemfileSectorSize, /* xSectorSize */
spmemfileDeviceCharacteristics /* xDeviceCharacteristics */
};
int spmemfileClose( sqlite3_file * file )
{
spmemfile_t * memfile = (spmemfile_t*)file;
spmemvfsDebug( "call %s( %p )", __func__, memfile );
if( SQLITE_OPEN_MAIN_DB & memfile->flags ) {
// noop
} else {
if( NULL != memfile->mem ) {
if( memfile->mem->data ) free( memfile->mem->data );
free( memfile->mem );
}
}
free( memfile->path );
return SQLITE_OK;
}
int spmemfileRead( sqlite3_file * file, void * buffer, int len, sqlite3_int64 offset )
{
spmemfile_t * memfile = (spmemfile_t*)file;
spmemvfsDebug( "call %s( %p, ..., %d, %lld ), len %d",
__func__, memfile, len, offset, memfile->mem->used );
if( ( offset + len ) > memfile->mem->used ) {
return SQLITE_IOERR_SHORT_READ;
}
memcpy( buffer, memfile->mem->data + offset, len );
return SQLITE_OK;
}
int spmemfileWrite( sqlite3_file * file, const void * buffer, int len, sqlite3_int64 offset )
{
spmemfile_t * memfile = (spmemfile_t*)file;
spmembuffer_t * mem = memfile->mem;
spmemvfsDebug( "call %s( %p, ..., %d, %lld ), len %d",
__func__, memfile, len, offset, mem->used );
if( ( offset + len ) > mem->total ) {
int64_t newTotal = 2 * ( offset + len + mem->total );
char * newBuffer = (char*)realloc( mem->data, newTotal );
if( NULL == newBuffer ) {
return SQLITE_NOMEM;
}
mem->total = newTotal;
mem->data = newBuffer;
}
memcpy( mem->data + offset, buffer, len );
mem->used = SPMEMVFS_MAX( mem->used, offset + len );
return SQLITE_OK;
}
int spmemfileTruncate( sqlite3_file * file, sqlite3_int64 size )
{
spmemfile_t * memfile = (spmemfile_t*)file;
spmemvfsDebug( "call %s( %p )", __func__, memfile );
memfile->mem->used = SPMEMVFS_MIN( memfile->mem->used, size );
return SQLITE_OK;
}
int spmemfileSync( sqlite3_file * file, int flags )
{
spmemvfsDebug( "call %s( %p )", __func__, file );
return SQLITE_OK;
}
int spmemfileFileSize( sqlite3_file * file, sqlite3_int64 * size )
{
spmemfile_t * memfile = (spmemfile_t*)file;
spmemvfsDebug( "call %s( %p )", __func__, memfile );
* size = memfile->mem->used;
return SQLITE_OK;
}
int spmemfileLock( sqlite3_file * file, int type )
{
spmemvfsDebug( "call %s( %p )", __func__, file );
return SQLITE_OK;
}
int spmemfileUnlock( sqlite3_file * file, int type )
{
spmemvfsDebug( "call %s( %p )", __func__, file );
return SQLITE_OK;
}
int spmemfileCheckReservedLock( sqlite3_file * file, int * result )
{
spmemvfsDebug( "call %s( %p )", __func__, file );
*result = 0;
return SQLITE_OK;
}
int spmemfileFileControl( sqlite3_file * file, int op, void * arg )
{
spmemvfsDebug( "call %s( %p )", __func__, file );
return SQLITE_OK;
}
int spmemfileSectorSize( sqlite3_file * file )
{
spmemvfsDebug( "call %s( %p )", __func__, file );
return 0;
}
int spmemfileDeviceCharacteristics( sqlite3_file * file )
{
spmemvfsDebug( "call %s( %p )", __func__, file );
return 0;
}
//===========================================================================
typedef struct spmemvfs_cb_t {
void * arg;
spmembuffer_t * ( * load ) ( void * args, const char * path );
} spmemvfs_cb_t;
typedef struct spmemvfs_t {
sqlite3_vfs base;
spmemvfs_cb_t cb;
sqlite3_vfs * parent;
} spmemvfs_t;
static int spmemvfsOpen( sqlite3_vfs * vfs, const char * path, sqlite3_file * file, int flags, int * outflags );
static int spmemvfsDelete( sqlite3_vfs * vfs, const char * path, int syncDir );
static int spmemvfsAccess( sqlite3_vfs * vfs, const char * path, int flags, int * result );
static int spmemvfsFullPathname( sqlite3_vfs * vfs, const char * path, int len, char * fullpath );
static void * spmemvfsDlOpen( sqlite3_vfs * vfs, const char * path );
static void spmemvfsDlError( sqlite3_vfs * vfs, int len, char * errmsg );
static void ( * spmemvfsDlSym ( sqlite3_vfs * vfs, void * handle, const char * symbol ) ) ( void );
static void spmemvfsDlClose( sqlite3_vfs * vfs, void * handle );
static int spmemvfsRandomness( sqlite3_vfs * vfs, int len, char * buffer );
static int spmemvfsSleep( sqlite3_vfs * vfs, int microseconds );
static int spmemvfsCurrentTime( sqlite3_vfs * vfs, double * result );
static spmemvfs_t g_spmemvfs = {
{
1, /* iVersion */
0, /* szOsFile */
0, /* mxPathname */
0, /* pNext */
SPMEMVFS_NAME, /* zName */
0, /* pAppData */
spmemvfsOpen, /* xOpen */
spmemvfsDelete, /* xDelete */
spmemvfsAccess, /* xAccess */
spmemvfsFullPathname, /* xFullPathname */
spmemvfsDlOpen, /* xDlOpen */
spmemvfsDlError, /* xDlError */
spmemvfsDlSym, /* xDlSym */
spmemvfsDlClose, /* xDlClose */
spmemvfsRandomness, /* xRandomness */
spmemvfsSleep, /* xSleep */
spmemvfsCurrentTime /* xCurrentTime */
},
{ 0 },
0 /* pParent */
};
int spmemvfsOpen( sqlite3_vfs * vfs, const char * path, sqlite3_file * file, int flags, int * outflags )
{
spmemvfs_t * memvfs = (spmemvfs_t*)vfs;
spmemfile_t * memfile = (spmemfile_t*)file;
spmemvfsDebug( "call %s( %p(%p), %s, %p, %x, %p )\n",
__func__, vfs, &g_spmemvfs, path, file, flags, outflags );
memset( memfile, 0, sizeof( spmemfile_t ) );
memfile->base.pMethods = &g_spmemfile_io_memthods;
memfile->flags = flags;
memfile->path = strdup( path );
if( SQLITE_OPEN_MAIN_DB & memfile->flags ) {
memfile->mem = memvfs->cb.load( memvfs->cb.arg, path );
} else {
memfile->mem = (spmembuffer_t*)calloc( sizeof( spmembuffer_t ), 1 );
}
return memfile->mem ? SQLITE_OK : SQLITE_ERROR;
}
int spmemvfsDelete( sqlite3_vfs * vfs, const char * path, int syncDir )
{
spmemvfsDebug( "call %s( %p(%p), %s, %d )\n",
__func__, vfs, &g_spmemvfs, path, syncDir );
return SQLITE_OK;
}
int spmemvfsAccess( sqlite3_vfs * vfs, const char * path, int flags, int * result )
{
* result = 0;
return SQLITE_OK;
}
int spmemvfsFullPathname( sqlite3_vfs * vfs, const char * path, int len, char * fullpath )
{
strncpy( fullpath, path, len );
fullpath[ len - 1 ] = '\0';
return SQLITE_OK;
}
void * spmemvfsDlOpen( sqlite3_vfs * vfs, const char * path )
{
return NULL;
}
void spmemvfsDlError( sqlite3_vfs * vfs, int len, char * errmsg )
{
// noop
}
void ( * spmemvfsDlSym ( sqlite3_vfs * vfs, void * handle, const char * symbol ) ) ( void )
{
return NULL;
}
void spmemvfsDlClose( sqlite3_vfs * vfs, void * handle )
{
// noop
}
int spmemvfsRandomness( sqlite3_vfs * vfs, int len, char * buffer )
{
return SQLITE_OK;
}
int spmemvfsSleep( sqlite3_vfs * vfs, int microseconds )
{
return SQLITE_OK;
}
int spmemvfsCurrentTime( sqlite3_vfs * vfs, double * result )
{
return SQLITE_OK;
}
//===========================================================================
int spmemvfs_init( spmemvfs_cb_t * cb )
{
sqlite3_vfs * parent = NULL;
if( g_spmemvfs.parent ) return SQLITE_OK;
parent = sqlite3_vfs_find( 0 );
g_spmemvfs.parent = parent;
g_spmemvfs.base.mxPathname = parent->mxPathname;
g_spmemvfs.base.szOsFile = sizeof( spmemfile_t );
g_spmemvfs.cb = * cb;
return sqlite3_vfs_register( (sqlite3_vfs*)&g_spmemvfs, 0 );
}
//===========================================================================
typedef struct spmembuffer_link_t {
char * path;
spmembuffer_t * mem;
struct spmembuffer_link_t * next;
} spmembuffer_link_t;
spmembuffer_link_t * spmembuffer_link_remove( spmembuffer_link_t ** head, const char * path )
{
spmembuffer_link_t * ret = NULL;
spmembuffer_link_t ** iter = head;
for( ; NULL != *iter; ) {
spmembuffer_link_t * curr = *iter;
if( 0 == strcmp( path, curr->path ) ) {
ret = curr;
*iter = curr->next;
break;
} else {
iter = &( curr->next );
}
}
return ret;
}
void spmembuffer_link_free( spmembuffer_link_t * iter )
{
free( iter->path );
free( iter->mem->data );
free( iter->mem );
free( iter );
}
//===========================================================================
typedef struct spmemvfs_env_t {
spmembuffer_link_t * head;
sqlite3_mutex * mutex;
} spmemvfs_env_t;
static spmemvfs_env_t * g_spmemvfs_env = NULL;
static spmembuffer_t * load_cb( void * arg, const char * path )
{
spmembuffer_t * ret = NULL;
spmemvfs_env_t * env = (spmemvfs_env_t*)arg;
sqlite3_mutex_enter( env->mutex );
{
spmembuffer_link_t * toFind = spmembuffer_link_remove( &( env->head ), path );
if( NULL != toFind ) {
ret = toFind->mem;
free( toFind->path );
free( toFind );
}
}
sqlite3_mutex_leave( env->mutex );
return ret;
}
int spmemvfs_env_init()
{
int ret = 0;
if( NULL == g_spmemvfs_env ) {
spmemvfs_cb_t cb;
g_spmemvfs_env = (spmemvfs_env_t*)calloc( sizeof( spmemvfs_env_t ), 1 );
g_spmemvfs_env->mutex = sqlite3_mutex_alloc( SQLITE_MUTEX_FAST );
cb.arg = g_spmemvfs_env;
cb.load = load_cb;
ret = spmemvfs_init( &cb );
}
return ret;
}
void spmemvfs_env_fini()
{
if( NULL != g_spmemvfs_env ) {
spmembuffer_link_t * iter = NULL;
sqlite3_vfs_unregister( (sqlite3_vfs*)&g_spmemvfs );
g_spmemvfs.parent = NULL;
sqlite3_mutex_free( g_spmemvfs_env->mutex );
iter = g_spmemvfs_env->head;
for( ; NULL != iter; ) {
spmembuffer_link_t * next = iter->next;
spmembuffer_link_free( iter );
iter = next;
}
free( g_spmemvfs_env );
g_spmemvfs_env = NULL;
}
}
int spmemvfs_open_db( spmemvfs_db_t * db, const char * path, spmembuffer_t * mem )
{
int ret = 0;
spmembuffer_link_t * iter = NULL;
memset( db, 0, sizeof( spmemvfs_db_t ) );
iter = (spmembuffer_link_t*)calloc( sizeof( spmembuffer_link_t ), 1 );
iter->path = strdup( path );
iter->mem = mem;
sqlite3_mutex_enter( g_spmemvfs_env->mutex );
{
iter->next = g_spmemvfs_env->head;
g_spmemvfs_env->head = iter;
}
sqlite3_mutex_leave( g_spmemvfs_env->mutex );
ret = sqlite3_open_v2( path, &(db->handle),
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, SPMEMVFS_NAME );
if( 0 == ret ) {
db->mem = mem;
} else {
sqlite3_mutex_enter( g_spmemvfs_env->mutex );
{
iter = spmembuffer_link_remove( &(g_spmemvfs_env->head), path );
if( NULL != iter ) spmembuffer_link_free( iter );
}
sqlite3_mutex_leave( g_spmemvfs_env->mutex );
}
return ret;
}
int spmemvfs_close_db( spmemvfs_db_t * db )
{
int ret = 0;
if( NULL == db ) return 0;
if( NULL != db->handle ) {
ret = sqlite3_close( db->handle );
db->handle = NULL;
}
if( NULL != db->mem ) {
if( NULL != db->mem->data ) free( db->mem->data );
free( db->mem );
db->mem = NULL;
}
return ret;
}

65
thirdparty/sqlite/spmemvfs.h vendored Normal file
View file

@ -0,0 +1,65 @@
/*
* BSD 2-Clause License
*
* Copyright 2009 Stephen Liu
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __spmemvfs_h__
#define __spmemvfs_h__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "sqlite3.h"
#define SPMEMVFS_NAME "spmemvfs"
typedef struct spmembuffer_t {
char *data;
int64_t used;
int64_t total;
} spmembuffer_t;
typedef struct spmemvfs_db_t {
sqlite3 * handle;
spmembuffer_t * mem;
} spmemvfs_db_t;
int spmemvfs_env_init();
void spmemvfs_env_fini();
int spmemvfs_open_db( spmemvfs_db_t * db, const char * path, spmembuffer_t * mem );
int spmemvfs_close_db( spmemvfs_db_t * db );
#ifdef __cplusplus
}
#endif
#endif

231754
thirdparty/sqlite/sqlite3.c vendored Normal file

File diff suppressed because it is too large Load diff

12237
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
View 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 */