From c209ed36b6aaaa992df8976789c8ba8112f8e5c5 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Sun, 4 Sep 2016 15:04:09 +0200 Subject: 2016-09-04 13:51:00 --- tex/context/base/mkiv/util-sql.lua | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'tex/context/base/mkiv/util-sql.lua') diff --git a/tex/context/base/mkiv/util-sql.lua b/tex/context/base/mkiv/util-sql.lua index 023c7809a..a0578f086 100644 --- a/tex/context/base/mkiv/util-sql.lua +++ b/tex/context/base/mkiv/util-sql.lua @@ -311,15 +311,30 @@ sql.setserver("mysql") -- helper: +local sqlmethods = sql.methods + function sql.usedatabase(presets,datatable) local name = datatable or presets.datatable if name then - local method = presets.method and sql.methods[presets.method] or sql.methods.client + local usedmethod = presets.method + local method = usedmethod and sqlmethods[usedmethod] + if not method then + usedmethod = currentmethod + method = usedmethod and sqlmethods[usedmethod] + end + if not method then + usedmethod = sql.methods.client + method = usedmethod and sqlmethods[usedmethod] + end local base = presets.database or "test" local basename = format("`%s`.`%s`",base,name) local execute = nil local m_execute = method.execute - if method.usesfiles then + if not m_execute then + execute = function() + report_state("no valid execute handler") + end + elseif method.usesfiles then local queryfile = presets.queryfile or format("%s-temp.sql",name) local resultfile = presets.resultfile or format("%s-temp.dat",name) execute = function(specification) -- variables template @@ -347,6 +362,7 @@ function sql.usedatabase(presets,datatable) end end return { + usedmethod = usedmethod, presets = preset, base = base, name = name, -- cgit v1.2.3