Description of problem: rh-database-update.pl is broken in Bugzilla 5. Version-Release number of selected component (if applicable): 5.0.3-rh20 Steps to Reproduce: Running `checksetup.pl` or `rh-database-update.pl` against an empty DB will get the following error: DBD::Pg::db selectcol_arrayref failed: ERROR: column forn.value does not exist LINE 3: ON tabl.value = forn.value ^ [for Statement "SELECT DISTINCT tabl.value FROM bug_dependent_products AS tabl LEFT JOIN dependent_products AS forn ON tabl.value = forn.value WHERE forn.value IS NULL AND tabl.value IS NOT NULL"] <pre> at Bugzilla/DB.pm line 1610. Bugzilla::DB::_check_references('Bugzilla::DB::Pg=HASH(0x9885f60)', 'bug_dependent_products', 'value', 'HASH(0xcb691c0)') called at Bugzilla/DB.pm line 701 Bugzilla::DB::bz_add_fks('Bugzilla::DB::Pg=HASH(0x9885f60)', 'bug_dependent_products', 'HASH(0xf764b08)') called at Bugzilla/DB.pm line 690 Bugzilla::DB::bz_add_fk('Bugzilla::DB::Pg=HASH(0x9885f60)', 'bug_dependent_products', 'value', 'HASH(0xcb691c0)') called at Bugzilla/Install/DB.pm line 3245 Bugzilla::Install::DB::_add_foreign_keys_to_multiselects() called at Bugzilla/Install/DB.pm line 545 Bugzilla::Install::DB::update_table_definitions('HASH(0x2bc4bd8)') called at ./checksetup.pl line 173 </pre> at Bugzilla/DB.pm line 1610. Additional info: This is because Bugzilla::DB::bz_add_fk() tries to add a foreign key that references a nonexistent column 'value' in table 'dependent_products'.
What is an "empty database", and how do you get it? The dev CI tests create a brand new database from scratch for every change set so it's unlikely a problem with the code.
(In reply to Jeff Fearn from comment #1) > What is an "empty database", and how do you get it? Sorry, I mean "new database from scratch", without any tables. > > The dev CI tests create a brand new database from scratch for every change > set so it's unlikely a problem with the code. That's weird. I tried upgrading the DB schema from BZ4 to BZ5 using checksetup.pl. It works fine. But the error above occurred if I against running it against a blank database.
After generate localconfig by checksetup.pl, then set the db to a non_exist database in localconfig $db_name = 'bugs_test2'; Then rerun checksetup.pl [root@bz-web bugzilla]# ./checksetup.pl * This is Bugzilla 5.0.3.rh21 on perl 5.16.3 * Running on Linux 3.10.0-327.10.1.el7.x86_64 #1 SMP Sat Jan 23 04:54:55 EST 2016 .......... Reading ./localconfig... Checking for DBD-Pg (v2.7.0) ok: found v3.5.3 Deep recursion on subroutine "Bugzilla::dbh" at Bugzilla/Mailer.pm line 110, <DATA> line 747. Deep recursion on subroutine "Bugzilla::dbh_main" at Bugzilla.pm line 576, <DATA> line 747. Deep recursion on subroutine "Bugzilla::DB::connect_main" at Bugzilla.pm line 580, <DATA> line 747. Deep recursion on subroutine "Bugzilla::DB::_connect" at Bugzilla/DB.pm line 124, <DATA> line 747. Deep recursion on subroutine "Bugzilla::DB::Pg::new" at Bugzilla/DB.pm line 139, <DATA> line 747. Deep recursion on subroutine "Bugzilla::DB::db_new" at Bugzilla/DB/Pg.pm line 58, <DATA> line 747. Deep recursion on subroutine "Bugzilla::Mailer::MessageToMTA" at Bugzilla/DB.pm line 1402, <DATA> line 747. I think this may related to bug 1409968
*** Bug 1409968 has been marked as a duplicate of this bug. ***
Have you enabled check_db in localconfig and granted the bugzilla user the right to create databases? The first is something we always disable, and the second is considered poor security practice, neither should not be used for testing releases destined for production.
(In reply to Jeff Fearn from comment #5) > Have you enabled check_db in localconfig and granted the bugzilla user the > right to create databases? 1.$db_check=0 This means enabled 2.not yet grant the createdb permission but after grant createdb permission, same error as before. > > The first is something we always disable, and the second is considered poor > security practice, neither should not be used for testing releases destined > for production.
(In reply to Rony Gong from comment #6) > (In reply to Jeff Fearn from comment #5) > > Have you enabled check_db in localconfig and granted the bugzilla user the > > right to create databases? > > 1.$db_check=0 This means enabled No, this means disabled, it has to be 1 to enable it. > 2.not yet grant the createdb permission > > but after grant createdb permission, same error as before. Yes, it won't try to create the DB unless you set $db_check=1.
After set "$db_check=1" ,it still show error: Reading ./localconfig... Checking for DBD-Pg (v2.7.0) ok: found v3.5.3 Checking for PostgreSQL (v8.03.0000) ok: found v09.02.1500 Checking for DBD-Pg (v2.19.3) ok: found v3.5.3 Deep recursion on subroutine "Bugzilla::DB::connect_main" at Bugzilla.pm line 580, <DATA> line 747. Deep recursion on subroutine "Bugzilla::DB::_connect" at Bugzilla/DB.pm line 124, <DATA> line 747. Deep recursion on subroutine "Bugzilla::DB::Pg::new" at Bugzilla/DB.pm line 139, <DATA> line 747. Deep recursion on subroutine "Bugzilla::DB::db_new" at Bugzilla/DB/Pg.pm line 58, <DATA> line 747. Deep recursion on subroutine "Bugzilla::Mailer::MessageToMTA" at Bugzilla/DB.pm line 1402, <DATA> line 747. Deep recursion on subroutine "Bugzilla::dbh" at Bugzilla/Mailer.pm line 110, <DATA> line 747. Deep recursion on subroutine "Bugzilla::dbh_main" at Bugzilla.pm line 576, <DATA> line 747.
Tested on QA environment(5.0.3-rh25) Result: Pass Steps: After set "$db_check=1" ,it works well and could create tables now.