Software /
code /
prosody
Comparison
plugins/mod_storage_sql.lua @ 13780:40185fad7505 13.0
mod_storage_sql: Fix indentation
Off-by-one in autoindent after `if not success then` since 3ec48555b773
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 19 Mar 2025 16:13:32 +0100 |
parent | 13661:5a7f042fe05d |
child | 13784:b30eaa74d35b |
comparison
equal
deleted
inserted
replaced
13778:b6d0f1d79b60 | 13780:40185fad7505 |
---|---|
864 end | 864 end |
865 end); | 865 end); |
866 success,err = engine:transaction(function() | 866 success,err = engine:transaction(function() |
867 return engine:execute(check_encoding_query, params.database, | 867 return engine:execute(check_encoding_query, params.database, |
868 engine.charset, engine.charset.."_bin"); | 868 engine.charset, engine.charset.."_bin"); |
869 end); | 869 end); |
870 if not success then | 870 if not success then |
871 module:log("error", "Failed to check/upgrade database encoding: %s", err or "unknown error"); | 871 module:log("error", "Failed to check/upgrade database encoding: %s", err or "unknown error"); |
872 return false; | 872 return false; |
873 end | 873 end |
874 else | 874 else |
875 local indices = {}; | 875 local indices = {}; |
876 engine:transaction(function () | 876 engine:transaction(function () |
877 if params.driver == "SQLite3" then | 877 if params.driver == "SQLite3" then |
878 for row in engine:select [[SELECT "name" FROM "sqlite_schema" WHERE "type"='index' AND "tbl_name"='prosody' AND "name"='prosody_index';]] do | 878 for row in engine:select [[SELECT "name" FROM "sqlite_schema" WHERE "type"='index' AND "tbl_name"='prosody' AND "name"='prosody_index';]] do |
879 indices[row[1]] = true; | 879 indices[row[1]] = true; |
880 end | 880 end |
881 elseif params.driver == "PostgreSQL" then | 881 elseif params.driver == "PostgreSQL" then |
882 for row in engine:select [[SELECT "indexname" FROM "pg_indexes" WHERE "tablename"='prosody' AND "indexname"='prosody_index';]] do | 882 for row in engine:select [[SELECT "indexname" FROM "pg_indexes" WHERE "tablename"='prosody' AND "indexname"='prosody_index';]] do |
883 indices[row[1]] = true; | 883 indices[row[1]] = true; |
884 end | 884 end |
885 end | 885 end |
886 end) | 886 end) |
887 if indices["prosody_index"] then | 887 if indices["prosody_index"] then |
888 if apply_changes then | 888 if apply_changes then |
889 local success = engine:transaction(function () | 889 local success = engine:transaction(function () |
890 return assert(engine:execute([[DROP INDEX "prosody_index";]])); | 890 return assert(engine:execute([[DROP INDEX "prosody_index";]])); |
891 end); | 891 end); |
892 if not success then | 892 if not success then |
893 module:log("error", "Failed to delete obsolete index \"prosody_index\""); | 893 module:log("error", "Failed to delete obsolete index \"prosody_index\""); |
894 return false; | 894 return false; |
895 end | 895 end |
896 else | 896 else |
897 changes = true; | 897 changes = true; |
898 end | 898 end |
899 end | 899 end |
900 end | 900 end |
901 return changes; | 901 return changes; |
902 end | 902 end |
903 | 903 |
904 local function normalize_database(driver, database) -- luacheck: ignore 431/driver | 904 local function normalize_database(driver, database) -- luacheck: ignore 431/driver |
905 if driver == "SQLite3" and database ~= ":memory:" then | 905 if driver == "SQLite3" and database ~= ":memory:" then |