launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #03558
[Merge] lp:~stub/launchpad/bug-179821-lowercase-tablenames into lp:launchpad
Stuart Bishop has proposed merging lp:~stub/launchpad/bug-179821-lowercase-tablenames into lp:launchpad with lp:~stub/launchpad/pending-db-changes as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #179821 in Launchpad itself: "Case sensitive table names are not to be used"
https://bugs.launchpad.net/launchpad/+bug/179821
For more details, see:
https://code.launchpad.net/~stub/launchpad/bug-179821-lowercase-tablenames/+merge/60510
--
https://code.launchpad.net/~stub/launchpad/bug-179821-lowercase-tablenames/+merge/60510
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stub/launchpad/bug-179821-lowercase-tablenames into lp:launchpad.
=== added file 'database/schema/patch-2208-66-0.sql'
--- database/schema/patch-2208-66-0.sql 1970-01-01 00:00:00 +0000
+++ database/schema/patch-2208-66-0.sql 2011-05-10 14:18:21 +0000
@@ -0,0 +1,26 @@
+SET client_min_messages=ERROR;
+
+-- Rename all temp_ names currently in existance to lower(name)
+CREATE OR REPLACE FUNCTION _migrate() RETURNS VOID LANGUAGE plpythonu AS
+$$
+ rows = plpy.execute(r"""
+ SELECT relname AS oldname FROM pg_class, pg_namespace
+ WHERE
+ pg_class.relnamespace = pg_namespace.oid
+ AND pg_namespace.nspname = 'public'
+ AND relkind='r'
+ AND relname LIKE 'temp\\_%'
+ """)
+ for row in rows:
+ oldname = row['oldname']
+ assert oldname.startswith('temp_'), oldname
+ newname = oldname.lower()
+ plpy.execute('ALTER TABLE "%s" RENAME TO "%s"' % (oldname, newname))
+$$;
+
+SELECT _migrate();
+
+DROP FUNCTION _migrate();
+
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 66, 0);
=== modified file 'lib/canonical/database/multitablecopy.py'
--- lib/canonical/database/multitablecopy.py 2009-06-25 05:30:52 +0000
+++ lib/canonical/database/multitablecopy.py 2011-05-10 14:18:21 +0000
@@ -253,9 +253,13 @@
"""Name for a holding table, but without quotes. Use with care."""
if suffix:
suffix = '_%s' % suffix
- return "temp_%s_holding_%s%s" % (
+
+ raw_name = "temp_%s_holding_%s%s" % (
str(tablename), self.name, str(suffix))
+ # Only lowercase names per Bug #179821.
+ return raw_name.lower()
+
def getHoldingTableName(self, tablename, suffix=''):
"""Name for a holding table to hold data being copied in tablename.
Follow ups