Query size limit may be documented incorrectly
(1) By anonymous on 2023-10-06 15:47:31 [link] [source]
The documentation for limits states that "The maximum number of bytes in the text of an SQL statement is limited to SQLITE_MAX_SQL_LENGTH which defaults to 1,000,000,000." However, the limit seems to be 1,000,000 (one million), which the following sentence implies. Someone should change that.
(2) By Richard Hipp (drh) on 2023-10-06 16:03:38 in reply to 1 [link] [source]
Looks like 1 billion to me: https://sqlite.org/src/info/33b1c9baba5?ln=55,57
Why do you think it is 1 million instead? What is your evidence?
(3) By anonymous on 2023-10-06 18:34:24 in reply to 2 [link] [source]
When I ran a query (from a Java script) I got an error: [SQLITE_TOOBIG] String or BLOB exceeds size limit (statement too long). The query text would have exceeded the 1,000,000 character limit but not the 1 billion character limit. When I reduced the query length, the code ran fine. Also, the very next line in the documentation starts: "If an SQL statement is limited to be a million bytes in length...". Based on that I thought it likely that the actual limit is 1 million. I did not find any way to check the limit directly, but figured one of the developers could check easily enough.
(4) By Richard Hipp (drh) on 2023-10-06 18:42:13 in reply to 3 [source]
What does this command show you?
PRAGMA compile_options;
I'm guessing that it will show a line that says "MAX_SQL_LENGTH=1000000" which indicates that your Java wrapper was compiled using -DSQLITE_MAX_SQL_LENGTH=1000000, thus overriding the default limit. Please check my guess.
(6) By anonymous on 2023-10-06 20:08:31 in reply to 4 [link] [source]
The code was actually run by someone else on a server that is managed by a campus service group. Unfortunately, I do not have access to that server myself. The Java code that ran the query was not compiled with that particular flag. We are using the sqlite-jdbc jar. I assume from your response that the default limit is 1 billion characters, so that the limit I am seeing came from something else. In any case, thanks for your quick response.
(8) By anonymous on 2023-10-07 02:29:29 in reply to 6 [link] [source]
The source code accompanying Xerial's sqlite-jdbc-3.43.0.0.jar package has a SQLiteConfig.java file containing this section:
/* Default limits used by SQLite: https://www.sqlite.org/limits.html */
private static final int DEFAULT_MAX_LENGTH = 1000000000;
private static final int DEFAULT_MAX_COLUMN = 2000;
private static final int DEFAULT_MAX_SQL_LENGTH = 1000000;
private static final int DEFAULT_MAX_FUNCTION_ARG = 100;
private static final int DEFAULT_MAX_ATTACHED = 10;
private static final int DEFAULT_MAX_PAGE_COUNT = 1073741823;
(5.1) By Stephan Beal (stephan) on 2023-10-06 19:07:06 edited from 5.0 in reply to 3 [link] [source]
When I ran a query (from a Java script)
Perhaps relevant: this project's own JS/WASM build is built with a SQLITE_MAX_ALLOCATION_SIZE of 536870911 (0x1fffffff), i.e. half a gig. The JS/WASM binding does not modify the default MAX_SQL_LENGTH.
If you're running against some other JS binding (e.g. a 3rd-party node.js binding) then you'll need to submit your grievance to the maintainers of that binding.
(7) By punkish on 2023-10-06 21:40:53 in reply to 5.1 [link] [source]
I think the OP is running a Java script, not a JavaScript script
(9) By Chris Locke (chrisjlocke1) on 2023-10-07 11:18:19 in reply to 3 [link] [source]
Based on that I thought it likely that the actual limit is 1 million
That's just giving an example and explaining the limit further. The figure quoted is for illustrative purposes only.