sqlite3_limit result code
(1) By anonymous on 2024-12-02 19:09:58 [link] [source]
Hi, http://www.sqlite.org/c3ref/limit.html says
Regardless of whether or not the limit was changed, the sqlite3_limit() interface returns the prior value of the limit.
But https://www.sqlite.org/src/file?ci=trunk&name=ext/jni/src/org/sqlite/jni/wrapper1/Sqlite.java&ln=867-869 seems to imply that a negative value is an error.
if( rc<0 ){
throw new SqliteException(CApi.SQLITE_RANGE);
}
Could you please advise / confirm that a negative result code is always an error ?
Thanks.
(2) By Stephan Beal (stephan) on 2024-12-02 19:18:19 in reply to 1 [link] [source]
Regardless of whether or not the limit was changed, the sqlite3_limit() interface returns the prior value of the limit
i am away from the computer so cannot readily verify this, but my recollection is that a negative return indicates that the limit constant/id passed to it is invalid. The return result you quote applies only for legal limit constants/ids. In other words: garbage in, garbage out.
i will double check that when i'm back on the computer (probably Tuesday).
(3) By Stephan Beal (stephan) on 2024-12-02 23:55:16 in reply to 2 [source]
my recollection is that a negative return indicates that the limit constant/id passed to it is invalid. The return result you quote applies only for legal limit constants/ids. In other words: garbage in, garbage out.
Verified: the result of sqlite3_limit() is undefined if it's passed an invalid LIMIT constant or a NULL sqlite3_db pointer. "Undefined" means that it can legally return a chicken or a full-length Hollywood film in those cases (if it can somehow determine how to encode one of those in a single singed integer). When passed an invalid LIMIT constant, it instead chooses to return a negative value. In the case of a NULL db pointer its behavior depends on whether the compile-time SQLITE_ENABLE_API_ARMOR is used: if so, it will return a negative value, else it will dereference a NULL pointer (i.e. it crashes on all known platforms). The JNI build you link to is hard-coded to use the SQLITE_ENABLE_API_ARMOR flag.