xref: /netbsd-src/external/public-domain/sqlite/man/sqlite3_errcode.3 (revision a24efa7dea9f1f56c3bdb15a927d3516792ace1c)
1.Dd $Mdocdate$
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
33The sqlite3_errcode() interface returns the numeric result code
34or extended result code for the most recent failed
35sqlite3_* API call associated with a database connection.
36If a prior API call failed but the most recent API call succeeded,
37the return value from sqlite3_errcode() is undefined.
38The sqlite3_extended_errcode() interface is the same except that it
39always returns the extended result code even when
40extended result codes are disabled.
41.Pp
42The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
43text that describes the error, as either UTF-8 or UTF-16 respectively.
44Memory to hold the error message string is managed internally.
45The application does not need to worry about freeing the result.
46However, the error string might be overwritten or deallocated by subsequent
47calls to other SQLite interface functions.
48.Pp
49The sqlite3_errstr() interface returns the English-language text that
50describes the result code, as UTF-8.
51Memory to hold the error message string is managed internally and must
52not be freed by the application  .
53.Pp
54When the serialized threading mode is in use, it might
55be the case that a second error occurs on a separate thread in between
56the time of the first error and the call to these interfaces.
57When that happens, the second error will be reported since these interfaces
58always report the most recent result.
59To avoid this, each thread can obtain exclusive use of the database connection
60D by invoking sqlite3_mutex_enter(sqlite3_db_mutex(D))
61before beginning to use D and invoking sqlite3_mutex_leave(sqlite3_db_mutex(D))
62after all calls to the interfaces listed here are completed.
63.Pp
64If an interface fails with SQLITE_MISUSE, that means the interface
65was invoked incorrectly by the application.
66In that case, the error code and message may or may not be set.
67.Sh SEE ALSO
68.Xr sqlite3 3 ,
69.Xr SQLITE_IOERR_READ 3 ,
70.Xr SQLITE_OK 3 ,
71.Xr sqlite3_db_mutex 3 ,
72.Xr sqlite3_mutex_alloc 3
73