Skip to content

Commit d995c54

Browse files
authored
Merge pull request #6939 from kenjis/feat-sqlite3-busyTimeout
feat: add SQLite3 Config busyTimeout
2 parents 69d2d81 + 0617d45 commit d995c54

4 files changed

Lines changed: 16 additions & 0 deletions

File tree

app/Config/Database.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class Database extends Config
6767
'failover' => [],
6868
'port' => 3306,
6969
'foreignKeys' => true,
70+
'busyTimeout' => 1000,
7071
];
7172

7273
public function __construct()

system/Database/SQLite3/Connection.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,26 @@ class Connection extends BaseConnection
4545
*/
4646
protected $foreignKeys = false;
4747

48+
/**
49+
* The milliseconds to sleep
50+
*
51+
* @var int|null milliseconds
52+
*
53+
* @see https://www.php.net/manual/en/sqlite3.busytimeout
54+
*/
55+
protected $busyTimeout;
56+
4857
public function initialize()
4958
{
5059
parent::initialize();
5160

5261
if ($this->foreignKeys) {
5362
$this->enableForeignKeyChecks();
5463
}
64+
65+
if (is_int($this->busyTimeout)) {
66+
$this->connID->busyTimeout($this->busyTimeout);
67+
}
5568
}
5669

5770
/**

user_guide_src/source/changelogs/v4.3.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ Forge
225225
Others
226226
------
227227

228+
- SQLite3 has a new Config item ``busyTimeout`` to set timeout when a table is locked.
228229
- ``BaseConnection::escape()`` now excludes the ``RawSql`` data type. This allows passing SQL strings into data.
229230
- Improved data returned by :ref:`BaseConnection::getForeignKeyData() <metadata-getforeignkeydata>`. All DBMS returns the same structure.
230231
- SQLite :ref:`BaseConnection::getIndexData() <db-metadata-getindexdata>` now can return pseudo index named ``PRIMARY`` for `AUTOINCREMENT` column, and each returned index data has ``type`` property.

user_guide_src/source/database/configuration.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ Explanation of Values:
148148
.. important:: SQLite3 Foreign Key constraint is disabled by default.
149149
See `SQLite documentation <https://www.sqlite.org/pragma.html#pragma_foreign_keys>`_.
150150
To enforce Foreign Key constraint, set this config item to true.
151+
**busyTimeout** milliseconds (int) - Sleeps for a specified amount of time when a table is locked (``SQLite3`` only).
151152
=============== ===========================================================================================================
152153

153154
.. note:: Depending on what database driver you are using (``MySQLi``, ``Postgres``,

0 commit comments

Comments
 (0)