Hello,

On 2017-04-28 12:16, Olivier Mascia wrote:
http://sqlite.org/c3ref/open.html says:

"If the filename is an empty string, then a private, temporary on-disk database will 
be created. This private database will be automatically deleted as soon as the database 
connection is closed."

The same behavior is when filename is NULL. In both cases a pager's filename is set to an empty string.

On such a successfully opened database, sqlite3_db_filename(db, "main") returns 
a NOT null pointer (to '\0').
The same behavior is seen when the opened database is an in-memory one (using 
":memory:" in the sqlite3_open_v2 call).

Indeed, look at the code (``sqlite3PagerFilename''):

return (nullIfMemDb && pPager->memDb) ? "" : pPager->zFilename;

Yet http://sqlite.org/c3ref/db_filename.html says:

"If there is no attached database N on the database connection D, or if database N 
is a temporary or in-memory database, then a NULL pointer is returned."

Actually, NULL means that there is no such schema (if provided N is NULL, then "main"'s filename is returned). An empty string (ptr to '\0') means that the schema is an on-disk temp, or an in-mem db, or ``temp'' schema.

So I would have expected (from the documentation) to get a NULL pointer, at 
least for the :memory: database. And for the on-disk but private temporary one, 
the documentation is mute about what to except from sqlite3_db_filename().

I agree, that a minor DOC improvement would be nice in this case.

-- best regards

Cezary H. Noweta
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to