Software /
code /
prosody
Comparison
plugins/mod_storage_sql.lua @ 7305:c02e3d8f23fc
mod_storage_sql: Make sure all serialization errors are propagated
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 21 Mar 2016 09:33:12 +0100 |
parent | 7274:e0727512bb99 |
child | 7359:a5a080c12c96 |
child | 7751:168919a947ed |
comparison
equal
deleted
inserted
replaced
7303:439d00063620 | 7305:c02e3d8f23fc |
---|---|
80 | 80 |
81 if data and next(data) ~= nil then | 81 if data and next(data) ~= nil then |
82 local extradata = {}; | 82 local extradata = {}; |
83 for key, value in pairs(data) do | 83 for key, value in pairs(data) do |
84 if type(key) == "string" and key ~= "" then | 84 if type(key) == "string" and key ~= "" then |
85 local t, value = serialize(value); | 85 local t, value = assert(serialize(value)); |
86 assert(t, value); | |
87 engine:insert("INSERT INTO `prosody` (`host`,`user`,`store`,`key`,`type`,`value`) VALUES (?,?,?,?,?,?)", host, user or "", store, key, t, value); | 86 engine:insert("INSERT INTO `prosody` (`host`,`user`,`store`,`key`,`type`,`value`) VALUES (?,?,?,?,?,?)", host, user or "", store, key, t, value); |
88 else | 87 else |
89 extradata[key] = value; | 88 extradata[key] = value; |
90 end | 89 end |
91 end | 90 end |
92 if next(extradata) ~= nil then | 91 if next(extradata) ~= nil then |
93 local t, extradata = serialize(extradata); | 92 local t, extradata = assert(serialize(extradata)); |
94 assert(t, extradata); | |
95 engine:insert("INSERT INTO `prosody` (`host`,`user`,`store`,`key`,`type`,`value`) VALUES (?,?,?,?,?,?)", host, user or "", store, "", t, extradata); | 93 engine:insert("INSERT INTO `prosody` (`host`,`user`,`store`,`key`,`type`,`value`) VALUES (?,?,?,?,?,?)", host, user or "", store, "", t, extradata); |
96 end | 94 end |
97 end | 95 end |
98 return true; | 96 return true; |
99 end | 97 end |
195 if key then | 193 if key then |
196 engine:delete("DELETE FROM `prosodyarchive` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", host, user or "", store, key); | 194 engine:delete("DELETE FROM `prosodyarchive` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", host, user or "", store, key); |
197 else | 195 else |
198 key = uuid.generate(); | 196 key = uuid.generate(); |
199 end | 197 end |
200 local t, value = serialize(value); | 198 local t, value = assert(serialize(value)); |
201 engine:insert("INSERT INTO `prosodyarchive` (`host`, `user`, `store`, `when`, `with`, `key`, `type`, `value`) VALUES (?,?,?,?,?,?,?,?)", host, user or "", store, when, with, key, t, value); | 199 engine:insert("INSERT INTO `prosodyarchive` (`host`, `user`, `store`, `when`, `with`, `key`, `type`, `value`) VALUES (?,?,?,?,?,?,?,?)", host, user or "", store, when, with, key, t, value); |
202 return key; | 200 return key; |
203 end); | 201 end); |
204 end | 202 end |
205 | 203 |