Beispiel #1
0
        public static SafeSqliteStatementHandle sqlite3_prepare_v2(
            SafeSqliteHandle db,
            string sql,
            out Result result
            )
        {
            using var _ = db.Lease();

            result = (Result)raw.sqlite3_prepare_v2(db.DangerousGetWrapper(), sql, out var wrapper);
            if (result != (int)Result.OK)
            {
                wrapper = null;
            }

            try
            {
                // Always return a non-null handle to match default P/Invoke marshaling behavior. SafeHandle.IsInvalid
                // will be true when the handle is not usable, but the handle instance can be disposed either way.
                return(new SafeSqliteStatementHandle(db, wrapper));
            }
            catch
            {
                raw.sqlite3_finalize(wrapper);
                throw;
            }
        }
Beispiel #2
0
 public SafeSqliteBlobHandle(SafeSqliteHandle sqliteHandle, sqlite3_blob?wrapper)
     : base(invalidHandleValue: IntPtr.Zero, ownsHandle: true)
 {
     _wrapper = wrapper;
     SetHandle(wrapper?.ptr ?? IntPtr.Zero);
     _lease = sqliteHandle.Lease();
 }
        public SafeSqliteBlobHandle(SafeSqliteHandle sqliteHandle, sqlite3_blob?wrapper)
            : base(invalidHandleValue: IntPtr.Zero, ownsHandle: true)
        {
            _wrapper = wrapper;
            if (wrapper is not null)
            {
                _lease = wrapper.Lease();
                SetHandle(wrapper.DangerousGetHandle());
            }
            else
            {
                _lease = default;
                SetHandle(IntPtr.Zero);
            }

            _sqliteLease = sqliteHandle.Lease();
        }
Beispiel #4
0
        public static SafeSqliteBlobHandle sqlite3_blob_open(SafeSqliteHandle db, utf8z sdb, utf8z table, utf8z col, long rowid, int flags, out Result result)
        {
            using var _ = db.Lease();

            result = (Result)raw.sqlite3_blob_open(db.DangerousGetWrapper(), sdb, table, col, rowid, flags, out var wrapper);
            if (result != (int)Result.OK)
            {
                wrapper = null;
            }

            try
            {
                // Always return a non-null handle to match default P/Invoke marshaling behavior. SafeHandle.IsInvalid
                // will be true when the handle is not usable, but the handle instance can be disposed either way.
                return(new SafeSqliteBlobHandle(db, wrapper));
            }
            catch
            {
                raw.sqlite3_blob_close(wrapper);
                throw;
            }
        }
Beispiel #5
0
 public static Result sqlite3_busy_timeout(SafeSqliteHandle db, int ms)
 {
     using var _ = db.Lease();
     return((Result)raw.sqlite3_busy_timeout(db.DangerousGetWrapper(), ms));
 }
Beispiel #6
0
 public static int sqlite3_extended_errcode(SafeSqliteHandle db)
 {
     using var _ = db.Lease();
     return(raw.sqlite3_extended_errcode(db.DangerousGetWrapper()));
 }
Beispiel #7
0
 public static string sqlite3_errmsg(SafeSqliteHandle db)
 {
     using var _ = db.Lease();
     return(raw.sqlite3_errmsg(db.DangerousGetWrapper()).utf8_to_string());
 }
Beispiel #8
0
 public static long sqlite3_last_insert_rowid(SafeSqliteHandle db)
 {
     using var _ = db.Lease();
     return(raw.sqlite3_last_insert_rowid(db.DangerousGetWrapper()));
 }
Beispiel #9
0
 public static string sqlite3_errmsg(SafeSqliteHandle db)
 {
     using var _ = db.Lease();
     return(raw.sqlite3_errmsg(db.DangerousGetHandle()));
 }
 public SafeSqliteStatementHandle(SafeSqliteHandle sqliteHandle, sqlite3_stmt?wrapper)
     : base(sqliteHandle, wrapper?.ptr ?? IntPtr.Zero, wrapper)
 {
 }
 public SafeSqliteBlobHandle(SafeSqliteHandle sqliteHandle, sqlite3_blob?wrapper)
     : base(sqliteHandle, wrapper?.ptr ?? IntPtr.Zero, wrapper)
 {
 }