Comparison

mod_mam_muc_sql/mod_mam_muc_sql.lua @ 1343:7dbde05b48a9

all the things: Remove trailing whitespace
author Florian Zeitz <florob@babelmonkeys.de>
date Tue, 11 Mar 2014 18:44:01 +0100
parent 821:87e847280aef
comparison
equal deleted inserted replaced
1342:0ae065453dc9 1343:7dbde05b48a9
89 if not ok or not DBI.Connect then 89 if not ok or not DBI.Connect then
90 return; -- Halt loading of this module 90 return; -- Halt loading of this module
91 end 91 end
92 92
93 params = params or { driver = "SQLite3" }; 93 params = params or { driver = "SQLite3" };
94 94
95 if params.driver == "SQLite3" then 95 if params.driver == "SQLite3" then
96 params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite"); 96 params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite");
97 end 97 end
98 98
99 assert(params.driver and params.database, "Both the SQL driver and the database need to be specified"); 99 assert(params.driver and params.database, "Both the SQL driver and the database need to be specified");
100 100
101 dburi = db2uri(params); 101 dburi = db2uri(params);
102 connection = connections[dburi]; 102 connection = connections[dburi];
103 103
104 assert(connect()); 104 assert(connect());
105 105
106 end 106 end
107 107
108 function getsql(sql, ...) 108 function getsql(sql, ...)
109 if params.driver == "PostgreSQL" then 109 if params.driver == "PostgreSQL" then
110 sql = sql:gsub("`", "\""); 110 sql = sql:gsub("`", "\"");
115 if not stmt then module:log("error", "QUERY FAILED: %s %s", err, debug.traceback()); return nil, err; end 115 if not stmt then module:log("error", "QUERY FAILED: %s %s", err, debug.traceback()); return nil, err; end
116 -- run query 116 -- run query
117 local ok, err = stmt:execute(...); 117 local ok, err = stmt:execute(...);
118 if not ok and not test_connection() then error("connection failed"); end 118 if not ok and not test_connection() then error("connection failed"); end
119 if not ok then return nil, err; end 119 if not ok then return nil, err; end
120 120
121 return stmt; 121 return stmt;
122 end 122 end
123 function setsql(sql, ...) 123 function setsql(sql, ...)
124 local stmt, err = getsql(sql, ...); 124 local stmt, err = getsql(sql, ...);
125 if not stmt then return stmt, err; end 125 if not stmt then return stmt, err; end
288 else 288 else
289 module:log("error", "SQL error: %s", err); 289 module:log("error", "SQL error: %s", err);
290 sql.rollback(); 290 sql.rollback();
291 end 291 end
292 --[[ This was dropped from the spec 292 --[[ This was dropped from the spec
293 if ok then 293 if ok then
294 stanza:tag("archived", { xmlns = xmlns_mam, by = host, id = id }):up(); 294 stanza:tag("archived", { xmlns = xmlns_mam, by = host, id = id }):up();
295 end 295 end
296 --]] 296 --]]
297 end 297 end
298 298