r8832: changes for allow import of clsql and clsql-usql in the same package
authorKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 6 Apr 2004 13:41:21 +0000 (13:41 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 6 Apr 2004 13:41:21 +0000 (13:41 +0000)
base/basic-sql.lisp
base/package.lisp
clsql-base.asd
debian/changelog
sql/functional.lisp
sql/package.lisp
sql/sql.lisp
usql/package.lisp
usql/sql.lisp

index df5d93b840c27ae9218718668b9bc5e0b5294806..ea9245e5aa8e03b8a070e1b0ff68a20eaa096592 100644 (file)
@@ -50,3 +50,111 @@ pair."))
   (values))
 
 
+(defmacro do-query (((&rest args) query-expression
+                    &key (database '*default-database*) (types nil))
+                   &body body)
+  "Repeatedly executes BODY within a binding of ARGS on the attributes
+of each record resulting from QUERY. The return value is determined by
+the result of executing BODY. The default value of DATABASE is
+*DEFAULT-DATABASE*."
+  (let ((result-set (gensym))
+       (columns (gensym))
+       (row (gensym))
+       (db (gensym)))
+    `(let ((,db ,database))
+      (multiple-value-bind (,result-set ,columns)
+          (database-query-result-set ,query-expression ,db
+                                     :full-set nil :types ,types)
+        (when ,result-set
+          (unwind-protect
+               (do ((,row (make-list ,columns)))
+                   ((not (database-store-next-row ,result-set ,db ,row))
+                    nil)
+                 (destructuring-bind ,args ,row
+                   ,@body))
+            (database-dump-result-set ,result-set ,db)))))))
+
+(defun map-query (output-type-spec function query-expression
+                 &key (database *default-database*)
+                 (types nil))
+  "Map the function over all tuples that are returned by the query in
+query-expression.  The results of the function are collected as
+specified in output-type-spec and returned like in MAP."
+  (macrolet ((type-specifier-atom (type)
+              `(if (atom ,type) ,type (car ,type))))
+    (case (type-specifier-atom output-type-spec)
+      ((nil) 
+       (map-query-for-effect function query-expression database types))
+      (list 
+       (map-query-to-list function query-expression database types))
+      ((simple-vector simple-string vector string array simple-array
+       bit-vector simple-bit-vector base-string
+       simple-base-string)
+       (map-query-to-simple output-type-spec function query-expression database types))
+      (t
+       (funcall #'map-query (cmucl-compat:result-type-or-lose output-type-spec t)
+              function query-expression :database database :types types)))))
+
+(defun map-query-for-effect (function query-expression database types)
+  (multiple-value-bind (result-set columns)
+      (database-query-result-set query-expression database :full-set nil
+                                :types types)
+    (when result-set
+      (unwind-protect
+          (do ((row (make-list columns)))
+              ((not (database-store-next-row result-set database row))
+               nil)
+            (apply function row))
+       (database-dump-result-set result-set database)))))
+                    
+(defun map-query-to-list (function query-expression database types)
+  (multiple-value-bind (result-set columns)
+      (database-query-result-set query-expression database :full-set nil
+                                :types types)
+    (when result-set
+      (unwind-protect
+          (let ((result (list nil)))
+            (do ((row (make-list columns))
+                 (current-cons result (cdr current-cons)))
+                ((not (database-store-next-row result-set database row))
+                 (cdr result))
+              (rplacd current-cons (list (apply function row)))))
+       (database-dump-result-set result-set database)))))
+
+
+(defun map-query-to-simple (output-type-spec function query-expression database types)
+  (multiple-value-bind (result-set columns rows)
+      (database-query-result-set query-expression database :full-set t
+                                :types types)
+    (when result-set
+      (unwind-protect
+          (if rows
+              ;; We know the row count in advance, so we allocate once
+              (do ((result
+                    (cmucl-compat:make-sequence-of-type output-type-spec rows))
+                   (row (make-list columns))
+                   (index 0 (1+ index)))
+                  ((not (database-store-next-row result-set database row))
+                   result)
+                (declare (fixnum index))
+                (setf (aref result index)
+                      (apply function row)))
+              ;; Database can't report row count in advance, so we have
+              ;; to grow and shrink our vector dynamically
+              (do ((result
+                    (cmucl-compat:make-sequence-of-type output-type-spec 100))
+                   (allocated-length 100)
+                   (row (make-list columns))
+                   (index 0 (1+ index)))
+                  ((not (database-store-next-row result-set database row))
+                   (cmucl-compat:shrink-vector result index))
+                (declare (fixnum allocated-length index))
+                (when (>= index allocated-length)
+                  (setq allocated-length (* allocated-length 2)
+                        result (adjust-array result allocated-length)))
+                (setf (aref result index)
+                      (apply function row))))
+       (database-dump-result-set result-set database)))))
+
+
+
index ba3eeec3b0e948b179635a8687631aad48f73f5e..dd2c674eeda5f21fa35ab16d2afbf72159748a40 100644 (file)
         #:write-large-object
         #:read-large-object
         #:delete-large-object
+        #:do-query
+        #:map-query
 
         ;; Transactions
         #:with-transaction
index f535a3adb6c11c21afdb39b3423de9331c696b7f..4a13f783b3c0f090659c9c23f7ce1a9dc2a7129b 100644 (file)
@@ -45,7 +45,7 @@
             (:file "time" :depends-on ("package"))
             (:file "database" :depends-on ("initialize"))
             (:file "recording" :depends-on ("time" "database"))
-            (:file "basic-sql" :depends-on ("database"))
+            (:file "basic-sql" :depends-on ("database" "cmucl-compat"))
             (:file "pool" :depends-on ("basic-sql"))
             (:file "transaction" :depends-on ("basic-sql"))
             ))))
index c50ca19b331af3cf16b34cfdd9e00679a2882f76..be965bae17b120ed139515e9a4b05de74aff1809 100644 (file)
@@ -1,8 +1,8 @@
-cl-sql (2.1.2-1) unstable; urgency=low
+cl-sql (2.1.4-1) unstable; urgency=low
 
   * New upstream
 
- -- Kevin M. Rosenberg <kmr@debian.org>  Tue,  6 Apr 2004 00:56:21 -0600
+ -- Kevin M. Rosenberg <kmr@debian.org>  Tue,  6 Apr 2004 07:40:36 -0600
 
 cl-sql (2.0.0-2) unstable; urgency=low
 
index dd8aa04c8e581f58b1bbbbc1c8f86f87515532f0..bf38a1219232716d18b90795eec91f89233a3bec 100644 (file)
 (in-package #:clsql-sys)
 
 
-;;;; This file implements the more advanced functions of the
-;;;; functional SQL interface, which are just nicer layers above the
-;;;; basic SQL interface.
+;;; This file implements the more advanced functions of the
+;;; functional SQL interface, which are just nicer layers above the
+;;; basic SQL interface.
+
+;;; With the integration of CLSQL-USQL, these functions are no
+;;; longer exported by the CLSQL package since they conflict with names
+;;; exported by CLSQL-USQL
 
 (defun insert-records
     (&key into attributes values av-pairs query (database *default-database*))
index 7d8b8b23be461bef560b5d53035cee348cc83358..44eecaab01f300785be68adf48be2f6e1db14be5 100644 (file)
@@ -95,6 +95,8 @@
         #:write-large-object
         #:read-large-object
         #:delete-large-object
+        #:do-query
+        #:map-query
 
         ;; Transactions
         #:with-transaction
         ))
     (:export
      ;; sql.cl
-     #:map-query
-     #:do-query
      #:for-each-row
      
-     ;; functional.cl
-     #:insert-records
-     #:delete-records
-     #:update-records
-     #:with-database
-     
      ;; Large objects (Marc B)
      #:create-large-object
      #:write-large-object
      #:read-large-object
      #:delete-large-object
 
+     ;; functional.lisp
+     ;; These are no longer export since different functions are
+     ;; exported by the CLSQL-USQL package
+     ;; #:insert-records
+     ;; #:delete-records
+     ;; #:update-records
+     
      .
      #1#
      )
index d46bdcf5c5acdb3401f19b6b400b718f227c5d58..7e36da85b94582527e629c09e68cdf05c1ff3be7 100644 (file)
 (in-package #:clsql-sys)
 
 
-(defun map-query (output-type-spec function query-expression
-                 &key (database *default-database*)
-                 (types nil))
-  "Map the function over all tuples that are returned by the query in
-query-expression.  The results of the function are collected as
-specified in output-type-spec and returned like in MAP."
-  ;; DANGER Will Robinson: Parts of the code for implementing
-  ;; map-query (including the code below and the helper functions
-  ;; called) are highly CMU CL specific.
-  ;; KMR -- these have been replaced with cross-platform instructions above
-  (macrolet ((type-specifier-atom (type)
-              `(if (atom ,type) ,type (car ,type))))
-    (case (type-specifier-atom output-type-spec)
-      ((nil) 
-       (map-query-for-effect function query-expression database types))
-      (list 
-       (map-query-to-list function query-expression database types))
-      ((simple-vector simple-string vector string array simple-array
-       bit-vector simple-bit-vector base-string
-       simple-base-string)
-       (map-query-to-simple output-type-spec function query-expression database types))
-      (t
-       (funcall #'map-query (cmucl-compat:result-type-or-lose output-type-spec t)
-              function query-expression :database database :types types)))))
-
-(defun map-query-for-effect (function query-expression database types)
-  (multiple-value-bind (result-set columns)
-      (database-query-result-set query-expression database :full-set nil
-                                :types types)
-    (when result-set
-      (unwind-protect
-          (do ((row (make-list columns)))
-              ((not (database-store-next-row result-set database row))
-               nil)
-            (apply function row))
-       (database-dump-result-set result-set database)))))
-                    
-(defun map-query-to-list (function query-expression database types)
-  (multiple-value-bind (result-set columns)
-      (database-query-result-set query-expression database :full-set nil
-                                :types types)
-    (when result-set
-      (unwind-protect
-          (let ((result (list nil)))
-            (do ((row (make-list columns))
-                 (current-cons result (cdr current-cons)))
-                ((not (database-store-next-row result-set database row))
-                 (cdr result))
-              (rplacd current-cons (list (apply function row)))))
-       (database-dump-result-set result-set database)))))
-
-
-(defun map-query-to-simple (output-type-spec function query-expression database types)
-  (multiple-value-bind (result-set columns rows)
-      (database-query-result-set query-expression database :full-set t
-                                :types types)
-    (when result-set
-      (unwind-protect
-          (if rows
-              ;; We know the row count in advance, so we allocate once
-              (do ((result
-                    (cmucl-compat:make-sequence-of-type output-type-spec rows))
-                   (row (make-list columns))
-                   (index 0 (1+ index)))
-                  ((not (database-store-next-row result-set database row))
-                   result)
-                (declare (fixnum index))
-                (setf (aref result index)
-                      (apply function row)))
-              ;; Database can't report row count in advance, so we have
-              ;; to grow and shrink our vector dynamically
-              (do ((result
-                    (cmucl-compat:make-sequence-of-type output-type-spec 100))
-                   (allocated-length 100)
-                   (row (make-list columns))
-                   (index 0 (1+ index)))
-                  ((not (database-store-next-row result-set database row))
-                   (cmucl-compat:shrink-vector result index))
-                (declare (fixnum allocated-length index))
-                (when (>= index allocated-length)
-                  (setq allocated-length (* allocated-length 2)
-                        result (adjust-array result allocated-length)))
-                (setf (aref result index)
-                      (apply function row))))
-       (database-dump-result-set result-set database)))))
-
-(defmacro do-query (((&rest args) query-expression
-                    &key (database '*default-database*)
-                    (types nil))
-                   &body body)
-  (let ((result-set (gensym))
-       (columns (gensym))
-       (row (gensym))
-       (db (gensym)))
-    `(let ((,db ,database))
-       (multiple-value-bind (,result-set ,columns)
-          (database-query-result-set ,query-expression ,db
-                                     :full-set nil :types ,types)
-        (when ,result-set
-          (unwind-protect
-               (do ((,row (make-list ,columns)))
-                   ((not (database-store-next-row ,result-set ,db ,row))
-                    nil)
-                 (destructuring-bind ,args ,row
-                   ,@body))
-            (database-dump-result-set ,result-set ,db)))))))
-
-
 ;;; Row processing macro
 
 
index daacdf1316159f806394d82f3bb6f86fbaa5b7d2..39f16a9b58ac7a33f034a0e806ca1e5477a78246 100644 (file)
        #:write-large-object
        #:read-large-object
        #:delete-large-object
-       
+       #:do-query
+       #:map-query
+
        ;; recording.lisp -- SQL I/O Recording 
        #:record-sql-comand
        #:record-sql-result
index f700c174140c917f5c9adfb3430aa2db5237cf33..b5c72846315b56aa8836eed305e86019efbed75b 100644 (file)
@@ -145,119 +145,6 @@ condition is true."
 
 ;; iteration 
 
-(defun map-query (output-type-spec function query-expression
-                                  &key (database *default-database*)
-                                   (types nil))
-  "Map the function over all tuples that are returned by the query in
-query-expression.  The results of the function are collected as
-specified in output-type-spec and returned like in MAP."
-  ;; DANGER Will Robinson: Parts of the code for implementing
-  ;; map-query (including the code below and the helper functions
-  ;; called) are highly CMU CL specific.
-  ;; KMR -- these have been replaced with cross-platform instructions above
-  (macrolet ((type-specifier-atom (type)
-              `(if (atom ,type) ,type (car ,type))))
-    (case (type-specifier-atom output-type-spec)
-      ((nil)
-       (map-query-for-effect function query-expression database types))
-      (list
-       (map-query-to-list function query-expression database types))
-      ((simple-vector simple-string vector string array simple-array
-                      bit-vector simple-bit-vector base-string
-                     simple-base-string)
-       (map-query-to-simple output-type-spec function query-expression
-                            database types))
-      (t
-       (funcall #'map-query
-                (cmucl-compat:result-type-or-lose output-type-spec t)  
-                function query-expression :database database :types types)))))
-
-(defun map-query-for-effect (function query-expression database types)
-  (multiple-value-bind (result-set columns)
-      (database-query-result-set query-expression database :full-set nil
-                                 :types types)
-    (when result-set
-      (unwind-protect
-          (do ((row (make-list columns)))
-              ((not (database-store-next-row result-set database row))
-               nil)
-            (apply function row))
-       (database-dump-result-set result-set database)))))
-                    
-(defun map-query-to-list (function query-expression database types)
-  (multiple-value-bind (result-set columns)
-      (database-query-result-set query-expression database :full-set nil
-                                 :types types)
-    (when result-set
-      (unwind-protect
-          (let ((result (list nil)))
-            (do ((row (make-list columns))
-                 (current-cons result (cdr current-cons)))
-                ((not (database-store-next-row result-set database row))
-                 (cdr result))
-              (rplacd current-cons (list (apply function row)))))
-       (database-dump-result-set result-set database)))))
-
-(defun map-query-to-simple (output-type-spec function query-expression
-                                             database types)
-  (multiple-value-bind (result-set columns rows)
-      (database-query-result-set query-expression database :full-set t
-                                 :types types)
-    (when result-set
-      (unwind-protect
-           (if rows
-               ;; We know the row count in advance, so we allocate once
-               (do ((result
-                     (cmucl-compat:make-sequence-of-type output-type-spec rows))
-                    (row (make-list columns))
-                    (index 0 (1+ index)))
-                   ((not (database-store-next-row result-set database row))
-                    result)
-                 (declare (fixnum index))
-                 (setf (aref result index)
-                       (apply function row)))
-               ;; Database can't report row count in advance, so we have
-               ;; to grow and shrink our vector dynamically
-               (do ((result
-                     (cmucl-compat:make-sequence-of-type output-type-spec 100))
-                    (allocated-length 100)
-                    (row (make-list columns))
-                    (index 0 (1+ index)))
-                   ((not (database-store-next-row result-set database row))
-                    (cmucl-compat:shrink-vector result index))
-                 (declare (fixnum allocated-length index))
-                 (when (>= index allocated-length)
-                   (setf allocated-length (* allocated-length 2)
-                         result (adjust-array result allocated-length)))
-                 (setf (aref result index)
-                       (apply function row))))
-        (database-dump-result-set result-set database)))))
-
-(defmacro do-query (((&rest args) query-expression
-                    &key (database '*default-database*) (types nil))
-                   &body body)
-  "Repeatedly executes BODY within a binding of ARGS on the attributes
-of each record resulting from QUERY. The return value is determined by
-the result of executing BODY. The default value of DATABASE is
-*DEFAULT-DATABASE*."
-  (let ((result-set (gensym))
-       (columns (gensym))
-       (row (gensym))
-       (db (gensym)))
-    `(let ((,db ,database))
-      (multiple-value-bind (,result-set ,columns)
-          (database-query-result-set ,query-expression ,db
-                                     :full-set nil :types ,types)
-        (when ,result-set
-          (unwind-protect
-               (do ((,row (make-list ,columns)))
-                   ((not (database-store-next-row ,result-set ,db ,row))
-                    nil)
-                 (destructuring-bind ,args ,row
-                   ,@body))
-            (database-dump-result-set ,result-set ,db)))))))
-
-
 ;; output-sql
 
 (defmethod database-output-sql ((str string) database)