X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=db-postgresql-socket%2Fpostgresql-socket-api.lisp;h=5630f04eceb3c2254a2a3c2253586583201a7fed;hp=13ce8e9965d2f5a1765796c904c4bdaabd5e162f;hb=9bbed78051e80e6ab76ae47834136035602bbbf1;hpb=5691bb90517d7c565a141d131da76c3de1f8d566 diff --git a/db-postgresql-socket/postgresql-socket-api.lisp b/db-postgresql-socket/postgresql-socket-api.lisp index 13ce8e9..5630f04 100644 --- a/db-postgresql-socket/postgresql-socket-api.lisp +++ b/db-postgresql-socket/postgresql-socket-api.lisp @@ -2,16 +2,14 @@ ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; -;;;; Name: postgresql-socket-api.lisp -;;;; Purpose: Low-level PostgreSQL interface using sockets -;;;; Programmers: Kevin M. Rosenberg based on -;;;; Original code by Pierre R. Mai -;;;; -;;;; Date Started: Feb 2002 +;;;; Name: postgresql-socket-api.lisp +;;;; Purpose: Low-level PostgreSQL interface using sockets +;;;; Authors: Kevin M. Rosenberg based on original code by Pierre R. Mai +;;;; Created: Feb 2002 ;;;; ;;;; $Id$ ;;;; -;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg +;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software @@ -19,16 +17,6 @@ ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;; ************************************************************************* - -;;;; Changes by Kevin Rosenberg -;;;; - Added socket open functions for Allegro and Lispworks -;;;; - Changed CMUCL FFI to UFFI -;;;; - Added necessary (force-output) for socket streams on -;;;; Allegro and Lispworks -;;;; - Added initialization variable -;;;; - Added field type processing - - (in-package #:postgresql-socket) (uffi:def-enum pgsql-ftype @@ -39,13 +27,13 @@ (:float4 700) (:float8 701))) -(defmethod clsql-base-sys:database-type-library-loaded ((database-type +(defmethod clsql-base:database-type-library-loaded ((database-type (eql :postgresql-socket))) "T if foreign library was able to be loaded successfully. Always true for socket interface" t) -(defmethod clsql-base-sys:database-type-load-foreign ((database-type (eql :postgresql-socket))) +(defmethod clsql-base:database-type-load-foreign ((database-type (eql :postgresql-socket))) t) @@ -310,7 +298,6 @@ socket interface" (defvar *postgresql-server-socket-timeout* 60 "Timeout in seconds for reads from the PostgreSQL server.") - #+(or cmu scl) (defun open-postgresql-socket (host port) (etypecase host @@ -323,6 +310,26 @@ socket interface" (string (ext:connect-to-inet-socket host port)))) +#+sbcl +(defun open-postgresql-socket (host port) + (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)))) + (string + (let ((sock (make-instance 'sb-bsd-sockets:inet-socket + :type :stream + :protocol :tcp))) + (sb-bsd-sockets:socket-connect + sock + (sb-bsd-sockets:host-ent-address + (sb-bsd-sockets:get-host-by-name host)) + port) + sock)))) + #+(or cmu scl) (defun open-postgresql-socket-stream (host port) (system:make-fd-stream @@ -334,11 +341,10 @@ socket interface" #+sbcl (defun open-postgresql-socket-stream (host port) - (sb-sys:make-fd-stream - (open-postgresql-socket host port) - :input t :output t :element-type '(unsigned-byte 8) - :buffering :none - :timeout *postgresql-server-socket-timeout*)) + (sb-bsd-sockets:socket-make-stream + (open-postgresql-socket host port) :input t :output t + :element-type '(unsigned-byte 8))) + #+allegro (defun open-postgresql-socket-stream (host port) @@ -357,6 +363,21 @@ socket interface" :remote-port port :remote-host host :connect :active :nodelay t)))))) +#+openmcl +(defun open-postgresql-socket-stream (host port) + (etypecase host + (pathname + (let ((path (namestring + (make-pathname :name ".s.PGSQL" :type (princ-to-string port) + :defaults host)))) + (ccl:make-socket :type :stream :address-family :file + :connect :active + :remote-filename path :local-filename path))) + (string + (ccl:make-socket :type :stream :address-family :internet + :remote-port port :remote-host host + :connect :active :nodelay t)))) + #+lispworks (defun open-postgresql-socket-stream (host port) (etypecase host