Update of /project/pg/cvsroot/pg In directory common-lisp.net:/tmp/cvs-serv9011
Modified Files: large-object.lisp v2-protocol.lisp v3-protocol.lisp lowlevel.lisp pg.lisp Log Message: Make PGLO-READ a generic function, with specializations on the v2 and v3 protocols. The difference is necessary because the v2 protocol reads large-object data in text, whereas the v3 protocol changed to use a binary format.
Date: Sun Jul 17 17:48:06 2005 Author: emarsden
Index: pg/large-object.lisp diff -u pg/large-object.lisp:1.2 pg/large-object.lisp:1.3 --- pg/large-object.lisp:1.2 Fri Aug 13 18:50:37 2004 +++ pg/large-object.lisp Sun Jul 17 17:48:06 2005 @@ -1,6 +1,6 @@ ;;; large-object.lisp -- support for BLOBs ;;; -;;; Author: Eric Marsden emarsden@laas.fr +;;; Author: Eric Marsden eric.marsden@free.fr ;; ;; ;; Sir Humphrey: Who is Large and to what does he object? @@ -81,10 +81,10 @@ (defun pglo-close (connection fd) (fn connection "lo_close" t fd))
-;; note that the 3rd argument means that we are reading data in binary -;; format, not text -(defun pglo-read (connection fd bytes) - (fn connection "loread" t fd bytes)) +;; pglo-read has moved to v2-protocol.lisp and v3-protocol.lisp +;; +;; the difference between the v3 and v2 protocols is that in the former case +;; data is read in binary format, whereas in the latter data is read as text.
(defun pglo-write (connection fd buf) (fn connection "lowrite" t fd buf))
Index: pg/v2-protocol.lisp diff -u pg/v2-protocol.lisp:1.4 pg/v2-protocol.lisp:1.5 --- pg/v2-protocol.lisp:1.4 Thu Apr 1 20:35:19 2004 +++ pg/v2-protocol.lisp Sun Jul 17 17:48:06 2005 @@ -1,6 +1,6 @@ ;;; v2-protocol.lisp -- frontend/backend protocol prior to PostgreSQL 7.4 ;;; -;;; Author: Eric Marsden emarsden@laas.fr +;;; Author: Eric Marsden eric.marsden@free.fr
(in-package :postgresql) @@ -197,6 +197,9 @@ ((stringp arg) (send-int connection (length arg) 4) (send-string connection arg)) + ((vectorp arg) + (send-int connection (length arg) 4) + (send-octets connection arg)) (t (error 'protocol-error :reason (format nil "Unknown fastpath type ~s" arg))))) (%flush connection) @@ -293,6 +296,12 @@ (defun handle-notice (connection) (push (%read-cstring (pgcon-stream connection) +MAX_MESSAGE_LEN+) (pgcon-notices connection))) + + +;; split out from large-object.lisp +(defmethod pglo-read ((connection pgcon-v2) fd bytes) + (let ((octets (fn connection "loread" nil fd bytes))) + (map '(vector (unsigned-byte 8)) #'char-code octets)))
;; EOF
Index: pg/v3-protocol.lisp diff -u pg/v3-protocol.lisp:1.16 pg/v3-protocol.lisp:1.17 --- pg/v3-protocol.lisp:1.16 Sun Jul 17 15:46:50 2005 +++ pg/v3-protocol.lisp Sun Jul 17 17:48:06 2005 @@ -965,4 +965,11 @@ (defmethod pg-close-portal ((connection pgcon-v3) (portal string)) (pg-close connection portal #\P))
+ +;; split out from large-object.lisp +(defmethod pglo-read ((connection pgcon-v3) fd bytes) + (fn connection "loread" t fd bytes)) + + + ;; EOF
Index: pg/lowlevel.lisp diff -u pg/lowlevel.lisp:1.3 pg/lowlevel.lisp:1.4 --- pg/lowlevel.lisp:1.3 Mon Mar 8 19:12:45 2004 +++ pg/lowlevel.lisp Sun Jul 17 17:48:06 2005 @@ -1,7 +1,7 @@ ;;; lowlevel.lisp -- lowlevel network ;;; ;;; Author: Eric Marsden <emarsden> -;;; Time-stamp: <2004-03-08 emarsden> +;;; Time-stamp: <2005-07-17 emarsden>
(in-package :postgresql) @@ -117,6 +117,10 @@ :initial-element 0 :element-type '(unsigned-byte 8)) stream)))) + +(defun send-octets (connection buffer) + (declare (type (vector (unsigned-byte 8) *) buffer)) + (write-sequence buffer (pgcon-stream connection)))
;; highest order bits first (defun send-int (connection int bytes)
Index: pg/pg.lisp diff -u pg/pg.lisp:1.4 pg/pg.lisp:1.5 --- pg/pg.lisp:1.4 Mon Mar 8 16:01:53 2004 +++ pg/pg.lisp Sun Jul 17 17:48:06 2005 @@ -1,10 +1,10 @@ ;;; pg.lisp -- socket level interface to the PostgreSQL RDBMS for Common Lisp ;; -;; Author: Eric Marsden emarsden@laas.fr -;; Time-stamp: <2004-03-08 emarsden> -;; Version: 0.21 +;; Author: Eric Marsden eric.marsden@free.fr +;; Time-stamp: <2005-07-17 emarsden> +;; Version: 0.22 ;; -;; Copyright (C) 1999,2000,2001,2002,2003 Eric Marsden +;; Copyright (C) 1999,2000,2001,2002,2003,2004,2005 Eric Marsden ;; ;; This library is free software; you can redistribute it and/or ;; modify it under the terms of the GNU Library General Public @@ -20,10 +20,7 @@ ;; License along with this library; if not, write to the Free ;; Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;; -;; Please send suggestions and bug reports to emarsden@laas.fr -;; The latest version of this package should be available from -;; -;; URL:http://purl.org/net/emarsden/home/downloads/ +;; Please send suggestions and bug reports to eric.marsden@free.fr
;;; Overview ========================================================= @@ -42,27 +39,13 @@ ;; ;; See the README for API documentation.
-;; This code has been tested or reported to work with -;; -;; * CMUCL 18d and 18e on Solaris/SPARC and Linux/x86 -;; * SBCL 0.8 on Linux/x86 and Linux/PowerPC -;; * CLISP 2.31 on Linux/PowerPC, Solaris and Linux/x86 -;; * OpenMCL 0.13.6 on Linux/PowerPC and MacOS 10.2 -;; * Armed Bear Lisp version 0.20 -;; * Lispworks 4.3 personal edition for MacOS X and win32 -;; * Allegro CL 6.1 trial Linux/x86 -;; * ECL as of 2003-10-10 -;; * PostgreSQL 6.5, 7.0, 7.1.2, 7.2, 7.3 (and equivalent "Red Hat -;; Database" versions) -;; -;; ;; Please note that your postmaster has to be started with the `-i' ;; option in order for it to accept TCP/IP connections (typically this ;; is not the default setting). See the PostgreSQL documentation at ;; URL:http://www.PostgreSQL.org/ for more information. ;; ;; Thanks to Marc Battyani for the LW port and for bugfixes, to -;; Johannes Grødem johs@copyleft.no for a fix to parsing of DATE +;; Johannes GrÞdem johs@copyleft.no for a fix to parsing of DATE ;; types, to Doug McNaught and Howard Ding for bugfixes, to Ernst ;; Jeschek for pointing out a bug in float parsing, to Brian Lui for ;; providing fixes for ACL6, to James Anderson for providing a fix for @@ -222,6 +205,11 @@ (defgeneric pg-close-portal (connection portal) (:documentation "Closes a prepared statement")) + +(defgeneric pglo-read (connection fd bytes) + (:documentation + "Read from a large object on file descriptor FD.")) +
;; first attempt to connect to connect using the v3 protocol; if this ;; results in an ErrorResponse we close the connection and retry using