Beispiel #1
0
        public bool MoveNext()
        {
            if (disposed)
            {
                ThrowHelper.ThrowObjectDisposedException(this.GetType().FullName);
            }

            if (mustReset)
            {
                return(false);
            }

            int rc = raw.sqlite3_step(this.sqlite3_stmt);

            if (rc == raw.SQLITE_DONE)
            {
                mustReset = true;
                return(false);
            }
            else if (rc == raw.SQLITE_ROW)
            {
                return(true);
            }
            else
            {
                SQLiteException.CheckOk(this.sqlite3_stmt, rc);
                // Never gets returned
                return(false);
            }
        }
Beispiel #2
0
        public void Bind(string text)
        {
            Contract.Requires(text != null);

            int rc = raw.sqlite3_bind_text(stmt, index + 1, text);

            SQLiteException.CheckOk(stmt, rc);
        }
        public void Bind(byte[] blob)
        {
            Contract.Requires(blob != null);

            int rc = raw.sqlite3_bind_blob(stmt, index + 1, blob);

            SQLiteException.CheckOk(stmt, rc);
        }
Beispiel #4
0
        public void BindZeroBlob(int size)
        {
            Contract.Requires(size >= 0);

            int rc = raw.sqlite3_bind_zeroblob(stmt, index + 1, size);

            SQLiteException.CheckOk(stmt, rc);
        }
Beispiel #5
0
        internal static void CheckOk(sqlite3 db, int rc)
        {
            int extended = raw.sqlite3_extended_errcode(db);

            if (raw.SQLITE_OK != rc)
            {
                SQLiteException.Throw(rc, extended, raw.sqlite3_errmsg(db).utf8_to_string());
            }
        }
        internal static void CheckOk(sqlite3 db, int rc)
        {
            int extended = raw.sqlite3_extended_errcode(db);

            if (raw.SQLITE_OK != rc)
            {
                throw SQLiteException.Create(rc, extended, raw.sqlite3_errmsg(db));
            }
        }
        internal static Exception Create(ErrorCode rc, ErrorCode extended, string msg)
        {
            var exp = new SQLiteException(rc, extended, msg);

            if (rc == pretty.ErrorCode.Interrupt)
            {
                return(new OperationCanceledException(msg, exp));
            }
            return(exp);
        }
        internal static Exception Create(ErrorCode rc, ErrorCode extended, string msg)
        {
            var exp = new SQLiteException(rc, extended, msg);

            if (rc == pretty.ErrorCode.Interrupt)
            {
                return new OperationCanceledException(msg, exp);
            }
            return exp;
        }
Beispiel #9
0
 private static void CheckOkOrThrowIOException(int rc)
 {
     try
     {
         SQLiteException.CheckOk(rc);
     }
     catch (SQLiteException e)
     {
         ThrowHelper.ThrowIOException("Received SQLiteException", e);
     }
 }
Beispiel #10
0
        public void ClearBindings()
        {
            if (disposed)
            {
                ThrowHelper.ThrowObjectDisposedException(this.GetType().FullName);
            }

            int rc = raw.sqlite3_clear_bindings(this.sqlite3_stmt);

            SQLiteException.CheckOk(this.sqlite3_stmt, rc);
        }
Beispiel #11
0
        internal static void CheckOk(int rc)
        {
            string msg = string.Empty;

            if (SQLite3.Version.CompareTo(SQLiteVersion.Of(3007015)) >= 0)
            {
                msg = raw.sqlite3_errstr(rc).utf8_to_string();
            }

            if (raw.SQLITE_OK != rc)
            {
                SQLiteException.Throw(rc, rc, msg);
            }
        }
        internal static void CheckOk(int rc)
        {
            string msg = "";

            if (SQLite3.Version.CompareTo(SQLiteVersion.Of(3007015)) >= 0)
            {
                msg = raw.sqlite3_errstr(rc);
            }

            if (raw.SQLITE_OK != rc)
            {
                throw SQLiteException.Create(rc, rc, msg);
            }
        }
Beispiel #13
0
        public void Reset()
        {
            if (disposed)
            {
                ThrowHelper.ThrowObjectDisposedException(this.GetType().FullName);
            }

            // FIXME: Ignore the result code?
            // If the most recent call to sqlite3_step(S) for the prepared statement S
            // returned SQLITE_ROW or SQLITE_DONE, or if sqlite3_step(S) has never before been
            // called on S, then sqlite3_reset(S) returns SQLITE_OK.
            // If the most recent call to sqlite3_step(S) for the prepared statement S indicated an
            // error, then sqlite3_reset(S) returns an appropriate error code.

            mustReset = false;
            int rc = raw.sqlite3_reset(this.sqlite3_stmt);

            SQLiteException.CheckOk(stmt, rc);
        }
Beispiel #14
0
        public bool Step(int nPages)
        {
            if (disposed)
            {
                ThrowHelper.ThrowObjectDisposedException(this.GetType().FullName);
            }

            int rc = raw.sqlite3_backup_step(backup, nPages);

            if (rc == raw.SQLITE_OK)
            {
                return(true);
            }
            else if (rc == raw.SQLITE_DONE)
            {
                return(false);
            }
            else
            {
                SQLiteException.CheckOk(rc);
                // Never happens, exception always thrown.
                return(false);
            }
        }
Beispiel #15
0
        public void BindNull()
        {
            int rc = raw.sqlite3_bind_null(stmt, index + 1);

            SQLiteException.CheckOk(stmt, rc);
        }
Beispiel #16
0
        public void Bind(long val)
        {
            int rc = raw.sqlite3_bind_int64(stmt, index + 1, val);

            SQLiteException.CheckOk(stmt, rc);
        }
Beispiel #17
0
        public void Bind(double val)
        {
            int rc = raw.sqlite3_bind_double(stmt, index + 1, val);

            SQLiteException.CheckOk(stmt, rc);
        }
Beispiel #18
0
        public void Bind(ReadOnlySpan <byte> blob)
        {
            int rc = raw.sqlite3_bind_blob(stmt, index + 1, blob);

            SQLiteException.CheckOk(stmt, rc);
        }
Beispiel #19
0
        /// <summary>
        /// Retrieve runtime status information about the
        /// performance of SQLite, and optionally to reset various highwater marks.
        /// </summary>
        /// <seealso href="https://www.sqlite.org/c3ref/status.html"/>
        /// <param name="statusCode">The specific parameter to measure.</param>
        /// <param name="current">The current value of the performance metric.</param>
        /// <param name="highwater">The highwater value of the performance metric.</param>
        /// <param name="reset">If <see langword="true"/>, then the highest record value is reset.</param>
        public static void Status(SQLiteStatusCode statusCode, out int current, out int highwater, bool reset)
        {
            int rc = raw.sqlite3_status((int)statusCode, out current, out highwater, reset ? 1 : 0);

            SQLiteException.CheckOk(rc);
        }