[drupal-devel] Bug#295496: drupal: postgresql interface can't connect to a UNIX domain socket

Devin Carraway devin at debian.org
Wed Feb 16 07:38:28 UTC 2005


Package: drupal
Version: 4.5.2-1
Severity: normal


Drupal ostensibly supports postgresql, but its use of the PEAR::DB DSN scheme
for configuration the database connection is incomplete, and cannot support
connection to a pgsql server via a UNIX domain socket, since the DSN scheme
for specifying one is not supported by PHP's parse_url() function used by
drupal to connect.

The PEAR::DB DSN scheme Drupal claims to support is described here:
http://pear.php.net/manual/en/package.database.db.intro-dsn.php

In this scheme, the syntax for specifying a connection to a pgsql domain
socket should be (I have no idea who thought this syntax was a good idea):

pgsql://username:password@unix(/var/run/postgresql)/dbname

Which is parsed by parse_sql as:

% php -r 'print_r(parse_url("pgsql://username:password@unix(/var/run/postgresql)/dbname"));'
Array
(
    [scheme] => pgsql
    [host] => unix(
    [user] => username
    [pass] => password
    [path] => /var/run/postgresql)/dbname
)


However, Drupal's actual implementation is thus:

function db_connect($url) {
  $url = parse_url($url);

  $conn_string = ' user='. $url['user'] .' dbname='. substr($url['path'], 1)
    .' password='. $url['pass'] . ' host=' . $url['host'];
  $conn_string .= ($url['port']) ? ' port=' . $url['port'] : '';
  $connection = pg_connect($conn_string) or die(pg_last_error());

  return $connection;
}

Which leads to a $conn_string of:

" user=username dbname=var/run/postgresql)/dbname password=password host=unix("


-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable')
Architecture: sparc (sparc64)
Kernel: Linux 2.6.6
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages drupal depends on:
ii  apache2-mpm-prefork [apache2] 2.0.52-3   Traditional model for Apache2
ii  debconf                       1.4.30.11  Debian configuration management sy
ii  makepasswd                    1.10-2     Generate and encrypt passwords
ii  php4-cli                      4:4.3.10-2 command-line interpreter for the p
ii  php4-pgsql                    3:4.3.9-1  PostgreSQL module for php4
ii  postgresql-client             7.4.7-2    front-end programs for PostgreSQL
ii  qmail [mail-transport-agent]  1.03-31    Secure, reliable, efficient, simpl
ii  wwwconfig-common              0.0.42     Debian web auto configuration

-- debconf information:
* drupal/remove_backups: false
  drupal/createuser_failed:
* drupal/db_auto_update: false
  drupal/dropdb_failed:
  drupal/upgradedb_impossible:
* drupal/dbgeneration: false
* drupal/dbtype: PostgreSQL
* drupal/database_doremove: false
  drupal/createdb_failed:
* drupal/dbserver: localhost
* drupal/webserver: apache2
  drupal/upgradedb_failed:
* drupal/dbname: drupal
* drupal/dbuser: drupal
  drupal/dbadmin: root
  drupal/initdb_failed:
  drupal/conffile_failed:





More information about the drupal-devel mailing list