Skip to content

Commit 1ebe19a

Browse files
committed
Support for isc_spb_bkp_stat/isc_spb_res_stat (DNET-646).
1 parent 4008bea commit 1ebe19a

File tree

5 files changed

+58
-2
lines changed

5 files changed

+58
-2
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ void BackupPart()
6969
backupSvc.Options = FbBackupFlags.IgnoreLimbo;
7070
backupSvc.BackupFiles.Add(new FbBackupFile(backupName, 2048));
7171
backupSvc.Verbose = true;
72+
backupSvc.Statistics = FbBackupRestoreStatistics.TotalTime | FbBackupRestoreStatistics.TimeDelta;
7273

7374
backupSvc.ServiceOutput += ServiceOutput;
7475

@@ -82,6 +83,7 @@ void RestorePart()
8283
restoreSvc.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace;
8384
restoreSvc.PageSize = FbTestsSetup.PageSize;
8485
restoreSvc.Verbose = true;
86+
restoreSvc.Statistics = FbBackupRestoreStatistics.TotalTime | FbBackupRestoreStatistics.TimeDelta;
8587
restoreSvc.BackupFiles.Add(new FbBackupFile(backupName, 2048));
8688

8789
restoreSvc.ServiceOutput += ServiceOutput;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ internal static class IscCodes
452452
public const int isc_spb_bkp_factor = 6;
453453
public const int isc_spb_bkp_length = 7;
454454
public const int isc_spb_bkp_skip_data = 8;
455-
455+
public const int isc_spb_bkp_stat = 15;
456456
public const int isc_spb_bkp_ignore_checksums = 0x01;
457457
public const int isc_spb_bkp_ignore_limbo = 0x02;
458458
public const int isc_spb_bkp_metadata_only = 0x04;
@@ -472,7 +472,9 @@ internal static class IscCodes
472472
public const int isc_spb_res_page_size = 10;
473473
public const int isc_spb_res_length = 11;
474474
public const int isc_spb_res_access_mode = 12;
475-
475+
public const int isc_spb_res_fix_fss_data = 13;
476+
public const int isc_spb_res_fix_fss_metadata = 14;
477+
public const int isc_spb_res_stat = isc_spb_bkp_stat;
476478
public const int isc_spb_res_metadata_only = isc_spb_bkp_metadata_only;
477479
public const int isc_spb_res_deactivate_idx = 0x0100;
478480
public const int isc_spb_res_no_shadow = 0x0200;

Provider/src/FirebirdSql.Data.FirebirdClient/Services/FbBackup.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public sealed class FbBackup : FbService
2828
public int Factor { get; set; }
2929
public string SkipData { get; set; }
3030
public FbBackupFlags Options { get; set; }
31+
public FbBackupRestoreStatistics Statistics { get; set; }
3132

3233
public FbBackup(string connectionString = null)
3334
: base(connectionString)
@@ -57,6 +58,7 @@ public void Execute()
5758
if (!string.IsNullOrEmpty(SkipData))
5859
StartSpb.Append(IscCodes.isc_spb_bkp_skip_data, SkipData);
5960
StartSpb.Append(IscCodes.isc_spb_options, (int)Options);
61+
StartSpb.Append(IscCodes.isc_spb_bkp_stat, Statistics.BuildConfiguration());
6062

6163
Open();
6264
StartTask();
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* The contents of this file are subject to the Initial
3+
* Developer's Public License Version 1.0 (the "License");
4+
* you may not use this file except in compliance with the
5+
* License. You may obtain a copy of the License at
6+
* https://github.com/FirebirdSQL/NETProvider/blob/master/license.txt.
7+
*
8+
* Software distributed under the License is distributed on
9+
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
10+
* express or implied. See the License for the specific
11+
* language governing rights and limitations under the License.
12+
*
13+
* All Rights Reserved.
14+
*/
15+
16+
//$Authors = Jiri Cincura ([email protected])
17+
18+
using System;
19+
using System.Text;
20+
21+
namespace FirebirdSql.Data.Services
22+
{
23+
[Flags]
24+
public enum FbBackupRestoreStatistics
25+
{
26+
TotalTime = 0b0001,
27+
TimeDelta = 0b0010,
28+
PageReads = 0b0100,
29+
PageWrites = 0b1000,
30+
}
31+
32+
internal static class Ext
33+
{
34+
public static string BuildConfiguration(this FbBackupRestoreStatistics statistics)
35+
{
36+
var sb = new StringBuilder();
37+
if (statistics.HasFlag(FbBackupRestoreStatistics.TotalTime))
38+
sb.Append("T");
39+
if (statistics.HasFlag(FbBackupRestoreStatistics.TimeDelta))
40+
sb.Append("D");
41+
if (statistics.HasFlag(FbBackupRestoreStatistics.PageReads))
42+
sb.Append("R");
43+
if (statistics.HasFlag(FbBackupRestoreStatistics.PageWrites))
44+
sb.Append("W");
45+
return sb.ToString();
46+
}
47+
}
48+
}

Provider/src/FirebirdSql.Data.FirebirdClient/Services/FbRestore.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public int? PageSize
4242
public bool ReadOnly { get; set; }
4343
public string SkipData { get; set; }
4444
public FbRestoreFlags Options { get; set; }
45+
public FbBackupRestoreStatistics Statistics { get; set; }
4546

4647
public FbRestore(string connectionString = null)
4748
: base(connectionString)
@@ -72,6 +73,7 @@ public void Execute()
7273
if (!string.IsNullOrEmpty(SkipData))
7374
StartSpb.Append(IscCodes.isc_spb_res_skip_data, SkipData);
7475
StartSpb.Append(IscCodes.isc_spb_options, (int)Options);
76+
StartSpb.Append(IscCodes.isc_spb_res_stat, Statistics.BuildConfiguration());
7577

7678
Open();
7779
StartTask();

0 commit comments

Comments
 (0)