How to enable 2GB Blobs
(1) By Mark Benningfield (mbenningfield1) on 2022-01-22 13:17:09 [link] [source]
What else do I need to do to allow BLOB's up to int32_t max value?
I defined SQLITE_MAX_LENGTH=2147483647
, but this
#include <stdio.h>
#include "sqlite3.h"
int main(int argc, char *argv[]) {
sqlite3 *pDb;
sqlite3_stmt *pStmt;
char *pzErr;
int rc = sqlite3_open(":memory:", &pDb);
char *sql = "drop table if exists t2;"
"create table t2 (id INTEGER PRIMARY KEY, a BLOB);"
"insert into t2 values (1, zeroblob(2147483647)); ";
rc = sqlite3_exec(pDb, sql, NULL, NULL, &pzErr);
if (rc) {
printf("%s", pzErr);
sqlite3_free(pzErr);
}
}
results in string or blob too big
I'm compiling on Windows with VS2015 (MSVC 1900). I can't debug SQLite very well because the VS debugger is terrified of the amalgamation (even when it is part of the source tree). I tried to set a breakpoint in the zeroblobFunc()
implementation, but the debugger won't hit.
from the sqlite3.c
amalgamation:
#define SQLITE_VERSION "3.37.2"
#define SQLITE_VERSION_NUMBER 3037002
#define SQLITE_SOURCE_ID "2022-01-06 13:25:41 872ba256cbf61d9290b571c0e6d82a20c224ca3ad82971edc46b29818d5d17a0"
(2.1) By RandomCoder on 2022-01-22 19:30:16 edited from 2.0 in reply to 1 [source]
That's how you change the max size of a BLOB, but note this from the documentation:
During part of SQLite's INSERT and SELECT processing, the complete content of each row in the database is encoded as a single BLOB. So the SQLITE_MAX_LENGTH parameter also determines the maximum number of bytes in a row.
So, you need to account for the size of the complete row, meaning in practice you can't insert a blob bigger than (SQLITE_MAX_LENGTH-8) or so, depending on what's in the row.
(3) By Mark Benningfield (mbenningfield1) on 2022-01-23 06:22:21 in reply to 2.1 [link] [source]
Right, thanks. I completely overlooked that.