1.Dd March 11, 2017 2.Dt SQLITE3_ERRCODE 3 3.Os 4.Sh NAME 5.Nm sqlite3_errcode , 6.Nm sqlite3_extended_errcode , 7.Nm sqlite3_errmsg , 8.Nm sqlite3_errmsg16 , 9.Nm sqlite3_errstr 10.Nd Error Codes And Messages 11.Sh SYNOPSIS 12.Ft int 13.Fo sqlite3_errcode 14.Fa "sqlite3 *db" 15.Fc 16.Ft int 17.Fo sqlite3_extended_errcode 18.Fa "sqlite3 *db" 19.Fc 20.Ft const char * 21.Fo sqlite3_errmsg 22.Fa "sqlite3*" 23.Fc 24.Ft const void * 25.Fo sqlite3_errmsg16 26.Fa "sqlite3*" 27.Fc 28.Ft const char * 29.Fo sqlite3_errstr 30.Fa "int" 31.Fc 32.Sh DESCRIPTION 33If the most recent sqlite3_* API call associated with database connection 34D failed, then the sqlite3_errcode(D) interface returns the numeric 35result code or extended result code 36for that API call. 37If the most recent API call was successful, then the return value from 38sqlite3_errcode() is undefined. 39The sqlite3_extended_errcode() interface is the same except that it 40always returns the extended result code even when 41extended result codes are disabled. 42.Pp 43The sqlite3_errmsg() and sqlite3_errmsg16() return English-language 44text that describes the error, as either UTF-8 or UTF-16 respectively. 45Memory to hold the error message string is managed internally. 46The application does not need to worry about freeing the result. 47However, the error string might be overwritten or deallocated by subsequent 48calls to other SQLite interface functions. 49.Pp 50The sqlite3_errstr() interface returns the English-language text that 51describes the result code, as UTF-8. 52Memory to hold the error message string is managed internally and must 53not be freed by the application . 54.Pp 55When the serialized threading mode is in use, it might 56be the case that a second error occurs on a separate thread in between 57the time of the first error and the call to these interfaces. 58When that happens, the second error will be reported since these interfaces 59always report the most recent result. 60To avoid this, each thread can obtain exclusive use of the database connection 61D by invoking sqlite3_mutex_enter(sqlite3_db_mutex(D)) 62before beginning to use D and invoking sqlite3_mutex_leave(sqlite3_db_mutex(D)) 63after all calls to the interfaces listed here are completed. 64.Pp 65If an interface fails with SQLITE_MISUSE, that means the interface 66was invoked incorrectly by the application. 67In that case, the error code and message may or may not be set. 68.Sh SEE ALSO 69.Xr sqlite3 3 , 70.Xr sqlite3_db_mutex 3 , 71.Xr sqlite3_mutex_alloc 3 72