Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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));
 }
Ejemplo n.º 6
0
 public static int sqlite3_extended_errcode(SafeSqliteHandle db)
 {
     using var _ = db.Lease();
     return(raw.sqlite3_extended_errcode(db.DangerousGetWrapper()));
 }
Ejemplo n.º 7
0
 public static string sqlite3_errmsg(SafeSqliteHandle db)
 {
     using var _ = db.Lease();
     return(raw.sqlite3_errmsg(db.DangerousGetWrapper()).utf8_to_string());
 }
Ejemplo n.º 8
0
 public static long sqlite3_last_insert_rowid(SafeSqliteHandle db)
 {
     using var _ = db.Lease();
     return(raw.sqlite3_last_insert_rowid(db.DangerousGetWrapper()));
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 11
0
 public SafeSqliteBlobHandle(SafeSqliteHandle sqliteHandle, sqlite3_blob?wrapper)
     : base(sqliteHandle, wrapper?.ptr ?? IntPtr.Zero, wrapper)
 {
 }