Mercurial > prosody-hg
comparison util/sql.lua @ 6775:22c8deb43daf
Merge 0.10->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 11 Aug 2015 10:29:25 +0200 |
| parents | 60957dd5b41b |
| children | 5de6b93d0190 |
comparison
equal
deleted
inserted
replaced
| 6770:cb84731b2dfd | 6775:22c8deb43daf |
|---|---|
| 283 log("debug", "Using encoding '%s' for database connection", charset); | 283 log("debug", "Using encoding '%s' for database connection", charset); |
| 284 local ok, err = self:transaction(function() return self:execute(set_names_query:format(charset)); end); | 284 local ok, err = self:transaction(function() return self:execute(set_names_query:format(charset)); end); |
| 285 if not ok then | 285 if not ok then |
| 286 return ok, err; | 286 return ok, err; |
| 287 end | 287 end |
| 288 | 288 |
| 289 if driver == "MySQL" then | 289 if driver == "MySQL" then |
| 290 local ok, actual_charset = self:transaction(function () | 290 local ok, actual_charset = self:transaction(function () |
| 291 return self:select"SHOW SESSION VARIABLES LIKE 'character_set_client'"; | 291 return self:select"SHOW SESSION VARIABLES LIKE 'character_set_client'"; |
| 292 end); | 292 end); |
| 293 for row in actual_charset do | 293 for row in actual_charset do |
| 295 log("error", "MySQL %s is actually %q (expected %q)", row[1], row[2], charset); | 295 log("error", "MySQL %s is actually %q (expected %q)", row[1], row[2], charset); |
| 296 return false, "Failed to set connection encoding"; | 296 return false, "Failed to set connection encoding"; |
| 297 end | 297 end |
| 298 end | 298 end |
| 299 end | 299 end |
| 300 | 300 |
| 301 return true; | 301 return true; |
| 302 end | 302 end |
| 303 local engine_mt = { __index = engine }; | 303 local engine_mt = { __index = engine }; |
| 304 | 304 |
| 305 function db2uri(params) | 305 function db2uri(params) |
