|
1 | 1 | -----------------------------------------------------------------------
|
2 | 2 | -- ADO Sqlite Database -- SQLite Database connections
|
3 |
| --- Copyright (C) 2009, 2010, 2011, 2012, 2015, 2017, 2018, 2019 Stephane Carrez |
| 3 | +-- Copyright (C) 2009, 2010, 2011, 2012, 2015, 2017, 2018, 2019, 2022 Stephane Carrez |
4 | 4 | -- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
|
5 | 5 | --
|
6 | 6 | -- Licensed under the Apache License, Version 2.0 (the "License");
|
|
15 | 15 | -- See the License for the specific language governing permissions and
|
16 | 16 | -- limitations under the License.
|
17 | 17 | -----------------------------------------------------------------------
|
| 18 | +with System; |
18 | 19 | with Interfaces.C.Strings;
|
19 | 20 |
|
20 | 21 | with Util.Log;
|
@@ -163,6 +164,17 @@ package body ADO.Connections.Sqlite is
|
163 | 164 | ADO.Schemas.Sqlite.Load_Schema (Database, Schema);
|
164 | 165 | end Load_Schema;
|
165 | 166 |
|
| 167 | + function Busy_Handler (Arg1 : System.Address; |
| 168 | + Count : Interfaces.C.int) |
| 169 | + return Interfaces.C.int with Convention => C; |
| 170 | + |
| 171 | + function Busy_Handler (Arg1 : System.Address; |
| 172 | + Count : Interfaces.C.int) return Interfaces.C.int is |
| 173 | + begin |
| 174 | + delay 0.001; |
| 175 | + return (if Count > 10_000 then 0 else 1); |
| 176 | + end Busy_Handler; |
| 177 | + |
166 | 178 | protected body Sqlite_Connections is
|
167 | 179 |
|
168 | 180 | procedure Open (Config : in Configuration'Class;
|
@@ -271,6 +283,9 @@ package body ADO.Connections.Sqlite is
|
271 | 283 | -- temp_store=MEMORY
|
272 | 284 | -- encoding='UTF-8'
|
273 | 285 | Config.Iterate (Process => Configure'Access);
|
| 286 | + Status := Sqlite3_H.sqlite3_busy_handler (Handle, |
| 287 | + Busy_Handler'Access, |
| 288 | + Database.all'Address); |
274 | 289 | end;
|
275 | 290 | end;
|
276 | 291 | end Open;
|
|
0 commit comments