1.Dd December 19, 2018 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. 37The sqlite3_extended_errcode() interface is the same except that it 38always returns the extended result code even when 39extended result codes are disabled. 40.Pp 41The values returned by sqlite3_errcode() and/or sqlite3_extended_errcode() 42might change with each API call. 43Except, there are some interfaces that are guaranteed to never change 44the value of the error code. 45The error-code preserving interfaces are: 46.Bl -bullet 47.It 48sqlite3_errcode() 49.It 50sqlite3_extended_errcode() 51.It 52sqlite3_errmsg() 53.It 54sqlite3_errmsg16() 55.El 56.Pp 57The sqlite3_errmsg() and sqlite3_errmsg16() return English-language 58text that describes the error, as either UTF-8 or UTF-16 respectively. 59Memory to hold the error message string is managed internally. 60The application does not need to worry about freeing the result. 61However, the error string might be overwritten or deallocated by subsequent 62calls to other SQLite interface functions. 63.Pp 64The sqlite3_errstr() interface returns the English-language text that 65describes the result code, as UTF-8. 66Memory to hold the error message string is managed internally and must 67not be freed by the application . 68.Pp 69When the serialized threading mode is in use, it might 70be the case that a second error occurs on a separate thread in between 71the time of the first error and the call to these interfaces. 72When that happens, the second error will be reported since these interfaces 73always report the most recent result. 74To avoid this, each thread can obtain exclusive use of the database connection 75D by invoking sqlite3_mutex_enter(sqlite3_db_mutex(D)) 76before beginning to use D and invoking sqlite3_mutex_leave(sqlite3_db_mutex(D)) 77after all calls to the interfaces listed here are completed. 78.Pp 79If an interface fails with SQLITE_MISUSE, that means the interface 80was invoked incorrectly by the application. 81In that case, the error code and message may or may not be set. 82.Sh SEE ALSO 83.Xr sqlite3 3 , 84.Xr sqlite3_db_mutex 3 , 85.Xr sqlite3_mutex_alloc 3 86