Loader: add pragma legacy_alter_table for compatibility with sqlite 3.25.2+ 75/197475/1
authorKonrad Lipinski <k.lipinski2@partner.samsung.com>
Thu, 10 Jan 2019 16:46:20 +0000 (17:46 +0100)
committerKonrad Lipinski <k.lipinski2@partner.samsung.com>
Fri, 11 Jan 2019 10:50:05 +0000 (11:50 +0100)
Change-Id: Iad4595cb9a12b3ebb23beca092b3057502ef822c

src/server/rules-loader/security-manager-rules-loader.cpp

index bf4225145e2d6b26f942b851b3effb28cf9f148d..df5cc3f755fb49ee892e40ddb6dc4014a6661741 100644 (file)
@@ -569,6 +569,13 @@ bool dbUp() {
         // an empty database file is recognized by sqlite as having user_version 0 but needs no update
         // merely applying the schema is enough in that case
         if (version || !fileEmpty(dbPath)) {
+            // https://www.sqlite.org/changes.html + https://sqlite.org/src/info/b41031ea2b537237 workaround
+            // automatically ignored for sqlite versions prior to 3.25.2
+            if (unlikely(!dbExec("PRAGMA legacy_alter_table=ON"))) {
+                toStderr("pragma legacy_alter_table failed");
+                return false;
+            }
+
             // update-db-to-v$i.sql is stored as dbUpdateScript[$i - 1]
             do {
                 if (unlikely(!dbExec(dbUpdateScript[version]))) {