Overview
Many of the routines in the SQLite C-language Interface return
numeric result codes indicating either success or failure, and
in the event of a failure, providing some idea of the cause of
the failure. This document strives to explain what each
of those numeric result codes means.
“Error codes” are a subset of “result codes” that indicate that
something has gone wrong. There are only a few non-error result
codes: SQLITE_OK, SQLITE_ROW, and SQLITE_DONE. The term
“error code” means any result code other than these three.
PostgreSQL присваивает пятисимвольные коды ошибок, которые соответствуют «SQLSTATE». Приложения обычно проверяют код ошибки и только потом обращаются к текстовому сообщению об ошибке. Коды ошибок и текстовое сообщение не меняются в новых выпусках. Обратите внимание, что не все коды ошибок, создаваемые PostgreSQL, определены в стандарте SQL. Некоторые дополнительные коды ошибок были добавлены самостоятельно или заимствованы из других баз данных.
Первые два символа кода ошибки представляют класс ошибок, а последние три символа — конкретное условие в этом классе. Таким образом, если вы не знаете значение конкретного кода ошибки, вы можете определить причину по классу ошибки.
Prerequisite – SQL Injection While checking for SQL injection we all discover various error messages. Let us figure out the basic cause behind each error and how it appears in MySQL. Below are various error and their explanation. Error-1: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ” foo ‘ at line X. Explanation – If you entered a single quote and it altered the syntax of the database query, this is the expected error message. For MySQL, SQL injection may be present, but the same error message can appear in other contexts. Error-2: N/A Explanation – You have commented out or removed a variable that normally would be supplied to the database. Error-3: The used SELECT statements have different number of columns. Explanation – You will see this when you are attempting a UNION SELECT attack, and you specified different number of columns to the number in the original SELECT statement. Error-4: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ XXX, YYY from SOME_TABLE’ at line 1 Explanation – You commonly see this error message when your injection point occurs before the FROM keyword (Example, you have injected into the columns to be returned) and you have used the comment character to remove required SQL keywords. Try completing the SQL statement yourself while using your comment character. MySQL should helpfully reveal the column names XXX, YYY when this condition is encountered. Error-5: Table ‘DBNAME.SOMETABLE’ doesn’t exist. Explanation – Either you are trying to access a table or view that does not exist. Test your query against a table you know you have access to. MySQL should helpfully reveal the current database schema DBNAME when this condition is encountered. Error-6: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ ‘ at line 1. Explanation – You were probably altering something in a WHERE clause, and your SQL injection attempt has disrupted the grammar. Error-7: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ ‘ line 1. Explanation – Your SQL injection attempt has worked, but the injection point was inside parentheses. You probably commented out the closing parentheses with injected comment characters (–). Error-8: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near XXXXX. Explanation – A general error message. The error messages listed previously all take precedence, so something else went wrong. It is likely that you can try alternative input and get a more meaningful message.
Use the RAISE statement to report messages and raise errors.
In this example, the value of v_job_id will replace the % in the string:
RAISE NOTICE ‘Calling cs_create_job(%)’, v_job_id;
Sets the error message text. This option can’t be used in the form of RAISE that includes a format string before USING.
Supplies an error detail message.
Supplies a hint message.
Specifies the error code (SQLSTATE) to report, either by condition name, as shown in Appendix A, or directly as a five-character SQLSTATE code.
Supplies the name of a related object.
This example will abort the transaction with the given error message and hint:
These two examples show equivalent ways of setting the SQLSTATE:
There is a second RAISE syntax in which the main argument is the condition name or SQLSTATE to be reported, for example:
RAISE division_by_zero;
RAISE SQLSTATE ‘22012’;
In this syntax, USING can be used to supply a custom error message, detail, or hint. Another way to do the earlier example is
Still another variant is to write RAISE USING or RAISE level USING and put everything else into the USING list.
Note
If no condition name nor SQLSTATE is specified in a RAISE EXCEPTION command, the default is to use ERRCODE_RAISE_EXCEPTION (P0001). If no message text is specified, the default is to use the condition name or SQLSTATE as message text.
When specifying an error code by SQLSTATE code, you are not limited to the predefined error codes, but can select any error code consisting of five digits and/or upper-case ASCII letters, other than 00000. It is recommended that you avoid throwing error codes that end in three zeroes, because these are category codes and can only be trapped by trapping the whole category.
Checking Assertions
The ASSERT statement is a convenient shorthand for inserting debugging checks into functions.
The condition is a Boolean expression that is expected to always evaluate to true; if it does, the ASSERT statement does nothing further. If the result is false or null, then an ASSERT_FAILURE exception is raised. (If an error occurs while evaluating the condition, it is reported as a normal error.)
If the optional message is provided, it is an expression whose result (if not null) replaces the default error message text , should the condition fail. The message expression is not evaluated in the normal case where the assertion succeeds.
Testing of assertions can be enabled or disabled via the configuration parameter plpgsql.check_asserts, which takes a Boolean value; the default is on. If this parameter is off then ASSERT statements do nothing.
Note that ASSERT is meant for detecting program bugs, not for reporting ordinary error conditions. Use the RAISE statement, described above, for that.
Класс 55 — Объект не находится в состоянии предпосылки
ОБЪЕКТ НЕ НАХОДИТСЯ В СОСТОЯНИИ ПРЕДПОСЫЛКИ
55006
ОБЪЕКТ В ИСПОЛЬЗОВАНИИ
55P02
НЕВОЗМОЖНО ИЗМЕНИТЬ ПАРАМЕТР ВРЕМЕНИ ВЫПОЛНЕНИЯ
55P03
ДОПОЛНИТЕЛЬНЫЕ ДИНАМИЧЕСКИЕ НАБОРЫ РЕЗУЛЬТАТОВ НЕ ВОЗВРАЩАЮТСЯ
Класс 01 — Предупреждение
ВОЗВРАЩЕНЫ ДИНАМИЧЕСКИЕ НАБОРЫ РЕЗУЛЬТАТОВ
01008
НЕЯВНОЕ ЗАПОЛНЕНИЕ НУЛЕВОГО БИТА
01003
НУЛЕВОЕ ЗНАЧЕНИЕ ИСКЛЮЧЕНО В ФУНКЦИИ SET
01007
ПРИВИЛЕГИЯ НЕ ПРЕДОСТАВЛЕНА
1006
ПРИВИЛЕГИЯ НЕ ОТОЗВАНА
01004
УСЕЧЕНИЕ ПРАВОЙ ЧАСТИ СТРОКОВЫХ ДАННЫХ
01P01
СИНТАКСИЧЕСКАЯ ОШИБКА ИЛИ НАРУШЕНИЕ ПРАВИЛА ДОСТУПА
42601
НЕ МОЖЕТ СОХРАНИТЬСЯ
42803
НЕДОПУСТИМЫЙ ВНЕШНИЙ КЛЮЧ
42602
СЛИШКОМ ДЛИННОЕ ИМЯ
42939
НЕСООТВЕТСТВИЕ ТИПОВ ДАННЫХ
42P18
НЕОПРЕДЕЛЕННЫЙ ТИП ДАННЫХ
42809
НЕПРАВИЛЬНЫЙ ТИП ОБЪЕКТА
42703
ДУБЛИРОВАНИЕ БАЗЫ ДАННЫХ
42723
ДУБЛИРОВАНИЕ ПОДГОТОВЛЕННОГО ОПЕРАТОРА
42P06
НЕДОПУСТИМАЯ ССЫЛКА НА СТОЛБЕЦ
42611
НЕКОРРЕКТНОЕ ОПРЕДЕЛЕНИЕ СТОЛБЦА
42P11
НЕКОРРЕКТНОЕ ОПРЕДЕЛЕНИЕ КУРСОРА
42P12
НЕДОПУСТИМОЕ ОПРЕДЕЛЕНИЕ БАЗЫ ДАННЫХ
42P13
НЕВЕРНОЕ ОПРЕДЕЛЕНИЕ ФУНКЦИИ
42P14
НЕДОПУСТИМОЕ ОПРЕДЕЛЕНИЕ ПОДГОТОВЛЕННОГО ОПЕРАТОРА
42P15
НЕВЕРНОЕ ОПРЕДЕЛЕНИЕ СХЕМЫ
42P16
НЕВЕРНОЕ ОПРЕДЕЛЕНИЕ ТАБЛИЦЫ
42P17
НЕВЕРНОЕ ОПРЕДЕЛЕНИЕ ОБЪЕКТА
Класс 38 — Исключение внешней программы
ИСКЛЮЧЕНИЕ ВНЕШНЕЙ ПРОЦЕДУРЫ
38001
СОДЕРЖАНИЕ SQL НЕ РАЗРЕШЕНО
38002
МОДИФИКАЦИЯ ДАННЫХ SQL НЕ РАЗРЕШЕНА
38003
ПРЕДПРИНЯТА ПОПЫТКА ВЫПОЛНЕНИЯ ЗАПРЕЩЕННОГО SQL-ЗАПРОСА
38004
ЧТЕНИЕ SQL-ДАННЫХ НЕ РАЗРЕШЕНО
Класс 3D — Неверное имя каталога
НЕДОПУСТИМОЕ ИМЯ КАТАЛОГА
Класс 40 — Откат транзакции
НАРУШЕНИЕ ОГРАНИЧЕНИЙ ЦЕЛОСТНОСТИ ТРАНЗАКЦИИ
40001
ЗАВЕРШЕНИЕ ОПЕРАЦИИ НЕИЗВЕСТНО
40P01
НЕДОПУСТИМОЕ ИМЯ SQL-ОПЕРАТОРА
Класс 0A — Функция не поддерживается
ФАТУРА НЕ ПОДДЕРЖИВАЕТСЯ Класс 0B — Неправильная инициация транзакции
0B000
НЕКОРРЕКТНОЕ ИНИЦИИРОВАНИЕ ТРАНЗАКЦИИ
Класс XX — Внутренняя ошибка
НАРУШЕНИЕ ОГРАНИЧЕНИЯ ЦЕЛОСТНОСТИ
23001
НАРУШЕНИЕ НЕ НУЛЯ
23503
НАРУШЕНИЕ ВНЕШНЕГО КЛЮЧА
23505
НАРУШЕНИЕ ПРАВИЛ ИЗМЕНЕНИЯ ДАННЫХ
Класс 58 — Системная ошибка (ошибки, внешние по отношению к самому PostgreSQL)
НЕ НАЙДЕНЫ ДАННЫЕ
P0003
СЛИШКОМ МНОГО СТРОК
Класс 2B — Зависимые дескрипторы привилегий все еще существуют
ЗАВИСИМЫЕ ДЕСКРИПТОРЫ ПРИВИЛЕГИЙ ВСЕ ЕЩЕ СУЩЕСТВУЮТ
2BP01
ЗАВИСИМЫЕ ОБЪЕКТЫ ВСЕ ЕЩЕ СУЩЕСТВУЮТ
Класс 03 — SQL-запрос еще не завершен
SQL-ЗАПРОС ЕЩЕ НЕ ЗАВЕРШЕН
Класс 57 — Вмешательство оператора
НАРУШЕНИЕ ОПЦИИ ПРОВЕРКИ
Класс 39 — Исключение при вызове внешнего маршрута
ИСКЛЮЧЕНИЕ ВЫЗОВА ВНЕШНЕЙ ПРОЦЕДУРЫ
39001
ВОЗВРАЩЕНО НЕВЕРНОЕ СОСТОЯНИЕ SQLSTATE
39004
НУЛЕВОЕ ЗНАЧЕНИЕ НЕДОПУСТИМО
39P01
НАРУШЕН ПРОТОКОЛ ТРИГГЕРА
39P02
НАРУШЕН ПРОТОКОЛ SRF
Класс 34 — Неверное имя курсора
НЕДОПУСТИМОЕ ИМЯ КУРСОРА
Класс 08 — Исключение подключения
СОЕДИНЕНИЕ НЕ СУЩЕСТВУЕТ
08006
SQLCLIENT НЕ МОЖЕТ УСТАНОВИТЬ SQL-СОЕДИНЕНИЕ
008004
SQLSERVER ОТКЛОНИЛ СОЗДАНИЕ SQL-СОЕДИНЕНИЯ
08007
РАЗРЕШЕНИЕ ТРАНЗАКЦИИ НЕИЗВЕСТНО
08P01
ИСКЛЮЧЕНИЕ ТОЧКИ СОХРАНЕНИЯ
3B001
НЕВЕРНАЯ СПЕЦИФИКАЦИЯ ТОЧКИ СОХРАНЕНИЯ
Класс 22 — Исключение данных
ОШИБКА ПОДСКРИПТА МАССИВА
22021
СИМВОЛ ОТСУТСТВУЕТ В РЕПЕРТУАРЕ
22008
ПЕРЕПОЛНЕНИЕ ПОЛЯ DATETIME
22012
ДЕЛЕНИЕ НА НОЛЬ
22005
ОШИБКА В ПРИСВОЕНИИ
2200B
КОНФЛИКТ УПРАВЛЯЮЩИХ СИМВОЛОВ
22022
ПЕРЕПОЛНЕНИЕ ПОЛЯ ИНТЕРВАЛА
2201E
НЕДОПУСТИМЫЙ АРГУМЕНТ ДЛЯ ЛОГАРИФМА
2201F
НЕДОПУСТИМЫЙ АРГУМЕНТ ДЛЯ ФУНКЦИИ ПИТАНИЯ
2201G
НЕДОПУСТИМЫЙ АРГУМЕНТ ДЛЯ ФУНКЦИИ ШИРИНЫ ВЕДРА
22018
НЕДОПУСТИМОЕ ЗНАЧЕНИЕ СИМВОЛА ДЛЯ БРОСКА
22007
НЕВЕРНЫЙ ФОРМАТ ВРЕМЕНИ ДАТЫ
22019
НЕДОПУСТИМЫЙ УПРАВЛЯЮЩИЙ СИМВОЛ
2200D
НЕДОПУСТИМЫЙ УПРАВЛЯЮЩИЙ ОКТЕТ
22025
НЕВЕРНАЯ ПОСЛЕДОВАТЕЛЬНОСТЬ СИМВОЛОВ
22P06
НЕСТАНДАРТНОЕ ИСПОЛЬЗОВАНИЕ УПРАВЛЯЮЩЕГО СИМВОЛА
22010
НЕДОПУСТИМОЕ ЗНАЧЕНИЕ ПАРАМЕТРА ИНДИКАТОРА
22020
НЕДОПУСТИМОЕ ПРЕДЕЛЬНОЕ ЗНАЧЕНИЕ
22023
НЕВЕРНОЕ РЕГУЛЯРНОЕ ВЫРАЖЕНИЕ
22009
НЕДОПУСТИМОЕ ЗНАЧЕНИЕ СМЕЩЕНИЯ ЧАСОВОГО ПОЯСА
2200C
НЕКОРРЕКТНОЕ ИСПОЛЬЗОВАНИЕ УПРАВЛЯЮЩЕГО СИМВОЛА
2200G
НАИБОЛЕЕ СПЕЦИФИЧЕСКОЕ НЕСООТВЕТСТВИЕ ТИПОВ
22004
НУЛЕВОЕ ЗНАЧЕНИЕ НЕТ ПАРАМЕТРА ИНДИКАТОРА
22003
ЧИСЛОВОЕ ЗНАЧЕНИЕ ВНЕ ДИАПАЗОНА
22026
НЕСООТВЕТСТВИЕ ДЛИНЫ СТРОКОВЫХ ДАННЫХ
22001
УСЕЧЕНИЕ СТРОКОВЫХ ДАННЫХ СПРАВА
22011
НЕЗАВЕРШЕННАЯ СТРОКА C
2200F
СТРОКА СИМВОЛОВ НУЛЕВОЙ ДЛИНЫ
22P01
ИСКЛЮЧЕНИЕ ПЛАВАЮЩЕЙ ТОЧКИ
22P02
НЕКОРРЕКТНОЕ ПРЕДСТАВЛЕНИЕ ТЕКСТА
22P03
НЕКОРРЕКТНОЕ ДВОИЧНОЕ ПРЕДСТАВЛЕНИЕ
22P04
НЕПРАВИЛЬНЫЙ ФОРМАТ ФАЙЛА КОПИИ
22P05
ПРЕВЫШЕН ЛИМИТ ПРОГРАММЫ
54001
СЛИШКОМ СЛОЖНОЕ УТВЕРЖДЕНИЕ
54011
СЛИШКОМ МНОГО СТОЛБЦОВ
54023
СЛИШКОМ МНОГО АРГУМЕНТОВ
Класс 25 — Неверное состояние транзакции
НЕДЕЙСТВИТЕЛЬНОЕ СОСТОЯНИЕ ТРАНЗАКЦИИ
25001
АКТИВНАЯ SQL ТРАНЗАКЦИЯ
25002
ТРАНЗАКЦИЯ ОТДЕЛЕНИЯ УЖЕ АКТИВНА
25008
УДЕРЖИВАЕМЫЙ КУРСОР ТРЕБУЕТ ОДИНАКОВОГО УРОВНЯ ИЗОЛЯЦИИ
25003
НЕСООТВЕТСТВУЮЩИЙ РЕЖИМ ДОСТУПА ДЛЯ ТРАНЗАКЦИИ ВЕТВЛЕНИЯ
25004
НЕСООТВЕТСТВУЮЩИЙ УРОВЕНЬ ИЗОЛЯЦИИ ДЛЯ ТРАНЗАКЦИИ ФИЛИАЛА
25005
НЕТ АКТИВНОЙ SQL-ТРАНЗАКЦИИ ДЛЯ ТРАНЗАКЦИИ ФИЛИАЛА
25006
SQL-ТРАНЗАКЦИЯ ТОЛЬКО ДЛЯ ЧТЕНИЯ
25007
СМЕШИВАНИЕ СХЕМЫ И ОПЕРАТОРА ДАННЫХ НЕ ПОДДЕРЖИВАЕТСЯ
25P01
НЕТ АКТИВНОЙ SQL ТРАНЗАКЦИИ
25P02
В НЕУДАЧНОЙ ТРАНЗАКЦИИ SQL
Класс 0F — Исключение локатора
НЕДЕЙСТВИТЕЛЬНАЯ СПЕЦИФИКАЦИЯ ЛОКАТОРА
Класс 09 — Спровоцированное исключение действия
ИСКЛЮЧЕНИЕ СРАБОТАВШЕГО ДЕЙСТВИЯ
Класс F0 — Ошибка файла конфигурации
ОШИБКА ФАЙЛА КОНФИГУРАЦИИ
F0001
СУЩЕСТВУЕТ ФАЙЛ БЛОКИРОВКИ
Класс 2D — Некорректное завершение транзакции
НЕКОРРЕКТНОЕ ЗАВЕРШЕНИЕ ТРАНЗАКЦИИ
Класс 00 — Успешное завершение
НЕДОПУСТИМОЕ СОСТОЯНИЕ КУРСОРА
Класс 0L — Неверный грантодатель
НЕДОПУСТИМАЯ ОПЕРАЦИЯ ГРАНТА
Класс 2F — Исключение SQL-маршрута
ФУНКЦИЯ ВЫПОЛНЕНА НЕТ ЗАЯВЛЕНИЯ О ВОЗВРАТЕ
2F002
МОДИФИКАЦИЯ ДАННЫХ SQL ЗАПРЕЩЕНА
2F003
ПОПЫТКА ЗАПРЕЩЕННОГО SQL-ОПЕРАТОРА
2F004
ЧТЕНИЕ SQL-ДАННЫХ ЗАПРЕЩЕНО
Класс 3F — Неверное имя схемы
НЕКОРРЕКТНОЕ ИМЯ СХЕМЫ
53000
НЕДОСТАТОЧНОЕ КОЛИЧЕСТВО РЕСУРСОВ
53100
СЛИШКОМ МНОГО СОЕДИНЕНИЙ
Класс 0P — Неверная спецификация роли
НЕДОПУСТИМАЯ СПЕЦИФИКАЦИЯ РОЛИ
Result Code Meanings
The meanings for all 105
result code values are shown below,
in numeric order.
(0) SQLITE_OK
The SQLITE_OK result code means that the operation was successful and
that there were no errors. Most other result codes indicate an error.
The SQLITE_ERROR result code is a generic error code that is used when
no other more specific error code is available.
(2) SQLITE_INTERNAL
The SQLITE_INTERNAL result code indicates an internal malfunction.
In a working version of SQLite, an application should never see this
result code. If application does encounter this result code, it shows
that there is a bug in the database engine.
SQLite does not currently generate this result code.
However, application-defined SQL functions or
virtual tables, or VFSes, or other extensions might cause this
result code to be returned.
(3) SQLITE_PERM
The SQLITE_PERM result code indicates that the requested access mode
for a newly created database could not be provided.
(4) SQLITE_ABORT
The SQLITE_ABORT result code indicates that an operation was aborted
prior to completion, usually be application request.
See also: SQLITE_INTERRUPT.
If the callback function to sqlite3_exec() returns non-zero, then
sqlite3_exec() will return SQLITE_ABORT.
If a ROLLBACK operation occurs on the same database connection as
a pending read or write, then the pending read or write may fail with
an SQLITE_ABORT or SQLITE_ABORT_ROLLBACK error.
In addition to being a result code,
the SQLITE_ABORT value is also used as a conflict resolution mode
returned from the sqlite3_vtab_on_conflict() interface.
(5) SQLITE_BUSY
The SQLITE_BUSY result code indicates that the database file could not
be written (or in some cases read) because of concurrent activity by
some other database connection, usually a database connection in a
separate process.
For example, if process A is in the middle of a large write transaction
and at the same time process B attempts to start a new write transaction,
process B will get back an SQLITE_BUSY result because SQLite only supports
one writer at a time. Process B will need to wait for process A to finish
its transaction before starting a new transaction. The
sqlite3_busy_timeout() and sqlite3_busy_handler() interfaces and
the busy_timeout pragma are available to process B to help it deal
with SQLITE_BUSY errors.
An SQLITE_BUSY error can occur at any point in a transaction: when the
transaction is first started, during any write or update operations, or
when the transaction commits.
To avoid encountering SQLITE_BUSY errors in the middle of a transaction,
the application can use BEGIN IMMEDIATE instead of just BEGIN to
start a transaction. The BEGIN IMMEDIATE command might itself return
SQLITE_BUSY, but if it succeeds, then SQLite guarantees that no
subsequent operations on the same database through the next COMMIT
will return SQLITE_BUSY.
See also: SQLITE_BUSY_RECOVERY and SQLITE_BUSY_SNAPSHOT.
(6) SQLITE_LOCKED
For example, a DROP TABLE statement cannot be run while another thread
is reading from that table on the same database connection because
dropping the table would delete the table out from under the concurrent
reader.
(7) SQLITE_NOMEM
The SQLITE_NOMEM result code indicates that SQLite was unable to allocate
all the memory it needed to complete the operation. In other words, an
internal call to sqlite3_malloc() or sqlite3_realloc() has failed in
a case where the memory being allocated was required in order to continue
the operation.
(8) SQLITE_READONLY
The SQLITE_READONLY result code is returned when an attempt is made to
alter some data for which the current database connection does not have
write permission.
(9) SQLITE_INTERRUPT
The SQLITE_INTERRUPT result code indicates that an operation was
interrupted by the sqlite3_interrupt() interface.
See also: SQLITE_ABORT
(10) SQLITE_IOERR
The SQLITE_IOERR result code says that the operation could not finish
because the operating system reported an I/O error.
A full disk drive will normally give an SQLITE_FULL error rather than
an SQLITE_IOERR error.
There are many different extended result codes for I/O errors that
identify the specific I/O operation that failed.
(11) SQLITE_CORRUPT
The SQLITE_CORRUPT result code indicates that the database file has
been corrupted. See the How To Corrupt Your Database Files for
further discussion on how corruption can occur.
(12) SQLITE_NOTFOUND
The SQLITE_NOTFOUND result code is exposed in three ways:
The SQLITE_NOTFOUND result code is also used
internally by the SQLite implementation, but those internal uses are
not exposed to the application.
(13) SQLITE_FULL
The SQLITE_FULL result code indicates that a write could not complete
because the disk is full. Note that this error can occur when trying
to write information into the main database file, or it can also
occur when writing into temporary disk files.
Sometimes applications encounter this error even though there is an
abundance of primary disk space because the error occurs when writing
into temporary disk files on a system where temporary files are stored
on a separate partition with much less space that the primary disk.
(14) SQLITE_CANTOPEN
The SQLITE_CANTOPEN result code indicates that SQLite was unable to
open a file. The file in question might be a primary database file
or one of several temporary disk files.
(15) SQLITE_PROTOCOL
The SQLITE_PROTOCOL result code indicates a problem with the file locking
protocol used by SQLite. The SQLITE_PROTOCOL error is currently only
returned when using WAL mode and attempting to start a new transaction.
There is a race condition that can occur when two separate
database connections both try to start a transaction at the same time
in WAL mode. The loser of the race backs off and tries again, after
a brief delay. If the same connection loses the locking race dozens
of times over a span of multiple seconds, it will eventually give up and
return SQLITE_PROTOCOL. The SQLITE_PROTOCOL error should appear in practice
very, very rarely, and only when there are many separate processes all
competing intensely to write to the same database.
(16) SQLITE_EMPTY
The SQLITE_EMPTY result code is not currently used.
(17) SQLITE_SCHEMA
The SQLITE_SCHEMA result code indicates that the database schema
has changed. This result code can be returned from sqlite3_step() for
a prepared statement that was generated using sqlite3_prepare() or
sqlite3_prepare16(). If the database schema was changed by some other
process in between the time that the statement was prepared and the time
the statement was run, this error can result.
If a prepared statement is generated from sqlite3_prepare_v2() then
the statement is automatically re-prepared if the schema changes, up to
SQLITE_MAX_SCHEMA_RETRY times (default: 50). The sqlite3_step()
interface will only return SQLITE_SCHEMA back to the application if
the failure persists after these many retries.
(18) SQLITE_TOOBIG
The SQLITE_CONSTRAINT error code means that an SQL constraint violation
occurred while trying to process an SQL statement. Additional information
about the failed constraint can be found by consulting the
accompanying error message (returned via sqlite3_errmsg() or
sqlite3_errmsg16()) or by looking at the extended error code.
The SQLITE_CONSTRAINT code can also be used as the return value from
the xBestIndex() method of a virtual table implementation. When
xBestIndex() returns SQLITE_CONSTRAINT, that indicates that the particular
combination of inputs submitted to xBestIndex() cannot result in a
usable query plan and should not be given further consideration.
(20) SQLITE_MISMATCH
The SQLITE_MISMATCH error code indicates a datatype mismatch.
SQLite is normally very forgiving about mismatches between the type of
a value and the declared type of the container in which that value is
to be stored. For example, SQLite allows the application to store
a large BLOB in a column with a declared type of BOOLEAN. But in a few
cases, SQLite is strict about types. The SQLITE_MISMATCH error is
returned in those few cases when the types do not match.
The rowid of a table must be an integer. Attempt to set the rowid
to anything other than an integer (or a NULL which will be automatically
converted into the next available integer rowid) results in an
SQLITE_MISMATCH error.
(21) SQLITE_MISUSE
The SQLITE_MISUSE return code might be returned if the application uses
any SQLite interface in a way that is undefined or unsupported. For
example, using a prepared statement after that prepared statement has
been finalized might result in an SQLITE_MISUSE error.
SQLite tries to detect misuse and report the misuse using this result code.
However, there is no guarantee that the detection of misuse will be
successful. Misuse detection is probabilistic. Applications should
never depend on an SQLITE_MISUSE return value.
If SQLite ever returns SQLITE_MISUSE from any interface, that means that
the application is incorrectly coded and needs to be fixed. Do not ship
an application that sometimes returns SQLITE_MISUSE from a standard
SQLite interface because that application contains potentially serious bugs.
(22) SQLITE_NOLFS
The SQLITE_NOLFS error can be returned on systems that do not support
large files when the database grows to be larger than what the filesystem
can handle. “NOLFS” stands for “NO Large File Support”.
(23) SQLITE_AUTH
The SQLITE_AUTH error is returned when the
authorizer callback indicates that an
SQL statement being prepared is not authorized.
(24) SQLITE_FORMAT
The SQLITE_FORMAT error code is not currently used by SQLite.
(25) SQLITE_RANGE
The SQLITE_RANGE error indices that the parameter number argument
to one of the sqlite3_bind routines or the
column number in one of the sqlite3_column
routines is out of range.
(26) SQLITE_NOTADB
When attempting to open a file, the SQLITE_NOTADB error indicates that
the file being opened does not appear to be an SQLite database file.
(27) SQLITE_NOTICE
The SQLITE_NOTICE result code is not returned by any C/C++ interface.
However, SQLITE_NOTICE (or rather one of its extended error codes)
is sometimes used as the first argument in an sqlite3_log() callback
to indicate that an unusual operation is taking place.
(28) SQLITE_WARNING
The SQLITE_WARNING result code is not returned by any C/C++ interface.
However, SQLITE_WARNING (or rather one of its extended error codes)
is sometimes used as the first argument in an sqlite3_log() callback
to indicate that an unusual and possibly ill-advised operation is
taking place.
(100) SQLITE_ROW
The SQLITE_ROW result code returned by
sqlite3_step() indicates that another row of output is available.
(101) SQLITE_DONE
The SQLITE_DONE result code indicates that an operation has completed.
The SQLITE_DONE result code is most commonly seen as a return value
from sqlite3_step() indicating that the SQL statement has run to
completion. But SQLITE_DONE can also be returned by other multi-step
interfaces such as sqlite3_backup_step().
(256) SQLITE_OK_LOAD_PERMANENTLY
The sqlite3_load_extension() interface loads an
extension into a single
database connection. The default behavior is for that extension to be
automatically unloaded when the database connection closes. However,
if the extension entry point returns SQLITE_OK_LOAD_PERMANENTLY instead
of SQLITE_OK, then the extension remains loaded into the process address
space after the database connection closes. In other words, the
xDlClose methods of the sqlite3_vfs object is not called for the
extension when the database connection closes.
The SQLITE_OK_LOAD_PERMANENTLY return code is useful to
loadable extensions that register new VFSes, for example.
The SQLITE_ERROR_MISSING_COLLSEQ result code means that an SQL
statement could not be prepared because a collating sequence named
in that SQL statement could not be located.
Sometimes when this error code is encountered, the
sqlite3_prepare_v2() routine will convert the error into
SQLITE_ERROR_RETRY and try again to prepare the SQL statement
using a different query plan that does not require the use of
the unknown collating sequence.
(261) SQLITE_BUSY_RECOVERY
The SQLITE_READONLY_RECOVERY error code is an extended error code
for SQLITE_READONLY. The SQLITE_READONLY_RECOVERY error code indicates
that a WAL mode database cannot be opened because the database file
needs to be recovered and recovery requires write access but only
read access is available.
(266) SQLITE_IOERR_READ
The SQLITE_IOERR_READ error code is an extended error code
for SQLITE_IOERR indicating an I/O error in the VFS layer
while trying to read from a file on disk. This error might result
from a hardware malfunction or because a filesystem came unmounted
while the file was open.
(267) SQLITE_CORRUPT_VTAB
The SQLITE_CORRUPT_VTAB error code is an extended error code
for SQLITE_CORRUPT used by virtual tables. A virtual table might
return SQLITE_CORRUPT_VTAB to indicate that content in the virtual table
is corrupt.
(270) SQLITE_CANTOPEN_NOTEMPDIR
The SQLITE_CANTOPEN_NOTEMPDIR error code is no longer used.
(275) SQLITE_CONSTRAINT_CHECK
The SQLITE_CONSTRAINT_CHECK error code is an extended error code
for SQLITE_CONSTRAINT indicating that a CHECK constraint failed.
(279) SQLITE_AUTH_USER
The SQLITE_NOTICE_RECOVER_WAL result code is
passed to the callback of
sqlite3_log() when a WAL mode database file is recovered.
(284) SQLITE_WARNING_AUTOINDEX
The SQLITE_WARNING_AUTOINDEX result code is
passed to the callback of
sqlite3_log() whenever automatic indexing is used.
This can serve as a warning to application designers that the
database might benefit from additional indexes.
The SQLITE_ERROR_RETRY is used internally to provoke sqlite3_prepare_v2()
(or one of its sibling routines for creating prepared statements) to
try again to prepare a statement that failed with an error on the
previous attempt.
(516) SQLITE_ABORT_ROLLBACK
The SQLITE_ABORT_ROLLBACK error code is an extended error code
for SQLITE_ABORT indicating that an SQL statement aborted because
the transaction that was active when the SQL statement first started
was rolled back. Pending write operations always fail with this error
when a rollback occurs. A ROLLBACK will cause a pending read operation
to fail only if the schema was changed within the transaction being rolled
back.
(517) SQLITE_BUSY_SNAPSHOT
The SQLITE_BUSY_SNAPSHOT error code is an extended error code
for SQLITE_BUSY that occurs on WAL mode databases when a database
connection tries to promote a read transaction into a write transaction
but finds that another database connection has already written to the
database and thus invalidated prior reads.
(518) SQLITE_LOCKED_VTAB
The SQLITE_LOCKED_VTAB result code is not used by the SQLite core, but
it is available for use by extensions. Virtual table implementations
can return this result code to indicate that they cannot complete the
current operation because of locks held by other threads or processes.
The R-Tree extension returns this result code when an attempt is made
to update the R-Tree while another prepared statement is actively reading
the R-Tree. The update cannot proceed because any change to an R-Tree
might involve reshuffling and rebalancing of nodes, which would disrupt
read cursors, causing some rows to be repeated and other rows to be
omitted.
(520) SQLITE_READONLY_CANTLOCK
The SQLITE_IOERR_SHORT_READ error code is an extended error code
for SQLITE_IOERR indicating that a read attempt in the VFS layer
was unable to obtain as many bytes as was requested. This might be
due to a truncated file.
(523) SQLITE_CORRUPT_SEQUENCE
CREATE TABLE sqlite_sequence(name,seq);
If SQLite discovers that the sqlite_sequence table has any other
format, it returns the SQLITE_CORRUPT_SEQUENCE error.
(526) SQLITE_CANTOPEN_ISDIR
The SQLITE_CANTOPEN_ISDIR error code is an extended error code
for SQLITE_CANTOPEN indicating that a file open operation failed because
the file is really a directory.
(531) SQLITE_CONSTRAINT_COMMITHOOK
The SQLITE_CONSTRAINT_COMMITHOOK error code
is an extended error code
for SQLITE_CONSTRAINT indicating that a
commit hook callback returned non-zero that thus
caused the SQL statement to be rolled back.
(539) SQLITE_NOTICE_RECOVER_ROLLBACK
The SQLITE_NOTICE_RECOVER_ROLLBACK result code is
passed to the callback of
sqlite3_log() when a hot journal is rolled back.
The SQLITE_ERROR_SNAPSHOT result code might be returned when attempting
to start a read transaction on an historical version of the database
by using the sqlite3_snapshot_open() interface. If the historical
snapshot is no longer available, then the read transaction will fail
with the SQLITE_ERROR_SNAPSHOT. This error code is only possible if
SQLite is compiled with -DSQLITE_ENABLE_SNAPSHOT.
(773) SQLITE_BUSY_TIMEOUT
The SQLITE_READONLY_ROLLBACK error code is an extended error code
for SQLITE_READONLY. The SQLITE_READONLY_ROLLBACK error code indicates
that a database cannot be opened because it has a hot journal that
needs to be rolled back but cannot because the database is readonly.
(778) SQLITE_IOERR_WRITE
The SQLITE_IOERR_WRITE error code is an extended error code
for SQLITE_IOERR indicating an I/O error in the VFS layer
while trying to write into a file on disk. This error might result
from a hardware malfunction or because a filesystem came unmounted
while the file was open. This error should not occur if the filesystem
is full as there is a separate error code (SQLITE_FULL) for that purpose.
(779) SQLITE_CORRUPT_INDEX
The SQLITE_CORRUPT_INDEX result code means that SQLite detected
an entry is or was missing from an index. This is a special case of
the SQLITE_CORRUPT error code that suggests that the problem might
be resolved by running the REINDEX command, assuming no other
problems exist elsewhere in the database file.
(782) SQLITE_CANTOPEN_FULLPATH
The SQLITE_CANTOPEN_FULLPATH error code is an extended error code
for SQLITE_CANTOPEN indicating that a file open operation failed because
the operating system was unable to convert the filename into a full pathname.
(787) SQLITE_CONSTRAINT_FOREIGNKEY
The SQLITE_CONSTRAINT_FOREIGNKEY error code
is an extended error code
for SQLITE_CONSTRAINT indicating that a foreign key constraint failed.
(1032) SQLITE_READONLY_DBMOVED
The SQLITE_READONLY_DBMOVED error code is an extended error code
for SQLITE_READONLY. The SQLITE_READONLY_DBMOVED error code indicates
that a database cannot be modified because the database file has been
moved since it was opened, and so any attempt to modify the database
might result in database corruption if the processes crashes because the
rollback journal would not be correctly named.
(1034) SQLITE_IOERR_FSYNC
The SQLITE_IOERR_FSYNC error code is an extended error code
for SQLITE_IOERR indicating an I/O error in the VFS layer
while trying to flush previously written content out of OS and/or
disk-control buffers and into persistent storage. In other words,
this code indicates a problem with the fsync() system call in unix
or the FlushFileBuffers() system call in windows.
(1038) SQLITE_CANTOPEN_CONVPATH
The SQLITE_CANTOPEN_CONVPATH error code is an extended error code
for SQLITE_CANTOPEN used only by Cygwin VFS and indicating that
the cygwin_conv_path() system call failed while trying to open a file.
See also: SQLITE_IOERR_CONVPATH
(1043) SQLITE_CONSTRAINT_FUNCTION
The SQLITE_CONSTRAINT_FUNCTION error code is not currently used
by the SQLite core. However, this error code is available for use
by extension functions.
(1288) SQLITE_READONLY_CANTINIT
The SQLITE_CANTOPEN_DIRTYWAL result code is not used at this time.
(1299) SQLITE_CONSTRAINT_NOTNULL
The SQLITE_CONSTRAINT_NOTNULL error code
is an extended error code
for SQLITE_CONSTRAINT indicating that a NOT NULL constraint failed.
(1544) SQLITE_READONLY_DIRECTORY
The SQLITE_READONLY_DIRECTORY result code indicates that the database
is read-only because process does not have permission to create
a journal file in the same directory as the database and the creation of
a journal file is a prerequisite for writing.
(1546) SQLITE_IOERR_TRUNCATE
The SQLITE_IOERR_TRUNCATE error code is an extended error code
for SQLITE_IOERR indicating an I/O error in the VFS layer
while trying to truncate a file to a smaller size.
(1550) SQLITE_CANTOPEN_SYMLINK
The SQLITE_CONSTRAINT_PRIMARYKEY error code
is an extended error code
for SQLITE_CONSTRAINT indicating that a PRIMARY KEY constraint failed.
(1802) SQLITE_IOERR_FSTAT
The SQLITE_IOERR_FSTAT error code is an extended error code
for SQLITE_IOERR indicating an I/O error in the VFS layer
while trying to invoke fstat() (or the equivalent) on a file in order
to determine information such as the file size or access permissions.
(1811) SQLITE_CONSTRAINT_TRIGGER
The SQLITE_CONSTRAINT_TRIGGER error code
is an extended error code
for SQLITE_CONSTRAINT indicating that a RAISE function within
a trigger fired, causing the SQL statement to abort.
(2058) SQLITE_IOERR_UNLOCK
The SQLITE_IOERR_UNLOCK error code is an extended error code
for SQLITE_IOERR indicating an I/O error
within xUnlock method on the sqlite3_io_methods object.
(2067) SQLITE_CONSTRAINT_UNIQUE
The SQLITE_CONSTRAINT_UNIQUE error code
is an extended error code
for SQLITE_CONSTRAINT indicating that a UNIQUE constraint failed.
(2314) SQLITE_IOERR_RDLOCK
The SQLITE_IOERR_UNLOCK error code is an extended error code
for SQLITE_IOERR indicating an I/O error
within xLock method on the sqlite3_io_methods object while trying
to obtain a read lock.
(2323) SQLITE_CONSTRAINT_VTAB
The SQLITE_CONSTRAINT_VTAB error code is not currently used
by the SQLite core. However, this error code is available for use
by application-defined virtual tables.
(2570) SQLITE_IOERR_DELETE
The SQLITE_IOERR_UNLOCK error code is an extended error code
for SQLITE_IOERR indicating an I/O error
within xDelete method on the sqlite3_vfs object.
(2579) SQLITE_CONSTRAINT_ROWID
The SQLITE_CONSTRAINT_ROWID error code
is an extended error code
for SQLITE_CONSTRAINT indicating that a rowid is not unique.
(2826) SQLITE_IOERR_BLOCKED
The SQLITE_CONSTRAINT_PINNED error code
is an extended error code
for SQLITE_CONSTRAINT indicating that an UPDATE trigger attempted
do delete the row that was being updated in the middle of the update.
(3082) SQLITE_IOERR_NOMEM
The SQLITE_IOERR_NOMEM error code is sometimes returned by the VFS
layer to indicate that an operation could not be completed due to the
inability to allocate sufficient memory. This error code is normally
converted into SQLITE_NOMEM by the higher layers of SQLite before
being returned to the application.
(3091) SQLITE_CONSTRAINT_DATATYPE
The SQLITE_CONSTRAINT_DATATYPE error code
is an extended error code
for SQLITE_CONSTRAINT indicating that an insert or update attempted
to store a value inconsistent with the column’s declared type
in a table defined as STRICT.
The SQLITE_IOERR_ACCESS error code is an extended error code
for SQLITE_IOERR indicating an I/O error
within the xAccess method on the sqlite3_vfs object.
(3594) SQLITE_IOERR_CHECKRESERVEDLOCK
The SQLITE_IOERR_CHECKRESERVEDLOCK error code is
an extended error code
for SQLITE_IOERR indicating an I/O error
within the xCheckReservedLock method on the sqlite3_io_methods object.
(3850) SQLITE_IOERR_LOCK
The SQLITE_IOERR_LOCK error code is an extended error code
for SQLITE_IOERR indicating an I/O error in the
advisory file locking logic.
Usually an SQLITE_IOERR_LOCK error indicates a problem obtaining
a PENDING lock. However it can also indicate miscellaneous
locking errors on some of the specialized VFSes used on Macs.
(4106) SQLITE_IOERR_CLOSE
The SQLITE_IOERR_ACCESS error code is an extended error code
for SQLITE_IOERR indicating an I/O error
within the xClose method on the sqlite3_io_methods object.
(4362) SQLITE_IOERR_DIR_CLOSE
The SQLITE_IOERR_DIR_CLOSE error code is no longer used.
(4618) SQLITE_IOERR_SHMOPEN
The SQLITE_IOERR_SHMSIZE error code is an extended error code
for SQLITE_IOERR indicating an I/O error
within the xShmMap method on the sqlite3_io_methods object
while trying to enlarge a “shm” file as part of
WAL mode transaction processing. This error may indicate that
the underlying filesystem volume is out of space.
(5130) SQLITE_IOERR_SHMLOCK
The SQLITE_IOERR_SHMLOCK error code is no longer used.
(5386) SQLITE_IOERR_SHMMAP
The SQLITE_IOERR_SEEK error code is an extended error code
for SQLITE_IOERR indicating an I/O error
within the xRead or xWrite methods on the sqlite3_io_methods object
while trying to seek a file descriptor to the beginning point of the
file where the read or write is to occur.
(5898) SQLITE_IOERR_DELETE_NOENT
The SQLITE_IOERR_DELETE_NOENT error code
is an extended error code
for SQLITE_IOERR indicating that the
xDelete method on the sqlite3_vfs object failed because the
file being deleted does not exist.
(6154) SQLITE_IOERR_MMAP
The SQLITE_IOERR_MMAP error code is an extended error code
for SQLITE_IOERR indicating an I/O error
within the xFetch or xUnfetch methods on the sqlite3_io_methods object
while trying to map or unmap part of the database file into the
process address space.
(6410) SQLITE_IOERR_GETTEMPPATH
The SQLITE_IOERR_GETTEMPPATH error code is an extended error code
for SQLITE_IOERR indicating that the VFS is unable to determine
a suitable directory in which to place temporary files.
(6666) SQLITE_IOERR_CONVPATH
The SQLITE_IOERR_CONVPATH error code is an extended error code
for SQLITE_IOERR used only by Cygwin VFS and indicating that
the cygwin_conv_path() system call failed.
See also: SQLITE_CANTOPEN_CONVPATH
(6922) SQLITE_IOERR_VNODE
The SQLITE_IOERR_VNODE error code is a code reserved for use
by extensions. It is not used by the SQLite core.
(7178) SQLITE_IOERR_AUTH
The SQLITE_IOERR_AUTH error code is a code reserved for use
by extensions. It is not used by the SQLite core.
(7434) SQLITE_IOERR_BEGIN_ATOMIC
The SQLITE_IOERR_BEGIN_ATOMIC error code indicates that the
underlying operating system reported and error on the
SQLITE_FCNTL_BEGIN_ATOMIC_WRITE file-control. This only comes
up when SQLITE_ENABLE_ATOMIC_WRITE is enabled and the database
is hosted on a filesystem that supports atomic writes.
(7690) SQLITE_IOERR_COMMIT_ATOMIC
The SQLITE_IOERR_COMMIT_ATOMIC error code indicates that the
underlying operating system reported and error on the
SQLITE_FCNTL_COMMIT_ATOMIC_WRITE file-control. This only comes
up when SQLITE_ENABLE_ATOMIC_WRITE is enabled and the database
is hosted on a filesystem that supports atomic writes.
(7946) SQLITE_IOERR_ROLLBACK_ATOMIC
The SQLITE_IOERR_ROLLBACK_ATOMIC error code indicates that the
underlying operating system reported and error on the
SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE file-control. This only comes
up when SQLITE_ENABLE_ATOMIC_WRITE is enabled and the database
is hosted on a filesystem that supports atomic writes.
(8202) SQLITE_IOERR_DATA
The SQLITE_IOERR_DATA error code is an extended error code
for SQLITE_IOERR used only by checksum VFS shim to indicate that
the checksum on a page of the database file is incorrect.
(8458) SQLITE_IOERR_CORRUPTFS
The SQLITE_IOERR_CORRUPTFS error code is an extended error code
for SQLITE_IOERR used only by a VFS to indicate that a seek or read
failure was due to the request not falling within the file’s boundary
rather than an ordinary device failure. This often indicates a
corrupt filesystem.
This page last modified on 2023-03-31 19:57:15 UTC
Primary Result Codes versus Extended Result Codes
Result codes are signed 32-bit integers.
The least significant 8 bits of the result code define a broad category
and are called the “primary result code”. More significant bits provide
more detailed information about the error and are called the
“extended result code”
Note that the primary result code is always a part of the extended
result code. Given a full 32-bit extended result code, the application
can always find the corresponding primary result code merely by extracting
the least significant 8 bits of the extended result code.
All extended result codes are also error codes. Hence the terms
“extended result code” and “extended error code” are interchangeable.
For historic compatibility, the C-language interfaces return
primary result codes by default.
The extended result code for the most recent error can be
retrieved using the sqlite3_extended_errcode() interface.
The sqlite3_extended_result_codes() interface can be used to put
a database connection into a mode where it returns the
extended result codes instead of the primary result codes.
Definitions
All result codes are integers.
Symbolic names for all result codes are created using
“#define” macros in the sqlite3.h header file.
There are separate sections in the sqlite3.h header file for
the result code definitions and the extended result code definitions.
Primary result code symbolic names are of the form “SQLITE_XXXXXX” where
XXXXXX is a sequence of uppercase alphabetic characters. Extended
result code names are of the form “SQLITE_XXXXXX_YYYYYYY” where
the XXXXXX part is the corresponding primary result code and the
YYYYYYY is an extension that further classifies the result code.
The names and numeric values for existing result codes are fixed
and unchanging. However, new result codes, and especially new extended
result codes, might appear in future releases of SQLite.
Extended Result Code List
The 74 extended result codes
are defined in sqlite3.h and are
listed in alphabetical order below:
Primary Result Code List
The 31 result codes are
defined in sqlite3.h and are listed in
alphabetical order below:
Класс 28 — Неверная спецификация авторизации
НЕДОПУСТИМАЯ СПЕЦИФИКАЦИЯ АВТОРИЗАЦИИ