|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67431 PDO::__construct tries to use login role as DB name if DB name isn't present
Submitted: 2014-06-13 02:57 UTC Modified: 2014-10-31 18:33 UTC
From: phansys at gmail dot com Assigned: mbeccati (profile)
Status: Not a bug Package: PDO PgSQL
PHP Version: Irrelevant OS: Ubuntu 14.10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
44 + 46 = ?
Subscribe to this entry?

 [2014-06-13 02:57 UTC] phansys at gmail dot com
I'm trying to open a PDO connection through PGSQL in order to create a new database with a login role created manually in PostgreSQL DB (called 'login_role_name').


PDO support => enabled
PDO drivers => pgsql


PDO Driver for PostgreSQL => enabled
PostgreSQL(libpq) Version => 9.3.4
Module version => 1.0.2
Revision =>  $Id$ 


PostgreSQL Support => enabled
PostgreSQL(libpq) Version => 9.3.4
PostgreSQL(libpq)  => PostgreSQL 9.3.4 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.2-16ubuntu6) 4.8.2, 64-bit
Multibyte character support => enabled
SSL support => enabled
Active Persistent Links => 0
Active Links => 0

Directive => Local Value => Master Value
pgsql.allow_persistent => On => On
pgsql.auto_reset_persistent => Off => Off
pgsql.ignore_notice => Off => Off
pgsql.log_notice => Off => Off
pgsql.max_links => Unlimited => Unlimited
pgsql.max_persistent => Unlimited => Unlimited

Test script:
$conn = new \PDO("pgsql:host=;port=5432;", 'login_role_name', 'login_role_pass');

Expected result:
object(PDO)#1 (0) {

Actual result:
PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[08006] [7] FATAL:  database "login_role_name" does not exist' in ...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-31 18:33 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: mbeccati
 [2014-10-31 18:33 UTC]
This is how Postgres works. If a database name is not provided, the default is a database with the same name as the username.

You need to connect to an existing database, like "postgres" or "template1".

Please consult the Postgres docs for more information.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 13:01:29 2024 UTC