r9336: 12 May 2004 Kevin Rosenberg (kevin@rosenberg.net)
[clsql.git] / sql / package.lisp
index 1b887ed46cc99d9fdc6525705930f33d49691ac6..58930465ca0f6c2bcf1ee19238f5dfa9c7704f92 100644 (file)
@@ -1,9 +1,9 @@
 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
 ;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
 ;;;;
-;;;; $Id$
-;;;;
-;;;; Package definitions for CLSQL. 
+;;;; Name:          package.lisp
+;;;; Purpose:       Package definition for SQL interface
 ;;;;
 ;;;; This file is part of CLSQL.
 ;;;;
 
 (in-package #:cl-user)
 
-(eval-when (:compile-toplevel :load-toplevel :execute)
+;;;; This file makes the required package definitions for CLSQL's
+;;;; core packages.
 
-#+sbcl
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  #+sbcl
   (if (find-package 'sb-mop)
       (pushnew :clsql-sbcl-mop cl:*features*)
       (pushnew :clsql-sbcl-pcl cl:*features*))
-
+  
   #+cmu
   (if (eq (symbol-package 'pcl:find-class)
          (find-package 'common-lisp))
@@ -29,8 +31,8 @@
 
 
 (eval-when (:compile-toplevel :load-toplevel :execute)
-  (defpackage #:clsql
-    (:use #:common-lisp #:clsql-base
+  (defpackage #:clsql-sys
+    (:use #:common-lisp
          #+clsql-sbcl-mop #:sb-mop
          #+clsql-cmucl-mop #:mop
          #+allegro #:mop
     #+allegro
     (:shadowing-import-from 
      #:excl)
-   #+lispworks
-   (:shadowing-import-from 
-    #:clos)
-   #+clsql-sbcl-mop 
-   (:shadowing-import-from 
-    #:sb-pcl
-    #:generic-function-lambda-list)
-   #+clsql-sbcl-pcl
-   (:shadowing-import-from 
-    #:sb-pcl
-    #:name
-    #:class-direct-slots
-    #:class-of #:class-name #:class-slots #:find-class
-    #:slot-boundp
-    #:standard-class
-    #:slot-definition-name #:finalize-inheritance
-    #:standard-direct-slot-definition
-    #:standard-effective-slot-definition #:validate-superclass
-    #:direct-slot-definition-class #:compute-effective-slot-definition
-    #:effective-slot-definition-class
-    #:slot-value-using-class
-    #:class-prototype #:generic-function-method-class #:intern-eql-specializer
-    #:make-method-lambda #:generic-function-lambda-list
-    #:class-precedence-list #:slot-definition-type
-    #:class-direct-superclasses
-    #:compute-class-precedence-list)
-   #+clsql-cmucl-mop 
-   (:shadowing-import-from 
-    #:pcl
-    #:generic-function-lambda-list)
-   #+clsql-cmucl-pcl
-   (:shadowing-import-from 
-    #:pcl
-    #:class-direct-slots
-    #:name
-    #:class-of  #:class-name #:class-slots #:find-class #:standard-class
-    #:slot-boundp
-    #:slot-definition-name #:finalize-inheritance
-    #:standard-direct-slot-definition #:standard-effective-slot-definition
-    #:validate-superclass #:direct-slot-definition-class
-    #:effective-slot-definition-class
-    #:compute-effective-slot-definition
-    #:slot-value-using-class
-    #:class-prototype #:generic-function-method-class #:intern-eql-specializer
-    #:make-method-lambda #:generic-function-lambda-list
-    #:class-precedence-list #:slot-definition-type
-    #:class-direct-superclasses
-    #:compute-class-precedence-list)
-   #+scl
-   (:shadowing-import-from 
-    #:clos
-    #:class-prototype  ;; note: make-method-lambda is not fbound
-    )
-   
-   (:import-from 
-    #:clsql-base
-    .
-    #1=(
-       ;; conditions 
-       #:clsql-condition
-       #:clsql-error
-       #:clsql-simple-error
-       #:clsql-warning
-       #:clsql-simple-warning
-       #:clsql-invalid-spec-error
-       #:clsql-invalid-spec-error-connection-spec
-       #:clsql-invalid-spec-error-database-type
-       #:clsql-invalid-spec-error-template
-       #:clsql-access-error
-       #:clsql-access-error-database-type
-       #:clsql-access-error-connection-spec
-       #:clsql-access-error-error
-       #:clsql-connect-error
-       #:clsql-connect-error-errno
-       #:clsql-sql-error
-       #:clsql-sql-error-database
-       #:clsql-sql-error-expression
-       #:clsql-sql-error-errno
-       #:clsql-sql-error-error
-       #:clsql-database-warning
-       #:clsql-database-warning-database
-       #:clsql-database-warning-message
-       #:clsql-exists-condition
-       #:clsql-exists-condition-new-db
-       #:clsql-exists-condition-old-db
-       #:clsql-exists-warning
-       #:clsql-exists-error
-       #:clsql-closed-error
-       #:clsql-closed-error-database
-       #:clsql-type-error
-       #:clsql-sql-syntax-error
-       #:*backend-warning-behavior*
-       
-       ;; db-interface
-       #:check-connection-spec
-       #:database-initialize-database-type
-       #:database-type-load-foreign
-       #:database-name-from-spec
-       #:database-create-sequence
-       #:database-drop-sequence
-       #:database-sequence-next
-       #:database-set-sequence-position
-       #:database-query-result-set
-       #:database-dump-result-set
-       #:database-store-next-row
-       #:database-get-type-specifier
-       #:database-list-tables
-       #:database-list-views
-       #:database-list-indexes
-       #:database-list-table-indexes
-       #:database-list-sequences
-       #:database-list-attributes
-       #:database-attribute-type
-       #:database-add-attribute
-       #:database-type 
-
-       ;; initialize
-       #:*loaded-database-types*
-       #:reload-database-types
-       #:*initialized-database-types*
-       #:initialize-database-type
-       ;; classes
-       #:database
-       #:database-name
-       #:command-recording-stream
-       #:result-recording-stream
-       #:database-view-classes
-       #:conn-pool
-       #:print-object 
-
-       ;; utils
-       #:sql-escape
+    #+lispworks
+    (:shadowing-import-from 
+     #:clos)
+    #+clsql-sbcl-mop 
+    (:shadowing-import-from 
+     #:sb-pcl
+     #:generic-function-lambda-list)
+    #+clsql-sbcl-pcl
+    (:shadowing-import-from 
+     #:sb-pcl
+     #:name
+     #:class-direct-slots
+     #:class-of #:class-name #:class-slots #:find-class
+     #:slot-boundp
+     #:standard-class
+     #:slot-definition-name #:finalize-inheritance
+     #:standard-direct-slot-definition
+     #:standard-effective-slot-definition #:validate-superclass
+     #:direct-slot-definition-class #:compute-effective-slot-definition
+     #:effective-slot-definition-class
+     #:slot-value-using-class
+     #:class-prototype #:generic-function-method-class #:intern-eql-specializer
+     #:make-method-lambda #:generic-function-lambda-list
+     #:class-precedence-list #:slot-definition-type
+     #:class-direct-superclasses
+     #:compute-class-precedence-list)
+    #+clsql-cmucl-mop 
+    (:shadowing-import-from 
+     #:pcl
+     #:generic-function-lambda-list)
+    #+clsql-cmucl-pcl
+    (:shadowing-import-from 
+     #:pcl
+     #:class-direct-slots
+     #:name
+     #:class-of  #:class-name #:class-slots #:find-class #:standard-class
+     #:slot-boundp
+     #:slot-definition-name #:finalize-inheritance
+     #:standard-direct-slot-definition #:standard-effective-slot-definition
+     #:validate-superclass #:direct-slot-definition-class
+     #:effective-slot-definition-class
+     #:compute-effective-slot-definition
+     #:slot-value-using-class
+     #:class-prototype #:generic-function-method-class #:intern-eql-specializer
+     #:make-method-lambda #:generic-function-lambda-list
+     #:class-precedence-list #:slot-definition-type
+     #:class-direct-superclasses
+     #:compute-class-precedence-list)
+    #+scl
+    (:shadowing-import-from 
+     #:clos
+     #:class-prototype  ;; note: make-method-lambda is not fbound
+     )
+    
+    (:export
+     ;; "Private" exports for use by interface packages
+     #:check-connection-spec
+     #:database-initialize-database-type
+     #:database-type-load-foreign
+     #:database-name-from-spec
+     #:database-connect
+     #:database-disconnect
+     #:database-query
+     #:database-execute-command
+     #:database-create-sequence
+     #:database-drop-sequence
+     #:database-sequence-next
+     #:database-set-sequence-position
+     #:database-query-result-set
+     #:database-dump-result-set
+     #:database-store-next-row
+     #:database-get-type-specifier
+     #:database-list-tables
+     #:database-table-exists-p
+     #:database-list-views
+     #:database-view-exists-p
+     #:database-list-indexes
+     #:database-list-table-indexes
+     #:database-index-exists-p
+     #:database-list-sequences
+     #:database-sequence-exists-p
+     #:database-list-attributes
+     #:database-attribute-type
+     #:database-describe-table
+     #:database-type-library-loaded
+     
+     #:db-backend-has-create/destroy-db?
+     #:db-type-has-views?
+     #:db-type-has-subqueries?
+     #:db-type-has-boolean-where?
+     #:db-type-transaction-capable?
+     #:db-type-has-fancy-math?
+     #:db-type-default-case
+     #:db-type-use-column-on-drop-index? 
+     #:database-underlying-type
 
-       ;; database.lisp -- Connection
-       #:*default-database-type*          ; database   xx
-       #:*default-database*               ; database   xx
-       #:connect                          ; database   xx
-       #:*connect-if-exists*              ; database   xx
-       #:connected-databases              ; database   xx
-       #:database                         ; database   xx
-       #:database-name                    ; database   xx
-       #:disconnect                       ; database   xx
-       #:reconnect                        ; database   xx
-       #:find-database                    ; database   xx
-       #:status                           ; database   xx
-       #:with-database
-       #:with-default-database
-       #:create-database
-       #:destroy-database
-       #:probe-database
-       
-       ;; pool.lisp
-       #:disconnect-pooled
+     ;; Large objects 
+     #:database-create-large-object
+     #:database-write-large-object
+     #:database-read-large-object
+     #:database-delete-large-object
+     #:create-large-object
+     #:write-large-object
+     #:read-large-object
+     #:delete-large-object
 
-       ;; basic-sql.lisp
-       #:query
-       #:execute-command
-       #:write-large-object
-       #:read-large-object
-       #:delete-large-object
-       #:describe-table
-       #:create-large-object
-       #:write-large-object
-       #:read-large-object
-       #:delete-large-object
+     ;; accessors for database class
+     #:name
+     #:connection-spec
+     #:transaction
+     #:transaction-level
+     #:conn-pool
+     #:command-recording-stream
+     #:result-recording-stream
+     #:record-caches
+     #:view-classes
+     #:database-type
+     #:database-state
+     #:attribute-cache
+     
 
-       
-       ;; recording.lisp -- SQL I/O Recording 
-       #:record-sql-command
-       #:record-sql-result
-       #:add-sql-stream                   ; recording  xx
-       #:delete-sql-stream                ; recording  xx
-       #:list-sql-streams                 ; recording  xx
-       #:sql-recording-p                  ; recording  xx
-       #:sql-stream                       ; recording  xx
-       #:start-sql-recording              ; recording  xx
-       #:stop-sql-recording               ; recording  xx
-       
-       ;; Transactions
-       #:with-transaction
-       #:commit-transaction
-       #:rollback-transaction
-       #:add-transaction-commit-hook
-       #:add-transaction-rollback-hook
-       #:commit                           ; transact   xx
-       #:rollback                         ; transact   xx
-       #:with-transaction                 ; transact   xx              
-       #:start-transaction                ; transact   xx
-       #:in-transaction-p                 ; transact   xx
-       #:database-start-transaction
-       #:database-abort-transaction
-       #:database-commit-transaction
-       #:transaction-level
-       #:transaction
-       
-       ;; Database capabilities
-       #:db-type-use-column-on-drop-index?
-       #:db-backend-has-create/destroy-db?
-       #:db-type-has-views?
-       #:db-type-has-subqueries?
-       #:db-type-has-boolean-where?
-       #:db-type-transaction-capable?
-       #:db-type-has-fancy-math?
-       #:db-type-default-case
-       #:convert-to-db-default-case
-       #:database-underlying-type
+     ;; utils.lisp
+     #:without-interrupts
+     #:make-process-lock
+     #:with-process-lock
+     #:command-output
+     #:symbol-name-default-case
+     #:convert-to-db-default-case
+     #:ensure-keyword
 
-       ;; time.lisp 
-       #:bad-component
-       #:current-day
-       #:current-month
-       #:current-year
-       #:day-duration
-       #:db-timestring
-       #:decode-duration
-       #:decode-time
-       #:duration
-       #:duration+
-       #:duration<
-       #:duration<=
-       #:duration=
-       #:duration>
-       #:duration>=
-       #:duration-day
-       #:duration-hour
-       #:duration-minute
-       #:duration-month
-       #:duration-second
-       #:duration-year
-       #:duration-reduce 
-       #:duration-timestring
-       #:extract-roman 
-       #:format-duration
-       #:format-time
-       #:get-time
-       #:utime->time
-       #:interval-clear
-       #:interval-contained
-       #:interval-data
-       #:interval-edit
-       #:interval-end
-       #:interval-match
-       #:interval-push
-       #:interval-relation
-       #:interval-start
-       #:interval-type
-       #:make-duration
-       #:make-interval
-       #:make-time
-       #:merged-time
-       #:midnight
-       #:month-name
-       #:parse-date-time
-       #:parse-timestring
-       #:parse-yearstring
-       #:print-date
-       #:roll
-       #:roll-to
-       #:time
-       #:time+
-       #:time-
-       #:time-by-adding-duration
-       #:time-compare
-       #:time-difference
-       #:time-dow
-       #:time-element
-       #:time-max
-       #:time-min
-       #:time-mjd
-       #:time-msec
-       #:time-p
-       #:time-sec
-       #:time-well-formed
-       #:time-ymd
-       #:time<
-       #:time<=
-       #:time=
-       #:time>
-       #:time>=
-       #:timezone
-       #:universal-time
-       #:wall-time
-       #:wall-timestring
-       #:week-containing
-       #:gregorian-to-mjd
-       #:mjd-to-gregorian
-       ))
-   (:export
-    ;; "Private" exports for use by interface packages
-    #:check-connection-spec
-    #:database-initialize-database-type
-    #:database-type-load-foreign
-    #:database-name-from-spec
-    #:database-connect
-    #:database-query
-    #:database-execute-command
-    #:database-create-sequence
-    #:database-drop-sequence
-    #:database-sequence-next
-    #:database-set-sequence-position
-    #:database-query-result-set
-    #:database-dump-result-set
-    #:database-store-next-row
-    #:database-get-type-specifier
-    #:database-list-tables
-    #:database-table-exists-p
-    #:database-list-views
-    #:database-view-exists-p
-    #:database-list-indexes
-    #:database-list-table-indexes
-    #:database-index-exists-p
-    #:database-list-sequences
-    #:database-sequence-exists-p
-    #:database-list-attributes
-    #:database-attribute-type
-    #:database-describe-table
+     
+     #:clsql-invalid-spec-error
+     #:clsql-invalid-spec-error-connection-spec
+     #:clsql-invalid-spec-error-database-type
+     #:clsql-invalid-spec-error-template
+     #:clsql-access-error
+     #:clsql-access-error-database-type
+     #:clsql-access-error-connection-spec
+     #:clsql-access-error-error
+     #:clsql-connect-error
+     #:clsql-connect-error-errno
+     #:clsql-sql-error
+     #:clsql-sql-error-database
+     #:clsql-sql-error-expression
+     #:clsql-sql-error-errno
+     #:clsql-sql-error-error
+     #:clsql-database-warning
+     #:clsql-database-warning-database
+     #:clsql-database-warning-message
+     #:clsql-exists-condition
+     #:clsql-exists-condition-new-db
+     #:clsql-exists-condition-old-db
+     #:clsql-exists-warning
+     #:clsql-exists-error
+     #:clsql-closed-error
+     #:clsql-closed-error-database
+     #:clsql-sql-syntax-error
+     #:clsql-type-error
+     #:clsql-odbc-error
+     #:clsql-odbc-error-message
+     
+     #:*loaded-database-types*
+     #:reload-database-types
+     #:*initialized-database-types*
+     #:initialize-database-type
+     #:*connect-if-exists*
+     #:*default-database*
+     #:connected-databases
+     #:database
+     #:find-database
+     #:is-database-open
+     #:database-type                     ; database   x
 
-    #:db-backend-has-create/destroy-db?
-    #:db-type-has-views?
-    #:db-type-has-subqueries?
-    #:db-type-has-boolean-where?
-    #:db-type-transaction-capable?
-    #:db-type-has-fancy-math?
-    #:db-type-default-case
-    #:database-underlying-type
-   
-   .
-   ;; Shared exports for re-export by CLSQL-USER. 
-   ;; I = Implemented, D = Documented
-   ;;  name                                 file       ID
-   ;;====================================================
-   #2=(;;------------------------------------------------
-       ;; CommonSQL API 
-       ;;------------------------------------------------
-      ;;FDML 
+     ;; utils.lisp
+     #:number-to-sql-string
+     #:float-to-sql-string
+     #:sql-escape-quotes
+     #:in
+     
+     .
+     ;; Shared exports for re-export by CLSQL package. 
+     ;; I = Implemented, D = Documented
+     ;;  name                                 file       ID
+     ;;====================================================
+     #1=(;;------------------------------------------------
+        ;; CommonSQL API 
+        ;;------------------------------------------------
+        ;;FDML 
        #:select                            ; objects    xx
        #:cache-table-queries               ; 
        #:*cache-table-queries-default*     ; 
        #:print-query                       ; sql        xx
        #:do-query                          ; sql        xx
        #:map-query                         ; sql        xx
-       #:loop                              ; loop-ext   x
+       #:for-each-row
+       #:loop
+
        ;;FDDL
        #:create-table                      ; table      xx
        #:drop-table                        ; table      xx
        #:locally-enable-sql-reader-syntax  ; syntax     xx
        #:restore-sql-reader-syntax-state   ; syntax     xx
 
-       ;;------------------------------------------------
-       ;; Miscellaneous Extensions
-       ;;------------------------------------------------
-       ;;Initialization
-       #:*loaded-database-types*           ; clsql-base xx
-       #:reload-database-types             ; clsql-base xx
-       #:database-type                     ; database   x
-       #:is-database-open
        ;;FDDL 
        #:list-views                        ; table      xx
        #:view-exists-p                     ; table      xx
        #:database-get-type-specifier       ; objects    x
        #:database-output-sql               ; sql/class  xx
 
+       ;; conditions
+       #:clsql-condition
+       #:clsql-error
+       #:clsql-simple-error
+       #:clsql-warning
+       #:clsql-simple-warning
+
        ;;-----------------------------------------------
        ;; Symbolic Sql Syntax 
        ;;-----------------------------------------------
        #:sql-view-class
        #:sql_slot-value
 
-       #:do-query
-       #:map-query
 
-       . 
-       #1#
+
+       ;; time.lisp
+       #:bad-component
+       #:current-day
+     #:current-month
+     #:current-year
+     #:day-duration
+     #:db-timestring
+     #:decode-duration
+     #:decode-time
+     #:duration
+     #:duration+
+     #:duration<
+     #:duration<=
+     #:duration=
+     #:duration>
+     #:duration>=
+     #:duration-day
+     #:duration-hour
+     #:duration-minute
+     #:duration-month
+     #:duration-second
+     #:duration-year
+     #:duration-reduce 
+     #:duration-timestring
+     #:extract-roman 
+     #:format-duration
+     #:format-time
+     #:get-time
+     #:utime->time
+     #:interval-clear
+     #:interval-contained
+     #:interval-data
+     #:interval-edit
+     #:interval-end
+     #:interval-match
+     #:interval-push
+     #:interval-relation
+     #:interval-start
+     #:interval-type
+     #:make-duration
+     #:make-interval
+     #:make-time
+     #:merged-time
+     #:midnight
+     #:month-name
+     #:parse-date-time
+     #:parse-timestring
+     #:parse-yearstring
+     #:print-date
+     #:roll
+     #:roll-to
+     #:time
+     #:time+
+     #:time-
+     #:time-by-adding-duration
+     #:time-compare
+     #:time-difference
+     #:time-dow
+     #:time-element
+     #:time-max
+     #:time-min
+     #:time-mjd
+     #:time-msec
+     #:time-p
+     #:time-sec
+     #:time-well-formed
+     #:time-ymd
+     #:time<
+     #:time<=
+     #:time=
+     #:time>
+     #:time>=
+     #:timezone
+     #:universal-time
+     #:wall-time
+     #:wall-timestring
+     #:week-containing
+     #:gregorian-to-mjd
+     #:mjd-to-gregorian
+
+     ;; recording.lisp -- SQL I/O Recording 
+     #:record-sql-command
+     #:record-sql-result
+     #:add-sql-stream                 ; recording  xx
+     #:delete-sql-stream                 ; recording  xx
+     #:list-sql-streams                  ; recording  xx
+     #:sql-recording-p           ; recording  xx
+     #:sql-stream                        ; recording  xx
+     #:start-sql-recording               ; recording  xx
+     #:stop-sql-recording                ; recording  xx
+
+     ;; database.lisp -- Connection
+     #:*default-database-type*           ; clsql-base xx
+     #:*default-database*                ; classes    xx
+     #:connect                           ; database   xx
+     #:*connect-if-exists*               ; database   xx
+     #:connected-databases               ; database   xx
+     #:database                          ; database   xx
+     #:database-name                     ; database   xx
+     #:disconnect                        ; database   xx
+     #:reconnect                         ; database
+     #:find-database                     ; database   xx
+     #:status                            ; database   xx
+     #:with-database
+     #:with-default-database
+     #:disconnect-pooled
+     #:create-database
+     #:destroy-database
+     #:probe-database
+     #:list-databases
+     
+     #:describe-table
+     #:*backend-warning-behavior*
+     
+     ;; Transactions
+     #:with-transaction
+     #:commit-transaction
+     #:rollback-transaction
+     #:add-transaction-commit-hook
+     #:add-transaction-rollback-hook
+     #:commit                            ; transact   xx
+     #:rollback                          ; transact   xx
+     #:with-transaction                  ; transact   xx               .
+     #:start-transaction                 ; transact   xx
+     #:in-transaction-p                  ; transact   xx
+     #:database-start-transaction
+     #:database-abort-transaction
+     #:database-commit-transaction
+     #:transaction-level
+     #:transaction
        ))
   (:documentation "This is the INTERNAL SQL-Interface package of CLSQL."))
 
 
-;; see http://thread.gmane.org/gmane.lisp.lispworks.general/681
-#+lispworks
-(setf *packages-for-warn-on-redefinition* 
-      (delete "SQL" *packages-for-warn-on-redefinition* :test 'string=))
+(defpackage #:clsql
+  (:use #:common-lisp)
+  (:import-from #:clsql-sys . #1#)
+  (:export . #1#)
+  (:documentation "This is the user package with CLSQL symbols."))
 
 (defpackage #:clsql-user
   (:use #:common-lisp)
-  (:import-from #:clsql . #2#)
-  (:export . #2#)
+  (:import-from #:clsql-sys . #1#)
+  (:export . #1#)
   (:documentation "This is the user package with CLSQL symbols."))
 
   ;; This is from USQL's pcl-patch  
                        slot-vars pv-parameters))
          ,@(mapcar #'(lambda (slot-var) `(declare (ignorable ,slot-var))) slot-vars)
          ,@body))))
-  
-  
+
+;; see http://thread.gmane.org/gmane.lisp.lispworks.general/681
+#+lispworks
+(setf *packages-for-warn-on-redefinition* 
+      (delete "SQL" *packages-for-warn-on-redefinition* :test 'string=))
+
   #+sbcl
   (if (find-package 'sb-mop)
       (setq cl:*features* (delete :clsql-sbcl-mop cl:*features*))
   (if (find-package 'mop)
       (setq cl:*features* (delete :clsql-cmucl-mop cl:*features*))
       (setq cl:*features* (delete :clsql-cmucl-pcl cl:*features*)))
-  
-);eval-when                                      
 
+) ;eval-when