r1650: *** empty log message ***
[clsql.git] / interfaces / postgresql / postgresql-sql.cl
index cb83a348b0cfe0a637cdf0042e008ceeef6ca8bd..6dedf46fa2a02f06fb074d30f9f50881c780289d 100644 (file)
@@ -8,7 +8,7 @@
 ;;;;                Original code by Pierre R. Mai 
 ;;;; Date Started:  Feb 2002
 ;;;;
-;;;; $Id: postgresql-sql.cl,v 1.1 2002/03/23 14:04:53 kevin Exp $
+;;;; $Id: postgresql-sql.cl,v 1.3 2002/03/24 18:08:27 kevin Exp $
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
                         (host db user password &optional port options tty))
   (destructuring-bind (host db user password &optional port options tty)
       connection-spec
-    (uffi:with-cstring (host-native host)
-      (uffi:with-cstring (user-native user)
-       (uffi:with-cstring (password-native password)
-         (uffi:with-cstring (db-native db)
-           (uffi:with-cstring (port-native port)
-             (uffi:with-cstring (options-native options)
-               (uffi:with-cstring (tty-native tty)
-                 (let ((connection (PQsetdbLogin host-native port-native
-                                                 options-native tty-native
-                                                 db-native user-native
-                                                 password-native)))
-                   (declare (type pgsql-conn-def connection))
-                   (when (not (eq (PQstatus connection) 
-                                  pgsql-conn-status-type#connection-ok))
-                     (error 'clsql-connect-error
-                            :database-type database-type
-                            :connection-spec connection-spec
-                            :errno (PQstatus connection)
-                            :error (tidy-error-message 
-                                    (PQerrorMessage connection))))
-                   (make-instance 'postgresql-database
-                     :name (database-name-from-spec connection-spec
-                                                    database-type)
-                     :conn-ptr connection)))))))))))
+    (uffi:with-cstrings ((host-native host)
+                        (user-native user)
+                        (password-native password)
+                        (db-native db)
+                        (port-native port)
+                        (options-native options)
+                        (tty-native tty))
+      (let ((connection (PQsetdbLogin host-native port-native
+                                     options-native tty-native
+                                     db-native user-native
+                                     password-native)))
+       (declare (type pgsql-conn-def connection))
+       (when (not (eq (PQstatus connection) 
+                      pgsql-conn-status-type#connection-ok))
+         (error 'clsql-connect-error
+                :database-type database-type
+                :connection-spec connection-spec
+                :errno (PQstatus connection)
+                :error (tidy-error-message 
+                        (PQerrorMessage connection))))
+       (make-instance 'postgresql-database
+                      :name (database-name-from-spec connection-spec
+                                                     database-type)
+                      :conn-ptr connection)))))
 
 
 (defmethod database-disconnect ((database postgresql-database))
@@ -99,7 +99,7 @@
   (setf (database-conn-ptr database) nil)
   t)
 
-(defmethod database-query (query-expression (database postgresql-database))
+(defmethod database-query (query-expression (database postgresql-database) field-types)
   (let ((conn-ptr (database-conn-ptr database)))
     (declare (type pgsql-conn-def conn-ptr))
     (uffi:with-cstring (query-native query-expression)
                               (PQresultErrorMessage result)))))
           (PQclear result))))))
 
-(defstruct postgresql-result-set
+(defstruct postgresql-result-sset
   (res-ptr (uffi:make-null-pointer 'pgsql-result) 
           :type pgsql-result-def)
-  (num-tuples 0)
-  (num-fields 0)
-  (tuple-index 0))
+  (field-types nil :type cons) 
+  (num-tuples 0 :type integer)
+  (num-fields 0 :type integer)
+  (tuple-index 0 :type integer))
 
-(defmethod database-query-result-set (query-expression 
-                                      (database postgresql-database) 
-                                      &optional full-set)
+(defmethod database-query-result-set (query-expression (database postgresql-database) 
+                                      &key full-set field-types)
   (let ((conn-ptr (database-conn-ptr database)))
     (declare (type pgsql-conn-def conn-ptr))
     (uffi:with-cstring (query-native query-expression)