Index: doc/src/sgml/libpq.sgml =================================================================== RCS file: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v retrieving revision 1.208 diff -c -c -r1.208 libpq.sgml *** doc/src/sgml/libpq.sgml 6 May 2006 16:25:11 -0000 1.208 --- doc/src/sgml/libpq.sgml 17 May 2006 01:52:40 -0000 *************** *** 4000,4008 **** entries first when you are using wildcards.) If an entry needs to contain : or \, escape this character with \. ! A hostname of localhost matches both host (TCP) ! and local (Unix domain socket) connections coming from the ! local machine. --- 4000,4008 ---- entries first when you are using wildcards.) If an entry needs to contain : or \, escape this character with \. ! A hostname of localhost matches both TCP host (hostname localhost) ! and Unix domain socket local (pghost empty or the default socket directory) ! connections coming from the local machine. Index: src/interfaces/libpq/fe-connect.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v retrieving revision 1.328 diff -c -c -r1.328 fe-connect.c *** src/interfaces/libpq/fe-connect.c 14 Mar 2006 22:48:23 -0000 1.328 --- src/interfaces/libpq/fe-connect.c 17 May 2006 01:52:59 -0000 *************** *** 3106,3114 **** --- 3106,3129 ---- if (username == NULL || strlen(username) == 0) return NULL; + /* 'localhost' matches pghost of '' or the default socket directory */ if (hostname == NULL) hostname = DefaultHost; + else if (is_absolute_path(hostname)) + { + char canon_host[MAXPGPATH]; + char canon_def_socket[MAXPGPATH]; + + StrNCpy(canon_host, hostname, MAXPGPATH); + StrNCpy(canon_def_socket, DEFAULT_PGSOCKET_DIR, MAXPGPATH); + canonicalize_path(canon_host); + canonicalize_path(canon_def_socket); + + if (strcmp(canon_host, canon_def_socket) == 0) + hostname = DefaultHost; + } + if (port == NULL) port = DEF_PGPORT_STR;