summaryrefslogtreecommitdiff
path: root/tex/context/base/util-sql-imp-library.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/util-sql-imp-library.lua')
-rw-r--r--tex/context/base/util-sql-imp-library.lua129
1 files changed, 2 insertions, 127 deletions
diff --git a/tex/context/base/util-sql-imp-library.lua b/tex/context/base/util-sql-imp-library.lua
index 374a34350..05b4f5b06 100644
--- a/tex/context/base/util-sql-imp-library.lua
+++ b/tex/context/base/util-sql-imp-library.lua
@@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['util-sql-library'] = {
license = "see context related readme files"
}
+-- local function pcall(f,...) return true, f(...) end
+
-- For some reason the sql lib partially fails in luatex when creating hashed row. So far
-- we couldn't figure it out (some issue with adapting the table that is passes as first
-- argument in the fetch routine. Apart from this it looks like the mysql binding has some
@@ -91,133 +93,6 @@ local function connect(session,specification)
)
end
--- local function datafetched(specification,query,converter)
--- if not query or query == "" then
--- report_state("no valid query")
--- return { }, { }
--- end
--- local id = specification.id
--- local session, connection
--- if id then
--- local c = cache[id]
--- if c then
--- session = c.session
--- connection = c.connection
--- end
--- if not connection then
--- session = initialize()
--- connection = connect(session,specification)
--- cache[id] = { session = session, connection = connection }
--- end
--- else
--- session = initialize()
--- connection = connect(session,specification)
--- end
--- if not connection then
--- report_state("error in connection: %s@%s to %s:%s",
--- specification.database or "no database",
--- specification.username or "no username",
--- specification.host or "no host",
--- specification.port or "no port"
--- )
--- return { }, { }
--- end
--- query = lpegmatch(querysplitter,query)
--- local result, message, okay
--- -- todo: check if open !
--- for i=1,#query do
--- local q = query[i]
--- local r, m = connection:execute(q)
--- if m then
--- report_state("error in query, stage 1: %s",string.collapsespaces(q))
--- message = message and format("%s\n%s",message,m) or m
--- end
--- local t = type(r)
--- if t == "userdata" then
--- result = r
--- okay = true
--- elseif t == "number" then
--- okay = true
--- end
--- end
--- if not okay and id then -- can go
--- if session then
--- session:close()
--- end
--- if connection then
--- connection:close()
--- end
--- session = initialize() -- maybe not needed
--- connection = connect(session,specification)
--- if connection then
--- cache[id] = { session = session, connection = connection }
--- for i=1,#query do
--- local q = query[i]
--- local r, m = connection:execute(q)
--- if m then
--- report_state("error in query, stage 2: %s",string.collapsespaces(q))
--- message = message and format("%s\n%s",message,m) or m
--- end
--- local t = type(r)
--- if t == "userdata" then
--- result = r
--- okay = true
--- elseif t == "number" then
--- okay = true
--- end
--- end
--- else
--- message = "unable to connect"
--- report_state(message)
--- end
--- end
--- local data, keys
--- if result then
--- if converter then
--- data = converter.library(result)
--- -- data = converter(result)
--- else
--- keys = result:getcolnames()
--- if keys then
--- local n = result:numrows() or 0
--- if n == 0 then
--- data = { }
--- -- elseif n == 1 then
--- -- -- data = { result:fetch({},"a") }
--- else
--- data = { }
--- -- for i=1,n do
--- -- data[i] = result:fetch({},"a")
--- -- end
--- local k = #keys
--- for i=1,n do
--- local v = { result:fetch() }
--- local d = { }
--- for i=1,k do
--- d[keys[i]] = v[i]
--- end
--- data[#data+1] = d
--- end
--- end
--- end
--- end
--- result:close()
--- elseif message then
--- report_state("message %s",message)
--- end
--- if not keys then
--- keys = { }
--- end
--- if not data then
--- data = { }
--- end
--- if not id then
--- connection:close()
--- session:close()
--- end
--- return data, keys
--- end
-
local function fetched(specification,query,converter)
if not query or query == "" then
report_state("no valid query")