Bug Report #1854

Improve DSN parsing

Added by Chris Bandy over 5 years ago. Updated about 5 years ago.

Status:ClosedStart date:07/18/2009
Priority:HighDue date:
Assignee:Ben Rogers% Done:

100%

Category:Libraries:Database
Target version:2.4
Resolution:fixed Points:

Description

Attached is a patch to use parse_url() to do much of the DSN parsing. I detected no performance gain or loss, but more strings now parse correctly.

'type:///database'
    => array('type' => 'type', 'user' => FALSE, 'pass' => FALSE, 'host' => FALSE, 'port' => FALSE, 'socket' => FALSE, 'database' => 'database')

'type://hostname'
    => array('type' => 'type', 'user' => FALSE, 'pass' => FALSE, 'host' => 'hostname', 'port' => FALSE, 'socket' => FALSE, 'database' => FALSE)

'type://hostname:12345'
    => array('type' => 'type', 'user' => FALSE, 'pass' => FALSE, 'host' => 'hostname', 'port' => 12345, 'socket' => FALSE, 'database' => FALSE)

'type://hostname/database'
    => array('type' => 'type', 'user' => FALSE, 'pass' => FALSE, 'host' => 'hostname', 'port' => FALSE, 'socket' => FALSE, 'database' => 'database')

'type://hostname:12345/database'
    => array('type' => 'type','user' => FALSE, 'pass' => FALSE, 'host' => 'hostname', 'port' => 12345, 'socket' => FALSE, 'database' => 'database')

'type://username@hostname'
    => array('type' => 'type', 'user' => 'username', 'pass' => FALSE, 'host' => 'hostname', 'port' => FALSE, 'socket' => FALSE, 'database' => FALSE)

'type://username@hostname:12345'
    => array('type' => 'type', 'user' => 'username', 'pass' => FALSE, 'host' => 'hostname', 'port' => 12345, 'socket' => FALSE, 'database' => FALSE)

'type://username:password@hostname'
    => array('type' => 'type', 'user' => 'username', 'pass' => 'password', 'host' => 'hostname', 'port' => FALSE, 'socket' => FALSE, 'database' => FALSE)

'type://username:password@hostname:12345'
    => array('type' => 'type', 'user' => 'username', 'pass' => 'password', 'host' => 'hostname', 'port' => 12345, 'socket' => FALSE, 'database' => FALSE)

'type://unix(/path/to/socket)'
    => array('type' => 'type', 'user' => FALSE, 'pass' => FALSE, 'host' => FALSE, 'port' => FALSE, 'socket' => '/path/to/socket', 'database' => FALSE)

'type://unix(/path/to/socket)/database'
    => array('type' => 'type', 'user' => FALSE, 'pass' => FALSE, 'host' => FALSE, 'port' => FALSE, 'socket' => '/path/to/socket', 'database' => 'database')

'type://username@unix(/path/to/socket)'
    => array('type' => 'type', 'user' => 'username', 'pass' => FALSE, 'host' => FALSE, 'port' => FALSE, 'socket' => '/path/to/socket', 'database' => FALSE)

'type://username:password@unix(/path/to/socket)'
    => array('type' => 'type', 'user' => 'username', 'pass' => 'password', 'host' => FALSE, 'port' => FALSE, 'socket' => '/path/to/socket', 'database' => FALSE)

0001-Use-parse_url-to-parse-DSN.patch Magnifier (2.59 KB) Chris Bandy, 07/19/2009 02:36 AM

Associated revisions

History

#1 Updated by Jeremy Bush over 5 years ago

  • Status changed from New to Review
  • Priority changed from Normal to Low

#2 Updated by Ben Rogers over 5 years ago

  • Assignee changed from John Heathco to Ben Rogers

#3 Updated by Ben Rogers about 5 years ago

  • Status changed from Review to Assigned

#4 Updated by Jeremy Bush about 5 years ago

  • Priority changed from Low to High

#5 Updated by Ben Rogers about 5 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

Applied in changeset r4531.

#6 Updated by Ben Rogers about 5 years ago

  • Resolution set to fixed

Also available in: Atom PDF