Software /
code /
prosody
Comparison
plugins/mod_storage_sql.lua @ 8081:a201f315de55
mod_storage_sql: Break long lines
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 12 Apr 2017 23:16:23 +0200 |
parent | 8080:8833f2ca6e53 |
child | 8082:8ca11201bfe7 |
comparison
equal
deleted
inserted
replaced
8080:8833f2ca6e53 | 8081:a201f315de55 |
---|---|
482 | 482 |
483 -- COMPAT w/pre-0.10: Upgrade table to UTF-8 if not already | 483 -- COMPAT w/pre-0.10: Upgrade table to UTF-8 if not already |
484 local check_encoding_query = [[ | 484 local check_encoding_query = [[ |
485 SELECT "COLUMN_NAME","COLUMN_TYPE","TABLE_NAME" | 485 SELECT "COLUMN_NAME","COLUMN_TYPE","TABLE_NAME" |
486 FROM "information_schema"."columns" | 486 FROM "information_schema"."columns" |
487 WHERE "TABLE_NAME" LIKE 'prosody%%' AND ( "CHARACTER_SET_NAME"!=? OR "COLLATION_NAME"!=?); | 487 WHERE "TABLE_NAME" LIKE 'prosody%%' |
488 AND ( "CHARACTER_SET_NAME"!=? OR "COLLATION_NAME"!=?); | |
488 ]]; | 489 ]]; |
489 -- FIXME Is it ok to ignore the return values from this? | 490 -- FIXME Is it ok to ignore the return values from this? |
490 engine:transaction(function() | 491 engine:transaction(function() |
491 local result = assert(engine:execute(check_encoding_query, engine.charset, engine.charset.."_bin")); | 492 local result = assert(engine:execute(check_encoding_query, engine.charset, engine.charset.."_bin")); |
492 local n_bad_columns = result:rowcount(); | 493 local n_bad_columns = result:rowcount(); |
504 end | 505 end |
505 module:log("info", "Database encoding upgrade complete!"); | 506 module:log("info", "Database encoding upgrade complete!"); |
506 end | 507 end |
507 end | 508 end |
508 end); | 509 end); |
509 success,err = engine:transaction(function() return engine:execute(check_encoding_query, engine.charset, engine.charset.."_bin"); end); | 510 success,err = engine:transaction(function() |
511 return engine:execute(check_encoding_query, engine.charset, engine.charset.."_bin"); | |
512 end); | |
510 if not success then | 513 if not success then |
511 module:log("error", "Failed to check/upgrade database encoding: %s", err or "unknown error"); | 514 module:log("error", "Failed to check/upgrade database encoding: %s", err or "unknown error"); |
512 return false; | 515 return false; |
513 end | 516 end |
514 end | 517 end |