예제 #1
0
 /// <summary> Sqlite 3 backup step. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <param name="backup"> The backup. </param>
 /// <param name="nPage"> The page. </param>
 /// <returns> A SqliteResultCode. </returns>
 internal SqliteResultCode sqlite3_backup_step(SqliteBackupHandle backup, int nPage)
 {
     if (backup == null)
     {
         throw new ArgumentNullException(nameof(backup));
     }
     backup.CheckMaintenanceMode();
     return((SqliteResultCode)DbProviderOperations.sqlite3_backup_step(backup.Backup, nPage));
 }
예제 #2
0
 /// <summary> Sqlite 3 reset. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <param name="stmt"> The statement. </param>
 /// <returns> A SqliteResultCode. </returns>
 internal SqliteResultCode sqlite3_reset(SqliteStatementHandle stmt)
 {
     if (stmt == null)
     {
         throw new ArgumentNullException(nameof(stmt));
     }
     stmt.CheckMaintenanceMode();
     return((SqliteResultCode)DbProviderOperations.sqlite3_reset(stmt.Statement));
 }
예제 #3
0
 /// <summary> Sqlite 3 column type. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <param name="stmt"> The statement. </param>
 /// <param name="index"> Zero-based index of the. </param>
 /// <returns> A SqliteColumnType. </returns>
 internal SqliteColumnType sqlite3_column_type(SqliteStatementHandle stmt, int index)
 {
     if (stmt == null)
     {
         throw new ArgumentNullException(nameof(stmt));
     }
     stmt.CheckMaintenanceMode();
     return((SqliteColumnType)DbProviderOperations.sqlite3_column_type(stmt.Statement, index));
 }
예제 #4
0
 /// <summary> Sqlite 3 column count. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <param name="stmt"> The statement. </param>
 /// <returns> An int. </returns>
 internal int sqlite3_column_count(SqliteStatementHandle stmt)
 {
     if (stmt == null)
     {
         throw new ArgumentNullException(nameof(stmt));
     }
     stmt.CheckMaintenanceMode();
     return(DbProviderOperations.sqlite3_column_count(stmt.Statement));
 }
예제 #5
0
 /// <summary> Sqlite 3 column BLOB. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <param name="stmt"> The statement. </param>
 /// <param name="index"> Zero-based index of the. </param>
 /// <returns> A byte[]. </returns>
 internal byte[] sqlite3_column_blob(SqliteStatementHandle stmt, int index)
 {
     if (stmt == null)
     {
         throw new ArgumentNullException(nameof(stmt));
     }
     stmt.CheckMaintenanceMode();
     return(DbProviderOperations.sqlite3_column_blob(stmt.Statement, index));
 }
예제 #6
0
 /// <summary> Sqlite 3 bind text. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <param name="stmt"> The statement. </param>
 /// <param name="index"> Zero-based index of the. </param>
 /// <param name="value"> The value. </param>
 /// <returns> A SqliteResultCode. </returns>
 internal SqliteResultCode sqlite3_bind_text(SqliteStatementHandle stmt, int index, string value)
 {
     if (stmt == null)
     {
         throw new ArgumentNullException(nameof(stmt));
     }
     stmt.CheckMaintenanceMode();
     return((SqliteResultCode)DbProviderOperations.sqlite3_bind_text(stmt.Statement, index, value));
 }
예제 #7
0
 /// <summary> Sqlite 3 bind parameter index. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <param name="stmt"> The statement. </param>
 /// <param name="name"> The name. </param>
 /// <returns> An int. </returns>
 internal int sqlite3_bind_parameter_index(SqliteStatementHandle stmt, string name)
 {
     if (stmt == null)
     {
         throw new ArgumentNullException(nameof(stmt));
     }
     stmt.CheckMaintenanceMode();
     return(DbProviderOperations.sqlite3_bind_parameter_index(stmt.Statement, name));
 }
예제 #8
0
 /// <summary> Sqlite 3 backup pagecount. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <param name="backup"> The backup. </param>
 /// <returns> An int. </returns>
 internal int sqlite3_backup_pagecount(SqliteBackupHandle backup)
 {
     if (backup == null)
     {
         throw new ArgumentNullException(nameof(backup));
     }
     backup.CheckMaintenanceMode();
     return(DbProviderOperations.sqlite3_backup_remaining(backup.Backup));
 }
예제 #9
0
 /// <summary> Sqlite 3 total changes. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <exception cref="ArgumentException"> Thrown when one or more arguments have unsupported or
 ///     illegal values. </exception>
 /// <param name="db"> The database. </param>
 /// <param name="isMaintenanceDb"> (Optional) True if this object is maintenance database. </param>
 /// <returns> An int. </returns>
 internal int sqlite3_total_changes(SqliteDatabaseHandle db, bool isMaintenanceDb = false)
 {
     if (db == null)
     {
         throw new ArgumentNullException(nameof(db));
     }
     DbProvider.sqlite3 database = (isMaintenanceDb ? db.MaintenanceDb : db.Db)
                                   ?? throw new ArgumentException((isMaintenanceDb
                                           ? "Maintenance mode is specified, but the database is not in Maintenance Mode."
                                           : "The database is in Maintenance Mode, but this was not properly specified."),
                                                                  nameof(isMaintenanceDb));
     return(DbProviderOperations.sqlite3_total_changes(database));
 }
예제 #10
0
 /// <summary> Handler, called when the sqlite 3 progress. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <exception cref="ArgumentException"> Thrown when one or more arguments have unsupported or
 ///     illegal values. </exception>
 /// <param name="db"> The database. </param>
 /// <param name="virtualMachineInstructions"> The virtual machine instructions. </param>
 /// <param name="func"> The function. </param>
 /// <param name="value"> The value. </param>
 /// <param name="isMaintenanceDb"> (Optional) True if this object is maintenance database. </param>
 internal void sqlite3_progress_handler(SqliteDatabaseHandle db, int virtualMachineInstructions, DbProvider.delegate_progress_handler func, object value, bool isMaintenanceDb = false)
 {
     if (db == null)
     {
         throw new ArgumentNullException(nameof(db));
     }
     DbProvider.sqlite3 database = (isMaintenanceDb ? db.MaintenanceDb : db.Db)
                                   ?? throw new ArgumentException((isMaintenanceDb
                                           ? "Maintenance mode is specified, but the database is not in Maintenance Mode."
                                           : "The database is in Maintenance Mode, but this was not properly specified."),
                                                                  nameof(isMaintenanceDb));
     DbProviderOperations.sqlite3_progress_handler(database, virtualMachineInstructions, func, value);
 }
예제 #11
0
 /// <summary> Sqlite 3 busy timeout. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <exception cref="ArgumentException"> Thrown when one or more arguments have unsupported or
 ///     illegal values. </exception>
 /// <param name="db"> The database. </param>
 /// <param name="milliseconds"> The milliseconds. </param>
 /// <param name="isMaintenanceDb"> (Optional) True if this object is maintenance database. </param>
 /// <returns> A SqliteResultCode. </returns>
 internal SqliteResultCode sqlite3_busy_timeout(SqliteDatabaseHandle db, int milliseconds, bool isMaintenanceDb = false)
 {
     if (db == null)
     {
         throw new ArgumentNullException(nameof(db));
     }
     DbProvider.sqlite3 database = (isMaintenanceDb ? db.MaintenanceDb : db.Db)
                                   ?? throw new ArgumentException((isMaintenanceDb
                                           ? "Maintenance mode is specified, but the database is not in Maintenance Mode."
                                           : "The database is in Maintenance Mode, but this was not properly specified."),
                                                                  nameof(isMaintenanceDb));
     return((SqliteResultCode)DbProviderOperations.sqlite3_busy_timeout(database, milliseconds));
 }
예제 #12
0
 /// <summary> Sqlite 3 last insert rowid. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <exception cref="ArgumentException"> Thrown when one or more arguments have unsupported or
 ///     illegal values. </exception>
 /// <param name="db"> The database. </param>
 /// <param name="isMaintenanceDb"> (Optional) True if this object is maintenance database. </param>
 /// <returns> A long. </returns>
 internal long sqlite3_last_insert_rowid(SqliteDatabaseHandle db, bool isMaintenanceDb = false)
 {
     if (db == null)
     {
         throw new ArgumentNullException(nameof(db));
     }
     lock (_stepLocker) {
         DbProvider.sqlite3 database = (isMaintenanceDb ? db.MaintenanceDb : db.Db)
                                       ?? throw new ArgumentException((isMaintenanceDb
                                               ? "Maintenance mode is specified, but the database is not in Maintenance Mode."
                                               : "The database is in Maintenance Mode, but this was not properly specified."),
                                                                      nameof(isMaintenanceDb));
         return(DbProviderOperations.sqlite3_last_insert_rowid(database));
     }
 }
예제 #13
0
 /// <summary> Sqlite 3 step return rowid. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <param name="db"> The database. </param>
 /// <param name="stmt"> The statement. </param>
 /// <param name="code"> [out] The code. </param>
 /// <returns> A long. </returns>
 internal long sqlite3_step_return_rowid(SqliteDatabaseHandle db, SqliteStatementHandle stmt, out SqliteResultCode code)
 {
     if (db == null)
     {
         throw new ArgumentNullException(nameof(db));
     }
     if (stmt == null)
     {
         throw new ArgumentNullException(nameof(stmt));
     }
     lock (_stepLocker) {
         stmt.CheckMaintenanceMode();
         code = (SqliteResultCode)DbProviderOperations.sqlite3_step(stmt.Statement);
         return(code.IsSuccessCode()
             ? DbProviderOperations.sqlite3_last_insert_rowid(stmt.ForMaintenance ? db.MaintenanceDb : db.Db)
             : -1);
     }
 }
예제 #14
0
        /// <summary> Sqlite 3 backup initialize. </summary>
        /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
        /// <exception cref="ArgumentOutOfRangeException"> Thrown when one or more arguments are outside
        ///     the required range. </exception>
        /// <exception cref="InvalidOperationException"> Thrown when the requested operation is invalid. </exception>
        /// <exception cref="SqliteException"> Thrown when a Sqlite error condition occurs. </exception>
        /// <param name="destinationDb"> Destination database. </param>
        /// <param name="destinationName"> Name of the destination. </param>
        /// <param name="sourceDb"> Source database. </param>
        /// <param name="sourceName"> Name of the source. </param>
        /// <returns> A SqliteBackupHandle. </returns>
        internal SqliteBackupHandle sqlite3_backup_init(
            SqliteDatabaseHandle destinationDb,
            string destinationName,
            SqliteDatabaseHandle sourceDb,
            string sourceName)
        {
            if (destinationDb == null)
            {
                throw new ArgumentNullException(nameof(destinationDb));
            }
            if (sourceDb == null)
            {
                throw new ArgumentNullException(nameof(sourceDb));
            }
            if (String.IsNullOrWhiteSpace(destinationName))
            {
                throw new ArgumentOutOfRangeException(nameof(destinationName));
            }
            if (String.IsNullOrWhiteSpace(sourceName))
            {
                throw new ArgumentOutOfRangeException(nameof(sourceName));
            }

            if (!destinationDb.IsDatabaseInMaintenanceMode)
            {
                throw new InvalidOperationException("The destination database is not currently in maintenance mode.");
            }

            if (!sourceDb.IsDatabaseInMaintenanceMode)
            {
                throw new InvalidOperationException("The source database is not currently in maintenance mode.");
            }

            DbProvider.sqlite3_backup result = DbProviderOperations.sqlite3_backup_init(destinationDb.MaintenanceDb, destinationName,
                                                                                        sourceDb.MaintenanceDb, sourceName);

            if (result == null)
            {
                throw new SqliteException("The resulting backup handle was NULL", SqliteResultCode.Empty);
            }

            return(new SqliteBackupHandle(destinationDb, destinationName, sourceDb, sourceName, result));
        }
예제 #15
0
 /// <summary> Sqlite 3 errstr. </summary>
 /// <param name="rc"> The rectangle. </param>
 /// <returns> A string. </returns>
 internal string sqlite3_errstr(SqliteResultCode rc)
 {
     return(DbProviderOperations.sqlite3_errstr((int)rc));
 }
예제 #16
0
 /// <summary> Sqlite 3 configuration log. </summary>
 /// <param name="func"> The function. </param>
 /// <param name="value"> The value. </param>
 internal void sqlite3_config_log(DbProvider.delegate_log func, object value)
 {
     DbProviderOperations.sqlite3_config_log(func, value);
 }