r8975: remove schema versioning cruft
[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
158        ;; initialize
159        #:*loaded-database-types*
160        #:reload-database-types
161        #:*default-database-type*
162        #:*initialized-database-types*
163        #:initialize-database-type
164        ;; classes
165        #:database
166        #:database-name
167        #:command-recording-stream
168        #:result-recording-stream
169        #:database-view-classes
170        #:conn-pool
171        #:print-object 
172        ;; utils
173        #:sql-escape
174
175        ;; database.lisp -- Connection
176        #:*default-database-type*                  ; clsql-base xx
177        #:*default-database*               ; classes    xx
178        #:connect                                  ; database   xx
179        #:*connect-if-exists*              ; database   xx
180        #:connected-databases              ; database   xx
181        #:database                         ; database   xx
182        #:database-name                     ; database   xx
183        #:disconnect                       ; database   xx
184        #:reconnect                         ; database
185        #:find-database                     ; database   xx
186        #:status                            ; database   xx
187        #:with-database
188        #:with-default-database
189        #:create-database
190        #:destroy-database
191        #:probe-database
192        
193        ;; pool.lisp
194        #:disconnect-pooled
195
196        ;; basic-sql.lisp
197        #:query
198        #:execute-command
199        #:write-large-object
200        #:read-large-object
201        #:delete-large-object
202        #:do-query
203        #:map-query
204        #:describe-table
205
206        
207        ;; recording.lisp -- SQL I/O Recording 
208        #:record-sql-action
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     #:database-describe-table
262    
263    .
264    ;; Shared exports for re-export by CLSQL. 
265    ;; I = Implemented, D = Documented
266    ;;  name                                 file       ID
267    ;;====================================================
268    #2=(;;------------------------------------------------
269        ;; CommonSQL API 
270        ;;------------------------------------------------
271       ;;FDML 
272        #:select                            ; objects    xx
273        #:cache-table-queries               ; 
274        #:*cache-table-queries-default*     ; 
275        #:delete-records                    ; sql               xx
276        #:insert-records                    ; sql        xx
277        #:update-records                    ; sql               xx
278        #:execute-command                          ; sql        xx
279        #:query                             ; sql        xx
280        #:print-query                      ; sql        xx
281        #:do-query                         ; sql        xx
282        #:map-query                        ; sql        xx
283        #:loop                             ; loop-ext   x
284        ;;FDDL
285        #:create-table                     ; table      xx
286        #:drop-table                       ; table      xx
287        #:list-tables                      ; table      xx
288        #:table-exists-p                    ; table      xx 
289        #:list-attributes                          ; table      xx
290        #:attribute-type                    ; table      xx
291        #:list-attribute-types              ; table      xx
292        #:create-view                      ; table      xx
293        #:drop-view                        ; table      xx
294        #:create-index                     ; table      xx               
295        #:drop-index                       ; table      xx               
296        #:truncate-database
297        ;;OODDL
298        #:standard-db-object               ; objects    xx
299        #:def-view-class                    ; objects    xx
300        #:create-view-from-class            ; objects    xx
301        #:drop-view-from-class             ; objects    xx
302        ;;OODML
303        #:instance-refreshed                ;
304        #:update-object-joins               ;
305        #:*default-update-objects-max-len*  ; 
306        #:update-slot-from-record           ; objects    xx
307        #:update-instance-from-records      ; objects    xx
308        #:update-records-from-instance     ; objects    xx
309        #:update-record-from-slot                  ; objects    xx
310        #:update-record-from-slots         ; objects    xx
311        #:list-classes                     ; objects    xx
312        #:delete-instance-records                  ; objects    xx
313        ;;Symbolic SQL Syntax 
314        #:sql                              ; syntax     xx
315        #:sql-expression                    ; syntax     xx
316        #:sql-operation                     ; syntax     xx
317        #:sql-operator                     ; syntax     xx       
318        #:disable-sql-reader-syntax         ; syntax     xx
319        #:enable-sql-reader-syntax          ; syntax     xx
320        #:locally-disable-sql-reader-syntax ; syntax     xx
321        #:locally-enable-sql-reader-syntax  ; syntax     xx
322        #:restore-sql-reader-syntax-state   ; syntax     xx
323
324        ;;------------------------------------------------
325        ;; Miscellaneous Extensions
326        ;;------------------------------------------------
327        ;;Initialization
328        #:*loaded-database-types*           ; clsql-base xx
329        #:reload-database-types             ; clsql-base xx
330        #:database-type                     ; database   x
331        #:is-database-open
332        ;;FDDL 
333        #:list-views                        ; table      xx
334        #:view-exists-p                     ; table      xx
335        #:list-indexes                      ; table      xx
336        #:index-exists-p                    ; table      xx
337        #:create-sequence                   ; table      xx
338        #:drop-sequence                     ; table      xx
339        #:list-sequences                    ; table      xx
340        #:sequence-exists-p                 ; table      xx
341        #:sequence-next                     ; table      xx
342        #:sequence-last                     ; table      xx
343        #:set-sequence-position             ; table      xx
344        ;;OODDL
345        #:view-table                        ; metaclass  x
346        #:create-sequence-from-class        ; objects    x
347        #:drop-sequence-from-class          ; objects    x       
348        ;;OODML
349        #:add-to-relation                   ; objects    x
350        #:remove-from-relation              ; objects    x
351        #:read-sql-value                    ; objects    x
352        #:database-output-sql-as-type       ; objects    x
353        #:database-get-type-specifier       ; objects    x
354        #:database-output-sql               ; sql/class  xx
355
356        ;;-----------------------------------------------
357        ;; Symbolic Sql Syntax 
358        ;;-----------------------------------------------
359        #:sql-and-qualifier
360        #:sql-escape
361        #:sql-query
362        #:sql-any
363        #:sql-all
364        #:sql-not
365        #:sql-union
366        #:sql-intersection
367        #:sql-minus
368        #:sql-group-by
369        #:sql-having
370        #:sql-null
371        #:sql-not-null
372        #:sql-exists
373        #:sql-*
374        #:sql-+
375        #:sql-/
376        #:sql-like
377        #:sql-uplike
378        #:sql-and
379        #:sql-or
380        #:sql-in
381        #:sql-||
382        #:sql-is
383        #:sql-=
384        #:sql-==
385        #:sql-<
386        #:sql->
387        #:sql->=
388        #:sql-<=
389        #:sql-count
390        #:sql-max
391        #:sql-min
392        #:sql-avg
393        #:sql-sum
394        #:sql-view-class
395        #:sql_slot-value
396
397        . 
398        #1#
399        ))
400   (:documentation "This is the INTERNAL SQL-Interface package of CLSQL."))
401
402
403 ;; see http://thread.gmane.org/gmane.lisp.lispworks.general/681
404 #+lispworks
405 (setf *packages-for-warn-on-redefinition* 
406       (delete "SQL" *packages-for-warn-on-redefinition* :test 'string=))
407
408 (defpackage #:clsql
409   (:use #:common-lisp)
410   (:import-from #:clsql-sys . #2#)
411   (:export . #2#)
412   (:documentation "This is the SQL-Interface package of CLSQL."))
413
414 (defpackage #:clsql-user
415   (:use #:common-lisp)
416   (:import-from #:clsql-sys . #2#)
417   (:export . #2#)
418   (:documentation "This is the user package with CLSQL symbols."))
419
420   ;; This is from USQL's pcl-patch  
421   #+(or clsql-sbcl-pcl clsql-cmucl-pcl)
422   (progn
423     ;; Note that this will no longer required for cmucl as of version 19a. 
424     (in-package #+cmu :pcl #+sbcl :sb-pcl)
425     (defmacro pv-binding1 ((pv calls pv-table-symbol pv-parameters slot-vars) 
426                            &body body)
427       `(pv-env (,pv ,calls ,pv-table-symbol ,pv-parameters)
428         (let (,@(mapcar #'(lambda (slot-var p) `(,slot-var (get-slots-or-nil ,p)))
429                         slot-vars pv-parameters))
430           ,@(mapcar #'(lambda (slot-var) `(declare (ignorable ,slot-var))) slot-vars)
431           ,@body))))
432   
433   
434   #+sbcl
435   (if (find-package 'sb-mop)
436       (setq cl:*features* (delete :clsql-sbcl-mop cl:*features*))
437       (setq cl:*features* (delete :clsql-sbcl-pcl cl:*features*)))
438   
439   #+cmu
440   (if (find-package 'mop)
441       (setq cl:*features* (delete :clsql-cmucl-mop cl:*features*))
442       (setq cl:*features* (delete :clsql-cmucl-pcl cl:*features*)))
443   
444 );eval-when                                      
445
446