X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=db-postgresql-socket%2Fpostgresql-socket-api.lisp;h=ba0cd221bbdc547c920d174bb023c22cdea58b3e;hp=a1283951c30b0f6afbdc83f6c59517d94d044ab3;hb=d9f41af62750c622945bb17b622a39689ee5b840;hpb=5d6de675e75567edd02a8a175fc2c68ebb0a8597 diff --git a/db-postgresql-socket/postgresql-socket-api.lisp b/db-postgresql-socket/postgresql-socket-api.lisp index a128395..ba0cd22 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-sys: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-sys:database-type-load-foreign ((database-type (eql :postgresql-socket))) t) @@ -226,19 +214,20 @@ socket interface" ;;; Support for encrypted password transmission #-scl -(eval-when (compile eval load) +(eval-when (:compile-toplevel :load-toplevel :execute) (defvar *crypt-library-loaded* nil) (unless *crypt-library-loaded* (uffi:load-foreign-library (uffi:find-foreign-library "libcrypt" - '("/usr/lib/" "/usr/local/lib/" "/lib/")) + '(#+64bit "/usr/lib64/" + "/usr/lib/" "/usr/local/lib/" "/lib/")) :supporting-libraries '("c")) (setq *crypt-library-loaded* t))) (in-package :postgresql-socket) -(uffi:def-function "crypt" +(uffi:def-function ("crypt" crypt) ((key :cstring) (salt :cstring)) :returning :cstring) @@ -386,11 +375,9 @@ socket interface" :connect :active :remote-filename path :local-filename path))) (string - (socket:with-pending-connect - (mp:with-timeout (*postgresql-server-socket-timeout* (error "connect failed")) - (ccl:make-socket :type :stream :address-family :internet - :remote-port port :remote-host host - :connect :active :nodelay t)))))) + (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) @@ -471,14 +458,16 @@ connection, if it is still open." (3 (send-unencrypted-password-message socket - (postgresql-connection-password connection))) + (postgresql-connection-password connection)) + (force-output socket)) (4 (let ((salt (make-string 2))) (read-socket-sequence salt socket) (send-encrypted-password-message socket (crypt-password - (postgresql-connection-password connection) salt)))) + (postgresql-connection-password connection) salt))) + (force-output socket)) (5 (let ((salt (make-string 4))) (read-socket-sequence salt socket) @@ -487,7 +476,8 @@ connection, if it is still open." (pwd (encrypt-md5 pwd2 salt))) (send-encrypted-password-message socket - (concatenate 'string "md5" pwd))))) + (concatenate 'string "md5" pwd)))) + (force-output socket)) (t (error 'postgresql-login-error :connection connection @@ -614,8 +604,9 @@ connection, if it is still open." :connection connection :message message)))) (#.+notice-response-message+ (let ((message (read-socket-value-string socket))) - (warn 'postgresql-warning - :connection connection :message message))) + (unless (eq :ignore clsql-sys:*backend-warning-behavior*) + (warn 'postgresql-warning + :connection connection :message message)))) (#.+notification-response-message+ (let ((pid (read-socket-value-int32 socket)) (message (read-socket-value-string socket)))