Was bedeutet dieser Code?
Code SQLITE_BUSY · Ein von SQLite gemeldetes Problem.
Übersetzte Erklärung
Der Ergebniscode SQLITE_BUSY gibt an, dass die Datenbankdatei aufgrund gleichzeitiger Aktivität einer anderen Datenbankverbindung, normalerweise einer Datenbankverbindung in einem separaten Prozess, nicht geschrieben (oder in einigen Fällen gelesen) werden konnte.
Wenn sich Prozess A beispielsweise mitten in einer großen Schreibtransaktion befindet und Prozess B gleichzeitig versucht, eine neue Schreibtransaktion zu starten, erhält Prozess B ein SQLITE_BUSY-Ergebnis zurück, da SQLite jeweils nur einen Writer unterstützt. Prozess B muss warten, bis Prozess A seine Transaktion abgeschlossen hat, bevor er eine neue Transaktion starten kann. Die Schnittstellen sqlite3_busy_timeout() und sqlite3_busy_handler() sowie das Busy_timeout-Pragma stehen Prozess B zur Verfügung, um ihn bei der Behandlung von SQLITE_BUSY-Fehlern zu unterstützen.
Ein SQLITE_BUSY-Fehler kann zu jedem Zeitpunkt einer Transaktion auftreten: beim ersten Start der Transaktion, bei Schreib- oder Aktualisierungsvorgängen oder beim Commit der Transaktion. Um zu vermeiden, dass mitten in einer Transaktion SQLITE_BUSY-Fehler auftreten, kann die Anwendung BEGIN IMMEDIATE statt nur BEGIN verwenden, um eine Transaktion zu starten. Der Befehl BEGIN IMMEDIATE gibt möglicherweise selbst SQLITE_BUSY zurück, aber wenn er erfolgreich ist, garantiert SQLite, dass keine nachfolgenden Vorgänge in derselben Datenbank bis zum nächsten COMMIT SQLITE_BUSY zurückgeben.
Siehe auch: SQLITE_BUSY_RECOVERY und SQLITE_BUSY_SNAPSHOT.
Der Ergebniscode SQLITE_BUSY unterscheidet sich von SQLITE_LOCKED darin, dass SQLITE_BUSY auf einen Konflikt mit einer separaten Datenbankverbindung hinweist, wahrscheinlich in einem separaten Prozess, während SQLITE_LOCKED auf einen Konflikt innerhalb derselben Datenbankverbindung (oder manchmal einer Datenbankverbindung mit einem gemeinsam genutzten Cache) hinweist.
Google Translate · Dies ist eine automatische Übersetzung. Prüfen Sie Fachbegriffe und anwendbare Bedingungen im englischen Original.
Offizielle Erklärung · Originaltext
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.
The SQLITE_BUSY result code differs from SQLITE_LOCKED in that SQLITE_BUSY indicates a conflict with a separate database connection, probably in a separate process, whereas SQLITE_LOCKED indicates a conflict within the same database connection (or sometimes a database connection with a shared cache).