r8926: add database-create database-destroy database-probe
[clsql.git] / sql / package.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;;
4 ;;;; $Id$
5 ;;;;
6 ;;;; Package definitions for CLSQL. 
7 ;;;;
8 ;;;; This file is part of CLSQL.
9 ;;;;
10 ;;;; CLSQL users are granted the rights to distribute and use this software
11 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
12 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
13 ;;;; *************************************************************************
14
15 (in-package #:cl-user)
16
17 (eval-when (:compile-toplevel :load-toplevel :execute)
18
19 #+sbcl
20   (if (find-package 'sb-mop)
21       (pushnew :clsql-sbcl-mop cl:*features*)
22       (pushnew :clsql-sbcl-pcl cl:*features*))
23
24   #+cmu
25   (if (eq (symbol-package 'pcl:find-class)
26           (find-package 'common-lisp))
27       (pushnew :clsql-cmucl-mop cl:*features*)
28       (pushnew :clsql-cmucl-pcl cl:*features*)))
29
30
31 (eval-when (:compile-toplevel :load-toplevel :execute)
32   (defpackage #:clsql-sys
33     (:use #:common-lisp #:clsql-base-sys
34           #+clsql-sbcl-mop #:sb-mop
35           #+clsql-cmucl-mop #:mop
36           #+allegro #:mop
37           #+lispworks #:clos
38           #+scl #:clos
39           #+openmcl #:openmcl-mop)
40     
41     #+allegro
42     (:shadowing-import-from 
43      #:excl)
44    #+lispworks
45    (:shadowing-import-from 
46     #:clos)
47    #+clsql-sbcl-mop 
48    (:shadowing-import-from 
49     #:sb-pcl
50     #:generic-function-lambda-list)
51    #+clsql-sbcl-pcl
52    (:shadowing-import-from 
53     #:sb-pcl
54     #:name
55     #:class-direct-slots
56     #:class-of #:class-name #:class-slots #:find-class
57     #:slot-boundp
58     #:standard-class
59     #:slot-definition-name #:finalize-inheritance
60     #:standard-direct-slot-definition
61     #:standard-effective-slot-definition #:validate-superclass
62     #:direct-slot-definition-class #:compute-effective-slot-definition
63     #:effective-slot-definition-class
64     #:slot-value-using-class
65     #:class-prototype #:generic-function-method-class #:intern-eql-specializer
66     #:make-method-lambda #:generic-function-lambda-list
67     #:class-precedence-list #:slot-definition-type
68     #:class-direct-superclasses
69     #:compute-class-precedence-list)
70    #+clsql-cmucl-mop 
71    (:shadowing-import-from 
72     #:pcl
73     #:generic-function-lambda-list)
74    #+clsql-cmucl-pcl
75    (:shadowing-import-from 
76     #:pcl
77     #:class-direct-slots
78     #:name
79     #:class-of  #:class-name #:class-slots #:find-class #:standard-class
80     #:slot-boundp
81     #:slot-definition-name #:finalize-inheritance
82     #:standard-direct-slot-definition #:standard-effective-slot-definition
83     #:validate-superclass #:direct-slot-definition-class
84     #:effective-slot-definition-class
85     #:compute-effective-slot-definition
86     #:slot-value-using-class
87     #:class-prototype #:generic-function-method-class #:intern-eql-specializer
88     #:make-method-lambda #:generic-function-lambda-list
89     #:class-precedence-list #:slot-definition-type
90     #:class-direct-superclasses
91     #:compute-class-precedence-list)
92    #+scl
93    (:shadowing-import-from 
94     #:clos
95     #:class-prototype  ;; note: make-method-lambda is not fbound
96     )
97    
98    (:import-from 
99     #:clsql-base-sys
100     .
101     #1=(
102        ;; conditions 
103        #:clsql-condition
104        #:clsql-error
105        #:clsql-simple-error
106        #:clsql-warning
107        #:clsql-simple-warning
108        #:clsql-invalid-spec-error
109        #:clsql-invalid-spec-error-connection-spec
110        #:clsql-invalid-spec-error-database-type
111        #:clsql-invalid-spec-error-template
112        #:clsql-access-error
113        #:clsql-access-error-database-type
114        #:clsql-access-error-connection-spec
115        #:clsql-access-error-error
116        #:clsql-connect-error
117        #:clsql-connect-error-errno
118        #:clsql-sql-error
119        #:clsql-sql-error-database
120        #:clsql-sql-error-expression
121        #:clsql-sql-error-errno
122        #:clsql-sql-error-error
123        #:clsql-database-warning
124        #:clsql-database-warning-database
125        #:clsql-database-warning-message
126        #:clsql-exists-condition
127        #:clsql-exists-condition-new-db
128        #:clsql-exists-condition-old-db
129        #:clsql-exists-warning
130        #:clsql-exists-error
131        #:clsql-closed-error
132        #:clsql-closed-error-database
133        #:clsql-type-error
134        #:clsql-sql-syntax-error
135
136        ;; db-interface
137        #:check-connection-spec
138        #:database-initialize-database-type
139        #:database-type-load-foreign
140        #:database-name-from-spec
141        #:database-create-sequence
142        #:database-drop-sequence
143        #:database-sequence-next
144        #:database-set-sequence-position
145        #:database-query-result-set
146        #:database-dump-result-set
147        #:database-store-next-row
148        #:database-get-type-specifier
149        #:database-list-tables
150        #:database-list-views
151        #:database-list-indexes
152        #:database-list-sequences
153        #:database-list-attributes
154        #:database-attribute-type
155        #:database-add-attribute
156        #:database-type 
157        ;; initialize
158        #:*loaded-database-types*
159        #:reload-database-types
160        #:*default-database-type*
161        #:*initialized-database-types*
162        #:initialize-database-type
163        ;; classes
164        #:database
165        #:closed-database
166        #:database-name
167        #:command-recording-stream
168        #:result-recording-stream
169        #:database-view-classes
170        #:database-schema
171        #:conn-pool
172        #:print-object 
173        ;; utils
174        #:sql-escape
175
176        ;; database.lisp -- Connection
177        #:*default-database-type*                  ; clsql-base xx
178        #:*default-database*               ; classes    xx
179        #:connect                                  ; database   xx
180        #:*connect-if-exists*              ; database   xx
181        #:connected-databases              ; database   xx
182        #:database                         ; database   xx
183        #:database-name                     ; database   xx
184        #:disconnect                       ; database   xx
185        #:reconnect                         ; database
186        #:find-database                     ; database   xx
187        #:status                            ; database   xx
188        #:with-database
189        #:with-default-database
190        #:create-database
191        #:destroy-database
192        #:probe-database
193
194        ;; pool.lisp
195        #:disconnect-pooled
196
197        ;; basic-sql.lisp
198        #:query
199        #:execute-command
200        #:write-large-object
201        #:read-large-object
202        #:delete-large-object
203        #:do-query
204        #:map-query
205
206        ;; recording.lisp -- SQL I/O Recording 
207        #:record-sql-comand
208        #:record-sql-result
209        #:add-sql-stream                 ; recording  xx
210        #:delete-sql-stream                ; recording  xx
211        #:list-sql-streams                 ; recording  xx
212        #:sql-recording-p                  ; recording  xx
213        #:sql-stream                       ; recording  xx
214        #:start-sql-recording              ; recording  xx
215        #:stop-sql-recording               ; recording  xx
216        
217        ;; Transactions
218        #:with-transaction
219        #:commit-transaction
220        #:rollback-transaction
221        #:add-transaction-commit-hook
222        #:add-transaction-rollback-hook
223        #:commit                            ; transact   xx
224        #:rollback                         ; transact   xx
225        #:with-transaction                 ; transact   xx               .
226        #:start-transaction                 ; transact   xx
227        #:in-transaction-p                  ; transact   xx
228        #:database-start-transaction
229        #:database-abort-transaction
230        #:database-commit-transaction
231        #:transaction-level
232        #:transaction
233        ))
234    (:export
235     ;; "Private" exports for use by interface packages
236     #:check-connection-spec
237     #:database-initialize-database-type
238     #:database-type-load-foreign
239     #:database-name-from-spec
240     #:database-connect
241    #:database-query
242    #:database-execute-command
243    #:database-create-sequence
244    #:database-drop-sequence
245    #:database-sequence-next
246    #:database-set-sequence-position
247    #:database-query-result-set
248    #:database-dump-result-set
249    #:database-store-next-row
250    #:database-get-type-specifier
251    #:database-list-tables
252    #:database-table-exists-p
253    #:database-list-views
254    #:database-view-exists-p
255    #:database-list-indexes
256    #:database-index-exists-p
257    #:database-list-sequences
258    #:database-sequence-exists-p
259    #:database-list-attributes
260    #:database-attribute-type
261
262    .
263    ;; Shared exports for re-export by CLSQL. 
264    ;; I = Implemented, D = Documented
265    ;;  name                                 file       ID
266    ;;====================================================
267    #2=(;;------------------------------------------------
268        ;; CommonSQL API 
269        ;;------------------------------------------------
270       ;;FDML 
271        #:select                            ; objects    xx
272        #:cache-table-queries               ; 
273        #:*cache-table-queries-default*     ; 
274        #:delete-records                    ; sql               xx
275        #:insert-records                    ; sql        xx
276        #:update-records                    ; sql               xx
277        #:execute-command                          ; sql        xx
278        #:query                             ; sql        xx
279        #:print-query                      ; sql        xx
280        #:do-query                         ; sql        xx
281        #:map-query                        ; sql        xx
282        #:loop                             ; loop-ext   x
283        ;;FDDL
284        #:create-table                     ; table      xx
285        #:drop-table                       ; table      xx
286        #:list-tables                      ; table      xx
287        #:table-exists-p                    ; table      xx 
288        #:list-attributes                          ; table      xx
289        #:attribute-type                    ; table      xx
290        #:list-attribute-types              ; table      xx
291        #:create-view                      ; table      xx
292        #:drop-view                        ; table      xx
293        #:create-index                     ; table      xx               
294        #:drop-index                       ; table      xx               
295        ;;OODDL
296        #:standard-db-object               ; objects    xx
297        #:def-view-class                    ; objects    xx
298        #:create-view-from-class            ; objects    xx
299        #:drop-view-from-class             ; objects    xx
300        ;;OODML
301        #:instance-refreshed                ;
302        #:update-object-joins               ;
303        #:*default-update-objects-max-len*  ; 
304        #:update-slot-from-record           ; objects    xx
305        #:update-instance-from-records      ; objects    xx
306        #:update-records-from-instance     ; objects    xx
307        #:update-record-from-slot                  ; objects    xx
308        #:update-record-from-slots         ; objects    xx
309        #:list-classes                     ; objects    xx
310        #:delete-instance-records                  ; objects    xx
311        ;;Symbolic SQL Syntax 
312        #:sql                              ; syntax     xx
313        #:sql-expression                    ; syntax     xx
314        #:sql-operation                     ; syntax     xx
315        #:sql-operator                     ; syntax     xx       
316        #:disable-sql-reader-syntax         ; syntax     xx
317        #:enable-sql-reader-syntax          ; syntax     xx
318        #:locally-disable-sql-reader-syntax ; syntax     xx
319        #:locally-enable-sql-reader-syntax  ; syntax     xx
320        #:restore-sql-reader-syntax-state   ; syntax     xx
321
322        ;;------------------------------------------------
323        ;; Miscellaneous Extensions
324        ;;------------------------------------------------
325        ;;Initialization
326        #:*loaded-database-types*           ; clsql-base xx
327        #:reload-database-types             ; clsql-base xx
328        #:closed-database                  ; database   xx
329        #:database-type                     ; database   x
330        #:in-schema                         ; classes    x
331        ;;FDDL 
332        #:list-views                        ; table      xx
333        #:view-exists-p                     ; table      xx
334        #:list-indexes                      ; table      xx
335        #:index-exists-p                    ; table      xx
336        #:create-sequence                   ; table      xx
337        #:drop-sequence                     ; table      xx
338        #:list-sequences                    ; table      xx
339        #:sequence-exists-p                 ; table      xx
340        #:sequence-next                     ; table      xx
341        #:sequence-last                     ; table      xx
342        #:set-sequence-position             ; table      xx
343        ;;OODDL
344        #:view-table                        ; metaclass  x
345        #:create-sequence-from-class        ; objects    x
346        #:drop-sequence-from-class          ; objects    x       
347        ;;OODML
348        #:add-to-relation                   ; objects    x
349        #:remove-from-relation              ; objects    x
350        #:read-sql-value                    ; objects    x
351        #:database-output-sql-as-type       ; objects    x
352        #:database-get-type-specifier       ; objects    x
353        #:database-output-sql               ; sql/class  xx
354
355        ;;-----------------------------------------------
356        ;; Symbolic Sql Syntax 
357        ;;-----------------------------------------------
358        #:sql-and-qualifier
359        #:sql-escape
360        #:sql-query
361        #:sql-any
362        #:sql-all
363        #:sql-not
364        #:sql-union
365        #:sql-intersection
366        #:sql-minus
367        #:sql-group-by
368        #:sql-having
369        #:sql-null
370        #:sql-not-null
371        #:sql-exists
372        #:sql-*
373        #:sql-+
374        #:sql-/
375        #:sql-like
376        #:sql-uplike
377        #:sql-and
378        #:sql-or
379        #:sql-in
380        #:sql-||
381        #:sql-is
382        #:sql-=
383        #:sql-==
384        #:sql-<
385        #:sql->
386        #:sql->=
387        #:sql-<=
388        #:sql-count
389        #:sql-max
390        #:sql-min
391        #:sql-avg
392        #:sql-sum
393        #:sql-view-class
394        #:sql_slot-value
395
396        . 
397        #1#
398        ))
399   (:documentation "This is the INTERNAL SQL-Interface package of CLSQL."))
400
401
402 ;; see http://thread.gmane.org/gmane.lisp.lispworks.general/681
403 #+lispworks
404 (setf *packages-for-warn-on-redefinition* 
405       (delete "SQL" *packages-for-warn-on-redefinition* :test 'string=))
406
407 (defpackage #:clsql
408   (:use #:common-lisp)
409   (:import-from #:clsql-sys . #2#)
410   (:export . #2#)
411   (:documentation "This is the SQL-Interface package of CLSQL."))
412
413 (defpackage #:clsql-user
414   (:use #:common-lisp)
415   (:import-from #:clsql-sys . #2#)
416   (:export . #2#)
417   (:documentation "This is the user package with CLSQL symbols."))
418
419   ;; This is from USQL's pcl-patch  
420   #+(or clsql-sbcl-pcl clsql-cmucl-pcl)
421   (progn
422     ;; Note that this will no longer required for cmucl as of version 19a. 
423     (in-package #+cmu :pcl #+sbcl :sb-pcl)
424     (defmacro pv-binding1 ((pv calls pv-table-symbol pv-parameters slot-vars) 
425                            &body body)
426       `(pv-env (,pv ,calls ,pv-table-symbol ,pv-parameters)
427         (let (,@(mapcar #'(lambda (slot-var p) `(,slot-var (get-slots-or-nil ,p)))
428                         slot-vars pv-parameters))
429           ,@(mapcar #'(lambda (slot-var) `(declare (ignorable ,slot-var))) slot-vars)
430           ,@body))))
431   
432   
433   #+sbcl
434   (if (find-package 'sb-mop)
435       (setq cl:*features* (delete :clsql-sbcl-mop cl:*features*))
436       (setq cl:*features* (delete :clsql-sbcl-pcl cl:*features*)))
437   
438   #+cmu
439   (if (find-package 'mop)
440       (setq cl:*features* (delete :clsql-cmucl-mop cl:*features*))
441       (setq cl:*features* (delete :clsql-cmucl-pcl cl:*features*)))
442   
443 );eval-when                                      
444
445