X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=inline;f=interfaces%2Fpostgresql%2Fpostgresql-sql.cl;fp=interfaces%2Fpostgresql%2Fpostgresql-sql.cl;h=db4128bf96c4eab0469eda865be9e716a44d029d;hb=33401393ccc0a9567da4104b3c2e7608956a8624;hp=f0a1ee1bd511a614a6b5002c6152278570738e2d;hpb=421ef23a5a01534ac4c4d7594d182023ed31b376;p=clsql.git diff --git a/interfaces/postgresql/postgresql-sql.cl b/interfaces/postgresql/postgresql-sql.cl index f0a1ee1..db4128b 100644 --- a/interfaces/postgresql/postgresql-sql.cl +++ b/interfaces/postgresql/postgresql-sql.cl @@ -8,7 +8,7 @@ ;;;; Original code by Pierre R. Mai ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: postgresql-sql.cl,v 1.7 2002/03/25 06:07:06 kevin Exp $ +;;;; $Id: postgresql-sql.cl,v 1.8 2002/03/25 14:13:41 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai @@ -30,14 +30,15 @@ ;;; Field conversion functions -(defun canonicalize-field-types (types num-fields) - (if (listp types) - (let ((length-types (length types)) - new-types) - (loop for i from 0 below num-fields +(defun canonicalize-field-types (types num-fields res-ptr) + (cond + ((if (listp types) + (let ((length-types (length types)) + (new-types '())) + (loop for i from 0 below num-fields do - (if (>= i length-types) - (push t new-types) ;; types is shorted than num-fields + (if (>= i length-types) + (push t new-types) ;; types is shorted than num-fields (push (case (nth i types) ((:int :long :double t) @@ -45,10 +46,28 @@ (t t)) new-types))) - (nreverse new-types)) - (if (eq types :auto) - :auto - nil))) + (nreverse new-types)))) + ((eq types :auto) + (let ((new-types '())) + (dotimes (i num-fields) + (declare (fixnum i)) + (let* ((type (PQftype res-ptr i))) + (push + (case type + ((#.pgsql-ftype#bytea + #.pgsql-ftype#int2 + #.pgsql-ftype#int4) + :int) + ((#.pgsql-ftype#float4 + #.pgsql-ftype#float8) + :double) + (otherwise + t)) + new-types))) + (nreverse new-types))) + (t + nil))) + (uffi:def-function "atoi" ((str :cstring)) @@ -165,7 +184,8 @@ (#.pgsql-exec-status-type#tuples-ok (let ((num-fields (PQnfields result))) (setq field-types - (canonicalize-field-types field-types num-fields)) + (canonicalize-field-types field-types num-fields + result)) (loop for tuple-index from 0 below (PQntuples result) collect (loop for i from 0 below num-fields @@ -242,7 +262,8 @@ :num-tuples (PQntuples result) :field-types (canonicalize-field-types field-types - (PQnfields result))))) + (PQnfields result) + result)))) (if full-set (values result-set (PQnfields result)