Skip to content

Commit 1dfa364

Browse files
committed
Backport Firebird 3.0 support
it is mostly the same as 2.5 but there is no docker container for 2.5 so this is neccesary to have code tested on github
1 parent b245646 commit 1dfa364

File tree

8 files changed

+801
-0
lines changed

8 files changed

+801
-0
lines changed

Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/DriverFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ private static SqlDriver CreateDriverInstance(
6262
if (coreServerInfo.ServerVersion.Major == 2 && coreServerInfo.ServerVersion.Minor == 5) {
6363
return new v2_5.Driver(coreServerInfo);
6464
}
65+
if (coreServerInfo.ServerVersion.Major == 3)
66+
return new v3_0.Driver(coreServerInfo);
6567

6668
return null;
6769
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (C) 2025 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Text;
8+
9+
namespace Xtensive.Sql.Drivers.Firebird.v3_0
10+
{
11+
internal class Compiler : v2_5.Compiler
12+
{
13+
protected internal Compiler(SqlDriver driver)
14+
: base(driver)
15+
{
16+
}
17+
}
18+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (C) 2025 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
4+
5+
using System;
6+
using Xtensive.Sql.Info;
7+
using Xtensive.Sql.Compiler;
8+
9+
namespace Xtensive.Sql.Drivers.Firebird.v3_0
10+
{
11+
internal class Driver : v2_5.Driver
12+
{
13+
protected override Sql.TypeMapper CreateTypeMapper() => new TypeMapper(this);
14+
15+
protected override SqlCompiler CreateCompiler() => new Compiler(this);
16+
17+
protected override SqlTranslator CreateTranslator() => new Translator(this);
18+
19+
protected override Model.Extractor CreateExtractor() => new Extractor(this);
20+
21+
protected override Info.ServerInfoProvider CreateServerInfoProvider() => new ServerInfoProvider(this);
22+
23+
// Constructors
24+
25+
public Driver(CoreServerInfo coreServerInfo)
26+
: base(coreServerInfo)
27+
{
28+
}
29+
}
30+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Copyright (C) 2021 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
4+
5+
namespace Xtensive.Sql.Drivers.Firebird.v3_0
6+
{
7+
internal partial class Extractor
8+
{
9+
protected override string GetExtractTableColumnsQuery()
10+
{
11+
return @"
12+
select schema
13+
,table_name
14+
,ordinal_position
15+
,column_name
16+
,field_type
17+
,column_subtype
18+
,column_size
19+
,numeric_precision
20+
,-numeric_scale as numeric_scale
21+
,character_max_length
22+
,(1 - coalesce(column_nullable,0)) as column_nullable
23+
,column_default
24+
,relation_type
25+
from (select cast(null as varchar(30)) as schema
26+
,trim(rfr.rdb$relation_name) as table_name
27+
,trim(rfr.rdb$field_name) as column_name
28+
,fld.rdb$field_sub_type as column_subtype
29+
,cast(fld.rdb$field_length as integer) as column_size
30+
,cast(fld.rdb$field_precision as integer) as numeric_precision
31+
,cast(fld.rdb$field_scale as integer) as numeric_scale
32+
,cast(fld.rdb$character_length as integer) as character_max_length
33+
,cast(fld.rdb$field_length as integer) as character_octet_length
34+
,rfr.rdb$field_position as ordinal_position
35+
,trim(rfr.rdb$field_source) as domain_name
36+
,trim(rfr.rdb$default_source) as column_default
37+
,trim(fld.rdb$computed_source) as computed_source
38+
,fld.rdb$dimensions as column_array
39+
,coalesce(fld.rdb$null_flag, rfr.rdb$null_flag) as column_nullable
40+
,0 as is_readonly
41+
,fld.rdb$field_type as field_type
42+
,trim(cs.rdb$character_set_name) as character_set_name
43+
,trim(coll.rdb$collation_name) as collation_name
44+
,trim(rfr.rdb$description) as description
45+
,cast(rr.rdb$relation_type as integer) as relation_type
46+
from rdb$relations rr join rdb$relation_fields rfr on rfr.rdb$relation_name = rr.rdb$relation_name
47+
left join rdb$fields fld on rfr.rdb$field_source = fld.rdb$field_name
48+
left join rdb$character_sets cs
49+
on cs.rdb$character_set_id = fld.rdb$character_set_id
50+
left join rdb$collations coll
51+
on (coll.rdb$collation_id = fld.rdb$collation_id
52+
and coll.rdb$character_set_id = fld.rdb$character_set_id)
53+
where rr.rdb$relation_type in (0, 4, 5) and rr.rdb$relation_name not starts with 'RDB$' and rr.rdb$relation_name not starts with 'MON$'
54+
order by table_name, ordinal_position)";
55+
}
56+
57+
protected override string GetExtractUniqueAndPrimaryKeyConstraintsQuery()
58+
{
59+
return @"
60+
select cast(null as varchar(30)) as schema
61+
,trim(rel.rdb$relation_name) as table_name
62+
,trim(rel.rdb$constraint_name) as constraint_name
63+
,trim(rel.rdb$constraint_type) constraint_type
64+
,trim(seg.rdb$field_name) as column_name
65+
,seg.rdb$field_position as column_position
66+
from rdb$relation_constraints rel
67+
left join rdb$indices idx on rel.rdb$index_name = idx.rdb$index_name
68+
left join rdb$index_segments seg on idx.rdb$index_name = seg.rdb$index_name
69+
where rel.rdb$constraint_type in ('PRIMARY KEY', 'UNIQUE')
70+
and rel.rdb$relation_name not starts with 'RDB$'
71+
and rel.rdb$relation_name not starts with 'MON$'
72+
order by rel.rdb$relation_name, rel.rdb$constraint_name, seg.rdb$field_position";
73+
}
74+
}
75+
}

0 commit comments

Comments
 (0)