BUGFIX: init of transports wrong
authorvb
Sat, 24 Jan 2015 15:26:40 +0100
changeset 467471e31bb278
parent 45 37a80387790d
child 47 5ed7e8a4f0c2
BUGFIX: init of transports wrong
src/Makefile
src/keymanagement.c
src/pEpEngine.c
src/pEpEngine.h
src/pEp_internal.h
src/pgp_gpg.c
src/sqlite3.c
src/sqlite3.h
src/transport.c
test/Makefile
test/pEpEngineTest.cc
     1.1 --- a/src/Makefile	Fri Jan 16 18:39:27 2015 +0100
     1.2 +++ b/src/Makefile	Sat Jan 24 15:26:40 2015 +0100
     1.3 @@ -7,24 +7,12 @@
     1.4  MACOSX_VERSION_MIN=10.6
     1.5  GPGME_IN=$(HOME)
     1.6  LIBGPGME=libgpgme-pthread.dylib
     1.7 -CC=gcc -std=c99
     1.8 +CC=clang -std=c99 -pthread
     1.9 +LD=clang
    1.10  CFLAGS=-I$(GPGME_IN)/include -I/opt/local/include $(OPTIMIZE) -pedantic \
    1.11 -	-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\"  -DSQLITE_THREADSAFE=1
    1.12 -LDFLAGS=-lc -macosx_version_min $(MACOSX_VERSION_MIN) -dylib -arch x86_64 \
    1.13 -	-L/opt/local/lib -letpan
    1.14 -
    1.15 -else ifeq ($(BUILD_FOR),Windoze)
    1.16 -
    1.17 -TARGET=pEpEngine.dll
    1.18 -GPGME_IN=$(HOME)
    1.19 -LIBGPGME=libgpgme-11.dll
    1.20 -CC=i686-w64-mingw32-gcc -std=c99
    1.21 -CXX=i686-w64-mingw32-g++
    1.22 -LD=i686-w64-mingw32-gcc
    1.23 -CFLAGS=-I$(HOME)/i686-w64-mingw32/include -I$(GPGME_IN)/include $(OPTIMIZE) -pedantic \
    1.24 -	-DLIBGPGME=\"$(LIBGPGME)\" -DWIN32 -DSQLITE_THREADSAFE=1
    1.25 -LDFLAGS=-shared -L$(HOME)/i686-w64-mingw32/lib -llibstdc++ \
    1.26 -	-Wl,--output-def,pEpEngine.def,--out-implib,libpEpEngine.a
    1.27 +	-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\"
    1.28 +LDFLAGS=-lc -shared -arch x86_64 \
    1.29 +	-L/opt/local/lib -letpan -lgpgme-pthread -lsqlite3
    1.30  
    1.31  else
    1.32  $(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    1.33 @@ -39,56 +27,19 @@
    1.34  CC=gcc -std=c99
    1.35  CFLAGS=-I$(GPGME_IN)/include $(OPTIMIZE) -fPIC -pedantic \
    1.36  	-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\" -DSQLITE_THREADSAFE=1
    1.37 -LDFLAGS=-L$(GPGME_IN) -shared -lc -ldl
    1.38 -
    1.39 -else ifeq ($(BUILD_FOR),Windoze)
    1.40 -
    1.41 -TARGET=pEpEngine.dll
    1.42 -GPGME_IN=$(HOME)
    1.43 -LIBGPGME=libgpgme-11.dll
    1.44 -CC=i686-w64-mingw32-gcc -std=c99
    1.45 -CXX=i686-w64-mingw32-g++
    1.46 -LD=i686-w64-mingw32-gcc
    1.47 -CFLAGS=-I/usr/i686-w64-mingw32/include -I$(GPGME_IN)/include $(OPTIMIZE) -pedantic \
    1.48 -	-DLIBGPGME=\"$(LIBGPGME)\" -DWIN32 -DSQLITE_THREADSAFE=1
    1.49 -LDFLAGS=-shared -L/usr/i686-w64-mingw32/lib -llibstdc++ \
    1.50 -	-Wl,--output-def,pEpEngine.def,--out-implib,libpEpEngine.a
    1.51 +LDFLAGS=-L$(GPGME_IN) -shared -lc -ldl -letpan -lgpgme-pthread -lsqlite3
    1.52  
    1.53  else
    1.54  $(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    1.55  endif
    1.56  
    1.57 -else ifeq ($(BUILD_ON),MINGW32_NT-6.1)
    1.58 -
    1.59 -TARGET=pEpEngine.dll
    1.60 -GPGME_IN=/c/Program\ Files/GNU/GnuPG
    1.61 -LIBGPGME=libgpgme-11.dll
    1.62 -CC=gcc -std=gnu99
    1.63 -CFLAGS=-I$(GPGME_IN)/include $(OPTIMIZE) -pedantic -DWIN32 -DSQLITE_THREADSAFE=1
    1.64 -LD=gcc
    1.65 -LDFLAGS=-shared -llibstdc++ -Wl,--output-def,pEpEngine.def,--out-implib,libpEpEngine.a
    1.66 -
    1.67  else
    1.68  $(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    1.69  endif
    1.70  
    1.71 -ifeq ($(BUILD_FOR),Windoze)
    1.72 -ALL_SOURCE=$(filter-out platform_unix.c,$(wildcard *.c))
    1.73 -else ifeq ($(BUILD_FOR),MINGW32_NT-6.1)
    1.74 -ALL_SOURCE=$(filter-out platform_unix.c,$(wildcard *.c))
    1.75 -else
    1.76  ALL_SOURCE=$(wildcard *.c)
    1.77 -endif
    1.78 -
    1.79  DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
    1.80 -
    1.81 -ifeq ($(BUILD_FOR),Windoze)
    1.82 -ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE)) platform_windows.o
    1.83 -else ifeq ($(BUILD_FOR),MINGW32_NT-6.1)
    1.84 -ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE)) platform_windows.o
    1.85 -else
    1.86  ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
    1.87 -endif
    1.88  
    1.89  all: $(TARGET)
    1.90  
    1.91 @@ -100,8 +51,8 @@
    1.92  
    1.93  -include $(DEPENDS)
    1.94  
    1.95 -platform_windows.o: platform_windows.cpp
    1.96 -	$(CXX) $(CXX_FLAGS) -o $@ -c $<
    1.97 +#platform_windows.o: platform_windows.cpp
    1.98 +#	$(CXX) $(CXX_FLAGS) -o $@ -c $<
    1.99  
   1.100  $(TARGET): libpEpEngine.a
   1.101  	$(LD) $(ALL_OBJECTS) $(LDFLAGS) -o $@
     2.1 --- a/src/keymanagement.c	Fri Jan 16 18:39:27 2015 +0100
     2.2 +++ b/src/keymanagement.c	Sat Jan 24 15:26:40 2015 +0100
     2.3 @@ -186,7 +186,7 @@
     2.4  DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
     2.5  {
     2.6      PEP_STATUS status;
     2.7 -    stringlist_t *keylist;
     2.8 +    stringlist_t *keylist = NULL;
     2.9  
    2.10      assert(session);
    2.11      assert(identity);
     3.1 --- a/src/pEpEngine.c	Fri Jan 16 18:39:27 2015 +0100
     3.2 +++ b/src/pEpEngine.c	Sat Jan 24 15:26:40 2015 +0100
     3.3 @@ -29,8 +29,8 @@
     3.4  	_session->version = PEP_ENGINE_VERSION;
     3.5  
     3.6      init_cryptotech(_session);
     3.7 -    init_transport_system(_session->transports);
     3.8 -
     3.9 +    init_transport_system(_session);
    3.10 +    
    3.11      assert(LOCAL_DB);
    3.12      if (LOCAL_DB == NULL) {
    3.13          release_transport_system(_session);
    3.14 @@ -232,27 +232,26 @@
    3.15  DYNAMIC_API void release(PEP_SESSION session)
    3.16  {
    3.17  	assert(session);
    3.18 -	pEpSession *_session = (pEpSession *) session;
    3.19  
    3.20 -	if (_session) {
    3.21 -		if (_session->db) {
    3.22 -			sqlite3_finalize(_session->safeword);
    3.23 -			sqlite3_finalize(_session->log);
    3.24 -			sqlite3_finalize(_session->get_identity);
    3.25 -			sqlite3_finalize(_session->set_identity);
    3.26 -            sqlite3_finalize(_session->set_person);
    3.27 -            sqlite3_finalize(_session->set_pgp_keypair);
    3.28 -            sqlite3_finalize(_session->set_trust);
    3.29 -            sqlite3_finalize(_session->get_trust);
    3.30 +	if (session) {
    3.31 +		if (session->db) {
    3.32 +			sqlite3_finalize(session->safeword);
    3.33 +			sqlite3_finalize(session->log);
    3.34 +			sqlite3_finalize(session->get_identity);
    3.35 +			sqlite3_finalize(session->set_identity);
    3.36 +            sqlite3_finalize(session->set_person);
    3.37 +            sqlite3_finalize(session->set_pgp_keypair);
    3.38 +            sqlite3_finalize(session->set_trust);
    3.39 +            sqlite3_finalize(session->get_trust);
    3.40  
    3.41 -			sqlite3_close_v2(_session->db);
    3.42 -			sqlite3_close_v2(_session->system_db);
    3.43 +			sqlite3_close_v2(session->db);
    3.44 +			sqlite3_close_v2(session->system_db);
    3.45  		}
    3.46  
    3.47 -        release_transport_system(_session);
    3.48 -        release_cryptotech(_session);
    3.49 +        release_transport_system(session);
    3.50 +        release_cryptotech(session);
    3.51      }
    3.52 -	free(_session);
    3.53 +	free(session);
    3.54  }
    3.55  
    3.56  stringlist_t *new_stringlist(const char *value)
    3.57 @@ -363,32 +362,31 @@
    3.58          const char *description, const char *comment
    3.59      )
    3.60  {
    3.61 -	pEpSession *_session = (pEpSession *) session;
    3.62  	PEP_STATUS status = PEP_STATUS_OK;
    3.63  	int result;
    3.64  
    3.65 -	assert(_session);
    3.66 +	assert(session);
    3.67  	assert(title);
    3.68  	assert(entity);
    3.69  
    3.70 -	sqlite3_reset(_session->log);
    3.71 -	sqlite3_bind_text(_session->log, 1, title, -1, SQLITE_STATIC);
    3.72 -	sqlite3_bind_text(_session->log, 2, entity, -1, SQLITE_STATIC);
    3.73 +	sqlite3_reset(session->log);
    3.74 +	sqlite3_bind_text(session->log, 1, title, -1, SQLITE_STATIC);
    3.75 +	sqlite3_bind_text(session->log, 2, entity, -1, SQLITE_STATIC);
    3.76  	if (description)
    3.77 -        sqlite3_bind_text(_session->log, 3, description, -1, SQLITE_STATIC);
    3.78 +        sqlite3_bind_text(session->log, 3, description, -1, SQLITE_STATIC);
    3.79  	else
    3.80 -		sqlite3_bind_null(_session->log, 3);
    3.81 +		sqlite3_bind_null(session->log, 3);
    3.82  	if (comment)
    3.83 -		sqlite3_bind_text(_session->log, 4, comment, -1, SQLITE_STATIC);
    3.84 +		sqlite3_bind_text(session->log, 4, comment, -1, SQLITE_STATIC);
    3.85  	else
    3.86 -		sqlite3_bind_null(_session->log, 4);
    3.87 +		sqlite3_bind_null(session->log, 4);
    3.88  	do {
    3.89 -		result = sqlite3_step(_session->log);
    3.90 +		result = sqlite3_step(session->log);
    3.91  		assert(result == SQLITE_DONE || result == SQLITE_BUSY);
    3.92  		if (result != SQLITE_DONE && result != SQLITE_BUSY)
    3.93  			status = PEP_UNKNOWN_ERROR;
    3.94  	} while (result == SQLITE_BUSY);
    3.95 -	sqlite3_reset(_session->log);
    3.96 +	sqlite3_reset(session->log);
    3.97  
    3.98  	return status;
    3.99  }
   3.100 @@ -398,11 +396,10 @@
   3.101              char **word, size_t *wsize
   3.102          )
   3.103  {
   3.104 -	pEpSession *_session = (pEpSession *) session;
   3.105  	PEP_STATUS status = PEP_STATUS_OK;
   3.106  	int result;
   3.107  
   3.108 -	assert(_session);
   3.109 +	assert(session);
   3.110  	assert(word);
   3.111  	assert(wsize);
   3.112  
   3.113 @@ -418,22 +415,22 @@
   3.114              || (lang[1] >= 'a' && lang[1] <= 'z'));
   3.115  	assert(lang[2] == 0);
   3.116  
   3.117 -	sqlite3_reset(_session->safeword);
   3.118 -    sqlite3_bind_text(_session->safeword, 1, lang, -1, SQLITE_STATIC);
   3.119 -	sqlite3_bind_int(_session->safeword, 2, value);
   3.120 +	sqlite3_reset(session->safeword);
   3.121 +    sqlite3_bind_text(session->safeword, 1, lang, -1, SQLITE_STATIC);
   3.122 +	sqlite3_bind_int(session->safeword, 2, value);
   3.123  
   3.124 -	result = sqlite3_step(_session->safeword);
   3.125 +	result = sqlite3_step(session->safeword);
   3.126  	if (result == SQLITE_ROW) {
   3.127 -        *word = strdup((const char *) sqlite3_column_text(_session->safeword,
   3.128 +        *word = strdup((const char *) sqlite3_column_text(session->safeword,
   3.129                      1));
   3.130  		if (*word)
   3.131 -            *wsize = sqlite3_column_bytes(_session->safeword, 1);
   3.132 +            *wsize = sqlite3_column_bytes(session->safeword, 1);
   3.133  		else
   3.134  			status = PEP_SAFEWORD_NOT_FOUND;
   3.135  	} else
   3.136  		status = PEP_SAFEWORD_NOT_FOUND;
   3.137  
   3.138 -	sqlite3_reset(_session->safeword);
   3.139 +	sqlite3_reset(session->safeword);
   3.140  	return status;
   3.141  }
   3.142  
   3.143 @@ -607,7 +604,6 @@
   3.144          pEp_identity **identity
   3.145      )
   3.146  {
   3.147 -	pEpSession *_session = (pEpSession *) session;
   3.148  	PEP_STATUS status = PEP_STATUS_OK;
   3.149  	static pEp_identity *_identity;
   3.150  	int result;
   3.151 @@ -617,24 +613,24 @@
   3.152  	assert(address);
   3.153      assert(address[0]);
   3.154  
   3.155 -    sqlite3_reset(_session->get_identity);
   3.156 -    sqlite3_bind_text(_session->get_identity, 1, address, -1, SQLITE_STATIC);
   3.157 +    sqlite3_reset(session->get_identity);
   3.158 +    sqlite3_bind_text(session->get_identity, 1, address, -1, SQLITE_STATIC);
   3.159  
   3.160 -    result = sqlite3_step(_session->get_identity);
   3.161 +    result = sqlite3_step(session->get_identity);
   3.162  	switch (result) {
   3.163  	case SQLITE_ROW:
   3.164          _identity = new_identity(
   3.165                  address,
   3.166 -                (const char *) sqlite3_column_text(_session->get_identity, 0),
   3.167 -                (const char *) sqlite3_column_text(_session->get_identity, 1),
   3.168 -                (const char *) sqlite3_column_text(_session->get_identity, 2)
   3.169 +                (const char *) sqlite3_column_text(session->get_identity, 0),
   3.170 +                (const char *) sqlite3_column_text(session->get_identity, 1),
   3.171 +                (const char *) sqlite3_column_text(session->get_identity, 2)
   3.172                  );
   3.173          assert(_identity);
   3.174          if (_identity == NULL)
   3.175              return PEP_OUT_OF_MEMORY;
   3.176  
   3.177 -        _identity->comm_type = (PEP_comm_type) sqlite3_column_int(_session->get_identity, 3);
   3.178 -        _lang = (const char *) sqlite3_column_text(_session->get_identity, 4);
   3.179 +        _identity->comm_type = (PEP_comm_type) sqlite3_column_int(session->get_identity, 3);
   3.180 +        _lang = (const char *) sqlite3_column_text(session->get_identity, 4);
   3.181          if (_lang && _lang[0]) {
   3.182  			assert(_lang[0] >= 'a' && _lang[0] <= 'z');
   3.183  			assert(_lang[1] >= 'a' && _lang[1] <= 'z');
   3.184 @@ -650,7 +646,7 @@
   3.185  		*identity = NULL;
   3.186  	}
   3.187  
   3.188 -    sqlite3_reset(_session->get_identity);
   3.189 +    sqlite3_reset(session->get_identity);
   3.190  	return status;
   3.191  }
   3.192  
   3.193 @@ -658,7 +654,6 @@
   3.194          PEP_SESSION session, const pEp_identity *identity
   3.195      )
   3.196  {
   3.197 -	pEpSession *_session = (pEpSession *) session;
   3.198  	int result;
   3.199  
   3.200  	assert(session);
   3.201 @@ -668,63 +663,63 @@
   3.202  	assert(identity->user_id);
   3.203  	assert(identity->username);
   3.204  
   3.205 -	sqlite3_exec(_session->db, "BEGIN ;", NULL, NULL, NULL);
   3.206 +	sqlite3_exec(session->db, "BEGIN ;", NULL, NULL, NULL);
   3.207  
   3.208 -	sqlite3_reset(_session->set_person);
   3.209 -    sqlite3_bind_text(_session->set_person, 1, identity->user_id, -1,
   3.210 +	sqlite3_reset(session->set_person);
   3.211 +    sqlite3_bind_text(session->set_person, 1, identity->user_id, -1,
   3.212              SQLITE_STATIC);
   3.213 -    sqlite3_bind_text(_session->set_person, 2, identity->username, -1,
   3.214 +    sqlite3_bind_text(session->set_person, 2, identity->username, -1,
   3.215              SQLITE_STATIC);
   3.216  	if (identity->lang[0])
   3.217 -        sqlite3_bind_text(_session->set_person, 3, identity->lang, 1,
   3.218 +        sqlite3_bind_text(session->set_person, 3, identity->lang, 1,
   3.219                  SQLITE_STATIC);
   3.220  	else
   3.221 -		sqlite3_bind_null(_session->set_person, 3);
   3.222 -	result = sqlite3_step(_session->set_person);
   3.223 -	sqlite3_reset(_session->set_person);
   3.224 +		sqlite3_bind_null(session->set_person, 3);
   3.225 +	result = sqlite3_step(session->set_person);
   3.226 +	sqlite3_reset(session->set_person);
   3.227  	if (result != SQLITE_DONE) {
   3.228 -		sqlite3_exec(_session->db, "ROLLBACK ;", NULL, NULL, NULL);
   3.229 +		sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
   3.230  		return PEP_CANNOT_SET_PERSON;
   3.231  	}
   3.232  
   3.233 -	sqlite3_reset(_session->set_pgp_keypair);
   3.234 -    sqlite3_bind_text(_session->set_pgp_keypair, 1, identity->fpr, -1,
   3.235 +	sqlite3_reset(session->set_pgp_keypair);
   3.236 +    sqlite3_bind_text(session->set_pgp_keypair, 1, identity->fpr, -1,
   3.237              SQLITE_STATIC);
   3.238 -	result = sqlite3_step(_session->set_pgp_keypair);
   3.239 -	sqlite3_reset(_session->set_pgp_keypair);
   3.240 +	result = sqlite3_step(session->set_pgp_keypair);
   3.241 +	sqlite3_reset(session->set_pgp_keypair);
   3.242  	if (result != SQLITE_DONE) {
   3.243 -		sqlite3_exec(_session->db, "ROLLBACK ;", NULL, NULL, NULL);
   3.244 +		sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
   3.245  		return PEP_CANNOT_SET_PGP_KEYPAIR;
   3.246  	}
   3.247  
   3.248 -	sqlite3_reset(_session->set_identity);
   3.249 -    sqlite3_bind_text(_session->set_identity, 1, identity->address, -1,
   3.250 +	sqlite3_reset(session->set_identity);
   3.251 +    sqlite3_bind_text(session->set_identity, 1, identity->address, -1,
   3.252              SQLITE_STATIC);
   3.253 -    sqlite3_bind_text(_session->set_identity, 2, identity->fpr, -1,
   3.254 +    sqlite3_bind_text(session->set_identity, 2, identity->fpr, -1,
   3.255              SQLITE_STATIC);
   3.256 -    sqlite3_bind_text(_session->set_identity, 3, identity->user_id, -1,
   3.257 +    sqlite3_bind_text(session->set_identity, 3, identity->user_id, -1,
   3.258              SQLITE_STATIC);
   3.259 -	result = sqlite3_step(_session->set_identity);
   3.260 -	sqlite3_reset(_session->set_identity);
   3.261 +	result = sqlite3_step(session->set_identity);
   3.262 +	sqlite3_reset(session->set_identity);
   3.263  	if (result != SQLITE_DONE) {
   3.264 -		sqlite3_exec(_session->db, "ROLLBACK ;", NULL, NULL, NULL);
   3.265 +		sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
   3.266  		return PEP_CANNOT_SET_IDENTITY;
   3.267  	}
   3.268  
   3.269 -	sqlite3_reset(_session->set_trust);
   3.270 -    sqlite3_bind_text(_session->set_trust, 1, identity->user_id, -1,
   3.271 +	sqlite3_reset(session->set_trust);
   3.272 +    sqlite3_bind_text(session->set_trust, 1, identity->user_id, -1,
   3.273              SQLITE_STATIC);
   3.274 -    sqlite3_bind_text(_session->set_trust, 2, identity->fpr, -1,
   3.275 +    sqlite3_bind_text(session->set_trust, 2, identity->fpr, -1,
   3.276              SQLITE_STATIC);
   3.277 -	sqlite3_bind_int(_session->set_trust, 3, identity->comm_type);
   3.278 -	result = sqlite3_step(_session->set_trust);
   3.279 -	sqlite3_reset(_session->set_trust);
   3.280 +	sqlite3_bind_int(session->set_trust, 3, identity->comm_type);
   3.281 +	result = sqlite3_step(session->set_trust);
   3.282 +	sqlite3_reset(session->set_trust);
   3.283  	if (result != SQLITE_DONE) {
   3.284 -		sqlite3_exec(_session->db, "ROLLBACK ;", NULL, NULL, NULL);
   3.285 +		sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
   3.286  		return PEP_CANNOT_SET_IDENTITY;
   3.287  	}
   3.288  
   3.289 -    result = sqlite3_exec(_session->db, "COMMIT ;", NULL, NULL, NULL);
   3.290 +    result = sqlite3_exec(session->db, "COMMIT ;", NULL, NULL, NULL);
   3.291  	if (result == SQLITE_OK)
   3.292  		return PEP_STATUS_OK;
   3.293  	else
   3.294 @@ -738,7 +733,6 @@
   3.295  
   3.296  DYNAMIC_API PEP_STATUS get_trust(PEP_SESSION session, pEp_identity *identity)
   3.297  {
   3.298 -    pEpSession *_session = (pEpSession *) session;
   3.299      PEP_STATUS status = PEP_STATUS_OK;
   3.300      int result;
   3.301  
   3.302 @@ -751,15 +745,15 @@
   3.303  
   3.304      identity->comm_type = PEP_ct_unknown;
   3.305  
   3.306 -    sqlite3_reset(_session->get_trust);
   3.307 -    sqlite3_bind_text(_session->get_trust, 1, identity->user_id, -1, SQLITE_STATIC);
   3.308 -    sqlite3_bind_text(_session->get_trust, 2, identity->fpr, -1, SQLITE_STATIC);
   3.309 +    sqlite3_reset(session->get_trust);
   3.310 +    sqlite3_bind_text(session->get_trust, 1, identity->user_id, -1, SQLITE_STATIC);
   3.311 +    sqlite3_bind_text(session->get_trust, 2, identity->fpr, -1, SQLITE_STATIC);
   3.312  
   3.313 -    result = sqlite3_step(_session->get_trust);
   3.314 +    result = sqlite3_step(session->get_trust);
   3.315      switch (result) {
   3.316      case SQLITE_ROW: {
   3.317 -        const char * user_id = (const char *) sqlite3_column_text(_session->get_trust, 1);
   3.318 -        int comm_type = (PEP_comm_type) sqlite3_column_int(_session->get_trust, 2);
   3.319 +        const char * user_id = (const char *) sqlite3_column_text(session->get_trust, 1);
   3.320 +        int comm_type = (PEP_comm_type) sqlite3_column_int(session->get_trust, 2);
   3.321  
   3.322          if (strcmp(user_id, identity->user_id) != 0) {
   3.323              free(identity->user_id);
   3.324 @@ -776,7 +770,7 @@
   3.325          status = PEP_CANNOT_FIND_IDENTITY;
   3.326      }
   3.327  
   3.328 -    sqlite3_reset(_session->get_trust);
   3.329 +    sqlite3_reset(session->get_trust);
   3.330      return status;
   3.331  }
   3.332  
   3.333 @@ -785,8 +779,7 @@
   3.334      char **ptext, size_t *psize, stringlist_t **keylist
   3.335      )
   3.336  {
   3.337 -    pEpSession *_session = (pEpSession *) session;
   3.338 -    return _session->cryptotech[PEP_crypt_OpenPGP].decrypt_and_verify(session, ctext, csize, ptext, psize, keylist);
   3.339 +    return session->cryptotech[PEP_crypt_OpenPGP].decrypt_and_verify(session, ctext, csize, ptext, psize, keylist);
   3.340  }
   3.341  
   3.342  DYNAMIC_API PEP_STATUS encrypt_and_sign(
   3.343 @@ -794,8 +787,7 @@
   3.344      size_t psize, char **ctext, size_t *csize
   3.345      )
   3.346  {
   3.347 -    pEpSession *_session = (pEpSession *) session;
   3.348 -    return _session->cryptotech[PEP_crypt_OpenPGP].encrypt_and_sign(session, keylist, ptext, psize, ctext, csize);
   3.349 +    return session->cryptotech[PEP_crypt_OpenPGP].encrypt_and_sign(session, keylist, ptext, psize, ctext, csize);
   3.350  }
   3.351  
   3.352  DYNAMIC_API PEP_STATUS verify_text(
   3.353 @@ -803,64 +795,55 @@
   3.354      const char *signature, size_t sig_size, stringlist_t **keylist
   3.355      )
   3.356  {
   3.357 -    pEpSession *_session = (pEpSession *) session;
   3.358 -    return _session->cryptotech[PEP_crypt_OpenPGP].verify_text(session, text, size, signature, sig_size, keylist);
   3.359 +    return session->cryptotech[PEP_crypt_OpenPGP].verify_text(session, text, size, signature, sig_size, keylist);
   3.360  }
   3.361  
   3.362  DYNAMIC_API PEP_STATUS delete_keypair(PEP_SESSION session, const char *fpr)
   3.363  {
   3.364 -    pEpSession *_session = (pEpSession *) session;
   3.365 -    return _session->cryptotech[PEP_crypt_OpenPGP].delete_keypair(session, fpr);
   3.366 +    return session->cryptotech[PEP_crypt_OpenPGP].delete_keypair(session, fpr);
   3.367  }
   3.368  
   3.369  DYNAMIC_API PEP_STATUS export_key(
   3.370 -    PEP_SESSION session, const char *fpr, char **key_data, size_t *size
   3.371 +        PEP_SESSION session, const char *fpr, char **key_data, size_t *size
   3.372      )
   3.373  {
   3.374 -    pEpSession *_session = (pEpSession *) session;
   3.375 -    return _session->cryptotech[PEP_crypt_OpenPGP].export_key(session, fpr, key_data, size);
   3.376 +    return session->cryptotech[PEP_crypt_OpenPGP].export_key(session, fpr, key_data, size);
   3.377  }
   3.378  
   3.379  DYNAMIC_API PEP_STATUS find_keys(
   3.380 -    PEP_SESSION session, const char *pattern, stringlist_t **keylist
   3.381 +        PEP_SESSION session, const char *pattern, stringlist_t **keylist
   3.382      )
   3.383  {
   3.384 -    pEpSession *_session = (pEpSession *) session;
   3.385 -    return _session->cryptotech[PEP_crypt_OpenPGP].find_keys(session, pattern, keylist);
   3.386 +    return session->cryptotech[PEP_crypt_OpenPGP].find_keys(session, pattern, keylist);
   3.387  }
   3.388  
   3.389  DYNAMIC_API PEP_STATUS generate_keypair(
   3.390 -    PEP_SESSION session, pEp_identity *identity
   3.391 +        PEP_SESSION session, pEp_identity *identity
   3.392      )
   3.393  {
   3.394 -    pEpSession *_session = (pEpSession *) session;
   3.395 -    return _session->cryptotech[PEP_crypt_OpenPGP].generate_keypair(session, identity);
   3.396 +    return session->cryptotech[PEP_crypt_OpenPGP].generate_keypair(session, identity);
   3.397  }
   3.398  
   3.399  DYNAMIC_API PEP_STATUS get_key_rating(
   3.400 -    PEP_SESSION session,
   3.401 -    const char *fpr,
   3.402 -    PEP_comm_type *comm_type
   3.403 +        PEP_SESSION session,
   3.404 +        const char *fpr,
   3.405 +        PEP_comm_type *comm_type
   3.406      )
   3.407  {
   3.408 -    pEpSession *_session = (pEpSession *) session;
   3.409 -    return _session->cryptotech[PEP_crypt_OpenPGP].get_key_rating(session, fpr, comm_type);
   3.410 +    return session->cryptotech[PEP_crypt_OpenPGP].get_key_rating(session, fpr, comm_type);
   3.411  }
   3.412  
   3.413  DYNAMIC_API PEP_STATUS import_key(PEP_SESSION session, const char *key_data, size_t size)
   3.414  {
   3.415 -    pEpSession *_session = (pEpSession *) session;
   3.416 -    return _session->cryptotech[PEP_crypt_OpenPGP].import_key(session, key_data, size);
   3.417 +    return session->cryptotech[PEP_crypt_OpenPGP].import_key(session, key_data, size);
   3.418  }
   3.419  
   3.420  DYNAMIC_API PEP_STATUS recv_key(PEP_SESSION session, const char *pattern)
   3.421  {
   3.422 -    pEpSession *_session = (pEpSession *) session;
   3.423 -    return _session->cryptotech[PEP_crypt_OpenPGP].recv_key(session, pattern);
   3.424 +    return session->cryptotech[PEP_crypt_OpenPGP].recv_key(session, pattern);
   3.425  }
   3.426  
   3.427  DYNAMIC_API PEP_STATUS send_key(PEP_SESSION session, const char *pattern)
   3.428  {
   3.429 -    pEpSession *_session = (pEpSession *) session;
   3.430 -    return _session->cryptotech[PEP_crypt_OpenPGP].send_key(session, pattern);
   3.431 +    return session->cryptotech[PEP_crypt_OpenPGP].send_key(session, pattern);
   3.432  }
     4.1 --- a/src/pEpEngine.h	Fri Jan 16 18:39:27 2015 +0100
     4.2 +++ b/src/pEpEngine.h	Sat Jan 24 15:26:40 2015 +0100
     4.3 @@ -26,7 +26,8 @@
     4.4  //      UTF-8 strings are UTF-8 encoded C strings (zero terminated)
     4.5  
     4.6  
     4.7 -typedef void * PEP_SESSION;
     4.8 +struct _pEpSession;
     4.9 +typedef struct _pEpSession * PEP_SESSION;
    4.10  
    4.11  typedef enum {
    4.12  	PEP_STATUS_OK									= 0,
     5.1 --- a/src/pEp_internal.h	Fri Jan 16 18:39:27 2015 +0100
     5.2 +++ b/src/pEp_internal.h	Sat Jan 24 15:26:40 2015 +0100
     5.3 @@ -60,7 +60,7 @@
     5.4  
     5.5  #define NOT_IMPLEMENTED assert(0)
     5.6  
     5.7 -typedef struct {
     5.8 +typedef struct _pEpSession {
     5.9      const char *version;
    5.10  
    5.11  #ifndef NO_GPG
     6.1 --- a/src/pgp_gpg.c	Fri Jan 16 18:39:27 2015 +0100
     6.2 +++ b/src/pgp_gpg.c	Sat Jan 24 15:26:40 2015 +0100
     6.3 @@ -39,204 +39,204 @@
     6.4  
     6.5  PEP_STATUS pgp_init(PEP_SESSION session)
     6.6  {
     6.7 -    pEpSession *_session = (pEpSession *) session;
     6.8      gpgme_error_t gpgme_error;
     6.9      bool bResult = ensure_keyserver();
    6.10      assert(bResult);
    6.11  
    6.12 -    _session->gpgme = dlopen(LIBGPGME, RTLD_LAZY);
    6.13 -    if (_session->gpgme == NULL) {
    6.14 -        free(_session);
    6.15 +    session->gpgme = dlopen(LIBGPGME, RTLD_LAZY);
    6.16 +    if (session->gpgme == NULL) {
    6.17 +        free(session);
    6.18          return PEP_INIT_CANNOT_LOAD_GPGME;
    6.19      }
    6.20  
    6.21 -    memset(&(_session->gpg), 0, sizeof(struct gpg_s));
    6.22 +    memset(&(session->gpg), 0, sizeof(struct gpg_s));
    6.23  
    6.24 -    _session->gpg.gpgme_set_locale
    6.25 -        = (gpgme_set_locale_t) (intptr_t) dlsym(_session->gpgme,
    6.26 +    session->gpg.gpgme_set_locale
    6.27 +        = (gpgme_set_locale_t) (intptr_t) dlsym(session->gpgme,
    6.28          "gpgme_set_locale");
    6.29 -    assert(_session->gpg.gpgme_set_locale);
    6.30 +    assert(session->gpg.gpgme_set_locale);
    6.31  
    6.32 -    _session->gpg.gpgme_check
    6.33 -        = (gpgme_check_version_t) (intptr_t) dlsym(_session->gpgme,
    6.34 +    session->gpg.gpgme_check
    6.35 +        = (gpgme_check_version_t) (intptr_t) dlsym(session->gpgme,
    6.36          "gpgme_check_version");
    6.37 -    assert(_session->gpg.gpgme_check);
    6.38 +    assert(session->gpg.gpgme_check);
    6.39  
    6.40 -    _session->gpg.gpgme_new
    6.41 -        = (gpgme_new_t) (intptr_t) dlsym(_session->gpgme, "gpgme_new");
    6.42 -    assert(_session->gpg.gpgme_new);
    6.43 +    session->gpg.gpgme_new
    6.44 +        = (gpgme_new_t) (intptr_t) dlsym(session->gpgme, "gpgme_new");
    6.45 +    assert(session->gpg.gpgme_new);
    6.46  
    6.47 -    _session->gpg.gpgme_release
    6.48 -        = (gpgme_release_t) (intptr_t) dlsym(_session->gpgme, "gpgme_release");
    6.49 -    assert(_session->gpg.gpgme_release);
    6.50 +    session->gpg.gpgme_release
    6.51 +        = (gpgme_release_t) (intptr_t) dlsym(session->gpgme, "gpgme_release");
    6.52 +    assert(session->gpg.gpgme_release);
    6.53  
    6.54 -    _session->gpg.gpgme_set_protocol
    6.55 -        = (gpgme_set_protocol_t) (intptr_t) dlsym(_session->gpgme,
    6.56 +    session->gpg.gpgme_set_protocol
    6.57 +        = (gpgme_set_protocol_t) (intptr_t) dlsym(session->gpgme,
    6.58          "gpgme_set_protocol");
    6.59 -    assert(_session->gpg.gpgme_set_protocol);
    6.60 +    assert(session->gpg.gpgme_set_protocol);
    6.61  
    6.62 -    _session->gpg.gpgme_set_armor
    6.63 -        = (gpgme_set_armor_t) (intptr_t) dlsym(_session->gpgme,
    6.64 +    session->gpg.gpgme_set_armor
    6.65 +        = (gpgme_set_armor_t) (intptr_t) dlsym(session->gpgme,
    6.66          "gpgme_set_armor");
    6.67 -    assert(_session->gpg.gpgme_set_armor);
    6.68 +    assert(session->gpg.gpgme_set_armor);
    6.69  
    6.70 -    _session->gpg.gpgme_data_new
    6.71 -        = (gpgme_data_new_t) (intptr_t) dlsym(_session->gpgme,
    6.72 +    session->gpg.gpgme_data_new
    6.73 +        = (gpgme_data_new_t) (intptr_t) dlsym(session->gpgme,
    6.74          "gpgme_data_new");
    6.75 -    assert(_session->gpg.gpgme_data_new);
    6.76 +    assert(session->gpg.gpgme_data_new);
    6.77  
    6.78 -    _session->gpg.gpgme_data_new_from_mem
    6.79 -        = (gpgme_data_new_from_mem_t) (intptr_t) dlsym(_session->gpgme,
    6.80 +    session->gpg.gpgme_data_new_from_mem
    6.81 +        = (gpgme_data_new_from_mem_t) (intptr_t) dlsym(session->gpgme,
    6.82          "gpgme_data_new_from_mem");
    6.83 -    assert(_session->gpg.gpgme_data_new_from_mem);
    6.84 +    assert(session->gpg.gpgme_data_new_from_mem);
    6.85  
    6.86 -    _session->gpg.gpgme_data_release
    6.87 -        = (gpgme_data_release_t) (intptr_t) dlsym(_session->gpgme,
    6.88 +    session->gpg.gpgme_data_release
    6.89 +        = (gpgme_data_release_t) (intptr_t) dlsym(session->gpgme,
    6.90          "gpgme_data_release");
    6.91 -    assert(_session->gpg.gpgme_data_release);
    6.92 +    assert(session->gpg.gpgme_data_release);
    6.93  
    6.94 -    _session->gpg.gpgme_data_identify
    6.95 -        = (gpgme_data_identify_t) (intptr_t) dlsym(_session->gpgme,
    6.96 +    session->gpg.gpgme_data_identify
    6.97 +        = (gpgme_data_identify_t) (intptr_t) dlsym(session->gpgme,
    6.98          "gpgme_data_identify");
    6.99 -    assert(_session->gpg.gpgme_data_identify);
   6.100 -    _session->gpg.gpgme_data_seek
   6.101 -        = (gpgme_data_seek_t) (intptr_t) dlsym(_session->gpgme,
   6.102 +    assert(session->gpg.gpgme_data_identify);
   6.103 +
   6.104 +    session->gpg.gpgme_data_seek
   6.105 +        = (gpgme_data_seek_t) (intptr_t) dlsym(session->gpgme,
   6.106          "gpgme_data_seek");
   6.107 -    assert(_session->gpg.gpgme_data_seek);
   6.108 +    assert(session->gpg.gpgme_data_seek);
   6.109  
   6.110 -    _session->gpg.gpgme_data_read
   6.111 -        = (gpgme_data_read_t) (intptr_t) dlsym(_session->gpgme,
   6.112 +    session->gpg.gpgme_data_read
   6.113 +        = (gpgme_data_read_t) (intptr_t) dlsym(session->gpgme,
   6.114          "gpgme_data_read");
   6.115 -    assert(_session->gpg.gpgme_data_read);
   6.116 +    assert(session->gpg.gpgme_data_read);
   6.117  
   6.118 -    _session->gpg.gpgme_op_decrypt
   6.119 -        = (gpgme_op_decrypt_t) (intptr_t) dlsym(_session->gpgme,
   6.120 +    session->gpg.gpgme_op_decrypt
   6.121 +        = (gpgme_op_decrypt_t) (intptr_t) dlsym(session->gpgme,
   6.122          "gpgme_op_decrypt");
   6.123 -    assert(_session->gpg.gpgme_op_decrypt);
   6.124 +    assert(session->gpg.gpgme_op_decrypt);
   6.125  
   6.126 -    _session->gpg.gpgme_op_verify
   6.127 -        = (gpgme_op_verify_t) (intptr_t) dlsym(_session->gpgme,
   6.128 +    session->gpg.gpgme_op_verify
   6.129 +        = (gpgme_op_verify_t) (intptr_t) dlsym(session->gpgme,
   6.130          "gpgme_op_verify");
   6.131 -    assert(_session->gpg.gpgme_op_verify);
   6.132 +    assert(session->gpg.gpgme_op_verify);
   6.133  
   6.134 -    _session->gpg.gpgme_op_decrypt_verify
   6.135 -        = (gpgme_op_decrypt_verify_t) (intptr_t) dlsym(_session->gpgme,
   6.136 +    session->gpg.gpgme_op_decrypt_verify
   6.137 +        = (gpgme_op_decrypt_verify_t) (intptr_t) dlsym(session->gpgme,
   6.138          "gpgme_op_decrypt_verify");
   6.139 -    assert(_session->gpg.gpgme_op_decrypt_verify);
   6.140 +    assert(session->gpg.gpgme_op_decrypt_verify);
   6.141  
   6.142 -    _session->gpg.gpgme_op_decrypt_result
   6.143 -        = (gpgme_op_decrypt_result_t) (intptr_t) dlsym(_session->gpgme,
   6.144 +    session->gpg.gpgme_op_decrypt_result
   6.145 +        = (gpgme_op_decrypt_result_t) (intptr_t) dlsym(session->gpgme,
   6.146          "gpgme_op_decrypt_result");
   6.147 -    assert(_session->gpg.gpgme_op_decrypt_result);
   6.148 +    assert(session->gpg.gpgme_op_decrypt_result);
   6.149  
   6.150 -    _session->gpg.gpgme_op_encrypt_sign
   6.151 -        = (gpgme_op_encrypt_sign_t) (intptr_t) dlsym(_session->gpgme,
   6.152 +    session->gpg.gpgme_op_encrypt_sign
   6.153 +        = (gpgme_op_encrypt_sign_t) (intptr_t) dlsym(session->gpgme,
   6.154          "gpgme_op_encrypt_sign");
   6.155 -    assert(_session->gpg.gpgme_op_encrypt_sign);
   6.156 +    assert(session->gpg.gpgme_op_encrypt_sign);
   6.157  
   6.158 -    _session->gpg.gpgme_op_verify_result
   6.159 -        = (gpgme_op_verify_result_t) (intptr_t) dlsym(_session->gpgme,
   6.160 +    session->gpg.gpgme_op_verify_result
   6.161 +        = (gpgme_op_verify_result_t) (intptr_t) dlsym(session->gpgme,
   6.162          "gpgme_op_verify_result");
   6.163 -    assert(_session->gpg.gpgme_op_verify_result);
   6.164 +    assert(session->gpg.gpgme_op_verify_result);
   6.165  
   6.166 -    _session->gpg.gpgme_signers_clear
   6.167 -        = (gpgme_signers_clear_t) (intptr_t) dlsym(_session->gpgme,
   6.168 +    session->gpg.gpgme_signers_clear
   6.169 +        = (gpgme_signers_clear_t) (intptr_t) dlsym(session->gpgme,
   6.170          "gpgme_signers_clear");
   6.171 -    assert(_session->gpg.gpgme_signers_clear);
   6.172 +    assert(session->gpg.gpgme_signers_clear);
   6.173  
   6.174 -    _session->gpg.gpgme_signers_add
   6.175 -        = (gpgme_signers_add_t) (intptr_t) dlsym(_session->gpgme,
   6.176 +    session->gpg.gpgme_signers_add
   6.177 +        = (gpgme_signers_add_t) (intptr_t) dlsym(session->gpgme,
   6.178          "gpgme_signers_add");
   6.179 -    assert(_session->gpg.gpgme_signers_add);
   6.180 -    _session->gpg.gpgme_get_key
   6.181 -        = (gpgme_get_key_t) (intptr_t) dlsym(_session->gpgme, "gpgme_get_key");
   6.182 -    assert(_session->gpg.gpgme_get_key);
   6.183 +    assert(session->gpg.gpgme_signers_add);
   6.184  
   6.185 -    _session->gpg.gpgme_op_genkey
   6.186 -        = (gpgme_op_genkey_t) (intptr_t) dlsym(_session->gpgme,
   6.187 +    session->gpg.gpgme_get_key
   6.188 +        = (gpgme_get_key_t) (intptr_t) dlsym(session->gpgme, "gpgme_get_key");
   6.189 +    assert(session->gpg.gpgme_get_key);
   6.190 +
   6.191 +    session->gpg.gpgme_op_genkey
   6.192 +        = (gpgme_op_genkey_t) (intptr_t) dlsym(session->gpgme,
   6.193          "gpgme_op_genkey");
   6.194 -    assert(_session->gpg.gpgme_op_genkey);
   6.195 +    assert(session->gpg.gpgme_op_genkey);
   6.196  
   6.197 -    _session->gpg.gpgme_op_genkey_result
   6.198 -        = (gpgme_op_genkey_result_t) (intptr_t) dlsym(_session->gpgme,
   6.199 +    session->gpg.gpgme_op_genkey_result
   6.200 +        = (gpgme_op_genkey_result_t) (intptr_t) dlsym(session->gpgme,
   6.201          "gpgme_op_genkey_result");
   6.202 -    assert(_session->gpg.gpgme_op_genkey_result);
   6.203 +    assert(session->gpg.gpgme_op_genkey_result);
   6.204  
   6.205 -    _session->gpg.gpgme_op_delete = (gpgme_op_delete_t) (intptr_t)
   6.206 -        dlsym(_session->gpgme, "gpgme_op_delete");
   6.207 -    assert(_session->gpg.gpgme_op_delete);
   6.208 +    session->gpg.gpgme_op_delete = (gpgme_op_delete_t) (intptr_t)
   6.209 +        dlsym(session->gpgme, "gpgme_op_delete");
   6.210 +    assert(session->gpg.gpgme_op_delete);
   6.211  
   6.212 -    _session->gpg.gpgme_op_import = (gpgme_op_import_t) (intptr_t)
   6.213 -        dlsym(_session->gpgme, "gpgme_op_import");
   6.214 -    assert(_session->gpg.gpgme_op_import);
   6.215 +    session->gpg.gpgme_op_import = (gpgme_op_import_t) (intptr_t)
   6.216 +        dlsym(session->gpgme, "gpgme_op_import");
   6.217 +    assert(session->gpg.gpgme_op_import);
   6.218  
   6.219 -    _session->gpg.gpgme_op_export = (gpgme_op_export_t) (intptr_t)
   6.220 -        dlsym(_session->gpgme, "gpgme_op_export");
   6.221 -    assert(_session->gpg.gpgme_op_export);
   6.222 +    session->gpg.gpgme_op_export = (gpgme_op_export_t) (intptr_t)
   6.223 +        dlsym(session->gpgme, "gpgme_op_export");
   6.224 +    assert(session->gpg.gpgme_op_export);
   6.225  
   6.226 -    _session->gpg.gpgme_set_keylist_mode = (gpgme_set_keylist_mode_t) (intptr_t)
   6.227 -        dlsym(_session->gpgme, "gpgme_set_keylist_mode");
   6.228 -    assert(_session->gpg.gpgme_set_keylist_mode);
   6.229 +    session->gpg.gpgme_set_keylist_mode = (gpgme_set_keylist_mode_t) (intptr_t)
   6.230 +        dlsym(session->gpgme, "gpgme_set_keylist_mode");
   6.231 +    assert(session->gpg.gpgme_set_keylist_mode);
   6.232  
   6.233 -    _session->gpg.gpgme_get_keylist_mode = (gpgme_get_keylist_mode_t) (intptr_t)
   6.234 -        dlsym(_session->gpgme, "gpgme_get_keylist_mode");
   6.235 -    assert(_session->gpg.gpgme_get_keylist_mode);
   6.236 +    session->gpg.gpgme_get_keylist_mode = (gpgme_get_keylist_mode_t) (intptr_t)
   6.237 +        dlsym(session->gpgme, "gpgme_get_keylist_mode");
   6.238 +    assert(session->gpg.gpgme_get_keylist_mode);
   6.239  
   6.240 -    _session->gpg.gpgme_op_keylist_start = (gpgme_op_keylist_start_t) (intptr_t)
   6.241 -        dlsym(_session->gpgme, "gpgme_op_keylist_start");
   6.242 -    assert(_session->gpg.gpgme_op_keylist_start);
   6.243 +    session->gpg.gpgme_op_keylist_start = (gpgme_op_keylist_start_t) (intptr_t)
   6.244 +        dlsym(session->gpgme, "gpgme_op_keylist_start");
   6.245 +    assert(session->gpg.gpgme_op_keylist_start);
   6.246  
   6.247 -    _session->gpg.gpgme_op_keylist_next = (gpgme_op_keylist_next_t) (intptr_t)
   6.248 -        dlsym(_session->gpgme, "gpgme_op_keylist_next");
   6.249 -    assert(_session->gpg.gpgme_op_keylist_next);
   6.250 +    session->gpg.gpgme_op_keylist_next = (gpgme_op_keylist_next_t) (intptr_t)
   6.251 +        dlsym(session->gpgme, "gpgme_op_keylist_next");
   6.252 +    assert(session->gpg.gpgme_op_keylist_next);
   6.253  
   6.254 -    _session->gpg.gpgme_op_keylist_end = (gpgme_op_keylist_end_t) (intptr_t)
   6.255 -        dlsym(_session->gpgme, "gpgme_op_keylist_end");
   6.256 -    assert(_session->gpg.gpgme_op_keylist_end);
   6.257 +    session->gpg.gpgme_op_keylist_end = (gpgme_op_keylist_end_t) (intptr_t)
   6.258 +        dlsym(session->gpgme, "gpgme_op_keylist_end");
   6.259 +    assert(session->gpg.gpgme_op_keylist_end);
   6.260  
   6.261 -    _session->gpg.gpgme_op_import_keys = (gpgme_op_import_keys_t) (intptr_t)
   6.262 -        dlsym(_session->gpgme, "gpgme_op_import_keys");
   6.263 -    assert(_session->gpg.gpgme_op_import_keys);
   6.264 +    session->gpg.gpgme_op_import_keys = (gpgme_op_import_keys_t) (intptr_t)
   6.265 +        dlsym(session->gpgme, "gpgme_op_import_keys");
   6.266 +    assert(session->gpg.gpgme_op_import_keys);
   6.267  
   6.268 -    _session->gpg.gpgme_key_ref = (gpgme_key_ref_t) (intptr_t)
   6.269 -        dlsym(_session->gpgme, "gpgme_key_ref");
   6.270 -    assert(_session->gpg.gpgme_key_ref);
   6.271 +    session->gpg.gpgme_key_ref = (gpgme_key_ref_t) (intptr_t)
   6.272 +        dlsym(session->gpgme, "gpgme_key_ref");
   6.273 +    assert(session->gpg.gpgme_key_ref);
   6.274  
   6.275 -    _session->gpg.gpgme_key_unref = (gpgme_key_unref_t) (intptr_t)
   6.276 -        dlsym(_session->gpgme, "gpgme_key_unref");
   6.277 -    assert(_session->gpg.gpgme_key_unref);
   6.278 +    session->gpg.gpgme_key_unref = (gpgme_key_unref_t) (intptr_t)
   6.279 +        dlsym(session->gpgme, "gpgme_key_unref");
   6.280 +    assert(session->gpg.gpgme_key_unref);
   6.281  
   6.282      setlocale(LC_ALL, "");
   6.283 -    _session->version = _session->gpg.gpgme_check(NULL);
   6.284 -    _session->gpg.gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL));
   6.285 +    session->version = session->gpg.gpgme_check(NULL);
   6.286 +    session->gpg.gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL));
   6.287  
   6.288 -    gpgme_error = _session->gpg.gpgme_new(&_session->ctx);
   6.289 +    gpgme_error = session->gpg.gpgme_new(&session->ctx);
   6.290      gpgme_error = _GPGERR(gpgme_error);
   6.291      if (gpgme_error != GPG_ERR_NO_ERROR) {
   6.292 -        dlclose(_session->gpgme);
   6.293 -        free(_session);
   6.294 +        dlclose(session->gpgme);
   6.295 +        free(session);
   6.296          return PEP_INIT_GPGME_INIT_FAILED;
   6.297      }
   6.298 -    assert(_session->ctx);
   6.299 +    assert(session->ctx);
   6.300  
   6.301 -    gpgme_error = _session->gpg.gpgme_set_protocol(_session->ctx,
   6.302 +    gpgme_error = session->gpg.gpgme_set_protocol(session->ctx,
   6.303          GPGME_PROTOCOL_OpenPGP);
   6.304      gpgme_error = _GPGERR(gpgme_error);
   6.305      assert(gpgme_error == GPG_ERR_NO_ERROR);
   6.306  
   6.307 -    _session->gpg.gpgme_set_armor(_session->ctx, 1);
   6.308 +    session->gpg.gpgme_set_armor(session->ctx, 1);
   6.309  
   6.310      return PEP_STATUS_OK;
   6.311  }
   6.312  
   6.313  void pgp_release(PEP_SESSION session)
   6.314  {
   6.315 -    pEpSession *_session = (pEpSession *) session;
   6.316 -    if (_session->ctx)
   6.317 -        _session->gpg.gpgme_release(_session->ctx);
   6.318 -    _session->ctx = NULL;
   6.319 -    memset(&(_session->gpg), 0, sizeof(struct gpg_s));
   6.320 -    dlclose(_session->gpgme);
   6.321 +    if (session->ctx)
   6.322 +        session->gpg.gpgme_release(session->ctx);
   6.323 +    session->ctx = NULL;
   6.324 +    memset(&(session->gpg), 0, sizeof(struct gpg_s));
   6.325 +    dlclose(session->gpgme);
   6.326  }
   6.327  
   6.328  PEP_STATUS pgp_decrypt_and_verify(
   6.329 @@ -244,8 +244,6 @@
   6.330      char **ptext, size_t *psize, stringlist_t **keylist
   6.331      )
   6.332  {
   6.333 -    pEpSession *_session = (pEpSession *) session;
   6.334 -
   6.335      PEP_STATUS result;
   6.336      gpgme_error_t gpgme_error;
   6.337      gpgme_data_t cipher, plain;
   6.338 @@ -254,7 +252,7 @@
   6.339      stringlist_t *_keylist = NULL;
   6.340      int i_key = 0;
   6.341  
   6.342 -    assert(_session);
   6.343 +    assert(session);
   6.344      assert(ctext);
   6.345      assert(csize);
   6.346      assert(ptext);
   6.347 @@ -265,7 +263,7 @@
   6.348      *psize = 0;
   6.349      *keylist = NULL;
   6.350  
   6.351 -    gpgme_error = _session->gpg.gpgme_data_new_from_mem(&cipher, ctext, csize, 0);
   6.352 +    gpgme_error = session->gpg.gpgme_data_new_from_mem(&cipher, ctext, csize, 0);
   6.353      gpgme_error = _GPGERR(gpgme_error);
   6.354      assert(gpgme_error == GPG_ERR_NO_ERROR);
   6.355      if (gpgme_error != GPG_ERR_NO_ERROR) {
   6.356 @@ -275,22 +273,22 @@
   6.357              return PEP_UNKNOWN_ERROR;
   6.358      }
   6.359  
   6.360 -    gpgme_error = _session->gpg.gpgme_data_new(&plain);
   6.361 +    gpgme_error = session->gpg.gpgme_data_new(&plain);
   6.362      gpgme_error = _GPGERR(gpgme_error);
   6.363      assert(gpgme_error == GPG_ERR_NO_ERROR);
   6.364      if (gpgme_error != GPG_ERR_NO_ERROR) {
   6.365 -        _session->gpg.gpgme_data_release(cipher);
   6.366 +        session->gpg.gpgme_data_release(cipher);
   6.367          if (gpgme_error == GPG_ERR_ENOMEM)
   6.368              return PEP_OUT_OF_MEMORY;
   6.369          else
   6.370              return PEP_UNKNOWN_ERROR;
   6.371      }
   6.372  
   6.373 -    dt = _session->gpg.gpgme_data_identify(cipher);
   6.374 +    dt = session->gpg.gpgme_data_identify(cipher);
   6.375      switch (dt) {
   6.376      case GPGME_DATA_TYPE_PGP_SIGNED:
   6.377      case GPGME_DATA_TYPE_PGP_OTHER:
   6.378 -        gpgme_error = _session->gpg.gpgme_op_decrypt_verify(_session->ctx, cipher,
   6.379 +        gpgme_error = session->gpg.gpgme_op_decrypt_verify(session->ctx, cipher,
   6.380              plain);
   6.381          gpgme_error = _GPGERR(gpgme_error);
   6.382          assert(gpgme_error != GPG_ERR_INV_VALUE);
   6.383 @@ -302,11 +300,11 @@
   6.384              gpgme_verify_result_t gpgme_verify_result;
   6.385              char *_buffer = NULL;
   6.386              size_t reading;
   6.387 -            size_t length = _session->gpg.gpgme_data_seek(plain, 0, SEEK_END);
   6.388 +            size_t length = session->gpg.gpgme_data_seek(plain, 0, SEEK_END);
   6.389              gpgme_signature_t gpgme_signature;
   6.390  
   6.391              assert(length != -1);
   6.392 -            _session->gpg.gpgme_data_seek(plain, 0, SEEK_SET);
   6.393 +            session->gpg.gpgme_data_seek(plain, 0, SEEK_SET);
   6.394  
   6.395              // TODO: make things less memory consuming
   6.396              // the following algorithm allocates memory for the complete
   6.397 @@ -315,16 +313,16 @@
   6.398              _buffer = malloc(length + 1);
   6.399              assert(_buffer);
   6.400              if (_buffer == NULL) {
   6.401 -                _session->gpg.gpgme_data_release(plain);
   6.402 -                _session->gpg.gpgme_data_release(cipher);
   6.403 +                session->gpg.gpgme_data_release(plain);
   6.404 +                session->gpg.gpgme_data_release(cipher);
   6.405                  return PEP_OUT_OF_MEMORY;
   6.406              }
   6.407  
   6.408 -            reading = _session->gpg.gpgme_data_read(plain, _buffer, length);
   6.409 +            reading = session->gpg.gpgme_data_read(plain, _buffer, length);
   6.410              assert(length == reading);
   6.411  
   6.412              gpgme_verify_result =
   6.413 -                _session->gpg.gpgme_op_verify_result(_session->ctx);
   6.414 +                session->gpg.gpgme_op_verify_result(session->ctx);
   6.415              assert(gpgme_verify_result);
   6.416              gpgme_signature = gpgme_verify_result->signatures;
   6.417  
   6.418 @@ -333,8 +331,8 @@
   6.419                  _keylist = new_stringlist(NULL);
   6.420                  assert(_keylist);
   6.421                  if (_keylist == NULL) {
   6.422 -                    _session->gpg.gpgme_data_release(plain);
   6.423 -                    _session->gpg.gpgme_data_release(cipher);
   6.424 +                    session->gpg.gpgme_data_release(plain);
   6.425 +                    session->gpg.gpgme_data_release(cipher);
   6.426                      free(_buffer);
   6.427                      return PEP_OUT_OF_MEMORY;
   6.428                  }
   6.429 @@ -390,7 +388,7 @@
   6.430              NOT_IMPLEMENTED;
   6.431          default:
   6.432          {
   6.433 -            gpgme_decrypt_result_t gpgme_decrypt_result = _session->gpg.gpgme_op_decrypt_result(_session->ctx);
   6.434 +            gpgme_decrypt_result_t gpgme_decrypt_result = session->gpg.gpgme_op_decrypt_result(session->ctx);
   6.435              result = PEP_DECRYPT_NO_KEY;
   6.436  
   6.437              if (gpgme_decrypt_result != NULL) {
   6.438 @@ -425,8 +423,8 @@
   6.439          result = PEP_DECRYPT_WRONG_FORMAT;
   6.440      }
   6.441  
   6.442 -    _session->gpg.gpgme_data_release(plain);
   6.443 -    _session->gpg.gpgme_data_release(cipher);
   6.444 +    session->gpg.gpgme_data_release(plain);
   6.445 +    session->gpg.gpgme_data_release(cipher);
   6.446      return result;
   6.447  }
   6.448  
   6.449 @@ -435,8 +433,6 @@
   6.450      const char *signature, size_t sig_size, stringlist_t **keylist
   6.451      )
   6.452  {
   6.453 -    pEpSession *_session = (pEpSession *) session;
   6.454 -
   6.455      PEP_STATUS result;
   6.456      gpgme_error_t gpgme_error;
   6.457      gpgme_data_t d_text, d_sig;
   6.458 @@ -451,7 +447,7 @@
   6.459  
   6.460      *keylist = NULL;
   6.461  
   6.462 -    gpgme_error = _session->gpg.gpgme_data_new_from_mem(&d_text, text, size, 0);
   6.463 +    gpgme_error = session->gpg.gpgme_data_new_from_mem(&d_text, text, size, 0);
   6.464      gpgme_error = _GPGERR(gpgme_error);
   6.465      assert(gpgme_error == GPG_ERR_NO_ERROR);
   6.466      if (gpgme_error != GPG_ERR_NO_ERROR) {
   6.467 @@ -461,18 +457,18 @@
   6.468              return PEP_UNKNOWN_ERROR;
   6.469      }
   6.470  
   6.471 -    gpgme_error = _session->gpg.gpgme_data_new_from_mem(&d_sig, signature, sig_size, 0);
   6.472 +    gpgme_error = session->gpg.gpgme_data_new_from_mem(&d_sig, signature, sig_size, 0);
   6.473      gpgme_error = _GPGERR(gpgme_error);
   6.474      assert(gpgme_error == GPG_ERR_NO_ERROR);
   6.475      if (gpgme_error != GPG_ERR_NO_ERROR) {
   6.476 -        _session->gpg.gpgme_data_release(d_text);
   6.477 +        session->gpg.gpgme_data_release(d_text);
   6.478          if (gpgme_error == GPG_ERR_ENOMEM)
   6.479              return PEP_OUT_OF_MEMORY;
   6.480          else
   6.481              return PEP_UNKNOWN_ERROR;
   6.482      }
   6.483  
   6.484 -    gpgme_error = _session->gpg.gpgme_op_verify(_session->ctx, d_sig, d_text, NULL);
   6.485 +    gpgme_error = session->gpg.gpgme_op_verify(session->ctx, d_sig, d_text, NULL);
   6.486      gpgme_error = _GPGERR(gpgme_error);
   6.487      assert(gpgme_error != GPG_ERR_INV_VALUE);
   6.488  
   6.489 @@ -483,7 +479,7 @@
   6.490          gpgme_signature_t gpgme_signature;
   6.491  
   6.492          gpgme_verify_result =
   6.493 -            _session->gpg.gpgme_op_verify_result(_session->ctx);
   6.494 +            session->gpg.gpgme_op_verify_result(session->ctx);
   6.495          assert(gpgme_verify_result);
   6.496          gpgme_signature = gpgme_verify_result->signatures;
   6.497  
   6.498 @@ -492,8 +488,8 @@
   6.499              _keylist = new_stringlist(NULL);
   6.500              assert(_keylist);
   6.501              if (_keylist == NULL) {
   6.502 -                _session->gpg.gpgme_data_release(d_text);
   6.503 -                _session->gpg.gpgme_data_release(d_sig);
   6.504 +                session->gpg.gpgme_data_release(d_text);
   6.505 +                session->gpg.gpgme_data_release(d_sig);
   6.506                  return PEP_OUT_OF_MEMORY;
   6.507              }
   6.508              k = _keylist;
   6.509 @@ -503,8 +499,8 @@
   6.510                  k = stringlist_add(k, gpgme_signature->fpr);
   6.511                  if (k == NULL) {
   6.512                      free_stringlist(_keylist);
   6.513 -                    _session->gpg.gpgme_data_release(d_text);
   6.514 -                    _session->gpg.gpgme_data_release(d_sig);
   6.515 +                    session->gpg.gpgme_data_release(d_text);
   6.516 +                    session->gpg.gpgme_data_release(d_sig);
   6.517                      return PEP_OUT_OF_MEMORY;
   6.518                  }
   6.519                  if (gpgme_signature->summary & GPGME_SIGSUM_RED) {
   6.520 @@ -557,8 +553,8 @@
   6.521          break;
   6.522      }
   6.523  
   6.524 -    _session->gpg.gpgme_data_release(d_text);
   6.525 -    _session->gpg.gpgme_data_release(d_sig);
   6.526 +    session->gpg.gpgme_data_release(d_text);
   6.527 +    session->gpg.gpgme_data_release(d_sig);
   6.528  
   6.529      return result;
   6.530  }
   6.531 @@ -568,8 +564,6 @@
   6.532      size_t psize, char **ctext, size_t *csize
   6.533      )
   6.534  {
   6.535 -    pEpSession *_session = (pEpSession *) session;
   6.536 -
   6.537      PEP_STATUS result;
   6.538      gpgme_error_t gpgme_error;
   6.539      gpgme_data_t plain, cipher;
   6.540 @@ -578,7 +572,7 @@
   6.541      const stringlist_t *_keylist;
   6.542      int i, j;
   6.543  
   6.544 -    assert(_session);
   6.545 +    assert(session);
   6.546      assert(keylist);
   6.547      assert(ptext);
   6.548      assert(psize);
   6.549 @@ -588,7 +582,7 @@
   6.550      *ctext = NULL;
   6.551      *csize = 0;
   6.552  
   6.553 -    gpgme_error = _session->gpg.gpgme_data_new_from_mem(&plain, ptext, psize, 0);
   6.554 +    gpgme_error = session->gpg.gpgme_data_new_from_mem(&plain, ptext, psize, 0);
   6.555      gpgme_error = _GPGERR(gpgme_error);
   6.556      assert(gpgme_error == GPG_ERR_NO_ERROR);
   6.557      if (gpgme_error != GPG_ERR_NO_ERROR) {
   6.558 @@ -598,11 +592,11 @@
   6.559              return PEP_UNKNOWN_ERROR;
   6.560      }
   6.561  
   6.562 -    gpgme_error = _session->gpg.gpgme_data_new(&cipher);
   6.563 +    gpgme_error = session->gpg.gpgme_data_new(&cipher);
   6.564      gpgme_error = _GPGERR(gpgme_error);
   6.565      assert(gpgme_error == GPG_ERR_NO_ERROR);
   6.566      if (gpgme_error != GPG_ERR_NO_ERROR) {
   6.567 -        _session->gpg.gpgme_data_release(plain);
   6.568 +        session->gpg.gpgme_data_release(plain);
   6.569          if (gpgme_error == GPG_ERR_ENOMEM)
   6.570              return PEP_OUT_OF_MEMORY;
   6.571          else
   6.572 @@ -613,16 +607,16 @@
   6.573          sizeof(gpgme_key_t));
   6.574      assert(rcpt);
   6.575      if (rcpt == NULL) {
   6.576 -        _session->gpg.gpgme_data_release(plain);
   6.577 -        _session->gpg.gpgme_data_release(cipher);
   6.578 +        session->gpg.gpgme_data_release(plain);
   6.579 +        session->gpg.gpgme_data_release(cipher);
   6.580          return PEP_OUT_OF_MEMORY;
   6.581      }
   6.582  
   6.583 -    _session->gpg.gpgme_signers_clear(_session->ctx);
   6.584 +    session->gpg.gpgme_signers_clear(session->ctx);
   6.585  
   6.586      for (_keylist = keylist, i = 0; _keylist != NULL; _keylist = _keylist->next, i++) {
   6.587          assert(_keylist->value);
   6.588 -        gpgme_error = _session->gpg.gpgme_get_key(_session->ctx, _keylist->value,
   6.589 +        gpgme_error = session->gpg.gpgme_get_key(session->ctx, _keylist->value,
   6.590              &rcpt[i], 0);
   6.591          gpgme_error = _GPGERR(gpgme_error);
   6.592          assert(gpgme_error != GPG_ERR_ENOMEM);
   6.593 @@ -630,39 +624,39 @@
   6.594          switch (gpgme_error) {
   6.595          case GPG_ERR_ENOMEM:
   6.596              for (j = 0; j<i; j++)
   6.597 -                _session->gpg.gpgme_key_unref(rcpt[j]);
   6.598 +                session->gpg.gpgme_key_unref(rcpt[j]);
   6.599              free(rcpt);
   6.600 -            _session->gpg.gpgme_data_release(plain);
   6.601 -            _session->gpg.gpgme_data_release(cipher);
   6.602 +            session->gpg.gpgme_data_release(plain);
   6.603 +            session->gpg.gpgme_data_release(cipher);
   6.604              return PEP_OUT_OF_MEMORY;
   6.605          case GPG_ERR_NO_ERROR:
   6.606              if (i == 0) {
   6.607 -                gpgme_error_t _gpgme_error = _session->gpg.gpgme_signers_add(_session->ctx, rcpt[0]);
   6.608 +                gpgme_error_t _gpgme_error = session->gpg.gpgme_signers_add(session->ctx, rcpt[0]);
   6.609                  _gpgme_error = _GPGERR(_gpgme_error);
   6.610                  assert(_gpgme_error == GPG_ERR_NO_ERROR);
   6.611              }
   6.612              break;
   6.613          case GPG_ERR_EOF:
   6.614              for (j = 0; j<i; j++)
   6.615 -                _session->gpg.gpgme_key_unref(rcpt[j]);
   6.616 +                session->gpg.gpgme_key_unref(rcpt[j]);
   6.617              free(rcpt);
   6.618 -            _session->gpg.gpgme_data_release(plain);
   6.619 -            _session->gpg.gpgme_data_release(cipher);
   6.620 +            session->gpg.gpgme_data_release(plain);
   6.621 +            session->gpg.gpgme_data_release(cipher);
   6.622              return PEP_KEY_NOT_FOUND;
   6.623          case GPG_ERR_AMBIGUOUS_NAME:
   6.624              for (j = 0; j<i; j++)
   6.625 -                _session->gpg.gpgme_key_unref(rcpt[j]);
   6.626 +                session->gpg.gpgme_key_unref(rcpt[j]);
   6.627              free(rcpt);
   6.628 -            _session->gpg.gpgme_data_release(plain);
   6.629 -            _session->gpg.gpgme_data_release(cipher);
   6.630 +            session->gpg.gpgme_data_release(plain);
   6.631 +            session->gpg.gpgme_data_release(cipher);
   6.632              return PEP_KEY_HAS_AMBIG_NAME;
   6.633          default: // GPG_ERR_INV_VALUE if CTX or R_KEY is not a valid pointer or
   6.634              // FPR is not a fingerprint or key ID
   6.635              for (j = 0; j<i; j++)
   6.636 -                _session->gpg.gpgme_key_unref(rcpt[j]);
   6.637 +                session->gpg.gpgme_key_unref(rcpt[j]);
   6.638              free(rcpt);
   6.639 -            _session->gpg.gpgme_data_release(plain);
   6.640 -            _session->gpg.gpgme_data_release(cipher);
   6.641 +            session->gpg.gpgme_data_release(plain);
   6.642 +            session->gpg.gpgme_data_release(cipher);
   6.643              return PEP_GET_KEY_FAILED;
   6.644          }
   6.645      }
   6.646 @@ -670,7 +664,7 @@
   6.647      // TODO: remove that and replace with proper key management
   6.648      flags = GPGME_ENCRYPT_ALWAYS_TRUST;
   6.649  
   6.650 -    gpgme_error = _session->gpg.gpgme_op_encrypt_sign(_session->ctx, rcpt, flags,
   6.651 +    gpgme_error = session->gpg.gpgme_op_encrypt_sign(session->ctx, rcpt, flags,
   6.652          plain, cipher);
   6.653      gpgme_error = _GPGERR(gpgme_error);
   6.654      switch (gpgme_error) {
   6.655 @@ -678,9 +672,9 @@
   6.656      {
   6.657          char *_buffer = NULL;
   6.658          size_t reading;
   6.659 -        size_t length = _session->gpg.gpgme_data_seek(cipher, 0, SEEK_END);
   6.660 +        size_t length = session->gpg.gpgme_data_seek(cipher, 0, SEEK_END);
   6.661          assert(length != -1);
   6.662 -        _session->gpg.gpgme_data_seek(cipher, 0, SEEK_SET);
   6.663 +        session->gpg.gpgme_data_seek(cipher, 0, SEEK_SET);
   6.664  
   6.665          // TODO: make things less memory consuming
   6.666          // the following algorithm allocates a buffer for the complete text
   6.667 @@ -689,14 +683,14 @@
   6.668          assert(_buffer);
   6.669          if (_buffer == NULL) {
   6.670              for (j = 0; j<stringlist_length(keylist); j++)
   6.671 -                _session->gpg.gpgme_key_unref(rcpt[j]);
   6.672 +                session->gpg.gpgme_key_unref(rcpt[j]);
   6.673              free(rcpt);
   6.674 -            _session->gpg.gpgme_data_release(plain);
   6.675 -            _session->gpg.gpgme_data_release(cipher);
   6.676 +            session->gpg.gpgme_data_release(plain);
   6.677 +            session->gpg.gpgme_data_release(cipher);
   6.678              return PEP_OUT_OF_MEMORY;
   6.679          }
   6.680  
   6.681 -        reading = _session->gpg.gpgme_data_read(cipher, _buffer, length);
   6.682 +        reading = session->gpg.gpgme_data_read(cipher, _buffer, length);
   6.683          assert(length == reading);
   6.684  
   6.685          *ctext = _buffer;
   6.686 @@ -710,10 +704,10 @@
   6.687      }
   6.688  
   6.689      for (j = 0; j<stringlist_length(keylist); j++)
   6.690 -        _session->gpg.gpgme_key_unref(rcpt[j]);
   6.691 +        session->gpg.gpgme_key_unref(rcpt[j]);
   6.692      free(rcpt);
   6.693 -    _session->gpg.gpgme_data_release(plain);
   6.694 -    _session->gpg.gpgme_data_release(cipher);
   6.695 +    session->gpg.gpgme_data_release(plain);
   6.696 +    session->gpg.gpgme_data_release(cipher);
   6.697      return result;
   6.698  }
   6.699  
   6.700 @@ -721,7 +715,6 @@
   6.701      PEP_SESSION session, pEp_identity *identity
   6.702      )
   6.703  {
   6.704 -    pEpSession *_session = (pEpSession *) session;
   6.705      gpgme_error_t gpgme_error;
   6.706      char *parms;
   6.707      const char *template =
   6.708 @@ -748,14 +741,14 @@
   6.709          return PEP_OUT_OF_MEMORY;
   6.710  
   6.711      result = snprintf(parms, PARMS_MAX, template, identity->username,
   6.712 -        identity->address); // , _session->passphrase);
   6.713 +        identity->address); // , session->passphrase);
   6.714      assert(result < PARMS_MAX);
   6.715      if (result >= PARMS_MAX) {
   6.716          free(parms);
   6.717          return PEP_BUFFER_TOO_SMALL;
   6.718      }
   6.719  
   6.720 -    gpgme_error = _session->gpg.gpgme_op_genkey(_session->ctx, parms, NULL, NULL);
   6.721 +    gpgme_error = session->gpg.gpgme_op_genkey(session->ctx, parms, NULL, NULL);
   6.722      gpgme_error = _GPGERR(gpgme_error);
   6.723      free(parms);
   6.724  
   6.725 @@ -771,7 +764,7 @@
   6.726          return PEP_UNKNOWN_ERROR;
   6.727      }
   6.728  
   6.729 -    gpgme_genkey_result = _session->gpg.gpgme_op_genkey_result(_session->ctx);
   6.730 +    gpgme_genkey_result = session->gpg.gpgme_op_genkey_result(session->ctx);
   6.731      assert(gpgme_genkey_result);
   6.732      assert(gpgme_genkey_result->fpr);
   6.733  
   6.734 @@ -782,14 +775,13 @@
   6.735  
   6.736  PEP_STATUS pgp_delete_keypair(PEP_SESSION session, const char *fpr)
   6.737  {
   6.738 -    pEpSession *_session = (pEpSession *) session;
   6.739      gpgme_error_t gpgme_error;
   6.740      gpgme_key_t key;
   6.741  
   6.742      assert(session);
   6.743      assert(fpr);
   6.744  
   6.745 -    gpgme_error = _session->gpg.gpgme_get_key(_session->ctx, fpr, &key, 0);
   6.746 +    gpgme_error = session->gpg.gpgme_get_key(session->ctx, fpr, &key, 0);
   6.747      gpgme_error = _GPGERR(gpgme_error);
   6.748      assert(gpgme_error != GPG_ERR_ENOMEM);
   6.749      switch (gpgme_error) {
   6.750 @@ -808,9 +800,9 @@
   6.751          return PEP_UNKNOWN_ERROR;
   6.752      }
   6.753  
   6.754 -    gpgme_error = _session->gpg.gpgme_op_delete(_session->ctx, key, 1);
   6.755 +    gpgme_error = session->gpg.gpgme_op_delete(session->ctx, key, 1);
   6.756      gpgme_error = _GPGERR(gpgme_error);
   6.757 -    _session->gpg.gpgme_key_unref(key);
   6.758 +    session->gpg.gpgme_key_unref(key);
   6.759      switch (gpgme_error) {
   6.760      case GPG_ERR_NO_ERROR:
   6.761          break;
   6.762 @@ -833,14 +825,13 @@
   6.763  
   6.764  PEP_STATUS pgp_import_key(PEP_SESSION session, const char *key_data, size_t size)
   6.765  {
   6.766 -    pEpSession *_session = (pEpSession *) session;
   6.767      gpgme_error_t gpgme_error;
   6.768      gpgme_data_t dh;
   6.769  
   6.770      assert(session);
   6.771      assert(key_data);
   6.772  
   6.773 -    gpgme_error = _session->gpg.gpgme_data_new_from_mem(&dh, key_data, size, 0);
   6.774 +    gpgme_error = session->gpg.gpgme_data_new_from_mem(&dh, key_data, size, 0);
   6.775      gpgme_error = _GPGERR(gpgme_error);
   6.776      assert(gpgme_error != GPG_ERR_ENOMEM);
   6.777      switch (gpgme_error) {
   6.778 @@ -856,25 +847,25 @@
   6.779          return PEP_UNKNOWN_ERROR;
   6.780      }
   6.781  
   6.782 -    gpgme_error = _session->gpg.gpgme_op_import(_session->ctx, dh);
   6.783 +    gpgme_error = session->gpg.gpgme_op_import(session->ctx, dh);
   6.784      gpgme_error = _GPGERR(gpgme_error);
   6.785      switch (gpgme_error) {
   6.786      case GPG_ERR_NO_ERROR:
   6.787          break;
   6.788      case GPG_ERR_INV_VALUE:
   6.789          assert(0);
   6.790 -        _session->gpg.gpgme_data_release(dh);
   6.791 +        session->gpg.gpgme_data_release(dh);
   6.792          return PEP_UNKNOWN_ERROR;
   6.793      case GPG_ERR_NO_DATA:
   6.794 -        _session->gpg.gpgme_data_release(dh);
   6.795 +        session->gpg.gpgme_data_release(dh);
   6.796          return PEP_ILLEGAL_VALUE;
   6.797      default:
   6.798          assert(0);
   6.799 -        _session->gpg.gpgme_data_release(dh);
   6.800 +        session->gpg.gpgme_data_release(dh);
   6.801          return PEP_UNKNOWN_ERROR;
   6.802      }
   6.803  
   6.804 -    _session->gpg.gpgme_data_release(dh);
   6.805 +    session->gpg.gpgme_data_release(dh);
   6.806      return PEP_STATUS_OK;
   6.807  }
   6.808  
   6.809 @@ -882,7 +873,6 @@
   6.810      PEP_SESSION session, const char *fpr, char **key_data, size_t *size
   6.811      )
   6.812  {
   6.813 -    pEpSession *_session = (pEpSession *) session;
   6.814      gpgme_error_t gpgme_error;
   6.815      gpgme_data_t dh;
   6.816      size_t _size;
   6.817 @@ -894,7 +884,7 @@
   6.818      assert(key_data);
   6.819      assert(size);
   6.820  
   6.821 -    gpgme_error = _session->gpg.gpgme_data_new(&dh);
   6.822 +    gpgme_error = session->gpg.gpgme_data_new(&dh);
   6.823      gpgme_error = _GPGERR(gpgme_error);
   6.824      assert(gpgme_error != GPG_ERR_ENOMEM);
   6.825      switch (gpgme_error) {
   6.826 @@ -910,37 +900,37 @@
   6.827          return PEP_UNKNOWN_ERROR;
   6.828      }
   6.829  
   6.830 -    gpgme_error = _session->gpg.gpgme_op_export(_session->ctx, fpr,
   6.831 +    gpgme_error = session->gpg.gpgme_op_export(session->ctx, fpr,
   6.832          GPGME_EXPORT_MODE_MINIMAL, dh);
   6.833      gpgme_error = _GPGERR(gpgme_error);
   6.834      switch (gpgme_error) {
   6.835      case GPG_ERR_NO_ERROR:
   6.836          break;
   6.837      case GPG_ERR_EOF:
   6.838 -        _session->gpg.gpgme_data_release(dh);
   6.839 +        session->gpg.gpgme_data_release(dh);
   6.840          return PEP_KEY_NOT_FOUND;
   6.841      case GPG_ERR_INV_VALUE:
   6.842          assert(0);
   6.843 -        _session->gpg.gpgme_data_release(dh);
   6.844 +        session->gpg.gpgme_data_release(dh);
   6.845          return PEP_UNKNOWN_ERROR;
   6.846      default:
   6.847          assert(0);
   6.848 -        _session->gpg.gpgme_data_release(dh);
   6.849 +        session->gpg.gpgme_data_release(dh);
   6.850          return PEP_UNKNOWN_ERROR;
   6.851      };
   6.852  
   6.853 -    _size = _session->gpg.gpgme_data_seek(dh, 0, SEEK_END);
   6.854 +    _size = session->gpg.gpgme_data_seek(dh, 0, SEEK_END);
   6.855      assert(_size != -1);
   6.856 -    _session->gpg.gpgme_data_seek(dh, 0, SEEK_SET);
   6.857 +    session->gpg.gpgme_data_seek(dh, 0, SEEK_SET);
   6.858  
   6.859      buffer = malloc(_size + 1);
   6.860      assert(buffer);
   6.861      if (buffer == NULL) {
   6.862 -        _session->gpg.gpgme_data_release(dh);
   6.863 +        session->gpg.gpgme_data_release(dh);
   6.864          return PEP_OUT_OF_MEMORY;
   6.865      }
   6.866  
   6.867 -    reading = _session->gpg.gpgme_data_read(dh, buffer, _size);
   6.868 +    reading = session->gpg.gpgme_data_read(dh, buffer, _size);
   6.869      assert(_size == reading);
   6.870  
   6.871      // safeguard for the naive user
   6.872 @@ -949,55 +939,54 @@
   6.873      *key_data = buffer;
   6.874      *size = _size;
   6.875  
   6.876 -    _session->gpg.gpgme_data_release(dh);
   6.877 +    session->gpg.gpgme_data_release(dh);
   6.878      return PEP_STATUS_OK;
   6.879  }
   6.880  
   6.881 -static void _switch_mode(pEpSession *_session, gpgme_keylist_mode_t remove_mode,
   6.882 +static void _switch_mode(pEpSession *session, gpgme_keylist_mode_t remove_mode,
   6.883      gpgme_keylist_mode_t add_mode)
   6.884  {
   6.885      gpgme_error_t gpgme_error;
   6.886      gpgme_keylist_mode_t mode;
   6.887  
   6.888 -    mode = _session->gpg.gpgme_get_keylist_mode(_session->ctx);
   6.889 +    mode = session->gpg.gpgme_get_keylist_mode(session->ctx);
   6.890  
   6.891      mode &= ~remove_mode;
   6.892      mode |= add_mode;
   6.893  
   6.894 -    gpgme_error = _session->gpg.gpgme_set_keylist_mode(_session->ctx, mode);
   6.895 +    gpgme_error = session->gpg.gpgme_set_keylist_mode(session->ctx, mode);
   6.896      gpgme_error = _GPGERR(gpgme_error);
   6.897      assert(gpgme_error == GPG_ERR_NO_ERROR);
   6.898  }
   6.899  
   6.900  PEP_STATUS pgp_recv_key(PEP_SESSION session, const char *pattern)
   6.901  {
   6.902 -    pEpSession *_session = (pEpSession *) session;
   6.903      gpgme_error_t gpgme_error;
   6.904      gpgme_key_t key;
   6.905  
   6.906      assert(session);
   6.907      assert(pattern);
   6.908  
   6.909 -    _switch_mode(_session, GPGME_KEYLIST_MODE_LOCAL, GPGME_KEYLIST_MODE_EXTERN);
   6.910 +    _switch_mode(session, GPGME_KEYLIST_MODE_LOCAL, GPGME_KEYLIST_MODE_EXTERN);
   6.911  
   6.912 -    gpgme_error = _session->gpg.gpgme_op_keylist_start(_session->ctx, pattern, 0);
   6.913 +    gpgme_error = session->gpg.gpgme_op_keylist_start(session->ctx, pattern, 0);
   6.914      gpgme_error = _GPGERR(gpgme_error);
   6.915      switch (gpgme_error) {
   6.916      case GPG_ERR_NO_ERROR:
   6.917          break;
   6.918      case GPG_ERR_INV_VALUE:
   6.919          assert(0);
   6.920 -        _switch_mode(_session, GPGME_KEYLIST_MODE_EXTERN,
   6.921 +        _switch_mode(session, GPGME_KEYLIST_MODE_EXTERN,
   6.922              GPGME_KEYLIST_MODE_LOCAL);
   6.923          return PEP_UNKNOWN_ERROR;
   6.924      default:
   6.925 -        _switch_mode(_session, GPGME_KEYLIST_MODE_EXTERN,
   6.926 +        _switch_mode(session, GPGME_KEYLIST_MODE_EXTERN,
   6.927              GPGME_KEYLIST_MODE_LOCAL);
   6.928          return PEP_GET_KEY_FAILED;
   6.929      };
   6.930  
   6.931      do {
   6.932 -        gpgme_error = _session->gpg.gpgme_op_keylist_next(_session->ctx, &key);
   6.933 +        gpgme_error = session->gpg.gpgme_op_keylist_next(session->ctx, &key);
   6.934          gpgme_error = _GPGERR(gpgme_error);
   6.935          assert(gpgme_error != GPG_ERR_INV_VALUE);
   6.936          switch (gpgme_error) {
   6.937 @@ -1011,32 +1000,26 @@
   6.938              keys[0] = key;
   6.939              keys[1] = NULL;
   6.940  
   6.941 -            gpgme_error = _session->gpg.gpgme_op_import_keys(_session->ctx, keys);
   6.942 +            gpgme_error = session->gpg.gpgme_op_import_keys(session->ctx, keys);
   6.943              gpgme_error = _GPGERR(gpgme_error);
   6.944 -            _session->gpg.gpgme_key_unref(key);
   6.945 +            session->gpg.gpgme_key_unref(key);
   6.946              assert(gpgme_error != GPG_ERR_INV_VALUE);
   6.947              assert(gpgme_error != GPG_ERR_CONFLICT);
   6.948          }
   6.949              break;
   6.950          case GPG_ERR_ENOMEM:
   6.951 -            _switch_mode(_session, GPGME_KEYLIST_MODE_EXTERN,
   6.952 +            _switch_mode(session, GPGME_KEYLIST_MODE_EXTERN,
   6.953                  GPGME_KEYLIST_MODE_LOCAL);
   6.954 -            _session->gpg.gpgme_op_keylist_end(_session->ctx);
   6.955 +            session->gpg.gpgme_op_keylist_end(session->ctx);
   6.956              return PEP_OUT_OF_MEMORY;
   6.957          default:
   6.958 -            // BUG: GPGME returns an illegal value instead of GPG_ERR_EOF after
   6.959 -            // reading first key
   6.960 -#ifndef NDEBUG
   6.961 -            fprintf(stderr, "warning: unknown result 0x%x of"
   6.962 -                " gpgme_op_keylist_next()\n", gpgme_error);
   6.963 -#endif
   6.964 -            gpgme_error = GPG_ERR_EOF;
   6.965 -            break;
   6.966 +            session->gpg.gpgme_op_keylist_end(session->ctx);
   6.967 +            return PEP_UNKNOWN_ERROR;
   6.968          };
   6.969      } while (gpgme_error != GPG_ERR_EOF);
   6.970  
   6.971 -    _session->gpg.gpgme_op_keylist_end(_session->ctx);
   6.972 -    _switch_mode(_session, GPGME_KEYLIST_MODE_EXTERN,
   6.973 +    session->gpg.gpgme_op_keylist_end(session->ctx);
   6.974 +    _switch_mode(session, GPGME_KEYLIST_MODE_EXTERN,
   6.975          GPGME_KEYLIST_MODE_LOCAL);
   6.976      return PEP_STATUS_OK;
   6.977  }
   6.978 @@ -1045,7 +1028,6 @@
   6.979      PEP_SESSION session, const char *pattern, stringlist_t **keylist
   6.980      )
   6.981  {
   6.982 -    pEpSession *_session = (pEpSession *) session;
   6.983      gpgme_error_t gpgme_error;
   6.984      gpgme_key_t key;
   6.985      stringlist_t *_keylist;
   6.986 @@ -1057,7 +1039,7 @@
   6.987  
   6.988      *keylist = NULL;
   6.989  
   6.990 -    gpgme_error = _session->gpg.gpgme_op_keylist_start(_session->ctx, pattern, 0);
   6.991 +    gpgme_error = session->gpg.gpgme_op_keylist_start(session->ctx, pattern, 0);
   6.992      gpgme_error = _GPGERR(gpgme_error);
   6.993      switch (gpgme_error) {
   6.994      case GPG_ERR_NO_ERROR:
   6.995 @@ -1066,6 +1048,7 @@
   6.996          assert(0);
   6.997          return PEP_UNKNOWN_ERROR;
   6.998      default:
   6.999 +        session->gpg.gpgme_op_keylist_end(session->ctx);
  6.1000          return PEP_GET_KEY_FAILED;
  6.1001      };
  6.1002  
  6.1003 @@ -1073,7 +1056,7 @@
  6.1004      stringlist_t *_k = _keylist;
  6.1005  
  6.1006      do {
  6.1007 -        gpgme_error = _session->gpg.gpgme_op_keylist_next(_session->ctx, &key);
  6.1008 +        gpgme_error = session->gpg.gpgme_op_keylist_next(session->ctx, &key);
  6.1009          gpgme_error = _GPGERR(gpgme_error);
  6.1010          assert(gpgme_error != GPG_ERR_INV_VALUE);
  6.1011          switch (gpgme_error) {
  6.1012 @@ -1090,34 +1073,27 @@
  6.1013                  break;
  6.1014          case GPG_ERR_ENOMEM:
  6.1015              free_stringlist(_keylist);
  6.1016 -            _session->gpg.gpgme_op_keylist_end(_session->ctx);
  6.1017 +            session->gpg.gpgme_op_keylist_end(session->ctx);
  6.1018              return PEP_OUT_OF_MEMORY;
  6.1019          default:
  6.1020 -            // BUG: GPGME returns an illegal value instead of GPG_ERR_EOF after
  6.1021 -            // reading first key
  6.1022 -#ifndef NDEBUG
  6.1023 -            fprintf(stderr, "warning: unknown result 0x%x of"
  6.1024 -                " gpgme_op_keylist_next()\n", gpgme_error);
  6.1025 -#endif
  6.1026 -            gpgme_error = GPG_ERR_EOF;
  6.1027 -            break;
  6.1028 +            session->gpg.gpgme_op_keylist_end(session->ctx);
  6.1029 +            return PEP_UNKNOWN_ERROR;
  6.1030          };
  6.1031      } while (gpgme_error != GPG_ERR_EOF);
  6.1032  
  6.1033 -    _session->gpg.gpgme_op_keylist_end(_session->ctx);
  6.1034 +    session->gpg.gpgme_op_keylist_end(session->ctx);
  6.1035      *keylist = _keylist;
  6.1036      return PEP_STATUS_OK;
  6.1037  }
  6.1038  
  6.1039  PEP_STATUS pgp_send_key(PEP_SESSION session, const char *pattern)
  6.1040  {
  6.1041 -    pEpSession *_session = (pEpSession *) session;
  6.1042      gpgme_error_t gpgme_error;
  6.1043  
  6.1044      assert(session);
  6.1045      assert(pattern);
  6.1046  
  6.1047 -    gpgme_error = _session->gpg.gpgme_op_export(_session->ctx, pattern,
  6.1048 +    gpgme_error = session->gpg.gpgme_op_export(session->ctx, pattern,
  6.1049          GPGME_EXPORT_MODE_EXTERN, NULL);
  6.1050      gpgme_error = _GPGERR(gpgme_error);
  6.1051      assert(gpgme_error != GPG_ERR_INV_VALUE);
  6.1052 @@ -1134,7 +1110,6 @@
  6.1053      PEP_comm_type *comm_type
  6.1054      )
  6.1055  {
  6.1056 -    pEpSession *_session = (pEpSession *) session;
  6.1057      PEP_STATUS status = PEP_STATUS_OK;
  6.1058      gpgme_error_t gpgme_error;
  6.1059      gpgme_key_t key;
  6.1060 @@ -1145,7 +1120,7 @@
  6.1061  
  6.1062      *comm_type = PEP_ct_unknown;
  6.1063  
  6.1064 -    gpgme_error = _session->gpg.gpgme_op_keylist_start(_session->ctx, fpr, 0);
  6.1065 +    gpgme_error = session->gpg.gpgme_op_keylist_start(session->ctx, fpr, 0);
  6.1066      gpgme_error = _GPGERR(gpgme_error);
  6.1067      switch (gpgme_error) {
  6.1068      case GPG_ERR_NO_ERROR:
  6.1069 @@ -1157,12 +1132,12 @@
  6.1070          return PEP_GET_KEY_FAILED;
  6.1071      };
  6.1072  
  6.1073 -    gpgme_error = _session->gpg.gpgme_op_keylist_next(_session->ctx, &key);
  6.1074 +    gpgme_error = session->gpg.gpgme_op_keylist_next(session->ctx, &key);
  6.1075      gpgme_error = _GPGERR(gpgme_error);
  6.1076      assert(gpgme_error != GPG_ERR_INV_VALUE);
  6.1077  
  6.1078      if (key == NULL) {
  6.1079 -        _session->gpg.gpgme_op_keylist_end(_session->ctx);
  6.1080 +        session->gpg.gpgme_op_keylist_end(session->ctx);
  6.1081          return PEP_KEY_NOT_FOUND;
  6.1082      }
  6.1083  
  6.1084 @@ -1176,7 +1151,7 @@
  6.1085          break;
  6.1086      default:
  6.1087          *comm_type = PEP_ct_unknown;
  6.1088 -        _session->gpg.gpgme_op_keylist_end(_session->ctx);
  6.1089 +        session->gpg.gpgme_op_keylist_end(session->ctx);
  6.1090          return PEP_STATUS_OK;
  6.1091      }
  6.1092  
  6.1093 @@ -1214,21 +1189,15 @@
  6.1094          }
  6.1095          break;
  6.1096      case GPG_ERR_ENOMEM:
  6.1097 -        _session->gpg.gpgme_op_keylist_end(_session->ctx);
  6.1098 +        session->gpg.gpgme_op_keylist_end(session->ctx);
  6.1099          *comm_type = PEP_ct_unknown;
  6.1100          return PEP_OUT_OF_MEMORY;
  6.1101      default:
  6.1102 -        // BUG: GPGME returns an illegal value instead of GPG_ERR_EOF after
  6.1103 -        // reading first key
  6.1104 -#ifndef NDEBUG
  6.1105 -        fprintf(stderr, "warning: unknown result 0x%x of"
  6.1106 -            " gpgme_op_keylist_next()\n", gpgme_error);
  6.1107 -#endif
  6.1108 -        gpgme_error = GPG_ERR_EOF;
  6.1109 -        break;
  6.1110 +        session->gpg.gpgme_op_keylist_end(session->ctx);
  6.1111 +        return PEP_UNKNOWN_ERROR;
  6.1112      };
  6.1113  
  6.1114 -    _session->gpg.gpgme_op_keylist_end(_session->ctx);
  6.1115 +    session->gpg.gpgme_op_keylist_end(session->ctx);
  6.1116  
  6.1117      return status;
  6.1118  }
     7.1 --- a/src/sqlite3.c	Fri Jan 16 18:39:27 2015 +0100
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,148882 +0,0 @@
     7.4 -/******************************************************************************
     7.5 -** This file is an amalgamation of many separate C source files from SQLite
     7.6 -** version 3.8.6.  By combining all the individual C code files into this 
     7.7 -** single large file, the entire code can be compiled as a single translation
     7.8 -** unit.  This allows many compilers to do optimizations that would not be
     7.9 -** possible if the files were compiled separately.  Performance improvements
    7.10 -** of 5% or more are commonly seen when SQLite is compiled as a single
    7.11 -** translation unit.
    7.12 -**
    7.13 -** This file is all you need to compile SQLite.  To use SQLite in other
    7.14 -** programs, you need this file and the "sqlite3.h" header file that defines
    7.15 -** the programming interface to the SQLite library.  (If you do not have 
    7.16 -** the "sqlite3.h" header file at hand, you will find a copy embedded within
    7.17 -** the text of this file.  Search for "Begin file sqlite3.h" to find the start
    7.18 -** of the embedded sqlite3.h header file.) Additional code files may be needed
    7.19 -** if you want a wrapper to interface SQLite with your choice of programming
    7.20 -** language. The code for the "sqlite3" command-line shell is also in a
    7.21 -** separate file. This file contains only code for the core SQLite library.
    7.22 -*/
    7.23 -#define SQLITE_CORE 1
    7.24 -#define SQLITE_AMALGAMATION 1
    7.25 -#ifndef SQLITE_PRIVATE
    7.26 -# define SQLITE_PRIVATE static
    7.27 -#endif
    7.28 -#ifndef SQLITE_API
    7.29 -# define SQLITE_API
    7.30 -#endif
    7.31 -/************** Begin file sqliteInt.h ***************************************/
    7.32 -/*
    7.33 -** 2001 September 15
    7.34 -**
    7.35 -** The author disclaims copyright to this source code.  In place of
    7.36 -** a legal notice, here is a blessing:
    7.37 -**
    7.38 -**    May you do good and not evil.
    7.39 -**    May you find forgiveness for yourself and forgive others.
    7.40 -**    May you share freely, never taking more than you give.
    7.41 -**
    7.42 -*************************************************************************
    7.43 -** Internal interface definitions for SQLite.
    7.44 -**
    7.45 -*/
    7.46 -#ifndef _SQLITEINT_H_
    7.47 -#define _SQLITEINT_H_
    7.48 -
    7.49 -/*
    7.50 -** These #defines should enable >2GB file support on POSIX if the
    7.51 -** underlying operating system supports it.  If the OS lacks
    7.52 -** large file support, or if the OS is windows, these should be no-ops.
    7.53 -**
    7.54 -** Ticket #2739:  The _LARGEFILE_SOURCE macro must appear before any
    7.55 -** system #includes.  Hence, this block of code must be the very first
    7.56 -** code in all source files.
    7.57 -**
    7.58 -** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
    7.59 -** on the compiler command line.  This is necessary if you are compiling
    7.60 -** on a recent machine (ex: Red Hat 7.2) but you want your code to work
    7.61 -** on an older machine (ex: Red Hat 6.0).  If you compile on Red Hat 7.2
    7.62 -** without this option, LFS is enable.  But LFS does not exist in the kernel
    7.63 -** in Red Hat 6.0, so the code won't work.  Hence, for maximum binary
    7.64 -** portability you should omit LFS.
    7.65 -**
    7.66 -** The previous paragraph was written in 2005.  (This paragraph is written
    7.67 -** on 2008-11-28.) These days, all Linux kernels support large files, so
    7.68 -** you should probably leave LFS enabled.  But some embedded platforms might
    7.69 -** lack LFS in which case the SQLITE_DISABLE_LFS macro might still be useful.
    7.70 -**
    7.71 -** Similar is true for Mac OS X.  LFS is only supported on Mac OS X 9 and later.
    7.72 -*/
    7.73 -#ifndef SQLITE_DISABLE_LFS
    7.74 -# define _LARGE_FILE       1
    7.75 -# ifndef _FILE_OFFSET_BITS
    7.76 -#   define _FILE_OFFSET_BITS 64
    7.77 -# endif
    7.78 -# define _LARGEFILE_SOURCE 1
    7.79 -#endif
    7.80 -
    7.81 -/*
    7.82 -** For MinGW, check to see if we can include the header file containing its
    7.83 -** version information, among other things.  Normally, this internal MinGW
    7.84 -** header file would [only] be included automatically by other MinGW header
    7.85 -** files; however, the contained version information is now required by this
    7.86 -** header file to work around binary compatibility issues (see below) and
    7.87 -** this is the only known way to reliably obtain it.  This entire #if block
    7.88 -** would be completely unnecessary if there was any other way of detecting
    7.89 -** MinGW via their preprocessor (e.g. if they customized their GCC to define
    7.90 -** some MinGW-specific macros).  When compiling for MinGW, either the
    7.91 -** _HAVE_MINGW_H or _HAVE__MINGW_H (note the extra underscore) macro must be
    7.92 -** defined; otherwise, detection of conditions specific to MinGW will be
    7.93 -** disabled.
    7.94 -*/
    7.95 -#if defined(_HAVE_MINGW_H)
    7.96 -# include "mingw.h"
    7.97 -#elif defined(_HAVE__MINGW_H)
    7.98 -# include "_mingw.h"
    7.99 -#endif
   7.100 -
   7.101 -/*
   7.102 -** For MinGW version 4.x (and higher), check to see if the _USE_32BIT_TIME_T
   7.103 -** define is required to maintain binary compatibility with the MSVC runtime
   7.104 -** library in use (e.g. for Windows XP).
   7.105 -*/
   7.106 -#if !defined(_USE_32BIT_TIME_T) && !defined(_USE_64BIT_TIME_T) && \
   7.107 -    defined(_WIN32) && !defined(_WIN64) && \
   7.108 -    defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION >= 4 && \
   7.109 -    defined(__MSVCRT__)
   7.110 -# define _USE_32BIT_TIME_T
   7.111 -#endif
   7.112 -
   7.113 -/* The public SQLite interface.  The _FILE_OFFSET_BITS macro must appear
   7.114 -** first in QNX.  Also, the _USE_32BIT_TIME_T macro must appear first for
   7.115 -** MinGW.
   7.116 -*/
   7.117 -/************** Include sqlite3.h in the middle of sqliteInt.h ***************/
   7.118 -/************** Begin file sqlite3.h *****************************************/
   7.119 -/*
   7.120 -** 2001 September 15
   7.121 -**
   7.122 -** The author disclaims copyright to this source code.  In place of
   7.123 -** a legal notice, here is a blessing:
   7.124 -**
   7.125 -**    May you do good and not evil.
   7.126 -**    May you find forgiveness for yourself and forgive others.
   7.127 -**    May you share freely, never taking more than you give.
   7.128 -**
   7.129 -*************************************************************************
   7.130 -** This header file defines the interface that the SQLite library
   7.131 -** presents to client programs.  If a C-function, structure, datatype,
   7.132 -** or constant definition does not appear in this file, then it is
   7.133 -** not a published API of SQLite, is subject to change without
   7.134 -** notice, and should not be referenced by programs that use SQLite.
   7.135 -**
   7.136 -** Some of the definitions that are in this file are marked as
   7.137 -** "experimental".  Experimental interfaces are normally new
   7.138 -** features recently added to SQLite.  We do not anticipate changes
   7.139 -** to experimental interfaces but reserve the right to make minor changes
   7.140 -** if experience from use "in the wild" suggest such changes are prudent.
   7.141 -**
   7.142 -** The official C-language API documentation for SQLite is derived
   7.143 -** from comments in this file.  This file is the authoritative source
   7.144 -** on how SQLite interfaces are suppose to operate.
   7.145 -**
   7.146 -** The name of this file under configuration management is "sqlite.h.in".
   7.147 -** The makefile makes some minor changes to this file (such as inserting
   7.148 -** the version number) and changes its name to "sqlite3.h" as
   7.149 -** part of the build process.
   7.150 -*/
   7.151 -#ifndef _SQLITE3_H_
   7.152 -#define _SQLITE3_H_
   7.153 -#include <stdarg.h>     /* Needed for the definition of va_list */
   7.154 -
   7.155 -/*
   7.156 -** Make sure we can call this stuff from C++.
   7.157 -*/
   7.158 -#if 0
   7.159 -extern "C" {
   7.160 -#endif
   7.161 -
   7.162 -
   7.163 -/*
   7.164 -** Add the ability to override 'extern'
   7.165 -*/
   7.166 -#ifndef SQLITE_EXTERN
   7.167 -# define SQLITE_EXTERN extern
   7.168 -#endif
   7.169 -
   7.170 -#ifndef SQLITE_API
   7.171 -# define SQLITE_API
   7.172 -#endif
   7.173 -
   7.174 -
   7.175 -/*
   7.176 -** These no-op macros are used in front of interfaces to mark those
   7.177 -** interfaces as either deprecated or experimental.  New applications
   7.178 -** should not use deprecated interfaces - they are support for backwards
   7.179 -** compatibility only.  Application writers should be aware that
   7.180 -** experimental interfaces are subject to change in point releases.
   7.181 -**
   7.182 -** These macros used to resolve to various kinds of compiler magic that
   7.183 -** would generate warning messages when they were used.  But that
   7.184 -** compiler magic ended up generating such a flurry of bug reports
   7.185 -** that we have taken it all out and gone back to using simple
   7.186 -** noop macros.
   7.187 -*/
   7.188 -#define SQLITE_DEPRECATED
   7.189 -#define SQLITE_EXPERIMENTAL
   7.190 -
   7.191 -/*
   7.192 -** Ensure these symbols were not defined by some previous header file.
   7.193 -*/
   7.194 -#ifdef SQLITE_VERSION
   7.195 -# undef SQLITE_VERSION
   7.196 -#endif
   7.197 -#ifdef SQLITE_VERSION_NUMBER
   7.198 -# undef SQLITE_VERSION_NUMBER
   7.199 -#endif
   7.200 -
   7.201 -/*
   7.202 -** CAPI3REF: Compile-Time Library Version Numbers
   7.203 -**
   7.204 -** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header
   7.205 -** evaluates to a string literal that is the SQLite version in the
   7.206 -** format "X.Y.Z" where X is the major version number (always 3 for
   7.207 -** SQLite3) and Y is the minor version number and Z is the release number.)^
   7.208 -** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
   7.209 -** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
   7.210 -** numbers used in [SQLITE_VERSION].)^
   7.211 -** The SQLITE_VERSION_NUMBER for any given release of SQLite will also
   7.212 -** be larger than the release from which it is derived.  Either Y will
   7.213 -** be held constant and Z will be incremented or else Y will be incremented
   7.214 -** and Z will be reset to zero.
   7.215 -**
   7.216 -** Since version 3.6.18, SQLite source code has been stored in the
   7.217 -** <a href="http://www.fossil-scm.org/">Fossil configuration management
   7.218 -** system</a>.  ^The SQLITE_SOURCE_ID macro evaluates to
   7.219 -** a string which identifies a particular check-in of SQLite
   7.220 -** within its configuration management system.  ^The SQLITE_SOURCE_ID
   7.221 -** string contains the date and time of the check-in (UTC) and an SHA1
   7.222 -** hash of the entire source tree.
   7.223 -**
   7.224 -** See also: [sqlite3_libversion()],
   7.225 -** [sqlite3_libversion_number()], [sqlite3_sourceid()],
   7.226 -** [sqlite_version()] and [sqlite_source_id()].
   7.227 -*/
   7.228 -#define SQLITE_VERSION        "3.8.6"
   7.229 -#define SQLITE_VERSION_NUMBER 3008006
   7.230 -#define SQLITE_SOURCE_ID      "2014-08-15 11:46:33 9491ba7d738528f168657adb43a198238abde19e"
   7.231 -
   7.232 -/*
   7.233 -** CAPI3REF: Run-Time Library Version Numbers
   7.234 -** KEYWORDS: sqlite3_version, sqlite3_sourceid
   7.235 -**
   7.236 -** These interfaces provide the same information as the [SQLITE_VERSION],
   7.237 -** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
   7.238 -** but are associated with the library instead of the header file.  ^(Cautious
   7.239 -** programmers might include assert() statements in their application to
   7.240 -** verify that values returned by these interfaces match the macros in
   7.241 -** the header, and thus insure that the application is
   7.242 -** compiled with matching library and header files.
   7.243 -**
   7.244 -** <blockquote><pre>
   7.245 -** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
   7.246 -** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
   7.247 -** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
   7.248 -** </pre></blockquote>)^
   7.249 -**
   7.250 -** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
   7.251 -** macro.  ^The sqlite3_libversion() function returns a pointer to the
   7.252 -** to the sqlite3_version[] string constant.  The sqlite3_libversion()
   7.253 -** function is provided for use in DLLs since DLL users usually do not have
   7.254 -** direct access to string constants within the DLL.  ^The
   7.255 -** sqlite3_libversion_number() function returns an integer equal to
   7.256 -** [SQLITE_VERSION_NUMBER].  ^The sqlite3_sourceid() function returns 
   7.257 -** a pointer to a string constant whose value is the same as the 
   7.258 -** [SQLITE_SOURCE_ID] C preprocessor macro.
   7.259 -**
   7.260 -** See also: [sqlite_version()] and [sqlite_source_id()].
   7.261 -*/
   7.262 -SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
   7.263 -SQLITE_API const char *sqlite3_libversion(void);
   7.264 -SQLITE_API const char *sqlite3_sourceid(void);
   7.265 -SQLITE_API int sqlite3_libversion_number(void);
   7.266 -
   7.267 -/*
   7.268 -** CAPI3REF: Run-Time Library Compilation Options Diagnostics
   7.269 -**
   7.270 -** ^The sqlite3_compileoption_used() function returns 0 or 1 
   7.271 -** indicating whether the specified option was defined at 
   7.272 -** compile time.  ^The SQLITE_ prefix may be omitted from the 
   7.273 -** option name passed to sqlite3_compileoption_used().  
   7.274 -**
   7.275 -** ^The sqlite3_compileoption_get() function allows iterating
   7.276 -** over the list of options that were defined at compile time by
   7.277 -** returning the N-th compile time option string.  ^If N is out of range,
   7.278 -** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_ 
   7.279 -** prefix is omitted from any strings returned by 
   7.280 -** sqlite3_compileoption_get().
   7.281 -**
   7.282 -** ^Support for the diagnostic functions sqlite3_compileoption_used()
   7.283 -** and sqlite3_compileoption_get() may be omitted by specifying the 
   7.284 -** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.
   7.285 -**
   7.286 -** See also: SQL functions [sqlite_compileoption_used()] and
   7.287 -** [sqlite_compileoption_get()] and the [compile_options pragma].
   7.288 -*/
   7.289 -#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
   7.290 -SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
   7.291 -SQLITE_API const char *sqlite3_compileoption_get(int N);
   7.292 -#endif
   7.293 -
   7.294 -/*
   7.295 -** CAPI3REF: Test To See If The Library Is Threadsafe
   7.296 -**
   7.297 -** ^The sqlite3_threadsafe() function returns zero if and only if
   7.298 -** SQLite was compiled with mutexing code omitted due to the
   7.299 -** [SQLITE_THREADSAFE] compile-time option being set to 0.
   7.300 -**
   7.301 -** SQLite can be compiled with or without mutexes.  When
   7.302 -** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
   7.303 -** are enabled and SQLite is threadsafe.  When the
   7.304 -** [SQLITE_THREADSAFE] macro is 0, 
   7.305 -** the mutexes are omitted.  Without the mutexes, it is not safe
   7.306 -** to use SQLite concurrently from more than one thread.
   7.307 -**
   7.308 -** Enabling mutexes incurs a measurable performance penalty.
   7.309 -** So if speed is of utmost importance, it makes sense to disable
   7.310 -** the mutexes.  But for maximum safety, mutexes should be enabled.
   7.311 -** ^The default behavior is for mutexes to be enabled.
   7.312 -**
   7.313 -** This interface can be used by an application to make sure that the
   7.314 -** version of SQLite that it is linking against was compiled with
   7.315 -** the desired setting of the [SQLITE_THREADSAFE] macro.
   7.316 -**
   7.317 -** This interface only reports on the compile-time mutex setting
   7.318 -** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with
   7.319 -** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
   7.320 -** can be fully or partially disabled using a call to [sqlite3_config()]
   7.321 -** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
   7.322 -** or [SQLITE_CONFIG_MUTEX].  ^(The return value of the
   7.323 -** sqlite3_threadsafe() function shows only the compile-time setting of
   7.324 -** thread safety, not any run-time changes to that setting made by
   7.325 -** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
   7.326 -** is unchanged by calls to sqlite3_config().)^
   7.327 -**
   7.328 -** See the [threading mode] documentation for additional information.
   7.329 -*/
   7.330 -SQLITE_API int sqlite3_threadsafe(void);
   7.331 -
   7.332 -/*
   7.333 -** CAPI3REF: Database Connection Handle
   7.334 -** KEYWORDS: {database connection} {database connections}
   7.335 -**
   7.336 -** Each open SQLite database is represented by a pointer to an instance of
   7.337 -** the opaque structure named "sqlite3".  It is useful to think of an sqlite3
   7.338 -** pointer as an object.  The [sqlite3_open()], [sqlite3_open16()], and
   7.339 -** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
   7.340 -** and [sqlite3_close_v2()] are its destructors.  There are many other
   7.341 -** interfaces (such as
   7.342 -** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
   7.343 -** [sqlite3_busy_timeout()] to name but three) that are methods on an
   7.344 -** sqlite3 object.
   7.345 -*/
   7.346 -typedef struct sqlite3 sqlite3;
   7.347 -
   7.348 -/*
   7.349 -** CAPI3REF: 64-Bit Integer Types
   7.350 -** KEYWORDS: sqlite_int64 sqlite_uint64
   7.351 -**
   7.352 -** Because there is no cross-platform way to specify 64-bit integer types
   7.353 -** SQLite includes typedefs for 64-bit signed and unsigned integers.
   7.354 -**
   7.355 -** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
   7.356 -** The sqlite_int64 and sqlite_uint64 types are supported for backwards
   7.357 -** compatibility only.
   7.358 -**
   7.359 -** ^The sqlite3_int64 and sqlite_int64 types can store integer values
   7.360 -** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The
   7.361 -** sqlite3_uint64 and sqlite_uint64 types can store integer values 
   7.362 -** between 0 and +18446744073709551615 inclusive.
   7.363 -*/
   7.364 -#ifdef SQLITE_INT64_TYPE
   7.365 -  typedef SQLITE_INT64_TYPE sqlite_int64;
   7.366 -  typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
   7.367 -#elif defined(_MSC_VER) || defined(__BORLANDC__)
   7.368 -  typedef __int64 sqlite_int64;
   7.369 -  typedef unsigned __int64 sqlite_uint64;
   7.370 -#else
   7.371 -  typedef long long int sqlite_int64;
   7.372 -  typedef unsigned long long int sqlite_uint64;
   7.373 -#endif
   7.374 -typedef sqlite_int64 sqlite3_int64;
   7.375 -typedef sqlite_uint64 sqlite3_uint64;
   7.376 -
   7.377 -/*
   7.378 -** If compiling for a processor that lacks floating point support,
   7.379 -** substitute integer for floating-point.
   7.380 -*/
   7.381 -#ifdef SQLITE_OMIT_FLOATING_POINT
   7.382 -# define double sqlite3_int64
   7.383 -#endif
   7.384 -
   7.385 -/*
   7.386 -** CAPI3REF: Closing A Database Connection
   7.387 -**
   7.388 -** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
   7.389 -** for the [sqlite3] object.
   7.390 -** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if
   7.391 -** the [sqlite3] object is successfully destroyed and all associated
   7.392 -** resources are deallocated.
   7.393 -**
   7.394 -** ^If the database connection is associated with unfinalized prepared
   7.395 -** statements or unfinished sqlite3_backup objects then sqlite3_close()
   7.396 -** will leave the database connection open and return [SQLITE_BUSY].
   7.397 -** ^If sqlite3_close_v2() is called with unfinalized prepared statements
   7.398 -** and/or unfinished sqlite3_backups, then the database connection becomes
   7.399 -** an unusable "zombie" which will automatically be deallocated when the
   7.400 -** last prepared statement is finalized or the last sqlite3_backup is
   7.401 -** finished.  The sqlite3_close_v2() interface is intended for use with
   7.402 -** host languages that are garbage collected, and where the order in which
   7.403 -** destructors are called is arbitrary.
   7.404 -**
   7.405 -** Applications should [sqlite3_finalize | finalize] all [prepared statements],
   7.406 -** [sqlite3_blob_close | close] all [BLOB handles], and 
   7.407 -** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated
   7.408 -** with the [sqlite3] object prior to attempting to close the object.  ^If
   7.409 -** sqlite3_close_v2() is called on a [database connection] that still has
   7.410 -** outstanding [prepared statements], [BLOB handles], and/or
   7.411 -** [sqlite3_backup] objects then it returns [SQLITE_OK] and the deallocation
   7.412 -** of resources is deferred until all [prepared statements], [BLOB handles],
   7.413 -** and [sqlite3_backup] objects are also destroyed.
   7.414 -**
   7.415 -** ^If an [sqlite3] object is destroyed while a transaction is open,
   7.416 -** the transaction is automatically rolled back.
   7.417 -**
   7.418 -** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)]
   7.419 -** must be either a NULL
   7.420 -** pointer or an [sqlite3] object pointer obtained
   7.421 -** from [sqlite3_open()], [sqlite3_open16()], or
   7.422 -** [sqlite3_open_v2()], and not previously closed.
   7.423 -** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
   7.424 -** argument is a harmless no-op.
   7.425 -*/
   7.426 -SQLITE_API int sqlite3_close(sqlite3*);
   7.427 -SQLITE_API int sqlite3_close_v2(sqlite3*);
   7.428 -
   7.429 -/*
   7.430 -** The type for a callback function.
   7.431 -** This is legacy and deprecated.  It is included for historical
   7.432 -** compatibility and is not documented.
   7.433 -*/
   7.434 -typedef int (*sqlite3_callback)(void*,int,char**, char**);
   7.435 -
   7.436 -/*
   7.437 -** CAPI3REF: One-Step Query Execution Interface
   7.438 -**
   7.439 -** The sqlite3_exec() interface is a convenience wrapper around
   7.440 -** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
   7.441 -** that allows an application to run multiple statements of SQL
   7.442 -** without having to use a lot of C code. 
   7.443 -**
   7.444 -** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
   7.445 -** semicolon-separate SQL statements passed into its 2nd argument,
   7.446 -** in the context of the [database connection] passed in as its 1st
   7.447 -** argument.  ^If the callback function of the 3rd argument to
   7.448 -** sqlite3_exec() is not NULL, then it is invoked for each result row
   7.449 -** coming out of the evaluated SQL statements.  ^The 4th argument to
   7.450 -** sqlite3_exec() is relayed through to the 1st argument of each
   7.451 -** callback invocation.  ^If the callback pointer to sqlite3_exec()
   7.452 -** is NULL, then no callback is ever invoked and result rows are
   7.453 -** ignored.
   7.454 -**
   7.455 -** ^If an error occurs while evaluating the SQL statements passed into
   7.456 -** sqlite3_exec(), then execution of the current statement stops and
   7.457 -** subsequent statements are skipped.  ^If the 5th parameter to sqlite3_exec()
   7.458 -** is not NULL then any error message is written into memory obtained
   7.459 -** from [sqlite3_malloc()] and passed back through the 5th parameter.
   7.460 -** To avoid memory leaks, the application should invoke [sqlite3_free()]
   7.461 -** on error message strings returned through the 5th parameter of
   7.462 -** of sqlite3_exec() after the error message string is no longer needed.
   7.463 -** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
   7.464 -** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
   7.465 -** NULL before returning.
   7.466 -**
   7.467 -** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
   7.468 -** routine returns SQLITE_ABORT without invoking the callback again and
   7.469 -** without running any subsequent SQL statements.
   7.470 -**
   7.471 -** ^The 2nd argument to the sqlite3_exec() callback function is the
   7.472 -** number of columns in the result.  ^The 3rd argument to the sqlite3_exec()
   7.473 -** callback is an array of pointers to strings obtained as if from
   7.474 -** [sqlite3_column_text()], one for each column.  ^If an element of a
   7.475 -** result row is NULL then the corresponding string pointer for the
   7.476 -** sqlite3_exec() callback is a NULL pointer.  ^The 4th argument to the
   7.477 -** sqlite3_exec() callback is an array of pointers to strings where each
   7.478 -** entry represents the name of corresponding result column as obtained
   7.479 -** from [sqlite3_column_name()].
   7.480 -**
   7.481 -** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
   7.482 -** to an empty string, or a pointer that contains only whitespace and/or 
   7.483 -** SQL comments, then no SQL statements are evaluated and the database
   7.484 -** is not changed.
   7.485 -**
   7.486 -** Restrictions:
   7.487 -**
   7.488 -** <ul>
   7.489 -** <li> The application must insure that the 1st parameter to sqlite3_exec()
   7.490 -**      is a valid and open [database connection].
   7.491 -** <li> The application must not close the [database connection] specified by
   7.492 -**      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
   7.493 -** <li> The application must not modify the SQL statement text passed into
   7.494 -**      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
   7.495 -** </ul>
   7.496 -*/
   7.497 -SQLITE_API int sqlite3_exec(
   7.498 -  sqlite3*,                                  /* An open database */
   7.499 -  const char *sql,                           /* SQL to be evaluated */
   7.500 -  int (*callback)(void*,int,char**,char**),  /* Callback function */
   7.501 -  void *,                                    /* 1st argument to callback */
   7.502 -  char **errmsg                              /* Error msg written here */
   7.503 -);
   7.504 -
   7.505 -/*
   7.506 -** CAPI3REF: Result Codes
   7.507 -** KEYWORDS: {result code definitions}
   7.508 -**
   7.509 -** Many SQLite functions return an integer result code from the set shown
   7.510 -** here in order to indicate success or failure.
   7.511 -**
   7.512 -** New error codes may be added in future versions of SQLite.
   7.513 -**
   7.514 -** See also: [extended result code definitions]
   7.515 -*/
   7.516 -#define SQLITE_OK           0   /* Successful result */
   7.517 -/* beginning-of-error-codes */
   7.518 -#define SQLITE_ERROR        1   /* SQL error or missing database */
   7.519 -#define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */
   7.520 -#define SQLITE_PERM         3   /* Access permission denied */
   7.521 -#define SQLITE_ABORT        4   /* Callback routine requested an abort */
   7.522 -#define SQLITE_BUSY         5   /* The database file is locked */
   7.523 -#define SQLITE_LOCKED       6   /* A table in the database is locked */
   7.524 -#define SQLITE_NOMEM        7   /* A malloc() failed */
   7.525 -#define SQLITE_READONLY     8   /* Attempt to write a readonly database */
   7.526 -#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/
   7.527 -#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */
   7.528 -#define SQLITE_CORRUPT     11   /* The database disk image is malformed */
   7.529 -#define SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */
   7.530 -#define SQLITE_FULL        13   /* Insertion failed because database is full */
   7.531 -#define SQLITE_CANTOPEN    14   /* Unable to open the database file */
   7.532 -#define SQLITE_PROTOCOL    15   /* Database lock protocol error */
   7.533 -#define SQLITE_EMPTY       16   /* Database is empty */
   7.534 -#define SQLITE_SCHEMA      17   /* The database schema changed */
   7.535 -#define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */
   7.536 -#define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */
   7.537 -#define SQLITE_MISMATCH    20   /* Data type mismatch */
   7.538 -#define SQLITE_MISUSE      21   /* Library used incorrectly */
   7.539 -#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */
   7.540 -#define SQLITE_AUTH        23   /* Authorization denied */
   7.541 -#define SQLITE_FORMAT      24   /* Auxiliary database format error */
   7.542 -#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */
   7.543 -#define SQLITE_NOTADB      26   /* File opened that is not a database file */
   7.544 -#define SQLITE_NOTICE      27   /* Notifications from sqlite3_log() */
   7.545 -#define SQLITE_WARNING     28   /* Warnings from sqlite3_log() */
   7.546 -#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */
   7.547 -#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */
   7.548 -/* end-of-error-codes */
   7.549 -
   7.550 -/*
   7.551 -** CAPI3REF: Extended Result Codes
   7.552 -** KEYWORDS: {extended result code definitions}
   7.553 -**
   7.554 -** In its default configuration, SQLite API routines return one of 30 integer
   7.555 -** [result codes].  However, experience has shown that many of
   7.556 -** these result codes are too coarse-grained.  They do not provide as
   7.557 -** much information about problems as programmers might like.  In an effort to
   7.558 -** address this, newer versions of SQLite (version 3.3.8 and later) include
   7.559 -** support for additional result codes that provide more detailed information
   7.560 -** about errors. These [extended result codes] are enabled or disabled
   7.561 -** on a per database connection basis using the
   7.562 -** [sqlite3_extended_result_codes()] API.  Or, the extended code for
   7.563 -** the most recent error can be obtained using
   7.564 -** [sqlite3_extended_errcode()].
   7.565 -*/
   7.566 -#define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))
   7.567 -#define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2<<8))
   7.568 -#define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3<<8))
   7.569 -#define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4<<8))
   7.570 -#define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5<<8))
   7.571 -#define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6<<8))
   7.572 -#define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7<<8))
   7.573 -#define SQLITE_IOERR_UNLOCK            (SQLITE_IOERR | (8<<8))
   7.574 -#define SQLITE_IOERR_RDLOCK            (SQLITE_IOERR | (9<<8))
   7.575 -#define SQLITE_IOERR_DELETE            (SQLITE_IOERR | (10<<8))
   7.576 -#define SQLITE_IOERR_BLOCKED           (SQLITE_IOERR | (11<<8))
   7.577 -#define SQLITE_IOERR_NOMEM             (SQLITE_IOERR | (12<<8))
   7.578 -#define SQLITE_IOERR_ACCESS            (SQLITE_IOERR | (13<<8))
   7.579 -#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
   7.580 -#define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))
   7.581 -#define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))
   7.582 -#define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))
   7.583 -#define SQLITE_IOERR_SHMOPEN           (SQLITE_IOERR | (18<<8))
   7.584 -#define SQLITE_IOERR_SHMSIZE           (SQLITE_IOERR | (19<<8))
   7.585 -#define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))
   7.586 -#define SQLITE_IOERR_SHMMAP            (SQLITE_IOERR | (21<<8))
   7.587 -#define SQLITE_IOERR_SEEK              (SQLITE_IOERR | (22<<8))
   7.588 -#define SQLITE_IOERR_DELETE_NOENT      (SQLITE_IOERR | (23<<8))
   7.589 -#define SQLITE_IOERR_MMAP              (SQLITE_IOERR | (24<<8))
   7.590 -#define SQLITE_IOERR_GETTEMPPATH       (SQLITE_IOERR | (25<<8))
   7.591 -#define SQLITE_IOERR_CONVPATH          (SQLITE_IOERR | (26<<8))
   7.592 -#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))
   7.593 -#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
   7.594 -#define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))
   7.595 -#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))
   7.596 -#define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))
   7.597 -#define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))
   7.598 -#define SQLITE_CANTOPEN_CONVPATH       (SQLITE_CANTOPEN | (4<<8))
   7.599 -#define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))
   7.600 -#define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))
   7.601 -#define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))
   7.602 -#define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))
   7.603 -#define SQLITE_READONLY_DBMOVED        (SQLITE_READONLY | (4<<8))
   7.604 -#define SQLITE_ABORT_ROLLBACK          (SQLITE_ABORT | (2<<8))
   7.605 -#define SQLITE_CONSTRAINT_CHECK        (SQLITE_CONSTRAINT | (1<<8))
   7.606 -#define SQLITE_CONSTRAINT_COMMITHOOK   (SQLITE_CONSTRAINT | (2<<8))
   7.607 -#define SQLITE_CONSTRAINT_FOREIGNKEY   (SQLITE_CONSTRAINT | (3<<8))
   7.608 -#define SQLITE_CONSTRAINT_FUNCTION     (SQLITE_CONSTRAINT | (4<<8))
   7.609 -#define SQLITE_CONSTRAINT_NOTNULL      (SQLITE_CONSTRAINT | (5<<8))
   7.610 -#define SQLITE_CONSTRAINT_PRIMARYKEY   (SQLITE_CONSTRAINT | (6<<8))
   7.611 -#define SQLITE_CONSTRAINT_TRIGGER      (SQLITE_CONSTRAINT | (7<<8))
   7.612 -#define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))
   7.613 -#define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))
   7.614 -#define SQLITE_CONSTRAINT_ROWID        (SQLITE_CONSTRAINT |(10<<8))
   7.615 -#define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))
   7.616 -#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
   7.617 -#define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))
   7.618 -
   7.619 -/*
   7.620 -** CAPI3REF: Flags For File Open Operations
   7.621 -**
   7.622 -** These bit values are intended for use in the
   7.623 -** 3rd parameter to the [sqlite3_open_v2()] interface and
   7.624 -** in the 4th parameter to the [sqlite3_vfs.xOpen] method.
   7.625 -*/
   7.626 -#define SQLITE_OPEN_READONLY         0x00000001  /* Ok for sqlite3_open_v2() */
   7.627 -#define SQLITE_OPEN_READWRITE        0x00000002  /* Ok for sqlite3_open_v2() */
   7.628 -#define SQLITE_OPEN_CREATE           0x00000004  /* Ok for sqlite3_open_v2() */
   7.629 -#define SQLITE_OPEN_DELETEONCLOSE    0x00000008  /* VFS only */
   7.630 -#define SQLITE_OPEN_EXCLUSIVE        0x00000010  /* VFS only */
   7.631 -#define SQLITE_OPEN_AUTOPROXY        0x00000020  /* VFS only */
   7.632 -#define SQLITE_OPEN_URI              0x00000040  /* Ok for sqlite3_open_v2() */
   7.633 -#define SQLITE_OPEN_MEMORY           0x00000080  /* Ok for sqlite3_open_v2() */
   7.634 -#define SQLITE_OPEN_MAIN_DB          0x00000100  /* VFS only */
   7.635 -#define SQLITE_OPEN_TEMP_DB          0x00000200  /* VFS only */
   7.636 -#define SQLITE_OPEN_TRANSIENT_DB     0x00000400  /* VFS only */
   7.637 -#define SQLITE_OPEN_MAIN_JOURNAL     0x00000800  /* VFS only */
   7.638 -#define SQLITE_OPEN_TEMP_JOURNAL     0x00001000  /* VFS only */
   7.639 -#define SQLITE_OPEN_SUBJOURNAL       0x00002000  /* VFS only */
   7.640 -#define SQLITE_OPEN_MASTER_JOURNAL   0x00004000  /* VFS only */
   7.641 -#define SQLITE_OPEN_NOMUTEX          0x00008000  /* Ok for sqlite3_open_v2() */
   7.642 -#define SQLITE_OPEN_FULLMUTEX        0x00010000  /* Ok for sqlite3_open_v2() */
   7.643 -#define SQLITE_OPEN_SHAREDCACHE      0x00020000  /* Ok for sqlite3_open_v2() */
   7.644 -#define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */
   7.645 -#define SQLITE_OPEN_WAL              0x00080000  /* VFS only */
   7.646 -
   7.647 -/* Reserved:                         0x00F00000 */
   7.648 -
   7.649 -/*
   7.650 -** CAPI3REF: Device Characteristics
   7.651 -**
   7.652 -** The xDeviceCharacteristics method of the [sqlite3_io_methods]
   7.653 -** object returns an integer which is a vector of these
   7.654 -** bit values expressing I/O characteristics of the mass storage
   7.655 -** device that holds the file that the [sqlite3_io_methods]
   7.656 -** refers to.
   7.657 -**
   7.658 -** The SQLITE_IOCAP_ATOMIC property means that all writes of
   7.659 -** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values
   7.660 -** mean that writes of blocks that are nnn bytes in size and
   7.661 -** are aligned to an address which is an integer multiple of
   7.662 -** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means
   7.663 -** that when data is appended to a file, the data is appended
   7.664 -** first then the size of the file is extended, never the other
   7.665 -** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that
   7.666 -** information is written to disk in the same order as calls
   7.667 -** to xWrite().  The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
   7.668 -** after reboot following a crash or power loss, the only bytes in a
   7.669 -** file that were written at the application level might have changed
   7.670 -** and that adjacent bytes, even bytes within the same sector are
   7.671 -** guaranteed to be unchanged.  The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN
   7.672 -** flag indicate that a file cannot be deleted when open.  The
   7.673 -** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on
   7.674 -** read-only media and cannot be changed even by processes with
   7.675 -** elevated privileges.
   7.676 -*/
   7.677 -#define SQLITE_IOCAP_ATOMIC                 0x00000001
   7.678 -#define SQLITE_IOCAP_ATOMIC512              0x00000002
   7.679 -#define SQLITE_IOCAP_ATOMIC1K               0x00000004
   7.680 -#define SQLITE_IOCAP_ATOMIC2K               0x00000008
   7.681 -#define SQLITE_IOCAP_ATOMIC4K               0x00000010
   7.682 -#define SQLITE_IOCAP_ATOMIC8K               0x00000020
   7.683 -#define SQLITE_IOCAP_ATOMIC16K              0x00000040
   7.684 -#define SQLITE_IOCAP_ATOMIC32K              0x00000080
   7.685 -#define SQLITE_IOCAP_ATOMIC64K              0x00000100
   7.686 -#define SQLITE_IOCAP_SAFE_APPEND            0x00000200
   7.687 -#define SQLITE_IOCAP_SEQUENTIAL             0x00000400
   7.688 -#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN  0x00000800
   7.689 -#define SQLITE_IOCAP_POWERSAFE_OVERWRITE    0x00001000
   7.690 -#define SQLITE_IOCAP_IMMUTABLE              0x00002000
   7.691 -
   7.692 -/*
   7.693 -** CAPI3REF: File Locking Levels
   7.694 -**
   7.695 -** SQLite uses one of these integer values as the second
   7.696 -** argument to calls it makes to the xLock() and xUnlock() methods
   7.697 -** of an [sqlite3_io_methods] object.
   7.698 -*/
   7.699 -#define SQLITE_LOCK_NONE          0
   7.700 -#define SQLITE_LOCK_SHARED        1
   7.701 -#define SQLITE_LOCK_RESERVED      2
   7.702 -#define SQLITE_LOCK_PENDING       3
   7.703 -#define SQLITE_LOCK_EXCLUSIVE     4
   7.704 -
   7.705 -/*
   7.706 -** CAPI3REF: Synchronization Type Flags
   7.707 -**
   7.708 -** When SQLite invokes the xSync() method of an
   7.709 -** [sqlite3_io_methods] object it uses a combination of
   7.710 -** these integer values as the second argument.
   7.711 -**
   7.712 -** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
   7.713 -** sync operation only needs to flush data to mass storage.  Inode
   7.714 -** information need not be flushed. If the lower four bits of the flag
   7.715 -** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
   7.716 -** If the lower four bits equal SQLITE_SYNC_FULL, that means
   7.717 -** to use Mac OS X style fullsync instead of fsync().
   7.718 -**
   7.719 -** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags
   7.720 -** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL
   7.721 -** settings.  The [synchronous pragma] determines when calls to the
   7.722 -** xSync VFS method occur and applies uniformly across all platforms.
   7.723 -** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how
   7.724 -** energetic or rigorous or forceful the sync operations are and
   7.725 -** only make a difference on Mac OSX for the default SQLite code.
   7.726 -** (Third-party VFS implementations might also make the distinction
   7.727 -** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the
   7.728 -** operating systems natively supported by SQLite, only Mac OSX
   7.729 -** cares about the difference.)
   7.730 -*/
   7.731 -#define SQLITE_SYNC_NORMAL        0x00002
   7.732 -#define SQLITE_SYNC_FULL          0x00003
   7.733 -#define SQLITE_SYNC_DATAONLY      0x00010
   7.734 -
   7.735 -/*
   7.736 -** CAPI3REF: OS Interface Open File Handle
   7.737 -**
   7.738 -** An [sqlite3_file] object represents an open file in the 
   7.739 -** [sqlite3_vfs | OS interface layer].  Individual OS interface
   7.740 -** implementations will
   7.741 -** want to subclass this object by appending additional fields
   7.742 -** for their own use.  The pMethods entry is a pointer to an
   7.743 -** [sqlite3_io_methods] object that defines methods for performing
   7.744 -** I/O operations on the open file.
   7.745 -*/
   7.746 -typedef struct sqlite3_file sqlite3_file;
   7.747 -struct sqlite3_file {
   7.748 -  const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */
   7.749 -};
   7.750 -
   7.751 -/*
   7.752 -** CAPI3REF: OS Interface File Virtual Methods Object
   7.753 -**
   7.754 -** Every file opened by the [sqlite3_vfs.xOpen] method populates an
   7.755 -** [sqlite3_file] object (or, more commonly, a subclass of the
   7.756 -** [sqlite3_file] object) with a pointer to an instance of this object.
   7.757 -** This object defines the methods used to perform various operations
   7.758 -** against the open file represented by the [sqlite3_file] object.
   7.759 -**
   7.760 -** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element 
   7.761 -** to a non-NULL pointer, then the sqlite3_io_methods.xClose method
   7.762 -** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed.  The
   7.763 -** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]
   7.764 -** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element
   7.765 -** to NULL.
   7.766 -**
   7.767 -** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or
   7.768 -** [SQLITE_SYNC_FULL].  The first choice is the normal fsync().
   7.769 -** The second choice is a Mac OS X style fullsync.  The [SQLITE_SYNC_DATAONLY]
   7.770 -** flag may be ORed in to indicate that only the data of the file
   7.771 -** and not its inode needs to be synced.
   7.772 -**
   7.773 -** The integer values to xLock() and xUnlock() are one of
   7.774 -** <ul>
   7.775 -** <li> [SQLITE_LOCK_NONE],
   7.776 -** <li> [SQLITE_LOCK_SHARED],
   7.777 -** <li> [SQLITE_LOCK_RESERVED],
   7.778 -** <li> [SQLITE_LOCK_PENDING], or
   7.779 -** <li> [SQLITE_LOCK_EXCLUSIVE].
   7.780 -** </ul>
   7.781 -** xLock() increases the lock. xUnlock() decreases the lock.
   7.782 -** The xCheckReservedLock() method checks whether any database connection,
   7.783 -** either in this process or in some other process, is holding a RESERVED,
   7.784 -** PENDING, or EXCLUSIVE lock on the file.  It returns true
   7.785 -** if such a lock exists and false otherwise.
   7.786 -**
   7.787 -** The xFileControl() method is a generic interface that allows custom
   7.788 -** VFS implementations to directly control an open file using the
   7.789 -** [sqlite3_file_control()] interface.  The second "op" argument is an
   7.790 -** integer opcode.  The third argument is a generic pointer intended to
   7.791 -** point to a structure that may contain arguments or space in which to
   7.792 -** write return values.  Potential uses for xFileControl() might be
   7.793 -** functions to enable blocking locks with timeouts, to change the
   7.794 -** locking strategy (for example to use dot-file locks), to inquire
   7.795 -** about the status of a lock, or to break stale locks.  The SQLite
   7.796 -** core reserves all opcodes less than 100 for its own use.
   7.797 -** A [file control opcodes | list of opcodes] less than 100 is available.
   7.798 -** Applications that define a custom xFileControl method should use opcodes
   7.799 -** greater than 100 to avoid conflicts.  VFS implementations should
   7.800 -** return [SQLITE_NOTFOUND] for file control opcodes that they do not
   7.801 -** recognize.
   7.802 -**
   7.803 -** The xSectorSize() method returns the sector size of the
   7.804 -** device that underlies the file.  The sector size is the
   7.805 -** minimum write that can be performed without disturbing
   7.806 -** other bytes in the file.  The xDeviceCharacteristics()
   7.807 -** method returns a bit vector describing behaviors of the
   7.808 -** underlying device:
   7.809 -**
   7.810 -** <ul>
   7.811 -** <li> [SQLITE_IOCAP_ATOMIC]
   7.812 -** <li> [SQLITE_IOCAP_ATOMIC512]
   7.813 -** <li> [SQLITE_IOCAP_ATOMIC1K]
   7.814 -** <li> [SQLITE_IOCAP_ATOMIC2K]
   7.815 -** <li> [SQLITE_IOCAP_ATOMIC4K]
   7.816 -** <li> [SQLITE_IOCAP_ATOMIC8K]
   7.817 -** <li> [SQLITE_IOCAP_ATOMIC16K]
   7.818 -** <li> [SQLITE_IOCAP_ATOMIC32K]
   7.819 -** <li> [SQLITE_IOCAP_ATOMIC64K]
   7.820 -** <li> [SQLITE_IOCAP_SAFE_APPEND]
   7.821 -** <li> [SQLITE_IOCAP_SEQUENTIAL]
   7.822 -** </ul>
   7.823 -**
   7.824 -** The SQLITE_IOCAP_ATOMIC property means that all writes of
   7.825 -** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values
   7.826 -** mean that writes of blocks that are nnn bytes in size and
   7.827 -** are aligned to an address which is an integer multiple of
   7.828 -** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means
   7.829 -** that when data is appended to a file, the data is appended
   7.830 -** first then the size of the file is extended, never the other
   7.831 -** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that
   7.832 -** information is written to disk in the same order as calls
   7.833 -** to xWrite().
   7.834 -**
   7.835 -** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill
   7.836 -** in the unread portions of the buffer with zeros.  A VFS that
   7.837 -** fails to zero-fill short reads might seem to work.  However,
   7.838 -** failure to zero-fill short reads will eventually lead to
   7.839 -** database corruption.
   7.840 -*/
   7.841 -typedef struct sqlite3_io_methods sqlite3_io_methods;
   7.842 -struct sqlite3_io_methods {
   7.843 -  int iVersion;
   7.844 -  int (*xClose)(sqlite3_file*);
   7.845 -  int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
   7.846 -  int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);
   7.847 -  int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);
   7.848 -  int (*xSync)(sqlite3_file*, int flags);
   7.849 -  int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);
   7.850 -  int (*xLock)(sqlite3_file*, int);
   7.851 -  int (*xUnlock)(sqlite3_file*, int);
   7.852 -  int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);
   7.853 -  int (*xFileControl)(sqlite3_file*, int op, void *pArg);
   7.854 -  int (*xSectorSize)(sqlite3_file*);
   7.855 -  int (*xDeviceCharacteristics)(sqlite3_file*);
   7.856 -  /* Methods above are valid for version 1 */
   7.857 -  int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
   7.858 -  int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);
   7.859 -  void (*xShmBarrier)(sqlite3_file*);
   7.860 -  int (*xShmUnmap)(sqlite3_file*, int deleteFlag);
   7.861 -  /* Methods above are valid for version 2 */
   7.862 -  int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);
   7.863 -  int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);
   7.864 -  /* Methods above are valid for version 3 */
   7.865 -  /* Additional methods may be added in future releases */
   7.866 -};
   7.867 -
   7.868 -/*
   7.869 -** CAPI3REF: Standard File Control Opcodes
   7.870 -** KEYWORDS: {file control opcodes} {file control opcode}
   7.871 -**
   7.872 -** These integer constants are opcodes for the xFileControl method
   7.873 -** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
   7.874 -** interface.
   7.875 -**
   7.876 -** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging.  This
   7.877 -** opcode causes the xFileControl method to write the current state of
   7.878 -** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
   7.879 -** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
   7.880 -** into an integer that the pArg argument points to. This capability
   7.881 -** is used during testing and only needs to be supported when SQLITE_TEST
   7.882 -** is defined.
   7.883 -** <ul>
   7.884 -** <li>[[SQLITE_FCNTL_SIZE_HINT]]
   7.885 -** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
   7.886 -** layer a hint of how large the database file will grow to be during the
   7.887 -** current transaction.  This hint is not guaranteed to be accurate but it
   7.888 -** is often close.  The underlying VFS might choose to preallocate database
   7.889 -** file space based on this hint in order to help writes to the database
   7.890 -** file run faster.
   7.891 -**
   7.892 -** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]
   7.893 -** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
   7.894 -** extends and truncates the database file in chunks of a size specified
   7.895 -** by the user. The fourth argument to [sqlite3_file_control()] should 
   7.896 -** point to an integer (type int) containing the new chunk-size to use
   7.897 -** for the nominated database. Allocating database file space in large
   7.898 -** chunks (say 1MB at a time), may reduce file-system fragmentation and
   7.899 -** improve performance on some systems.
   7.900 -**
   7.901 -** <li>[[SQLITE_FCNTL_FILE_POINTER]]
   7.902 -** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
   7.903 -** to the [sqlite3_file] object associated with a particular database
   7.904 -** connection.  See the [sqlite3_file_control()] documentation for
   7.905 -** additional information.
   7.906 -**
   7.907 -** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
   7.908 -** No longer in use.
   7.909 -**
   7.910 -** <li>[[SQLITE_FCNTL_SYNC]]
   7.911 -** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and
   7.912 -** sent to the VFS immediately before the xSync method is invoked on a
   7.913 -** database file descriptor. Or, if the xSync method is not invoked 
   7.914 -** because the user has configured SQLite with 
   7.915 -** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place 
   7.916 -** of the xSync method. In most cases, the pointer argument passed with
   7.917 -** this file-control is NULL. However, if the database file is being synced
   7.918 -** as part of a multi-database commit, the argument points to a nul-terminated
   7.919 -** string containing the transactions master-journal file name. VFSes that 
   7.920 -** do not need this signal should silently ignore this opcode. Applications 
   7.921 -** should not call [sqlite3_file_control()] with this opcode as doing so may 
   7.922 -** disrupt the operation of the specialized VFSes that do require it.  
   7.923 -**
   7.924 -** <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]]
   7.925 -** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite
   7.926 -** and sent to the VFS after a transaction has been committed immediately
   7.927 -** but before the database is unlocked. VFSes that do not need this signal
   7.928 -** should silently ignore this opcode. Applications should not call
   7.929 -** [sqlite3_file_control()] with this opcode as doing so may disrupt the 
   7.930 -** operation of the specialized VFSes that do require it.  
   7.931 -**
   7.932 -** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]
   7.933 -** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
   7.934 -** retry counts and intervals for certain disk I/O operations for the
   7.935 -** windows [VFS] in order to provide robustness in the presence of
   7.936 -** anti-virus programs.  By default, the windows VFS will retry file read,
   7.937 -** file write, and file delete operations up to 10 times, with a delay
   7.938 -** of 25 milliseconds before the first retry and with the delay increasing
   7.939 -** by an additional 25 milliseconds with each subsequent retry.  This
   7.940 -** opcode allows these two values (10 retries and 25 milliseconds of delay)
   7.941 -** to be adjusted.  The values are changed for all database connections
   7.942 -** within the same process.  The argument is a pointer to an array of two
   7.943 -** integers where the first integer i the new retry count and the second
   7.944 -** integer is the delay.  If either integer is negative, then the setting
   7.945 -** is not changed but instead the prior value of that setting is written
   7.946 -** into the array entry, allowing the current retry settings to be
   7.947 -** interrogated.  The zDbName parameter is ignored.
   7.948 -**
   7.949 -** <li>[[SQLITE_FCNTL_PERSIST_WAL]]
   7.950 -** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
   7.951 -** persistent [WAL | Write Ahead Log] setting.  By default, the auxiliary
   7.952 -** write ahead log and shared memory files used for transaction control
   7.953 -** are automatically deleted when the latest connection to the database
   7.954 -** closes.  Setting persistent WAL mode causes those files to persist after
   7.955 -** close.  Persisting the files is useful when other processes that do not
   7.956 -** have write permission on the directory containing the database file want
   7.957 -** to read the database file, as the WAL and shared memory files must exist
   7.958 -** in order for the database to be readable.  The fourth parameter to
   7.959 -** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
   7.960 -** That integer is 0 to disable persistent WAL mode or 1 to enable persistent
   7.961 -** WAL mode.  If the integer is -1, then it is overwritten with the current
   7.962 -** WAL persistence setting.
   7.963 -**
   7.964 -** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]]
   7.965 -** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the
   7.966 -** persistent "powersafe-overwrite" or "PSOW" setting.  The PSOW setting
   7.967 -** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the
   7.968 -** xDeviceCharacteristics methods. The fourth parameter to
   7.969 -** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
   7.970 -** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage
   7.971 -** mode.  If the integer is -1, then it is overwritten with the current
   7.972 -** zero-damage mode setting.
   7.973 -**
   7.974 -** <li>[[SQLITE_FCNTL_OVERWRITE]]
   7.975 -** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening
   7.976 -** a write transaction to indicate that, unless it is rolled back for some
   7.977 -** reason, the entire database file will be overwritten by the current 
   7.978 -** transaction. This is used by VACUUM operations.
   7.979 -**
   7.980 -** <li>[[SQLITE_FCNTL_VFSNAME]]
   7.981 -** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of
   7.982 -** all [VFSes] in the VFS stack.  The names are of all VFS shims and the
   7.983 -** final bottom-level VFS are written into memory obtained from 
   7.984 -** [sqlite3_malloc()] and the result is stored in the char* variable
   7.985 -** that the fourth parameter of [sqlite3_file_control()] points to.
   7.986 -** The caller is responsible for freeing the memory when done.  As with
   7.987 -** all file-control actions, there is no guarantee that this will actually
   7.988 -** do anything.  Callers should initialize the char* variable to a NULL
   7.989 -** pointer in case this file-control is not implemented.  This file-control
   7.990 -** is intended for diagnostic use only.
   7.991 -**
   7.992 -** <li>[[SQLITE_FCNTL_PRAGMA]]
   7.993 -** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] 
   7.994 -** file control is sent to the open [sqlite3_file] object corresponding
   7.995 -** to the database file to which the pragma statement refers. ^The argument
   7.996 -** to the [SQLITE_FCNTL_PRAGMA] file control is an array of
   7.997 -** pointers to strings (char**) in which the second element of the array
   7.998 -** is the name of the pragma and the third element is the argument to the
   7.999 -** pragma or NULL if the pragma has no argument.  ^The handler for an
  7.1000 -** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element
  7.1001 -** of the char** argument point to a string obtained from [sqlite3_mprintf()]
  7.1002 -** or the equivalent and that string will become the result of the pragma or
  7.1003 -** the error message if the pragma fails. ^If the
  7.1004 -** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal 
  7.1005 -** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]
  7.1006 -** file control returns [SQLITE_OK], then the parser assumes that the
  7.1007 -** VFS has handled the PRAGMA itself and the parser generates a no-op
  7.1008 -** prepared statement.  ^If the [SQLITE_FCNTL_PRAGMA] file control returns
  7.1009 -** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
  7.1010 -** that the VFS encountered an error while handling the [PRAGMA] and the
  7.1011 -** compilation of the PRAGMA fails with an error.  ^The [SQLITE_FCNTL_PRAGMA]
  7.1012 -** file control occurs at the beginning of pragma statement analysis and so
  7.1013 -** it is able to override built-in [PRAGMA] statements.
  7.1014 -**
  7.1015 -** <li>[[SQLITE_FCNTL_BUSYHANDLER]]
  7.1016 -** ^The [SQLITE_FCNTL_BUSYHANDLER]
  7.1017 -** file-control may be invoked by SQLite on the database file handle
  7.1018 -** shortly after it is opened in order to provide a custom VFS with access
  7.1019 -** to the connections busy-handler callback. The argument is of type (void **)
  7.1020 -** - an array of two (void *) values. The first (void *) actually points
  7.1021 -** to a function of type (int (*)(void *)). In order to invoke the connections
  7.1022 -** busy-handler, this function should be invoked with the second (void *) in
  7.1023 -** the array as the only argument. If it returns non-zero, then the operation
  7.1024 -** should be retried. If it returns zero, the custom VFS should abandon the
  7.1025 -** current operation.
  7.1026 -**
  7.1027 -** <li>[[SQLITE_FCNTL_TEMPFILENAME]]
  7.1028 -** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control
  7.1029 -** to have SQLite generate a
  7.1030 -** temporary filename using the same algorithm that is followed to generate
  7.1031 -** temporary filenames for TEMP tables and other internal uses.  The
  7.1032 -** argument should be a char** which will be filled with the filename
  7.1033 -** written into memory obtained from [sqlite3_malloc()].  The caller should
  7.1034 -** invoke [sqlite3_free()] on the result to avoid a memory leak.
  7.1035 -**
  7.1036 -** <li>[[SQLITE_FCNTL_MMAP_SIZE]]
  7.1037 -** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the
  7.1038 -** maximum number of bytes that will be used for memory-mapped I/O.
  7.1039 -** The argument is a pointer to a value of type sqlite3_int64 that
  7.1040 -** is an advisory maximum number of bytes in the file to memory map.  The
  7.1041 -** pointer is overwritten with the old value.  The limit is not changed if
  7.1042 -** the value originally pointed to is negative, and so the current limit 
  7.1043 -** can be queried by passing in a pointer to a negative number.  This
  7.1044 -** file-control is used internally to implement [PRAGMA mmap_size].
  7.1045 -**
  7.1046 -** <li>[[SQLITE_FCNTL_TRACE]]
  7.1047 -** The [SQLITE_FCNTL_TRACE] file control provides advisory information
  7.1048 -** to the VFS about what the higher layers of the SQLite stack are doing.
  7.1049 -** This file control is used by some VFS activity tracing [shims].
  7.1050 -** The argument is a zero-terminated string.  Higher layers in the
  7.1051 -** SQLite stack may generate instances of this file control if
  7.1052 -** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled.
  7.1053 -**
  7.1054 -** <li>[[SQLITE_FCNTL_HAS_MOVED]]
  7.1055 -** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a
  7.1056 -** pointer to an integer and it writes a boolean into that integer depending
  7.1057 -** on whether or not the file has been renamed, moved, or deleted since it
  7.1058 -** was first opened.
  7.1059 -**
  7.1060 -** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
  7.1061 -** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging.  This
  7.1062 -** opcode causes the xFileControl method to swap the file handle with the one
  7.1063 -** pointed to by the pArg argument.  This capability is used during testing
  7.1064 -** and only needs to be supported when SQLITE_TEST is defined.
  7.1065 -**
  7.1066 -** </ul>
  7.1067 -*/
  7.1068 -#define SQLITE_FCNTL_LOCKSTATE               1
  7.1069 -#define SQLITE_GET_LOCKPROXYFILE             2
  7.1070 -#define SQLITE_SET_LOCKPROXYFILE             3
  7.1071 -#define SQLITE_LAST_ERRNO                    4
  7.1072 -#define SQLITE_FCNTL_SIZE_HINT               5
  7.1073 -#define SQLITE_FCNTL_CHUNK_SIZE              6
  7.1074 -#define SQLITE_FCNTL_FILE_POINTER            7
  7.1075 -#define SQLITE_FCNTL_SYNC_OMITTED            8
  7.1076 -#define SQLITE_FCNTL_WIN32_AV_RETRY          9
  7.1077 -#define SQLITE_FCNTL_PERSIST_WAL            10
  7.1078 -#define SQLITE_FCNTL_OVERWRITE              11
  7.1079 -#define SQLITE_FCNTL_VFSNAME                12
  7.1080 -#define SQLITE_FCNTL_POWERSAFE_OVERWRITE    13
  7.1081 -#define SQLITE_FCNTL_PRAGMA                 14
  7.1082 -#define SQLITE_FCNTL_BUSYHANDLER            15
  7.1083 -#define SQLITE_FCNTL_TEMPFILENAME           16
  7.1084 -#define SQLITE_FCNTL_MMAP_SIZE              18
  7.1085 -#define SQLITE_FCNTL_TRACE                  19
  7.1086 -#define SQLITE_FCNTL_HAS_MOVED              20
  7.1087 -#define SQLITE_FCNTL_SYNC                   21
  7.1088 -#define SQLITE_FCNTL_COMMIT_PHASETWO        22
  7.1089 -#define SQLITE_FCNTL_WIN32_SET_HANDLE       23
  7.1090 -
  7.1091 -/*
  7.1092 -** CAPI3REF: Mutex Handle
  7.1093 -**
  7.1094 -** The mutex module within SQLite defines [sqlite3_mutex] to be an
  7.1095 -** abstract type for a mutex object.  The SQLite core never looks
  7.1096 -** at the internal representation of an [sqlite3_mutex].  It only
  7.1097 -** deals with pointers to the [sqlite3_mutex] object.
  7.1098 -**
  7.1099 -** Mutexes are created using [sqlite3_mutex_alloc()].
  7.1100 -*/
  7.1101 -typedef struct sqlite3_mutex sqlite3_mutex;
  7.1102 -
  7.1103 -/*
  7.1104 -** CAPI3REF: OS Interface Object
  7.1105 -**
  7.1106 -** An instance of the sqlite3_vfs object defines the interface between
  7.1107 -** the SQLite core and the underlying operating system.  The "vfs"
  7.1108 -** in the name of the object stands for "virtual file system".  See
  7.1109 -** the [VFS | VFS documentation] for further information.
  7.1110 -**
  7.1111 -** The value of the iVersion field is initially 1 but may be larger in
  7.1112 -** future versions of SQLite.  Additional fields may be appended to this
  7.1113 -** object when the iVersion value is increased.  Note that the structure
  7.1114 -** of the sqlite3_vfs object changes in the transaction between
  7.1115 -** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not
  7.1116 -** modified.
  7.1117 -**
  7.1118 -** The szOsFile field is the size of the subclassed [sqlite3_file]
  7.1119 -** structure used by this VFS.  mxPathname is the maximum length of
  7.1120 -** a pathname in this VFS.
  7.1121 -**
  7.1122 -** Registered sqlite3_vfs objects are kept on a linked list formed by
  7.1123 -** the pNext pointer.  The [sqlite3_vfs_register()]
  7.1124 -** and [sqlite3_vfs_unregister()] interfaces manage this list
  7.1125 -** in a thread-safe way.  The [sqlite3_vfs_find()] interface
  7.1126 -** searches the list.  Neither the application code nor the VFS
  7.1127 -** implementation should use the pNext pointer.
  7.1128 -**
  7.1129 -** The pNext field is the only field in the sqlite3_vfs
  7.1130 -** structure that SQLite will ever modify.  SQLite will only access
  7.1131 -** or modify this field while holding a particular static mutex.
  7.1132 -** The application should never modify anything within the sqlite3_vfs
  7.1133 -** object once the object has been registered.
  7.1134 -**
  7.1135 -** The zName field holds the name of the VFS module.  The name must
  7.1136 -** be unique across all VFS modules.
  7.1137 -**
  7.1138 -** [[sqlite3_vfs.xOpen]]
  7.1139 -** ^SQLite guarantees that the zFilename parameter to xOpen
  7.1140 -** is either a NULL pointer or string obtained
  7.1141 -** from xFullPathname() with an optional suffix added.
  7.1142 -** ^If a suffix is added to the zFilename parameter, it will
  7.1143 -** consist of a single "-" character followed by no more than
  7.1144 -** 11 alphanumeric and/or "-" characters.
  7.1145 -** ^SQLite further guarantees that
  7.1146 -** the string will be valid and unchanged until xClose() is
  7.1147 -** called. Because of the previous sentence,
  7.1148 -** the [sqlite3_file] can safely store a pointer to the
  7.1149 -** filename if it needs to remember the filename for some reason.
  7.1150 -** If the zFilename parameter to xOpen is a NULL pointer then xOpen
  7.1151 -** must invent its own temporary name for the file.  ^Whenever the 
  7.1152 -** xFilename parameter is NULL it will also be the case that the
  7.1153 -** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].
  7.1154 -**
  7.1155 -** The flags argument to xOpen() includes all bits set in
  7.1156 -** the flags argument to [sqlite3_open_v2()].  Or if [sqlite3_open()]
  7.1157 -** or [sqlite3_open16()] is used, then flags includes at least
  7.1158 -** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. 
  7.1159 -** If xOpen() opens a file read-only then it sets *pOutFlags to
  7.1160 -** include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.
  7.1161 -**
  7.1162 -** ^(SQLite will also add one of the following flags to the xOpen()
  7.1163 -** call, depending on the object being opened:
  7.1164 -**
  7.1165 -** <ul>
  7.1166 -** <li>  [SQLITE_OPEN_MAIN_DB]
  7.1167 -** <li>  [SQLITE_OPEN_MAIN_JOURNAL]
  7.1168 -** <li>  [SQLITE_OPEN_TEMP_DB]
  7.1169 -** <li>  [SQLITE_OPEN_TEMP_JOURNAL]
  7.1170 -** <li>  [SQLITE_OPEN_TRANSIENT_DB]
  7.1171 -** <li>  [SQLITE_OPEN_SUBJOURNAL]
  7.1172 -** <li>  [SQLITE_OPEN_MASTER_JOURNAL]
  7.1173 -** <li>  [SQLITE_OPEN_WAL]
  7.1174 -** </ul>)^
  7.1175 -**
  7.1176 -** The file I/O implementation can use the object type flags to
  7.1177 -** change the way it deals with files.  For example, an application
  7.1178 -** that does not care about crash recovery or rollback might make
  7.1179 -** the open of a journal file a no-op.  Writes to this journal would
  7.1180 -** also be no-ops, and any attempt to read the journal would return
  7.1181 -** SQLITE_IOERR.  Or the implementation might recognize that a database
  7.1182 -** file will be doing page-aligned sector reads and writes in a random
  7.1183 -** order and set up its I/O subsystem accordingly.
  7.1184 -**
  7.1185 -** SQLite might also add one of the following flags to the xOpen method:
  7.1186 -**
  7.1187 -** <ul>
  7.1188 -** <li> [SQLITE_OPEN_DELETEONCLOSE]
  7.1189 -** <li> [SQLITE_OPEN_EXCLUSIVE]
  7.1190 -** </ul>
  7.1191 -**
  7.1192 -** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be
  7.1193 -** deleted when it is closed.  ^The [SQLITE_OPEN_DELETEONCLOSE]
  7.1194 -** will be set for TEMP databases and their journals, transient
  7.1195 -** databases, and subjournals.
  7.1196 -**
  7.1197 -** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction
  7.1198 -** with the [SQLITE_OPEN_CREATE] flag, which are both directly
  7.1199 -** analogous to the O_EXCL and O_CREAT flags of the POSIX open()
  7.1200 -** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the 
  7.1201 -** SQLITE_OPEN_CREATE, is used to indicate that file should always
  7.1202 -** be created, and that it is an error if it already exists.
  7.1203 -** It is <i>not</i> used to indicate the file should be opened 
  7.1204 -** for exclusive access.
  7.1205 -**
  7.1206 -** ^At least szOsFile bytes of memory are allocated by SQLite
  7.1207 -** to hold the  [sqlite3_file] structure passed as the third
  7.1208 -** argument to xOpen.  The xOpen method does not have to
  7.1209 -** allocate the structure; it should just fill it in.  Note that
  7.1210 -** the xOpen method must set the sqlite3_file.pMethods to either
  7.1211 -** a valid [sqlite3_io_methods] object or to NULL.  xOpen must do
  7.1212 -** this even if the open fails.  SQLite expects that the sqlite3_file.pMethods
  7.1213 -** element will be valid after xOpen returns regardless of the success
  7.1214 -** or failure of the xOpen call.
  7.1215 -**
  7.1216 -** [[sqlite3_vfs.xAccess]]
  7.1217 -** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
  7.1218 -** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to
  7.1219 -** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]
  7.1220 -** to test whether a file is at least readable.   The file can be a
  7.1221 -** directory.
  7.1222 -**
  7.1223 -** ^SQLite will always allocate at least mxPathname+1 bytes for the
  7.1224 -** output buffer xFullPathname.  The exact size of the output buffer
  7.1225 -** is also passed as a parameter to both  methods. If the output buffer
  7.1226 -** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is
  7.1227 -** handled as a fatal error by SQLite, vfs implementations should endeavor
  7.1228 -** to prevent this by setting mxPathname to a sufficiently large value.
  7.1229 -**
  7.1230 -** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()
  7.1231 -** interfaces are not strictly a part of the filesystem, but they are
  7.1232 -** included in the VFS structure for completeness.
  7.1233 -** The xRandomness() function attempts to return nBytes bytes
  7.1234 -** of good-quality randomness into zOut.  The return value is
  7.1235 -** the actual number of bytes of randomness obtained.
  7.1236 -** The xSleep() method causes the calling thread to sleep for at
  7.1237 -** least the number of microseconds given.  ^The xCurrentTime()
  7.1238 -** method returns a Julian Day Number for the current date and time as
  7.1239 -** a floating point value.
  7.1240 -** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
  7.1241 -** Day Number multiplied by 86400000 (the number of milliseconds in 
  7.1242 -** a 24-hour day).  
  7.1243 -** ^SQLite will use the xCurrentTimeInt64() method to get the current
  7.1244 -** date and time if that method is available (if iVersion is 2 or 
  7.1245 -** greater and the function pointer is not NULL) and will fall back
  7.1246 -** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
  7.1247 -**
  7.1248 -** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces
  7.1249 -** are not used by the SQLite core.  These optional interfaces are provided
  7.1250 -** by some VFSes to facilitate testing of the VFS code. By overriding 
  7.1251 -** system calls with functions under its control, a test program can
  7.1252 -** simulate faults and error conditions that would otherwise be difficult
  7.1253 -** or impossible to induce.  The set of system calls that can be overridden
  7.1254 -** varies from one VFS to another, and from one version of the same VFS to the
  7.1255 -** next.  Applications that use these interfaces must be prepared for any
  7.1256 -** or all of these interfaces to be NULL or for their behavior to change
  7.1257 -** from one release to the next.  Applications must not attempt to access
  7.1258 -** any of these methods if the iVersion of the VFS is less than 3.
  7.1259 -*/
  7.1260 -typedef struct sqlite3_vfs sqlite3_vfs;
  7.1261 -typedef void (*sqlite3_syscall_ptr)(void);
  7.1262 -struct sqlite3_vfs {
  7.1263 -  int iVersion;            /* Structure version number (currently 3) */
  7.1264 -  int szOsFile;            /* Size of subclassed sqlite3_file */
  7.1265 -  int mxPathname;          /* Maximum file pathname length */
  7.1266 -  sqlite3_vfs *pNext;      /* Next registered VFS */
  7.1267 -  const char *zName;       /* Name of this virtual file system */
  7.1268 -  void *pAppData;          /* Pointer to application-specific data */
  7.1269 -  int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
  7.1270 -               int flags, int *pOutFlags);
  7.1271 -  int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
  7.1272 -  int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
  7.1273 -  int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);
  7.1274 -  void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
  7.1275 -  void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
  7.1276 -  void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
  7.1277 -  void (*xDlClose)(sqlite3_vfs*, void*);
  7.1278 -  int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
  7.1279 -  int (*xSleep)(sqlite3_vfs*, int microseconds);
  7.1280 -  int (*xCurrentTime)(sqlite3_vfs*, double*);
  7.1281 -  int (*xGetLastError)(sqlite3_vfs*, int, char *);
  7.1282 -  /*
  7.1283 -  ** The methods above are in version 1 of the sqlite_vfs object
  7.1284 -  ** definition.  Those that follow are added in version 2 or later
  7.1285 -  */
  7.1286 -  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
  7.1287 -  /*
  7.1288 -  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
  7.1289 -  ** Those below are for version 3 and greater.
  7.1290 -  */
  7.1291 -  int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);
  7.1292 -  sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);
  7.1293 -  const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);
  7.1294 -  /*
  7.1295 -  ** The methods above are in versions 1 through 3 of the sqlite_vfs object.
  7.1296 -  ** New fields may be appended in figure versions.  The iVersion
  7.1297 -  ** value will increment whenever this happens. 
  7.1298 -  */
  7.1299 -};
  7.1300 -
  7.1301 -/*
  7.1302 -** CAPI3REF: Flags for the xAccess VFS method
  7.1303 -**
  7.1304 -** These integer constants can be used as the third parameter to
  7.1305 -** the xAccess method of an [sqlite3_vfs] object.  They determine
  7.1306 -** what kind of permissions the xAccess method is looking for.
  7.1307 -** With SQLITE_ACCESS_EXISTS, the xAccess method
  7.1308 -** simply checks whether the file exists.
  7.1309 -** With SQLITE_ACCESS_READWRITE, the xAccess method
  7.1310 -** checks whether the named directory is both readable and writable
  7.1311 -** (in other words, if files can be added, removed, and renamed within
  7.1312 -** the directory).
  7.1313 -** The SQLITE_ACCESS_READWRITE constant is currently used only by the
  7.1314 -** [temp_store_directory pragma], though this could change in a future
  7.1315 -** release of SQLite.
  7.1316 -** With SQLITE_ACCESS_READ, the xAccess method
  7.1317 -** checks whether the file is readable.  The SQLITE_ACCESS_READ constant is
  7.1318 -** currently unused, though it might be used in a future release of
  7.1319 -** SQLite.
  7.1320 -*/
  7.1321 -#define SQLITE_ACCESS_EXISTS    0
  7.1322 -#define SQLITE_ACCESS_READWRITE 1   /* Used by PRAGMA temp_store_directory */
  7.1323 -#define SQLITE_ACCESS_READ      2   /* Unused */
  7.1324 -
  7.1325 -/*
  7.1326 -** CAPI3REF: Flags for the xShmLock VFS method
  7.1327 -**
  7.1328 -** These integer constants define the various locking operations
  7.1329 -** allowed by the xShmLock method of [sqlite3_io_methods].  The
  7.1330 -** following are the only legal combinations of flags to the
  7.1331 -** xShmLock method:
  7.1332 -**
  7.1333 -** <ul>
  7.1334 -** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_SHARED
  7.1335 -** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE
  7.1336 -** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED
  7.1337 -** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE
  7.1338 -** </ul>
  7.1339 -**
  7.1340 -** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
  7.1341 -** was given no the corresponding lock.  
  7.1342 -**
  7.1343 -** The xShmLock method can transition between unlocked and SHARED or
  7.1344 -** between unlocked and EXCLUSIVE.  It cannot transition between SHARED
  7.1345 -** and EXCLUSIVE.
  7.1346 -*/
  7.1347 -#define SQLITE_SHM_UNLOCK       1
  7.1348 -#define SQLITE_SHM_LOCK         2
  7.1349 -#define SQLITE_SHM_SHARED       4
  7.1350 -#define SQLITE_SHM_EXCLUSIVE    8
  7.1351 -
  7.1352 -/*
  7.1353 -** CAPI3REF: Maximum xShmLock index
  7.1354 -**
  7.1355 -** The xShmLock method on [sqlite3_io_methods] may use values
  7.1356 -** between 0 and this upper bound as its "offset" argument.
  7.1357 -** The SQLite core will never attempt to acquire or release a
  7.1358 -** lock outside of this range
  7.1359 -*/
  7.1360 -#define SQLITE_SHM_NLOCK        8
  7.1361 -
  7.1362 -
  7.1363 -/*
  7.1364 -** CAPI3REF: Initialize The SQLite Library
  7.1365 -**
  7.1366 -** ^The sqlite3_initialize() routine initializes the
  7.1367 -** SQLite library.  ^The sqlite3_shutdown() routine
  7.1368 -** deallocates any resources that were allocated by sqlite3_initialize().
  7.1369 -** These routines are designed to aid in process initialization and
  7.1370 -** shutdown on embedded systems.  Workstation applications using
  7.1371 -** SQLite normally do not need to invoke either of these routines.
  7.1372 -**
  7.1373 -** A call to sqlite3_initialize() is an "effective" call if it is
  7.1374 -** the first time sqlite3_initialize() is invoked during the lifetime of
  7.1375 -** the process, or if it is the first time sqlite3_initialize() is invoked
  7.1376 -** following a call to sqlite3_shutdown().  ^(Only an effective call
  7.1377 -** of sqlite3_initialize() does any initialization.  All other calls
  7.1378 -** are harmless no-ops.)^
  7.1379 -**
  7.1380 -** A call to sqlite3_shutdown() is an "effective" call if it is the first
  7.1381 -** call to sqlite3_shutdown() since the last sqlite3_initialize().  ^(Only
  7.1382 -** an effective call to sqlite3_shutdown() does any deinitialization.
  7.1383 -** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^
  7.1384 -**
  7.1385 -** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
  7.1386 -** is not.  The sqlite3_shutdown() interface must only be called from a
  7.1387 -** single thread.  All open [database connections] must be closed and all
  7.1388 -** other SQLite resources must be deallocated prior to invoking
  7.1389 -** sqlite3_shutdown().
  7.1390 -**
  7.1391 -** Among other things, ^sqlite3_initialize() will invoke
  7.1392 -** sqlite3_os_init().  Similarly, ^sqlite3_shutdown()
  7.1393 -** will invoke sqlite3_os_end().
  7.1394 -**
  7.1395 -** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.
  7.1396 -** ^If for some reason, sqlite3_initialize() is unable to initialize
  7.1397 -** the library (perhaps it is unable to allocate a needed resource such
  7.1398 -** as a mutex) it returns an [error code] other than [SQLITE_OK].
  7.1399 -**
  7.1400 -** ^The sqlite3_initialize() routine is called internally by many other
  7.1401 -** SQLite interfaces so that an application usually does not need to
  7.1402 -** invoke sqlite3_initialize() directly.  For example, [sqlite3_open()]
  7.1403 -** calls sqlite3_initialize() so the SQLite library will be automatically
  7.1404 -** initialized when [sqlite3_open()] is called if it has not be initialized
  7.1405 -** already.  ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
  7.1406 -** compile-time option, then the automatic calls to sqlite3_initialize()
  7.1407 -** are omitted and the application must call sqlite3_initialize() directly
  7.1408 -** prior to using any other SQLite interface.  For maximum portability,
  7.1409 -** it is recommended that applications always invoke sqlite3_initialize()
  7.1410 -** directly prior to using any other SQLite interface.  Future releases
  7.1411 -** of SQLite may require this.  In other words, the behavior exhibited
  7.1412 -** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the
  7.1413 -** default behavior in some future release of SQLite.
  7.1414 -**
  7.1415 -** The sqlite3_os_init() routine does operating-system specific
  7.1416 -** initialization of the SQLite library.  The sqlite3_os_end()
  7.1417 -** routine undoes the effect of sqlite3_os_init().  Typical tasks
  7.1418 -** performed by these routines include allocation or deallocation
  7.1419 -** of static resources, initialization of global variables,
  7.1420 -** setting up a default [sqlite3_vfs] module, or setting up
  7.1421 -** a default configuration using [sqlite3_config()].
  7.1422 -**
  7.1423 -** The application should never invoke either sqlite3_os_init()
  7.1424 -** or sqlite3_os_end() directly.  The application should only invoke
  7.1425 -** sqlite3_initialize() and sqlite3_shutdown().  The sqlite3_os_init()
  7.1426 -** interface is called automatically by sqlite3_initialize() and
  7.1427 -** sqlite3_os_end() is called by sqlite3_shutdown().  Appropriate
  7.1428 -** implementations for sqlite3_os_init() and sqlite3_os_end()
  7.1429 -** are built into SQLite when it is compiled for Unix, Windows, or OS/2.
  7.1430 -** When [custom builds | built for other platforms]
  7.1431 -** (using the [SQLITE_OS_OTHER=1] compile-time
  7.1432 -** option) the application must supply a suitable implementation for
  7.1433 -** sqlite3_os_init() and sqlite3_os_end().  An application-supplied
  7.1434 -** implementation of sqlite3_os_init() or sqlite3_os_end()
  7.1435 -** must return [SQLITE_OK] on success and some other [error code] upon
  7.1436 -** failure.
  7.1437 -*/
  7.1438 -SQLITE_API int sqlite3_initialize(void);
  7.1439 -SQLITE_API int sqlite3_shutdown(void);
  7.1440 -SQLITE_API int sqlite3_os_init(void);
  7.1441 -SQLITE_API int sqlite3_os_end(void);
  7.1442 -
  7.1443 -/*
  7.1444 -** CAPI3REF: Configuring The SQLite Library
  7.1445 -**
  7.1446 -** The sqlite3_config() interface is used to make global configuration
  7.1447 -** changes to SQLite in order to tune SQLite to the specific needs of
  7.1448 -** the application.  The default configuration is recommended for most
  7.1449 -** applications and so this routine is usually not necessary.  It is
  7.1450 -** provided to support rare applications with unusual needs.
  7.1451 -**
  7.1452 -** The sqlite3_config() interface is not threadsafe.  The application
  7.1453 -** must insure that no other SQLite interfaces are invoked by other
  7.1454 -** threads while sqlite3_config() is running.  Furthermore, sqlite3_config()
  7.1455 -** may only be invoked prior to library initialization using
  7.1456 -** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
  7.1457 -** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
  7.1458 -** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
  7.1459 -** Note, however, that ^sqlite3_config() can be called as part of the
  7.1460 -** implementation of an application-defined [sqlite3_os_init()].
  7.1461 -**
  7.1462 -** The first argument to sqlite3_config() is an integer
  7.1463 -** [configuration option] that determines
  7.1464 -** what property of SQLite is to be configured.  Subsequent arguments
  7.1465 -** vary depending on the [configuration option]
  7.1466 -** in the first argument.
  7.1467 -**
  7.1468 -** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
  7.1469 -** ^If the option is unknown or SQLite is unable to set the option
  7.1470 -** then this routine returns a non-zero [error code].
  7.1471 -*/
  7.1472 -SQLITE_API int sqlite3_config(int, ...);
  7.1473 -
  7.1474 -/*
  7.1475 -** CAPI3REF: Configure database connections
  7.1476 -**
  7.1477 -** The sqlite3_db_config() interface is used to make configuration
  7.1478 -** changes to a [database connection].  The interface is similar to
  7.1479 -** [sqlite3_config()] except that the changes apply to a single
  7.1480 -** [database connection] (specified in the first argument).
  7.1481 -**
  7.1482 -** The second argument to sqlite3_db_config(D,V,...)  is the
  7.1483 -** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code 
  7.1484 -** that indicates what aspect of the [database connection] is being configured.
  7.1485 -** Subsequent arguments vary depending on the configuration verb.
  7.1486 -**
  7.1487 -** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
  7.1488 -** the call is considered successful.
  7.1489 -*/
  7.1490 -SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
  7.1491 -
  7.1492 -/*
  7.1493 -** CAPI3REF: Memory Allocation Routines
  7.1494 -**
  7.1495 -** An instance of this object defines the interface between SQLite
  7.1496 -** and low-level memory allocation routines.
  7.1497 -**
  7.1498 -** This object is used in only one place in the SQLite interface.
  7.1499 -** A pointer to an instance of this object is the argument to
  7.1500 -** [sqlite3_config()] when the configuration option is
  7.1501 -** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].  
  7.1502 -** By creating an instance of this object
  7.1503 -** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])
  7.1504 -** during configuration, an application can specify an alternative
  7.1505 -** memory allocation subsystem for SQLite to use for all of its
  7.1506 -** dynamic memory needs.
  7.1507 -**
  7.1508 -** Note that SQLite comes with several [built-in memory allocators]
  7.1509 -** that are perfectly adequate for the overwhelming majority of applications
  7.1510 -** and that this object is only useful to a tiny minority of applications
  7.1511 -** with specialized memory allocation requirements.  This object is
  7.1512 -** also used during testing of SQLite in order to specify an alternative
  7.1513 -** memory allocator that simulates memory out-of-memory conditions in
  7.1514 -** order to verify that SQLite recovers gracefully from such
  7.1515 -** conditions.
  7.1516 -**
  7.1517 -** The xMalloc, xRealloc, and xFree methods must work like the
  7.1518 -** malloc(), realloc() and free() functions from the standard C library.
  7.1519 -** ^SQLite guarantees that the second argument to
  7.1520 -** xRealloc is always a value returned by a prior call to xRoundup.
  7.1521 -**
  7.1522 -** xSize should return the allocated size of a memory allocation
  7.1523 -** previously obtained from xMalloc or xRealloc.  The allocated size
  7.1524 -** is always at least as big as the requested size but may be larger.
  7.1525 -**
  7.1526 -** The xRoundup method returns what would be the allocated size of
  7.1527 -** a memory allocation given a particular requested size.  Most memory
  7.1528 -** allocators round up memory allocations at least to the next multiple
  7.1529 -** of 8.  Some allocators round up to a larger multiple or to a power of 2.
  7.1530 -** Every memory allocation request coming in through [sqlite3_malloc()]
  7.1531 -** or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0, 
  7.1532 -** that causes the corresponding memory allocation to fail.
  7.1533 -**
  7.1534 -** The xInit method initializes the memory allocator.  For example,
  7.1535 -** it might allocate any require mutexes or initialize internal data
  7.1536 -** structures.  The xShutdown method is invoked (indirectly) by
  7.1537 -** [sqlite3_shutdown()] and should deallocate any resources acquired
  7.1538 -** by xInit.  The pAppData pointer is used as the only parameter to
  7.1539 -** xInit and xShutdown.
  7.1540 -**
  7.1541 -** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes
  7.1542 -** the xInit method, so the xInit method need not be threadsafe.  The
  7.1543 -** xShutdown method is only called from [sqlite3_shutdown()] so it does
  7.1544 -** not need to be threadsafe either.  For all other methods, SQLite
  7.1545 -** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the
  7.1546 -** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which
  7.1547 -** it is by default) and so the methods are automatically serialized.
  7.1548 -** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other
  7.1549 -** methods must be threadsafe or else make their own arrangements for
  7.1550 -** serialization.
  7.1551 -**
  7.1552 -** SQLite will never invoke xInit() more than once without an intervening
  7.1553 -** call to xShutdown().
  7.1554 -*/
  7.1555 -typedef struct sqlite3_mem_methods sqlite3_mem_methods;
  7.1556 -struct sqlite3_mem_methods {
  7.1557 -  void *(*xMalloc)(int);         /* Memory allocation function */
  7.1558 -  void (*xFree)(void*);          /* Free a prior allocation */
  7.1559 -  void *(*xRealloc)(void*,int);  /* Resize an allocation */
  7.1560 -  int (*xSize)(void*);           /* Return the size of an allocation */
  7.1561 -  int (*xRoundup)(int);          /* Round up request size to allocation size */
  7.1562 -  int (*xInit)(void*);           /* Initialize the memory allocator */
  7.1563 -  void (*xShutdown)(void*);      /* Deinitialize the memory allocator */
  7.1564 -  void *pAppData;                /* Argument to xInit() and xShutdown() */
  7.1565 -};
  7.1566 -
  7.1567 -/*
  7.1568 -** CAPI3REF: Configuration Options
  7.1569 -** KEYWORDS: {configuration option}
  7.1570 -**
  7.1571 -** These constants are the available integer configuration options that
  7.1572 -** can be passed as the first argument to the [sqlite3_config()] interface.
  7.1573 -**
  7.1574 -** New configuration options may be added in future releases of SQLite.
  7.1575 -** Existing configuration options might be discontinued.  Applications
  7.1576 -** should check the return code from [sqlite3_config()] to make sure that
  7.1577 -** the call worked.  The [sqlite3_config()] interface will return a
  7.1578 -** non-zero [error code] if a discontinued or unsupported configuration option
  7.1579 -** is invoked.
  7.1580 -**
  7.1581 -** <dl>
  7.1582 -** [[SQLITE_CONFIG_SINGLETHREAD]] <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
  7.1583 -** <dd>There are no arguments to this option.  ^This option sets the
  7.1584 -** [threading mode] to Single-thread.  In other words, it disables
  7.1585 -** all mutexing and puts SQLite into a mode where it can only be used
  7.1586 -** by a single thread.   ^If SQLite is compiled with
  7.1587 -** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  7.1588 -** it is not possible to change the [threading mode] from its default
  7.1589 -** value of Single-thread and so [sqlite3_config()] will return 
  7.1590 -** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD
  7.1591 -** configuration option.</dd>
  7.1592 -**
  7.1593 -** [[SQLITE_CONFIG_MULTITHREAD]] <dt>SQLITE_CONFIG_MULTITHREAD</dt>
  7.1594 -** <dd>There are no arguments to this option.  ^This option sets the
  7.1595 -** [threading mode] to Multi-thread.  In other words, it disables
  7.1596 -** mutexing on [database connection] and [prepared statement] objects.
  7.1597 -** The application is responsible for serializing access to
  7.1598 -** [database connections] and [prepared statements].  But other mutexes
  7.1599 -** are enabled so that SQLite will be safe to use in a multi-threaded
  7.1600 -** environment as long as no two threads attempt to use the same
  7.1601 -** [database connection] at the same time.  ^If SQLite is compiled with
  7.1602 -** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  7.1603 -** it is not possible to set the Multi-thread [threading mode] and
  7.1604 -** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
  7.1605 -** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>
  7.1606 -**
  7.1607 -** [[SQLITE_CONFIG_SERIALIZED]] <dt>SQLITE_CONFIG_SERIALIZED</dt>
  7.1608 -** <dd>There are no arguments to this option.  ^This option sets the
  7.1609 -** [threading mode] to Serialized. In other words, this option enables
  7.1610 -** all mutexes including the recursive
  7.1611 -** mutexes on [database connection] and [prepared statement] objects.
  7.1612 -** In this mode (which is the default when SQLite is compiled with
  7.1613 -** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access
  7.1614 -** to [database connections] and [prepared statements] so that the
  7.1615 -** application is free to use the same [database connection] or the
  7.1616 -** same [prepared statement] in different threads at the same time.
  7.1617 -** ^If SQLite is compiled with
  7.1618 -** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  7.1619 -** it is not possible to set the Serialized [threading mode] and
  7.1620 -** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
  7.1621 -** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
  7.1622 -**
  7.1623 -** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>
  7.1624 -** <dd> ^(This option takes a single argument which is a pointer to an
  7.1625 -** instance of the [sqlite3_mem_methods] structure.  The argument specifies
  7.1626 -** alternative low-level memory allocation routines to be used in place of
  7.1627 -** the memory allocation routines built into SQLite.)^ ^SQLite makes
  7.1628 -** its own private copy of the content of the [sqlite3_mem_methods] structure
  7.1629 -** before the [sqlite3_config()] call returns.</dd>
  7.1630 -**
  7.1631 -** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>
  7.1632 -** <dd> ^(This option takes a single argument which is a pointer to an
  7.1633 -** instance of the [sqlite3_mem_methods] structure.  The [sqlite3_mem_methods]
  7.1634 -** structure is filled with the currently defined memory allocation routines.)^
  7.1635 -** This option can be used to overload the default memory allocation
  7.1636 -** routines with a wrapper that simulations memory allocation failure or
  7.1637 -** tracks memory usage, for example. </dd>
  7.1638 -**
  7.1639 -** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>
  7.1640 -** <dd> ^This option takes single argument of type int, interpreted as a 
  7.1641 -** boolean, which enables or disables the collection of memory allocation 
  7.1642 -** statistics. ^(When memory allocation statistics are disabled, the 
  7.1643 -** following SQLite interfaces become non-operational:
  7.1644 -**   <ul>
  7.1645 -**   <li> [sqlite3_memory_used()]
  7.1646 -**   <li> [sqlite3_memory_highwater()]
  7.1647 -**   <li> [sqlite3_soft_heap_limit64()]
  7.1648 -**   <li> [sqlite3_status()]
  7.1649 -**   </ul>)^
  7.1650 -** ^Memory allocation statistics are enabled by default unless SQLite is
  7.1651 -** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
  7.1652 -** allocation statistics are disabled by default.
  7.1653 -** </dd>
  7.1654 -**
  7.1655 -** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>
  7.1656 -** <dd> ^This option specifies a static memory buffer that SQLite can use for
  7.1657 -** scratch memory.  There are three arguments:  A pointer an 8-byte
  7.1658 -** aligned memory buffer from which the scratch allocations will be
  7.1659 -** drawn, the size of each scratch allocation (sz),
  7.1660 -** and the maximum number of scratch allocations (N).  The sz
  7.1661 -** argument must be a multiple of 16.
  7.1662 -** The first argument must be a pointer to an 8-byte aligned buffer
  7.1663 -** of at least sz*N bytes of memory.
  7.1664 -** ^SQLite will use no more than two scratch buffers per thread.  So
  7.1665 -** N should be set to twice the expected maximum number of threads.
  7.1666 -** ^SQLite will never require a scratch buffer that is more than 6
  7.1667 -** times the database page size. ^If SQLite needs needs additional
  7.1668 -** scratch memory beyond what is provided by this configuration option, then 
  7.1669 -** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
  7.1670 -**
  7.1671 -** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
  7.1672 -** <dd> ^This option specifies a static memory buffer that SQLite can use for
  7.1673 -** the database page cache with the default page cache implementation.  
  7.1674 -** This configuration should not be used if an application-define page
  7.1675 -** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option.
  7.1676 -** There are three arguments to this option: A pointer to 8-byte aligned
  7.1677 -** memory, the size of each page buffer (sz), and the number of pages (N).
  7.1678 -** The sz argument should be the size of the largest database page
  7.1679 -** (a power of two between 512 and 32768) plus a little extra for each
  7.1680 -** page header.  ^The page header size is 20 to 40 bytes depending on
  7.1681 -** the host architecture.  ^It is harmless, apart from the wasted memory,
  7.1682 -** to make sz a little too large.  The first
  7.1683 -** argument should point to an allocation of at least sz*N bytes of memory.
  7.1684 -** ^SQLite will use the memory provided by the first argument to satisfy its
  7.1685 -** memory needs for the first N pages that it adds to cache.  ^If additional
  7.1686 -** page cache memory is needed beyond what is provided by this option, then
  7.1687 -** SQLite goes to [sqlite3_malloc()] for the additional storage space.
  7.1688 -** The pointer in the first argument must
  7.1689 -** be aligned to an 8-byte boundary or subsequent behavior of SQLite
  7.1690 -** will be undefined.</dd>
  7.1691 -**
  7.1692 -** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>
  7.1693 -** <dd> ^This option specifies a static memory buffer that SQLite will use
  7.1694 -** for all of its dynamic memory allocation needs beyond those provided
  7.1695 -** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
  7.1696 -** There are three arguments: An 8-byte aligned pointer to the memory,
  7.1697 -** the number of bytes in the memory buffer, and the minimum allocation size.
  7.1698 -** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
  7.1699 -** to using its default memory allocator (the system malloc() implementation),
  7.1700 -** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the
  7.1701 -** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
  7.1702 -** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
  7.1703 -** allocator is engaged to handle all of SQLites memory allocation needs.
  7.1704 -** The first pointer (the memory pointer) must be aligned to an 8-byte
  7.1705 -** boundary or subsequent behavior of SQLite will be undefined.
  7.1706 -** The minimum allocation size is capped at 2**12. Reasonable values
  7.1707 -** for the minimum allocation size are 2**5 through 2**8.</dd>
  7.1708 -**
  7.1709 -** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>
  7.1710 -** <dd> ^(This option takes a single argument which is a pointer to an
  7.1711 -** instance of the [sqlite3_mutex_methods] structure.  The argument specifies
  7.1712 -** alternative low-level mutex routines to be used in place
  7.1713 -** the mutex routines built into SQLite.)^  ^SQLite makes a copy of the
  7.1714 -** content of the [sqlite3_mutex_methods] structure before the call to
  7.1715 -** [sqlite3_config()] returns. ^If SQLite is compiled with
  7.1716 -** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  7.1717 -** the entire mutexing subsystem is omitted from the build and hence calls to
  7.1718 -** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will
  7.1719 -** return [SQLITE_ERROR].</dd>
  7.1720 -**
  7.1721 -** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>
  7.1722 -** <dd> ^(This option takes a single argument which is a pointer to an
  7.1723 -** instance of the [sqlite3_mutex_methods] structure.  The
  7.1724 -** [sqlite3_mutex_methods]
  7.1725 -** structure is filled with the currently defined mutex routines.)^
  7.1726 -** This option can be used to overload the default mutex allocation
  7.1727 -** routines with a wrapper used to track mutex usage for performance
  7.1728 -** profiling or testing, for example.   ^If SQLite is compiled with
  7.1729 -** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  7.1730 -** the entire mutexing subsystem is omitted from the build and hence calls to
  7.1731 -** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
  7.1732 -** return [SQLITE_ERROR].</dd>
  7.1733 -**
  7.1734 -** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
  7.1735 -** <dd> ^(This option takes two arguments that determine the default
  7.1736 -** memory allocation for the lookaside memory allocator on each
  7.1737 -** [database connection].  The first argument is the
  7.1738 -** size of each lookaside buffer slot and the second is the number of
  7.1739 -** slots allocated to each database connection.)^  ^(This option sets the
  7.1740 -** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
  7.1741 -** verb to [sqlite3_db_config()] can be used to change the lookaside
  7.1742 -** configuration on individual connections.)^ </dd>
  7.1743 -**
  7.1744 -** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
  7.1745 -** <dd> ^(This option takes a single argument which is a pointer to
  7.1746 -** an [sqlite3_pcache_methods2] object.  This object specifies the interface
  7.1747 -** to a custom page cache implementation.)^  ^SQLite makes a copy of the
  7.1748 -** object and uses it for page cache memory allocations.</dd>
  7.1749 -**
  7.1750 -** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>
  7.1751 -** <dd> ^(This option takes a single argument which is a pointer to an
  7.1752 -** [sqlite3_pcache_methods2] object.  SQLite copies of the current
  7.1753 -** page cache implementation into that object.)^ </dd>
  7.1754 -**
  7.1755 -** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>
  7.1756 -** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite
  7.1757 -** global [error log].
  7.1758 -** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a
  7.1759 -** function with a call signature of void(*)(void*,int,const char*), 
  7.1760 -** and a pointer to void. ^If the function pointer is not NULL, it is
  7.1761 -** invoked by [sqlite3_log()] to process each logging event.  ^If the
  7.1762 -** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.
  7.1763 -** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is
  7.1764 -** passed through as the first parameter to the application-defined logger
  7.1765 -** function whenever that function is invoked.  ^The second parameter to
  7.1766 -** the logger function is a copy of the first parameter to the corresponding
  7.1767 -** [sqlite3_log()] call and is intended to be a [result code] or an
  7.1768 -** [extended result code].  ^The third parameter passed to the logger is
  7.1769 -** log message after formatting via [sqlite3_snprintf()].
  7.1770 -** The SQLite logging interface is not reentrant; the logger function
  7.1771 -** supplied by the application must not invoke any SQLite interface.
  7.1772 -** In a multi-threaded application, the application-defined logger
  7.1773 -** function must be threadsafe. </dd>
  7.1774 -**
  7.1775 -** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
  7.1776 -** <dd>^(This option takes a single argument of type int. If non-zero, then
  7.1777 -** URI handling is globally enabled. If the parameter is zero, then URI handling
  7.1778 -** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
  7.1779 -** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
  7.1780 -** specified as part of [ATTACH] commands are interpreted as URIs, regardless
  7.1781 -** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
  7.1782 -** connection is opened. ^If it is globally disabled, filenames are
  7.1783 -** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
  7.1784 -** database connection is opened. ^(By default, URI handling is globally
  7.1785 -** disabled. The default value may be changed by compiling with the
  7.1786 -** [SQLITE_USE_URI] symbol defined.)^
  7.1787 -**
  7.1788 -** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
  7.1789 -** <dd>^This option takes a single integer argument which is interpreted as
  7.1790 -** a boolean in order to enable or disable the use of covering indices for
  7.1791 -** full table scans in the query optimizer.  ^The default setting is determined
  7.1792 -** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
  7.1793 -** if that compile-time option is omitted.
  7.1794 -** The ability to disable the use of covering indices for full table scans
  7.1795 -** is because some incorrectly coded legacy applications might malfunction
  7.1796 -** when the optimization is enabled.  Providing the ability to
  7.1797 -** disable the optimization allows the older, buggy application code to work
  7.1798 -** without change even with newer versions of SQLite.
  7.1799 -**
  7.1800 -** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
  7.1801 -** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
  7.1802 -** <dd> These options are obsolete and should not be used by new code.
  7.1803 -** They are retained for backwards compatibility but are now no-ops.
  7.1804 -** </dd>
  7.1805 -**
  7.1806 -** [[SQLITE_CONFIG_SQLLOG]]
  7.1807 -** <dt>SQLITE_CONFIG_SQLLOG
  7.1808 -** <dd>This option is only available if sqlite is compiled with the
  7.1809 -** [SQLITE_ENABLE_SQLLOG] pre-processor macro defined. The first argument should
  7.1810 -** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).
  7.1811 -** The second should be of type (void*). The callback is invoked by the library
  7.1812 -** in three separate circumstances, identified by the value passed as the
  7.1813 -** fourth parameter. If the fourth parameter is 0, then the database connection
  7.1814 -** passed as the second argument has just been opened. The third argument
  7.1815 -** points to a buffer containing the name of the main database file. If the
  7.1816 -** fourth parameter is 1, then the SQL statement that the third parameter
  7.1817 -** points to has just been executed. Or, if the fourth parameter is 2, then
  7.1818 -** the connection being passed as the second parameter is being closed. The
  7.1819 -** third parameter is passed NULL In this case.  An example of using this
  7.1820 -** configuration option can be seen in the "test_sqllog.c" source file in
  7.1821 -** the canonical SQLite source tree.</dd>
  7.1822 -**
  7.1823 -** [[SQLITE_CONFIG_MMAP_SIZE]]
  7.1824 -** <dt>SQLITE_CONFIG_MMAP_SIZE
  7.1825 -** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
  7.1826 -** that are the default mmap size limit (the default setting for
  7.1827 -** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
  7.1828 -** ^The default setting can be overridden by each database connection using
  7.1829 -** either the [PRAGMA mmap_size] command, or by using the
  7.1830 -** [SQLITE_FCNTL_MMAP_SIZE] file control.  ^(The maximum allowed mmap size
  7.1831 -** cannot be changed at run-time.  Nor may the maximum allowed mmap size
  7.1832 -** exceed the compile-time maximum mmap size set by the
  7.1833 -** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
  7.1834 -** ^If either argument to this option is negative, then that argument is
  7.1835 -** changed to its compile-time default.
  7.1836 -**
  7.1837 -** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]
  7.1838 -** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
  7.1839 -** <dd>^This option is only available if SQLite is compiled for Windows
  7.1840 -** with the [SQLITE_WIN32_MALLOC] pre-processor macro defined.
  7.1841 -** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
  7.1842 -** that specifies the maximum size of the created heap.
  7.1843 -** </dl>
  7.1844 -*/
  7.1845 -#define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
  7.1846 -#define SQLITE_CONFIG_MULTITHREAD   2  /* nil */
  7.1847 -#define SQLITE_CONFIG_SERIALIZED    3  /* nil */
  7.1848 -#define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */
  7.1849 -#define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */
  7.1850 -#define SQLITE_CONFIG_SCRATCH       6  /* void*, int sz, int N */
  7.1851 -#define SQLITE_CONFIG_PAGECACHE     7  /* void*, int sz, int N */
  7.1852 -#define SQLITE_CONFIG_HEAP          8  /* void*, int nByte, int min */
  7.1853 -#define SQLITE_CONFIG_MEMSTATUS     9  /* boolean */
  7.1854 -#define SQLITE_CONFIG_MUTEX        10  /* sqlite3_mutex_methods* */
  7.1855 -#define SQLITE_CONFIG_GETMUTEX     11  /* sqlite3_mutex_methods* */
  7.1856 -/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ 
  7.1857 -#define SQLITE_CONFIG_LOOKASIDE    13  /* int int */
  7.1858 -#define SQLITE_CONFIG_PCACHE       14  /* no-op */
  7.1859 -#define SQLITE_CONFIG_GETPCACHE    15  /* no-op */
  7.1860 -#define SQLITE_CONFIG_LOG          16  /* xFunc, void* */
  7.1861 -#define SQLITE_CONFIG_URI          17  /* int */
  7.1862 -#define SQLITE_CONFIG_PCACHE2      18  /* sqlite3_pcache_methods2* */
  7.1863 -#define SQLITE_CONFIG_GETPCACHE2   19  /* sqlite3_pcache_methods2* */
  7.1864 -#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20  /* int */
  7.1865 -#define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */
  7.1866 -#define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */
  7.1867 -#define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */
  7.1868 -
  7.1869 -/*
  7.1870 -** CAPI3REF: Database Connection Configuration Options
  7.1871 -**
  7.1872 -** These constants are the available integer configuration options that
  7.1873 -** can be passed as the second argument to the [sqlite3_db_config()] interface.
  7.1874 -**
  7.1875 -** New configuration options may be added in future releases of SQLite.
  7.1876 -** Existing configuration options might be discontinued.  Applications
  7.1877 -** should check the return code from [sqlite3_db_config()] to make sure that
  7.1878 -** the call worked.  ^The [sqlite3_db_config()] interface will return a
  7.1879 -** non-zero [error code] if a discontinued or unsupported configuration option
  7.1880 -** is invoked.
  7.1881 -**
  7.1882 -** <dl>
  7.1883 -** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
  7.1884 -** <dd> ^This option takes three additional arguments that determine the 
  7.1885 -** [lookaside memory allocator] configuration for the [database connection].
  7.1886 -** ^The first argument (the third parameter to [sqlite3_db_config()] is a
  7.1887 -** pointer to a memory buffer to use for lookaside memory.
  7.1888 -** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
  7.1889 -** may be NULL in which case SQLite will allocate the
  7.1890 -** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
  7.1891 -** size of each lookaside buffer slot.  ^The third argument is the number of
  7.1892 -** slots.  The size of the buffer in the first argument must be greater than
  7.1893 -** or equal to the product of the second and third arguments.  The buffer
  7.1894 -** must be aligned to an 8-byte boundary.  ^If the second argument to
  7.1895 -** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
  7.1896 -** rounded down to the next smaller multiple of 8.  ^(The lookaside memory
  7.1897 -** configuration for a database connection can only be changed when that
  7.1898 -** connection is not currently using lookaside memory, or in other words
  7.1899 -** when the "current value" returned by
  7.1900 -** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.
  7.1901 -** Any attempt to change the lookaside memory configuration when lookaside
  7.1902 -** memory is in use leaves the configuration unchanged and returns 
  7.1903 -** [SQLITE_BUSY].)^</dd>
  7.1904 -**
  7.1905 -** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
  7.1906 -** <dd> ^This option is used to enable or disable the enforcement of
  7.1907 -** [foreign key constraints].  There should be two additional arguments.
  7.1908 -** The first argument is an integer which is 0 to disable FK enforcement,
  7.1909 -** positive to enable FK enforcement or negative to leave FK enforcement
  7.1910 -** unchanged.  The second parameter is a pointer to an integer into which
  7.1911 -** is written 0 or 1 to indicate whether FK enforcement is off or on
  7.1912 -** following this call.  The second parameter may be a NULL pointer, in
  7.1913 -** which case the FK enforcement setting is not reported back. </dd>
  7.1914 -**
  7.1915 -** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>
  7.1916 -** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].
  7.1917 -** There should be two additional arguments.
  7.1918 -** The first argument is an integer which is 0 to disable triggers,
  7.1919 -** positive to enable triggers or negative to leave the setting unchanged.
  7.1920 -** The second parameter is a pointer to an integer into which
  7.1921 -** is written 0 or 1 to indicate whether triggers are disabled or enabled
  7.1922 -** following this call.  The second parameter may be a NULL pointer, in
  7.1923 -** which case the trigger setting is not reported back. </dd>
  7.1924 -**
  7.1925 -** </dl>
  7.1926 -*/
  7.1927 -#define SQLITE_DBCONFIG_LOOKASIDE       1001  /* void* int int */
  7.1928 -#define SQLITE_DBCONFIG_ENABLE_FKEY     1002  /* int int* */
  7.1929 -#define SQLITE_DBCONFIG_ENABLE_TRIGGER  1003  /* int int* */
  7.1930 -
  7.1931 -
  7.1932 -/*
  7.1933 -** CAPI3REF: Enable Or Disable Extended Result Codes
  7.1934 -**
  7.1935 -** ^The sqlite3_extended_result_codes() routine enables or disables the
  7.1936 -** [extended result codes] feature of SQLite. ^The extended result
  7.1937 -** codes are disabled by default for historical compatibility.
  7.1938 -*/
  7.1939 -SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
  7.1940 -
  7.1941 -/*
  7.1942 -** CAPI3REF: Last Insert Rowid
  7.1943 -**
  7.1944 -** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
  7.1945 -** has a unique 64-bit signed
  7.1946 -** integer key called the [ROWID | "rowid"]. ^The rowid is always available
  7.1947 -** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
  7.1948 -** names are not also used by explicitly declared columns. ^If
  7.1949 -** the table has a column of type [INTEGER PRIMARY KEY] then that column
  7.1950 -** is another alias for the rowid.
  7.1951 -**
  7.1952 -** ^The sqlite3_last_insert_rowid(D) interface returns the [rowid] of the 
  7.1953 -** most recent successful [INSERT] into a rowid table or [virtual table]
  7.1954 -** on database connection D.
  7.1955 -** ^Inserts into [WITHOUT ROWID] tables are not recorded.
  7.1956 -** ^If no successful [INSERT]s into rowid tables
  7.1957 -** have ever occurred on the database connection D, 
  7.1958 -** then sqlite3_last_insert_rowid(D) returns zero.
  7.1959 -**
  7.1960 -** ^(If an [INSERT] occurs within a trigger or within a [virtual table]
  7.1961 -** method, then this routine will return the [rowid] of the inserted
  7.1962 -** row as long as the trigger or virtual table method is running.
  7.1963 -** But once the trigger or virtual table method ends, the value returned 
  7.1964 -** by this routine reverts to what it was before the trigger or virtual
  7.1965 -** table method began.)^
  7.1966 -**
  7.1967 -** ^An [INSERT] that fails due to a constraint violation is not a
  7.1968 -** successful [INSERT] and does not change the value returned by this
  7.1969 -** routine.  ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
  7.1970 -** and INSERT OR ABORT make no changes to the return value of this
  7.1971 -** routine when their insertion fails.  ^(When INSERT OR REPLACE
  7.1972 -** encounters a constraint violation, it does not fail.  The
  7.1973 -** INSERT continues to completion after deleting rows that caused
  7.1974 -** the constraint problem so INSERT OR REPLACE will always change
  7.1975 -** the return value of this interface.)^
  7.1976 -**
  7.1977 -** ^For the purposes of this routine, an [INSERT] is considered to
  7.1978 -** be successful even if it is subsequently rolled back.
  7.1979 -**
  7.1980 -** This function is accessible to SQL statements via the
  7.1981 -** [last_insert_rowid() SQL function].
  7.1982 -**
  7.1983 -** If a separate thread performs a new [INSERT] on the same
  7.1984 -** database connection while the [sqlite3_last_insert_rowid()]
  7.1985 -** function is running and thus changes the last insert [rowid],
  7.1986 -** then the value returned by [sqlite3_last_insert_rowid()] is
  7.1987 -** unpredictable and might not equal either the old or the new
  7.1988 -** last insert [rowid].
  7.1989 -*/
  7.1990 -SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
  7.1991 -
  7.1992 -/*
  7.1993 -** CAPI3REF: Count The Number Of Rows Modified
  7.1994 -**
  7.1995 -** ^This function returns the number of database rows that were changed
  7.1996 -** or inserted or deleted by the most recently completed SQL statement
  7.1997 -** on the [database connection] specified by the first parameter.
  7.1998 -** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
  7.1999 -** or [DELETE] statement are counted.  Auxiliary changes caused by
  7.2000 -** triggers or [foreign key actions] are not counted.)^ Use the
  7.2001 -** [sqlite3_total_changes()] function to find the total number of changes
  7.2002 -** including changes caused by triggers and foreign key actions.
  7.2003 -**
  7.2004 -** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
  7.2005 -** are not counted.  Only real table changes are counted.
  7.2006 -**
  7.2007 -** ^(A "row change" is a change to a single row of a single table
  7.2008 -** caused by an INSERT, DELETE, or UPDATE statement.  Rows that
  7.2009 -** are changed as side effects of [REPLACE] constraint resolution,
  7.2010 -** rollback, ABORT processing, [DROP TABLE], or by any other
  7.2011 -** mechanisms do not count as direct row changes.)^
  7.2012 -**
  7.2013 -** A "trigger context" is a scope of execution that begins and
  7.2014 -** ends with the script of a [CREATE TRIGGER | trigger]. 
  7.2015 -** Most SQL statements are
  7.2016 -** evaluated outside of any trigger.  This is the "top level"
  7.2017 -** trigger context.  If a trigger fires from the top level, a
  7.2018 -** new trigger context is entered for the duration of that one
  7.2019 -** trigger.  Subtriggers create subcontexts for their duration.
  7.2020 -**
  7.2021 -** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
  7.2022 -** not create a new trigger context.
  7.2023 -**
  7.2024 -** ^This function returns the number of direct row changes in the
  7.2025 -** most recent INSERT, UPDATE, or DELETE statement within the same
  7.2026 -** trigger context.
  7.2027 -**
  7.2028 -** ^Thus, when called from the top level, this function returns the
  7.2029 -** number of changes in the most recent INSERT, UPDATE, or DELETE
  7.2030 -** that also occurred at the top level.  ^(Within the body of a trigger,
  7.2031 -** the sqlite3_changes() interface can be called to find the number of
  7.2032 -** changes in the most recently completed INSERT, UPDATE, or DELETE
  7.2033 -** statement within the body of the same trigger.
  7.2034 -** However, the number returned does not include changes
  7.2035 -** caused by subtriggers since those have their own context.)^
  7.2036 -**
  7.2037 -** See also the [sqlite3_total_changes()] interface, the
  7.2038 -** [count_changes pragma], and the [changes() SQL function].
  7.2039 -**
  7.2040 -** If a separate thread makes changes on the same database connection
  7.2041 -** while [sqlite3_changes()] is running then the value returned
  7.2042 -** is unpredictable and not meaningful.
  7.2043 -*/
  7.2044 -SQLITE_API int sqlite3_changes(sqlite3*);
  7.2045 -
  7.2046 -/*
  7.2047 -** CAPI3REF: Total Number Of Rows Modified
  7.2048 -**
  7.2049 -** ^This function returns the number of row changes caused by [INSERT],
  7.2050 -** [UPDATE] or [DELETE] statements since the [database connection] was opened.
  7.2051 -** ^(The count returned by sqlite3_total_changes() includes all changes
  7.2052 -** from all [CREATE TRIGGER | trigger] contexts and changes made by
  7.2053 -** [foreign key actions]. However,
  7.2054 -** the count does not include changes used to implement [REPLACE] constraints,
  7.2055 -** do rollbacks or ABORT processing, or [DROP TABLE] processing.  The
  7.2056 -** count does not include rows of views that fire an [INSTEAD OF trigger],
  7.2057 -** though if the INSTEAD OF trigger makes changes of its own, those changes 
  7.2058 -** are counted.)^
  7.2059 -** ^The sqlite3_total_changes() function counts the changes as soon as
  7.2060 -** the statement that makes them is completed (when the statement handle
  7.2061 -** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
  7.2062 -**
  7.2063 -** See also the [sqlite3_changes()] interface, the
  7.2064 -** [count_changes pragma], and the [total_changes() SQL function].
  7.2065 -**
  7.2066 -** If a separate thread makes changes on the same database connection
  7.2067 -** while [sqlite3_total_changes()] is running then the value
  7.2068 -** returned is unpredictable and not meaningful.
  7.2069 -*/
  7.2070 -SQLITE_API int sqlite3_total_changes(sqlite3*);
  7.2071 -
  7.2072 -/*
  7.2073 -** CAPI3REF: Interrupt A Long-Running Query
  7.2074 -**
  7.2075 -** ^This function causes any pending database operation to abort and
  7.2076 -** return at its earliest opportunity. This routine is typically
  7.2077 -** called in response to a user action such as pressing "Cancel"
  7.2078 -** or Ctrl-C where the user wants a long query operation to halt
  7.2079 -** immediately.
  7.2080 -**
  7.2081 -** ^It is safe to call this routine from a thread different from the
  7.2082 -** thread that is currently running the database operation.  But it
  7.2083 -** is not safe to call this routine with a [database connection] that
  7.2084 -** is closed or might close before sqlite3_interrupt() returns.
  7.2085 -**
  7.2086 -** ^If an SQL operation is very nearly finished at the time when
  7.2087 -** sqlite3_interrupt() is called, then it might not have an opportunity
  7.2088 -** to be interrupted and might continue to completion.
  7.2089 -**
  7.2090 -** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
  7.2091 -** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
  7.2092 -** that is inside an explicit transaction, then the entire transaction
  7.2093 -** will be rolled back automatically.
  7.2094 -**
  7.2095 -** ^The sqlite3_interrupt(D) call is in effect until all currently running
  7.2096 -** SQL statements on [database connection] D complete.  ^Any new SQL statements
  7.2097 -** that are started after the sqlite3_interrupt() call and before the 
  7.2098 -** running statements reaches zero are interrupted as if they had been
  7.2099 -** running prior to the sqlite3_interrupt() call.  ^New SQL statements
  7.2100 -** that are started after the running statement count reaches zero are
  7.2101 -** not effected by the sqlite3_interrupt().
  7.2102 -** ^A call to sqlite3_interrupt(D) that occurs when there are no running
  7.2103 -** SQL statements is a no-op and has no effect on SQL statements
  7.2104 -** that are started after the sqlite3_interrupt() call returns.
  7.2105 -**
  7.2106 -** If the database connection closes while [sqlite3_interrupt()]
  7.2107 -** is running then bad things will likely happen.
  7.2108 -*/
  7.2109 -SQLITE_API void sqlite3_interrupt(sqlite3*);
  7.2110 -
  7.2111 -/*
  7.2112 -** CAPI3REF: Determine If An SQL Statement Is Complete
  7.2113 -**
  7.2114 -** These routines are useful during command-line input to determine if the
  7.2115 -** currently entered text seems to form a complete SQL statement or
  7.2116 -** if additional input is needed before sending the text into
  7.2117 -** SQLite for parsing.  ^These routines return 1 if the input string
  7.2118 -** appears to be a complete SQL statement.  ^A statement is judged to be
  7.2119 -** complete if it ends with a semicolon token and is not a prefix of a
  7.2120 -** well-formed CREATE TRIGGER statement.  ^Semicolons that are embedded within
  7.2121 -** string literals or quoted identifier names or comments are not
  7.2122 -** independent tokens (they are part of the token in which they are
  7.2123 -** embedded) and thus do not count as a statement terminator.  ^Whitespace
  7.2124 -** and comments that follow the final semicolon are ignored.
  7.2125 -**
  7.2126 -** ^These routines return 0 if the statement is incomplete.  ^If a
  7.2127 -** memory allocation fails, then SQLITE_NOMEM is returned.
  7.2128 -**
  7.2129 -** ^These routines do not parse the SQL statements thus
  7.2130 -** will not detect syntactically incorrect SQL.
  7.2131 -**
  7.2132 -** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior 
  7.2133 -** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
  7.2134 -** automatically by sqlite3_complete16().  If that initialization fails,
  7.2135 -** then the return value from sqlite3_complete16() will be non-zero
  7.2136 -** regardless of whether or not the input SQL is complete.)^
  7.2137 -**
  7.2138 -** The input to [sqlite3_complete()] must be a zero-terminated
  7.2139 -** UTF-8 string.
  7.2140 -**
  7.2141 -** The input to [sqlite3_complete16()] must be a zero-terminated
  7.2142 -** UTF-16 string in native byte order.
  7.2143 -*/
  7.2144 -SQLITE_API int sqlite3_complete(const char *sql);
  7.2145 -SQLITE_API int sqlite3_complete16(const void *sql);
  7.2146 -
  7.2147 -/*
  7.2148 -** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
  7.2149 -**
  7.2150 -** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
  7.2151 -** that might be invoked with argument P whenever
  7.2152 -** an attempt is made to access a database table associated with
  7.2153 -** [database connection] D when another thread
  7.2154 -** or process has the table locked.
  7.2155 -** The sqlite3_busy_handler() interface is used to implement
  7.2156 -** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout].
  7.2157 -**
  7.2158 -** ^If the busy callback is NULL, then [SQLITE_BUSY]
  7.2159 -** is returned immediately upon encountering the lock.  ^If the busy callback
  7.2160 -** is not NULL, then the callback might be invoked with two arguments.
  7.2161 -**
  7.2162 -** ^The first argument to the busy handler is a copy of the void* pointer which
  7.2163 -** is the third argument to sqlite3_busy_handler().  ^The second argument to
  7.2164 -** the busy handler callback is the number of times that the busy handler has
  7.2165 -** been invoked for the same locking event.  ^If the
  7.2166 -** busy callback returns 0, then no additional attempts are made to
  7.2167 -** access the database and [SQLITE_BUSY] is returned
  7.2168 -** to the application.
  7.2169 -** ^If the callback returns non-zero, then another attempt
  7.2170 -** is made to access the database and the cycle repeats.
  7.2171 -**
  7.2172 -** The presence of a busy handler does not guarantee that it will be invoked
  7.2173 -** when there is lock contention. ^If SQLite determines that invoking the busy
  7.2174 -** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]
  7.2175 -** to the application instead of invoking the 
  7.2176 -** busy handler.
  7.2177 -** Consider a scenario where one process is holding a read lock that
  7.2178 -** it is trying to promote to a reserved lock and
  7.2179 -** a second process is holding a reserved lock that it is trying
  7.2180 -** to promote to an exclusive lock.  The first process cannot proceed
  7.2181 -** because it is blocked by the second and the second process cannot
  7.2182 -** proceed because it is blocked by the first.  If both processes
  7.2183 -** invoke the busy handlers, neither will make any progress.  Therefore,
  7.2184 -** SQLite returns [SQLITE_BUSY] for the first process, hoping that this
  7.2185 -** will induce the first process to release its read lock and allow
  7.2186 -** the second process to proceed.
  7.2187 -**
  7.2188 -** ^The default busy callback is NULL.
  7.2189 -**
  7.2190 -** ^(There can only be a single busy handler defined for each
  7.2191 -** [database connection].  Setting a new busy handler clears any
  7.2192 -** previously set handler.)^  ^Note that calling [sqlite3_busy_timeout()]
  7.2193 -** or evaluating [PRAGMA busy_timeout=N] will change the
  7.2194 -** busy handler and thus clear any previously set busy handler.
  7.2195 -**
  7.2196 -** The busy callback should not take any actions which modify the
  7.2197 -** database connection that invoked the busy handler.  In other words,
  7.2198 -** the busy handler is not reentrant.  Any such actions
  7.2199 -** result in undefined behavior.
  7.2200 -** 
  7.2201 -** A busy handler must not close the database connection
  7.2202 -** or [prepared statement] that invoked the busy handler.
  7.2203 -*/
  7.2204 -SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
  7.2205 -
  7.2206 -/*
  7.2207 -** CAPI3REF: Set A Busy Timeout
  7.2208 -**
  7.2209 -** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
  7.2210 -** for a specified amount of time when a table is locked.  ^The handler
  7.2211 -** will sleep multiple times until at least "ms" milliseconds of sleeping
  7.2212 -** have accumulated.  ^After at least "ms" milliseconds of sleeping,
  7.2213 -** the handler returns 0 which causes [sqlite3_step()] to return
  7.2214 -** [SQLITE_BUSY].
  7.2215 -**
  7.2216 -** ^Calling this routine with an argument less than or equal to zero
  7.2217 -** turns off all busy handlers.
  7.2218 -**
  7.2219 -** ^(There can only be a single busy handler for a particular
  7.2220 -** [database connection] any any given moment.  If another busy handler
  7.2221 -** was defined  (using [sqlite3_busy_handler()]) prior to calling
  7.2222 -** this routine, that other busy handler is cleared.)^
  7.2223 -**
  7.2224 -** See also:  [PRAGMA busy_timeout]
  7.2225 -*/
  7.2226 -SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
  7.2227 -
  7.2228 -/*
  7.2229 -** CAPI3REF: Convenience Routines For Running Queries
  7.2230 -**
  7.2231 -** This is a legacy interface that is preserved for backwards compatibility.
  7.2232 -** Use of this interface is not recommended.
  7.2233 -**
  7.2234 -** Definition: A <b>result table</b> is memory data structure created by the
  7.2235 -** [sqlite3_get_table()] interface.  A result table records the
  7.2236 -** complete query results from one or more queries.
  7.2237 -**
  7.2238 -** The table conceptually has a number of rows and columns.  But
  7.2239 -** these numbers are not part of the result table itself.  These
  7.2240 -** numbers are obtained separately.  Let N be the number of rows
  7.2241 -** and M be the number of columns.
  7.2242 -**
  7.2243 -** A result table is an array of pointers to zero-terminated UTF-8 strings.
  7.2244 -** There are (N+1)*M elements in the array.  The first M pointers point
  7.2245 -** to zero-terminated strings that  contain the names of the columns.
  7.2246 -** The remaining entries all point to query results.  NULL values result
  7.2247 -** in NULL pointers.  All other values are in their UTF-8 zero-terminated
  7.2248 -** string representation as returned by [sqlite3_column_text()].
  7.2249 -**
  7.2250 -** A result table might consist of one or more memory allocations.
  7.2251 -** It is not safe to pass a result table directly to [sqlite3_free()].
  7.2252 -** A result table should be deallocated using [sqlite3_free_table()].
  7.2253 -**
  7.2254 -** ^(As an example of the result table format, suppose a query result
  7.2255 -** is as follows:
  7.2256 -**
  7.2257 -** <blockquote><pre>
  7.2258 -**        Name        | Age
  7.2259 -**        -----------------------
  7.2260 -**        Alice       | 43
  7.2261 -**        Bob         | 28
  7.2262 -**        Cindy       | 21
  7.2263 -** </pre></blockquote>
  7.2264 -**
  7.2265 -** There are two column (M==2) and three rows (N==3).  Thus the
  7.2266 -** result table has 8 entries.  Suppose the result table is stored
  7.2267 -** in an array names azResult.  Then azResult holds this content:
  7.2268 -**
  7.2269 -** <blockquote><pre>
  7.2270 -**        azResult&#91;0] = "Name";
  7.2271 -**        azResult&#91;1] = "Age";
  7.2272 -**        azResult&#91;2] = "Alice";
  7.2273 -**        azResult&#91;3] = "43";
  7.2274 -**        azResult&#91;4] = "Bob";
  7.2275 -**        azResult&#91;5] = "28";
  7.2276 -**        azResult&#91;6] = "Cindy";
  7.2277 -**        azResult&#91;7] = "21";
  7.2278 -** </pre></blockquote>)^
  7.2279 -**
  7.2280 -** ^The sqlite3_get_table() function evaluates one or more
  7.2281 -** semicolon-separated SQL statements in the zero-terminated UTF-8
  7.2282 -** string of its 2nd parameter and returns a result table to the
  7.2283 -** pointer given in its 3rd parameter.
  7.2284 -**
  7.2285 -** After the application has finished with the result from sqlite3_get_table(),
  7.2286 -** it must pass the result table pointer to sqlite3_free_table() in order to
  7.2287 -** release the memory that was malloced.  Because of the way the
  7.2288 -** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling
  7.2289 -** function must not try to call [sqlite3_free()] directly.  Only
  7.2290 -** [sqlite3_free_table()] is able to release the memory properly and safely.
  7.2291 -**
  7.2292 -** The sqlite3_get_table() interface is implemented as a wrapper around
  7.2293 -** [sqlite3_exec()].  The sqlite3_get_table() routine does not have access
  7.2294 -** to any internal data structures of SQLite.  It uses only the public
  7.2295 -** interface defined here.  As a consequence, errors that occur in the
  7.2296 -** wrapper layer outside of the internal [sqlite3_exec()] call are not
  7.2297 -** reflected in subsequent calls to [sqlite3_errcode()] or
  7.2298 -** [sqlite3_errmsg()].
  7.2299 -*/
  7.2300 -SQLITE_API int sqlite3_get_table(
  7.2301 -  sqlite3 *db,          /* An open database */
  7.2302 -  const char *zSql,     /* SQL to be evaluated */
  7.2303 -  char ***pazResult,    /* Results of the query */
  7.2304 -  int *pnRow,           /* Number of result rows written here */
  7.2305 -  int *pnColumn,        /* Number of result columns written here */
  7.2306 -  char **pzErrmsg       /* Error msg written here */
  7.2307 -);
  7.2308 -SQLITE_API void sqlite3_free_table(char **result);
  7.2309 -
  7.2310 -/*
  7.2311 -** CAPI3REF: Formatted String Printing Functions
  7.2312 -**
  7.2313 -** These routines are work-alikes of the "printf()" family of functions
  7.2314 -** from the standard C library.
  7.2315 -**
  7.2316 -** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
  7.2317 -** results into memory obtained from [sqlite3_malloc()].
  7.2318 -** The strings returned by these two routines should be
  7.2319 -** released by [sqlite3_free()].  ^Both routines return a
  7.2320 -** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
  7.2321 -** memory to hold the resulting string.
  7.2322 -**
  7.2323 -** ^(The sqlite3_snprintf() routine is similar to "snprintf()" from
  7.2324 -** the standard C library.  The result is written into the
  7.2325 -** buffer supplied as the second parameter whose size is given by
  7.2326 -** the first parameter. Note that the order of the
  7.2327 -** first two parameters is reversed from snprintf().)^  This is an
  7.2328 -** historical accident that cannot be fixed without breaking
  7.2329 -** backwards compatibility.  ^(Note also that sqlite3_snprintf()
  7.2330 -** returns a pointer to its buffer instead of the number of
  7.2331 -** characters actually written into the buffer.)^  We admit that
  7.2332 -** the number of characters written would be a more useful return
  7.2333 -** value but we cannot change the implementation of sqlite3_snprintf()
  7.2334 -** now without breaking compatibility.
  7.2335 -**
  7.2336 -** ^As long as the buffer size is greater than zero, sqlite3_snprintf()
  7.2337 -** guarantees that the buffer is always zero-terminated.  ^The first
  7.2338 -** parameter "n" is the total size of the buffer, including space for
  7.2339 -** the zero terminator.  So the longest string that can be completely
  7.2340 -** written will be n-1 characters.
  7.2341 -**
  7.2342 -** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf().
  7.2343 -**
  7.2344 -** These routines all implement some additional formatting
  7.2345 -** options that are useful for constructing SQL statements.
  7.2346 -** All of the usual printf() formatting options apply.  In addition, there
  7.2347 -** is are "%q", "%Q", and "%z" options.
  7.2348 -**
  7.2349 -** ^(The %q option works like %s in that it substitutes a nul-terminated
  7.2350 -** string from the argument list.  But %q also doubles every '\'' character.
  7.2351 -** %q is designed for use inside a string literal.)^  By doubling each '\''
  7.2352 -** character it escapes that character and allows it to be inserted into
  7.2353 -** the string.
  7.2354 -**
  7.2355 -** For example, assume the string variable zText contains text as follows:
  7.2356 -**
  7.2357 -** <blockquote><pre>
  7.2358 -**  char *zText = "It's a happy day!";
  7.2359 -** </pre></blockquote>
  7.2360 -**
  7.2361 -** One can use this text in an SQL statement as follows:
  7.2362 -**
  7.2363 -** <blockquote><pre>
  7.2364 -**  char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText);
  7.2365 -**  sqlite3_exec(db, zSQL, 0, 0, 0);
  7.2366 -**  sqlite3_free(zSQL);
  7.2367 -** </pre></blockquote>
  7.2368 -**
  7.2369 -** Because the %q format string is used, the '\'' character in zText
  7.2370 -** is escaped and the SQL generated is as follows:
  7.2371 -**
  7.2372 -** <blockquote><pre>
  7.2373 -**  INSERT INTO table1 VALUES('It''s a happy day!')
  7.2374 -** </pre></blockquote>
  7.2375 -**
  7.2376 -** This is correct.  Had we used %s instead of %q, the generated SQL
  7.2377 -** would have looked like this:
  7.2378 -**
  7.2379 -** <blockquote><pre>
  7.2380 -**  INSERT INTO table1 VALUES('It's a happy day!');
  7.2381 -** </pre></blockquote>
  7.2382 -**
  7.2383 -** This second example is an SQL syntax error.  As a general rule you should
  7.2384 -** always use %q instead of %s when inserting text into a string literal.
  7.2385 -**
  7.2386 -** ^(The %Q option works like %q except it also adds single quotes around
  7.2387 -** the outside of the total string.  Additionally, if the parameter in the
  7.2388 -** argument list is a NULL pointer, %Q substitutes the text "NULL" (without
  7.2389 -** single quotes).)^  So, for example, one could say:
  7.2390 -**
  7.2391 -** <blockquote><pre>
  7.2392 -**  char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
  7.2393 -**  sqlite3_exec(db, zSQL, 0, 0, 0);
  7.2394 -**  sqlite3_free(zSQL);
  7.2395 -** </pre></blockquote>
  7.2396 -**
  7.2397 -** The code above will render a correct SQL statement in the zSQL
  7.2398 -** variable even if the zText variable is a NULL pointer.
  7.2399 -**
  7.2400 -** ^(The "%z" formatting option works like "%s" but with the
  7.2401 -** addition that after the string has been read and copied into
  7.2402 -** the result, [sqlite3_free()] is called on the input string.)^
  7.2403 -*/
  7.2404 -SQLITE_API char *sqlite3_mprintf(const char*,...);
  7.2405 -SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
  7.2406 -SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
  7.2407 -SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
  7.2408 -
  7.2409 -/*
  7.2410 -** CAPI3REF: Memory Allocation Subsystem
  7.2411 -**
  7.2412 -** The SQLite core uses these three routines for all of its own
  7.2413 -** internal memory allocation needs. "Core" in the previous sentence
  7.2414 -** does not include operating-system specific VFS implementation.  The
  7.2415 -** Windows VFS uses native malloc() and free() for some operations.
  7.2416 -**
  7.2417 -** ^The sqlite3_malloc() routine returns a pointer to a block
  7.2418 -** of memory at least N bytes in length, where N is the parameter.
  7.2419 -** ^If sqlite3_malloc() is unable to obtain sufficient free
  7.2420 -** memory, it returns a NULL pointer.  ^If the parameter N to
  7.2421 -** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
  7.2422 -** a NULL pointer.
  7.2423 -**
  7.2424 -** ^Calling sqlite3_free() with a pointer previously returned
  7.2425 -** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
  7.2426 -** that it might be reused.  ^The sqlite3_free() routine is
  7.2427 -** a no-op if is called with a NULL pointer.  Passing a NULL pointer
  7.2428 -** to sqlite3_free() is harmless.  After being freed, memory
  7.2429 -** should neither be read nor written.  Even reading previously freed
  7.2430 -** memory might result in a segmentation fault or other severe error.
  7.2431 -** Memory corruption, a segmentation fault, or other severe error
  7.2432 -** might result if sqlite3_free() is called with a non-NULL pointer that
  7.2433 -** was not obtained from sqlite3_malloc() or sqlite3_realloc().
  7.2434 -**
  7.2435 -** ^(The sqlite3_realloc() interface attempts to resize a
  7.2436 -** prior memory allocation to be at least N bytes, where N is the
  7.2437 -** second parameter.  The memory allocation to be resized is the first
  7.2438 -** parameter.)^ ^ If the first parameter to sqlite3_realloc()
  7.2439 -** is a NULL pointer then its behavior is identical to calling
  7.2440 -** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
  7.2441 -** ^If the second parameter to sqlite3_realloc() is zero or
  7.2442 -** negative then the behavior is exactly the same as calling
  7.2443 -** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
  7.2444 -** ^sqlite3_realloc() returns a pointer to a memory allocation
  7.2445 -** of at least N bytes in size or NULL if sufficient memory is unavailable.
  7.2446 -** ^If M is the size of the prior allocation, then min(N,M) bytes
  7.2447 -** of the prior allocation are copied into the beginning of buffer returned
  7.2448 -** by sqlite3_realloc() and the prior allocation is freed.
  7.2449 -** ^If sqlite3_realloc() returns NULL, then the prior allocation
  7.2450 -** is not freed.
  7.2451 -**
  7.2452 -** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
  7.2453 -** is always aligned to at least an 8 byte boundary, or to a
  7.2454 -** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
  7.2455 -** option is used.
  7.2456 -**
  7.2457 -** In SQLite version 3.5.0 and 3.5.1, it was possible to define
  7.2458 -** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
  7.2459 -** implementation of these routines to be omitted.  That capability
  7.2460 -** is no longer provided.  Only built-in memory allocators can be used.
  7.2461 -**
  7.2462 -** Prior to SQLite version 3.7.10, the Windows OS interface layer called
  7.2463 -** the system malloc() and free() directly when converting
  7.2464 -** filenames between the UTF-8 encoding used by SQLite
  7.2465 -** and whatever filename encoding is used by the particular Windows
  7.2466 -** installation.  Memory allocation errors were detected, but
  7.2467 -** they were reported back as [SQLITE_CANTOPEN] or
  7.2468 -** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
  7.2469 -**
  7.2470 -** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
  7.2471 -** must be either NULL or else pointers obtained from a prior
  7.2472 -** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
  7.2473 -** not yet been released.
  7.2474 -**
  7.2475 -** The application must not read or write any part of
  7.2476 -** a block of memory after it has been released using
  7.2477 -** [sqlite3_free()] or [sqlite3_realloc()].
  7.2478 -*/
  7.2479 -SQLITE_API void *sqlite3_malloc(int);
  7.2480 -SQLITE_API void *sqlite3_realloc(void*, int);
  7.2481 -SQLITE_API void sqlite3_free(void*);
  7.2482 -
  7.2483 -/*
  7.2484 -** CAPI3REF: Memory Allocator Statistics
  7.2485 -**
  7.2486 -** SQLite provides these two interfaces for reporting on the status
  7.2487 -** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]
  7.2488 -** routines, which form the built-in memory allocation subsystem.
  7.2489 -**
  7.2490 -** ^The [sqlite3_memory_used()] routine returns the number of bytes
  7.2491 -** of memory currently outstanding (malloced but not freed).
  7.2492 -** ^The [sqlite3_memory_highwater()] routine returns the maximum
  7.2493 -** value of [sqlite3_memory_used()] since the high-water mark
  7.2494 -** was last reset.  ^The values returned by [sqlite3_memory_used()] and
  7.2495 -** [sqlite3_memory_highwater()] include any overhead
  7.2496 -** added by SQLite in its implementation of [sqlite3_malloc()],
  7.2497 -** but not overhead added by the any underlying system library
  7.2498 -** routines that [sqlite3_malloc()] may call.
  7.2499 -**
  7.2500 -** ^The memory high-water mark is reset to the current value of
  7.2501 -** [sqlite3_memory_used()] if and only if the parameter to
  7.2502 -** [sqlite3_memory_highwater()] is true.  ^The value returned
  7.2503 -** by [sqlite3_memory_highwater(1)] is the high-water mark
  7.2504 -** prior to the reset.
  7.2505 -*/
  7.2506 -SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
  7.2507 -SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
  7.2508 -
  7.2509 -/*
  7.2510 -** CAPI3REF: Pseudo-Random Number Generator
  7.2511 -**
  7.2512 -** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
  7.2513 -** select random [ROWID | ROWIDs] when inserting new records into a table that
  7.2514 -** already uses the largest possible [ROWID].  The PRNG is also used for
  7.2515 -** the build-in random() and randomblob() SQL functions.  This interface allows
  7.2516 -** applications to access the same PRNG for other purposes.
  7.2517 -**
  7.2518 -** ^A call to this routine stores N bytes of randomness into buffer P.
  7.2519 -** ^If N is less than one, then P can be a NULL pointer.
  7.2520 -**
  7.2521 -** ^If this routine has not been previously called or if the previous
  7.2522 -** call had N less than one, then the PRNG is seeded using randomness
  7.2523 -** obtained from the xRandomness method of the default [sqlite3_vfs] object.
  7.2524 -** ^If the previous call to this routine had an N of 1 or more then
  7.2525 -** the pseudo-randomness is generated
  7.2526 -** internally and without recourse to the [sqlite3_vfs] xRandomness
  7.2527 -** method.
  7.2528 -*/
  7.2529 -SQLITE_API void sqlite3_randomness(int N, void *P);
  7.2530 -
  7.2531 -/*
  7.2532 -** CAPI3REF: Compile-Time Authorization Callbacks
  7.2533 -**
  7.2534 -** ^This routine registers an authorizer callback with a particular
  7.2535 -** [database connection], supplied in the first argument.
  7.2536 -** ^The authorizer callback is invoked as SQL statements are being compiled
  7.2537 -** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
  7.2538 -** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()].  ^At various
  7.2539 -** points during the compilation process, as logic is being created
  7.2540 -** to perform various actions, the authorizer callback is invoked to
  7.2541 -** see if those actions are allowed.  ^The authorizer callback should
  7.2542 -** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
  7.2543 -** specific action but allow the SQL statement to continue to be
  7.2544 -** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
  7.2545 -** rejected with an error.  ^If the authorizer callback returns
  7.2546 -** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
  7.2547 -** then the [sqlite3_prepare_v2()] or equivalent call that triggered
  7.2548 -** the authorizer will fail with an error message.
  7.2549 -**
  7.2550 -** When the callback returns [SQLITE_OK], that means the operation
  7.2551 -** requested is ok.  ^When the callback returns [SQLITE_DENY], the
  7.2552 -** [sqlite3_prepare_v2()] or equivalent call that triggered the
  7.2553 -** authorizer will fail with an error message explaining that
  7.2554 -** access is denied. 
  7.2555 -**
  7.2556 -** ^The first parameter to the authorizer callback is a copy of the third
  7.2557 -** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
  7.2558 -** to the callback is an integer [SQLITE_COPY | action code] that specifies
  7.2559 -** the particular action to be authorized. ^The third through sixth parameters
  7.2560 -** to the callback are zero-terminated strings that contain additional
  7.2561 -** details about the action to be authorized.
  7.2562 -**
  7.2563 -** ^If the action code is [SQLITE_READ]
  7.2564 -** and the callback returns [SQLITE_IGNORE] then the
  7.2565 -** [prepared statement] statement is constructed to substitute
  7.2566 -** a NULL value in place of the table column that would have
  7.2567 -** been read if [SQLITE_OK] had been returned.  The [SQLITE_IGNORE]
  7.2568 -** return can be used to deny an untrusted user access to individual
  7.2569 -** columns of a table.
  7.2570 -** ^If the action code is [SQLITE_DELETE] and the callback returns
  7.2571 -** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
  7.2572 -** [truncate optimization] is disabled and all rows are deleted individually.
  7.2573 -**
  7.2574 -** An authorizer is used when [sqlite3_prepare | preparing]
  7.2575 -** SQL statements from an untrusted source, to ensure that the SQL statements
  7.2576 -** do not try to access data they are not allowed to see, or that they do not
  7.2577 -** try to execute malicious statements that damage the database.  For
  7.2578 -** example, an application may allow a user to enter arbitrary
  7.2579 -** SQL queries for evaluation by a database.  But the application does
  7.2580 -** not want the user to be able to make arbitrary changes to the
  7.2581 -** database.  An authorizer could then be put in place while the
  7.2582 -** user-entered SQL is being [sqlite3_prepare | prepared] that
  7.2583 -** disallows everything except [SELECT] statements.
  7.2584 -**
  7.2585 -** Applications that need to process SQL from untrusted sources
  7.2586 -** might also consider lowering resource limits using [sqlite3_limit()]
  7.2587 -** and limiting database size using the [max_page_count] [PRAGMA]
  7.2588 -** in addition to using an authorizer.
  7.2589 -**
  7.2590 -** ^(Only a single authorizer can be in place on a database connection
  7.2591 -** at a time.  Each call to sqlite3_set_authorizer overrides the
  7.2592 -** previous call.)^  ^Disable the authorizer by installing a NULL callback.
  7.2593 -** The authorizer is disabled by default.
  7.2594 -**
  7.2595 -** The authorizer callback must not do anything that will modify
  7.2596 -** the database connection that invoked the authorizer callback.
  7.2597 -** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
  7.2598 -** database connections for the meaning of "modify" in this paragraph.
  7.2599 -**
  7.2600 -** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
  7.2601 -** statement might be re-prepared during [sqlite3_step()] due to a 
  7.2602 -** schema change.  Hence, the application should ensure that the
  7.2603 -** correct authorizer callback remains in place during the [sqlite3_step()].
  7.2604 -**
  7.2605 -** ^Note that the authorizer callback is invoked only during
  7.2606 -** [sqlite3_prepare()] or its variants.  Authorization is not
  7.2607 -** performed during statement evaluation in [sqlite3_step()], unless
  7.2608 -** as stated in the previous paragraph, sqlite3_step() invokes
  7.2609 -** sqlite3_prepare_v2() to reprepare a statement after a schema change.
  7.2610 -*/
  7.2611 -SQLITE_API int sqlite3_set_authorizer(
  7.2612 -  sqlite3*,
  7.2613 -  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
  7.2614 -  void *pUserData
  7.2615 -);
  7.2616 -
  7.2617 -/*
  7.2618 -** CAPI3REF: Authorizer Return Codes
  7.2619 -**
  7.2620 -** The [sqlite3_set_authorizer | authorizer callback function] must
  7.2621 -** return either [SQLITE_OK] or one of these two constants in order
  7.2622 -** to signal SQLite whether or not the action is permitted.  See the
  7.2623 -** [sqlite3_set_authorizer | authorizer documentation] for additional
  7.2624 -** information.
  7.2625 -**
  7.2626 -** Note that SQLITE_IGNORE is also used as a [conflict resolution mode]
  7.2627 -** returned from the [sqlite3_vtab_on_conflict()] interface.
  7.2628 -*/
  7.2629 -#define SQLITE_DENY   1   /* Abort the SQL statement with an error */
  7.2630 -#define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */
  7.2631 -
  7.2632 -/*
  7.2633 -** CAPI3REF: Authorizer Action Codes
  7.2634 -**
  7.2635 -** The [sqlite3_set_authorizer()] interface registers a callback function
  7.2636 -** that is invoked to authorize certain SQL statement actions.  The
  7.2637 -** second parameter to the callback is an integer code that specifies
  7.2638 -** what action is being authorized.  These are the integer action codes that
  7.2639 -** the authorizer callback may be passed.
  7.2640 -**
  7.2641 -** These action code values signify what kind of operation is to be
  7.2642 -** authorized.  The 3rd and 4th parameters to the authorization
  7.2643 -** callback function will be parameters or NULL depending on which of these
  7.2644 -** codes is used as the second parameter.  ^(The 5th parameter to the
  7.2645 -** authorizer callback is the name of the database ("main", "temp",
  7.2646 -** etc.) if applicable.)^  ^The 6th parameter to the authorizer callback
  7.2647 -** is the name of the inner-most trigger or view that is responsible for
  7.2648 -** the access attempt or NULL if this access attempt is directly from
  7.2649 -** top-level SQL code.
  7.2650 -*/
  7.2651 -/******************************************* 3rd ************ 4th ***********/
  7.2652 -#define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */
  7.2653 -#define SQLITE_CREATE_TABLE          2   /* Table Name      NULL            */
  7.2654 -#define SQLITE_CREATE_TEMP_INDEX     3   /* Index Name      Table Name      */
  7.2655 -#define SQLITE_CREATE_TEMP_TABLE     4   /* Table Name      NULL            */
  7.2656 -#define SQLITE_CREATE_TEMP_TRIGGER   5   /* Trigger Name    Table Name      */
  7.2657 -#define SQLITE_CREATE_TEMP_VIEW      6   /* View Name       NULL            */
  7.2658 -#define SQLITE_CREATE_TRIGGER        7   /* Trigger Name    Table Name      */
  7.2659 -#define SQLITE_CREATE_VIEW           8   /* View Name       NULL            */
  7.2660 -#define SQLITE_DELETE                9   /* Table Name      NULL            */
  7.2661 -#define SQLITE_DROP_INDEX           10   /* Index Name      Table Name      */
  7.2662 -#define SQLITE_DROP_TABLE           11   /* Table Name      NULL            */
  7.2663 -#define SQLITE_DROP_TEMP_INDEX      12   /* Index Name      Table Name      */
  7.2664 -#define SQLITE_DROP_TEMP_TABLE      13   /* Table Name      NULL            */
  7.2665 -#define SQLITE_DROP_TEMP_TRIGGER    14   /* Trigger Name    Table Name      */
  7.2666 -#define SQLITE_DROP_TEMP_VIEW       15   /* View Name       NULL            */
  7.2667 -#define SQLITE_DROP_TRIGGER         16   /* Trigger Name    Table Name      */
  7.2668 -#define SQLITE_DROP_VIEW            17   /* View Name       NULL            */
  7.2669 -#define SQLITE_INSERT               18   /* Table Name      NULL            */
  7.2670 -#define SQLITE_PRAGMA               19   /* Pragma Name     1st arg or NULL */
  7.2671 -#define SQLITE_READ                 20   /* Table Name      Column Name     */
  7.2672 -#define SQLITE_SELECT               21   /* NULL            NULL            */
  7.2673 -#define SQLITE_TRANSACTION          22   /* Operation       NULL            */
  7.2674 -#define SQLITE_UPDATE               23   /* Table Name      Column Name     */
  7.2675 -#define SQLITE_ATTACH               24   /* Filename        NULL            */
  7.2676 -#define SQLITE_DETACH               25   /* Database Name   NULL            */
  7.2677 -#define SQLITE_ALTER_TABLE          26   /* Database Name   Table Name      */
  7.2678 -#define SQLITE_REINDEX              27   /* Index Name      NULL            */
  7.2679 -#define SQLITE_ANALYZE              28   /* Table Name      NULL            */
  7.2680 -#define SQLITE_CREATE_VTABLE        29   /* Table Name      Module Name     */
  7.2681 -#define SQLITE_DROP_VTABLE          30   /* Table Name      Module Name     */
  7.2682 -#define SQLITE_FUNCTION             31   /* NULL            Function Name   */
  7.2683 -#define SQLITE_SAVEPOINT            32   /* Operation       Savepoint Name  */
  7.2684 -#define SQLITE_COPY                  0   /* No longer used */
  7.2685 -#define SQLITE_RECURSIVE            33   /* NULL            NULL            */
  7.2686 -
  7.2687 -/*
  7.2688 -** CAPI3REF: Tracing And Profiling Functions
  7.2689 -**
  7.2690 -** These routines register callback functions that can be used for
  7.2691 -** tracing and profiling the execution of SQL statements.
  7.2692 -**
  7.2693 -** ^The callback function registered by sqlite3_trace() is invoked at
  7.2694 -** various times when an SQL statement is being run by [sqlite3_step()].
  7.2695 -** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
  7.2696 -** SQL statement text as the statement first begins executing.
  7.2697 -** ^(Additional sqlite3_trace() callbacks might occur
  7.2698 -** as each triggered subprogram is entered.  The callbacks for triggers
  7.2699 -** contain a UTF-8 SQL comment that identifies the trigger.)^
  7.2700 -**
  7.2701 -** The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit
  7.2702 -** the length of [bound parameter] expansion in the output of sqlite3_trace().
  7.2703 -**
  7.2704 -** ^The callback function registered by sqlite3_profile() is invoked
  7.2705 -** as each SQL statement finishes.  ^The profile callback contains
  7.2706 -** the original statement text and an estimate of wall-clock time
  7.2707 -** of how long that statement took to run.  ^The profile callback
  7.2708 -** time is in units of nanoseconds, however the current implementation
  7.2709 -** is only capable of millisecond resolution so the six least significant
  7.2710 -** digits in the time are meaningless.  Future versions of SQLite
  7.2711 -** might provide greater resolution on the profiler callback.  The
  7.2712 -** sqlite3_profile() function is considered experimental and is
  7.2713 -** subject to change in future versions of SQLite.
  7.2714 -*/
  7.2715 -SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
  7.2716 -SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
  7.2717 -   void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
  7.2718 -
  7.2719 -/*
  7.2720 -** CAPI3REF: Query Progress Callbacks
  7.2721 -**
  7.2722 -** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
  7.2723 -** function X to be invoked periodically during long running calls to
  7.2724 -** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for
  7.2725 -** database connection D.  An example use for this
  7.2726 -** interface is to keep a GUI updated during a large query.
  7.2727 -**
  7.2728 -** ^The parameter P is passed through as the only parameter to the 
  7.2729 -** callback function X.  ^The parameter N is the approximate number of 
  7.2730 -** [virtual machine instructions] that are evaluated between successive
  7.2731 -** invocations of the callback X.  ^If N is less than one then the progress
  7.2732 -** handler is disabled.
  7.2733 -**
  7.2734 -** ^Only a single progress handler may be defined at one time per
  7.2735 -** [database connection]; setting a new progress handler cancels the
  7.2736 -** old one.  ^Setting parameter X to NULL disables the progress handler.
  7.2737 -** ^The progress handler is also disabled by setting N to a value less
  7.2738 -** than 1.
  7.2739 -**
  7.2740 -** ^If the progress callback returns non-zero, the operation is
  7.2741 -** interrupted.  This feature can be used to implement a
  7.2742 -** "Cancel" button on a GUI progress dialog box.
  7.2743 -**
  7.2744 -** The progress handler callback must not do anything that will modify
  7.2745 -** the database connection that invoked the progress handler.
  7.2746 -** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
  7.2747 -** database connections for the meaning of "modify" in this paragraph.
  7.2748 -**
  7.2749 -*/
  7.2750 -SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
  7.2751 -
  7.2752 -/*
  7.2753 -** CAPI3REF: Opening A New Database Connection
  7.2754 -**
  7.2755 -** ^These routines open an SQLite database file as specified by the 
  7.2756 -** filename argument. ^The filename argument is interpreted as UTF-8 for
  7.2757 -** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
  7.2758 -** order for sqlite3_open16(). ^(A [database connection] handle is usually
  7.2759 -** returned in *ppDb, even if an error occurs.  The only exception is that
  7.2760 -** if SQLite is unable to allocate memory to hold the [sqlite3] object,
  7.2761 -** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]
  7.2762 -** object.)^ ^(If the database is opened (and/or created) successfully, then
  7.2763 -** [SQLITE_OK] is returned.  Otherwise an [error code] is returned.)^ ^The
  7.2764 -** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain
  7.2765 -** an English language description of the error following a failure of any
  7.2766 -** of the sqlite3_open() routines.
  7.2767 -**
  7.2768 -** ^The default encoding for the database will be UTF-8 if
  7.2769 -** sqlite3_open() or sqlite3_open_v2() is called and
  7.2770 -** UTF-16 in the native byte order if sqlite3_open16() is used.
  7.2771 -**
  7.2772 -** Whether or not an error occurs when it is opened, resources
  7.2773 -** associated with the [database connection] handle should be released by
  7.2774 -** passing it to [sqlite3_close()] when it is no longer required.
  7.2775 -**
  7.2776 -** The sqlite3_open_v2() interface works like sqlite3_open()
  7.2777 -** except that it accepts two additional parameters for additional control
  7.2778 -** over the new database connection.  ^(The flags parameter to
  7.2779 -** sqlite3_open_v2() can take one of
  7.2780 -** the following three values, optionally combined with the 
  7.2781 -** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
  7.2782 -** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^
  7.2783 -**
  7.2784 -** <dl>
  7.2785 -** ^(<dt>[SQLITE_OPEN_READONLY]</dt>
  7.2786 -** <dd>The database is opened in read-only mode.  If the database does not
  7.2787 -** already exist, an error is returned.</dd>)^
  7.2788 -**
  7.2789 -** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>
  7.2790 -** <dd>The database is opened for reading and writing if possible, or reading
  7.2791 -** only if the file is write protected by the operating system.  In either
  7.2792 -** case the database must already exist, otherwise an error is returned.</dd>)^
  7.2793 -**
  7.2794 -** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
  7.2795 -** <dd>The database is opened for reading and writing, and is created if
  7.2796 -** it does not already exist. This is the behavior that is always used for
  7.2797 -** sqlite3_open() and sqlite3_open16().</dd>)^
  7.2798 -** </dl>
  7.2799 -**
  7.2800 -** If the 3rd parameter to sqlite3_open_v2() is not one of the
  7.2801 -** combinations shown above optionally combined with other
  7.2802 -** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]
  7.2803 -** then the behavior is undefined.
  7.2804 -**
  7.2805 -** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
  7.2806 -** opens in the multi-thread [threading mode] as long as the single-thread
  7.2807 -** mode has not been set at compile-time or start-time.  ^If the
  7.2808 -** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens
  7.2809 -** in the serialized [threading mode] unless single-thread was
  7.2810 -** previously selected at compile-time or start-time.
  7.2811 -** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
  7.2812 -** eligible to use [shared cache mode], regardless of whether or not shared
  7.2813 -** cache is enabled using [sqlite3_enable_shared_cache()].  ^The
  7.2814 -** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
  7.2815 -** participate in [shared cache mode] even if it is enabled.
  7.2816 -**
  7.2817 -** ^The fourth parameter to sqlite3_open_v2() is the name of the
  7.2818 -** [sqlite3_vfs] object that defines the operating system interface that
  7.2819 -** the new database connection should use.  ^If the fourth parameter is
  7.2820 -** a NULL pointer then the default [sqlite3_vfs] object is used.
  7.2821 -**
  7.2822 -** ^If the filename is ":memory:", then a private, temporary in-memory database
  7.2823 -** is created for the connection.  ^This in-memory database will vanish when
  7.2824 -** the database connection is closed.  Future versions of SQLite might
  7.2825 -** make use of additional special filenames that begin with the ":" character.
  7.2826 -** It is recommended that when a database filename actually does begin with
  7.2827 -** a ":" character you should prefix the filename with a pathname such as
  7.2828 -** "./" to avoid ambiguity.
  7.2829 -**
  7.2830 -** ^If the filename is an empty string, then a private, temporary
  7.2831 -** on-disk database will be created.  ^This private database will be
  7.2832 -** automatically deleted as soon as the database connection is closed.
  7.2833 -**
  7.2834 -** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>
  7.2835 -**
  7.2836 -** ^If [URI filename] interpretation is enabled, and the filename argument
  7.2837 -** begins with "file:", then the filename is interpreted as a URI. ^URI
  7.2838 -** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is
  7.2839 -** set in the fourth argument to sqlite3_open_v2(), or if it has
  7.2840 -** been enabled globally using the [SQLITE_CONFIG_URI] option with the
  7.2841 -** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.
  7.2842 -** As of SQLite version 3.7.7, URI filename interpretation is turned off
  7.2843 -** by default, but future releases of SQLite might enable URI filename
  7.2844 -** interpretation by default.  See "[URI filenames]" for additional
  7.2845 -** information.
  7.2846 -**
  7.2847 -** URI filenames are parsed according to RFC 3986. ^If the URI contains an
  7.2848 -** authority, then it must be either an empty string or the string 
  7.2849 -** "localhost". ^If the authority is not an empty string or "localhost", an 
  7.2850 -** error is returned to the caller. ^The fragment component of a URI, if 
  7.2851 -** present, is ignored.
  7.2852 -**
  7.2853 -** ^SQLite uses the path component of the URI as the name of the disk file
  7.2854 -** which contains the database. ^If the path begins with a '/' character, 
  7.2855 -** then it is interpreted as an absolute path. ^If the path does not begin 
  7.2856 -** with a '/' (meaning that the authority section is omitted from the URI)
  7.2857 -** then the path is interpreted as a relative path. 
  7.2858 -** ^On windows, the first component of an absolute path 
  7.2859 -** is a drive specification (e.g. "C:").
  7.2860 -**
  7.2861 -** [[core URI query parameters]]
  7.2862 -** The query component of a URI may contain parameters that are interpreted
  7.2863 -** either by SQLite itself, or by a [VFS | custom VFS implementation].
  7.2864 -** SQLite interprets the following three query parameters:
  7.2865 -**
  7.2866 -** <ul>
  7.2867 -**   <li> <b>vfs</b>: ^The "vfs" parameter may be used to specify the name of
  7.2868 -**     a VFS object that provides the operating system interface that should
  7.2869 -**     be used to access the database file on disk. ^If this option is set to
  7.2870 -**     an empty string the default VFS object is used. ^Specifying an unknown
  7.2871 -**     VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is
  7.2872 -**     present, then the VFS specified by the option takes precedence over
  7.2873 -**     the value passed as the fourth parameter to sqlite3_open_v2().
  7.2874 -**
  7.2875 -**   <li> <b>mode</b>: ^(The mode parameter may be set to either "ro", "rw",
  7.2876 -**     "rwc", or "memory". Attempting to set it to any other value is
  7.2877 -**     an error)^. 
  7.2878 -**     ^If "ro" is specified, then the database is opened for read-only 
  7.2879 -**     access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the 
  7.2880 -**     third argument to sqlite3_open_v2(). ^If the mode option is set to 
  7.2881 -**     "rw", then the database is opened for read-write (but not create) 
  7.2882 -**     access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had 
  7.2883 -**     been set. ^Value "rwc" is equivalent to setting both 
  7.2884 -**     SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE.  ^If the mode option is
  7.2885 -**     set to "memory" then a pure [in-memory database] that never reads
  7.2886 -**     or writes from disk is used. ^It is an error to specify a value for
  7.2887 -**     the mode parameter that is less restrictive than that specified by
  7.2888 -**     the flags passed in the third parameter to sqlite3_open_v2().
  7.2889 -**
  7.2890 -**   <li> <b>cache</b>: ^The cache parameter may be set to either "shared" or
  7.2891 -**     "private". ^Setting it to "shared" is equivalent to setting the
  7.2892 -**     SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to
  7.2893 -**     sqlite3_open_v2(). ^Setting the cache parameter to "private" is 
  7.2894 -**     equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.
  7.2895 -**     ^If sqlite3_open_v2() is used and the "cache" parameter is present in
  7.2896 -**     a URI filename, its value overrides any behavior requested by setting
  7.2897 -**     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.
  7.2898 -**
  7.2899 -**  <li> <b>psow</b>: ^The psow parameter may be "true" (or "on" or "yes" or
  7.2900 -**     "1") or "false" (or "off" or "no" or "0") to indicate that the
  7.2901 -**     [powersafe overwrite] property does or does not apply to the
  7.2902 -**     storage media on which the database file resides.  ^The psow query
  7.2903 -**     parameter only works for the built-in unix and Windows VFSes.
  7.2904 -**
  7.2905 -**  <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter
  7.2906 -**     which if set disables file locking in rollback journal modes.  This
  7.2907 -**     is useful for accessing a database on a filesystem that does not
  7.2908 -**     support locking.  Caution:  Database corruption might result if two
  7.2909 -**     or more processes write to the same database and any one of those
  7.2910 -**     processes uses nolock=1.
  7.2911 -**
  7.2912 -**  <li> <b>immutable</b>: ^The immutable parameter is a boolean query
  7.2913 -**     parameter that indicates that the database file is stored on
  7.2914 -**     read-only media.  ^When immutable is set, SQLite assumes that the
  7.2915 -**     database file cannot be changed, even by a process with higher
  7.2916 -**     privilege, and so the database is opened read-only and all locking
  7.2917 -**     and change detection is disabled.  Caution: Setting the immutable
  7.2918 -**     property on a database file that does in fact change can result
  7.2919 -**     in incorrect query results and/or [SQLITE_CORRUPT] errors.
  7.2920 -**     See also: [SQLITE_IOCAP_IMMUTABLE].
  7.2921 -**       
  7.2922 -** </ul>
  7.2923 -**
  7.2924 -** ^Specifying an unknown parameter in the query component of a URI is not an
  7.2925 -** error.  Future versions of SQLite might understand additional query
  7.2926 -** parameters.  See "[query parameters with special meaning to SQLite]" for
  7.2927 -** additional information.
  7.2928 -**
  7.2929 -** [[URI filename examples]] <h3>URI filename examples</h3>
  7.2930 -**
  7.2931 -** <table border="1" align=center cellpadding=5>
  7.2932 -** <tr><th> URI filenames <th> Results
  7.2933 -** <tr><td> file:data.db <td> 
  7.2934 -**          Open the file "data.db" in the current directory.
  7.2935 -** <tr><td> file:/home/fred/data.db<br>
  7.2936 -**          file:///home/fred/data.db <br> 
  7.2937 -**          file://localhost/home/fred/data.db <br> <td> 
  7.2938 -**          Open the database file "/home/fred/data.db".
  7.2939 -** <tr><td> file://darkstar/home/fred/data.db <td> 
  7.2940 -**          An error. "darkstar" is not a recognized authority.
  7.2941 -** <tr><td style="white-space:nowrap"> 
  7.2942 -**          file:///C:/Documents%20and%20Settings/fred/Desktop/data.db
  7.2943 -**     <td> Windows only: Open the file "data.db" on fred's desktop on drive
  7.2944 -**          C:. Note that the %20 escaping in this example is not strictly 
  7.2945 -**          necessary - space characters can be used literally
  7.2946 -**          in URI filenames.
  7.2947 -** <tr><td> file:data.db?mode=ro&cache=private <td> 
  7.2948 -**          Open file "data.db" in the current directory for read-only access.
  7.2949 -**          Regardless of whether or not shared-cache mode is enabled by
  7.2950 -**          default, use a private cache.
  7.2951 -** <tr><td> file:/home/fred/data.db?vfs=unix-dotfile <td>
  7.2952 -**          Open file "/home/fred/data.db". Use the special VFS "unix-dotfile"
  7.2953 -**          that uses dot-files in place of posix advisory locking.
  7.2954 -** <tr><td> file:data.db?mode=readonly <td> 
  7.2955 -**          An error. "readonly" is not a valid option for the "mode" parameter.
  7.2956 -** </table>
  7.2957 -**
  7.2958 -** ^URI hexadecimal escape sequences (%HH) are supported within the path and
  7.2959 -** query components of a URI. A hexadecimal escape sequence consists of a
  7.2960 -** percent sign - "%" - followed by exactly two hexadecimal digits 
  7.2961 -** specifying an octet value. ^Before the path or query components of a
  7.2962 -** URI filename are interpreted, they are encoded using UTF-8 and all 
  7.2963 -** hexadecimal escape sequences replaced by a single byte containing the
  7.2964 -** corresponding octet. If this process generates an invalid UTF-8 encoding,
  7.2965 -** the results are undefined.
  7.2966 -**
  7.2967 -** <b>Note to Windows users:</b>  The encoding used for the filename argument
  7.2968 -** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever
  7.2969 -** codepage is currently defined.  Filenames containing international
  7.2970 -** characters must be converted to UTF-8 prior to passing them into
  7.2971 -** sqlite3_open() or sqlite3_open_v2().
  7.2972 -**
  7.2973 -** <b>Note to Windows Runtime users:</b>  The temporary directory must be set
  7.2974 -** prior to calling sqlite3_open() or sqlite3_open_v2().  Otherwise, various
  7.2975 -** features that require the use of temporary files may fail.
  7.2976 -**
  7.2977 -** See also: [sqlite3_temp_directory]
  7.2978 -*/
  7.2979 -SQLITE_API int sqlite3_open(
  7.2980 -  const char *filename,   /* Database filename (UTF-8) */
  7.2981 -  sqlite3 **ppDb          /* OUT: SQLite db handle */
  7.2982 -);
  7.2983 -SQLITE_API int sqlite3_open16(
  7.2984 -  const void *filename,   /* Database filename (UTF-16) */
  7.2985 -  sqlite3 **ppDb          /* OUT: SQLite db handle */
  7.2986 -);
  7.2987 -SQLITE_API int sqlite3_open_v2(
  7.2988 -  const char *filename,   /* Database filename (UTF-8) */
  7.2989 -  sqlite3 **ppDb,         /* OUT: SQLite db handle */
  7.2990 -  int flags,              /* Flags */
  7.2991 -  const char *zVfs        /* Name of VFS module to use */
  7.2992 -);
  7.2993 -
  7.2994 -/*
  7.2995 -** CAPI3REF: Obtain Values For URI Parameters
  7.2996 -**
  7.2997 -** These are utility routines, useful to VFS implementations, that check
  7.2998 -** to see if a database file was a URI that contained a specific query 
  7.2999 -** parameter, and if so obtains the value of that query parameter.
  7.3000 -**
  7.3001 -** If F is the database filename pointer passed into the xOpen() method of 
  7.3002 -** a VFS implementation when the flags parameter to xOpen() has one or 
  7.3003 -** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and
  7.3004 -** P is the name of the query parameter, then
  7.3005 -** sqlite3_uri_parameter(F,P) returns the value of the P
  7.3006 -** parameter if it exists or a NULL pointer if P does not appear as a 
  7.3007 -** query parameter on F.  If P is a query parameter of F
  7.3008 -** has no explicit value, then sqlite3_uri_parameter(F,P) returns
  7.3009 -** a pointer to an empty string.
  7.3010 -**
  7.3011 -** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean
  7.3012 -** parameter and returns true (1) or false (0) according to the value
  7.3013 -** of P.  The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the
  7.3014 -** value of query parameter P is one of "yes", "true", or "on" in any
  7.3015 -** case or if the value begins with a non-zero number.  The 
  7.3016 -** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of
  7.3017 -** query parameter P is one of "no", "false", or "off" in any case or
  7.3018 -** if the value begins with a numeric zero.  If P is not a query
  7.3019 -** parameter on F or if the value of P is does not match any of the
  7.3020 -** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).
  7.3021 -**
  7.3022 -** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a
  7.3023 -** 64-bit signed integer and returns that integer, or D if P does not
  7.3024 -** exist.  If the value of P is something other than an integer, then
  7.3025 -** zero is returned.
  7.3026 -** 
  7.3027 -** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and
  7.3028 -** sqlite3_uri_boolean(F,P,B) returns B.  If F is not a NULL pointer and
  7.3029 -** is not a database file pathname pointer that SQLite passed into the xOpen
  7.3030 -** VFS method, then the behavior of this routine is undefined and probably
  7.3031 -** undesirable.
  7.3032 -*/
  7.3033 -SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
  7.3034 -SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
  7.3035 -SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
  7.3036 -
  7.3037 -
  7.3038 -/*
  7.3039 -** CAPI3REF: Error Codes And Messages
  7.3040 -**
  7.3041 -** ^The sqlite3_errcode() interface returns the numeric [result code] or
  7.3042 -** [extended result code] for the most recent failed sqlite3_* API call
  7.3043 -** associated with a [database connection]. If a prior API call failed
  7.3044 -** but the most recent API call succeeded, the return value from
  7.3045 -** sqlite3_errcode() is undefined.  ^The sqlite3_extended_errcode()
  7.3046 -** interface is the same except that it always returns the 
  7.3047 -** [extended result code] even when extended result codes are
  7.3048 -** disabled.
  7.3049 -**
  7.3050 -** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
  7.3051 -** text that describes the error, as either UTF-8 or UTF-16 respectively.
  7.3052 -** ^(Memory to hold the error message string is managed internally.
  7.3053 -** The application does not need to worry about freeing the result.
  7.3054 -** However, the error string might be overwritten or deallocated by
  7.3055 -** subsequent calls to other SQLite interface functions.)^
  7.3056 -**
  7.3057 -** ^The sqlite3_errstr() interface returns the English-language text
  7.3058 -** that describes the [result code], as UTF-8.
  7.3059 -** ^(Memory to hold the error message string is managed internally
  7.3060 -** and must not be freed by the application)^.
  7.3061 -**
  7.3062 -** When the serialized [threading mode] is in use, it might be the
  7.3063 -** case that a second error occurs on a separate thread in between
  7.3064 -** the time of the first error and the call to these interfaces.
  7.3065 -** When that happens, the second error will be reported since these
  7.3066 -** interfaces always report the most recent result.  To avoid
  7.3067 -** this, each thread can obtain exclusive use of the [database connection] D
  7.3068 -** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning
  7.3069 -** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after
  7.3070 -** all calls to the interfaces listed here are completed.
  7.3071 -**
  7.3072 -** If an interface fails with SQLITE_MISUSE, that means the interface
  7.3073 -** was invoked incorrectly by the application.  In that case, the
  7.3074 -** error code and message may or may not be set.
  7.3075 -*/
  7.3076 -SQLITE_API int sqlite3_errcode(sqlite3 *db);
  7.3077 -SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
  7.3078 -SQLITE_API const char *sqlite3_errmsg(sqlite3*);
  7.3079 -SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
  7.3080 -SQLITE_API const char *sqlite3_errstr(int);
  7.3081 -
  7.3082 -/*
  7.3083 -** CAPI3REF: SQL Statement Object
  7.3084 -** KEYWORDS: {prepared statement} {prepared statements}
  7.3085 -**
  7.3086 -** An instance of this object represents a single SQL statement.
  7.3087 -** This object is variously known as a "prepared statement" or a
  7.3088 -** "compiled SQL statement" or simply as a "statement".
  7.3089 -**
  7.3090 -** The life of a statement object goes something like this:
  7.3091 -**
  7.3092 -** <ol>
  7.3093 -** <li> Create the object using [sqlite3_prepare_v2()] or a related
  7.3094 -**      function.
  7.3095 -** <li> Bind values to [host parameters] using the sqlite3_bind_*()
  7.3096 -**      interfaces.
  7.3097 -** <li> Run the SQL by calling [sqlite3_step()] one or more times.
  7.3098 -** <li> Reset the statement using [sqlite3_reset()] then go back
  7.3099 -**      to step 2.  Do this zero or more times.
  7.3100 -** <li> Destroy the object using [sqlite3_finalize()].
  7.3101 -** </ol>
  7.3102 -**
  7.3103 -** Refer to documentation on individual methods above for additional
  7.3104 -** information.
  7.3105 -*/
  7.3106 -typedef struct sqlite3_stmt sqlite3_stmt;
  7.3107 -
  7.3108 -/*
  7.3109 -** CAPI3REF: Run-time Limits
  7.3110 -**
  7.3111 -** ^(This interface allows the size of various constructs to be limited
  7.3112 -** on a connection by connection basis.  The first parameter is the
  7.3113 -** [database connection] whose limit is to be set or queried.  The
  7.3114 -** second parameter is one of the [limit categories] that define a
  7.3115 -** class of constructs to be size limited.  The third parameter is the
  7.3116 -** new limit for that construct.)^
  7.3117 -**
  7.3118 -** ^If the new limit is a negative number, the limit is unchanged.
  7.3119 -** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a 
  7.3120 -** [limits | hard upper bound]
  7.3121 -** set at compile-time by a C preprocessor macro called
  7.3122 -** [limits | SQLITE_MAX_<i>NAME</i>].
  7.3123 -** (The "_LIMIT_" in the name is changed to "_MAX_".))^
  7.3124 -** ^Attempts to increase a limit above its hard upper bound are
  7.3125 -** silently truncated to the hard upper bound.
  7.3126 -**
  7.3127 -** ^Regardless of whether or not the limit was changed, the 
  7.3128 -** [sqlite3_limit()] interface returns the prior value of the limit.
  7.3129 -** ^Hence, to find the current value of a limit without changing it,
  7.3130 -** simply invoke this interface with the third parameter set to -1.
  7.3131 -**
  7.3132 -** Run-time limits are intended for use in applications that manage
  7.3133 -** both their own internal database and also databases that are controlled
  7.3134 -** by untrusted external sources.  An example application might be a
  7.3135 -** web browser that has its own databases for storing history and
  7.3136 -** separate databases controlled by JavaScript applications downloaded
  7.3137 -** off the Internet.  The internal databases can be given the
  7.3138 -** large, default limits.  Databases managed by external sources can
  7.3139 -** be given much smaller limits designed to prevent a denial of service
  7.3140 -** attack.  Developers might also want to use the [sqlite3_set_authorizer()]
  7.3141 -** interface to further control untrusted SQL.  The size of the database
  7.3142 -** created by an untrusted script can be contained using the
  7.3143 -** [max_page_count] [PRAGMA].
  7.3144 -**
  7.3145 -** New run-time limit categories may be added in future releases.
  7.3146 -*/
  7.3147 -SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
  7.3148 -
  7.3149 -/*
  7.3150 -** CAPI3REF: Run-Time Limit Categories
  7.3151 -** KEYWORDS: {limit category} {*limit categories}
  7.3152 -**
  7.3153 -** These constants define various performance limits
  7.3154 -** that can be lowered at run-time using [sqlite3_limit()].
  7.3155 -** The synopsis of the meanings of the various limits is shown below.
  7.3156 -** Additional information is available at [limits | Limits in SQLite].
  7.3157 -**
  7.3158 -** <dl>
  7.3159 -** [[SQLITE_LIMIT_LENGTH]] ^(<dt>SQLITE_LIMIT_LENGTH</dt>
  7.3160 -** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^
  7.3161 -**
  7.3162 -** [[SQLITE_LIMIT_SQL_LENGTH]] ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>
  7.3163 -** <dd>The maximum length of an SQL statement, in bytes.</dd>)^
  7.3164 -**
  7.3165 -** [[SQLITE_LIMIT_COLUMN]] ^(<dt>SQLITE_LIMIT_COLUMN</dt>
  7.3166 -** <dd>The maximum number of columns in a table definition or in the
  7.3167 -** result set of a [SELECT] or the maximum number of columns in an index
  7.3168 -** or in an ORDER BY or GROUP BY clause.</dd>)^
  7.3169 -**
  7.3170 -** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
  7.3171 -** <dd>The maximum depth of the parse tree on any expression.</dd>)^
  7.3172 -**
  7.3173 -** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
  7.3174 -** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
  7.3175 -**
  7.3176 -** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
  7.3177 -** <dd>The maximum number of instructions in a virtual machine program
  7.3178 -** used to implement an SQL statement.  This limit is not currently
  7.3179 -** enforced, though that might be added in some future release of
  7.3180 -** SQLite.</dd>)^
  7.3181 -**
  7.3182 -** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
  7.3183 -** <dd>The maximum number of arguments on a function.</dd>)^
  7.3184 -**
  7.3185 -** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
  7.3186 -** <dd>The maximum number of [ATTACH | attached databases].)^</dd>
  7.3187 -**
  7.3188 -** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]]
  7.3189 -** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
  7.3190 -** <dd>The maximum length of the pattern argument to the [LIKE] or
  7.3191 -** [GLOB] operators.</dd>)^
  7.3192 -**
  7.3193 -** [[SQLITE_LIMIT_VARIABLE_NUMBER]]
  7.3194 -** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
  7.3195 -** <dd>The maximum index number of any [parameter] in an SQL statement.)^
  7.3196 -**
  7.3197 -** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
  7.3198 -** <dd>The maximum depth of recursion for triggers.</dd>)^
  7.3199 -** </dl>
  7.3200 -*/
  7.3201 -#define SQLITE_LIMIT_LENGTH                    0
  7.3202 -#define SQLITE_LIMIT_SQL_LENGTH                1
  7.3203 -#define SQLITE_LIMIT_COLUMN                    2
  7.3204 -#define SQLITE_LIMIT_EXPR_DEPTH                3
  7.3205 -#define SQLITE_LIMIT_COMPOUND_SELECT           4
  7.3206 -#define SQLITE_LIMIT_VDBE_OP                   5
  7.3207 -#define SQLITE_LIMIT_FUNCTION_ARG              6
  7.3208 -#define SQLITE_LIMIT_ATTACHED                  7
  7.3209 -#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH       8
  7.3210 -#define SQLITE_LIMIT_VARIABLE_NUMBER           9
  7.3211 -#define SQLITE_LIMIT_TRIGGER_DEPTH            10
  7.3212 -
  7.3213 -/*
  7.3214 -** CAPI3REF: Compiling An SQL Statement
  7.3215 -** KEYWORDS: {SQL statement compiler}
  7.3216 -**
  7.3217 -** To execute an SQL query, it must first be compiled into a byte-code
  7.3218 -** program using one of these routines.
  7.3219 -**
  7.3220 -** The first argument, "db", is a [database connection] obtained from a
  7.3221 -** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
  7.3222 -** [sqlite3_open16()].  The database connection must not have been closed.
  7.3223 -**
  7.3224 -** The second argument, "zSql", is the statement to be compiled, encoded
  7.3225 -** as either UTF-8 or UTF-16.  The sqlite3_prepare() and sqlite3_prepare_v2()
  7.3226 -** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
  7.3227 -** use UTF-16.
  7.3228 -**
  7.3229 -** ^If the nByte argument is less than zero, then zSql is read up to the
  7.3230 -** first zero terminator. ^If nByte is non-negative, then it is the maximum
  7.3231 -** number of  bytes read from zSql.  ^When nByte is non-negative, the
  7.3232 -** zSql string ends at either the first '\000' or '\u0000' character or
  7.3233 -** the nByte-th byte, whichever comes first. If the caller knows
  7.3234 -** that the supplied string is nul-terminated, then there is a small
  7.3235 -** performance advantage to be gained by passing an nByte parameter that
  7.3236 -** is equal to the number of bytes in the input string <i>including</i>
  7.3237 -** the nul-terminator bytes as this saves SQLite from having to
  7.3238 -** make a copy of the input string.
  7.3239 -**
  7.3240 -** ^If pzTail is not NULL then *pzTail is made to point to the first byte
  7.3241 -** past the end of the first SQL statement in zSql.  These routines only
  7.3242 -** compile the first statement in zSql, so *pzTail is left pointing to
  7.3243 -** what remains uncompiled.
  7.3244 -**
  7.3245 -** ^*ppStmt is left pointing to a compiled [prepared statement] that can be
  7.3246 -** executed using [sqlite3_step()].  ^If there is an error, *ppStmt is set
  7.3247 -** to NULL.  ^If the input text contains no SQL (if the input is an empty
  7.3248 -** string or a comment) then *ppStmt is set to NULL.
  7.3249 -** The calling procedure is responsible for deleting the compiled
  7.3250 -** SQL statement using [sqlite3_finalize()] after it has finished with it.
  7.3251 -** ppStmt may not be NULL.
  7.3252 -**
  7.3253 -** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
  7.3254 -** otherwise an [error code] is returned.
  7.3255 -**
  7.3256 -** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
  7.3257 -** recommended for all new programs. The two older interfaces are retained
  7.3258 -** for backwards compatibility, but their use is discouraged.
  7.3259 -** ^In the "v2" interfaces, the prepared statement
  7.3260 -** that is returned (the [sqlite3_stmt] object) contains a copy of the
  7.3261 -** original SQL text. This causes the [sqlite3_step()] interface to
  7.3262 -** behave differently in three ways:
  7.3263 -**
  7.3264 -** <ol>
  7.3265 -** <li>
  7.3266 -** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
  7.3267 -** always used to do, [sqlite3_step()] will automatically recompile the SQL
  7.3268 -** statement and try to run it again. As many as [SQLITE_MAX_SCHEMA_RETRY]
  7.3269 -** retries will occur before sqlite3_step() gives up and returns an error.
  7.3270 -** </li>
  7.3271 -**
  7.3272 -** <li>
  7.3273 -** ^When an error occurs, [sqlite3_step()] will return one of the detailed
  7.3274 -** [error codes] or [extended error codes].  ^The legacy behavior was that
  7.3275 -** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code
  7.3276 -** and the application would have to make a second call to [sqlite3_reset()]
  7.3277 -** in order to find the underlying cause of the problem. With the "v2" prepare
  7.3278 -** interfaces, the underlying reason for the error is returned immediately.
  7.3279 -** </li>
  7.3280 -**
  7.3281 -** <li>
  7.3282 -** ^If the specific value bound to [parameter | host parameter] in the 
  7.3283 -** WHERE clause might influence the choice of query plan for a statement,
  7.3284 -** then the statement will be automatically recompiled, as if there had been 
  7.3285 -** a schema change, on the first  [sqlite3_step()] call following any change
  7.3286 -** to the [sqlite3_bind_text | bindings] of that [parameter]. 
  7.3287 -** ^The specific value of WHERE-clause [parameter] might influence the 
  7.3288 -** choice of query plan if the parameter is the left-hand side of a [LIKE]
  7.3289 -** or [GLOB] operator or if the parameter is compared to an indexed column
  7.3290 -** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
  7.3291 -** </li>
  7.3292 -** </ol>
  7.3293 -*/
  7.3294 -SQLITE_API int sqlite3_prepare(
  7.3295 -  sqlite3 *db,            /* Database handle */
  7.3296 -  const char *zSql,       /* SQL statement, UTF-8 encoded */
  7.3297 -  int nByte,              /* Maximum length of zSql in bytes. */
  7.3298 -  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  7.3299 -  const char **pzTail     /* OUT: Pointer to unused portion of zSql */
  7.3300 -);
  7.3301 -SQLITE_API int sqlite3_prepare_v2(
  7.3302 -  sqlite3 *db,            /* Database handle */
  7.3303 -  const char *zSql,       /* SQL statement, UTF-8 encoded */
  7.3304 -  int nByte,              /* Maximum length of zSql in bytes. */
  7.3305 -  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  7.3306 -  const char **pzTail     /* OUT: Pointer to unused portion of zSql */
  7.3307 -);
  7.3308 -SQLITE_API int sqlite3_prepare16(
  7.3309 -  sqlite3 *db,            /* Database handle */
  7.3310 -  const void *zSql,       /* SQL statement, UTF-16 encoded */
  7.3311 -  int nByte,              /* Maximum length of zSql in bytes. */
  7.3312 -  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  7.3313 -  const void **pzTail     /* OUT: Pointer to unused portion of zSql */
  7.3314 -);
  7.3315 -SQLITE_API int sqlite3_prepare16_v2(
  7.3316 -  sqlite3 *db,            /* Database handle */
  7.3317 -  const void *zSql,       /* SQL statement, UTF-16 encoded */
  7.3318 -  int nByte,              /* Maximum length of zSql in bytes. */
  7.3319 -  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  7.3320 -  const void **pzTail     /* OUT: Pointer to unused portion of zSql */
  7.3321 -);
  7.3322 -
  7.3323 -/*
  7.3324 -** CAPI3REF: Retrieving Statement SQL
  7.3325 -**
  7.3326 -** ^This interface can be used to retrieve a saved copy of the original
  7.3327 -** SQL text used to create a [prepared statement] if that statement was
  7.3328 -** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
  7.3329 -*/
  7.3330 -SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
  7.3331 -
  7.3332 -/*
  7.3333 -** CAPI3REF: Determine If An SQL Statement Writes The Database
  7.3334 -**
  7.3335 -** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
  7.3336 -** and only if the [prepared statement] X makes no direct changes to
  7.3337 -** the content of the database file.
  7.3338 -**
  7.3339 -** Note that [application-defined SQL functions] or
  7.3340 -** [virtual tables] might change the database indirectly as a side effect.  
  7.3341 -** ^(For example, if an application defines a function "eval()" that 
  7.3342 -** calls [sqlite3_exec()], then the following SQL statement would
  7.3343 -** change the database file through side-effects:
  7.3344 -**
  7.3345 -** <blockquote><pre>
  7.3346 -**    SELECT eval('DELETE FROM t1') FROM t2;
  7.3347 -** </pre></blockquote>
  7.3348 -**
  7.3349 -** But because the [SELECT] statement does not change the database file
  7.3350 -** directly, sqlite3_stmt_readonly() would still return true.)^
  7.3351 -**
  7.3352 -** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK],
  7.3353 -** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true,
  7.3354 -** since the statements themselves do not actually modify the database but
  7.3355 -** rather they control the timing of when other statements modify the 
  7.3356 -** database.  ^The [ATTACH] and [DETACH] statements also cause
  7.3357 -** sqlite3_stmt_readonly() to return true since, while those statements
  7.3358 -** change the configuration of a database connection, they do not make 
  7.3359 -** changes to the content of the database files on disk.
  7.3360 -*/
  7.3361 -SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
  7.3362 -
  7.3363 -/*
  7.3364 -** CAPI3REF: Determine If A Prepared Statement Has Been Reset
  7.3365 -**
  7.3366 -** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
  7.3367 -** [prepared statement] S has been stepped at least once using 
  7.3368 -** [sqlite3_step(S)] but has not run to completion and/or has not 
  7.3369 -** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)
  7.3370 -** interface returns false if S is a NULL pointer.  If S is not a 
  7.3371 -** NULL pointer and is not a pointer to a valid [prepared statement]
  7.3372 -** object, then the behavior is undefined and probably undesirable.
  7.3373 -**
  7.3374 -** This interface can be used in combination [sqlite3_next_stmt()]
  7.3375 -** to locate all prepared statements associated with a database 
  7.3376 -** connection that are in need of being reset.  This can be used,
  7.3377 -** for example, in diagnostic routines to search for prepared 
  7.3378 -** statements that are holding a transaction open.
  7.3379 -*/
  7.3380 -SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
  7.3381 -
  7.3382 -/*
  7.3383 -** CAPI3REF: Dynamically Typed Value Object
  7.3384 -** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
  7.3385 -**
  7.3386 -** SQLite uses the sqlite3_value object to represent all values
  7.3387 -** that can be stored in a database table. SQLite uses dynamic typing
  7.3388 -** for the values it stores.  ^Values stored in sqlite3_value objects
  7.3389 -** can be integers, floating point values, strings, BLOBs, or NULL.
  7.3390 -**
  7.3391 -** An sqlite3_value object may be either "protected" or "unprotected".
  7.3392 -** Some interfaces require a protected sqlite3_value.  Other interfaces
  7.3393 -** will accept either a protected or an unprotected sqlite3_value.
  7.3394 -** Every interface that accepts sqlite3_value arguments specifies
  7.3395 -** whether or not it requires a protected sqlite3_value.
  7.3396 -**
  7.3397 -** The terms "protected" and "unprotected" refer to whether or not
  7.3398 -** a mutex is held.  An internal mutex is held for a protected
  7.3399 -** sqlite3_value object but no mutex is held for an unprotected
  7.3400 -** sqlite3_value object.  If SQLite is compiled to be single-threaded
  7.3401 -** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)
  7.3402 -** or if SQLite is run in one of reduced mutex modes 
  7.3403 -** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD]
  7.3404 -** then there is no distinction between protected and unprotected
  7.3405 -** sqlite3_value objects and they can be used interchangeably.  However,
  7.3406 -** for maximum code portability it is recommended that applications
  7.3407 -** still make the distinction between protected and unprotected
  7.3408 -** sqlite3_value objects even when not strictly required.
  7.3409 -**
  7.3410 -** ^The sqlite3_value objects that are passed as parameters into the
  7.3411 -** implementation of [application-defined SQL functions] are protected.
  7.3412 -** ^The sqlite3_value object returned by
  7.3413 -** [sqlite3_column_value()] is unprotected.
  7.3414 -** Unprotected sqlite3_value objects may only be used with
  7.3415 -** [sqlite3_result_value()] and [sqlite3_bind_value()].
  7.3416 -** The [sqlite3_value_blob | sqlite3_value_type()] family of
  7.3417 -** interfaces require protected sqlite3_value objects.
  7.3418 -*/
  7.3419 -typedef struct Mem sqlite3_value;
  7.3420 -
  7.3421 -/*
  7.3422 -** CAPI3REF: SQL Function Context Object
  7.3423 -**
  7.3424 -** The context in which an SQL function executes is stored in an
  7.3425 -** sqlite3_context object.  ^A pointer to an sqlite3_context object
  7.3426 -** is always first parameter to [application-defined SQL functions].
  7.3427 -** The application-defined SQL function implementation will pass this
  7.3428 -** pointer through into calls to [sqlite3_result_int | sqlite3_result()],
  7.3429 -** [sqlite3_aggregate_context()], [sqlite3_user_data()],
  7.3430 -** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],
  7.3431 -** and/or [sqlite3_set_auxdata()].
  7.3432 -*/
  7.3433 -typedef struct sqlite3_context sqlite3_context;
  7.3434 -
  7.3435 -/*
  7.3436 -** CAPI3REF: Binding Values To Prepared Statements
  7.3437 -** KEYWORDS: {host parameter} {host parameters} {host parameter name}
  7.3438 -** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
  7.3439 -**
  7.3440 -** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
  7.3441 -** literals may be replaced by a [parameter] that matches one of following
  7.3442 -** templates:
  7.3443 -**
  7.3444 -** <ul>
  7.3445 -** <li>  ?
  7.3446 -** <li>  ?NNN
  7.3447 -** <li>  :VVV
  7.3448 -** <li>  @VVV
  7.3449 -** <li>  $VVV
  7.3450 -** </ul>
  7.3451 -**
  7.3452 -** In the templates above, NNN represents an integer literal,
  7.3453 -** and VVV represents an alphanumeric identifier.)^  ^The values of these
  7.3454 -** parameters (also called "host parameter names" or "SQL parameters")
  7.3455 -** can be set using the sqlite3_bind_*() routines defined here.
  7.3456 -**
  7.3457 -** ^The first argument to the sqlite3_bind_*() routines is always
  7.3458 -** a pointer to the [sqlite3_stmt] object returned from
  7.3459 -** [sqlite3_prepare_v2()] or its variants.
  7.3460 -**
  7.3461 -** ^The second argument is the index of the SQL parameter to be set.
  7.3462 -** ^The leftmost SQL parameter has an index of 1.  ^When the same named
  7.3463 -** SQL parameter is used more than once, second and subsequent
  7.3464 -** occurrences have the same index as the first occurrence.
  7.3465 -** ^The index for named parameters can be looked up using the
  7.3466 -** [sqlite3_bind_parameter_index()] API if desired.  ^The index
  7.3467 -** for "?NNN" parameters is the value of NNN.
  7.3468 -** ^The NNN value must be between 1 and the [sqlite3_limit()]
  7.3469 -** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).
  7.3470 -**
  7.3471 -** ^The third argument is the value to bind to the parameter.
  7.3472 -** ^If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16()
  7.3473 -** or sqlite3_bind_blob() is a NULL pointer then the fourth parameter
  7.3474 -** is ignored and the end result is the same as sqlite3_bind_null().
  7.3475 -**
  7.3476 -** ^(In those routines that have a fourth argument, its value is the
  7.3477 -** number of bytes in the parameter.  To be clear: the value is the
  7.3478 -** number of <u>bytes</u> in the value, not the number of characters.)^
  7.3479 -** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16()
  7.3480 -** is negative, then the length of the string is
  7.3481 -** the number of bytes up to the first zero terminator.
  7.3482 -** If the fourth parameter to sqlite3_bind_blob() is negative, then
  7.3483 -** the behavior is undefined.
  7.3484 -** If a non-negative fourth parameter is provided to sqlite3_bind_text()
  7.3485 -** or sqlite3_bind_text16() then that parameter must be the byte offset
  7.3486 -** where the NUL terminator would occur assuming the string were NUL
  7.3487 -** terminated.  If any NUL characters occur at byte offsets less than 
  7.3488 -** the value of the fourth parameter then the resulting string value will
  7.3489 -** contain embedded NULs.  The result of expressions involving strings
  7.3490 -** with embedded NULs is undefined.
  7.3491 -**
  7.3492 -** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
  7.3493 -** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
  7.3494 -** string after SQLite has finished with it.  ^The destructor is called
  7.3495 -** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(),
  7.3496 -** sqlite3_bind_text(), or sqlite3_bind_text16() fails.  
  7.3497 -** ^If the fifth argument is
  7.3498 -** the special value [SQLITE_STATIC], then SQLite assumes that the
  7.3499 -** information is in static, unmanaged space and does not need to be freed.
  7.3500 -** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
  7.3501 -** SQLite makes its own private copy of the data immediately, before
  7.3502 -** the sqlite3_bind_*() routine returns.
  7.3503 -**
  7.3504 -** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
  7.3505 -** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory
  7.3506 -** (just an integer to hold its size) while it is being processed.
  7.3507 -** Zeroblobs are intended to serve as placeholders for BLOBs whose
  7.3508 -** content is later written using
  7.3509 -** [sqlite3_blob_open | incremental BLOB I/O] routines.
  7.3510 -** ^A negative value for the zeroblob results in a zero-length BLOB.
  7.3511 -**
  7.3512 -** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
  7.3513 -** for the [prepared statement] or with a prepared statement for which
  7.3514 -** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
  7.3515 -** then the call will return [SQLITE_MISUSE].  If any sqlite3_bind_()
  7.3516 -** routine is passed a [prepared statement] that has been finalized, the
  7.3517 -** result is undefined and probably harmful.
  7.3518 -**
  7.3519 -** ^Bindings are not cleared by the [sqlite3_reset()] routine.
  7.3520 -** ^Unbound parameters are interpreted as NULL.
  7.3521 -**
  7.3522 -** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
  7.3523 -** [error code] if anything goes wrong.
  7.3524 -** ^[SQLITE_RANGE] is returned if the parameter
  7.3525 -** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.
  7.3526 -**
  7.3527 -** See also: [sqlite3_bind_parameter_count()],
  7.3528 -** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
  7.3529 -*/
  7.3530 -SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
  7.3531 -SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
  7.3532 -SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
  7.3533 -SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
  7.3534 -SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
  7.3535 -SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
  7.3536 -SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
  7.3537 -SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
  7.3538 -SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
  7.3539 -
  7.3540 -/*
  7.3541 -** CAPI3REF: Number Of SQL Parameters
  7.3542 -**
  7.3543 -** ^This routine can be used to find the number of [SQL parameters]
  7.3544 -** in a [prepared statement].  SQL parameters are tokens of the
  7.3545 -** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
  7.3546 -** placeholders for values that are [sqlite3_bind_blob | bound]
  7.3547 -** to the parameters at a later time.
  7.3548 -**
  7.3549 -** ^(This routine actually returns the index of the largest (rightmost)
  7.3550 -** parameter. For all forms except ?NNN, this will correspond to the
  7.3551 -** number of unique parameters.  If parameters of the ?NNN form are used,
  7.3552 -** there may be gaps in the list.)^
  7.3553 -**
  7.3554 -** See also: [sqlite3_bind_blob|sqlite3_bind()],
  7.3555 -** [sqlite3_bind_parameter_name()], and
  7.3556 -** [sqlite3_bind_parameter_index()].
  7.3557 -*/
  7.3558 -SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
  7.3559 -
  7.3560 -/*
  7.3561 -** CAPI3REF: Name Of A Host Parameter
  7.3562 -**
  7.3563 -** ^The sqlite3_bind_parameter_name(P,N) interface returns
  7.3564 -** the name of the N-th [SQL parameter] in the [prepared statement] P.
  7.3565 -** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
  7.3566 -** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
  7.3567 -** respectively.
  7.3568 -** In other words, the initial ":" or "$" or "@" or "?"
  7.3569 -** is included as part of the name.)^
  7.3570 -** ^Parameters of the form "?" without a following integer have no name
  7.3571 -** and are referred to as "nameless" or "anonymous parameters".
  7.3572 -**
  7.3573 -** ^The first host parameter has an index of 1, not 0.
  7.3574 -**
  7.3575 -** ^If the value N is out of range or if the N-th parameter is
  7.3576 -** nameless, then NULL is returned.  ^The returned string is
  7.3577 -** always in UTF-8 encoding even if the named parameter was
  7.3578 -** originally specified as UTF-16 in [sqlite3_prepare16()] or
  7.3579 -** [sqlite3_prepare16_v2()].
  7.3580 -**
  7.3581 -** See also: [sqlite3_bind_blob|sqlite3_bind()],
  7.3582 -** [sqlite3_bind_parameter_count()], and
  7.3583 -** [sqlite3_bind_parameter_index()].
  7.3584 -*/
  7.3585 -SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
  7.3586 -
  7.3587 -/*
  7.3588 -** CAPI3REF: Index Of A Parameter With A Given Name
  7.3589 -**
  7.3590 -** ^Return the index of an SQL parameter given its name.  ^The
  7.3591 -** index value returned is suitable for use as the second
  7.3592 -** parameter to [sqlite3_bind_blob|sqlite3_bind()].  ^A zero
  7.3593 -** is returned if no matching parameter is found.  ^The parameter
  7.3594 -** name must be given in UTF-8 even if the original statement
  7.3595 -** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
  7.3596 -**
  7.3597 -** See also: [sqlite3_bind_blob|sqlite3_bind()],
  7.3598 -** [sqlite3_bind_parameter_count()], and
  7.3599 -** [sqlite3_bind_parameter_index()].
  7.3600 -*/
  7.3601 -SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
  7.3602 -
  7.3603 -/*
  7.3604 -** CAPI3REF: Reset All Bindings On A Prepared Statement
  7.3605 -**
  7.3606 -** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
  7.3607 -** the [sqlite3_bind_blob | bindings] on a [prepared statement].
  7.3608 -** ^Use this routine to reset all host parameters to NULL.
  7.3609 -*/
  7.3610 -SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
  7.3611 -
  7.3612 -/*
  7.3613 -** CAPI3REF: Number Of Columns In A Result Set
  7.3614 -**
  7.3615 -** ^Return the number of columns in the result set returned by the
  7.3616 -** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
  7.3617 -** statement that does not return data (for example an [UPDATE]).
  7.3618 -**
  7.3619 -** See also: [sqlite3_data_count()]
  7.3620 -*/
  7.3621 -SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
  7.3622 -
  7.3623 -/*
  7.3624 -** CAPI3REF: Column Names In A Result Set
  7.3625 -**
  7.3626 -** ^These routines return the name assigned to a particular column
  7.3627 -** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()
  7.3628 -** interface returns a pointer to a zero-terminated UTF-8 string
  7.3629 -** and sqlite3_column_name16() returns a pointer to a zero-terminated
  7.3630 -** UTF-16 string.  ^The first parameter is the [prepared statement]
  7.3631 -** that implements the [SELECT] statement. ^The second parameter is the
  7.3632 -** column number.  ^The leftmost column is number 0.
  7.3633 -**
  7.3634 -** ^The returned string pointer is valid until either the [prepared statement]
  7.3635 -** is destroyed by [sqlite3_finalize()] or until the statement is automatically
  7.3636 -** reprepared by the first call to [sqlite3_step()] for a particular run
  7.3637 -** or until the next call to
  7.3638 -** sqlite3_column_name() or sqlite3_column_name16() on the same column.
  7.3639 -**
  7.3640 -** ^If sqlite3_malloc() fails during the processing of either routine
  7.3641 -** (for example during a conversion from UTF-8 to UTF-16) then a
  7.3642 -** NULL pointer is returned.
  7.3643 -**
  7.3644 -** ^The name of a result column is the value of the "AS" clause for
  7.3645 -** that column, if there is an AS clause.  If there is no AS clause
  7.3646 -** then the name of the column is unspecified and may change from
  7.3647 -** one release of SQLite to the next.
  7.3648 -*/
  7.3649 -SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
  7.3650 -SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
  7.3651 -
  7.3652 -/*
  7.3653 -** CAPI3REF: Source Of Data In A Query Result
  7.3654 -**
  7.3655 -** ^These routines provide a means to determine the database, table, and
  7.3656 -** table column that is the origin of a particular result column in
  7.3657 -** [SELECT] statement.
  7.3658 -** ^The name of the database or table or column can be returned as
  7.3659 -** either a UTF-8 or UTF-16 string.  ^The _database_ routines return
  7.3660 -** the database name, the _table_ routines return the table name, and
  7.3661 -** the origin_ routines return the column name.
  7.3662 -** ^The returned string is valid until the [prepared statement] is destroyed
  7.3663 -** using [sqlite3_finalize()] or until the statement is automatically
  7.3664 -** reprepared by the first call to [sqlite3_step()] for a particular run
  7.3665 -** or until the same information is requested
  7.3666 -** again in a different encoding.
  7.3667 -**
  7.3668 -** ^The names returned are the original un-aliased names of the
  7.3669 -** database, table, and column.
  7.3670 -**
  7.3671 -** ^The first argument to these interfaces is a [prepared statement].
  7.3672 -** ^These functions return information about the Nth result column returned by
  7.3673 -** the statement, where N is the second function argument.
  7.3674 -** ^The left-most column is column 0 for these routines.
  7.3675 -**
  7.3676 -** ^If the Nth column returned by the statement is an expression or
  7.3677 -** subquery and is not a column value, then all of these functions return
  7.3678 -** NULL.  ^These routine might also return NULL if a memory allocation error
  7.3679 -** occurs.  ^Otherwise, they return the name of the attached database, table,
  7.3680 -** or column that query result column was extracted from.
  7.3681 -**
  7.3682 -** ^As with all other SQLite APIs, those whose names end with "16" return
  7.3683 -** UTF-16 encoded strings and the other functions return UTF-8.
  7.3684 -**
  7.3685 -** ^These APIs are only available if the library was compiled with the
  7.3686 -** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
  7.3687 -**
  7.3688 -** If two or more threads call one or more of these routines against the same
  7.3689 -** prepared statement and column at the same time then the results are
  7.3690 -** undefined.
  7.3691 -**
  7.3692 -** If two or more threads call one or more
  7.3693 -** [sqlite3_column_database_name | column metadata interfaces]
  7.3694 -** for the same [prepared statement] and result column
  7.3695 -** at the same time then the results are undefined.
  7.3696 -*/
  7.3697 -SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
  7.3698 -SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
  7.3699 -SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
  7.3700 -SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
  7.3701 -SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
  7.3702 -SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
  7.3703 -
  7.3704 -/*
  7.3705 -** CAPI3REF: Declared Datatype Of A Query Result
  7.3706 -**
  7.3707 -** ^(The first parameter is a [prepared statement].
  7.3708 -** If this statement is a [SELECT] statement and the Nth column of the
  7.3709 -** returned result set of that [SELECT] is a table column (not an
  7.3710 -** expression or subquery) then the declared type of the table
  7.3711 -** column is returned.)^  ^If the Nth column of the result set is an
  7.3712 -** expression or subquery, then a NULL pointer is returned.
  7.3713 -** ^The returned string is always UTF-8 encoded.
  7.3714 -**
  7.3715 -** ^(For example, given the database schema:
  7.3716 -**
  7.3717 -** CREATE TABLE t1(c1 VARIANT);
  7.3718 -**
  7.3719 -** and the following statement to be compiled:
  7.3720 -**
  7.3721 -** SELECT c1 + 1, c1 FROM t1;
  7.3722 -**
  7.3723 -** this routine would return the string "VARIANT" for the second result
  7.3724 -** column (i==1), and a NULL pointer for the first result column (i==0).)^
  7.3725 -**
  7.3726 -** ^SQLite uses dynamic run-time typing.  ^So just because a column
  7.3727 -** is declared to contain a particular type does not mean that the
  7.3728 -** data stored in that column is of the declared type.  SQLite is
  7.3729 -** strongly typed, but the typing is dynamic not static.  ^Type
  7.3730 -** is associated with individual values, not with the containers
  7.3731 -** used to hold those values.
  7.3732 -*/
  7.3733 -SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
  7.3734 -SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
  7.3735 -
  7.3736 -/*
  7.3737 -** CAPI3REF: Evaluate An SQL Statement
  7.3738 -**
  7.3739 -** After a [prepared statement] has been prepared using either
  7.3740 -** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
  7.3741 -** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
  7.3742 -** must be called one or more times to evaluate the statement.
  7.3743 -**
  7.3744 -** The details of the behavior of the sqlite3_step() interface depend
  7.3745 -** on whether the statement was prepared using the newer "v2" interface
  7.3746 -** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
  7.3747 -** interface [sqlite3_prepare()] and [sqlite3_prepare16()].  The use of the
  7.3748 -** new "v2" interface is recommended for new applications but the legacy
  7.3749 -** interface will continue to be supported.
  7.3750 -**
  7.3751 -** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
  7.3752 -** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
  7.3753 -** ^With the "v2" interface, any of the other [result codes] or
  7.3754 -** [extended result codes] might be returned as well.
  7.3755 -**
  7.3756 -** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
  7.3757 -** database locks it needs to do its job.  ^If the statement is a [COMMIT]
  7.3758 -** or occurs outside of an explicit transaction, then you can retry the
  7.3759 -** statement.  If the statement is not a [COMMIT] and occurs within an
  7.3760 -** explicit transaction then you should rollback the transaction before
  7.3761 -** continuing.
  7.3762 -**
  7.3763 -** ^[SQLITE_DONE] means that the statement has finished executing
  7.3764 -** successfully.  sqlite3_step() should not be called again on this virtual
  7.3765 -** machine without first calling [sqlite3_reset()] to reset the virtual
  7.3766 -** machine back to its initial state.
  7.3767 -**
  7.3768 -** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]
  7.3769 -** is returned each time a new row of data is ready for processing by the
  7.3770 -** caller. The values may be accessed using the [column access functions].
  7.3771 -** sqlite3_step() is called again to retrieve the next row of data.
  7.3772 -**
  7.3773 -** ^[SQLITE_ERROR] means that a run-time error (such as a constraint
  7.3774 -** violation) has occurred.  sqlite3_step() should not be called again on
  7.3775 -** the VM. More information may be found by calling [sqlite3_errmsg()].
  7.3776 -** ^With the legacy interface, a more specific error code (for example,
  7.3777 -** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)
  7.3778 -** can be obtained by calling [sqlite3_reset()] on the
  7.3779 -** [prepared statement].  ^In the "v2" interface,
  7.3780 -** the more specific error code is returned directly by sqlite3_step().
  7.3781 -**
  7.3782 -** [SQLITE_MISUSE] means that the this routine was called inappropriately.
  7.3783 -** Perhaps it was called on a [prepared statement] that has
  7.3784 -** already been [sqlite3_finalize | finalized] or on one that had
  7.3785 -** previously returned [SQLITE_ERROR] or [SQLITE_DONE].  Or it could
  7.3786 -** be the case that the same database connection is being used by two or
  7.3787 -** more threads at the same moment in time.
  7.3788 -**
  7.3789 -** For all versions of SQLite up to and including 3.6.23.1, a call to
  7.3790 -** [sqlite3_reset()] was required after sqlite3_step() returned anything
  7.3791 -** other than [SQLITE_ROW] before any subsequent invocation of
  7.3792 -** sqlite3_step().  Failure to reset the prepared statement using 
  7.3793 -** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from
  7.3794 -** sqlite3_step().  But after version 3.6.23.1, sqlite3_step() began
  7.3795 -** calling [sqlite3_reset()] automatically in this circumstance rather
  7.3796 -** than returning [SQLITE_MISUSE].  This is not considered a compatibility
  7.3797 -** break because any application that ever receives an SQLITE_MISUSE error
  7.3798 -** is broken by definition.  The [SQLITE_OMIT_AUTORESET] compile-time option
  7.3799 -** can be used to restore the legacy behavior.
  7.3800 -**
  7.3801 -** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()
  7.3802 -** API always returns a generic error code, [SQLITE_ERROR], following any
  7.3803 -** error other than [SQLITE_BUSY] and [SQLITE_MISUSE].  You must call
  7.3804 -** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
  7.3805 -** specific [error codes] that better describes the error.
  7.3806 -** We admit that this is a goofy design.  The problem has been fixed
  7.3807 -** with the "v2" interface.  If you prepare all of your SQL statements
  7.3808 -** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
  7.3809 -** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
  7.3810 -** then the more specific [error codes] are returned directly
  7.3811 -** by sqlite3_step().  The use of the "v2" interface is recommended.
  7.3812 -*/
  7.3813 -SQLITE_API int sqlite3_step(sqlite3_stmt*);
  7.3814 -
  7.3815 -/*
  7.3816 -** CAPI3REF: Number of columns in a result set
  7.3817 -**
  7.3818 -** ^The sqlite3_data_count(P) interface returns the number of columns in the
  7.3819 -** current row of the result set of [prepared statement] P.
  7.3820 -** ^If prepared statement P does not have results ready to return
  7.3821 -** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
  7.3822 -** interfaces) then sqlite3_data_count(P) returns 0.
  7.3823 -** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
  7.3824 -** ^The sqlite3_data_count(P) routine returns 0 if the previous call to
  7.3825 -** [sqlite3_step](P) returned [SQLITE_DONE].  ^The sqlite3_data_count(P)
  7.3826 -** will return non-zero if previous call to [sqlite3_step](P) returned
  7.3827 -** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum]
  7.3828 -** where it always returns zero since each step of that multi-step
  7.3829 -** pragma returns 0 columns of data.
  7.3830 -**
  7.3831 -** See also: [sqlite3_column_count()]
  7.3832 -*/
  7.3833 -SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
  7.3834 -
  7.3835 -/*
  7.3836 -** CAPI3REF: Fundamental Datatypes
  7.3837 -** KEYWORDS: SQLITE_TEXT
  7.3838 -**
  7.3839 -** ^(Every value in SQLite has one of five fundamental datatypes:
  7.3840 -**
  7.3841 -** <ul>
  7.3842 -** <li> 64-bit signed integer
  7.3843 -** <li> 64-bit IEEE floating point number
  7.3844 -** <li> string
  7.3845 -** <li> BLOB
  7.3846 -** <li> NULL
  7.3847 -** </ul>)^
  7.3848 -**
  7.3849 -** These constants are codes for each of those types.
  7.3850 -**
  7.3851 -** Note that the SQLITE_TEXT constant was also used in SQLite version 2
  7.3852 -** for a completely different meaning.  Software that links against both
  7.3853 -** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not
  7.3854 -** SQLITE_TEXT.
  7.3855 -*/
  7.3856 -#define SQLITE_INTEGER  1
  7.3857 -#define SQLITE_FLOAT    2
  7.3858 -#define SQLITE_BLOB     4
  7.3859 -#define SQLITE_NULL     5
  7.3860 -#ifdef SQLITE_TEXT
  7.3861 -# undef SQLITE_TEXT
  7.3862 -#else
  7.3863 -# define SQLITE_TEXT     3
  7.3864 -#endif
  7.3865 -#define SQLITE3_TEXT     3
  7.3866 -
  7.3867 -/*
  7.3868 -** CAPI3REF: Result Values From A Query
  7.3869 -** KEYWORDS: {column access functions}
  7.3870 -**
  7.3871 -** These routines form the "result set" interface.
  7.3872 -**
  7.3873 -** ^These routines return information about a single column of the current
  7.3874 -** result row of a query.  ^In every case the first argument is a pointer
  7.3875 -** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
  7.3876 -** that was returned from [sqlite3_prepare_v2()] or one of its variants)
  7.3877 -** and the second argument is the index of the column for which information
  7.3878 -** should be returned. ^The leftmost column of the result set has the index 0.
  7.3879 -** ^The number of columns in the result can be determined using
  7.3880 -** [sqlite3_column_count()].
  7.3881 -**
  7.3882 -** If the SQL statement does not currently point to a valid row, or if the
  7.3883 -** column index is out of range, the result is undefined.
  7.3884 -** These routines may only be called when the most recent call to
  7.3885 -** [sqlite3_step()] has returned [SQLITE_ROW] and neither
  7.3886 -** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently.
  7.3887 -** If any of these routines are called after [sqlite3_reset()] or
  7.3888 -** [sqlite3_finalize()] or after [sqlite3_step()] has returned
  7.3889 -** something other than [SQLITE_ROW], the results are undefined.
  7.3890 -** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
  7.3891 -** are called from a different thread while any of these routines
  7.3892 -** are pending, then the results are undefined.
  7.3893 -**
  7.3894 -** ^The sqlite3_column_type() routine returns the
  7.3895 -** [SQLITE_INTEGER | datatype code] for the initial data type
  7.3896 -** of the result column.  ^The returned value is one of [SQLITE_INTEGER],
  7.3897 -** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].  The value
  7.3898 -** returned by sqlite3_column_type() is only meaningful if no type
  7.3899 -** conversions have occurred as described below.  After a type conversion,
  7.3900 -** the value returned by sqlite3_column_type() is undefined.  Future
  7.3901 -** versions of SQLite may change the behavior of sqlite3_column_type()
  7.3902 -** following a type conversion.
  7.3903 -**
  7.3904 -** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
  7.3905 -** routine returns the number of bytes in that BLOB or string.
  7.3906 -** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
  7.3907 -** the string to UTF-8 and then returns the number of bytes.
  7.3908 -** ^If the result is a numeric value then sqlite3_column_bytes() uses
  7.3909 -** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns
  7.3910 -** the number of bytes in that string.
  7.3911 -** ^If the result is NULL, then sqlite3_column_bytes() returns zero.
  7.3912 -**
  7.3913 -** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16()
  7.3914 -** routine returns the number of bytes in that BLOB or string.
  7.3915 -** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts
  7.3916 -** the string to UTF-16 and then returns the number of bytes.
  7.3917 -** ^If the result is a numeric value then sqlite3_column_bytes16() uses
  7.3918 -** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns
  7.3919 -** the number of bytes in that string.
  7.3920 -** ^If the result is NULL, then sqlite3_column_bytes16() returns zero.
  7.3921 -**
  7.3922 -** ^The values returned by [sqlite3_column_bytes()] and 
  7.3923 -** [sqlite3_column_bytes16()] do not include the zero terminators at the end
  7.3924 -** of the string.  ^For clarity: the values returned by
  7.3925 -** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of
  7.3926 -** bytes in the string, not the number of characters.
  7.3927 -**
  7.3928 -** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
  7.3929 -** even empty strings, are always zero-terminated.  ^The return
  7.3930 -** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
  7.3931 -**
  7.3932 -** ^The object returned by [sqlite3_column_value()] is an
  7.3933 -** [unprotected sqlite3_value] object.  An unprotected sqlite3_value object
  7.3934 -** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
  7.3935 -** If the [unprotected sqlite3_value] object returned by
  7.3936 -** [sqlite3_column_value()] is used in any other way, including calls
  7.3937 -** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
  7.3938 -** or [sqlite3_value_bytes()], then the behavior is undefined.
  7.3939 -**
  7.3940 -** These routines attempt to convert the value where appropriate.  ^For
  7.3941 -** example, if the internal representation is FLOAT and a text result
  7.3942 -** is requested, [sqlite3_snprintf()] is used internally to perform the
  7.3943 -** conversion automatically.  ^(The following table details the conversions
  7.3944 -** that are applied:
  7.3945 -**
  7.3946 -** <blockquote>
  7.3947 -** <table border="1">
  7.3948 -** <tr><th> Internal<br>Type <th> Requested<br>Type <th>  Conversion
  7.3949 -**
  7.3950 -** <tr><td>  NULL    <td> INTEGER   <td> Result is 0
  7.3951 -** <tr><td>  NULL    <td>  FLOAT    <td> Result is 0.0
  7.3952 -** <tr><td>  NULL    <td>   TEXT    <td> Result is a NULL pointer
  7.3953 -** <tr><td>  NULL    <td>   BLOB    <td> Result is a NULL pointer
  7.3954 -** <tr><td> INTEGER  <td>  FLOAT    <td> Convert from integer to float
  7.3955 -** <tr><td> INTEGER  <td>   TEXT    <td> ASCII rendering of the integer
  7.3956 -** <tr><td> INTEGER  <td>   BLOB    <td> Same as INTEGER->TEXT
  7.3957 -** <tr><td>  FLOAT   <td> INTEGER   <td> [CAST] to INTEGER
  7.3958 -** <tr><td>  FLOAT   <td>   TEXT    <td> ASCII rendering of the float
  7.3959 -** <tr><td>  FLOAT   <td>   BLOB    <td> [CAST] to BLOB
  7.3960 -** <tr><td>  TEXT    <td> INTEGER   <td> [CAST] to INTEGER
  7.3961 -** <tr><td>  TEXT    <td>  FLOAT    <td> [CAST] to REAL
  7.3962 -** <tr><td>  TEXT    <td>   BLOB    <td> No change
  7.3963 -** <tr><td>  BLOB    <td> INTEGER   <td> [CAST] to INTEGER
  7.3964 -** <tr><td>  BLOB    <td>  FLOAT    <td> [CAST] to REAL
  7.3965 -** <tr><td>  BLOB    <td>   TEXT    <td> Add a zero terminator if needed
  7.3966 -** </table>
  7.3967 -** </blockquote>)^
  7.3968 -**
  7.3969 -** The table above makes reference to standard C library functions atoi()
  7.3970 -** and atof().  SQLite does not really use these functions.  It has its
  7.3971 -** own equivalent internal routines.  The atoi() and atof() names are
  7.3972 -** used in the table for brevity and because they are familiar to most
  7.3973 -** C programmers.
  7.3974 -**
  7.3975 -** Note that when type conversions occur, pointers returned by prior
  7.3976 -** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
  7.3977 -** sqlite3_column_text16() may be invalidated.
  7.3978 -** Type conversions and pointer invalidations might occur
  7.3979 -** in the following cases:
  7.3980 -**
  7.3981 -** <ul>
  7.3982 -** <li> The initial content is a BLOB and sqlite3_column_text() or
  7.3983 -**      sqlite3_column_text16() is called.  A zero-terminator might
  7.3984 -**      need to be added to the string.</li>
  7.3985 -** <li> The initial content is UTF-8 text and sqlite3_column_bytes16() or
  7.3986 -**      sqlite3_column_text16() is called.  The content must be converted
  7.3987 -**      to UTF-16.</li>
  7.3988 -** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or
  7.3989 -**      sqlite3_column_text() is called.  The content must be converted
  7.3990 -**      to UTF-8.</li>
  7.3991 -** </ul>
  7.3992 -**
  7.3993 -** ^Conversions between UTF-16be and UTF-16le are always done in place and do
  7.3994 -** not invalidate a prior pointer, though of course the content of the buffer
  7.3995 -** that the prior pointer references will have been modified.  Other kinds
  7.3996 -** of conversion are done in place when it is possible, but sometimes they
  7.3997 -** are not possible and in those cases prior pointers are invalidated.
  7.3998 -**
  7.3999 -** The safest and easiest to remember policy is to invoke these routines
  7.4000 -** in one of the following ways:
  7.4001 -**
  7.4002 -** <ul>
  7.4003 -**  <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
  7.4004 -**  <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
  7.4005 -**  <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
  7.4006 -** </ul>
  7.4007 -**
  7.4008 -** In other words, you should call sqlite3_column_text(),
  7.4009 -** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result
  7.4010 -** into the desired format, then invoke sqlite3_column_bytes() or
  7.4011 -** sqlite3_column_bytes16() to find the size of the result.  Do not mix calls
  7.4012 -** to sqlite3_column_text() or sqlite3_column_blob() with calls to
  7.4013 -** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
  7.4014 -** with calls to sqlite3_column_bytes().
  7.4015 -**
  7.4016 -** ^The pointers returned are valid until a type conversion occurs as
  7.4017 -** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
  7.4018 -** [sqlite3_finalize()] is called.  ^The memory space used to hold strings
  7.4019 -** and BLOBs is freed automatically.  Do <b>not</b> pass the pointers returned
  7.4020 -** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
  7.4021 -** [sqlite3_free()].
  7.4022 -**
  7.4023 -** ^(If a memory allocation error occurs during the evaluation of any
  7.4024 -** of these routines, a default value is returned.  The default value
  7.4025 -** is either the integer 0, the floating point number 0.0, or a NULL
  7.4026 -** pointer.  Subsequent calls to [sqlite3_errcode()] will return
  7.4027 -** [SQLITE_NOMEM].)^
  7.4028 -*/
  7.4029 -SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
  7.4030 -SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
  7.4031 -SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
  7.4032 -SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
  7.4033 -SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
  7.4034 -SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
  7.4035 -SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
  7.4036 -SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
  7.4037 -SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
  7.4038 -SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
  7.4039 -
  7.4040 -/*
  7.4041 -** CAPI3REF: Destroy A Prepared Statement Object
  7.4042 -**
  7.4043 -** ^The sqlite3_finalize() function is called to delete a [prepared statement].
  7.4044 -** ^If the most recent evaluation of the statement encountered no errors
  7.4045 -** or if the statement is never been evaluated, then sqlite3_finalize() returns
  7.4046 -** SQLITE_OK.  ^If the most recent evaluation of statement S failed, then
  7.4047 -** sqlite3_finalize(S) returns the appropriate [error code] or
  7.4048 -** [extended error code].
  7.4049 -**
  7.4050 -** ^The sqlite3_finalize(S) routine can be called at any point during
  7.4051 -** the life cycle of [prepared statement] S:
  7.4052 -** before statement S is ever evaluated, after
  7.4053 -** one or more calls to [sqlite3_reset()], or after any call
  7.4054 -** to [sqlite3_step()] regardless of whether or not the statement has
  7.4055 -** completed execution.
  7.4056 -**
  7.4057 -** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.
  7.4058 -**
  7.4059 -** The application must finalize every [prepared statement] in order to avoid
  7.4060 -** resource leaks.  It is a grievous error for the application to try to use
  7.4061 -** a prepared statement after it has been finalized.  Any use of a prepared
  7.4062 -** statement after it has been finalized can result in undefined and
  7.4063 -** undesirable behavior such as segfaults and heap corruption.
  7.4064 -*/
  7.4065 -SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
  7.4066 -
  7.4067 -/*
  7.4068 -** CAPI3REF: Reset A Prepared Statement Object
  7.4069 -**
  7.4070 -** The sqlite3_reset() function is called to reset a [prepared statement]
  7.4071 -** object back to its initial state, ready to be re-executed.
  7.4072 -** ^Any SQL statement variables that had values bound to them using
  7.4073 -** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
  7.4074 -** Use [sqlite3_clear_bindings()] to reset the bindings.
  7.4075 -**
  7.4076 -** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S
  7.4077 -** back to the beginning of its program.
  7.4078 -**
  7.4079 -** ^If the most recent call to [sqlite3_step(S)] for the
  7.4080 -** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
  7.4081 -** or if [sqlite3_step(S)] has never before been called on S,
  7.4082 -** then [sqlite3_reset(S)] returns [SQLITE_OK].
  7.4083 -**
  7.4084 -** ^If the most recent call to [sqlite3_step(S)] for the
  7.4085 -** [prepared statement] S indicated an error, then
  7.4086 -** [sqlite3_reset(S)] returns an appropriate [error code].
  7.4087 -**
  7.4088 -** ^The [sqlite3_reset(S)] interface does not change the values
  7.4089 -** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
  7.4090 -*/
  7.4091 -SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
  7.4092 -
  7.4093 -/*
  7.4094 -** CAPI3REF: Create Or Redefine SQL Functions
  7.4095 -** KEYWORDS: {function creation routines}
  7.4096 -** KEYWORDS: {application-defined SQL function}
  7.4097 -** KEYWORDS: {application-defined SQL functions}
  7.4098 -**
  7.4099 -** ^These functions (collectively known as "function creation routines")
  7.4100 -** are used to add SQL functions or aggregates or to redefine the behavior
  7.4101 -** of existing SQL functions or aggregates.  The only differences between
  7.4102 -** these routines are the text encoding expected for
  7.4103 -** the second parameter (the name of the function being created)
  7.4104 -** and the presence or absence of a destructor callback for
  7.4105 -** the application data pointer.
  7.4106 -**
  7.4107 -** ^The first parameter is the [database connection] to which the SQL
  7.4108 -** function is to be added.  ^If an application uses more than one database
  7.4109 -** connection then application-defined SQL functions must be added
  7.4110 -** to each database connection separately.
  7.4111 -**
  7.4112 -** ^The second parameter is the name of the SQL function to be created or
  7.4113 -** redefined.  ^The length of the name is limited to 255 bytes in a UTF-8
  7.4114 -** representation, exclusive of the zero-terminator.  ^Note that the name
  7.4115 -** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.  
  7.4116 -** ^Any attempt to create a function with a longer name
  7.4117 -** will result in [SQLITE_MISUSE] being returned.
  7.4118 -**
  7.4119 -** ^The third parameter (nArg)
  7.4120 -** is the number of arguments that the SQL function or
  7.4121 -** aggregate takes. ^If this parameter is -1, then the SQL function or
  7.4122 -** aggregate may take any number of arguments between 0 and the limit
  7.4123 -** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]).  If the third
  7.4124 -** parameter is less than -1 or greater than 127 then the behavior is
  7.4125 -** undefined.
  7.4126 -**
  7.4127 -** ^The fourth parameter, eTextRep, specifies what
  7.4128 -** [SQLITE_UTF8 | text encoding] this SQL function prefers for
  7.4129 -** its parameters.  The application should set this parameter to
  7.4130 -** [SQLITE_UTF16LE] if the function implementation invokes 
  7.4131 -** [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the
  7.4132 -** implementation invokes [sqlite3_value_text16be()] on an input, or
  7.4133 -** [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8]
  7.4134 -** otherwise.  ^The same SQL function may be registered multiple times using
  7.4135 -** different preferred text encodings, with different implementations for
  7.4136 -** each encoding.
  7.4137 -** ^When multiple implementations of the same function are available, SQLite
  7.4138 -** will pick the one that involves the least amount of data conversion.
  7.4139 -**
  7.4140 -** ^The fourth parameter may optionally be ORed with [SQLITE_DETERMINISTIC]
  7.4141 -** to signal that the function will always return the same result given
  7.4142 -** the same inputs within a single SQL statement.  Most SQL functions are
  7.4143 -** deterministic.  The built-in [random()] SQL function is an example of a
  7.4144 -** function that is not deterministic.  The SQLite query planner is able to
  7.4145 -** perform additional optimizations on deterministic functions, so use
  7.4146 -** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
  7.4147 -**
  7.4148 -** ^(The fifth parameter is an arbitrary pointer.  The implementation of the
  7.4149 -** function can gain access to this pointer using [sqlite3_user_data()].)^
  7.4150 -**
  7.4151 -** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are
  7.4152 -** pointers to C-language functions that implement the SQL function or
  7.4153 -** aggregate. ^A scalar SQL function requires an implementation of the xFunc
  7.4154 -** callback only; NULL pointers must be passed as the xStep and xFinal
  7.4155 -** parameters. ^An aggregate SQL function requires an implementation of xStep
  7.4156 -** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
  7.4157 -** SQL function or aggregate, pass NULL pointers for all three function
  7.4158 -** callbacks.
  7.4159 -**
  7.4160 -** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,
  7.4161 -** then it is destructor for the application data pointer. 
  7.4162 -** The destructor is invoked when the function is deleted, either by being
  7.4163 -** overloaded or when the database connection closes.)^
  7.4164 -** ^The destructor is also invoked if the call to
  7.4165 -** sqlite3_create_function_v2() fails.
  7.4166 -** ^When the destructor callback of the tenth parameter is invoked, it
  7.4167 -** is passed a single argument which is a copy of the application data 
  7.4168 -** pointer which was the fifth parameter to sqlite3_create_function_v2().
  7.4169 -**
  7.4170 -** ^It is permitted to register multiple implementations of the same
  7.4171 -** functions with the same name but with either differing numbers of
  7.4172 -** arguments or differing preferred text encodings.  ^SQLite will use
  7.4173 -** the implementation that most closely matches the way in which the
  7.4174 -** SQL function is used.  ^A function implementation with a non-negative
  7.4175 -** nArg parameter is a better match than a function implementation with
  7.4176 -** a negative nArg.  ^A function where the preferred text encoding
  7.4177 -** matches the database encoding is a better
  7.4178 -** match than a function where the encoding is different.  
  7.4179 -** ^A function where the encoding difference is between UTF16le and UTF16be
  7.4180 -** is a closer match than a function where the encoding difference is
  7.4181 -** between UTF8 and UTF16.
  7.4182 -**
  7.4183 -** ^Built-in functions may be overloaded by new application-defined functions.
  7.4184 -**
  7.4185 -** ^An application-defined function is permitted to call other
  7.4186 -** SQLite interfaces.  However, such calls must not
  7.4187 -** close the database connection nor finalize or reset the prepared
  7.4188 -** statement in which the function is running.
  7.4189 -*/
  7.4190 -SQLITE_API int sqlite3_create_function(
  7.4191 -  sqlite3 *db,
  7.4192 -  const char *zFunctionName,
  7.4193 -  int nArg,
  7.4194 -  int eTextRep,
  7.4195 -  void *pApp,
  7.4196 -  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  7.4197 -  void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  7.4198 -  void (*xFinal)(sqlite3_context*)
  7.4199 -);
  7.4200 -SQLITE_API int sqlite3_create_function16(
  7.4201 -  sqlite3 *db,
  7.4202 -  const void *zFunctionName,
  7.4203 -  int nArg,
  7.4204 -  int eTextRep,
  7.4205 -  void *pApp,
  7.4206 -  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  7.4207 -  void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  7.4208 -  void (*xFinal)(sqlite3_context*)
  7.4209 -);
  7.4210 -SQLITE_API int sqlite3_create_function_v2(
  7.4211 -  sqlite3 *db,
  7.4212 -  const char *zFunctionName,
  7.4213 -  int nArg,
  7.4214 -  int eTextRep,
  7.4215 -  void *pApp,
  7.4216 -  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  7.4217 -  void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  7.4218 -  void (*xFinal)(sqlite3_context*),
  7.4219 -  void(*xDestroy)(void*)
  7.4220 -);
  7.4221 -
  7.4222 -/*
  7.4223 -** CAPI3REF: Text Encodings
  7.4224 -**
  7.4225 -** These constant define integer codes that represent the various
  7.4226 -** text encodings supported by SQLite.
  7.4227 -*/
  7.4228 -#define SQLITE_UTF8           1
  7.4229 -#define SQLITE_UTF16LE        2
  7.4230 -#define SQLITE_UTF16BE        3
  7.4231 -#define SQLITE_UTF16          4    /* Use native byte order */
  7.4232 -#define SQLITE_ANY            5    /* Deprecated */
  7.4233 -#define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */
  7.4234 -
  7.4235 -/*
  7.4236 -** CAPI3REF: Function Flags
  7.4237 -**
  7.4238 -** These constants may be ORed together with the 
  7.4239 -** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
  7.4240 -** to [sqlite3_create_function()], [sqlite3_create_function16()], or
  7.4241 -** [sqlite3_create_function_v2()].
  7.4242 -*/
  7.4243 -#define SQLITE_DETERMINISTIC    0x800
  7.4244 -
  7.4245 -/*
  7.4246 -** CAPI3REF: Deprecated Functions
  7.4247 -** DEPRECATED
  7.4248 -**
  7.4249 -** These functions are [deprecated].  In order to maintain
  7.4250 -** backwards compatibility with older code, these functions continue 
  7.4251 -** to be supported.  However, new applications should avoid
  7.4252 -** the use of these functions.  To help encourage people to avoid
  7.4253 -** using these functions, we are not going to tell you what they do.
  7.4254 -*/
  7.4255 -#ifndef SQLITE_OMIT_DEPRECATED
  7.4256 -SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
  7.4257 -SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
  7.4258 -SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
  7.4259 -SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
  7.4260 -SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
  7.4261 -SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
  7.4262 -                      void*,sqlite3_int64);
  7.4263 -#endif
  7.4264 -
  7.4265 -/*
  7.4266 -** CAPI3REF: Obtaining SQL Function Parameter Values
  7.4267 -**
  7.4268 -** The C-language implementation of SQL functions and aggregates uses
  7.4269 -** this set of interface routines to access the parameter values on
  7.4270 -** the function or aggregate.
  7.4271 -**
  7.4272 -** The xFunc (for scalar functions) or xStep (for aggregates) parameters
  7.4273 -** to [sqlite3_create_function()] and [sqlite3_create_function16()]
  7.4274 -** define callbacks that implement the SQL functions and aggregates.
  7.4275 -** The 3rd parameter to these callbacks is an array of pointers to
  7.4276 -** [protected sqlite3_value] objects.  There is one [sqlite3_value] object for
  7.4277 -** each parameter to the SQL function.  These routines are used to
  7.4278 -** extract values from the [sqlite3_value] objects.
  7.4279 -**
  7.4280 -** These routines work only with [protected sqlite3_value] objects.
  7.4281 -** Any attempt to use these routines on an [unprotected sqlite3_value]
  7.4282 -** object results in undefined behavior.
  7.4283 -**
  7.4284 -** ^These routines work just like the corresponding [column access functions]
  7.4285 -** except that  these routines take a single [protected sqlite3_value] object
  7.4286 -** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
  7.4287 -**
  7.4288 -** ^The sqlite3_value_text16() interface extracts a UTF-16 string
  7.4289 -** in the native byte-order of the host machine.  ^The
  7.4290 -** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
  7.4291 -** extract UTF-16 strings as big-endian and little-endian respectively.
  7.4292 -**
  7.4293 -** ^(The sqlite3_value_numeric_type() interface attempts to apply
  7.4294 -** numeric affinity to the value.  This means that an attempt is
  7.4295 -** made to convert the value to an integer or floating point.  If
  7.4296 -** such a conversion is possible without loss of information (in other
  7.4297 -** words, if the value is a string that looks like a number)
  7.4298 -** then the conversion is performed.  Otherwise no conversion occurs.
  7.4299 -** The [SQLITE_INTEGER | datatype] after conversion is returned.)^
  7.4300 -**
  7.4301 -** Please pay particular attention to the fact that the pointer returned
  7.4302 -** from [sqlite3_value_blob()], [sqlite3_value_text()], or
  7.4303 -** [sqlite3_value_text16()] can be invalidated by a subsequent call to
  7.4304 -** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
  7.4305 -** or [sqlite3_value_text16()].
  7.4306 -**
  7.4307 -** These routines must be called from the same thread as
  7.4308 -** the SQL function that supplied the [sqlite3_value*] parameters.
  7.4309 -*/
  7.4310 -SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
  7.4311 -SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
  7.4312 -SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
  7.4313 -SQLITE_API double sqlite3_value_double(sqlite3_value*);
  7.4314 -SQLITE_API int sqlite3_value_int(sqlite3_value*);
  7.4315 -SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
  7.4316 -SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
  7.4317 -SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
  7.4318 -SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
  7.4319 -SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
  7.4320 -SQLITE_API int sqlite3_value_type(sqlite3_value*);
  7.4321 -SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
  7.4322 -
  7.4323 -/*
  7.4324 -** CAPI3REF: Obtain Aggregate Function Context
  7.4325 -**
  7.4326 -** Implementations of aggregate SQL functions use this
  7.4327 -** routine to allocate memory for storing their state.
  7.4328 -**
  7.4329 -** ^The first time the sqlite3_aggregate_context(C,N) routine is called 
  7.4330 -** for a particular aggregate function, SQLite
  7.4331 -** allocates N of memory, zeroes out that memory, and returns a pointer
  7.4332 -** to the new memory. ^On second and subsequent calls to
  7.4333 -** sqlite3_aggregate_context() for the same aggregate function instance,
  7.4334 -** the same buffer is returned.  Sqlite3_aggregate_context() is normally
  7.4335 -** called once for each invocation of the xStep callback and then one
  7.4336 -** last time when the xFinal callback is invoked.  ^(When no rows match
  7.4337 -** an aggregate query, the xStep() callback of the aggregate function
  7.4338 -** implementation is never called and xFinal() is called exactly once.
  7.4339 -** In those cases, sqlite3_aggregate_context() might be called for the
  7.4340 -** first time from within xFinal().)^
  7.4341 -**
  7.4342 -** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer 
  7.4343 -** when first called if N is less than or equal to zero or if a memory
  7.4344 -** allocate error occurs.
  7.4345 -**
  7.4346 -** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
  7.4347 -** determined by the N parameter on first successful call.  Changing the
  7.4348 -** value of N in subsequent call to sqlite3_aggregate_context() within
  7.4349 -** the same aggregate function instance will not resize the memory
  7.4350 -** allocation.)^  Within the xFinal callback, it is customary to set
  7.4351 -** N=0 in calls to sqlite3_aggregate_context(C,N) so that no 
  7.4352 -** pointless memory allocations occur.
  7.4353 -**
  7.4354 -** ^SQLite automatically frees the memory allocated by 
  7.4355 -** sqlite3_aggregate_context() when the aggregate query concludes.
  7.4356 -**
  7.4357 -** The first parameter must be a copy of the
  7.4358 -** [sqlite3_context | SQL function context] that is the first parameter
  7.4359 -** to the xStep or xFinal callback routine that implements the aggregate
  7.4360 -** function.
  7.4361 -**
  7.4362 -** This routine must be called from the same thread in which
  7.4363 -** the aggregate SQL function is running.
  7.4364 -*/
  7.4365 -SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
  7.4366 -
  7.4367 -/*
  7.4368 -** CAPI3REF: User Data For Functions
  7.4369 -**
  7.4370 -** ^The sqlite3_user_data() interface returns a copy of
  7.4371 -** the pointer that was the pUserData parameter (the 5th parameter)
  7.4372 -** of the [sqlite3_create_function()]
  7.4373 -** and [sqlite3_create_function16()] routines that originally
  7.4374 -** registered the application defined function.
  7.4375 -**
  7.4376 -** This routine must be called from the same thread in which
  7.4377 -** the application-defined function is running.
  7.4378 -*/
  7.4379 -SQLITE_API void *sqlite3_user_data(sqlite3_context*);
  7.4380 -
  7.4381 -/*
  7.4382 -** CAPI3REF: Database Connection For Functions
  7.4383 -**
  7.4384 -** ^The sqlite3_context_db_handle() interface returns a copy of
  7.4385 -** the pointer to the [database connection] (the 1st parameter)
  7.4386 -** of the [sqlite3_create_function()]
  7.4387 -** and [sqlite3_create_function16()] routines that originally
  7.4388 -** registered the application defined function.
  7.4389 -*/
  7.4390 -SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
  7.4391 -
  7.4392 -/*
  7.4393 -** CAPI3REF: Function Auxiliary Data
  7.4394 -**
  7.4395 -** These functions may be used by (non-aggregate) SQL functions to
  7.4396 -** associate metadata with argument values. If the same value is passed to
  7.4397 -** multiple invocations of the same SQL function during query execution, under
  7.4398 -** some circumstances the associated metadata may be preserved.  An example
  7.4399 -** of where this might be useful is in a regular-expression matching
  7.4400 -** function. The compiled version of the regular expression can be stored as
  7.4401 -** metadata associated with the pattern string.  
  7.4402 -** Then as long as the pattern string remains the same,
  7.4403 -** the compiled regular expression can be reused on multiple
  7.4404 -** invocations of the same function.
  7.4405 -**
  7.4406 -** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
  7.4407 -** associated by the sqlite3_set_auxdata() function with the Nth argument
  7.4408 -** value to the application-defined function. ^If there is no metadata
  7.4409 -** associated with the function argument, this sqlite3_get_auxdata() interface
  7.4410 -** returns a NULL pointer.
  7.4411 -**
  7.4412 -** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
  7.4413 -** argument of the application-defined function.  ^Subsequent
  7.4414 -** calls to sqlite3_get_auxdata(C,N) return P from the most recent
  7.4415 -** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
  7.4416 -** NULL if the metadata has been discarded.
  7.4417 -** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
  7.4418 -** SQLite will invoke the destructor function X with parameter P exactly
  7.4419 -** once, when the metadata is discarded.
  7.4420 -** SQLite is free to discard the metadata at any time, including: <ul>
  7.4421 -** <li> when the corresponding function parameter changes, or
  7.4422 -** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
  7.4423 -**      SQL statement, or
  7.4424 -** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
  7.4425 -** <li> during the original sqlite3_set_auxdata() call when a memory 
  7.4426 -**      allocation error occurs. </ul>)^
  7.4427 -**
  7.4428 -** Note the last bullet in particular.  The destructor X in 
  7.4429 -** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
  7.4430 -** sqlite3_set_auxdata() interface even returns.  Hence sqlite3_set_auxdata()
  7.4431 -** should be called near the end of the function implementation and the
  7.4432 -** function implementation should not make any use of P after
  7.4433 -** sqlite3_set_auxdata() has been called.
  7.4434 -**
  7.4435 -** ^(In practice, metadata is preserved between function calls for
  7.4436 -** function parameters that are compile-time constants, including literal
  7.4437 -** values and [parameters] and expressions composed from the same.)^
  7.4438 -**
  7.4439 -** These routines must be called from the same thread in which
  7.4440 -** the SQL function is running.
  7.4441 -*/
  7.4442 -SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
  7.4443 -SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
  7.4444 -
  7.4445 -
  7.4446 -/*
  7.4447 -** CAPI3REF: Constants Defining Special Destructor Behavior
  7.4448 -**
  7.4449 -** These are special values for the destructor that is passed in as the
  7.4450 -** final argument to routines like [sqlite3_result_blob()].  ^If the destructor
  7.4451 -** argument is SQLITE_STATIC, it means that the content pointer is constant
  7.4452 -** and will never change.  It does not need to be destroyed.  ^The
  7.4453 -** SQLITE_TRANSIENT value means that the content will likely change in
  7.4454 -** the near future and that SQLite should make its own private copy of
  7.4455 -** the content before returning.
  7.4456 -**
  7.4457 -** The typedef is necessary to work around problems in certain
  7.4458 -** C++ compilers.
  7.4459 -*/
  7.4460 -typedef void (*sqlite3_destructor_type)(void*);
  7.4461 -#define SQLITE_STATIC      ((sqlite3_destructor_type)0)
  7.4462 -#define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)
  7.4463 -
  7.4464 -/*
  7.4465 -** CAPI3REF: Setting The Result Of An SQL Function
  7.4466 -**
  7.4467 -** These routines are used by the xFunc or xFinal callbacks that
  7.4468 -** implement SQL functions and aggregates.  See
  7.4469 -** [sqlite3_create_function()] and [sqlite3_create_function16()]
  7.4470 -** for additional information.
  7.4471 -**
  7.4472 -** These functions work very much like the [parameter binding] family of
  7.4473 -** functions used to bind values to host parameters in prepared statements.
  7.4474 -** Refer to the [SQL parameter] documentation for additional information.
  7.4475 -**
  7.4476 -** ^The sqlite3_result_blob() interface sets the result from
  7.4477 -** an application-defined function to be the BLOB whose content is pointed
  7.4478 -** to by the second parameter and which is N bytes long where N is the
  7.4479 -** third parameter.
  7.4480 -**
  7.4481 -** ^The sqlite3_result_zeroblob() interfaces set the result of
  7.4482 -** the application-defined function to be a BLOB containing all zero
  7.4483 -** bytes and N bytes in size, where N is the value of the 2nd parameter.
  7.4484 -**
  7.4485 -** ^The sqlite3_result_double() interface sets the result from
  7.4486 -** an application-defined function to be a floating point value specified
  7.4487 -** by its 2nd argument.
  7.4488 -**
  7.4489 -** ^The sqlite3_result_error() and sqlite3_result_error16() functions
  7.4490 -** cause the implemented SQL function to throw an exception.
  7.4491 -** ^SQLite uses the string pointed to by the
  7.4492 -** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()
  7.4493 -** as the text of an error message.  ^SQLite interprets the error
  7.4494 -** message string from sqlite3_result_error() as UTF-8. ^SQLite
  7.4495 -** interprets the string from sqlite3_result_error16() as UTF-16 in native
  7.4496 -** byte order.  ^If the third parameter to sqlite3_result_error()
  7.4497 -** or sqlite3_result_error16() is negative then SQLite takes as the error
  7.4498 -** message all text up through the first zero character.
  7.4499 -** ^If the third parameter to sqlite3_result_error() or
  7.4500 -** sqlite3_result_error16() is non-negative then SQLite takes that many
  7.4501 -** bytes (not characters) from the 2nd parameter as the error message.
  7.4502 -** ^The sqlite3_result_error() and sqlite3_result_error16()
  7.4503 -** routines make a private copy of the error message text before
  7.4504 -** they return.  Hence, the calling function can deallocate or
  7.4505 -** modify the text after they return without harm.
  7.4506 -** ^The sqlite3_result_error_code() function changes the error code
  7.4507 -** returned by SQLite as a result of an error in a function.  ^By default,
  7.4508 -** the error code is SQLITE_ERROR.  ^A subsequent call to sqlite3_result_error()
  7.4509 -** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.
  7.4510 -**
  7.4511 -** ^The sqlite3_result_error_toobig() interface causes SQLite to throw an
  7.4512 -** error indicating that a string or BLOB is too long to represent.
  7.4513 -**
  7.4514 -** ^The sqlite3_result_error_nomem() interface causes SQLite to throw an
  7.4515 -** error indicating that a memory allocation failed.
  7.4516 -**
  7.4517 -** ^The sqlite3_result_int() interface sets the return value
  7.4518 -** of the application-defined function to be the 32-bit signed integer
  7.4519 -** value given in the 2nd argument.
  7.4520 -** ^The sqlite3_result_int64() interface sets the return value
  7.4521 -** of the application-defined function to be the 64-bit signed integer
  7.4522 -** value given in the 2nd argument.
  7.4523 -**
  7.4524 -** ^The sqlite3_result_null() interface sets the return value
  7.4525 -** of the application-defined function to be NULL.
  7.4526 -**
  7.4527 -** ^The sqlite3_result_text(), sqlite3_result_text16(),
  7.4528 -** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces
  7.4529 -** set the return value of the application-defined function to be
  7.4530 -** a text string which is represented as UTF-8, UTF-16 native byte order,
  7.4531 -** UTF-16 little endian, or UTF-16 big endian, respectively.
  7.4532 -** ^SQLite takes the text result from the application from
  7.4533 -** the 2nd parameter of the sqlite3_result_text* interfaces.
  7.4534 -** ^If the 3rd parameter to the sqlite3_result_text* interfaces
  7.4535 -** is negative, then SQLite takes result text from the 2nd parameter
  7.4536 -** through the first zero character.
  7.4537 -** ^If the 3rd parameter to the sqlite3_result_text* interfaces
  7.4538 -** is non-negative, then as many bytes (not characters) of the text
  7.4539 -** pointed to by the 2nd parameter are taken as the application-defined
  7.4540 -** function result.  If the 3rd parameter is non-negative, then it
  7.4541 -** must be the byte offset into the string where the NUL terminator would
  7.4542 -** appear if the string where NUL terminated.  If any NUL characters occur
  7.4543 -** in the string at a byte offset that is less than the value of the 3rd
  7.4544 -** parameter, then the resulting string will contain embedded NULs and the
  7.4545 -** result of expressions operating on strings with embedded NULs is undefined.
  7.4546 -** ^If the 4th parameter to the sqlite3_result_text* interfaces
  7.4547 -** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
  7.4548 -** function as the destructor on the text or BLOB result when it has
  7.4549 -** finished using that result.
  7.4550 -** ^If the 4th parameter to the sqlite3_result_text* interfaces or to
  7.4551 -** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite
  7.4552 -** assumes that the text or BLOB result is in constant space and does not
  7.4553 -** copy the content of the parameter nor call a destructor on the content
  7.4554 -** when it has finished using that result.
  7.4555 -** ^If the 4th parameter to the sqlite3_result_text* interfaces
  7.4556 -** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
  7.4557 -** then SQLite makes a copy of the result into space obtained from
  7.4558 -** from [sqlite3_malloc()] before it returns.
  7.4559 -**
  7.4560 -** ^The sqlite3_result_value() interface sets the result of
  7.4561 -** the application-defined function to be a copy the
  7.4562 -** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The
  7.4563 -** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
  7.4564 -** so that the [sqlite3_value] specified in the parameter may change or
  7.4565 -** be deallocated after sqlite3_result_value() returns without harm.
  7.4566 -** ^A [protected sqlite3_value] object may always be used where an
  7.4567 -** [unprotected sqlite3_value] object is required, so either
  7.4568 -** kind of [sqlite3_value] object can be used with this interface.
  7.4569 -**
  7.4570 -** If these routines are called from within the different thread
  7.4571 -** than the one containing the application-defined function that received
  7.4572 -** the [sqlite3_context] pointer, the results are undefined.
  7.4573 -*/
  7.4574 -SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
  7.4575 -SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
  7.4576 -SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
  7.4577 -SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
  7.4578 -SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
  7.4579 -SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
  7.4580 -SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
  7.4581 -SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
  7.4582 -SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
  7.4583 -SQLITE_API void sqlite3_result_null(sqlite3_context*);
  7.4584 -SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
  7.4585 -SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
  7.4586 -SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
  7.4587 -SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
  7.4588 -SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
  7.4589 -SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
  7.4590 -
  7.4591 -/*
  7.4592 -** CAPI3REF: Define New Collating Sequences
  7.4593 -**
  7.4594 -** ^These functions add, remove, or modify a [collation] associated
  7.4595 -** with the [database connection] specified as the first argument.
  7.4596 -**
  7.4597 -** ^The name of the collation is a UTF-8 string
  7.4598 -** for sqlite3_create_collation() and sqlite3_create_collation_v2()
  7.4599 -** and a UTF-16 string in native byte order for sqlite3_create_collation16().
  7.4600 -** ^Collation names that compare equal according to [sqlite3_strnicmp()] are
  7.4601 -** considered to be the same name.
  7.4602 -**
  7.4603 -** ^(The third argument (eTextRep) must be one of the constants:
  7.4604 -** <ul>
  7.4605 -** <li> [SQLITE_UTF8],
  7.4606 -** <li> [SQLITE_UTF16LE],
  7.4607 -** <li> [SQLITE_UTF16BE],
  7.4608 -** <li> [SQLITE_UTF16], or
  7.4609 -** <li> [SQLITE_UTF16_ALIGNED].
  7.4610 -** </ul>)^
  7.4611 -** ^The eTextRep argument determines the encoding of strings passed
  7.4612 -** to the collating function callback, xCallback.
  7.4613 -** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep
  7.4614 -** force strings to be UTF16 with native byte order.
  7.4615 -** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin
  7.4616 -** on an even byte address.
  7.4617 -**
  7.4618 -** ^The fourth argument, pArg, is an application data pointer that is passed
  7.4619 -** through as the first argument to the collating function callback.
  7.4620 -**
  7.4621 -** ^The fifth argument, xCallback, is a pointer to the collating function.
  7.4622 -** ^Multiple collating functions can be registered using the same name but
  7.4623 -** with different eTextRep parameters and SQLite will use whichever
  7.4624 -** function requires the least amount of data transformation.
  7.4625 -** ^If the xCallback argument is NULL then the collating function is
  7.4626 -** deleted.  ^When all collating functions having the same name are deleted,
  7.4627 -** that collation is no longer usable.
  7.4628 -**
  7.4629 -** ^The collating function callback is invoked with a copy of the pArg 
  7.4630 -** application data pointer and with two strings in the encoding specified
  7.4631 -** by the eTextRep argument.  The collating function must return an
  7.4632 -** integer that is negative, zero, or positive
  7.4633 -** if the first string is less than, equal to, or greater than the second,
  7.4634 -** respectively.  A collating function must always return the same answer
  7.4635 -** given the same inputs.  If two or more collating functions are registered
  7.4636 -** to the same collation name (using different eTextRep values) then all
  7.4637 -** must give an equivalent answer when invoked with equivalent strings.
  7.4638 -** The collating function must obey the following properties for all
  7.4639 -** strings A, B, and C:
  7.4640 -**
  7.4641 -** <ol>
  7.4642 -** <li> If A==B then B==A.
  7.4643 -** <li> If A==B and B==C then A==C.
  7.4644 -** <li> If A&lt;B THEN B&gt;A.
  7.4645 -** <li> If A&lt;B and B&lt;C then A&lt;C.
  7.4646 -** </ol>
  7.4647 -**
  7.4648 -** If a collating function fails any of the above constraints and that
  7.4649 -** collating function is  registered and used, then the behavior of SQLite
  7.4650 -** is undefined.
  7.4651 -**
  7.4652 -** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
  7.4653 -** with the addition that the xDestroy callback is invoked on pArg when
  7.4654 -** the collating function is deleted.
  7.4655 -** ^Collating functions are deleted when they are overridden by later
  7.4656 -** calls to the collation creation functions or when the
  7.4657 -** [database connection] is closed using [sqlite3_close()].
  7.4658 -**
  7.4659 -** ^The xDestroy callback is <u>not</u> called if the 
  7.4660 -** sqlite3_create_collation_v2() function fails.  Applications that invoke
  7.4661 -** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should 
  7.4662 -** check the return code and dispose of the application data pointer
  7.4663 -** themselves rather than expecting SQLite to deal with it for them.
  7.4664 -** This is different from every other SQLite interface.  The inconsistency 
  7.4665 -** is unfortunate but cannot be changed without breaking backwards 
  7.4666 -** compatibility.
  7.4667 -**
  7.4668 -** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
  7.4669 -*/
  7.4670 -SQLITE_API int sqlite3_create_collation(
  7.4671 -  sqlite3*, 
  7.4672 -  const char *zName, 
  7.4673 -  int eTextRep, 
  7.4674 -  void *pArg,
  7.4675 -  int(*xCompare)(void*,int,const void*,int,const void*)
  7.4676 -);
  7.4677 -SQLITE_API int sqlite3_create_collation_v2(
  7.4678 -  sqlite3*, 
  7.4679 -  const char *zName, 
  7.4680 -  int eTextRep, 
  7.4681 -  void *pArg,
  7.4682 -  int(*xCompare)(void*,int,const void*,int,const void*),
  7.4683 -  void(*xDestroy)(void*)
  7.4684 -);
  7.4685 -SQLITE_API int sqlite3_create_collation16(
  7.4686 -  sqlite3*, 
  7.4687 -  const void *zName,
  7.4688 -  int eTextRep, 
  7.4689 -  void *pArg,
  7.4690 -  int(*xCompare)(void*,int,const void*,int,const void*)
  7.4691 -);
  7.4692 -
  7.4693 -/*
  7.4694 -** CAPI3REF: Collation Needed Callbacks
  7.4695 -**
  7.4696 -** ^To avoid having to register all collation sequences before a database
  7.4697 -** can be used, a single callback function may be registered with the
  7.4698 -** [database connection] to be invoked whenever an undefined collation
  7.4699 -** sequence is required.
  7.4700 -**
  7.4701 -** ^If the function is registered using the sqlite3_collation_needed() API,
  7.4702 -** then it is passed the names of undefined collation sequences as strings
  7.4703 -** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,
  7.4704 -** the names are passed as UTF-16 in machine native byte order.
  7.4705 -** ^A call to either function replaces the existing collation-needed callback.
  7.4706 -**
  7.4707 -** ^(When the callback is invoked, the first argument passed is a copy
  7.4708 -** of the second argument to sqlite3_collation_needed() or
  7.4709 -** sqlite3_collation_needed16().  The second argument is the database
  7.4710 -** connection.  The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],
  7.4711 -** or [SQLITE_UTF16LE], indicating the most desirable form of the collation
  7.4712 -** sequence function required.  The fourth parameter is the name of the
  7.4713 -** required collation sequence.)^
  7.4714 -**
  7.4715 -** The callback function should register the desired collation using
  7.4716 -** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
  7.4717 -** [sqlite3_create_collation_v2()].
  7.4718 -*/
  7.4719 -SQLITE_API int sqlite3_collation_needed(
  7.4720 -  sqlite3*, 
  7.4721 -  void*, 
  7.4722 -  void(*)(void*,sqlite3*,int eTextRep,const char*)
  7.4723 -);
  7.4724 -SQLITE_API int sqlite3_collation_needed16(
  7.4725 -  sqlite3*, 
  7.4726 -  void*,
  7.4727 -  void(*)(void*,sqlite3*,int eTextRep,const void*)
  7.4728 -);
  7.4729 -
  7.4730 -#ifdef SQLITE_HAS_CODEC
  7.4731 -/*
  7.4732 -** Specify the key for an encrypted database.  This routine should be
  7.4733 -** called right after sqlite3_open().
  7.4734 -**
  7.4735 -** The code to implement this API is not available in the public release
  7.4736 -** of SQLite.
  7.4737 -*/
  7.4738 -SQLITE_API int sqlite3_key(
  7.4739 -  sqlite3 *db,                   /* Database to be rekeyed */
  7.4740 -  const void *pKey, int nKey     /* The key */
  7.4741 -);
  7.4742 -SQLITE_API int sqlite3_key_v2(
  7.4743 -  sqlite3 *db,                   /* Database to be rekeyed */
  7.4744 -  const char *zDbName,           /* Name of the database */
  7.4745 -  const void *pKey, int nKey     /* The key */
  7.4746 -);
  7.4747 -
  7.4748 -/*
  7.4749 -** Change the key on an open database.  If the current database is not
  7.4750 -** encrypted, this routine will encrypt it.  If pNew==0 or nNew==0, the
  7.4751 -** database is decrypted.
  7.4752 -**
  7.4753 -** The code to implement this API is not available in the public release
  7.4754 -** of SQLite.
  7.4755 -*/
  7.4756 -SQLITE_API int sqlite3_rekey(
  7.4757 -  sqlite3 *db,                   /* Database to be rekeyed */
  7.4758 -  const void *pKey, int nKey     /* The new key */
  7.4759 -);
  7.4760 -SQLITE_API int sqlite3_rekey_v2(
  7.4761 -  sqlite3 *db,                   /* Database to be rekeyed */
  7.4762 -  const char *zDbName,           /* Name of the database */
  7.4763 -  const void *pKey, int nKey     /* The new key */
  7.4764 -);
  7.4765 -
  7.4766 -/*
  7.4767 -** Specify the activation key for a SEE database.  Unless 
  7.4768 -** activated, none of the SEE routines will work.
  7.4769 -*/
  7.4770 -SQLITE_API void sqlite3_activate_see(
  7.4771 -  const char *zPassPhrase        /* Activation phrase */
  7.4772 -);
  7.4773 -#endif
  7.4774 -
  7.4775 -#ifdef SQLITE_ENABLE_CEROD
  7.4776 -/*
  7.4777 -** Specify the activation key for a CEROD database.  Unless 
  7.4778 -** activated, none of the CEROD routines will work.
  7.4779 -*/
  7.4780 -SQLITE_API void sqlite3_activate_cerod(
  7.4781 -  const char *zPassPhrase        /* Activation phrase */
  7.4782 -);
  7.4783 -#endif
  7.4784 -
  7.4785 -/*
  7.4786 -** CAPI3REF: Suspend Execution For A Short Time
  7.4787 -**
  7.4788 -** The sqlite3_sleep() function causes the current thread to suspend execution
  7.4789 -** for at least a number of milliseconds specified in its parameter.
  7.4790 -**
  7.4791 -** If the operating system does not support sleep requests with
  7.4792 -** millisecond time resolution, then the time will be rounded up to
  7.4793 -** the nearest second. The number of milliseconds of sleep actually
  7.4794 -** requested from the operating system is returned.
  7.4795 -**
  7.4796 -** ^SQLite implements this interface by calling the xSleep()
  7.4797 -** method of the default [sqlite3_vfs] object.  If the xSleep() method
  7.4798 -** of the default VFS is not implemented correctly, or not implemented at
  7.4799 -** all, then the behavior of sqlite3_sleep() may deviate from the description
  7.4800 -** in the previous paragraphs.
  7.4801 -*/
  7.4802 -SQLITE_API int sqlite3_sleep(int);
  7.4803 -
  7.4804 -/*
  7.4805 -** CAPI3REF: Name Of The Folder Holding Temporary Files
  7.4806 -**
  7.4807 -** ^(If this global variable is made to point to a string which is
  7.4808 -** the name of a folder (a.k.a. directory), then all temporary files
  7.4809 -** created by SQLite when using a built-in [sqlite3_vfs | VFS]
  7.4810 -** will be placed in that directory.)^  ^If this variable
  7.4811 -** is a NULL pointer, then SQLite performs a search for an appropriate
  7.4812 -** temporary file directory.
  7.4813 -**
  7.4814 -** Applications are strongly discouraged from using this global variable.
  7.4815 -** It is required to set a temporary folder on Windows Runtime (WinRT).
  7.4816 -** But for all other platforms, it is highly recommended that applications
  7.4817 -** neither read nor write this variable.  This global variable is a relic
  7.4818 -** that exists for backwards compatibility of legacy applications and should
  7.4819 -** be avoided in new projects.
  7.4820 -**
  7.4821 -** It is not safe to read or modify this variable in more than one
  7.4822 -** thread at a time.  It is not safe to read or modify this variable
  7.4823 -** if a [database connection] is being used at the same time in a separate
  7.4824 -** thread.
  7.4825 -** It is intended that this variable be set once
  7.4826 -** as part of process initialization and before any SQLite interface
  7.4827 -** routines have been called and that this variable remain unchanged
  7.4828 -** thereafter.
  7.4829 -**
  7.4830 -** ^The [temp_store_directory pragma] may modify this variable and cause
  7.4831 -** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,
  7.4832 -** the [temp_store_directory pragma] always assumes that any string
  7.4833 -** that this variable points to is held in memory obtained from 
  7.4834 -** [sqlite3_malloc] and the pragma may attempt to free that memory
  7.4835 -** using [sqlite3_free].
  7.4836 -** Hence, if this variable is modified directly, either it should be
  7.4837 -** made NULL or made to point to memory obtained from [sqlite3_malloc]
  7.4838 -** or else the use of the [temp_store_directory pragma] should be avoided.
  7.4839 -** Except when requested by the [temp_store_directory pragma], SQLite
  7.4840 -** does not free the memory that sqlite3_temp_directory points to.  If
  7.4841 -** the application wants that memory to be freed, it must do
  7.4842 -** so itself, taking care to only do so after all [database connection]
  7.4843 -** objects have been destroyed.
  7.4844 -**
  7.4845 -** <b>Note to Windows Runtime users:</b>  The temporary directory must be set
  7.4846 -** prior to calling [sqlite3_open] or [sqlite3_open_v2].  Otherwise, various
  7.4847 -** features that require the use of temporary files may fail.  Here is an
  7.4848 -** example of how to do this using C++ with the Windows Runtime:
  7.4849 -**
  7.4850 -** <blockquote><pre>
  7.4851 -** LPCWSTR zPath = Windows::Storage::ApplicationData::Current->
  7.4852 -** &nbsp;     TemporaryFolder->Path->Data();
  7.4853 -** char zPathBuf&#91;MAX_PATH + 1&#93;;
  7.4854 -** memset(zPathBuf, 0, sizeof(zPathBuf));
  7.4855 -** WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),
  7.4856 -** &nbsp;     NULL, NULL);
  7.4857 -** sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf);
  7.4858 -** </pre></blockquote>
  7.4859 -*/
  7.4860 -SQLITE_API char *sqlite3_temp_directory;
  7.4861 -
  7.4862 -/*
  7.4863 -** CAPI3REF: Name Of The Folder Holding Database Files
  7.4864 -**
  7.4865 -** ^(If this global variable is made to point to a string which is
  7.4866 -** the name of a folder (a.k.a. directory), then all database files
  7.4867 -** specified with a relative pathname and created or accessed by
  7.4868 -** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed
  7.4869 -** to be relative to that directory.)^ ^If this variable is a NULL
  7.4870 -** pointer, then SQLite assumes that all database files specified
  7.4871 -** with a relative pathname are relative to the current directory
  7.4872 -** for the process.  Only the windows VFS makes use of this global
  7.4873 -** variable; it is ignored by the unix VFS.
  7.4874 -**
  7.4875 -** Changing the value of this variable while a database connection is
  7.4876 -** open can result in a corrupt database.
  7.4877 -**
  7.4878 -** It is not safe to read or modify this variable in more than one
  7.4879 -** thread at a time.  It is not safe to read or modify this variable
  7.4880 -** if a [database connection] is being used at the same time in a separate
  7.4881 -** thread.
  7.4882 -** It is intended that this variable be set once
  7.4883 -** as part of process initialization and before any SQLite interface
  7.4884 -** routines have been called and that this variable remain unchanged
  7.4885 -** thereafter.
  7.4886 -**
  7.4887 -** ^The [data_store_directory pragma] may modify this variable and cause
  7.4888 -** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,
  7.4889 -** the [data_store_directory pragma] always assumes that any string
  7.4890 -** that this variable points to is held in memory obtained from 
  7.4891 -** [sqlite3_malloc] and the pragma may attempt to free that memory
  7.4892 -** using [sqlite3_free].
  7.4893 -** Hence, if this variable is modified directly, either it should be
  7.4894 -** made NULL or made to point to memory obtained from [sqlite3_malloc]
  7.4895 -** or else the use of the [data_store_directory pragma] should be avoided.
  7.4896 -*/
  7.4897 -SQLITE_API char *sqlite3_data_directory;
  7.4898 -
  7.4899 -/*
  7.4900 -** CAPI3REF: Test For Auto-Commit Mode
  7.4901 -** KEYWORDS: {autocommit mode}
  7.4902 -**
  7.4903 -** ^The sqlite3_get_autocommit() interface returns non-zero or
  7.4904 -** zero if the given database connection is or is not in autocommit mode,
  7.4905 -** respectively.  ^Autocommit mode is on by default.
  7.4906 -** ^Autocommit mode is disabled by a [BEGIN] statement.
  7.4907 -** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
  7.4908 -**
  7.4909 -** If certain kinds of errors occur on a statement within a multi-statement
  7.4910 -** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],
  7.4911 -** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the
  7.4912 -** transaction might be rolled back automatically.  The only way to
  7.4913 -** find out whether SQLite automatically rolled back the transaction after
  7.4914 -** an error is to use this function.
  7.4915 -**
  7.4916 -** If another thread changes the autocommit status of the database
  7.4917 -** connection while this routine is running, then the return value
  7.4918 -** is undefined.
  7.4919 -*/
  7.4920 -SQLITE_API int sqlite3_get_autocommit(sqlite3*);
  7.4921 -
  7.4922 -/*
  7.4923 -** CAPI3REF: Find The Database Handle Of A Prepared Statement
  7.4924 -**
  7.4925 -** ^The sqlite3_db_handle interface returns the [database connection] handle
  7.4926 -** to which a [prepared statement] belongs.  ^The [database connection]
  7.4927 -** returned by sqlite3_db_handle is the same [database connection]
  7.4928 -** that was the first argument
  7.4929 -** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
  7.4930 -** create the statement in the first place.
  7.4931 -*/
  7.4932 -SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
  7.4933 -
  7.4934 -/*
  7.4935 -** CAPI3REF: Return The Filename For A Database Connection
  7.4936 -**
  7.4937 -** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
  7.4938 -** associated with database N of connection D.  ^The main database file
  7.4939 -** has the name "main".  If there is no attached database N on the database
  7.4940 -** connection D, or if database N is a temporary or in-memory database, then
  7.4941 -** a NULL pointer is returned.
  7.4942 -**
  7.4943 -** ^The filename returned by this function is the output of the
  7.4944 -** xFullPathname method of the [VFS].  ^In other words, the filename
  7.4945 -** will be an absolute pathname, even if the filename used
  7.4946 -** to open the database originally was a URI or relative pathname.
  7.4947 -*/
  7.4948 -SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
  7.4949 -
  7.4950 -/*
  7.4951 -** CAPI3REF: Determine if a database is read-only
  7.4952 -**
  7.4953 -** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
  7.4954 -** of connection D is read-only, 0 if it is read/write, or -1 if N is not
  7.4955 -** the name of a database on connection D.
  7.4956 -*/
  7.4957 -SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
  7.4958 -
  7.4959 -/*
  7.4960 -** CAPI3REF: Find the next prepared statement
  7.4961 -**
  7.4962 -** ^This interface returns a pointer to the next [prepared statement] after
  7.4963 -** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL
  7.4964 -** then this interface returns a pointer to the first prepared statement
  7.4965 -** associated with the database connection pDb.  ^If no prepared statement
  7.4966 -** satisfies the conditions of this routine, it returns NULL.
  7.4967 -**
  7.4968 -** The [database connection] pointer D in a call to
  7.4969 -** [sqlite3_next_stmt(D,S)] must refer to an open database
  7.4970 -** connection and in particular must not be a NULL pointer.
  7.4971 -*/
  7.4972 -SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
  7.4973 -
  7.4974 -/*
  7.4975 -** CAPI3REF: Commit And Rollback Notification Callbacks
  7.4976 -**
  7.4977 -** ^The sqlite3_commit_hook() interface registers a callback
  7.4978 -** function to be invoked whenever a transaction is [COMMIT | committed].
  7.4979 -** ^Any callback set by a previous call to sqlite3_commit_hook()
  7.4980 -** for the same database connection is overridden.
  7.4981 -** ^The sqlite3_rollback_hook() interface registers a callback
  7.4982 -** function to be invoked whenever a transaction is [ROLLBACK | rolled back].
  7.4983 -** ^Any callback set by a previous call to sqlite3_rollback_hook()
  7.4984 -** for the same database connection is overridden.
  7.4985 -** ^The pArg argument is passed through to the callback.
  7.4986 -** ^If the callback on a commit hook function returns non-zero,
  7.4987 -** then the commit is converted into a rollback.
  7.4988 -**
  7.4989 -** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions
  7.4990 -** return the P argument from the previous call of the same function
  7.4991 -** on the same [database connection] D, or NULL for
  7.4992 -** the first call for each function on D.
  7.4993 -**
  7.4994 -** The commit and rollback hook callbacks are not reentrant.
  7.4995 -** The callback implementation must not do anything that will modify
  7.4996 -** the database connection that invoked the callback.  Any actions
  7.4997 -** to modify the database connection must be deferred until after the
  7.4998 -** completion of the [sqlite3_step()] call that triggered the commit
  7.4999 -** or rollback hook in the first place.
  7.5000 -** Note that running any other SQL statements, including SELECT statements,
  7.5001 -** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
  7.5002 -** the database connections for the meaning of "modify" in this paragraph.
  7.5003 -**
  7.5004 -** ^Registering a NULL function disables the callback.
  7.5005 -**
  7.5006 -** ^When the commit hook callback routine returns zero, the [COMMIT]
  7.5007 -** operation is allowed to continue normally.  ^If the commit hook
  7.5008 -** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].
  7.5009 -** ^The rollback hook is invoked on a rollback that results from a commit
  7.5010 -** hook returning non-zero, just as it would be with any other rollback.
  7.5011 -**
  7.5012 -** ^For the purposes of this API, a transaction is said to have been
  7.5013 -** rolled back if an explicit "ROLLBACK" statement is executed, or
  7.5014 -** an error or constraint causes an implicit rollback to occur.
  7.5015 -** ^The rollback callback is not invoked if a transaction is
  7.5016 -** automatically rolled back because the database connection is closed.
  7.5017 -**
  7.5018 -** See also the [sqlite3_update_hook()] interface.
  7.5019 -*/
  7.5020 -SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
  7.5021 -SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
  7.5022 -
  7.5023 -/*
  7.5024 -** CAPI3REF: Data Change Notification Callbacks
  7.5025 -**
  7.5026 -** ^The sqlite3_update_hook() interface registers a callback function
  7.5027 -** with the [database connection] identified by the first argument
  7.5028 -** to be invoked whenever a row is updated, inserted or deleted in
  7.5029 -** a rowid table.
  7.5030 -** ^Any callback set by a previous call to this function
  7.5031 -** for the same database connection is overridden.
  7.5032 -**
  7.5033 -** ^The second argument is a pointer to the function to invoke when a
  7.5034 -** row is updated, inserted or deleted in a rowid table.
  7.5035 -** ^The first argument to the callback is a copy of the third argument
  7.5036 -** to sqlite3_update_hook().
  7.5037 -** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
  7.5038 -** or [SQLITE_UPDATE], depending on the operation that caused the callback
  7.5039 -** to be invoked.
  7.5040 -** ^The third and fourth arguments to the callback contain pointers to the
  7.5041 -** database and table name containing the affected row.
  7.5042 -** ^The final callback parameter is the [rowid] of the row.
  7.5043 -** ^In the case of an update, this is the [rowid] after the update takes place.
  7.5044 -**
  7.5045 -** ^(The update hook is not invoked when internal system tables are
  7.5046 -** modified (i.e. sqlite_master and sqlite_sequence).)^
  7.5047 -** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified.
  7.5048 -**
  7.5049 -** ^In the current implementation, the update hook
  7.5050 -** is not invoked when duplication rows are deleted because of an
  7.5051 -** [ON CONFLICT | ON CONFLICT REPLACE] clause.  ^Nor is the update hook
  7.5052 -** invoked when rows are deleted using the [truncate optimization].
  7.5053 -** The exceptions defined in this paragraph might change in a future
  7.5054 -** release of SQLite.
  7.5055 -**
  7.5056 -** The update hook implementation must not do anything that will modify
  7.5057 -** the database connection that invoked the update hook.  Any actions
  7.5058 -** to modify the database connection must be deferred until after the
  7.5059 -** completion of the [sqlite3_step()] call that triggered the update hook.
  7.5060 -** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
  7.5061 -** database connections for the meaning of "modify" in this paragraph.
  7.5062 -**
  7.5063 -** ^The sqlite3_update_hook(D,C,P) function
  7.5064 -** returns the P argument from the previous call
  7.5065 -** on the same [database connection] D, or NULL for
  7.5066 -** the first call on D.
  7.5067 -**
  7.5068 -** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
  7.5069 -** interfaces.
  7.5070 -*/
  7.5071 -SQLITE_API void *sqlite3_update_hook(
  7.5072 -  sqlite3*, 
  7.5073 -  void(*)(void *,int ,char const *,char const *,sqlite3_int64),
  7.5074 -  void*
  7.5075 -);
  7.5076 -
  7.5077 -/*
  7.5078 -** CAPI3REF: Enable Or Disable Shared Pager Cache
  7.5079 -**
  7.5080 -** ^(This routine enables or disables the sharing of the database cache
  7.5081 -** and schema data structures between [database connection | connections]
  7.5082 -** to the same database. Sharing is enabled if the argument is true
  7.5083 -** and disabled if the argument is false.)^
  7.5084 -**
  7.5085 -** ^Cache sharing is enabled and disabled for an entire process.
  7.5086 -** This is a change as of SQLite version 3.5.0. In prior versions of SQLite,
  7.5087 -** sharing was enabled or disabled for each thread separately.
  7.5088 -**
  7.5089 -** ^(The cache sharing mode set by this interface effects all subsequent
  7.5090 -** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
  7.5091 -** Existing database connections continue use the sharing mode
  7.5092 -** that was in effect at the time they were opened.)^
  7.5093 -**
  7.5094 -** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
  7.5095 -** successfully.  An [error code] is returned otherwise.)^
  7.5096 -**
  7.5097 -** ^Shared cache is disabled by default. But this might change in
  7.5098 -** future releases of SQLite.  Applications that care about shared
  7.5099 -** cache setting should set it explicitly.
  7.5100 -**
  7.5101 -** This interface is threadsafe on processors where writing a
  7.5102 -** 32-bit integer is atomic.
  7.5103 -**
  7.5104 -** See Also:  [SQLite Shared-Cache Mode]
  7.5105 -*/
  7.5106 -SQLITE_API int sqlite3_enable_shared_cache(int);
  7.5107 -
  7.5108 -/*
  7.5109 -** CAPI3REF: Attempt To Free Heap Memory
  7.5110 -**
  7.5111 -** ^The sqlite3_release_memory() interface attempts to free N bytes
  7.5112 -** of heap memory by deallocating non-essential memory allocations
  7.5113 -** held by the database library.   Memory used to cache database
  7.5114 -** pages to improve performance is an example of non-essential memory.
  7.5115 -** ^sqlite3_release_memory() returns the number of bytes actually freed,
  7.5116 -** which might be more or less than the amount requested.
  7.5117 -** ^The sqlite3_release_memory() routine is a no-op returning zero
  7.5118 -** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
  7.5119 -**
  7.5120 -** See also: [sqlite3_db_release_memory()]
  7.5121 -*/
  7.5122 -SQLITE_API int sqlite3_release_memory(int);
  7.5123 -
  7.5124 -/*
  7.5125 -** CAPI3REF: Free Memory Used By A Database Connection
  7.5126 -**
  7.5127 -** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
  7.5128 -** memory as possible from database connection D. Unlike the
  7.5129 -** [sqlite3_release_memory()] interface, this interface is in effect even
  7.5130 -** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
  7.5131 -** omitted.
  7.5132 -**
  7.5133 -** See also: [sqlite3_release_memory()]
  7.5134 -*/
  7.5135 -SQLITE_API int sqlite3_db_release_memory(sqlite3*);
  7.5136 -
  7.5137 -/*
  7.5138 -** CAPI3REF: Impose A Limit On Heap Size
  7.5139 -**
  7.5140 -** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
  7.5141 -** soft limit on the amount of heap memory that may be allocated by SQLite.
  7.5142 -** ^SQLite strives to keep heap memory utilization below the soft heap
  7.5143 -** limit by reducing the number of pages held in the page cache
  7.5144 -** as heap memory usages approaches the limit.
  7.5145 -** ^The soft heap limit is "soft" because even though SQLite strives to stay
  7.5146 -** below the limit, it will exceed the limit rather than generate
  7.5147 -** an [SQLITE_NOMEM] error.  In other words, the soft heap limit 
  7.5148 -** is advisory only.
  7.5149 -**
  7.5150 -** ^The return value from sqlite3_soft_heap_limit64() is the size of
  7.5151 -** the soft heap limit prior to the call, or negative in the case of an
  7.5152 -** error.  ^If the argument N is negative
  7.5153 -** then no change is made to the soft heap limit.  Hence, the current
  7.5154 -** size of the soft heap limit can be determined by invoking
  7.5155 -** sqlite3_soft_heap_limit64() with a negative argument.
  7.5156 -**
  7.5157 -** ^If the argument N is zero then the soft heap limit is disabled.
  7.5158 -**
  7.5159 -** ^(The soft heap limit is not enforced in the current implementation
  7.5160 -** if one or more of following conditions are true:
  7.5161 -**
  7.5162 -** <ul>
  7.5163 -** <li> The soft heap limit is set to zero.
  7.5164 -** <li> Memory accounting is disabled using a combination of the
  7.5165 -**      [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
  7.5166 -**      the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
  7.5167 -** <li> An alternative page cache implementation is specified using
  7.5168 -**      [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).
  7.5169 -** <li> The page cache allocates from its own memory pool supplied
  7.5170 -**      by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
  7.5171 -**      from the heap.
  7.5172 -** </ul>)^
  7.5173 -**
  7.5174 -** Beginning with SQLite version 3.7.3, the soft heap limit is enforced
  7.5175 -** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]
  7.5176 -** compile-time option is invoked.  With [SQLITE_ENABLE_MEMORY_MANAGEMENT],
  7.5177 -** the soft heap limit is enforced on every memory allocation.  Without
  7.5178 -** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced
  7.5179 -** when memory is allocated by the page cache.  Testing suggests that because
  7.5180 -** the page cache is the predominate memory user in SQLite, most
  7.5181 -** applications will achieve adequate soft heap limit enforcement without
  7.5182 -** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
  7.5183 -**
  7.5184 -** The circumstances under which SQLite will enforce the soft heap limit may
  7.5185 -** changes in future releases of SQLite.
  7.5186 -*/
  7.5187 -SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
  7.5188 -
  7.5189 -/*
  7.5190 -** CAPI3REF: Deprecated Soft Heap Limit Interface
  7.5191 -** DEPRECATED
  7.5192 -**
  7.5193 -** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
  7.5194 -** interface.  This routine is provided for historical compatibility
  7.5195 -** only.  All new applications should use the
  7.5196 -** [sqlite3_soft_heap_limit64()] interface rather than this one.
  7.5197 -*/
  7.5198 -SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
  7.5199 -
  7.5200 -
  7.5201 -/*
  7.5202 -** CAPI3REF: Extract Metadata About A Column Of A Table
  7.5203 -**
  7.5204 -** ^This routine returns metadata about a specific column of a specific
  7.5205 -** database table accessible using the [database connection] handle
  7.5206 -** passed as the first function argument.
  7.5207 -**
  7.5208 -** ^The column is identified by the second, third and fourth parameters to
  7.5209 -** this function. ^The second parameter is either the name of the database
  7.5210 -** (i.e. "main", "temp", or an attached database) containing the specified
  7.5211 -** table or NULL. ^If it is NULL, then all attached databases are searched
  7.5212 -** for the table using the same algorithm used by the database engine to
  7.5213 -** resolve unqualified table references.
  7.5214 -**
  7.5215 -** ^The third and fourth parameters to this function are the table and column
  7.5216 -** name of the desired column, respectively. Neither of these parameters
  7.5217 -** may be NULL.
  7.5218 -**
  7.5219 -** ^Metadata is returned by writing to the memory locations passed as the 5th
  7.5220 -** and subsequent parameters to this function. ^Any of these arguments may be
  7.5221 -** NULL, in which case the corresponding element of metadata is omitted.
  7.5222 -**
  7.5223 -** ^(<blockquote>
  7.5224 -** <table border="1">
  7.5225 -** <tr><th> Parameter <th> Output<br>Type <th>  Description
  7.5226 -**
  7.5227 -** <tr><td> 5th <td> const char* <td> Data type
  7.5228 -** <tr><td> 6th <td> const char* <td> Name of default collation sequence
  7.5229 -** <tr><td> 7th <td> int         <td> True if column has a NOT NULL constraint
  7.5230 -** <tr><td> 8th <td> int         <td> True if column is part of the PRIMARY KEY
  7.5231 -** <tr><td> 9th <td> int         <td> True if column is [AUTOINCREMENT]
  7.5232 -** </table>
  7.5233 -** </blockquote>)^
  7.5234 -**
  7.5235 -** ^The memory pointed to by the character pointers returned for the
  7.5236 -** declaration type and collation sequence is valid only until the next
  7.5237 -** call to any SQLite API function.
  7.5238 -**
  7.5239 -** ^If the specified table is actually a view, an [error code] is returned.
  7.5240 -**
  7.5241 -** ^If the specified column is "rowid", "oid" or "_rowid_" and an
  7.5242 -** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
  7.5243 -** parameters are set for the explicitly declared column. ^(If there is no
  7.5244 -** explicitly declared [INTEGER PRIMARY KEY] column, then the output
  7.5245 -** parameters are set as follows:
  7.5246 -**
  7.5247 -** <pre>
  7.5248 -**     data type: "INTEGER"
  7.5249 -**     collation sequence: "BINARY"
  7.5250 -**     not null: 0
  7.5251 -**     primary key: 1
  7.5252 -**     auto increment: 0
  7.5253 -** </pre>)^
  7.5254 -**
  7.5255 -** ^(This function may load one or more schemas from database files. If an
  7.5256 -** error occurs during this process, or if the requested table or column
  7.5257 -** cannot be found, an [error code] is returned and an error message left
  7.5258 -** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
  7.5259 -**
  7.5260 -** ^This API is only available if the library was compiled with the
  7.5261 -** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
  7.5262 -*/
  7.5263 -SQLITE_API int sqlite3_table_column_metadata(
  7.5264 -  sqlite3 *db,                /* Connection handle */
  7.5265 -  const char *zDbName,        /* Database name or NULL */
  7.5266 -  const char *zTableName,     /* Table name */
  7.5267 -  const char *zColumnName,    /* Column name */
  7.5268 -  char const **pzDataType,    /* OUTPUT: Declared data type */
  7.5269 -  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */
  7.5270 -  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */
  7.5271 -  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */
  7.5272 -  int *pAutoinc               /* OUTPUT: True if column is auto-increment */
  7.5273 -);
  7.5274 -
  7.5275 -/*
  7.5276 -** CAPI3REF: Load An Extension
  7.5277 -**
  7.5278 -** ^This interface loads an SQLite extension library from the named file.
  7.5279 -**
  7.5280 -** ^The sqlite3_load_extension() interface attempts to load an
  7.5281 -** [SQLite extension] library contained in the file zFile.  If
  7.5282 -** the file cannot be loaded directly, attempts are made to load
  7.5283 -** with various operating-system specific extensions added.
  7.5284 -** So for example, if "samplelib" cannot be loaded, then names like
  7.5285 -** "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might
  7.5286 -** be tried also.
  7.5287 -**
  7.5288 -** ^The entry point is zProc.
  7.5289 -** ^(zProc may be 0, in which case SQLite will try to come up with an
  7.5290 -** entry point name on its own.  It first tries "sqlite3_extension_init".
  7.5291 -** If that does not work, it constructs a name "sqlite3_X_init" where the
  7.5292 -** X is consists of the lower-case equivalent of all ASCII alphabetic
  7.5293 -** characters in the filename from the last "/" to the first following
  7.5294 -** "." and omitting any initial "lib".)^
  7.5295 -** ^The sqlite3_load_extension() interface returns
  7.5296 -** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
  7.5297 -** ^If an error occurs and pzErrMsg is not 0, then the
  7.5298 -** [sqlite3_load_extension()] interface shall attempt to
  7.5299 -** fill *pzErrMsg with error message text stored in memory
  7.5300 -** obtained from [sqlite3_malloc()]. The calling function
  7.5301 -** should free this memory by calling [sqlite3_free()].
  7.5302 -**
  7.5303 -** ^Extension loading must be enabled using
  7.5304 -** [sqlite3_enable_load_extension()] prior to calling this API,
  7.5305 -** otherwise an error will be returned.
  7.5306 -**
  7.5307 -** See also the [load_extension() SQL function].
  7.5308 -*/
  7.5309 -SQLITE_API int sqlite3_load_extension(
  7.5310 -  sqlite3 *db,          /* Load the extension into this database connection */
  7.5311 -  const char *zFile,    /* Name of the shared library containing extension */
  7.5312 -  const char *zProc,    /* Entry point.  Derived from zFile if 0 */
  7.5313 -  char **pzErrMsg       /* Put error message here if not 0 */
  7.5314 -);
  7.5315 -
  7.5316 -/*
  7.5317 -** CAPI3REF: Enable Or Disable Extension Loading
  7.5318 -**
  7.5319 -** ^So as not to open security holes in older applications that are
  7.5320 -** unprepared to deal with [extension loading], and as a means of disabling
  7.5321 -** [extension loading] while evaluating user-entered SQL, the following API
  7.5322 -** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
  7.5323 -**
  7.5324 -** ^Extension loading is off by default.
  7.5325 -** ^Call the sqlite3_enable_load_extension() routine with onoff==1
  7.5326 -** to turn extension loading on and call it with onoff==0 to turn
  7.5327 -** it back off again.
  7.5328 -*/
  7.5329 -SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
  7.5330 -
  7.5331 -/*
  7.5332 -** CAPI3REF: Automatically Load Statically Linked Extensions
  7.5333 -**
  7.5334 -** ^This interface causes the xEntryPoint() function to be invoked for
  7.5335 -** each new [database connection] that is created.  The idea here is that
  7.5336 -** xEntryPoint() is the entry point for a statically linked [SQLite extension]
  7.5337 -** that is to be automatically loaded into all new database connections.
  7.5338 -**
  7.5339 -** ^(Even though the function prototype shows that xEntryPoint() takes
  7.5340 -** no arguments and returns void, SQLite invokes xEntryPoint() with three
  7.5341 -** arguments and expects and integer result as if the signature of the
  7.5342 -** entry point where as follows:
  7.5343 -**
  7.5344 -** <blockquote><pre>
  7.5345 -** &nbsp;  int xEntryPoint(
  7.5346 -** &nbsp;    sqlite3 *db,
  7.5347 -** &nbsp;    const char **pzErrMsg,
  7.5348 -** &nbsp;    const struct sqlite3_api_routines *pThunk
  7.5349 -** &nbsp;  );
  7.5350 -** </pre></blockquote>)^
  7.5351 -**
  7.5352 -** If the xEntryPoint routine encounters an error, it should make *pzErrMsg
  7.5353 -** point to an appropriate error message (obtained from [sqlite3_mprintf()])
  7.5354 -** and return an appropriate [error code].  ^SQLite ensures that *pzErrMsg
  7.5355 -** is NULL before calling the xEntryPoint().  ^SQLite will invoke
  7.5356 -** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns.  ^If any
  7.5357 -** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()],
  7.5358 -** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail.
  7.5359 -**
  7.5360 -** ^Calling sqlite3_auto_extension(X) with an entry point X that is already
  7.5361 -** on the list of automatic extensions is a harmless no-op. ^No entry point
  7.5362 -** will be called more than once for each database connection that is opened.
  7.5363 -**
  7.5364 -** See also: [sqlite3_reset_auto_extension()]
  7.5365 -** and [sqlite3_cancel_auto_extension()]
  7.5366 -*/
  7.5367 -SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
  7.5368 -
  7.5369 -/*
  7.5370 -** CAPI3REF: Cancel Automatic Extension Loading
  7.5371 -**
  7.5372 -** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
  7.5373 -** initialization routine X that was registered using a prior call to
  7.5374 -** [sqlite3_auto_extension(X)].  ^The [sqlite3_cancel_auto_extension(X)]
  7.5375 -** routine returns 1 if initialization routine X was successfully 
  7.5376 -** unregistered and it returns 0 if X was not on the list of initialization
  7.5377 -** routines.
  7.5378 -*/
  7.5379 -SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
  7.5380 -
  7.5381 -/*
  7.5382 -** CAPI3REF: Reset Automatic Extension Loading
  7.5383 -**
  7.5384 -** ^This interface disables all automatic extensions previously
  7.5385 -** registered using [sqlite3_auto_extension()].
  7.5386 -*/
  7.5387 -SQLITE_API void sqlite3_reset_auto_extension(void);
  7.5388 -
  7.5389 -/*
  7.5390 -** The interface to the virtual-table mechanism is currently considered
  7.5391 -** to be experimental.  The interface might change in incompatible ways.
  7.5392 -** If this is a problem for you, do not use the interface at this time.
  7.5393 -**
  7.5394 -** When the virtual-table mechanism stabilizes, we will declare the
  7.5395 -** interface fixed, support it indefinitely, and remove this comment.
  7.5396 -*/
  7.5397 -
  7.5398 -/*
  7.5399 -** Structures used by the virtual table interface
  7.5400 -*/
  7.5401 -typedef struct sqlite3_vtab sqlite3_vtab;
  7.5402 -typedef struct sqlite3_index_info sqlite3_index_info;
  7.5403 -typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;
  7.5404 -typedef struct sqlite3_module sqlite3_module;
  7.5405 -
  7.5406 -/*
  7.5407 -** CAPI3REF: Virtual Table Object
  7.5408 -** KEYWORDS: sqlite3_module {virtual table module}
  7.5409 -**
  7.5410 -** This structure, sometimes called a "virtual table module", 
  7.5411 -** defines the implementation of a [virtual tables].  
  7.5412 -** This structure consists mostly of methods for the module.
  7.5413 -**
  7.5414 -** ^A virtual table module is created by filling in a persistent
  7.5415 -** instance of this structure and passing a pointer to that instance
  7.5416 -** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
  7.5417 -** ^The registration remains valid until it is replaced by a different
  7.5418 -** module or until the [database connection] closes.  The content
  7.5419 -** of this structure must not change while it is registered with
  7.5420 -** any database connection.
  7.5421 -*/
  7.5422 -struct sqlite3_module {
  7.5423 -  int iVersion;
  7.5424 -  int (*xCreate)(sqlite3*, void *pAux,
  7.5425 -               int argc, const char *const*argv,
  7.5426 -               sqlite3_vtab **ppVTab, char**);
  7.5427 -  int (*xConnect)(sqlite3*, void *pAux,
  7.5428 -               int argc, const char *const*argv,
  7.5429 -               sqlite3_vtab **ppVTab, char**);
  7.5430 -  int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);
  7.5431 -  int (*xDisconnect)(sqlite3_vtab *pVTab);
  7.5432 -  int (*xDestroy)(sqlite3_vtab *pVTab);
  7.5433 -  int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);
  7.5434 -  int (*xClose)(sqlite3_vtab_cursor*);
  7.5435 -  int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,
  7.5436 -                int argc, sqlite3_value **argv);
  7.5437 -  int (*xNext)(sqlite3_vtab_cursor*);
  7.5438 -  int (*xEof)(sqlite3_vtab_cursor*);
  7.5439 -  int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);
  7.5440 -  int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);
  7.5441 -  int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);
  7.5442 -  int (*xBegin)(sqlite3_vtab *pVTab);
  7.5443 -  int (*xSync)(sqlite3_vtab *pVTab);
  7.5444 -  int (*xCommit)(sqlite3_vtab *pVTab);
  7.5445 -  int (*xRollback)(sqlite3_vtab *pVTab);
  7.5446 -  int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,
  7.5447 -                       void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
  7.5448 -                       void **ppArg);
  7.5449 -  int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
  7.5450 -  /* The methods above are in version 1 of the sqlite_module object. Those 
  7.5451 -  ** below are for version 2 and greater. */
  7.5452 -  int (*xSavepoint)(sqlite3_vtab *pVTab, int);
  7.5453 -  int (*xRelease)(sqlite3_vtab *pVTab, int);
  7.5454 -  int (*xRollbackTo)(sqlite3_vtab *pVTab, int);
  7.5455 -};
  7.5456 -
  7.5457 -/*
  7.5458 -** CAPI3REF: Virtual Table Indexing Information
  7.5459 -** KEYWORDS: sqlite3_index_info
  7.5460 -**
  7.5461 -** The sqlite3_index_info structure and its substructures is used as part
  7.5462 -** of the [virtual table] interface to
  7.5463 -** pass information into and receive the reply from the [xBestIndex]
  7.5464 -** method of a [virtual table module].  The fields under **Inputs** are the
  7.5465 -** inputs to xBestIndex and are read-only.  xBestIndex inserts its
  7.5466 -** results into the **Outputs** fields.
  7.5467 -**
  7.5468 -** ^(The aConstraint[] array records WHERE clause constraints of the form:
  7.5469 -**
  7.5470 -** <blockquote>column OP expr</blockquote>
  7.5471 -**
  7.5472 -** where OP is =, &lt;, &lt;=, &gt;, or &gt;=.)^  ^(The particular operator is
  7.5473 -** stored in aConstraint[].op using one of the
  7.5474 -** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^
  7.5475 -** ^(The index of the column is stored in
  7.5476 -** aConstraint[].iColumn.)^  ^(aConstraint[].usable is TRUE if the
  7.5477 -** expr on the right-hand side can be evaluated (and thus the constraint
  7.5478 -** is usable) and false if it cannot.)^
  7.5479 -**
  7.5480 -** ^The optimizer automatically inverts terms of the form "expr OP column"
  7.5481 -** and makes other simplifications to the WHERE clause in an attempt to
  7.5482 -** get as many WHERE clause terms into the form shown above as possible.
  7.5483 -** ^The aConstraint[] array only reports WHERE clause terms that are
  7.5484 -** relevant to the particular virtual table being queried.
  7.5485 -**
  7.5486 -** ^Information about the ORDER BY clause is stored in aOrderBy[].
  7.5487 -** ^Each term of aOrderBy records a column of the ORDER BY clause.
  7.5488 -**
  7.5489 -** The [xBestIndex] method must fill aConstraintUsage[] with information
  7.5490 -** about what parameters to pass to xFilter.  ^If argvIndex>0 then
  7.5491 -** the right-hand side of the corresponding aConstraint[] is evaluated
  7.5492 -** and becomes the argvIndex-th entry in argv.  ^(If aConstraintUsage[].omit
  7.5493 -** is true, then the constraint is assumed to be fully handled by the
  7.5494 -** virtual table and is not checked again by SQLite.)^
  7.5495 -**
  7.5496 -** ^The idxNum and idxPtr values are recorded and passed into the
  7.5497 -** [xFilter] method.
  7.5498 -** ^[sqlite3_free()] is used to free idxPtr if and only if
  7.5499 -** needToFreeIdxPtr is true.
  7.5500 -**
  7.5501 -** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in
  7.5502 -** the correct order to satisfy the ORDER BY clause so that no separate
  7.5503 -** sorting step is required.
  7.5504 -**
  7.5505 -** ^The estimatedCost value is an estimate of the cost of a particular
  7.5506 -** strategy. A cost of N indicates that the cost of the strategy is similar
  7.5507 -** to a linear scan of an SQLite table with N rows. A cost of log(N) 
  7.5508 -** indicates that the expense of the operation is similar to that of a
  7.5509 -** binary search on a unique indexed field of an SQLite table with N rows.
  7.5510 -**
  7.5511 -** ^The estimatedRows value is an estimate of the number of rows that
  7.5512 -** will be returned by the strategy.
  7.5513 -**
  7.5514 -** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
  7.5515 -** structure for SQLite version 3.8.2. If a virtual table extension is
  7.5516 -** used with an SQLite version earlier than 3.8.2, the results of attempting 
  7.5517 -** to read or write the estimatedRows field are undefined (but are likely 
  7.5518 -** to included crashing the application). The estimatedRows field should
  7.5519 -** therefore only be used if [sqlite3_libversion_number()] returns a
  7.5520 -** value greater than or equal to 3008002.
  7.5521 -*/
  7.5522 -struct sqlite3_index_info {
  7.5523 -  /* Inputs */
  7.5524 -  int nConstraint;           /* Number of entries in aConstraint */
  7.5525 -  struct sqlite3_index_constraint {
  7.5526 -     int iColumn;              /* Column on left-hand side of constraint */
  7.5527 -     unsigned char op;         /* Constraint operator */
  7.5528 -     unsigned char usable;     /* True if this constraint is usable */
  7.5529 -     int iTermOffset;          /* Used internally - xBestIndex should ignore */
  7.5530 -  } *aConstraint;            /* Table of WHERE clause constraints */
  7.5531 -  int nOrderBy;              /* Number of terms in the ORDER BY clause */
  7.5532 -  struct sqlite3_index_orderby {
  7.5533 -     int iColumn;              /* Column number */
  7.5534 -     unsigned char desc;       /* True for DESC.  False for ASC. */
  7.5535 -  } *aOrderBy;               /* The ORDER BY clause */
  7.5536 -  /* Outputs */
  7.5537 -  struct sqlite3_index_constraint_usage {
  7.5538 -    int argvIndex;           /* if >0, constraint is part of argv to xFilter */
  7.5539 -    unsigned char omit;      /* Do not code a test for this constraint */
  7.5540 -  } *aConstraintUsage;
  7.5541 -  int idxNum;                /* Number used to identify the index */
  7.5542 -  char *idxStr;              /* String, possibly obtained from sqlite3_malloc */
  7.5543 -  int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */
  7.5544 -  int orderByConsumed;       /* True if output is already ordered */
  7.5545 -  double estimatedCost;           /* Estimated cost of using this index */
  7.5546 -  /* Fields below are only available in SQLite 3.8.2 and later */
  7.5547 -  sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */
  7.5548 -};
  7.5549 -
  7.5550 -/*
  7.5551 -** CAPI3REF: Virtual Table Constraint Operator Codes
  7.5552 -**
  7.5553 -** These macros defined the allowed values for the
  7.5554 -** [sqlite3_index_info].aConstraint[].op field.  Each value represents
  7.5555 -** an operator that is part of a constraint term in the wHERE clause of
  7.5556 -** a query that uses a [virtual table].
  7.5557 -*/
  7.5558 -#define SQLITE_INDEX_CONSTRAINT_EQ    2
  7.5559 -#define SQLITE_INDEX_CONSTRAINT_GT    4
  7.5560 -#define SQLITE_INDEX_CONSTRAINT_LE    8
  7.5561 -#define SQLITE_INDEX_CONSTRAINT_LT    16
  7.5562 -#define SQLITE_INDEX_CONSTRAINT_GE    32
  7.5563 -#define SQLITE_INDEX_CONSTRAINT_MATCH 64
  7.5564 -
  7.5565 -/*
  7.5566 -** CAPI3REF: Register A Virtual Table Implementation
  7.5567 -**
  7.5568 -** ^These routines are used to register a new [virtual table module] name.
  7.5569 -** ^Module names must be registered before
  7.5570 -** creating a new [virtual table] using the module and before using a
  7.5571 -** preexisting [virtual table] for the module.
  7.5572 -**
  7.5573 -** ^The module name is registered on the [database connection] specified
  7.5574 -** by the first parameter.  ^The name of the module is given by the 
  7.5575 -** second parameter.  ^The third parameter is a pointer to
  7.5576 -** the implementation of the [virtual table module].   ^The fourth
  7.5577 -** parameter is an arbitrary client data pointer that is passed through
  7.5578 -** into the [xCreate] and [xConnect] methods of the virtual table module
  7.5579 -** when a new virtual table is be being created or reinitialized.
  7.5580 -**
  7.5581 -** ^The sqlite3_create_module_v2() interface has a fifth parameter which
  7.5582 -** is a pointer to a destructor for the pClientData.  ^SQLite will
  7.5583 -** invoke the destructor function (if it is not NULL) when SQLite
  7.5584 -** no longer needs the pClientData pointer.  ^The destructor will also
  7.5585 -** be invoked if the call to sqlite3_create_module_v2() fails.
  7.5586 -** ^The sqlite3_create_module()
  7.5587 -** interface is equivalent to sqlite3_create_module_v2() with a NULL
  7.5588 -** destructor.
  7.5589 -*/
  7.5590 -SQLITE_API int sqlite3_create_module(
  7.5591 -  sqlite3 *db,               /* SQLite connection to register module with */
  7.5592 -  const char *zName,         /* Name of the module */
  7.5593 -  const sqlite3_module *p,   /* Methods for the module */
  7.5594 -  void *pClientData          /* Client data for xCreate/xConnect */
  7.5595 -);
  7.5596 -SQLITE_API int sqlite3_create_module_v2(
  7.5597 -  sqlite3 *db,               /* SQLite connection to register module with */
  7.5598 -  const char *zName,         /* Name of the module */
  7.5599 -  const sqlite3_module *p,   /* Methods for the module */
  7.5600 -  void *pClientData,         /* Client data for xCreate/xConnect */
  7.5601 -  void(*xDestroy)(void*)     /* Module destructor function */
  7.5602 -);
  7.5603 -
  7.5604 -/*
  7.5605 -** CAPI3REF: Virtual Table Instance Object
  7.5606 -** KEYWORDS: sqlite3_vtab
  7.5607 -**
  7.5608 -** Every [virtual table module] implementation uses a subclass
  7.5609 -** of this object to describe a particular instance
  7.5610 -** of the [virtual table].  Each subclass will
  7.5611 -** be tailored to the specific needs of the module implementation.
  7.5612 -** The purpose of this superclass is to define certain fields that are
  7.5613 -** common to all module implementations.
  7.5614 -**
  7.5615 -** ^Virtual tables methods can set an error message by assigning a
  7.5616 -** string obtained from [sqlite3_mprintf()] to zErrMsg.  The method should
  7.5617 -** take care that any prior string is freed by a call to [sqlite3_free()]
  7.5618 -** prior to assigning a new string to zErrMsg.  ^After the error message
  7.5619 -** is delivered up to the client application, the string will be automatically
  7.5620 -** freed by sqlite3_free() and the zErrMsg field will be zeroed.
  7.5621 -*/
  7.5622 -struct sqlite3_vtab {
  7.5623 -  const sqlite3_module *pModule;  /* The module for this virtual table */
  7.5624 -  int nRef;                       /* NO LONGER USED */
  7.5625 -  char *zErrMsg;                  /* Error message from sqlite3_mprintf() */
  7.5626 -  /* Virtual table implementations will typically add additional fields */
  7.5627 -};
  7.5628 -
  7.5629 -/*
  7.5630 -** CAPI3REF: Virtual Table Cursor Object
  7.5631 -** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
  7.5632 -**
  7.5633 -** Every [virtual table module] implementation uses a subclass of the
  7.5634 -** following structure to describe cursors that point into the
  7.5635 -** [virtual table] and are used
  7.5636 -** to loop through the virtual table.  Cursors are created using the
  7.5637 -** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed
  7.5638 -** by the [sqlite3_module.xClose | xClose] method.  Cursors are used
  7.5639 -** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods
  7.5640 -** of the module.  Each module implementation will define
  7.5641 -** the content of a cursor structure to suit its own needs.
  7.5642 -**
  7.5643 -** This superclass exists in order to define fields of the cursor that
  7.5644 -** are common to all implementations.
  7.5645 -*/
  7.5646 -struct sqlite3_vtab_cursor {
  7.5647 -  sqlite3_vtab *pVtab;      /* Virtual table of this cursor */
  7.5648 -  /* Virtual table implementations will typically add additional fields */
  7.5649 -};
  7.5650 -
  7.5651 -/*
  7.5652 -** CAPI3REF: Declare The Schema Of A Virtual Table
  7.5653 -**
  7.5654 -** ^The [xCreate] and [xConnect] methods of a
  7.5655 -** [virtual table module] call this interface
  7.5656 -** to declare the format (the names and datatypes of the columns) of
  7.5657 -** the virtual tables they implement.
  7.5658 -*/
  7.5659 -SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
  7.5660 -
  7.5661 -/*
  7.5662 -** CAPI3REF: Overload A Function For A Virtual Table
  7.5663 -**
  7.5664 -** ^(Virtual tables can provide alternative implementations of functions
  7.5665 -** using the [xFindFunction] method of the [virtual table module].  
  7.5666 -** But global versions of those functions
  7.5667 -** must exist in order to be overloaded.)^
  7.5668 -**
  7.5669 -** ^(This API makes sure a global version of a function with a particular
  7.5670 -** name and number of parameters exists.  If no such function exists
  7.5671 -** before this API is called, a new function is created.)^  ^The implementation
  7.5672 -** of the new function always causes an exception to be thrown.  So
  7.5673 -** the new function is not good for anything by itself.  Its only
  7.5674 -** purpose is to be a placeholder function that can be overloaded
  7.5675 -** by a [virtual table].
  7.5676 -*/
  7.5677 -SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
  7.5678 -
  7.5679 -/*
  7.5680 -** The interface to the virtual-table mechanism defined above (back up
  7.5681 -** to a comment remarkably similar to this one) is currently considered
  7.5682 -** to be experimental.  The interface might change in incompatible ways.
  7.5683 -** If this is a problem for you, do not use the interface at this time.
  7.5684 -**
  7.5685 -** When the virtual-table mechanism stabilizes, we will declare the
  7.5686 -** interface fixed, support it indefinitely, and remove this comment.
  7.5687 -*/
  7.5688 -
  7.5689 -/*
  7.5690 -** CAPI3REF: A Handle To An Open BLOB
  7.5691 -** KEYWORDS: {BLOB handle} {BLOB handles}
  7.5692 -**
  7.5693 -** An instance of this object represents an open BLOB on which
  7.5694 -** [sqlite3_blob_open | incremental BLOB I/O] can be performed.
  7.5695 -** ^Objects of this type are created by [sqlite3_blob_open()]
  7.5696 -** and destroyed by [sqlite3_blob_close()].
  7.5697 -** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
  7.5698 -** can be used to read or write small subsections of the BLOB.
  7.5699 -** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
  7.5700 -*/
  7.5701 -typedef struct sqlite3_blob sqlite3_blob;
  7.5702 -
  7.5703 -/*
  7.5704 -** CAPI3REF: Open A BLOB For Incremental I/O
  7.5705 -**
  7.5706 -** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
  7.5707 -** in row iRow, column zColumn, table zTable in database zDb;
  7.5708 -** in other words, the same BLOB that would be selected by:
  7.5709 -**
  7.5710 -** <pre>
  7.5711 -**     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
  7.5712 -** </pre>)^
  7.5713 -**
  7.5714 -** ^If the flags parameter is non-zero, then the BLOB is opened for read
  7.5715 -** and write access. ^If it is zero, the BLOB is opened for read access.
  7.5716 -** ^It is not possible to open a column that is part of an index or primary 
  7.5717 -** key for writing. ^If [foreign key constraints] are enabled, it is 
  7.5718 -** not possible to open a column that is part of a [child key] for writing.
  7.5719 -**
  7.5720 -** ^Note that the database name is not the filename that contains
  7.5721 -** the database but rather the symbolic name of the database that
  7.5722 -** appears after the AS keyword when the database is connected using [ATTACH].
  7.5723 -** ^For the main database file, the database name is "main".
  7.5724 -** ^For TEMP t