Skip to content

FbConnection.CreateDatabase does not always throw exceptions when it cannot create the database [DNET398] #401

@firebird-automations

Description

@firebird-automations

Submitted by: Fernando Nájera (fernandonajera)

Consider the following code:

string file = @"X:\Test.fdb";
File.Delete (file);

string cnnStr = @"character set=UTF8;connection lifetime=15;user id=SYSDBA;password=masterkey;initial catalog=" + file + @";data source=localhost;dialect=3;pooling=False;min pool size=0;max pool size=50;packet size=8192;server type=Default";
FbConnection.CreateDatabase (cnnStr, 8192, true, false);
FbConnection.CreateDatabase (cnnStr, 8192, true, false);

Test #⁠1: run the code as-is

In 2.6.0.0, the second CreateDatabase fails with 'I/O error during "CreateFile (create)" operation for file "X:\TEST.FDB" // Error while trying to create file', which is fine.
In 2.6.5.0, the second CreateDatabase fails with 'I/O error during "CreateFile (create)" operation for file "X:\TEST.FDB" // Error while trying to create file', which is fine.

Test #⁠2: run up to the first FbConnection, then connect to the database using another process (e.g. via isql), and while connected, run the second FbConnection

In 2.6.0.0, the second CreateDatabase fails with 'invalid database handle (no active connection)', which is good enough for me.
In 2.6.5.0, the second CreateDatabase does not throw any exception!

Test #⁠3: change the code above so instead of the two CreateDatabase calls you have now this:

FbConnection.CreateDatabase (cnnStr, 8192, true, false);
using (FbConnection cnn = new FbConnection (cnnStr))
{
cnn.Open ();
FbConnection.CreateDatabase (cnnStr, 8192, true, false);
}

In 2.6.0.0, the second CreateDatabase fails with 'invalid database handle (no active connection)', which is good enough for me.
In 2.6.5.0, the second CreateDatabase does not throw any exception!

The bottom line is, if the database has any active connection (by the same or by another process), CreateDatabase does not fail in 2.6.5.0! This is a change of behaviour against 2.6.0.0, and in my opinion is a bug - CreateDatabase should create a database, or fail.

I have put the priority to Critical, because this behavior can effectively lead to crashes - the call does not fail, so you think you have created a new, empty database, when in fact you are reusing an existing database!

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions