From ade9263aa485636f95d425de0833811dd4328e49 Mon Sep 17 00:00:00 2001 From: Cheng Date: Mon, 13 Nov 2023 19:29:02 +0000 Subject: [PATCH] minor changes in sqlite compile time options. Again, wasting time on a digression --- sqlite3/sqlite3.c | 9 ++++----- src/sqlite3.h | 11 ++++------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/sqlite3/sqlite3.c b/sqlite3/sqlite3.c index 436714c..8c6acd7 100644 --- a/sqlite3/sqlite3.c +++ b/sqlite3/sqlite3.c @@ -28,21 +28,20 @@ #define SQLITE_THREADSAFE 2 //Sets the default mode to SQLITE_CONFIG_MULTITHREAD. One thread, one database connection. Data structures such as compiled SQL are threadlocal. But sqlite3 is empowered to do its own multithreading. Many databases per database connection. Database connection and compiled sql statements are threadlocal. last_insert_rowid() is not subject to race conditions in this mode. #define SQLITE_DEFAULT_MEMSTATUS 0 //Don't track memory usage. Disables the ability of the program using sqlite3 to monitor its memory usage. This setting causes the sqlite3_status() interfaces that track memory usage to be disabled. This helps the sqlite3_malloc() routines run much faster, and since SQLite uses sqlite3_malloc() internally, this helps to make the entire library faster. #define SQLITE_DEFAULT_WAL_SYNCHRONOUS 1 // in WAL mode, recent changes to the database might be rolled back by a power loss, but the database will not be corrupted. Furthermore, transaction commit is much faster in WAL mode using synchronous=NORMAL than with the default synchronous=FULL. For these reasons, it is recommended that the synchronous setting be changed from FULL to NORMAL when switching to WAL mode. This compile-time option will accomplish that. -#define SQLITE_DEFAULT_FOREIGN_KEYS 0 //Dont handle foreign key constraints. Programmer has to do it himself. +#define SQLITE_DEFAULT_FOREIGN_KEYS 1 //if this compile-time parameter is set to 1, enforcement of foreign key constraints will be on by default. #define SQLITE_LIKE_DOESNT_MATCH_BLOBS 1 //Blobs are not strings. Historically, SQLite has allowed BLOB operands to the LIKE and GLOB operators. But having a BLOB as an operand of LIKE or GLOB complicates and slows the LIKE optimization. When this option is set, it means that the LIKE and GLOB operators always return FALSE if either operand is a BLOB. That simplifies the implementation of the LIKE optimization and allows queries that use the LIKE optimization to run faster. #define SQLITE_MAX_EXPR_DEPTH 0 //Setting the maximum expression parse-tree depth to zero disables all checking of the expression parse-tree depth, which simplifies the code resulting in faster execution, and helps the parse tree to use less memory. #define SQLITE_OMIT_DECLTYPE 1 // By omitting the (seldom-needed) ability to return the declared type of columns from the result set of query, prepared statements can be made to consume less memory. -#define SQLITE_OMIT_DEPRECATED 1 -#define SQLITE_OMIT_PROGRESS_CALLBACK 1 -#define SQLITE_OMIT_SHARED_CACHE 1 +#define SQLITE_OMIT_DEPRECATED 1 //Omitting deprecated interfaces and features will not help SQLite to run any faster. It will reduce the library footprint, however. And it is the right thing to do. +#define SQLITE_OMIT_PROGRESS_CALLBACK 1 // The progress handler callback counter must be checked in the inner loop of the bytecode engine. By omitting this interface, a single conditional is removed from the inner loop of the bytecode engine, helping SQL statements to run slightly faster. #define SQLITE_OMIT_UTF16 1 #define SQLITE_USE_ALLOCA 1 //Make use of alloca() for dynamically allocating temporary stack space for use within a single function, on systems that support alloca(). Without this option, temporary space is allocated from the heap #define SQLITE_OMIT_LOAD_EXTENSION 1 #define SQLITE_TEMP_STORE 1 //Temporary files are stashed on disk when their cache overflows. #define SQLITE_OMIT_AUTOINIT 1 //.The SQLite library needs to be initialized using a call to sqlite3_initialize() before certain interfaces are used.This initialization normally happens automatically the first time it is needed.However, with the SQLITE_OMIT_AUTOINIT option, the automatic initialization is omitted.This helps many API calls to run a little faster(since they do not have to check to see if initialization has already occurred and then run initialization if it has not previously been invoked) but it also means that the application must call sqlite3_initialize() manually.If SQLite is compiled with - DSQLITE_OMIT_AUTOINIT and a routine like sqlite3_malloc() or sqlite3_vfs_find() or sqlite3_open() is invoked without first calling sqlite3_initialize(), the likely result will be a segfault +#define SQLITE_OMIT_AUTORESET 1 //end my custom compile options*/ - /************** Begin file sqliteInt.h ***************************************/ /* ** 2001 September 15 diff --git a/src/sqlite3.h b/src/sqlite3.h index 2e3aa31..ea6a5f6 100644 --- a/src/sqlite3.h +++ b/src/sqlite3.h @@ -74,22 +74,19 @@ extern "C" { #define SQLITE_THREADSAFE 2 //Sets the default mode to SQLITE_CONFIG_MULTITHREAD. One thread, one database connection. Data structures such as compiled SQL are threadlocal. But sqlite3 is empowered to do its own multithreading. Many databases per database connection. Database connection and compiled sql statements are threadlocal. last_insert_rowid() is not subject to race conditions in this mode. #define SQLITE_DEFAULT_MEMSTATUS 0 //Don't track memory usage. Disables the ability of the program using sqlite3 to monitor its memory usage. This setting causes the sqlite3_status() interfaces that track memory usage to be disabled. This helps the sqlite3_malloc() routines run much faster, and since SQLite uses sqlite3_malloc() internally, this helps to make the entire library faster. #define SQLITE_DEFAULT_WAL_SYNCHRONOUS 1 // in WAL mode, recent changes to the database might be rolled back by a power loss, but the database will not be corrupted. Furthermore, transaction commit is much faster in WAL mode using synchronous=NORMAL than with the default synchronous=FULL. For these reasons, it is recommended that the synchronous setting be changed from FULL to NORMAL when switching to WAL mode. This compile-time option will accomplish that. -#define SQLITE_DEFAULT_FOREIGN_KEYS 0 //Dont handle foreign key constraints. Programmer has to do it himself. +#define SQLITE_DEFAULT_FOREIGN_KEYS 1 //if this compile-time parameter is set to 1, enforcement of foreign key constraints will be on by default. #define SQLITE_LIKE_DOESNT_MATCH_BLOBS 1 //Blobs are not strings. Historically, SQLite has allowed BLOB operands to the LIKE and GLOB operators. But having a BLOB as an operand of LIKE or GLOB complicates and slows the LIKE optimization. When this option is set, it means that the LIKE and GLOB operators always return FALSE if either operand is a BLOB. That simplifies the implementation of the LIKE optimization and allows queries that use the LIKE optimization to run faster. #define SQLITE_MAX_EXPR_DEPTH 0 //Setting the maximum expression parse-tree depth to zero disables all checking of the expression parse-tree depth, which simplifies the code resulting in faster execution, and helps the parse tree to use less memory. #define SQLITE_OMIT_DECLTYPE 1 // By omitting the (seldom-needed) ability to return the declared type of columns from the result set of query, prepared statements can be made to consume less memory. -#define SQLITE_OMIT_DEPRECATED 1 -#define SQLITE_DQS 0 //Don't accept double quoted string literals. -#define SQLITE_OMIT_PROGRESS_CALLBACK 1 -#define SQLITE_OMIT_SHARED_CACHE 1 +#define SQLITE_OMIT_DEPRECATED 1 //Omitting deprecated interfaces and features will not help SQLite to run any faster. It will reduce the library footprint, however. And it is the right thing to do. +#define SQLITE_OMIT_PROGRESS_CALLBACK 1 // The progress handler callback counter must be checked in the inner loop of the bytecode engine. By omitting this interface, a single conditional is removed from the inner loop of the bytecode engine, helping SQL statements to run slightly faster. #define SQLITE_OMIT_UTF16 1 #define SQLITE_USE_ALLOCA 1 //Make use of alloca() for dynamically allocating temporary stack space for use within a single function, on systems that support alloca(). Without this option, temporary space is allocated from the heap #define SQLITE_OMIT_LOAD_EXTENSION 1 #define SQLITE_TEMP_STORE 1 //Temporary files are stashed on disk when their cache overflows. #define SQLITE_OMIT_AUTOINIT 1 //.The SQLite library needs to be initialized using a call to sqlite3_initialize() before certain interfaces are used.This initialization normally happens automatically the first time it is needed.However, with the SQLITE_OMIT_AUTOINIT option, the automatic initialization is omitted.This helps many API calls to run a little faster(since they do not have to check to see if initialization has already occurred and then run initialization if it has not previously been invoked) but it also means that the application must call sqlite3_initialize() manually.If SQLite is compiled with - DSQLITE_OMIT_AUTOINIT and a routine like sqlite3_malloc() or sqlite3_vfs_find() or sqlite3_open() is invoked without first calling sqlite3_initialize(), the likely result will be a segfault +#define SQLITE_OMIT_AUTORESET 1 //end my custom compile options*/ - - #ifndef SQLITE_EXTERN # define SQLITE_EXTERN extern #endif