X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-postgresql-socket3%2Fsql.lisp;h=12929c6e85d3cc9ba20c46e9a2960a87cddf38bf;hb=3ab5ff5c8b7f6a8fc37f5870b9518a0862f2e611;hp=db3ba86e8942660c51e73779d5645a4a1251742e;hpb=f1d668746523a72a6893a46380468a9e033545e4;p=clsql.git diff --git a/db-postgresql-socket3/sql.lisp b/db-postgresql-socket3/sql.lisp index db3ba86..12929c6 100644 --- a/db-postgresql-socket3/sql.lisp +++ b/db-postgresql-socket3/sql.lisp @@ -22,24 +22,29 @@ (defpackage :clsql-postgresql-socket3 (:use #:common-lisp #:clsql-sys #:postgresql-socket3) (:export #:postgresql-socket3-database) - (:documentation "This is the CLSQL socket interface (protocol version 3) to PostgreSQL.")) + (:documentation + "This is the CLSQL socket interface (protocol version 3) to PostgreSQL.")) (in-package #:clsql-postgresql-socket3) (defvar *sqlreader* (cl-postgres:copy-sql-readtable)) -(let ((dt-fn (lambda (useconds-since-2000) - (let ((sec (truncate - (/ useconds-since-2000 - 1000000))) - (usec (mod useconds-since-2000 - 1000000))) - (clsql:make-time :year 2000 :second sec :usec usec))))) + + +(labels ((d-fn (days-since-2000) + (clsql:make-date :year 2000 :day (+ 1 days-since-2000))) + (dt-tz-fn (useconds-since-2000 + &aux (dt (dt-fn useconds-since-2000))) + (setf (clsql-sys::time-is-utc? dt) t) + dt) + (dt-fn (useconds-since-2000) + (multiple-value-bind (sec usec) + (floor useconds-since-2000 1000000) + (clsql:make-time :year 2000 :second sec :usec usec)))) (cl-postgres:set-sql-datetime-readers :table *sqlreader* - :date (lambda (days-since-2000) - (clsql:make-date :year 2000 :day (+ 1 days-since-2000))) - :timestamp dt-fn - :timestamp-with-timezone dt-fn)) + :timestamp #'dt-fn + :timestamp-with-timezone #'dt-tz-fn + :date #'d-fn)) @@ -109,6 +114,7 @@ (etypecase host (null "localhost") + (keyword "unix") (pathname (namestring host)) (string host)) (when port @@ -182,8 +188,8 @@ (declare (type (signed-byte 32) cl-postgres::size)) (if (eq cl-postgres::size -1) nil - (funcall (cl-postgres::field-interpreter cl-postgres::field) - stream cl-postgres::size))))) + (funcall (cl-postgres::field-interpreter cl-postgres::field) + stream cl-postgres::size))))) (let ((results (loop :while (cl-postgres:next-row) :collect (loop :for field :across fields :collect (cl-postgres:next-field field)))) @@ -325,12 +331,3 @@ (clsql-sys:initialize-database-type :database-type :postgresql-socket3)) -;; Type munging functions - -(defmethod read-sql-value (val (type (eql 'boolean)) (database postgresql-socket3-database) db-type) - (declare (ignore database db-type)) - val) - -(defmethod read-sql-value (val (type (eql 'generalized-boolean)) (database postgresql-socket3-database) db-type) - (declare (ignore database db-type)) - val)