php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: phansys at gmail dot com
New email:
PHP Version: OS:

 

 [2014-06-13 02:57 UTC] 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 ...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-31 18:33 UTC] mbeccati@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: mbeccati
 [2014-10-31 18:33 UTC] mbeccati@php.net
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: Thu Dec 26 10:01:29 2024 UTC