[exim-cvs] sqlite hintsdb: safer create of table

Página Inicial
Delete this message
Reply to this message
Autor: Exim Git Commits Mailing List
Data:  
Para: exim-cvs
Assunto: [exim-cvs] sqlite hintsdb: safer create of table
Gitweb: https://git.exim.org/exim.git/commitdiff/50589c35f57a4b9465ad7041db7d5cd67c52d72b
Commit:     50589c35f57a4b9465ad7041db7d5cd67c52d72b
Parent:     1145b1aea70658de9f7f85b03772bc06408c027a
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Fri Jun 7 20:12:27 2024 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Fri Jun 7 20:12:27 2024 +0100


    sqlite hintsdb: safer create of table
---
 src/src/dbfn.c    | 2 ++
 src/src/hintsdb.h | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)


diff --git a/src/src/dbfn.c b/src/src/dbfn.c
index 6b2027aa9..5f30ccf58 100644
--- a/src/src/dbfn.c
+++ b/src/src/dbfn.c
@@ -67,6 +67,8 @@ Arguments:
   name     The single-component name of one of Exim's database files.
   flags    Either O_RDONLY or O_RDWR, indicating the type of open required;
              O_RDWR implies "create if necessary"
+XXX this is a mess.  hintsdb.h has grown lots of code expecting O_CREAT
+XXX with the obvious semantics, and not that described above.
   dbblock  Points to an open_db block to be filled in.
   lof      If TRUE, write to the log for actual open failures (locking failures
            are always logged).
diff --git a/src/src/hintsdb.h b/src/src/hintsdb.h
index 545c83dbd..17b5c243c 100644
--- a/src/src/hintsdb.h
+++ b/src/src/hintsdb.h
@@ -87,7 +87,8 @@ if ((ret = sqlite3_open_v2(CCS name, &dbp, sflags, NULL)) == SQLITE_OK)
   sqlite3_busy_timeout(dbp, 5000);
   if (flags & O_CREAT)
     ret == sqlite3_exec(dbp,
-        "CREATE TABLE tbl (ky TEXT PRIMARY KEY, dat BLOB);", NULL, NULL, NULL);
+        "CREATE TABLE IF NOT EXISTS tbl (ky TEXT PRIMARY KEY, dat BLOB);",
+        NULL, NULL, NULL);
   }
 //else
 //  fprintf(stderr, "sqlite3_open_v2: %s\n", sqlite3_errmsg(dbp));


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-cvs.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-cvs-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/