diff options
| author | Eli Zaretskii | 2025-04-14 12:42:28 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2025-04-14 12:42:28 +0300 |
| commit | 4918de1699152e98c7aaa3ecb21795a3cbd05194 (patch) | |
| tree | d97089e461e0e0f2b1c97824e0b125210756dbfa /src/sqlite.c | |
| parent | f7ca720e2d0aebeabc454a24a600c23fd444b60b (diff) | |
| download | emacs-4918de1699152e98c7aaa3ecb21795a3cbd05194.tar.gz emacs-4918de1699152e98c7aaa3ecb21795a3cbd05194.zip | |
Support file:// URIs and readonly DB in 'sqlite-open'
* src/sqlite.c (Fsqlite_open): Two new optional arguments,
READONLY and DISABLE-URI. Doc fix.
* etc/NEWS:
* doc/lispref/text.texi (Database): Document the new optional
arguments to 'sqlite-open'. (Bug#65274)
Diffstat (limited to 'src/sqlite.c')
| -rw-r--r-- | src/sqlite.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/sqlite.c b/src/sqlite.c index 0de7488d8fd..99f91fd6da6 100644 --- a/src/sqlite.c +++ b/src/sqlite.c | |||
| @@ -277,18 +277,28 @@ check_sqlite (Lisp_Object db, bool is_statement) | |||
| 277 | 277 | ||
| 278 | static int db_count = 0; | 278 | static int db_count = 0; |
| 279 | 279 | ||
| 280 | DEFUN ("sqlite-open", Fsqlite_open, Ssqlite_open, 0, 1, 0, | 280 | DEFUN ("sqlite-open", Fsqlite_open, Ssqlite_open, 0, 3, 0, |
| 281 | doc: /* Open FILE as an sqlite database. | 281 | doc: /* Open FILE as an sqlite database. |
| 282 | If FILE is nil, an in-memory database will be opened instead. */) | 282 | If FILE is nil or omitted, an in-memory database will be opened instead. |
| 283 | (Lisp_Object file) | 283 | If READONLY is non-nil or omitted, open the database in read-only mode, |
| 284 | otherwise open it in read-write mode. | ||
| 285 | By default, file:// URIs are automatically recognized, unless | ||
| 286 | DISABLE-URI is non-nil. */) | ||
| 287 | (Lisp_Object file, Lisp_Object readonly, Lisp_Object disable_uri) | ||
| 284 | { | 288 | { |
| 285 | Lisp_Object name; | 289 | Lisp_Object name; |
| 286 | int flags = (SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE); | 290 | int flags; |
| 291 | |||
| 292 | if (!NILP (readonly)) | ||
| 293 | flags = SQLITE_OPEN_READONLY; | ||
| 294 | else | ||
| 295 | flags = (SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE); | ||
| 287 | #ifdef SQLITE_OPEN_FULLMUTEX | 296 | #ifdef SQLITE_OPEN_FULLMUTEX |
| 288 | flags |= SQLITE_OPEN_FULLMUTEX; | 297 | flags |= SQLITE_OPEN_FULLMUTEX; |
| 289 | #endif | 298 | #endif |
| 290 | #ifdef SQLITE_OPEN_URI | 299 | #ifdef SQLITE_OPEN_URI |
| 291 | flags |= SQLITE_OPEN_URI; | 300 | if (NILP (disable_uri)) |
| 301 | flags |= SQLITE_OPEN_URI; | ||
| 292 | #endif | 302 | #endif |
| 293 | 303 | ||
| 294 | if (!init_sqlite_functions ()) | 304 | if (!init_sqlite_functions ()) |