After testing a good deal of settings and looking at the code…
I have a solution for the postgres unix socket problem, with confirmed “local pipe” (unix socket) connections.
My solution uses a process to check if db_host = localhost for the pgsql db_type and if so, to use the linux socket (just as mysql does) and this should eliminate some confusion between the previous two different db settings (e.g. ‘localhost’ and ‘’) to get the unix socket.
Note: There seem to be two types of connections using two different database abstraction connection methods: ADOdb and PDO.
For ADOdb connection, I propose the following changes in class.egw_db.inc.php (starting on line 359 for the pgsql case):
case ‘pgsql’:
$type = ‘postgres’; // name in ADOdb
// create our own pgsql connection-string, to allow unix domain soccets if !$Host
if ($this->Host == ‘localhost’) {
$Host = “dbname=$this->Database user=$this->User”.($this->Password ? " password=’".addslashes($this->Password)."’" : ‘’);
} else {
$Host = “dbname=$this->Database”.($this->Host ? " host=$this->Host".($this->Port ? " port=$this->Port" : ‘’) : ‘’)." user=$this->User".($this->Password ? " password=’".addslashes($this->Password)."’" : ‘’);
}
$User = $Password = $Database = ‘’; // to indicate $Host is a connection-string
break;
For PDO connection, I propose the following changes in class.sqlfs_stream_wrapper.inc.php (starting on line 1368 to define the db switch, adding a case for pgsql):
switch($egw_db->Type)
{
case ‘pgsql’:
if ($egw_db->Host == ‘localhost’) {
$dsn = self::$pdo_type.":host=’’;port=’’;dbname=".$egw_db->Database;
} else {
$dsn = self::$pdo_type.’:host=’.$egw_db->Host.’;port=’.$egw_db->Port.’;dbname=’.$egw_db->Database;
}
break;
default:
$dsn = self::$pdo_type.’:host=’.$egw_db->Host.’;port=’.$egw_db->Port.’;dbname=’.$egw_db->Database;
break;
}
As you can see the only result that is changed for the original code is the Host == ‘localhost’ case for pgsql db_type to remove the host and port settings to enable use of the unix socket. Note: this would require Windows systems to use 127.0.0.1 instead of localhost for global db_host setting.
Note: When using unix sockets for postgres connection with ADOdb an PDO as implemented in eGroupware, there are warning/error messages each time a new persistent db connection is opened (but not when the persistent connection is reused). There is likely a bug somewhere related to this; however, I have noticed that the speed using the unix socket is sufficient to not need persistent connections (and given the controversy over persistent connections in the php community, this is likely the best route).