summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/util-sql-imp-ffi.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-08-21 09:24:39 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2018-08-21 09:24:39 +0200
commit990e593fc4ae1da7568f52ba2c61539ba4e79069 (patch)
tree42c5dd9afb6c9d21b7fdadff7adb496ba93e4ffc /tex/context/base/mkiv/util-sql-imp-ffi.lua
parenteac3559b6b0ef831294368a3a835070ecd7c44fc (diff)
downloadcontext-990e593fc4ae1da7568f52ba2c61539ba4e79069.tar.gz
2018-08-21 08:41:00
Diffstat (limited to 'tex/context/base/mkiv/util-sql-imp-ffi.lua')
-rw-r--r--tex/context/base/mkiv/util-sql-imp-ffi.lua31
1 files changed, 25 insertions, 6 deletions
diff --git a/tex/context/base/mkiv/util-sql-imp-ffi.lua b/tex/context/base/mkiv/util-sql-imp-ffi.lua
index 6f1555f7c..e18736171 100644
--- a/tex/context/base/mkiv/util-sql-imp-ffi.lua
+++ b/tex/context/base/mkiv/util-sql-imp-ffi.lua
@@ -191,10 +191,10 @@ local ffi_tostring = ffi.string
local ffi_gc = ffi.gc
----- mysqldata = ffi.cast("MYSQL_instance*",mysql.malloc(1024*1024))
--- local instance = mysql.mysql_init(nil) -- (mysqldata)
+local instance = mysql.mysql_init(nil) -- (mysqldata)
-local instance = ffi.cast("MYSQL_instance*",mysql.malloc(1024*1024))
-local success = mysql.mysql_init(mysqldata)
+-- local instance = ffi.cast("MYSQL_instance*",mysql.malloc(1024*1024))
+-- local success = mysql.mysql_init(mysqldata)
local mysql_constant_false = false
local mysql_constant_true = true
@@ -309,7 +309,8 @@ local function execute(t,query)
return false
end
-local mt = { __index = {
+local mt = {
+ __index = {
close = close,
execute = execute,
}
@@ -475,6 +476,20 @@ local function datafetched(specification,query,converter)
elseif message then
report_state("message %s",message)
end
+
+ if not result then -- can go
+ if session then
+ session:close()
+ end
+ if connection then
+ connection:close()
+ end
+ if id then
+ cache[id] = nil
+ end
+ return "execution error"
+ end
+
if not keys then
keys = { }
end
@@ -482,8 +497,12 @@ local function datafetched(specification,query,converter)
data = { }
end
if not id then
- connection:close()
- session:close()
+ if connection then
+ connection:close()
+ end
+ if session then
+ session:close()
+ end
end
return data, keys
end