Index: src/db.c ================================================================== --- src/db.c +++ src/db.c @@ -1276,10 +1276,13 @@ if( g.fSqlTrace ) sqlite3_trace_v2(db, SQLITE_TRACE_PROFILE, db_sql_trace, 0); db_add_aux_functions(db); re_add_sql_func(db); /* The REGEXP operator */ foci_register(db); /* The "files_of_checkin" virtual table */ sqlite3_exec(db, "PRAGMA foreign_keys=OFF;", 0, 0, 0); +#if USE_SYSTEM_SQLITE+0==1 + sqlite3_limit(db, SQLITE_LIMIT_WORKER_THREADS, g.maxWorkerThreads); +#endif return db; } /* @@ -1766,10 +1769,14 @@ sqlite3_file_control(g.db, "repository", SQLITE_FCNTL_DATA_VERSION, &g.iRepoDataVers); /* Cache "allow-symlinks" option, because we'll need it on every stat call */ g.allowSymlinks = db_get_boolean("allow-symlinks", db_allow_symlinks_by_default()); + /* Cache "max-wthreads" option */ +#if USE_SYSTEM_SQLITE+0==1 + g.maxWorkerThreads = db_get_int("max-wthreads", 0); +#endif g.zAuxSchema = db_get("aux-schema",""); g.eHashPolicy = db_get_int("hash-policy",-1); if( g.eHashPolicy<0 ){ g.eHashPolicy = hname_default_policy(); db_set_int("hash-policy", g.eHashPolicy, 0); @@ -3540,10 +3547,19 @@ */ /* ** SETTING: max-upload width=25 default=250000 ** A limit on the size of uplink HTTP requests. */ +#if USE_SYSTEM_SQLITE+0==1 +/* +** SETTING: max-wthreads width=16 default=0 +** The maximum number of auxiliary worker threads that a +** single prepared statement may start. Only works when +** using the system SQLite library and when that library +** was compiled with support for threading. +*/ +#endif /* ** SETTING: mimetypes width=40 versionable block-text ** A list of file extension-to-mimetype mappings, one per line. e.g. ** "foo application/x-foo". File extensions are compared ** case-insensitively in the order listed in this setting. A leading Index: src/main.c ================================================================== --- src/main.c +++ src/main.c @@ -312,10 +312,13 @@ } reqPayload; /* request payload object (if any) */ cson_array *warnings; /* response warnings */ int timerId; /* fetched from fossil_timer_start() */ } json; #endif /* FOSSIL_ENABLE_JSON */ +#if USE_SYSTEM_SQLITE+0==1 + int maxWorkerThreads; /* Cached "max-wthreads" option */ +#endif }; /* ** Macro for debugging: */ Index: src/sqlcmd.c ================================================================== --- src/sqlcmd.c +++ src/sqlcmd.c @@ -165,10 +165,13 @@ sqlite3 *db, const char **pzErrMsg, const void *notUsed ){ int mTrace = SQLITE_TRACE_CLOSE; +#if USE_SYSTEM_SQLITE+0==1 + sqlite3_limit(db, SQLITE_LIMIT_WORKER_THREADS, g.maxWorkerThreads); +#endif add_content_sql_commands(db); db_add_aux_functions(db); re_add_sql_func(db); search_sql_setup(db); foci_register(db);