We recently moved the application I work on everyday to Amazon Web Services and bravely adopted their Relational Database Service (RDS) and have had little trouble thus far, but the other day I noticed since we kicked into BST, timestamps in the database where an hour behind. Low and behold, the default time zone cannot be changed. Luckily, we've been using mysql-proxy since we migrated and rather than changed our application, I managed to knock up a lua script that sets the timezone variable on every query. It would be nice if it could do it when it creates a connection, but I've not worked out how to do that yet!
--- -- read_query() can rewrite packets -- function read_query( packet ) if string.byte(packet) == proxy.COM_QUERY then proxy.queries:append(1, string.char(proxy.COM_QUERY) .. "SET time_zone = 'Europe/London'", {resultset_is_needed = true}) proxy.queries:append(2, packet) return proxy.PROXY_SEND_QUERY end end --- -- read_query_result() is called when we receive a query result -- from the server -- function read_query_result(inj) if (inj.type == 1) then return proxy.PROXY_IGNORE_RESULT end end
If anyone could point me in the general direction for setting the variable at connection time, it'd be appreciated. I assume I can create a create_connection function, but I don't know where to go from there.