Bug #67431 [Opn->Nab]: PDO::__construct tries to use login role as DB name if DB name isn't present

From: Date: Fri, 31 Oct 2014 18:33:59 +0000
Subject: Bug #67431 [Opn->Nab]: PDO::__construct tries to use login role as DB name if DB name isn't present
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188391@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67431&edit=1 ID: 67431 Updated by: mbeccati@php.net Reported by: phansys at gmail dot com Summary: PDO::__construct tries to use login role as DB name if DB name isn't present -Status: Open +Status: Not a bug Type: Bug Package: PDO PgSQL Operating System: Ubuntu 14.10 PHP Version: Irrelevant -Assigned To: +Assigned To: mbeccati Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2014-06-13 02:57:01] phansys at gmail dot com Description: ------------ 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 PDO support => enabled PDO drivers => pgsql pdo_pgsql PDO Driver for PostgreSQL => enabled PostgreSQL(libpq) Version => 9.3.4 Module version => 1.0.2 Revision => $Id$ pgsql 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=0.0.0.0;port=5432;", 'login_role_name', 'login_role_pass'); var_dump($conn); 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 ... ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67431&edit=1

« previous php.bugs (#188391) next »