@@ -13,6 +13,7 @@ include("api.jl")
13
13
# Normal constructor from filename
14
14
sqliteopen (file, handle) = sqlite3_open (file, handle)
15
15
sqliteerror (db) = throw (SQLiteException (unsafe_string (sqlite3_errmsg (db. handle))))
16
+ sqliteexception (db) = SQLiteException (unsafe_string (sqlite3_errmsg (db. handle)))
16
17
17
18
"""
18
19
represents an SQLite database, either backed by an on-disk file or in-memory
@@ -138,14 +139,14 @@ function bind!(stmt::Stmt,name::AbstractString, val)
138
139
end
139
140
return bind! (stmt, i, val)
140
141
end
141
- bind! (stmt:: Stmt , i:: Int , val:: AbstractFloat ) = (stmt. params[i] = val; sqlite3_bind_double (stmt. handle, i ,Float64 (val)); return nothing )
142
- bind! (stmt:: Stmt , i:: Int , val:: Int32 ) = (stmt. params[i] = val; sqlite3_bind_int (stmt. handle, i ,val); return nothing )
143
- bind! (stmt:: Stmt , i:: Int , val:: Int64 ) = (stmt. params[i] = val; sqlite3_bind_int64 (stmt. handle, i ,val); return nothing )
144
- bind! (stmt:: Stmt , i:: Int , val:: Missing ) = (stmt. params[i] = val; sqlite3_bind_null (stmt. handle, i ); return nothing )
145
- bind! (stmt:: Stmt , i:: Int , val:: AbstractString ) = (stmt. params[i] = val; sqlite3_bind_text (stmt. handle, i ,val); return nothing )
146
- bind! (stmt:: Stmt , i:: Int , val:: WeakRefString{UInt8} ) = (stmt. params[i] = val; sqlite3_bind_text (stmt. handle, i, val. ptr, val. len); return nothing )
147
- bind! (stmt:: Stmt , i:: Int , val:: WeakRefString{UInt16} ) = (stmt. params[i] = val; sqlite3_bind_text16 (stmt. handle, i, val. ptr, val. len* 2 ); return nothing )
148
- bind! (stmt:: Stmt , i:: Int , val:: Vector{UInt8} ) = (stmt. params[i] = val; sqlite3_bind_blob (stmt. handle, i, val); return nothing )
142
+ bind! (stmt:: Stmt , i:: Int , val:: AbstractFloat ) = (stmt. params[i] = val; @CHECK stmt . db sqlite3_bind_double (stmt. handle, i ,Float64 (val)); return nothing )
143
+ bind! (stmt:: Stmt , i:: Int , val:: Int32 ) = (stmt. params[i] = val; @CHECK stmt . db sqlite3_bind_int (stmt. handle, i ,val); return nothing )
144
+ bind! (stmt:: Stmt , i:: Int , val:: Int64 ) = (stmt. params[i] = val; @CHECK stmt . db sqlite3_bind_int64 (stmt. handle, i ,val); return nothing )
145
+ bind! (stmt:: Stmt , i:: Int , val:: Missing ) = (stmt. params[i] = val; @CHECK stmt . db sqlite3_bind_null (stmt. handle, i ); return nothing )
146
+ bind! (stmt:: Stmt , i:: Int , val:: AbstractString ) = (stmt. params[i] = val; @CHECK stmt . db sqlite3_bind_text (stmt. handle, i ,val); return nothing )
147
+ bind! (stmt:: Stmt , i:: Int , val:: WeakRefString{UInt8} ) = (stmt. params[i] = val; @CHECK stmt . db sqlite3_bind_text (stmt. handle, i, val. ptr, val. len); return nothing )
148
+ bind! (stmt:: Stmt , i:: Int , val:: WeakRefString{UInt16} ) = (stmt. params[i] = val; @CHECK stmt . db sqlite3_bind_text16 (stmt. handle, i, val. ptr, val. len* 2 ); return nothing )
149
+ bind! (stmt:: Stmt , i:: Int , val:: Vector{UInt8} ) = (stmt. params[i] = val; @CHECK stmt . db sqlite3_bind_blob (stmt. handle, i, val); return nothing )
149
150
# Fallback is BLOB and defaults to serializing the julia value
150
151
151
152
# internal wrapper mutable struct to, in-effect, mark something which has been serialized
@@ -248,7 +249,9 @@ function execute!(stmt::Stmt)
248
249
if r == SQLITE_DONE
249
250
sqlite3_reset (stmt. handle)
250
251
elseif r != SQLITE_ROW
251
- sqliteerror (stmt. db)
252
+ e = sqliteexception (stmt. db)
253
+ sqlite3_reset (stmt. handle)
254
+ throw (e)
252
255
end
253
256
return r
254
257
end
0 commit comments