View Issue Details

IDProjectCategoryView StatusLast Update
0012248mantisbtdb postgresqlpublic2014-12-08 00:34
ReporternomikonAssigned Todregad 
Status closedResolutionfixed 
PlatformBSDOSFreeBSDOS Version8.0
Product Version1.1.8 
Target Version1.3.0-beta.1Fixed in Version1.3.0-beta.1 
Summary0012248: Problem updating from 1.1.8 to 1.2.0

(Using PostgreSQL 8.4.4, PHP 5.2.12, on FreeBSD 8.0)

Attempting to upgrade a current 1.1.8 installation to 1.2.0, when is comes to Database upgrade, we set the Mantis DB details (username and pasword). After clicking the 'upgrade' button we get the following page content:

Database Parameters
Upgrade Options
Admin username and password
Setting Database Hostname GOOD
Setting Database Type GOOD
Checking PHP support for database type GOOD
Setting Database Username GOOD
Setting Database Password GOOD
Setting Database Name GOOD
Setting Admin Username GOOD
Setting Admin Password GOOD
Attempting to connect to database as admin BAD
Does administrative user have access to the database? ( Database connection failed )

Looking at the PostgreSQL log, it seems that the upgrading process is attempting to connect to 'template1' database:

Jul 10 08:19:30 postgres[41626]: [2-1] LOG: received connection: host= port=55536
Jul 10 08:19:30 postgres[41626]: [3-1] LOG: authorized connection: usuario=mantis database=template1
Jul 10 08:19:30 postgres[41626]: [4-1] FATAL: permission denied to database <<template1>>
Jul 10 08:19:30 postgres[41626]: [4-2] DETAIL: User has no connection privileges.

As far as 'Setting Database Name', 'Setting Admin Username' and 'Setting Admin Password' are all found GOOD, the fault doesn't make sense. It seems there is no reason to attempt to connect with the 'template1' database, for which the Mantis DB owner doesn't have privileges.

Steps To Reproduce

Just following the steps above.

TagsNo tags attached.


has duplicate 0011573 closeddregad Cannot upgrade from 1.1.x to 1.2.0 using PostgreSQL and an unprivileged user 
child of 0014398 closeddregad Support for PostgreSQL broken in 1.3 




2010-08-11 13:48

reporter   ~0026270

You mention upgrading to 1.2.0, but that is not the latest version, and I believe there were a few fixes to the upgrade system in 1.2.1 and 1.2.2. Can you please try upgrading directly to 1.2.2 and see if that solves the issue?



2010-08-11 15:00

reporter   ~0026272

Thanks for your quick answer!

Before sending the report I reviewed the change logs for 1.2.1 and 1.2.2, looking for a possible fix to that issue. Anyway I have just now attemped the upgrade using a fresh 1.2.2 download, and the problem persists. I keep getting the same red warning:

Attempting to connect to database as admin BAD
Does administrative user have access to the database? ( Database connection failed )

The PostgreSQL log shows the same error as well (the Mantis DB owner is trying to connect to 'template1' database.)



2010-08-11 15:18

reporter   ~0026274

Could you paste the portion of your config_inc.php here that involves the database connection? Thanks



2010-08-11 18:46

reporter   ~0026291

Here is:


--- Database Configuration ---

$g_hostname = 'localhost';
$g_db_type = 'pgsql';
$g_database_name = 'mantis';
$g_db_username = 'mantis';
$g_db_password = 'xxxxxx';

This same DB configuration is running fine in 1.1.8



2010-08-26 14:09

reporter   ~0026477

Hi, any new about this issue? As far as I can see, the problem is clear:

The admin/install.php script (lines 285 and later) ALWAYS try to do a first connection attempt without specifying a database name. In PostgreSQL this means it will attempt to connect to "template1" database, for which the username defined for the Mantis database has no permissions, resulting in the known error.

I don't fully understand the reason to do two connections, given that the second one would catch any errors. If you want to be able to create the database, it would suffit changing the logic the other way around:

Try connect to the specified database with the normal user and password.
If all goes well, go on.
If not, try to create the database using the administrative user and password.
If all goes well, go on.
If not, show error.

Actually, modifying that code to skip the first connection (just for testing) I'm able to go ahead without the known "Attempting to connect to database as admin BAD" error.

However, beyond that point I'm now stumped again with a new "APPLICATION ERROR 0000401" Database query failed. Error received from database was #-1: ERROR: invalid input syntax for integer: «» for the query: UPDATE mantis_bug_table SET category_id=? WHERE project_id=? AND category=?.

As far as I can remember this is an old known one... Should I open a new ticket for it?



2010-08-26 14:15

reporter   ~0026478

BTW, as far as this issue is blocking the upgrade, should we raise the category of this ticket up to "block"?

Sander Niemeijer

Sander Niemeijer

2012-10-05 07:08

reporter   ~0033045

I am having the same issue when trying to upgrade from 1.2.8 to 1.2.11 (PostgreSQL 8.4.4, PHP 5.3.2, RHEL 6.0), patching the install.php to include '$f_database_name' in the first call to $g_db->Connect resolved the issue for me.



2012-10-16 09:17

developer   ~0033227

Unassigned from jreese as he is no longer actively developing.



2014-02-24 15:26

developer   ~0039514

This should be fixed in master branch; if you are able to reproduce the behavior using a nightly build, feel free to reopen the issue.

Issue History

Date Modified Username Field Change
2010-08-11 13:38 nomikon New Issue
2010-08-11 13:48 jreese Note Added: 0026270
2010-08-11 13:48 jreese Assigned To => jreese
2010-08-11 13:48 jreese Status new => feedback
2010-08-11 15:00 nomikon Note Added: 0026272
2010-08-11 15:00 nomikon Status feedback => assigned
2010-08-11 15:18 jreese Note Added: 0026274
2010-08-11 15:18 jreese Status assigned => feedback
2010-08-11 18:46 nomikon Note Added: 0026291
2010-08-11 18:46 nomikon Status feedback => assigned
2010-08-26 14:09 nomikon Note Added: 0026477
2010-08-26 14:15 nomikon Note Added: 0026478
2012-10-05 07:08 Sander Niemeijer Note Added: 0033045
2012-10-16 09:03 dregad Status assigned => confirmed
2012-10-16 09:04 dregad Assigned To jreese =>
2012-10-16 09:17 dregad Note Added: 0033227
2013-07-30 06:46 dregad Relationship added has duplicate 0011573
2013-07-30 06:51 dregad Relationship added child of 0014398
2013-08-16 04:38 hero2289 Tag Attached: closed
2013-08-16 06:33 atrol Tag Detached: closed
2014-02-24 15:26 dregad Note Added: 0039514
2014-02-24 15:26 dregad Status confirmed => resolved
2014-02-24 15:26 dregad Fixed in Version => 1.3.0-beta.1
2014-02-24 15:26 dregad Resolution open => fixed
2014-02-24 15:26 dregad Assigned To => dregad
2014-02-24 15:26 dregad Product Version => 1.1.8
2014-02-24 15:26 dregad Target Version => 1.3.0-beta.1
2014-12-08 00:34 vboctor Status resolved => closed