From acb0db86c55e04489eebc44bdc41a474e2cce92c Mon Sep 17 00:00:00 2001 From: "bzrmirror%bugzilla.org" Date: Fri, 30 Aug 2013 08:51:42 +0000 Subject: [PATCH] Bug 903895 - Allow more than 32k components r=gerv, a=sgreen git-svn-id: svn://10.0.0.236/trunk@264988 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/.bzrrev | 2 +- .../webtools/bugzilla/Bugzilla/DB/Schema.pm | 10 ++++---- .../webtools/bugzilla/Bugzilla/Install/DB.pm | 24 +++++++++++++++++-- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/mozilla/webtools/bugzilla/.bzrrev b/mozilla/webtools/bugzilla/.bzrrev index bf7e7209526..d86c7644885 100644 --- a/mozilla/webtools/bugzilla/.bzrrev +++ b/mozilla/webtools/bugzilla/.bzrrev @@ -1 +1 @@ -8718 \ No newline at end of file +8719 \ No newline at end of file diff --git a/mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm b/mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm index 0d8396df573..c619a578079 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm @@ -254,7 +254,7 @@ use constant ABSTRACT_SCHEMA => { REFERENCES => {TABLE => 'profiles', COLUMN => 'userid'}}, version => {TYPE => 'varchar(64)', NOTNULL => 1}, - component_id => {TYPE => 'INT2', NOTNULL => 1, + component_id => {TYPE => 'INT3', NOTNULL => 1, REFERENCES => {TABLE => 'components', COLUMN => 'id'}}, resolution => {TYPE => 'varchar(64)', @@ -634,7 +634,7 @@ use constant ABSTRACT_SCHEMA => { REFERENCES => {TABLE => 'products', COLUMN => 'id', DELETE => 'CASCADE'}}, - component_id => {TYPE => 'INT2', + component_id => {TYPE => 'INT3', REFERENCES => {TABLE => 'components', COLUMN => 'id', DELETE => 'CASCADE'}}, @@ -655,7 +655,7 @@ use constant ABSTRACT_SCHEMA => { REFERENCES => {TABLE => 'products', COLUMN => 'id', DELETE => 'CASCADE'}}, - component_id => {TYPE => 'INT2', + component_id => {TYPE => 'INT3', REFERENCES => {TABLE => 'components', COLUMN => 'id', DELETE => 'CASCADE'}}, @@ -1069,7 +1069,7 @@ use constant ABSTRACT_SCHEMA => { REFERENCES => {TABLE => 'profiles', COLUMN => 'userid', DELETE => 'CASCADE'}}, - component_id => {TYPE => 'INT2', NOTNULL => 1, + component_id => {TYPE => 'INT3', NOTNULL => 1, REFERENCES => {TABLE => 'components', COLUMN => 'id', DELETE => 'CASCADE'}}, @@ -1347,7 +1347,7 @@ use constant ABSTRACT_SCHEMA => { components => { FIELDS => [ - id => {TYPE => 'SMALLSERIAL', NOTNULL => 1, + id => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1}, name => {TYPE => 'varchar(64)', NOTNULL => 1}, product_id => {TYPE => 'INT2', NOTNULL => 1, diff --git a/mozilla/webtools/bugzilla/Bugzilla/Install/DB.pm b/mozilla/webtools/bugzilla/Bugzilla/Install/DB.pm index a45c5a5ea68..a463fe87918 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Install/DB.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Install/DB.pm @@ -711,6 +711,9 @@ sub update_table_definitions { # 2013-02-04 dkl@mozilla.com - Bug 824346 _fix_flagclusions_indexes(); + # 2013-08-26 sgreen@redhat.com - Bug 903895 + _fix_components_primary_key(); + ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # ################################################################ @@ -1429,9 +1432,9 @@ sub _use_ids_for_products_and_components { print "Updating the database to use component IDs.\n"; $dbh->bz_add_column("components", "id", - {TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1}); + {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1}); $dbh->bz_add_column("bugs", "component_id", - {TYPE => 'INT2', NOTNULL => 1}, 0); + {TYPE => 'INT3', NOTNULL => 1}, 0); my %components; $sth = $dbh->prepare("SELECT id, value, product_id FROM components"); @@ -3852,6 +3855,23 @@ sub _fix_flagclusions_indexes { } } +sub _fix_components_primary_key { + my $dbh = Bugzilla->dbh; + if ($dbh->bz_column_info('components', 'id')->{TYPE} ne 'MEDIUMSERIAL') { + $dbh->bz_drop_related_fks('components', 'id'); + $dbh->bz_alter_column("components", "id", + {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1}); + $dbh->bz_alter_column("flaginclusions", "component_id", + {TYPE => 'INT3'}); + $dbh->bz_alter_column("flagexclusions", "component_id", + {TYPE => 'INT3'}); + $dbh->bz_alter_column("bugs", "component_id", + {TYPE => 'INT3', NOTNULL => 1}); + $dbh->bz_alter_column("component_cc", "component_id", + {TYPE => 'INT3', NOTNULL => 1}); + } +} + 1; __END__