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