mirror of https://github.com/status-im/nim-eth.git
kvstore: remove unnecessary EH (#592)
This commit is contained in:
parent
ca1c205441
commit
72c9858927
|
@ -664,22 +664,18 @@ proc customScalarBlobFunction(ctx: ptr sqlite3_context, n: cint, v: ptr ptr sqli
|
||||||
toOpenArray(blob2, 0, blob2Len - 1)
|
toOpenArray(blob2, 0, blob2Len - 1)
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
if s.isOk():
|
||||||
if s.isOk():
|
let bytes = s.unsafeGet()
|
||||||
let bytes = s.unsafeGet()
|
# try is necessary as otherwise nim marks SQLITE_TRANSIENT as throwing
|
||||||
# try is necessary as otherwise nim marks SQLITE_TRANSIENT as throwing
|
# unlisted exception.
|
||||||
# unlisted exception.
|
# Using SQLITE_TRANSIENT destructor type, as it inform sqlite that data
|
||||||
# Using SQLITE_TRANSIENT destructor type, as it inform sqlite that data
|
# under provided pointer may be deleted at any moment, which is the case
|
||||||
# under provided pointer may be deleted at any moment, which is the case
|
# for seq[byte] as it is managed by nim gc. With this flag sqlite copy bytes
|
||||||
# for seq[byte] as it is managed by nim gc. With this flag sqlite copy bytes
|
# under pointer and then releases them itself.
|
||||||
# under pointer and then releases them itself.
|
sqlite3_result_blob(ctx, unsafeAddr bytes[0], bytes.len.cint, SQLITE_TRANSIENT)
|
||||||
sqlite3_result_blob(ctx, unsafeAddr bytes[0], bytes.len.cint, SQLITE_TRANSIENT)
|
else:
|
||||||
else:
|
let errMsg = s.error
|
||||||
let errMsg = s.error
|
sqlite3_result_error(ctx, errMsg, -1)
|
||||||
sqlite3_result_error(ctx, errMsg, -1)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
raiseAssert(e.msg)
|
|
||||||
|
|
||||||
proc registerCustomScalarFunction*(db: SqStoreRef, name: string, fun: CustomFunction): KvResult[void] =
|
proc registerCustomScalarFunction*(db: SqStoreRef, name: string, fun: CustomFunction): KvResult[void] =
|
||||||
## Register custom function inside sqlite engine. Registered function can
|
## Register custom function inside sqlite engine. Registered function can
|
||||||
|
|
Loading…
Reference in New Issue