QUESTION: what is the max length allowed for text blobs?

Issue #46 closed
NML Admin created an issue

Didn't know where else to ask this, sorry!

What is the maximum length of a text blob field used in a Xamarin project?

Thanks!

Comments (2)

  1. Guillermo Gutiérrez

    Recommended way of posting questions is using StackOverflow with the sqlite-net-extensions tag.

    String properties are stored in varchar fields of the length specified in the MaxLength attribute of the property, you can easily check this behavior by looking at the SQLite.Net source code. If maximum length attribute is not specified, according to the SQLite documentation the default maximum length is 1 billion bytes:

    The maximum number of bytes in a string or BLOB in SQLite is defined by the preprocessor macro SQLITE_MAX_LENGTH. The default value of this macro is 1 billion (1 thousand million or 1,000,000,000). You can raise or lower this value at compile-time using a command-line option like this:

    -DSQLITE_MAX_LENGTH=123456789

    The current implementation will only support a string or BLOB length up to 231-1 or 2147483647. And some built-in functions such as hex() might fail well before that point. In security-sensitive applications it is best not to try to increase the maximum string and blob length. In fact, you might do well to lower the maximum string and blob length to something more in the range of a few million if that is possible.

    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.

    The maximum string or BLOB length can be lowered at run-time using the sqlite3_limit(db,SQLITE_LIMIT_LENGTH,size) interface.

  2. Log in to comment