[PKG-Openstack-devel] Bug#915938: migrate: Enable compatability with sqlite >= 3.26

Corey Bryant corey.bryant at canonical.com
Sat Dec 8 02:24:21 GMT 2018


Package: migrate
Version: 0.11.0-3
Severity: important
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu disco ubuntu-patch

Dear Maintainer,

In Ubuntu, the attached patch was applied to achieve the following:

  * d/p/use-legacy-alter-sqlite.patch: Cherry-picked from upstream
    gerrit review (https://review.openstack.org/#/c/623564/) to ensure
    compatability with sqlite >= 3.26 (LP: #1807262).

Thanks for considering the patch.


-- System Information:
Debian Release: buster/sid
  APT prefers disco
  APT policy: (500, 'disco'), (500, 'cosmic-security'), (500, 'bionic-security')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.18.0-11-generic (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
-------------- next part --------------
diff -Nru migrate-0.11.0/debian/patches/series migrate-0.11.0/debian/patches/series
--- migrate-0.11.0/debian/patches/series	2018-04-27 04:29:21.000000000 -0400
+++ migrate-0.11.0/debian/patches/series	2018-12-07 14:16:55.000000000 -0500
@@ -2,3 +2,4 @@
 keep_empty_modules.patch
 disable_issuetracker.patch
 remove-tempest-lib-build-depends-from-upstream.patch
+use-legacy-alter-sqlite.patch
diff -Nru migrate-0.11.0/debian/patches/use-legacy-alter-sqlite.patch migrate-0.11.0/debian/patches/use-legacy-alter-sqlite.patch
--- migrate-0.11.0/debian/patches/use-legacy-alter-sqlite.patch	1969-12-31 19:00:00.000000000 -0500
+++ migrate-0.11.0/debian/patches/use-legacy-alter-sqlite.patch	2018-12-07 14:16:14.000000000 -0500
@@ -0,0 +1,53 @@
+From f73dac34f00f3c783c6a824c93f86a756aa5cf64 Mon Sep 17 00:00:00 2001
+From: Corey Bryant <corey.bryant at canonical.com>
+Date: Fri, 7 Dec 2018 13:49:20 -0500
+Subject: [PATCH] Use legacy_alter_table ON in sqlite recreate_table
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Use "PRAGMA legacy_alter_table = ON" with sqlite >= 3.26 when
+using "ALTER TABLE RENAME TO migration_tmp" to maintain legacy
+behavior.
+
+As of sqlite version 3.26, when a table is renamed using
+"ALTER TABLE RENAME TO", REFERENCES clauses that refer to the
+table will be updated. To maintain legacy (3.24 and earlier)
+behavior, "PRAGMA legacy_alter_table" can be set to true and
+"PRAGMA foreign_keys" can be set to false. [1]
+
+[1] https://www.sqlite.org/src/info/ae9638e9c0ad0c36
+
+Thanks to "László Böszörményi (GCS)" <gcs at debian.org> for
+providing the code for this patch, which has since been
+slightly modified.
+
+Change-Id: I539988ab2ad6df6c8f423ecec15364ad8fcc7267
+Closes-Bug: 1807262
+---
+ migrate/changeset/databases/sqlite.py | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/migrate/changeset/databases/sqlite.py b/migrate/changeset/databases/sqlite.py
+index 92d42f2..568a329 100644
+--- a/migrate/changeset/databases/sqlite.py
++++ b/migrate/changeset/databases/sqlite.py
+@@ -96,8 +96,15 @@ class SQLiteHelper(SQLiteCommon):
+             if omit_constraints is None or cons.name not in omit_constraints
+         ])
+ 
++        tup = sqlite3.sqlite_version_info
++        if tup[0] > 3 or (tup[0] == 3 and tup[1] >= 26):
++            self.append('PRAGMA legacy_alter_table = ON')
++            self.execute()
+         self.append('ALTER TABLE %s RENAME TO migration_tmp' % table_name)
+         self.execute()
++        if tup[0] > 3 or (tup[0] == 3 and tup[1] >= 26):
++            self.append('PRAGMA legacy_alter_table = OFF')
++            self.execute()
+ 
+         insertion_string = self._modify_table(table, column, delta)
+ 
+-- 
+2.19.1
+


More information about the Openstack-devel mailing list