I'm using the C interface to SQLite and need to list the size of the a string stored in TEXT column, i.e. what some databases would support using
SELECT DATALENGTH(body) FROM table;
However, SQLite does not have the DATALENGTH function. Since the text in question is quite large, I want to avoid loading the actual body column from disk. Since the TEXT is utf8, LENGTH(body) does not return the desired result (it does return the character count, whereas I need to know the storage size). Converting the column to BLOB is not an option because the database is created by a third-party program.
Q: Is there any way to obtain this information directly from the database, short of writing a custom SQL function? The SQLite file format does store the length of TEXT fields, so I'd be surprised if this information really isn't exposed.
Related: