标准码(StandardCodes)
下面是标准的返回值和错误码定义:
- #definesqlITE_OK0/*Successfulresult*/
- /*beginning-of-error-codes*/
- #definesqlITE_ERROR1/*sqlerrorormissingdatabase*/
- #definesqlITE_INTERNAL2/*Internallogicerrorinsqlite*/
- #definesqlITE_PERM3/*Accesspermissiondenied*/
- #definesqlITE_ABORT4/*Callbackroutinerequestedanabort*/
- #definesqlITE_BUSY5/*Thedatabasefileislocked*/
- #definesqlITE_LOCKED6/*Atableinthedatabaseislocked*/
- #definesqlITE_NOMEM7/*Amalloc()Failed*/
- #definesqlITE_READONLY8/*Attempttowriteareadonlydatabase*/
- #definesqlITE_INTERRUPT9/*Operationterminatedbysqlite3_interrupt()*/
- #definesqlITE_IOERR10/*SomekindofdiskI/Oerroroccurred*/
- #definesqlITE_CORRUPT11/*Thedatabasediskimageismalformed*/
- #definesqlITE_NOTFOUND12/*Unknownopcodeinsqlite3_file_control()*/
- #definesqlITE_FULL13/*InsertionFailedbecausedatabaseisfull*/
- #definesqlITE_CANTOPEN14/*Unabletoopenthedatabasefile*/
- #definesqlITE_PROTOCOL15/*Databaselockprotocolerror*/
- #definesqlITE_EMPTY16/*Databaseisempty*/
- #definesqlITE_SCHEMA17/*Thedatabaseschemachanged*/
- #definesqlITE_TOOBIG18/*StringorBLOBexceedssizelimit*/
- #definesqlITE_CONSTRAINT19/*Abortduetoconstraintviolation*/
- #definesqlITE_MISMATCH20/*Datatypemismatch*/
- #definesqlITE_MISUSE21/*Libraryusedincorrectly*/
- #definesqlITE_NOLFS22/*UsesOSfeaturesnotsupportedonhost*/
- #definesqlITE_AUTH23/*Authorizationdenied*/
- #definesqlITE_FORMAT24/*Auxiliarydatabaseformaterror*/
- #definesqlITE_RANGE25/*2ndparametertosqlite3_bindoutofrange*/
- #definesqlITE_NOTADB26/*Fileopenedthatisnotadatabasefile*/
- #definesqlITE_ROW100/*sqlite3_step()hasanotherrowready*/
- #definesqlITE_DONE101/*sqlite3_step()hasfinishedexecuting*/
- /*end-of-error-codes*/
其中有些常量只由具体的某个函数返回,比如sqlITE_RANGE只会由sqlite3_bind_xxx函数返回。还有一些常量,比如sqlITE_ERROR只能说明函数在执行过程中发生了错误,但无法知道错误发生的原因。
sqlITE_MISUSE代表API被误用。比如一条语句在sqlite3_step函数执行之后,没有被重置之前,再次给其绑定参数,这时bind函数就会返回sqlITE_MISUSE。
扩展码(ExtendedCodes)
标准错误码对于错误发生的原因,所提供的信息比较少。所以有时候,我们会使用扩展的错误码。扩展错误码是以标准错误码为基础,其低阶字节就是原本的标准错误码,然后在其高阶字节“或”上附加信息,描述错误发生的细节。