Skip to content

Commit ebce3a3

Browse files
committed
Support for fb_info_next_attachment (#938).
1 parent 10a702e commit ebce3a3

File tree

3 files changed

+43
-25
lines changed

3 files changed

+43
-25
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" }.Contains(m.Name))
45+
if (ServerVersion < new Version(4, 0, 0, 0) && new[] { "GetWireCryptAsync", "GetCryptPluginAsync", "GetNextAttachmentAsync" }.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: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public static List<object> ParseDatabaseInfo(byte[] buffer)
7171
case IscCodes.isc_info_next_transaction:
7272
case IscCodes.isc_info_active_transactions:
7373
case IscCodes.isc_info_active_tran_count:
74+
case IscCodes.fb_info_next_attachment:
7475
info.Add(VaxInteger(buffer, pos, length));
7576
break;
7677

@@ -94,16 +95,18 @@ public static List<object> ParseDatabaseInfo(byte[] buffer)
9495
break;
9596

9697
case IscCodes.isc_info_db_id:
97-
var dbFile = Encoding2.Default.GetString(buffer, pos + 2, buffer[pos + 1]);
98-
var sitePos = pos + 2 + buffer[pos + 1];
99-
int siteLength = buffer[sitePos];
100-
var siteName = Encoding2.Default.GetString(buffer, sitePos + 1, siteLength);
98+
{
99+
var dbFile = Encoding2.Default.GetString(buffer, pos + 2, buffer[pos + 1]);
100+
var sitePos = pos + 2 + buffer[pos + 1];
101+
int siteLength = buffer[sitePos];
102+
var siteName = Encoding2.Default.GetString(buffer, sitePos + 1, siteLength);
101103

102-
sitePos += siteLength + 1;
103-
siteLength = buffer[sitePos];
104-
siteName += "." + Encoding2.Default.GetString(buffer, sitePos + 1, siteLength);
104+
sitePos += siteLength + 1;
105+
siteLength = buffer[sitePos];
106+
siteName += "." + Encoding2.Default.GetString(buffer, sitePos + 1, siteLength);
105107

106-
info.Add(siteName + ":" + dbFile);
108+
info.Add(siteName + ":" + dbFile);
109+
}
107110
break;
108111

109112
case IscCodes.isc_info_implementation:
@@ -112,32 +115,38 @@ public static List<object> ParseDatabaseInfo(byte[] buffer)
112115

113116
case IscCodes.isc_info_isc_version:
114117
case IscCodes.isc_info_firebird_version:
115-
var messagePosition = pos;
116-
var count = buffer[messagePosition];
117-
for (var i = 0; i < count; i++)
118118
{
119-
var messageLength = buffer[messagePosition + 1];
120-
info.Add(Encoding2.Default.GetString(buffer, messagePosition + 2, messageLength));
121-
messagePosition += 1 + messageLength;
119+
var messagePosition = pos;
120+
var count = buffer[messagePosition];
121+
for (var i = 0; i < count; i++)
122+
{
123+
var messageLength = buffer[messagePosition + 1];
124+
info.Add(Encoding2.Default.GetString(buffer, messagePosition + 2, messageLength));
125+
messagePosition += 1 + messageLength;
126+
}
122127
}
123128
break;
124129

125130
case IscCodes.isc_info_db_class:
126-
var serverClass = VaxInteger(buffer, pos, length);
127-
if (serverClass == IscCodes.isc_info_db_class_classic_access)
128-
{
129-
info.Add("CLASSIC SERVER");
130-
}
131-
else
132131
{
133-
info.Add("SUPER SERVER");
132+
var serverClass = VaxInteger(buffer, pos, length);
133+
if (serverClass == IscCodes.isc_info_db_class_classic_access)
134+
{
135+
info.Add("CLASSIC SERVER");
136+
}
137+
else
138+
{
139+
info.Add("SUPER SERVER");
140+
}
134141
}
135142
break;
136143

137144
case IscCodes.isc_info_creation_date:
138-
var date = TypeDecoder.DecodeDate((int)VaxInteger(buffer, pos, 4));
139-
var time = TypeDecoder.DecodeTime((int)VaxInteger(buffer, pos + 4, 4));
140-
info.Add(date.Add(time));
145+
{
146+
var date = TypeDecoder.DecodeDate((int)VaxInteger(buffer, pos, 4));
147+
var time = TypeDecoder.DecodeTime((int)VaxInteger(buffer, pos + 4, 4));
148+
info.Add(date.Add(time));
149+
}
141150
break;
142151

143152
default:

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,15 @@ public Task<DateTime> GetCreationDateAsync(CancellationToken cancellationToken =
395395
return GetValueAsync<DateTime>(IscCodes.isc_info_creation_date, cancellationToken);
396396
}
397397

398+
public long GetNextAttachment()
399+
{
400+
return GetValue<long>(IscCodes.fb_info_next_attachment);
401+
}
402+
public Task<long> GetNextAttachmentAsync(CancellationToken cancellationToken = default)
403+
{
404+
return GetValueAsync<long>(IscCodes.fb_info_next_attachment, cancellationToken);
405+
}
406+
398407
#endregion
399408

400409
#region Constructors

0 commit comments

Comments
 (0)