comparison mod_auth_sql/mod_auth_sql.lua @ 366:c2554fee5c21

Reconnect on DB disconnection.
author Tomasz Sterna <tomek@xiaoka.com>
date Wed, 13 Apr 2011 15:37:26 +0200
parents f24998ec7f8d
children a6dee73a11e7
comparison
equal deleted inserted replaced
365:1d95b69c2c81 366:c2554fee5c21
58 58
59 local function getsql(sql, ...) 59 local function getsql(sql, ...)
60 if params.driver == "PostgreSQL" then 60 if params.driver == "PostgreSQL" then
61 sql = sql:gsub("`", "\""); 61 sql = sql:gsub("`", "\"");
62 end 62 end
63 if not test_connection() then connect() end
63 -- do prepared statement stuff 64 -- do prepared statement stuff
64 local stmt, err = connection:prepare(sql); 65 local stmt, err = connection:prepare(sql);
65 if not stmt and not test_connection() then error("connection failed"); end 66 if not stmt and not test_connection() then error("connection failed"); end
66 if not stmt then module:log("error", "QUERY FAILED: %s %s", err, debug.traceback()); return nil, err; end 67 if not stmt then module:log("error", "QUERY FAILED: %s %s", err, debug.traceback()); return nil, err; end
67 -- run query 68 -- run query