Skip to content

Commit d3fd636

Browse files
committed
Support for fb_info_replica_mode (#942)
1 parent 353fe22 commit d3fd636

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

Provider/src/FirebirdSql.Data.FirebirdClient.Tests/FbDatabaseInfoTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void CompleteDatabaseInfoTest()
4242
.Where(x => !x.IsSpecialName)
4343
.Where(x => x.Name.EndsWith("Async")))
4444
{
45-
if (ServerVersion < new Version(4, 0, 0, 0) && new[] { "GetWireCryptAsync", "GetCryptPluginAsync", "GetNextAttachmentAsync", "GetNextStatementAsync" }.Contains(m.Name))
45+
if (ServerVersion < new Version(4, 0, 0, 0) && new[] { "GetWireCryptAsync", "GetCryptPluginAsync", "GetNextAttachmentAsync", "GetNextStatementAsync", "GetReplicaModeAsync" }.Contains(m.Name))
4646
continue;
4747

4848
Assert.DoesNotThrowAsync(() => (Task)m.Invoke(dbInfo, new object[] { CancellationToken.None }), m.Name);

Provider/src/FirebirdSql.Data.FirebirdClient/Common/IscHelper.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,12 @@ public static List<object> ParseDatabaseInfo(byte[] buffer)
131131
case IscCodes.isc_info_db_class:
132132
{
133133
var serverClass = VaxInteger(buffer, pos, length);
134-
if (serverClass == IscCodes.isc_info_db_class_classic_access)
134+
info.Add(serverClass switch
135135
{
136-
info.Add("CLASSIC SERVER");
137-
}
138-
else
139-
{
140-
info.Add("SUPER SERVER");
141-
}
136+
IscCodes.isc_info_db_class_classic_access => "CLASSIC SERVER",
137+
IscCodes.isc_info_db_class_server_access => "SUPER SERVER",
138+
_ => throw new ArgumentOutOfRangeException(nameof(serverClass), $"{nameof(serverClass)}={serverClass}"),
139+
});
142140
}
143141
break;
144142

@@ -150,6 +148,19 @@ public static List<object> ParseDatabaseInfo(byte[] buffer)
150148
}
151149
break;
152150

151+
case IscCodes.fb_info_replica_mode:
152+
{
153+
var mode = VaxInteger(buffer, pos, length);
154+
info.Add(mode switch
155+
{
156+
0 => "NONE",
157+
1 => "READ ONLY",
158+
2 => "READ WRITE",
159+
_ => throw new ArgumentOutOfRangeException(nameof(mode), $"{nameof(mode)}={mode}"),
160+
});
161+
}
162+
break;
163+
153164
default:
154165
throw new ArgumentOutOfRangeException(nameof(type), $"{nameof(type)}={type}");
155166
}

Provider/src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbDatabaseInfo.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,15 @@ public Task<long> GetNextStatementAsync(CancellationToken cancellationToken = de
413413
return GetValueAsync<long>(IscCodes.fb_info_next_statement, cancellationToken);
414414
}
415415

416+
public string GetReplicaMode()
417+
{
418+
return GetValue<string>(IscCodes.fb_info_replica_mode);
419+
}
420+
public Task<string> GetReplicaModeAsync(CancellationToken cancellationToken = default)
421+
{
422+
return GetValueAsync<string>(IscCodes.fb_info_replica_mode, cancellationToken);
423+
}
424+
416425
#endregion
417426

418427
#region Constructors

0 commit comments

Comments
 (0)