On Tue, 9 Oct 2007, Joe Wilson wrote: > --- Cyrus Durgin <[EMAIL PROTECTED]> wrote: > > i'm wondering if there's a "standard" way to get an open file handle from an > > sqlite3 pointer using the C API. anyone know? > > No such function exists, but it would be a useful addition to the API. > Copying the database during an exclusive lock without spawning a process > for instance...
I agree. At Schrodinger, we added two functions to our version of sqlite3: /* The sqlite3 APIs to get file descriptors fo the open files */ int sqlite3_get_database_file_fd( sqlite3* sqlite3_db_ptr ); int sqlite3_get_journal_file_fd( sqlite3* sqlite3_db_ptr ); This was done to prevent the open files from being inherited by forked child processes, using fcntl(fd, F_SETFD, FD_CLOEXEC), since otherwise those child processes could keep the files open, thereby preventing deletion of the database files (and the directory that contains them) in the parent process. It would be better for us to have similar functions included as part of the standard sqlite interface. --- The database files are kept inside project directories, created by the same client application, to store data about project entries and their properties. In this application, there is expected to be only a single client process accessing the database, and the project is locked by the client to ensure this. Before adding these functions (in order to set the FD_CLOEXEC flag), we had problems with the deletion of scratch (temporary) projects or user deletion of projects, because child processes launched in the background (such as calculation job processes or browsers for online help) would by default inherit all open files. The database files are open essentially the entire time that the project is open, because we maintain an open transaction at all times (except for commit or rollback of changes to the project data) to improve performance and to handle single-level undo of data modifications (in the project, and in the application state). --- Andy Spencer <[EMAIL PROTECTED]> ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------