Patch for postgresql domain socket connections
"Steven E. Harris" <[email protected]> Mon, 09 Jan 2006 14:43:47 -0800
| Newsgroups | gmane.lisp.clsql.devel |
|---|---|
| Organization | SEH Labs |
| Message-ID | <[email protected]> |
Working on Debian with CLSQL against PostgreSQL with
clsql-postgresql-socket package version 3.5.0-1 and sbcl package
version 0.9.7.1-3, I noticed a problem trying to connect to a database
via a local domain socket:
(clsql:with-database (db `(,(make-pathname :directory '(:absolute "var" "run" "postgresql"))
"demo" "seh" "")
:database-type :postgresql-socket)
(print "Connected!"))
Up the call chain, this form eventually calls on the
open-postgresql-socket function in postgresql-socket-api.lisp,
choosing the branch with the "host" parameter as a pathname. There we
call on sb-bsd-sockets:socket-connect passing a namestring as the sole
parameter. Instead, we need to pass an instance of an
sb-bsd-sockets:local-socket¹ as the first argument²:
,----[ open-postgresql-socket fragment ]
| (defun open-postgresql-socket (host port)
| (etypecase host
| (pathname
| ;; Directory to unix-domain socket
| (let ((sock (make-instance 'sb-bsd-sockets:local-socket
| :type :stream)))
| (sb-bsd-sockets:socket-connect
| sock
| (namestring
| (make-pathname :name ".s.PGSQL" :type (princ-to-string port)
| :defaults host)))
| sock))
`----
Find a suitable patch attached.
Footnotes:
¹ http://www.sbcl.org/manual/Local--Unix--Domain-Sockets.html#Local%20(Unix)%20Domain%20Sockets
² http://www.sbcl.org/manual/General-Sockets.html#General%20Sockets
--
Steven E. Harris
_______________________________________________
CLSQL-Devel mailing list
[email protected]
http://lists.b9.com/mailman/listinfo/clsql-devel
postgresql-socket-api.lisp.diff
(text/x-patch, 811 B)
--- db-postgresql-socket/postgresql-socket-api.lisp.orig 2006-01-09 14:19:49.696250000 -0800
+++ db-postgresql-socket/postgresql-socket-api.lisp 2006-01-09 14:20:05.477500000 -0800
@@ -334,10 +334,14 @@
(etypecase host
(pathname
;; Directory to unix-domain socket
- (sb-bsd-sockets:socket-connect
- (namestring
- (make-pathname :name ".s.PGSQL" :type (princ-to-string port)
- :defaults host))))
+ (let ((sock (make-instance 'sb-bsd-sockets:local-socket
+ :type :stream)))
+ (sb-bsd-sockets:socket-connect
+ sock
+ (namestring
+ (make-pathname :name ".s.PGSQL" :type (princ-to-string port)
+ :defaults host)))
+ sock))
(string
(let ((sock (make-instance 'sb-bsd-sockets:inet-socket
:type :stream