comparison mod_mam_sql/mod_mam_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
parents c6b8ae5a8369
children 6e1facedcb74
comparison
equal deleted inserted replaced
1342:0ae065453dc9 1343:7dbde05b48a9
97 if not ok or not DBI.Connect then 97 if not ok or not DBI.Connect then
98 return; -- Halt loading of this module 98 return; -- Halt loading of this module
99 end 99 end
100 100
101 params = params or { driver = "SQLite3" }; 101 params = params or { driver = "SQLite3" };
102 102
103 if params.driver == "SQLite3" then 103 if params.driver == "SQLite3" then
104 params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite"); 104 params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite");
105 end 105 end
106 106
107 assert(params.driver and params.database, "Both the SQL driver and the database need to be specified"); 107 assert(params.driver and params.database, "Both the SQL driver and the database need to be specified");
108 108
109 dburi = db2uri(params); 109 dburi = db2uri(params);
110 connection = connections[dburi]; 110 connection = connections[dburi];
111 111
112 assert(connect()); 112 assert(connect());
113 113
114 end 114 end
115 115
116 function getsql(sql, ...) 116 function getsql(sql, ...)
117 if params.driver == "PostgreSQL" then 117 if params.driver == "PostgreSQL" then
118 sql = sql:gsub("`", "\""); 118 sql = sql:gsub("`", "\"");
133 local ok, err = stmt:execute(...); 133 local ok, err = stmt:execute(...);
134 if not ok and not test_connection() then 134 if not ok and not test_connection() then
135 return nil, "connection failed"; 135 return nil, "connection failed";
136 end 136 end
137 if not ok then return nil, err; end 137 if not ok then return nil, err; end
138 138
139 return stmt; 139 return stmt;
140 end 140 end
141 function setsql(sql, ...) 141 function setsql(sql, ...)
142 local stmt, err = getsql(sql, ...); 142 local stmt, err = getsql(sql, ...);
143 if not stmt then return stmt, err; end 143 if not stmt then return stmt, err; end
399 else 399 else
400 module:log("error", "SQL error: %s", err); 400 module:log("error", "SQL error: %s", err);
401 sql.rollback(); 401 sql.rollback();
402 end 402 end
403 --[[ This was dropped from the spec 403 --[[ This was dropped from the spec
404 if ok then 404 if ok then
405 stanza:tag("archived", { xmlns = xmlns_mam, by = host, id = id }):up(); 405 stanza:tag("archived", { xmlns = xmlns_mam, by = host, id = id }):up();
406 end 406 end
407 --]] 407 --]]
408 else 408 else
409 module:log("debug", "Not archiving stanza: %s", stanza:top_tag()); 409 module:log("debug", "Not archiving stanza: %s", stanza:top_tag());