FirebirdSQL / firebird

Firebird server, client and tools
https://www.firebirdsql.org/
1.21k stars 209 forks source link

Firebird Embedded and read-only databases without exclusive lock [CORE926] #1326

Open firebird-automations opened 17 years ago

firebird-automations commented 17 years ago

Submitted by: Adam Siwon (traptak)

I'd like to work with Firebird Embedded without database exclusive locking if database is set up to read-only mode. If it is possible...

firebird-automations commented 17 years ago

Commented by: Erik LaBianca (erik_ilsw.com)

There's a pretty easy workaround for this. Mark the file in your filesystem as read-only, after using gfix to set the database as read only.

I tracked it down in the source, the background information is as follows. The database engine (at least on windows) first tries to open a given database in read/write exclusive mode. If that succeeds, it will note the read/only flag on the db in particular but will never release the lock and get a read-only lock. If the attempt to gain a read/write exclusive handle fails, the engine falls back to a read-only open. It then checks to see if the database has been flagged as read-only, and throws an exception if it is not.

IMO there would be some benefit to opening the DB in read-only mode first, then reopening in RW mode IFF the database has not been flagged as read only. This would allow read-only databases to be opened multiple times without jumping through hoops such as storing them on read-only media or setting read-only flags on them.

firebird-automations commented 17 years ago

Commented by: Adam Siwon (traptak)

Thank you very much. This is the best solution for me. I can set read-only attribute during installation. But I think, this feature should be described in documentation. I have checked them and only found information that database is exclusive locked when application use Firebird embedded.

firebird-automations commented 16 years ago
Modified by: @pcisar Workflow: jira \[ 11199 \] =\> Firebird \[ 14699 \]