diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/util-sql-tickets.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/util-sql-tickets.lua | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/util-sql-tickets.lua b/Master/texmf-dist/tex/context/base/mkiv/util-sql-tickets.lua index f392c0b913f..3258fb186d8 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/util-sql-tickets.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/util-sql-tickets.lua @@ -18,6 +18,8 @@ local ostime, uuid, osfulltime = os.time, os.uuid, os.fulltime local random = math.random local concat = table.concat +if not utilities.sql then require("util-sql") end + local sql = utilities.sql local tickets = { } sql.tickets = tickets @@ -27,7 +29,6 @@ local report = logs.reporter("sql","tickets") local serialize = sql.serialize local deserialize = sql.deserialize -local execute = sql.execute tickets.newtoken = sql.tokens.new @@ -66,7 +67,7 @@ end tickets.usedb = checkeddb -local template =[[ +local template = [[ CREATE TABLE IF NOT EXISTS %basename% ( `id` int(11) NOT NULL AUTO_INCREMENT, `token` varchar(50) NOT NULL, @@ -82,14 +83,30 @@ local template =[[ PRIMARY KEY (`id`), UNIQUE INDEX `id_unique_index` (`id` ASC), KEY `token_unique_key` (`token`) - ) - DEFAULT CHARSET = utf8 ; + ) DEFAULT CHARSET = utf8 ; +]] + +local sqlite_template = [[ + CREATE TABLE IF NOT EXISTS %basename% ( + `id` TEXT NOT NULL AUTO_INCREMENT, + `token` TEXT NOT NULL, + `subtoken` INTEGER DEFAULT '0', + `created` INTEGER DEFAULT '0', + `accessed` INTEGER DEFAULT '0', + `category` INTEGER DEFAULT '0', + `status` INTEGER DEFAULT '0', + `usertoken` TEXT NOT NULL, + `data` TEXT NOT NULL, + `comment` TEXT NOT NULL + ) ; ]] function tickets.createdb(presets,datatable) + local db = checkeddb(presets,datatable) + local data, keys = db.execute { - template = template, + template = db.usedmethod == "sqlite" and sqlite_template or template, variables = { basename = db.basename, }, |