Skip to content

Commit

Permalink
Support for isc_spb_bkp_stat/isc_spb_res_stat (DNET-646).
Browse files Browse the repository at this point in the history
  • Loading branch information
cincuranet committed Aug 1, 2019
1 parent 4008bea commit 1ebe19a
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 2 deletions.
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
@@ -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();
}
}
}
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 1ebe19a

Please sign in to comment.