internal void Export(List <string> tablesToExport, SQLiteBackup manager) { if (manager.stopProcess || tablesToExport.Count < 1 || !tablesToExport.Contains(_tableName.Trim().ToLower())) { return; } manager.Export_WriteLine(_createIndexSQL); manager.textWriter.WriteLine(); }
/// <summary> /// Destroys the backup object, rolling back any backup that may be in /// progess. /// </summary> /// <param name="backup">The backup object to destroy.</param> internal abstract void FinishBackup(SQLiteBackup backup);
/// <summary> /// Returns the total number of pages in the source database associated /// with the specified backup object. /// </summary> /// <param name="backup">The backup object to check.</param> /// <returns>The total number of pages in the source database.</returns> internal abstract int PageCountBackup(SQLiteBackup backup);
/// <summary> /// Returns the number of pages remaining to be copied from the source /// database to the destination database associated with the specified /// backup object. /// </summary> /// <param name="backup">The backup object to check.</param> /// <returns>The number of pages remaining to be copied.</returns> internal abstract int RemainingBackup(SQLiteBackup backup);
/// <summary> /// Copies up to N pages from the source database to the destination /// database associated with the specified backup object. /// </summary> /// <param name="backup">The backup object to use.</param> /// <param name="nPage"> /// The number of pages to copy or negative to copy all remaining pages. /// </param> /// <param name="retry"> /// Set to true if the operation needs to be retried due to database /// locking issues. /// </param> /// <returns> /// True if there are more pages to be copied, false otherwise. /// </returns> internal abstract bool StepBackup(SQLiteBackup backup, int nPage, out bool retry);
/// <summary> /// Destroys the backup object, rolling back any backup that may be in /// progess. /// </summary> /// <param name="backup">The backup object to destroy.</param> internal override void FinishBackup( SQLiteBackup backup ) { if (backup == null) throw new ArgumentNullException("backup"); SQLiteBackupHandle handle = backup._sqlite_backup; if (handle == null) throw new InvalidOperationException( "Backup object has an invalid handle."); int n = UnsafeNativeMethods.sqlite3_backup_finish(handle); handle.SetHandleAsInvalid(); if ((n > 0) && (n != backup._stepResult)) throw new SQLiteException(n, GetLastError()); }
/// <summary> /// Returns the total number of pages in the source database associated /// with the specified backup object. /// </summary> /// <param name="backup">The backup object to check.</param> /// <returns>The total number of pages in the source database.</returns> internal override int PageCountBackup( SQLiteBackup backup ) { if (backup == null) throw new ArgumentNullException("backup"); SQLiteBackupHandle handle = backup._sqlite_backup; if (handle == null) throw new InvalidOperationException( "Backup object has an invalid handle."); return UnsafeNativeMethods.sqlite3_backup_pagecount(handle); }
/// <summary> /// Copies up to N pages from the source database to the destination /// database associated with the specified backup object. /// </summary> /// <param name="backup">The backup object to use.</param> /// <param name="nPage"> /// The number of pages to copy, negative to copy all remaining pages. /// </param> /// <param name="retry"> /// Set to true if the operation needs to be retried due to database /// locking issues; otherwise, set to false. /// </param> /// <returns> /// True if there are more pages to be copied, false otherwise. /// </returns> internal override bool StepBackup( SQLiteBackup backup, int nPage, out bool retry ) { retry = false; if (backup == null) throw new ArgumentNullException("backup"); SQLiteBackupHandle handle = backup._sqlite_backup; if (handle == null) throw new InvalidOperationException( "Backup object has an invalid handle."); int n = UnsafeNativeMethods.sqlite3_backup_step(handle, nPage); backup._stepResult = n; /* NOTE: Save for use by FinishBackup. */ if (n == (int)SQLiteErrorCode.Ok) { return true; } else if (n == (int)SQLiteErrorCode.Busy) { retry = true; return true; } else if (n == (int)SQLiteErrorCode.Locked) { retry = true; return true; } else if (n == (int)SQLiteErrorCode.Done) { return false; } else { throw new SQLiteException(n, GetLastError()); } }
/// <summary> /// Destroys the backup object, rolling back any backup that may be in /// progess. /// </summary> /// <param name="backup">The backup object to destroy.</param> internal override void FinishBackup( SQLiteBackup backup ) { if (backup == null) throw new ArgumentNullException("backup"); SQLiteBackupHandle handle = backup._sqlite_backup; if (handle == null) throw new InvalidOperationException( "Backup object has an invalid handle."); IntPtr handlePtr = handle; if (handlePtr == IntPtr.Zero) throw new InvalidOperationException( "Backup object has an invalid handle pointer."); SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_backup_finish(handlePtr); handle.SetHandleAsInvalid(); #if COUNT_HANDLE if (n == SQLiteErrorCode.Ok) handle.WasReleasedOk(); #endif if ((n != SQLiteErrorCode.Ok) && (n != backup._stepResult)) throw new SQLiteException(n, GetLastError()); }
/// <summary> /// Returns the number of pages remaining to be copied from the source /// database to the destination database associated with the specified /// backup object. /// </summary> /// <param name="backup">The backup object to check.</param> /// <returns>The number of pages remaining to be copied.</returns> internal override int RemainingBackup( SQLiteBackup backup ) { if (backup == null) throw new ArgumentNullException("backup"); SQLiteBackupHandle handle = backup._sqlite_backup; if (handle == null) throw new InvalidOperationException( "Backup object has an invalid handle."); IntPtr handlePtr = handle; if (handlePtr == IntPtr.Zero) throw new InvalidOperationException( "Backup object has an invalid handle pointer."); return UnsafeNativeMethods.sqlite3_backup_remaining(handlePtr); }