Subject | Re: [firebird-support] Embedded Firebird 2.1.1 keeps the database file opened |
---|---|
Author | Helen Borrie |
Post date | 2008-08-20T12:24:31Z |
At 19:14 20/08/2008, you wrote:
You can't move a database within the context of a connection. You can move it as a FILE if it isn't open.
./heLen
>HelloThe command that deletes a database is DROP DATABASE (with no parameters). The server must be running and the owner must be connected to it, in order to drop it.
>
>I started use embedded Firebird 2.1.1 in my Delphi application (with FBLib)
>and I need to create and populate a database file, but if anything goes
>wrong, an exception gets thrown, I need to close and delete the database and
>then prompt the user to try again.
>
>The problem is the embedded super-server keeps the newly created database
>opened.
>I use
>gfix -force 1 -shut dbFile.fdb
>That is I use TFBLService.GFixSetShutdownDb(dbFile.fdb, 1), which is theWhat you have with embedded on Windows is a Firebird server and a client library running side by side in one application space, with no user authentication credentials. Since only SYSDBA can perform a database shutdown, it can't be expected to work with embedded, even if it made sense (which it doesn't). Database shutdown prevents new connections and new transactions. Since your instance of fbembed has exclusive access to the database, what would you be hoping for here?
>equivalent
>API call in FBLib.
>The database file is still opened by the library after that. I even tried to...while the *proper* way is to disconnect from the database - or indeed, to ask the server to DROP the database, if that be your will. When the server drops a database, it deletes the file that the database lived in.
>
>FreeLibrary(hDLL)
>
>which, apart from the fact that it later crashes my app, still keeps the new
>database opened, even though the debugger says 'Module unload: fbembed.dll
>...' at the time I call FreeLibrary. The only way to release the file is to
>exit my process.
>How can I create a database and then move it or delete it ?To delete it, send a DROP DATABASE request.
You can't move a database within the context of a connection. You can move it as a FILE if it isn't open.
>Is this a known issue ? Is this by design ?A database lives in a file but the server regards it as a database, not a file. To illustrate this, on more sophisticated platforms than Windows, a database doesn't have to live in a file. It can be a device in its own right, living on a raw disk partition that the filesystem doesn't even know is there.
>It would be awful to create a new process, transparent to the user, thatYep, it all sounds pretty hairy...and hairy is as hairy does. Think "database" not "file". Firebird isn't a file-served database system.
>would load the library and receive db requests from the main app by pipes or
>shared memory, just to be able to release the file.
>
>Has anyone had this problem before ? It is really frustrating ...
./heLen