mirror of
https://github.com/sbrow/envr.git
synced 2026-06-27 10:38:33 -04:00
refactor(sqlite): Used distinct types for Db and Stmt pointers.
This commit is contained in:
77
db.odin
77
db.odin
@@ -31,8 +31,7 @@ SyncError :: enum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Db :: struct {
|
Db :: struct {
|
||||||
// Pointer to the sqlite db
|
conn: ^sqlite.Db,
|
||||||
db: ^rawptr,
|
|
||||||
cfg: Config,
|
cfg: Config,
|
||||||
changed: bool,
|
changed: bool,
|
||||||
arena: mem.Dynamic_Arena,
|
arena: mem.Dynamic_Arena,
|
||||||
@@ -65,7 +64,7 @@ db_open :: proc(cfg_path: string) -> (database: Db, ok: bool) {
|
|||||||
data_path := data_path(database.cfg.config_path, context.temp_allocator)
|
data_path := data_path(database.cfg.config_path, context.temp_allocator)
|
||||||
if os.exists(data_path) {
|
if os.exists(data_path) {
|
||||||
if ok = db_restore_from_encrypted(&database, data_path); !ok {
|
if ok = db_restore_from_encrypted(&database, data_path); !ok {
|
||||||
sqlite.close(database.db)
|
sqlite.close(database.conn)
|
||||||
return database, false
|
return database, false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -79,21 +78,21 @@ db_open :: proc(cfg_path: string) -> (database: Db, ok: bool) {
|
|||||||
// Creates a database an allocator and fresh, empty table, with zero encryption.
|
// Creates a database an allocator and fresh, empty table, with zero encryption.
|
||||||
// In production, you most likely want to use `db_open`.
|
// In production, you most likely want to use `db_open`.
|
||||||
db_init :: proc() -> (database: Db, ok: bool) {
|
db_init :: proc() -> (database: Db, ok: bool) {
|
||||||
db: ^rawptr
|
conn: ^sqlite.Db
|
||||||
rc := sqlite.open(":memory:", &db)
|
rc := sqlite.open(":memory:", &conn)
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
fmt.printf("Error opening in-memory database: %s\n", sqlite.db_errmsg(db))
|
fmt.printf("Error opening in-memory database: %s\n", sqlite.db_errmsg(conn))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
create_sql: cstring = "CREATE TABLE IF NOT EXISTS envr_env_files (path TEXT PRIMARY KEY NOT NULL, remotes TEXT, sha256 TEXT NOT NULL, contents TEXT NOT NULL)"
|
create_sql: cstring = "CREATE TABLE IF NOT EXISTS envr_env_files (path TEXT PRIMARY KEY NOT NULL, remotes TEXT, sha256 TEXT NOT NULL, contents TEXT NOT NULL)"
|
||||||
rc = sqlite.db_exec(db, create_sql, nil, nil, nil)
|
rc = sqlite.db_exec(conn, create_sql, nil, nil, nil)
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
fmt.printf("Error creating table: %s\n", sqlite.db_errmsg(db))
|
fmt.printf("Error creating table: %s\n", sqlite.db_errmsg(conn))
|
||||||
sqlite.close(db)
|
sqlite.close(conn)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
database.db = db
|
database.conn = conn
|
||||||
|
|
||||||
mem.dynamic_arena_init(&database.arena)
|
mem.dynamic_arena_init(&database.arena)
|
||||||
|
|
||||||
@@ -128,7 +127,7 @@ db_restore_from_encrypted :: proc(db: ^Db, data_path: string) -> bool {
|
|||||||
copy(buf[:len(plaintext)], plaintext)
|
copy(buf[:len(plaintext)], plaintext)
|
||||||
|
|
||||||
rc := sqlite.deserialize(
|
rc := sqlite.deserialize(
|
||||||
db.db,
|
db.conn,
|
||||||
"main",
|
"main",
|
||||||
buf,
|
buf,
|
||||||
n,
|
n,
|
||||||
@@ -137,7 +136,7 @@ db_restore_from_encrypted :: proc(db: ^Db, data_path: string) -> bool {
|
|||||||
)
|
)
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
sqlite.free(buf)
|
sqlite.free(buf)
|
||||||
fmt.printf("Error deserializing database: %s\n", sqlite.db_errmsg(db.db))
|
fmt.printf("Error deserializing database: %s\n", sqlite.db_errmsg(db.conn))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +147,7 @@ db_close :: proc(d: ^Db) {
|
|||||||
allocator := db_allocator(d)
|
allocator := db_allocator(d)
|
||||||
|
|
||||||
defer {
|
defer {
|
||||||
sqlite.close(d.db)
|
sqlite.close(d.conn)
|
||||||
|
|
||||||
delete_config(&d.cfg, allocator)
|
delete_config(&d.cfg, allocator)
|
||||||
|
|
||||||
@@ -156,14 +155,14 @@ db_close :: proc(d: ^Db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if d.changed {
|
if d.changed {
|
||||||
rc := sqlite.db_exec(d.db, "VACUUM", nil, nil, nil)
|
rc := sqlite.db_exec(d.conn, "VACUUM", nil, nil, nil)
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
fmt.printf("Error vacuuming database: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error vacuuming database: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sz: i64
|
sz: i64
|
||||||
data := sqlite.serialize(d.db, "main", &sz, 0)
|
data := sqlite.serialize(d.conn, "main", &sz, 0)
|
||||||
if data == nil {
|
if data == nil {
|
||||||
fmt.println("Error: failed to serialize database")
|
fmt.println("Error: failed to serialize database")
|
||||||
return
|
return
|
||||||
@@ -195,16 +194,16 @@ db_close :: proc(d: ^Db) {
|
|||||||
|
|
||||||
// Results will be freed when `db_close` is called.
|
// Results will be freed when `db_close` is called.
|
||||||
db_list :: proc(d: ^Db) -> ([]EnvFile, bool) {
|
db_list :: proc(d: ^Db) -> ([]EnvFile, bool) {
|
||||||
stmt: ^rawptr
|
stmt: ^sqlite.Stmt
|
||||||
rc := sqlite.prepare_v2(
|
rc := sqlite.prepare_v2(
|
||||||
d.db,
|
d.conn,
|
||||||
"SELECT path, remotes, sha256, contents FROM envr_env_files",
|
"SELECT path, remotes, sha256, contents FROM envr_env_files",
|
||||||
-1,
|
-1,
|
||||||
&stmt,
|
&stmt,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
fmt.printf("Error preparing query: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error preparing query: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
return []EnvFile{}, false
|
return []EnvFile{}, false
|
||||||
}
|
}
|
||||||
defer sqlite.finalize(stmt)
|
defer sqlite.finalize(stmt)
|
||||||
@@ -218,7 +217,7 @@ db_list :: proc(d: ^Db) -> ([]EnvFile, bool) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if rc != sqlite.ROW {
|
if rc != sqlite.ROW {
|
||||||
fmt.printf("Error stepping query: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error stepping query: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
#no_bounds_check return results[:], false
|
#no_bounds_check return results[:], false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,10 +254,10 @@ db_insert :: proc(d: ^Db, file: EnvFile) -> bool {
|
|||||||
sql: cstring =
|
sql: cstring =
|
||||||
"INSERT OR REPLACE INTO " +
|
"INSERT OR REPLACE INTO " +
|
||||||
"envr_env_files (path, remotes, sha256, contents) VALUES (?, ?, ?, ?)"
|
"envr_env_files (path, remotes, sha256, contents) VALUES (?, ?, ?, ?)"
|
||||||
stmt: ^rawptr
|
stmt: ^sqlite.Stmt
|
||||||
rc := sqlite.prepare_v2(d.db, sql, -1, &stmt, nil)
|
rc := sqlite.prepare_v2(d.conn, sql, -1, &stmt, nil)
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
fmt.printf("Error preparing insert: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error preparing insert: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
defer sqlite.finalize(stmt)
|
defer sqlite.finalize(stmt)
|
||||||
@@ -268,7 +267,7 @@ db_insert :: proc(d: ^Db, file: EnvFile) -> bool {
|
|||||||
defer delete(cpath)
|
defer delete(cpath)
|
||||||
rc = sqlite.bind_text(stmt, 1, cpath, -1, nil)
|
rc = sqlite.bind_text(stmt, 1, cpath, -1, nil)
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
fmt.printf("Error binding path: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error binding path: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +275,7 @@ db_insert :: proc(d: ^Db, file: EnvFile) -> bool {
|
|||||||
defer delete(cremotes)
|
defer delete(cremotes)
|
||||||
rc = sqlite.bind_text(stmt, 2, cremotes, -1, nil)
|
rc = sqlite.bind_text(stmt, 2, cremotes, -1, nil)
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
fmt.printf("Error binding remotes: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error binding remotes: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +283,7 @@ db_insert :: proc(d: ^Db, file: EnvFile) -> bool {
|
|||||||
defer delete(csha)
|
defer delete(csha)
|
||||||
rc = sqlite.bind_text(stmt, 3, csha, -1, nil)
|
rc = sqlite.bind_text(stmt, 3, csha, -1, nil)
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
fmt.printf("Error binding sha256: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error binding sha256: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,13 +291,13 @@ db_insert :: proc(d: ^Db, file: EnvFile) -> bool {
|
|||||||
defer delete(ccontents)
|
defer delete(ccontents)
|
||||||
rc = sqlite.bind_text(stmt, 4, ccontents, -1, nil)
|
rc = sqlite.bind_text(stmt, 4, ccontents, -1, nil)
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
fmt.printf("Error binding contents: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error binding contents: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = sqlite.step(stmt)
|
rc = sqlite.step(stmt)
|
||||||
if rc != sqlite.DONE {
|
if rc != sqlite.DONE {
|
||||||
fmt.printf("Error inserting: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error inserting: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,10 +308,10 @@ db_insert :: proc(d: ^Db, file: EnvFile) -> bool {
|
|||||||
// Result will be freed when `db_close` is called.
|
// Result will be freed when `db_close` is called.
|
||||||
db_fetch :: proc(d: ^Db, path: string) -> (EnvFile, bool) {
|
db_fetch :: proc(d: ^Db, path: string) -> (EnvFile, bool) {
|
||||||
sql: cstring = "SELECT path, remotes, sha256, contents FROM envr_env_files WHERE path = ?"
|
sql: cstring = "SELECT path, remotes, sha256, contents FROM envr_env_files WHERE path = ?"
|
||||||
stmt: ^rawptr
|
stmt: ^sqlite.Stmt
|
||||||
rc := sqlite.prepare_v2(d.db, sql, -1, &stmt, nil)
|
rc := sqlite.prepare_v2(d.conn, sql, -1, &stmt, nil)
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
fmt.printf("Error preparing fetch: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error preparing fetch: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
return EnvFile{}, false
|
return EnvFile{}, false
|
||||||
}
|
}
|
||||||
defer sqlite.finalize(stmt)
|
defer sqlite.finalize(stmt)
|
||||||
@@ -323,7 +322,7 @@ db_fetch :: proc(d: ^Db, path: string) -> (EnvFile, bool) {
|
|||||||
defer delete(cpath, allocator)
|
defer delete(cpath, allocator)
|
||||||
rc = sqlite.bind_text(stmt, 1, cpath, -1, nil)
|
rc = sqlite.bind_text(stmt, 1, cpath, -1, nil)
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
fmt.printf("Error binding path: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error binding path: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
return EnvFile{}, false
|
return EnvFile{}, false
|
||||||
}
|
}
|
||||||
rc = sqlite.step(stmt)
|
rc = sqlite.step(stmt)
|
||||||
@@ -332,7 +331,7 @@ db_fetch :: proc(d: ^Db, path: string) -> (EnvFile, bool) {
|
|||||||
return EnvFile{}, false
|
return EnvFile{}, false
|
||||||
}
|
}
|
||||||
if rc != sqlite.ROW {
|
if rc != sqlite.ROW {
|
||||||
fmt.printf("Error fetching: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error fetching: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
return EnvFile{}, false
|
return EnvFile{}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,10 +355,10 @@ db_fetch :: proc(d: ^Db, path: string) -> (EnvFile, bool) {
|
|||||||
|
|
||||||
db_delete :: proc(d: ^Db, path: string) -> bool {
|
db_delete :: proc(d: ^Db, path: string) -> bool {
|
||||||
sql: cstring = "DELETE FROM envr_env_files WHERE path = ?"
|
sql: cstring = "DELETE FROM envr_env_files WHERE path = ?"
|
||||||
stmt: ^rawptr
|
stmt: ^sqlite.Stmt
|
||||||
rc := sqlite.prepare_v2(d.db, sql, -1, &stmt, nil)
|
rc := sqlite.prepare_v2(d.conn, sql, -1, &stmt, nil)
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
fmt.printf("Error preparing delete: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error preparing delete: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
defer sqlite.finalize(stmt)
|
defer sqlite.finalize(stmt)
|
||||||
@@ -368,16 +367,16 @@ db_delete :: proc(d: ^Db, path: string) -> bool {
|
|||||||
defer delete(cpath)
|
defer delete(cpath)
|
||||||
rc = sqlite.bind_text(stmt, 1, cpath, -1, nil)
|
rc = sqlite.bind_text(stmt, 1, cpath, -1, nil)
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
fmt.printf("Error binding path: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error binding path: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
rc = sqlite.step(stmt)
|
rc = sqlite.step(stmt)
|
||||||
if rc != sqlite.DONE {
|
if rc != sqlite.DONE {
|
||||||
fmt.printf("Error deleting: %s\n", sqlite.db_errmsg(d.db))
|
fmt.printf("Error deleting: %s\n", sqlite.db_errmsg(d.conn))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if sqlite.changes(d.db) == 0 {
|
if sqlite.changes(d.conn) == 0 {
|
||||||
fmt.printf("No file found with path: %s\n", path)
|
fmt.printf("No file found with path: %s\n", path)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ test_decrypt_then_deserialize_sqlite :: proc(t: ^testing.T) {
|
|||||||
}
|
}
|
||||||
defer delete(plaintext)
|
defer delete(plaintext)
|
||||||
|
|
||||||
mem_db: ^rawptr
|
mem_db: ^sqlite.Db
|
||||||
rc := sqlite.open(":memory:", &mem_db)
|
rc := sqlite.open(":memory:", &mem_db)
|
||||||
testing.expectf(t, rc == sqlite.OK, "failed to open in-memory db")
|
testing.expectf(t, rc == sqlite.OK, "failed to open in-memory db")
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
@@ -194,7 +194,7 @@ test_decrypt_then_deserialize_sqlite :: proc(t: ^testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sql: cstring = "SELECT path FROM envr_env_files"
|
sql: cstring = "SELECT path FROM envr_env_files"
|
||||||
stmt: ^rawptr
|
stmt: ^sqlite.Stmt
|
||||||
rc = sqlite.prepare_v2(mem_db, sql, -1, &stmt, nil)
|
rc = sqlite.prepare_v2(mem_db, sql, -1, &stmt, nil)
|
||||||
testing.expect(t, rc == sqlite.OK, "prepare failed")
|
testing.expect(t, rc == sqlite.OK, "prepare failed")
|
||||||
if rc != sqlite.OK {
|
if rc != sqlite.OK {
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ test_db_serialize :: proc(t: ^testing.T) {
|
|||||||
db_insert(&d, f)
|
db_insert(&d, f)
|
||||||
|
|
||||||
sz: i64
|
sz: i64
|
||||||
data := sqlite.serialize(d.db, "main", &sz, 0)
|
data := sqlite.serialize(d.conn, "main", &sz, 0)
|
||||||
testing.expect(t, data != nil, "serialize should return non-nil")
|
testing.expect(t, data != nil, "serialize should return non-nil")
|
||||||
if data == nil do return
|
if data == nil do return
|
||||||
defer sqlite.free(data)
|
defer sqlite.free(data)
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import "core:c"
|
|||||||
|
|
||||||
foreign import lib "system:sqlite3"
|
foreign import lib "system:sqlite3"
|
||||||
|
|
||||||
|
Db :: distinct rawptr
|
||||||
|
Stmt :: distinct rawptr
|
||||||
|
|
||||||
|
// TODO: Use an enum?
|
||||||
OK :: 0
|
OK :: 0
|
||||||
ROW :: 100
|
ROW :: 100
|
||||||
DONE :: 101
|
DONE :: 101
|
||||||
@@ -13,31 +17,31 @@ DESERIALIZE_RESIZEABLE :: 2
|
|||||||
|
|
||||||
foreign lib {
|
foreign lib {
|
||||||
@(link_name = "sqlite3_open")
|
@(link_name = "sqlite3_open")
|
||||||
open :: proc(filename: cstring, ppDb: ^^rawptr) -> c.int ---
|
open :: proc(filename: cstring, ppDb: ^^Db) -> c.int ---
|
||||||
@(link_name = "sqlite3_close")
|
@(link_name = "sqlite3_close")
|
||||||
close :: proc(db: ^rawptr) -> c.int ---
|
close :: proc(db: ^Db) -> c.int ---
|
||||||
@(link_name = "sqlite3_errmsg")
|
@(link_name = "sqlite3_errmsg")
|
||||||
db_errmsg :: proc(db: ^rawptr) -> cstring ---
|
db_errmsg :: proc(db: ^Db) -> cstring ---
|
||||||
@(link_name = "sqlite3_exec")
|
@(link_name = "sqlite3_exec")
|
||||||
db_exec :: proc(db: ^rawptr, sql: cstring, callback: rawptr, callback_arg: rawptr, errmsg: ^cstring) -> c.int ---
|
db_exec :: proc(db: ^Db, sql: cstring, callback: rawptr, callback_arg: rawptr, errmsg: ^cstring) -> c.int ---
|
||||||
@(link_name = "sqlite3_prepare_v2")
|
@(link_name = "sqlite3_prepare_v2")
|
||||||
prepare_v2 :: proc(db: ^rawptr, sql: cstring, nByte: c.int, ppStmt: ^^rawptr, pzTail: ^cstring) -> c.int ---
|
prepare_v2 :: proc(db: ^Db, sql: cstring, nByte: c.int, ppStmt: ^^Stmt, pzTail: ^cstring) -> c.int ---
|
||||||
@(link_name = "sqlite3_step")
|
@(link_name = "sqlite3_step")
|
||||||
step :: proc(stmt: ^rawptr) -> c.int ---
|
step :: proc(stmt: ^Stmt) -> c.int ---
|
||||||
@(link_name = "sqlite3_finalize")
|
@(link_name = "sqlite3_finalize")
|
||||||
finalize :: proc(stmt: ^rawptr) -> c.int ---
|
finalize :: proc(stmt: ^Stmt) -> c.int ---
|
||||||
@(link_name = "sqlite3_column_text")
|
@(link_name = "sqlite3_column_text")
|
||||||
column_text :: proc(stmt: ^rawptr, iCol: c.int) -> cstring ---
|
column_text :: proc(stmt: ^Stmt, iCol: c.int) -> cstring ---
|
||||||
@(link_name = "sqlite3_column_bytes")
|
@(link_name = "sqlite3_column_bytes")
|
||||||
column_bytes :: proc(stmt: ^rawptr, iCol: c.int) -> c.int ---
|
column_bytes :: proc(stmt: ^Stmt, iCol: c.int) -> c.int ---
|
||||||
@(link_name = "sqlite3_bind_text")
|
@(link_name = "sqlite3_bind_text")
|
||||||
bind_text :: proc(stmt: ^rawptr, idx: c.int, val: cstring, n: c.int, destructor: rawptr) -> c.int ---
|
bind_text :: proc(stmt: ^Stmt, idx: c.int, val: cstring, n: c.int, destructor: rawptr) -> c.int ---
|
||||||
@(link_name = "sqlite3_changes")
|
@(link_name = "sqlite3_changes")
|
||||||
changes :: proc(db: ^rawptr) -> c.int ---
|
changes :: proc(db: ^Db) -> c.int ---
|
||||||
@(link_name = "sqlite3_serialize")
|
@(link_name = "sqlite3_serialize")
|
||||||
serialize :: proc(db: ^rawptr, zSchema: cstring, piSize: ^i64, mFlags: u32) -> [^]u8 ---
|
serialize :: proc(db: ^Db, zSchema: cstring, piSize: ^i64, mFlags: u32) -> [^]u8 ---
|
||||||
@(link_name = "sqlite3_deserialize")
|
@(link_name = "sqlite3_deserialize")
|
||||||
deserialize :: proc(db: ^rawptr, zSchema: cstring, pData: [^]u8, szDb: i64, szBuf: i64, mFlags: u32) -> c.int ---
|
deserialize :: proc(db: ^Db, zSchema: cstring, pData: [^]u8, szDb: i64, szBuf: i64, mFlags: u32) -> c.int ---
|
||||||
@(link_name = "sqlite3_malloc64")
|
@(link_name = "sqlite3_malloc64")
|
||||||
malloc64 :: proc(n: i64) -> [^]u8 ---
|
malloc64 :: proc(n: i64) -> [^]u8 ---
|
||||||
@(link_name = "sqlite3_free")
|
@(link_name = "sqlite3_free")
|
||||||
|
|||||||
Reference in New Issue
Block a user