summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/util-sql.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/util-sql.lua')
-rw-r--r--tex/context/base/mkiv/util-sql.lua26
1 files changed, 20 insertions, 6 deletions
diff --git a/tex/context/base/mkiv/util-sql.lua b/tex/context/base/mkiv/util-sql.lua
index 09056c048..d01a2267c 100644
--- a/tex/context/base/mkiv/util-sql.lua
+++ b/tex/context/base/mkiv/util-sql.lua
@@ -103,17 +103,21 @@ local defaults = { __index =
variables = { },
username = "default",
password = "default",
- host = "localhost",
+ host = "localhost", -- 127.0.0.1 is sometimes more reliable
port = 3306,
database = "default",
},
}
setmetatableindex(sql.methods,function(t,k)
- report_state("start loading method %a",k)
- require("util-sql-imp-"..k)
- report_state("loading method %a done",k)
- return rawget(t,k)
+ if type(k) == "string" then
+ report_state("start loading method %a",k)
+ require("util-sql-imp-"..k)
+ report_state("loading method %a done",k)
+ return rawget(t,k)
+ else
+ report_state("invalid method %a",tostring(k))
+ end
end)
-- converters
@@ -285,7 +289,13 @@ local currentmethod
local currentserver
local function firstexecute(...)
- local execute = methods[currentmethod].execute
+ local method = methods[currentmethod]
+ if not method then
+ report_state("invalid sql method")
+ sql.execute = function() end
+ return nil
+ end
+ local execute = method.execute
sql.execute = execute
return execute(...)
end
@@ -326,6 +336,10 @@ function sql.usedatabase(presets,datatable)
if not method then
usedmethod = sql.methods.client
method = usedmethod and sqlmethods[usedmethod]
+ if not method then
+ report_state("invalid method")
+ return
+ end
end
local base = presets.database or "test"
local basename = format("`%s`.`%s`",base,name)