欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SQLITE源码剖析(16)

程序员文章站 2022-05-08 21:54:26
...

声明:本SQLite源码剖析系列为刘兴(http://deepfuture.iteye.com/)原创,未经笔者授权,任何人和机构不能转载

 

/*结果代码

** CAPI3REF: Result Codes

** KEYWORDS: SQLITE_OK {error code} {error codes}

** KEYWORDS: {result code} {result codes}

**关键字:SQLITE_OK {error code} {error codes}

**关键字:{result code} {result codes}

** Many SQLite functions return an integer result code from the set shown

** here in order to indicates success or failure.

**新的错误代码可能在未来的SQLite版本中被增加

** New error codes may be added in future versions of SQLite.

**更多可以看[SQLITE_IOERR_READ | extended result codes]

** See also: [SQLITE_IOERR_READ | extended result codes]

*/

//成功返回SQLITE_OK ,即0

#define SQLITE_OK           0   /* Successful result */

/* beginning-of-error-codes */

//SQLITE 错误代码宏

#define SQLITE_ERROR        1   /* SQL error or missing database */

#define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */

#define SQLITE_PERM         3   /* Access permission denied */

#define SQLITE_ABORT        4   /* Callback routine requested an abort */

#define SQLITE_BUSY         5   /* The database file is locked */

#define SQLITE_LOCKED       6   /* A table in the database is locked */

#define SQLITE_NOMEM        7   /* A malloc() failed */

#define SQLITE_READONLY     8   /* Attempt to write a readonly database */

#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/

#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */

#define SQLITE_CORRUPT     11   /* The database disk image is malformed */

#define SQLITE_NOTFOUND    12   /* NOT USED. Table or record not found */

#define SQLITE_FULL        13   /* Insertion failed because database is full */

#define SQLITE_CANTOPEN    14   /* Unable to open the database file */

#define SQLITE_PROTOCOL    15   /* NOT USED. Database lock protocol error */

#define SQLITE_EMPTY       16   /* Database is empty */

#define SQLITE_SCHEMA      17   /* The database schema changed */

#define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */

#define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */

#define SQLITE_MISMATCH    20   /* Data type mismatch */

#define SQLITE_MISUSE      21   /* Library used incorrectly */

#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */

#define SQLITE_AUTH        23   /* Authorization denied */

#define SQLITE_FORMAT      24   /* Auxiliary database format error */

#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */

#define SQLITE_NOTADB      26   /* File opened that is not a database file */

#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */

#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */

/* end-of-error-codes */

 

/*

** CAPI3REF: Extended Result Codes

** KEYWORDS: {extended error code} {extended error codes}

** KEYWORDS: {extended result code} {extended result codes}

**扩展返回代码,在默认配置下,SQLITE API返回SQLITE_OK | result codes26总共26个状态整数之一,然而,实践中,这些代码过于粗陋,不能提供太多的问题信息。

** In its default configuration, SQLite API routines return one of 26 integer

** [SQLITE_OK | result codes].  However, experience has shown that many of

** these result codes are too coarse-grained.  They do not provide as

** much information about problems as programmers might like.  In an effort to

** address this, newer versions of SQLite (version 3.3.8 and later) include

** support for additional result codes that provide more detailed information

** about errors. The extended result codes are enabled or disabled

** on a per database connection basis using the

** [sqlite3_extended_result_codes()] API.

**SQLITE的最近新版本(3.3.8及以后)支持额外的返回代码,提供关于错误的更多细节。

使用sqlite3_extended_result_codes()的API在每个数据库连接时允许和禁止额外返回代码。

** Some of the available extended result codes are listed here.

** One may expect the number of extended result codes will be expand

** over time.  Software that uses extended result codes should expect

** to see new result codes in future releases of SQLite.

**下面列出了一些额外返回代码,返回代码随着时间推移越来越多,在未来版本号中将会出现更多的额外返回代码。

** The SQLITE_OK result code will never be extended.  It will always

** be exactly zero.

SQLITE_OK是0,永远不会被扩展和出现更额外的SQLITE_OK

*/

#define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))

#define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2<<8))

#define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3<<8))

#define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4<<8))

#define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5<<8))

#define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6<<8))

#define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7<<8))

#define SQLITE_IOERR_UNLOCK            (SQLITE_IOERR | (8<<8))

#define SQLITE_IOERR_RDLOCK            (SQLITE_IOERR | (9<<8))

#define SQLITE_IOERR_DELETE            (SQLITE_IOERR | (10<<8))

#define SQLITE_IOERR_BLOCKED           (SQLITE_IOERR | (11<<8))

#define SQLITE_IOERR_NOMEM             (SQLITE_IOERR | (12<<8))

#define SQLITE_IOERR_ACCESS            (SQLITE_IOERR | (13<<8))

#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))

#define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))

#define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))

#define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))

#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED | (1<<8) )