Comparison

plugins/mod_storage_sql.lua @ 13156:019cd1db9bec

mod_storage_sql: Be more specific when checking for old index in SQLite3 Prevents false positives in the odd case where something other than an index with this name might exist.
author Kim Alvefur <zash@zash.se>
date Sat, 17 Jun 2023 00:00:21 +0200
parent 13155:9a7523ea45cb
child 13157:841276d0cc25
comparison
equal deleted inserted replaced
13155:9a7523ea45cb 13156:019cd1db9bec
848 end 848 end
849 else 849 else
850 local indices = {}; 850 local indices = {};
851 engine:transaction(function () 851 engine:transaction(function ()
852 if params.driver == "SQLite3" then 852 if params.driver == "SQLite3" then
853 for row in engine:select [[SELECT "name" from "sqlite_schema" WHERE "name"='prosody_index';]] do 853 for row in engine:select [[SELECT "name" FROM "sqlite_schema" WHERE "type"='index' AND "tbl_name"='prosody' AND "name"='prosody_index';]] do
854 indices[row[1]] = true; 854 indices[row[1]] = true;
855 end 855 end
856 elseif params.driver == "PostgreSQL" then 856 elseif params.driver == "PostgreSQL" then
857 for row in engine:select [[SELECT "relname" FROM "pg_indexes" WHERE "tablename"='prosody' AND "indexname"='prosody_index';]] do 857 for row in engine:select [[SELECT "relname" FROM "pg_indexes" WHERE "tablename"='prosody' AND "indexname"='prosody_index';]] do
858 indices[row[1]] = true; 858 indices[row[1]] = true;