@@ -244,6 +244,7 @@ class Database
244
244
@db = getValue (apiTemp, ' i32' )
245
245
RegisterExtensionFunctions (@db )
246
246
@statements = {} # A list of all prepared statements of the database
247
+ @functions = [] # A list of all user function (created by create_function call) of the database
247
248
248
249
### Execute an SQL query, ignoring the rows it returns.
249
250
@@ -395,6 +396,7 @@ class Database
395
396
###
396
397
' export ' : ->
397
398
stmt[' free' ]() for _,stmt of @statements
399
+ removeFunction (func) for func in @functions
398
400
@ handleError sqlite3_close_v2 @db
399
401
binaryDb = FS .readFile @filename , encoding : ' binary'
400
402
@ handleError sqlite3_open @filename , apiTemp
@@ -414,6 +416,7 @@ class Database
414
416
###
415
417
' close ' : ->
416
418
stmt[' free' ]() for _,stmt of @statements
419
+ removeFunction (func) for func in @functions
417
420
@ handleError sqlite3_close_v2 @db
418
421
FS .unlink ' /' + @filename
419
422
@db = null
@@ -481,5 +484,6 @@ class Database
481
484
482
485
# Generate a pointer to the wrapped, user defined function, and register with SQLite.
483
486
func_ptr = addFunction (wrapped_func)
487
+ @functions .push (func_ptr);
484
488
@ handleError sqlite3_create_function_v2 @db , name, func .length , SQLite .UTF8 , 0 , func_ptr, 0 , 0 , 0
485
489
return @
0 commit comments