r9114: fixes for list-indexes
[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-table-indexes
153        #:database-list-sequences
154        #:database-list-attributes
155        #:database-attribute-type
156        #:database-add-attribute
157        #:database-type 
158
159        ;; initialize
160        #:*loaded-database-types*
161        #:reload-database-types
162        #:*default-database-type*
163        #:*initialized-database-types*
164        #:initialize-database-type
165        ;; classes
166        #:database
167        #:database-name
168        #:command-recording-stream
169        #:result-recording-stream
170        #:database-view-classes
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        #:describe-table
206
207        
208        ;; recording.lisp -- SQL I/O Recording 
209        #:record-sql-action
210        #:add-sql-stream                 ; recording  xx
211        #:delete-sql-stream                ; recording  xx
212        #:list-sql-streams                 ; recording  xx
213        #:sql-recording-p                  ; recording  xx
214        #:sql-stream                       ; recording  xx
215        #:start-sql-recording              ; recording  xx
216        #:stop-sql-recording               ; recording  xx
217        
218        ;; Transactions
219        #:with-transaction
220        #:commit-transaction
221        #:rollback-transaction
222        #:add-transaction-commit-hook
223        #:add-transaction-rollback-hook
224        #:commit                            ; transact   xx
225        #:rollback                         ; transact   xx
226        #:with-transaction                 ; transact   xx               .
227        #:start-transaction                 ; transact   xx
228        #:in-transaction-p                  ; transact   xx
229        #:database-start-transaction
230        #:database-abort-transaction
231        #:database-commit-transaction
232        #:transaction-level
233        #:transaction
234        
235        ;; Database capabilities
236        #:db-use-column-on-drop-index?
237        
238        ))
239    (:export
240     ;; "Private" exports for use by interface packages
241     #:check-connection-spec
242     #:database-initialize-database-type
243     #:database-type-load-foreign
244     #:database-name-from-spec
245     #:database-connect
246     #:database-query
247     #:database-execute-command
248     #:database-create-sequence
249     #:database-drop-sequence
250     #:database-sequence-next
251     #:database-set-sequence-position
252     #:database-query-result-set
253     #:database-dump-result-set
254     #:database-store-next-row
255     #:database-get-type-specifier
256     #:database-list-tables
257     #:database-table-exists-p
258     #:database-list-views
259     #:database-view-exists-p
260     #:database-list-indexes
261     #:database-list-table-indexes
262     #:database-index-exists-p
263     #:database-list-sequences
264     #:database-sequence-exists-p
265     #:database-list-attributes
266     #:database-attribute-type
267     #:database-describe-table
268    
269    .
270    ;; Shared exports for re-export by CLSQL. 
271    ;; I = Implemented, D = Documented
272    ;;  name                                 file       ID
273    ;;====================================================
274    #2=(;;------------------------------------------------
275        ;; CommonSQL API 
276        ;;------------------------------------------------
277       ;;FDML 
278        #:select                            ; objects    xx
279        #:cache-table-queries               ; 
280        #:*cache-table-queries-default*     ; 
281        #:delete-records                    ; sql               xx
282        #:insert-records                    ; sql        xx
283        #:update-records                    ; sql               xx
284        #:execute-command                          ; sql        xx
285        #:query                             ; sql        xx
286        #:print-query                      ; sql        xx
287        #:do-query                         ; sql        xx
288        #:map-query                        ; sql        xx
289        #:loop                             ; loop-ext   x
290        ;;FDDL
291        #:create-table                     ; table      xx
292        #:drop-table                       ; table      xx
293        #:list-tables                      ; table      xx
294        #:table-exists-p                    ; table      xx 
295        #:list-attributes                          ; table      xx
296        #:attribute-type                    ; table      xx
297        #:list-attribute-types              ; table      xx
298        #:create-view                      ; table      xx
299        #:drop-view                        ; table      xx
300        #:create-index                     ; table      xx               
301        #:drop-index                       ; table      xx               
302        #:truncate-database
303        ;;OODDL
304        #:standard-db-object               ; objects    xx
305        #:def-view-class                    ; objects    xx
306        #:create-view-from-class            ; objects    xx
307        #:drop-view-from-class             ; objects    xx
308        ;;OODML
309        #:instance-refreshed                ;
310        #:update-object-joins               ;
311        #:*default-update-objects-max-len*  ; 
312        #:update-slot-from-record           ; objects    xx
313        #:update-instance-from-records      ; objects    xx
314        #:update-records-from-instance     ; objects    xx
315        #:update-record-from-slot                  ; objects    xx
316        #:update-record-from-slots         ; objects    xx
317        #:list-classes                     ; objects    xx
318        #:delete-instance-records                  ; objects    xx
319        ;;Symbolic SQL Syntax 
320        #:sql                              ; syntax     xx
321        #:sql-expression                    ; syntax     xx
322        #:sql-operation                     ; syntax     xx
323        #:sql-operator                     ; syntax     xx       
324        #:disable-sql-reader-syntax         ; syntax     xx
325        #:enable-sql-reader-syntax          ; syntax     xx
326        #:locally-disable-sql-reader-syntax ; syntax     xx
327        #:locally-enable-sql-reader-syntax  ; syntax     xx
328        #:restore-sql-reader-syntax-state   ; syntax     xx
329
330        ;;------------------------------------------------
331        ;; Miscellaneous Extensions
332        ;;------------------------------------------------
333        ;;Initialization
334        #:*loaded-database-types*           ; clsql-base xx
335        #:reload-database-types             ; clsql-base xx
336        #:database-type                     ; database   x
337        #:is-database-open
338        ;;FDDL 
339        #:list-views                        ; table      xx
340        #:view-exists-p                     ; table      xx
341        #:list-indexes                      ; table      xx
342        #:list-table-indexes                ; table      xx
343        #:index-exists-p                    ; table      xx
344        #:create-sequence                   ; table      xx
345        #:drop-sequence                     ; table      xx
346        #:list-sequences                    ; table      xx
347        #:sequence-exists-p                 ; table      xx
348        #:sequence-next                     ; table      xx
349        #:sequence-last                     ; table      xx
350        #:set-sequence-position             ; table      xx
351        ;;OODDL
352        #:view-table                        ; metaclass  x
353        #:create-sequence-from-class        ; objects    x
354        #:drop-sequence-from-class          ; objects    x       
355        ;;OODML
356        #:add-to-relation                   ; objects    x
357        #:remove-from-relation              ; objects    x
358        #:read-sql-value                    ; objects    x
359        #:database-output-sql-as-type       ; objects    x
360        #:database-get-type-specifier       ; objects    x
361        #:database-output-sql               ; sql/class  xx
362
363        ;;-----------------------------------------------
364        ;; Symbolic Sql Syntax 
365        ;;-----------------------------------------------
366        #:sql-and-qualifier
367        #:sql-escape
368        #:sql-query
369        #:sql-any
370        #:sql-all
371        #:sql-not
372        #:sql-union
373        #:sql-intersection
374        #:sql-minus
375        #:sql-group-by
376        #:sql-having
377        #:sql-null
378        #:sql-not-null
379        #:sql-exists
380        #:sql-*
381        #:sql-+
382        #:sql-/
383        #:sql-like
384        #:sql-uplike
385        #:sql-and
386        #:sql-or
387        #:sql-in
388        #:sql-||
389        #:sql-is
390        #:sql-=
391        #:sql-==
392        #:sql-<
393        #:sql->
394        #:sql->=
395        #:sql-<=
396        #:sql-count
397        #:sql-max
398        #:sql-min
399        #:sql-avg
400        #:sql-sum
401        #:sql-view-class
402        #:sql_slot-value
403
404        . 
405        #1#
406        ))
407   (:documentation "This is the INTERNAL SQL-Interface package of CLSQL."))
408
409
410 ;; see http://thread.gmane.org/gmane.lisp.lispworks.general/681
411 #+lispworks
412 (setf *packages-for-warn-on-redefinition* 
413       (delete "SQL" *packages-for-warn-on-redefinition* :test 'string=))
414
415 (defpackage #:clsql
416   (:use #:common-lisp)
417   (:import-from #:clsql-sys . #2#)
418   (:export . #2#)
419   (:documentation "This is the SQL-Interface package of CLSQL."))
420
421 (defpackage #:clsql-user
422   (:use #:common-lisp)
423   (:import-from #:clsql-sys . #2#)
424   (:export . #2#)
425   (:documentation "This is the user package with CLSQL symbols."))
426
427   ;; This is from USQL's pcl-patch  
428   #+(or clsql-sbcl-pcl clsql-cmucl-pcl)
429   (progn
430     ;; Note that this will no longer required for cmucl as of version 19a. 
431     (in-package #+cmu :pcl #+sbcl :sb-pcl)
432     (defmacro pv-binding1 ((pv calls pv-table-symbol pv-parameters slot-vars) 
433                            &body body)
434       `(pv-env (,pv ,calls ,pv-table-symbol ,pv-parameters)
435         (let (,@(mapcar #'(lambda (slot-var p) `(,slot-var (get-slots-or-nil ,p)))
436                         slot-vars pv-parameters))
437           ,@(mapcar #'(lambda (slot-var) `(declare (ignorable ,slot-var))) slot-vars)
438           ,@body))))
439   
440   
441   #+sbcl
442   (if (find-package 'sb-mop)
443       (setq cl:*features* (delete :clsql-sbcl-mop cl:*features*))
444       (setq cl:*features* (delete :clsql-sbcl-pcl cl:*features*)))
445   
446   #+cmu
447   (if (find-package 'mop)
448       (setq cl:*features* (delete :clsql-cmucl-mop cl:*features*))
449       (setq cl:*features* (delete :clsql-cmucl-pcl cl:*features*)))
450   
451 );eval-when                                      
452
453