[postmodern-devel] Local connection to Postgresql under FreeBSD

rrl endian.sign at gmail.com
Sat May 15 08:41:55 UTC 2010


Hi,

I can connect to Postgresql using a Unix socket with sbcl by passing
:unix as a host.  The problem is that under FreeBSD, the default
directory for the socket is ``/tmp'' and not ``/var/run/postgresql''.
Here's a quick fix that solves the problem:

--- public.lisp.orig    2010-04-14 21:41:39.000000000 +0300
+++ public.lisp 2010-05-15 11:21:56.000000000 +0300
@@ -47,7 +47,9 @@
 #+(and sbcl unix)
 (defun sb-unix-socket-connect (port)
   (let ((sock (make-instance 'sb-bsd-sockets:local-socket :type :stream))
-        (addr (format nil "/var/run/postgresql/.s.PGSQL.~a" port)))
+        (addr (format nil "~a/.s.PGSQL.~a"
+                      #-freebsd "/var/run/postgresql" #+freebsd "/tmp"
+                      port)))
     (sb-bsd-sockets:socket-connect sock addr)
     (sb-bsd-sockets:socket-make-stream
      sock :input t :output t :element-type '(unsigned-byte 8))))

Maybe a better fix would be to define a variable for the socket
directory and let the user set it himself.




More information about the postmodern-devel mailing list