Commit e1b511fd authored by Eric Marsden's avatar Eric Marsden

*** empty log message ***

parent 0cbcbb6d
=== Version 0.20, 2003-xxxx ============================================
- added more tests for BOOLEAN types, to check the handling of
PostgreSQL errors (violation of an integrity constraint leads to an
error of type PG:BACKEND-ERROR being signaled). For CMUCL users who
use the multiprocessing support, there's a test that runs several data
producers and a consumer in different threads.
- error condition names (POSTGRESQL-ERROR, AUTHENTICATION-FAILURE,
BACKEND-ERROR are now exported from the PG package.
=== Version 0.19, 2003-10-10 ===========================================
- new multi-file organization: split out the system-dependent parts
and the tests into separate files. An ASDF system description is
provided in the file pg.asd.
- change to WITH-PG-TRANSACTION: the previous version would abort the
current transaction upon encountering an error, which made
debugging difficult. The new version (thanks to Daniel Barlow)
maintains the transaction open until you have exited the debugger.
- support for connecting to PostgreSQL using a local socket instead
of using TCP/IP, when you're on the same host as the backend. To
enable, use a NIL host argument to PG-CONNECT. This makes it
possible to connect to the database without enabling TCP/IP
connections in the backend ("-i" option), and (depending on the
access configuration parameters specified in pg_hba.conf) possibly
without supplying a password. This is currently only supported for
CMUCL and SBCL.
- parser support for the INTERVAL type (you get this by subtracting
two timestamps). They are coerced by pg-dot-lisp to a number of
seconds, represented in floating point.
- new configuration variable *PG-CLIENT-ENCODING*, that supports
client-side encoding of text data, as per
<http://www.postgresql.org/docs/7.3/static/multibyte.html>.
Function PG-CLIENT-ENCODING, and corresponding setf
function, that allows you to retrieve and modify the current client
encoding.
- new configuration variable *PG-DATE-STYLE* that allows you to
change the style in which date types are printed. Function
PG-DATE-STYLE that allows you to retrieve (and modify via its SETF
function) the current backend's date style.
- CMUCL: loading the file cmucl-install-subsystem.lisp (as a user who
has write access to the directory where CMUCL is installed) will
cause this package to be installed as a CMUCL "subsystem", that can
thereafter be loaded by saying "(require :pg)".
- SBCL: fix for new sb-bsd-sockets
- support for a new Common Lisp implementation, Armed Bear Lisp for
the JVM
=== Version 0.18, 2003-06-01 ============================================
- Fix for parsing of TIMESTAMP fields in PostgreSQL 7.3, thanks to
James Anderson. These can now contain timezone and millisecond
fields.
This diff is collapsed.
(defpackage :postgresql
(:nicknames :pg)
(:use :common-lisp
#+cmu :alien
#+cmu :c-call
#+openmcl :ccl)
#+openmcl (:shadow ccl:socket-connect)
(:export #:pg-connect #:pg-exec #:pg-result #:pg-disconnect
#:*pg-disable-type-coercion*
#:pg-databases #:pg-tables #:pg-columns
#:pg-backend-version
#:pg-date-style
#:pg-client-encoding
#:with-pg-connection
#:with-pg-transaction
#:pg-for-each
#:pglo-create
#:pglo-open
#:pglo-close
#:pglo-read
#:pglo-write
#:pglo-lseek
#:pglo-tell
#:pglo-unlink
#:pglo-import
#:pglo-export
#:postgresql-error
#:connection-failure
#:authentication-failure
#:protocol-error
#:backend-error))
;; EOF
This diff is collapsed.
;;; -*- Mode: lisp -*-
;;
;; For CMUCL, ensure that the crypt library is loaded before
;; attempting to load the code.
(in-package :asdf)
(defclass pg-component (cl-source-file)
())
#+cmu
(defmethod perform :before ((o load-op) (c pg-component))
(ext:load-foreign "/usr/lib/libcrypt.a"))
(defsystem :pg
:name "Socket-level PostgreSQL interface"
:author "Eric Marsden"
:version "0.19"
:components ((:file "defpackage")
(:file "sysdep" :depends-on ("defpackage"))
(:pg-component "pg" :depends-on ("sysdep"))))
This diff is collapsed.
;;; system-dependent parts of pg-dot-lisp
(in-package :pg)
(eval-when (:compile-toplevel :load-toplevel :execute)
#+allegro (require :socket)
#+lispworks (require "comm")
#+cormanlisp (require :sockets)
#+sbcl (progn (require :asdf) (require :sb-bsd-sockets))
#+(and mcl (not openmcl)) (require "OPENTRANSPORT"))
#+(and cmu glibc2)
(eval-when (:compile-toplevel :load-toplevel)
(format t ";; Loading libcrypt~%")
;; (ext:load-foreign "/lib/libcrypt.so.1")
(sys::load-object-file "/usr/lib/libcrypt.so"))
#+(and cmu glibc2)
(defun crypt (key salt)
(declare (type string key salt))
(alien:alien-funcall
(alien:extern-alien "crypt"
(function c-call:c-string c-call:c-string c-call:c-string))
key salt))
#-(and cmu glibc2)
(defun crypt (key salt)
(declare (ignore salt))
key)
;; this is a little fiddly, because CLISP can be built without support
;; for the Linux package
;; #+CLISP
;; (defun crypt (key salt)
;; (linux::crypt key salt))
;; bug in WRITE-SEQUENCE in CMUCL
#+(or cmu18c cmu18d)
(defun write-sequence (seq stream &key start end)
(declare (ignore start end))
(loop :for element :across seq
:do (write-byte element stream)))
;; work around bug in FASL fop dumping
#+cmu (setf c::top-level-lambda-max 0)
#+(and cmu ssl)
(defun socket-connect (port host)
(declare (type integer port))
(handler-case
(let ((fd (ext:connect-to-inet-socket host port)))
(ssl:make-ssl-client-stream fd))
(error (e)
(error 'connection-failure
:host host
:port port
:transport-error e))))
#+cmu
(defun socket-connect (port host)
(declare (type integer port))
(handler-case
(let ((fd (if host
(ext:connect-to-inet-socket host port)
(ext:connect-to-unix-socket
(format nil "/var/run/postgresql/.s.PGSQL.~D" port)))))
(sys:make-fd-stream fd :input t :output t
:element-type '(unsigned-byte 8)))
(error (e)
(error 'connection-failure
:host host
:port port
:transport-error e))))
;; this doesn't currently work, because WRITE-SEQUENCE is not
;; implemented
#+(and cmu simple-streams broken)
(defun socket-connect (port host)
(declare (type integer port))
(handler-case
(make-instance 'stream:socket-simple-stream
:remote-host host
:remote-port port
:direction :io)
(error (e)
(error 'connection-failure
:host host
:port port
:transport-error e))))
#+clisp
(defun socket-connect (port host)
(declare (type integer port))
(handler-case
(#+lisp=cl socket:socket-connect
#-lisp=cl lisp:socket-connect
port host :element-type '(unsigned-byte 8))
(error (e)
(declare (ignore e))
(error 'connection-failure :host host :port port))))
#+db-sockets
(defun socket-connect (port host)
(declare (type integer port))
(handler-case
(let ((s (sockets:make-inet-socket :stream :tcp))
(num (car (sockets:host-ent-addresses
(sockets:get-host-by-name host)))))
(sockets:socket-connect s num port)
(sockets:socket-make-stream s :element-type '(unsigned-byte 8)
:input t :output t :buffering :none))
(error (e)
(error 'connection-failure
:host host
:port port
:transport-error e))))
#+sbcl
(defun socket-connect (port host)
(declare (type integer port))
(handler-case
(sb-bsd-sockets:socket-make-stream
(if host
(let ((s (make-instance 'sb-bsd-sockets:inet-socket
:type :stream :protocol :tcp))
(num (car (sb-bsd-sockets:host-ent-addresses
(sb-bsd-sockets:get-host-by-name host)))))
(sb-bsd-sockets:socket-connect s num port)
s)
(let ((s (make-instance 'sb-bsd-sockets:local-socket :type :stream)))
(sb-bsd-sockets:socket-connect
s (format nil "/var/run/postgresql/.s.PGSQL.~D" port))
s))
:element-type '(unsigned-byte 8)
:input t
:output t
:buffering :none)
(error (e)
(error 'connection-failure :host host :port port :transport-error e))))
#+allegro
(defun socket-connect (port host)
(declare (type integer port))
(handler-case
(socket:make-socket :remote-host host
:remote-port port
:format :binary)
(error (e)
(signal 'connection-failure
:host host
:port port
:transport-error e))))
;; Lispworks 4.2 doesn't seem to implement WRITE-SEQUENCE on binary
;; streams. Fixed in version 4.3.
#+lispworks
(defun socket-connect (port host)
(declare (type integer port))
(comm:open-tcp-stream host port
:element-type '(unsigned-byte 8)
:direction :io))
;; this doesn't work, since the Corman sockets module doesn't support
;; binary I/O on socket streams.
#+cormanlisp
(defun socket-connect (port host)
(declare (type integer port))
(handler-case
(progn
(sockets:start-sockets)
(let ((sock (sockets:make-client-socket :host host :port port)))
(sockets:make-socket-stream sock)))
(error (e)
(declare (ignore e))
(error 'connection-failure :host host :port port))))
#+openmcl
(defun socket-connect (port host)
(declare (type integer port))
(let ((sock (make-socket :type :stream
:connect :active
:format :binary
:remote-host host
:remote-port port)))
sock))
;; from John DeSoi
#+(and mcl (not openmcl))
(defun socket-connect (port host)
(declare (type integer port))
(ccl::open-tcp-stream host port :element-type '(unsigned-byte 8)))
;; There is a bug in MCL (4.3.1 tested) where read-sequence and
;; write-sequence fail with binary tcp streams. These two methods
;; provide a work-around.
#+(and mcl (not openmcl))
(defmethod ccl:stream-write-sequence ((s ccl::opentransport-binary-tcp-stream)
(sequence ccl::simple-unsigned-byte-vector)
&key (start 0) end)
(ccl::stream-write-vector s sequence start (or end (length sequence)))
s)
#+(and mcl (not openmcl))
(defmethod ccl:stream-read-sequence ((s ccl::opentransport-binary-tcp-stream)
(sequence ccl::simple-unsigned-byte-vector)
&key (start 0) (end (length sequence)))
(ccl::io-buffer-read-bytes-to-vector (ccl::stream-io-buffer s)
sequence (- end start) start)
end)
;; there seems to be a bug in ECL's binary socket streams; data is corrupted
#+ecl
(defun socket-connect (port host)
(declare (type integer port))
(si:open-client-stream host port))
;; #+ecl
;; (defun write-sequence (seq stream &key start end)
;; (declare (ignore start end))
;; (loop :for element :across seq
;; :do (write-byte element stream)))
;;
;; #+ecl
;; (defun read-bytes (connection howmany)
;; (let ((v (make-array howmany :element-type '(unsigned-byte 8)))
;; (s (pgcon-stream connection)))
;; (loop :for pos :below howmany
;; :do (setf (aref v pos) (read-byte s)))
;; v))
;;
;; #+ecl
;; (defun cl:read-sequence (seq stream &key (start 0) (end (length seq)))
;; (loop :for pos :from start :below end
;; :do (setf (aref seq pos) (read-byte stream))))
;; as of version 2.6 GCL is way too broken to run this: DEFPACKAGE doesn't
;; work, DEFINE-CONDITION not implemented, ...
#+gcl
(defun socket-connect (port host)
(declare (type integer port))
(si::socket port :host host))
#+armedbear
(defun socket-connect (port host)
(declare (type integer port))
(ext:make-binary-socket host port))
#+armedbear
(defun cl:write-sequence (seq stream &key (start 0) (end (length seq)))
(declare (ignore start end))
(loop :for element :across seq
:do (write-byte element stream)))
#+armedbear
(defun read-bytes (connection howmany)
(let ((v (make-array howmany :element-type '(unsigned-byte 8)))
(s (pgcon-stream connection)))
(loop :for pos :below howmany
:do (setf (aref v pos) (read-byte s)))
v))
#+armedbear
(defun cl:read-sequence (seq stream &key (start 0) (end (length seq)))
(loop :for pos :from start :below end
:do (setf (aref seq pos) (read-byte stream))))
;; EOF
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment