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