Place in the code where can understand that the file was created
(1) By Sten (SicSten) on 2021-05-11 15:50:04 [link] [source]
Hello! Tell me, in which line of the source code of the sqlite3.c file, you can clearly understand that a new database file has been created int res = sqlite3_open_v2( “D:\\MyNewDB.db”, /* Database filename (UTF-8) */ &db_handle, /* OUT: SQLite db handle */ SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE|SQLITE_OPEN_FULLMUTEX, /* Flags */ NULL /* Name of VFS module to use */ ); Prompt the line number or a piece of code from sqlite3.c where i can clearly understand that the non-existent file “D:\\MyNewDB.db” was created. And if the database was created it was also clear
(2.1) By Simon Slavin (slavin) on 2021-05-11 21:14:18 edited from 2.0 in reply to 1 [link] [source]
If I understand previous comments here correctly, SQLite doesn't do any file access until it needs to. For example, if you do
sqlite3_open_v2() and then
sqlite3_close_v2(), no file access is done. This would suggest that
sqlite3_open_v2() by itself would not create a database file.
It's possible that this was behaviour for
sqlite3_open_v2() does something different. But it might be worth a test.
If you want to know whether a file of a particularly path/name exists, I think you're expected to use a file system call.
(3) By Kees Nuyt (knu) on 2021-05-11 21:24:47 in reply to 1 [source]
Open the database with
If it returns an error, the file already existed.
The details are handled in the VFS module for your operating system, in your case probably
Begin file os_win.c in sqlite3.c to find that code.
(4) By David Jones (vman59) on 2021-05-11 23:23:34 in reply to 3 [link] [source]
Look for the code around the string 'Only allow sensible combinations" in sqlite3.c, it does not consider SQLITE_OPEN_CREATE without an accompanying SQLITE_OPEN_READWRITE to be a sensible combination. This check is in the common open function before the VFS gets involved.