FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » Database host:port support
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Database host:port support [message #163964] Fri, 17 December 2010 12:57 Go to next message
mguillaume is currently offline  mguillaume   France
Messages: 13
Registered: December 2010
Karma: 0
Junior Member
Right now we don't have support for non-standard db ports (at least in PostgreSQL) though the GLOBALS_HELP suggest we should be able to use the "host:port" notation for the db host.

Suggestion: in data/sql/pgsql/db.inc, replace:
if ($GLOBALS['DBHOST']) {
    $connect_str .= 'host='. $GLOBALS['DBHOST'];
}

with:
if ($GLOBALS['DBHOST']) {
    $hostport=explode(":",$GLOBALS['DBHOST']);
    if (count($hostport)==1) {
        $connect_str .= 'host='. $GLOBALS['DBHOST'];
    } else {
        $connect_str .= 'host='.$hostport[0].' port='.$hostport[1];
    }
}


Note that this probably should be improved upon to support IPv6 addresses (which include ':' in their notation).
Re: Database host:port support [message #163965 is a reply to message #163964] Sat, 18 December 2010 23:19 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Can you please test the below code (with IPv6 support)?
if ($GLOBALS['DBHOST']) {
        // Expand optional port number (e.g. [::1]:5432).
        if ( preg_match('/^(.+):(\d*)$/', $GLOBALS['DBHOST'], $m)) {
                $GLOBALS['DBHOST'] = $m[1] .' port='. $m[2];
        }
        // Remove IPv6 block quotes.
        $connect_str .= preg_replace('/\[|\]/', '', 'host='. $GLOBALS['DBHOST']);
}
Re: Database host:port support [message #163967 is a reply to message #163965] Sun, 19 December 2010 04:46 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
Do you really wanna redefine a global variable in the 4th row instead of using a placeholder Frank?

Re: Database host:port support [message #163968 is a reply to message #163967] Sun, 19 December 2010 05:09 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Maybe not. We should to use a placeholder Smile
Re: Database host:port support [message #163970 is a reply to message #163968] Sun, 19 December 2010 14:17 Go to previous message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Patch committed.
Details at http://fudforum.svn.sourceforge.net/fudforum/?rev=5090&view=rev
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Suggestion for the "rebuild search index" page
Next Topic: Logging Group Manager actions
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 20:27:24 GMT 2024

Total time taken to generate the page: 0.02326 seconds