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