summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/util-sql.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/util-sql.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/util-sql.lua26
1 files changed, 20 insertions, 6 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/util-sql.lua b/Master/texmf-dist/tex/context/base/mkiv/util-sql.lua
index 09056c0484c..d01a2267cf6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/util-sql.lua
+++ b/Master/texmf-dist/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)