sqlite3_reset() private method

private sqlite3_reset ( IntPtr stmt ) : int
stmt IntPtr
return int
示例#1
0
        internal static void ResetConnection(SqliteConnectionHandle db)
        {
            lock (_lock)
            {
                IntPtr stmt = IntPtr.Zero;

                do
                {
                    stmt = UnsafeNativeMethods.sqlite3_next_stmt(db, stmt);
                    if (stmt != IntPtr.Zero)
                    {
#if !SQLITE_STANDARD
                        UnsafeNativeMethods.sqlite3_reset_interop(stmt);
#else
                        UnsafeNativeMethods.sqlite3_reset(stmt);
#endif
                    }
                } while (stmt != IntPtr.Zero);

                // Not overly concerned with the return value from a rollback.
                UnsafeNativeMethods.sqlite3_exec(db, ToUTF8("ROLLBACK"), IntPtr.Zero, IntPtr.Zero, out stmt);
                // but free the error message if any!
                if (stmt != IntPtr.Zero)
                {
                    UnsafeNativeMethods.sqlite3_free(stmt);
                }
            }
        }
        internal static void ResetConnection(SqliteConnectionHandle db)
        {
            lock (_lock)
            {
                SqliteStatementHandle stmt = null;
                do
                {
                    stmt = UnsafeNativeMethods.sqlite3_next_stmt(db, stmt);
                    if (stmt != null)
                    {
                        UnsafeNativeMethods.sqlite3_reset(stmt);
                    }
                } while (stmt != null);

                // Not overly concerned with the return value from a rollback.
                string msg = null;
                UnsafeNativeMethods.sqlite3_exec(db, "ROLLBACK", out msg);
            }
        }
示例#3
0
        internal override int Reset(SqliteStatement stmt)
        {
            int n;

#if !SQLITE_STANDARD
            n = UnsafeNativeMethods.sqlite3_reset_interop(stmt._sqlite_stmt);
#else
            n = UnsafeNativeMethods.sqlite3_reset(stmt._sqlite_stmt);
#endif

            // If the schema changed, try and re-prepare it
            if (n == 17) // SQLITE_SCHEMA
            {
                // Recreate a dummy statement
                string str;
                using (SqliteStatement tmp = Prepare(null, stmt._sqlStatement, null, (uint)(stmt._command._commandTimeout * 1000), out str))
                {
                    // Finalize the existing statement
                    stmt._sqlite_stmt.Dispose();
                    // Reassign a new statement pointer to the old statement and clear the temporary one
                    stmt._sqlite_stmt = tmp._sqlite_stmt;
                    tmp._sqlite_stmt  = null;

                    // Reapply parameters
                    stmt.BindParameters();
                }
                return(-1);            // Reset was OK, with schema change
            }
            else if (n == 6 || n == 5) // SQLITE_LOCKED || SQLITE_BUSY
            {
                return(n);
            }

            if (n > 0)
            {
                throw new SqliteException(n, SQLiteLastError());
            }

            return(0); // We reset OK, no schema changes
        }
示例#4
0
        internal override int Reset(SqliteStatement stmt)
        {
            int n;

            n = UnsafeNativeMethods.sqlite3_reset(stmt._sqlite_stmt);

            // If the schema changed, try and re-prepare it
            if (n == 17) // SQLITE_SCHEMA
            {
                // Recreate a dummy statement
                string str;
                using (SqliteStatement tmp = Prepare(stmt._sqlStatement, null, out str))
                {
                    // Finalize the existing statement
                    FinalizeStatement(stmt);

                    // Reassign a new statement pointer to the old statement and clear the temporary one
                    stmt._sqlite_stmt = tmp._sqlite_stmt;
                    tmp._sqlite_stmt  = IntPtr.Zero;

                    // Reapply parameters
                    stmt.BindParameters();
                }
                return(-1);  // Reset was OK, with schema change
            }
            else if (n == 6) // SQLITE_LOCKED
            {
                return(n);
            }

            if (n > 0)
            {
                throw new SqliteException(n, SqliteLastError());
            }

            return(0); // We reset OK, no schema changes
        }