From 1ebe19ac5a81129aff428e197c32c8e302bd2923 Mon Sep 17 00:00:00 2001 From: Jiri Cincura Date: Thu, 1 Aug 2019 09:37:28 +0200 Subject: [PATCH] Support for isc_spb_bkp_stat/isc_spb_res_stat (DNET-646). --- .../FbServicesTests.cs | 2 + .../Common/IscCodes.cs | 6 ++- .../Services/FbBackup.cs | 2 + .../Services/FbBackupRestoreStatistics.cs | 48 +++++++++++++++++++ .../Services/FbRestore.cs | 2 + 5 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 Provider/src/FirebirdSql.Data.FirebirdClient/Services/FbBackupRestoreStatistics.cs diff --git a/Provider/src/FirebirdSql.Data.FirebirdClient.Tests/FbServicesTests.cs b/Provider/src/FirebirdSql.Data.FirebirdClient.Tests/FbServicesTests.cs index a1a1c67e..84314646 100644 --- a/Provider/src/FirebirdSql.Data.FirebirdClient.Tests/FbServicesTests.cs +++ b/Provider/src/FirebirdSql.Data.FirebirdClient.Tests/FbServicesTests.cs @@ -69,6 +69,7 @@ void BackupPart() backupSvc.Options = FbBackupFlags.IgnoreLimbo; backupSvc.BackupFiles.Add(new FbBackupFile(backupName, 2048)); backupSvc.Verbose = true; + backupSvc.Statistics = FbBackupRestoreStatistics.TotalTime | FbBackupRestoreStatistics.TimeDelta; backupSvc.ServiceOutput += ServiceOutput; @@ -82,6 +83,7 @@ void RestorePart() restoreSvc.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace; restoreSvc.PageSize = FbTestsSetup.PageSize; restoreSvc.Verbose = true; + restoreSvc.Statistics = FbBackupRestoreStatistics.TotalTime | FbBackupRestoreStatistics.TimeDelta; restoreSvc.BackupFiles.Add(new FbBackupFile(backupName, 2048)); restoreSvc.ServiceOutput += ServiceOutput; diff --git a/Provider/src/FirebirdSql.Data.FirebirdClient/Common/IscCodes.cs b/Provider/src/FirebirdSql.Data.FirebirdClient/Common/IscCodes.cs index 48bcef6a..327c63bb 100644 --- a/Provider/src/FirebirdSql.Data.FirebirdClient/Common/IscCodes.cs +++ b/Provider/src/FirebirdSql.Data.FirebirdClient/Common/IscCodes.cs @@ -452,7 +452,7 @@ internal static class IscCodes public const int isc_spb_bkp_factor = 6; public const int isc_spb_bkp_length = 7; public const int isc_spb_bkp_skip_data = 8; - + public const int isc_spb_bkp_stat = 15; public const int isc_spb_bkp_ignore_checksums = 0x01; public const int isc_spb_bkp_ignore_limbo = 0x02; public const int isc_spb_bkp_metadata_only = 0x04; @@ -472,7 +472,9 @@ internal static class IscCodes public const int isc_spb_res_page_size = 10; public const int isc_spb_res_length = 11; public const int isc_spb_res_access_mode = 12; - + public const int isc_spb_res_fix_fss_data = 13; + public const int isc_spb_res_fix_fss_metadata = 14; + public const int isc_spb_res_stat = isc_spb_bkp_stat; public const int isc_spb_res_metadata_only = isc_spb_bkp_metadata_only; public const int isc_spb_res_deactivate_idx = 0x0100; public const int isc_spb_res_no_shadow = 0x0200; diff --git a/Provider/src/FirebirdSql.Data.FirebirdClient/Services/FbBackup.cs b/Provider/src/FirebirdSql.Data.FirebirdClient/Services/FbBackup.cs index c53fcf2d..00704f7c 100644 --- a/Provider/src/FirebirdSql.Data.FirebirdClient/Services/FbBackup.cs +++ b/Provider/src/FirebirdSql.Data.FirebirdClient/Services/FbBackup.cs @@ -28,6 +28,7 @@ public sealed class FbBackup : FbService public int Factor { get; set; } public string SkipData { get; set; } public FbBackupFlags Options { get; set; } + public FbBackupRestoreStatistics Statistics { get; set; } public FbBackup(string connectionString = null) : base(connectionString) @@ -57,6 +58,7 @@ public void Execute() if (!string.IsNullOrEmpty(SkipData)) StartSpb.Append(IscCodes.isc_spb_bkp_skip_data, SkipData); StartSpb.Append(IscCodes.isc_spb_options, (int)Options); + StartSpb.Append(IscCodes.isc_spb_bkp_stat, Statistics.BuildConfiguration()); Open(); StartTask(); diff --git a/Provider/src/FirebirdSql.Data.FirebirdClient/Services/FbBackupRestoreStatistics.cs b/Provider/src/FirebirdSql.Data.FirebirdClient/Services/FbBackupRestoreStatistics.cs new file mode 100644 index 00000000..d71e38a8 --- /dev/null +++ b/Provider/src/FirebirdSql.Data.FirebirdClient/Services/FbBackupRestoreStatistics.cs @@ -0,0 +1,48 @@ +/* + * The contents of this file are subject to the Initial + * Developer's Public License Version 1.0 (the "License"); + * you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * https://github.com/FirebirdSQL/NETProvider/blob/master/license.txt. + * + * Software distributed under the License is distributed on + * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * All Rights Reserved. + */ + +//$Authors = Jiri Cincura (jiri@cincura.net) + +using System; +using System.Text; + +namespace FirebirdSql.Data.Services +{ + [Flags] + public enum FbBackupRestoreStatistics + { + TotalTime = 0b0001, + TimeDelta = 0b0010, + PageReads = 0b0100, + PageWrites = 0b1000, + } + + internal static class Ext + { + public static string BuildConfiguration(this FbBackupRestoreStatistics statistics) + { + var sb = new StringBuilder(); + if (statistics.HasFlag(FbBackupRestoreStatistics.TotalTime)) + sb.Append("T"); + if (statistics.HasFlag(FbBackupRestoreStatistics.TimeDelta)) + sb.Append("D"); + if (statistics.HasFlag(FbBackupRestoreStatistics.PageReads)) + sb.Append("R"); + if (statistics.HasFlag(FbBackupRestoreStatistics.PageWrites)) + sb.Append("W"); + return sb.ToString(); + } + } +} diff --git a/Provider/src/FirebirdSql.Data.FirebirdClient/Services/FbRestore.cs b/Provider/src/FirebirdSql.Data.FirebirdClient/Services/FbRestore.cs index e95cc136..b969db77 100644 --- a/Provider/src/FirebirdSql.Data.FirebirdClient/Services/FbRestore.cs +++ b/Provider/src/FirebirdSql.Data.FirebirdClient/Services/FbRestore.cs @@ -42,6 +42,7 @@ public sealed class FbRestore : FbService public bool ReadOnly { get; set; } public string SkipData { get; set; } public FbRestoreFlags Options { get; set; } + public FbBackupRestoreStatistics Statistics { get; set; } public FbRestore(string connectionString = null) : base(connectionString) @@ -72,6 +73,7 @@ public void Execute() if (!string.IsNullOrEmpty(SkipData)) StartSpb.Append(IscCodes.isc_spb_res_skip_data, SkipData); StartSpb.Append(IscCodes.isc_spb_options, (int)Options); + StartSpb.Append(IscCodes.isc_spb_res_stat, Statistics.BuildConfiguration()); Open(); StartTask();