Raising the SQLite AttachDatabase limit

By default SQLite limits the number of attached databases to 10. I would like to raise this limit to 24, which is possible according to the SQLite documentation. However, given that SQLite is wrapped in a XOJO class I can’t call the sqlite3_limit function suggested. Can anyone point me at an option I can use to adjust this limit.

The c API call is:
int sqlite3_limit(sqlite3*, int id, int newVal);

and the parameter SQLITE_LIMIT_ATTACHED (which has a value of 7).

Thanks
Ian

The compiled in limit is 10
You won’t be able to raise it above that - per the docs for sqlite3_limit SQLITE_LIMIT_ATTACHED is the category ID
The MAX is a compiled in value SQLITE_MAX_ATTACHED which is 10
For each limit category SQLITE_LIMIT_NAME there is a hard upper bound set at compile-time by a C preprocessor macro called SQLITE_MAX_NAME. Attempts to increase a limit above its hard upper bound are silently truncated to the hard upper bound.

Hi Norman,
Thanks for that, however, according to the docs the limit as far as SQLite is concerned is 125.

https://www.sqlite.org/limits.html (item 11)

You stopped at a very key point:

So it’s only a matter of altering the default and re-compiling. The true hard limit for this parameter is 125

I could really do with the limit being 25, otherwise I’m going to have to merge a whole load of databases, rather than running queries on a set of unions. Obviously a huge overhead.

From the header file in the sqlite source we use

/*
** The maximum number of attached databases. This must be between 0
** and 62. The upper bound on 62 is because a 64-bit integer bitmap
** is used internally to track attached databases.
*/
#ifndef SQLITE_MAX_ATTACHED

define SQLITE_MAX_ATTACHED 10

#endif

so its currently compiled as 10

Changing that limit would be an FR

FR created, thanks
<https://xojo.com/issue/37170>