r9443: * test/test-fdml.lisp: String table names are now case sensitive,...
[clsql.git] / sql / package.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          package.lisp
6 ;;;; Purpose:       Package definition for SQL interface
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 ;;;; This file makes the required package definitions for CLSQL's
18 ;;;; core packages.
19
20 (eval-when (:compile-toplevel :load-toplevel :execute)
21   #+sbcl
22   (if (find-package 'sb-mop)
23       (pushnew :clsql-sbcl-mop cl:*features*)
24       (pushnew :clsql-sbcl-pcl cl:*features*))
25   
26   #+cmu
27   (if (eq (symbol-package 'pcl:find-class)
28           (find-package 'common-lisp))
29       (pushnew :clsql-cmucl-mop cl:*features*)
30       (pushnew :clsql-cmucl-pcl cl:*features*)))
31
32
33 (eval-when (:compile-toplevel :load-toplevel :execute)
34   (defpackage #:clsql-sys
35     (:use #:common-lisp
36           #+clsql-sbcl-mop #:sb-mop
37           #+clsql-cmucl-mop #:mop
38           #+allegro #:mop
39           #+lispworks #:clos
40           #+scl #:clos
41           #+openmcl #:openmcl-mop)
42     
43     #+allegro
44     (:shadowing-import-from 
45      #:excl)
46     #+lispworks
47     (:shadowing-import-from 
48      #:clos)
49     #+clsql-sbcl-mop 
50     (:shadowing-import-from 
51      #:sb-pcl
52      #:generic-function-lambda-list)
53     #+clsql-sbcl-pcl
54     (:shadowing-import-from 
55      #:sb-pcl
56      #:name
57      #:class-direct-slots
58      #:class-of #:class-name #:class-slots #:find-class
59      #:slot-boundp
60      #:standard-class
61      #:slot-definition-name #:finalize-inheritance
62      #:standard-direct-slot-definition
63      #:standard-effective-slot-definition #:validate-superclass
64      #:direct-slot-definition-class #:compute-effective-slot-definition
65      #:effective-slot-definition-class
66      #:slot-value-using-class
67      #:class-prototype #:generic-function-method-class #:intern-eql-specializer
68      #:make-method-lambda #:generic-function-lambda-list
69      #:class-precedence-list #:slot-definition-type
70      #:class-direct-superclasses
71      #:compute-class-precedence-list)
72     #+clsql-cmucl-mop 
73     (:shadowing-import-from 
74      #:pcl
75      #:generic-function-lambda-list)
76     #+clsql-cmucl-pcl
77     (:shadowing-import-from 
78      #:pcl
79      #:class-direct-slots
80      #:name
81      #:class-of  #:class-name #:class-slots #:find-class #:standard-class
82      #:slot-boundp
83      #:slot-definition-name #:finalize-inheritance
84      #:standard-direct-slot-definition #:standard-effective-slot-definition
85      #:validate-superclass #:direct-slot-definition-class
86      #:effective-slot-definition-class
87      #:compute-effective-slot-definition
88      #:slot-value-using-class
89      #:class-prototype #:generic-function-method-class #:intern-eql-specializer
90      #:make-method-lambda #:generic-function-lambda-list
91      #:class-precedence-list #:slot-definition-type
92      #:class-direct-superclasses
93      #:compute-class-precedence-list)
94     #+scl
95     (:shadowing-import-from 
96      #:clos
97      #:class-prototype  ;; note: make-method-lambda is not fbound
98      )
99     
100     (:export
101      ;; "Private" exports for use by interface packages
102      #:check-connection-spec
103      #:database-initialize-database-type
104      #:database-type-load-foreign
105      #:database-name-from-spec
106      #:database-connect
107      #:database-disconnect
108      #:database-query
109      #:database-execute-command
110      #:database-create-sequence
111      #:database-drop-sequence
112      #:database-sequence-next
113      #:database-set-sequence-position
114      #:database-query-result-set
115      #:database-dump-result-set
116      #:database-store-next-row
117      #:database-get-type-specifier
118      #:database-list-tables
119      #:database-table-exists-p
120      #:database-list-views
121      #:database-view-exists-p
122      #:database-list-indexes
123      #:database-list-table-indexes
124      #:database-index-exists-p
125      #:database-list-sequences
126      #:database-sequence-last
127      #:database-sequence-exists-p
128      #:database-list-attributes
129      #:database-attribute-type
130      #:database-describe-table
131      #:database-type-library-loaded
132      #:database-create
133      #:database-destroy
134      #:database-probe
135      #:database-list
136      
137      #:db-backend-has-create/destroy-db?
138      #:db-type-has-views?
139      #:db-type-has-bigint?
140      #:db-type-has-union?
141      #:db-type-has-subqueries?
142      #:db-type-has-boolean-where?
143      #:db-type-transaction-capable?
144      #:db-type-has-fancy-math?
145      #:db-type-default-case
146      #:db-type-use-column-on-drop-index? 
147      #:database-underlying-type
148
149      ;; Large objects 
150      #:database-create-large-object
151      #:database-write-large-object
152      #:database-read-large-object
153      #:database-delete-large-object
154      #:create-large-object
155      #:write-large-object
156      #:read-large-object
157      #:delete-large-object
158
159      ;; accessors for database class
160      #:name
161      #:connection-spec
162      #:transaction
163      #:transaction-level
164      #:conn-pool
165      #:command-recording-stream
166      #:result-recording-stream
167      #:record-caches
168      #:view-classes
169      #:database-type
170      #:database-state
171      #:attribute-cache
172      
173
174      ;; utils.lisp
175      #:without-interrupts
176      #:make-process-lock
177      #:with-process-lock
178      #:command-output
179      #:symbol-name-default-case
180      #:convert-to-db-default-case
181      #:ensure-keyword
182      #:getenv
183      
184      #:*loaded-database-types*
185      #:reload-database-types
186      #:*connect-if-exists*
187      #:connected-databases
188      #:database
189      #:find-database
190      #:is-database-open
191      #:database-type                     ; database   x
192
193      ;; utils.lisp
194      #:number-to-sql-string
195      #:float-to-sql-string
196      #:sql-escape-quotes
197      #:in
198      
199      .
200      ;; Shared exports for re-export by CLSQL package. 
201      ;; I = Implemented, D = Documented
202      ;;  name                                 file       ID
203      ;;====================================================
204      #1=(;;------------------------------------------------
205          ;; CommonSQL API 
206          ;;------------------------------------------------
207          ;;FDML 
208          #:select                            ; objects    xx
209          #:cache-table-queries               ; 
210          #:*cache-table-queries-default*     ; 
211          #:delete-records                    ; sql        xx
212          #:insert-records                    ; sql        xx
213          #:update-records                    ; sql        xx
214          #:execute-command                   ; sql        xx
215          #:query                             ; sql        xx
216          #:print-query                       ; sql        xx
217          #:do-query                          ; sql        xx
218          #:map-query                         ; sql        xx
219          #:for-each-row
220          #:loop
221
222          ;; conditions
223          #:sql-user-error
224          #:sql-database-error
225          #:sql-database-data-error
226          #:sql-connection-error
227          #:sql-temporary-error
228          #:sql-error-error-id
229          #:sql-error-secondary-error-id
230          #:sql-error-database-message
231
232          ;; CLSQL Extensions
233          #:sql-condition
234          #:sql-error
235          #:sql-warning
236          #:sql-database-warning
237          
238          ;;FDDL
239          #:create-table                      ; table      xx
240          #:drop-table                        ; table      xx
241          #:list-tables                       ; table      xx
242          #:table-exists-p                    ; table      xx 
243          #:list-attributes                   ; table      xx
244          #:attribute-type                    ; table      xx
245          #:list-attribute-types              ; table      xx
246          #:*cache-table-queries-default*     ; table      xx 
247          #:create-view                       ; table      xx
248          #:drop-view                         ; table      xx
249          #:create-index                      ; table      xx            
250          #:drop-index                        ; table      xx            
251          #:truncate-database
252          ;;OODDL
253          #:standard-db-object                ; objects    xx
254          #:def-view-class                    ; objects    xx
255          #:create-view-from-class            ; objects    xx
256          #:drop-view-from-class              ; objects    xx
257          ;;OODML
258          #:instance-refreshed                ; objects    xx 
259          #:update-objects-joins              ; objects    xx
260          #:*default-update-objects-max-len*  ; objects    xx
261          #:update-slot-from-record           ; objects    xx
262          #:update-instance-from-records      ; objects    xx
263          #:update-records-from-instance      ; objects    xx
264          #:update-record-from-slot           ; objects    xx
265          #:update-record-from-slots          ; objects    xx
266          #:list-classes                      ; objects    xx
267          #:delete-instance-records           ; objects    xx
268          ;;Symbolic SQL Syntax 
269          #:sql                               ; syntax     xx
270          #:sql-expression                    ; syntax     xx
271          #:sql-operation                     ; syntax     xx
272          #:sql-operator                      ; syntax     xx    
273          #:disable-sql-reader-syntax         ; syntax     xx
274          #:enable-sql-reader-syntax          ; syntax     xx
275          #:locally-disable-sql-reader-syntax ; syntax     xx
276          #:locally-enable-sql-reader-syntax  ; syntax     xx
277          #:restore-sql-reader-syntax-state   ; syntax     xx
278          
279          ;;FDDL 
280          #:list-views                        ; table      xx
281          #:view-exists-p                     ; table      xx
282          #:list-indexes                      ; table      xx
283          #:list-table-indexes                ; table      xx
284          #:index-exists-p                    ; table      xx
285          #:create-sequence                   ; table      xx
286          #:drop-sequence                     ; table      xx
287          #:list-sequences                    ; table      xx
288          #:sequence-exists-p                 ; table      xx
289          #:sequence-next                     ; table      xx
290          #:sequence-last                     ; table      xx
291          #:set-sequence-position             ; table      xx
292          ;;OODDL
293          #:view-table                        ; metaclass  x
294          #:universal-time                    ; objects    xx 
295          #:bigint
296          ;;OODML
297          #:*db-auto-sync*                    ; objects    xx              
298          #:read-sql-value                    ; objects    x
299          #:database-output-sql-as-type       ; objects    x
300          #:database-get-type-specifier       ; objects    x
301          #:database-output-sql               ; sql/class  xx
302          
303          ;; conditions
304          #:clsql-condition
305          #:clsql-error
306          #:clsql-simple-error
307          #:clsql-simple-warning
308          
309          ;;-----------------------------------------------
310          ;; Symbolic Sql Syntax 
311          ;;-----------------------------------------------
312          #:sql-and-qualifier
313          #:sql-escape
314          #:sql-query
315          #:sql-object-query
316          #:sql-any
317          #:sql-all
318          #:sql-not
319          #:sql-union
320          #:sql-intersection
321          #:sql-minus
322          #:sql-group-by
323          #:sql-having
324          #:sql-null
325          #:sql-not-null
326          #:sql-exists
327          #:sql-*
328          #:sql-+
329          #:sql-/
330          #:sql-like
331          #:sql-uplike
332          #:sql-and
333          #:sql-or
334          #:sql-in
335          #:sql-||
336          #:sql-is
337          #:sql-=
338          #:sql-==
339          #:sql-<
340        #:sql->
341        #:sql->=
342        #:sql-<=
343        #:sql-count
344        #:sql-max
345        #:sql-min
346        #:sql-avg
347        #:sql-sum
348        #:sql-view-class
349        #:sql_slot-value
350
351
352
353        ;; time.lisp
354        #:bad-component
355        #:current-day
356      #:current-month
357      #:current-year
358      #:day-duration
359      #:db-timestring
360      #:decode-duration
361      #:decode-time
362      #:duration
363      #:duration+
364      #:duration<
365      #:duration<=
366      #:duration=
367      #:duration>
368      #:duration>=
369      #:duration-day
370      #:duration-hour
371      #:duration-minute
372      #:duration-month
373      #:duration-second
374      #:duration-year
375      #:duration-reduce 
376      #:duration-timestring
377      #:extract-roman 
378      #:format-duration
379      #:format-time
380      #:get-time
381      #:utime->time
382      #:interval-clear
383      #:interval-contained
384      #:interval-data
385      #:interval-edit
386      #:interval-end
387      #:interval-match
388      #:interval-push
389      #:interval-relation
390      #:interval-start
391      #:interval-type
392      #:make-duration
393      #:make-interval
394      #:make-time
395      #:merged-time
396      #:midnight
397      #:month-name
398      #:parse-date-time
399      #:parse-timestring
400      #:parse-yearstring
401      #:print-date
402      #:roll
403      #:roll-to
404      #:time
405      #:time+
406      #:time-
407      #:time-by-adding-duration
408      #:time-compare
409      #:time-difference
410      #:time-dow
411      #:time-element
412      #:time-max
413      #:time-min
414      #:time-mjd
415      #:time-msec
416      #:time-p
417      #:time-sec
418      #:time-well-formed
419      #:time-ymd
420      #:time<
421      #:time<=
422      #:time=
423      #:time>
424      #:time>=
425      #:timezone
426      #:universal-time
427      #:wall-time
428      #:wall-timestring
429      #:week-containing
430      #:gregorian-to-mjd
431      #:mjd-to-gregorian
432
433      ;; recording.lisp -- SQL I/O Recording 
434      #:record-sql-command
435      #:record-sql-result
436      #:add-sql-stream                 ; recording  xx
437      #:delete-sql-stream                  ; recording  xx
438      #:list-sql-streams           ; recording  xx
439      #:sql-recording-p            ; recording  xx
440      #:sql-stream                         ; recording  xx
441      #:start-sql-recording                ; recording  xx
442      #:stop-sql-recording                 ; recording  xx
443
444      ;; database.lisp -- Connection
445      #:*default-database-type*            ; clsql-base xx
446      #:*default-database*                 ; classes    xx
447      #:*initialized-database-types*
448      #:initialize-database-type
449      #:connect                            ; database   xx
450      #:disconnect                         ; database   xx
451      #:*connect-if-exists*                ; database   xx
452      #:connected-databases                ; database   xx
453      #:database                   ; database   xx
454      #:database-name                     ; database   xx
455      #:reconnect                         ; database
456      #:find-database                     ; database   xx
457      #:status                            ; database   xx
458      #:with-database
459      #:with-default-database
460      #:disconnect-pooled
461      #:create-database
462      #:destroy-database
463      #:probe-database
464      #:list-databases
465      
466      #:describe-table
467      #:*backend-warning-behavior*
468      
469      ;; Transactions
470      #:with-transaction
471      #:commit-transaction
472      #:rollback-transaction
473      #:add-transaction-commit-hook
474      #:add-transaction-rollback-hook
475      #:commit                            ; transact   xx
476      #:rollback                   ; transact   xx
477      #:with-transaction           ; transact   xx               .
478      #:start-transaction                 ; transact   xx
479      #:in-transaction-p                  ; transact   xx
480      #:database-start-transaction
481      #:database-abort-transaction
482      #:database-commit-transaction
483      #:transaction-level
484      #:transaction
485        ))
486   (:documentation "This is the INTERNAL SQL-Interface package of CLSQL."))
487
488
489 (defpackage #:clsql
490   (:use #:common-lisp)
491   (:import-from #:clsql-sys . #1#)
492   (:export . #1#)
493   (:documentation "This is the user package with CLSQL symbols."))
494
495 (defpackage #:clsql-user
496   (:use #:common-lisp)
497   (:import-from #:clsql-sys . #1#)
498   (:export . #1#)
499   (:documentation "This is the user package with CLSQL symbols."))
500
501   ;; This is from USQL's pcl-patch  
502   #+(or clsql-sbcl-pcl clsql-cmucl-pcl)
503   (progn
504     ;; Note that this will no longer required for cmucl as of version 19a. 
505     (in-package #+cmu :pcl #+sbcl :sb-pcl)
506     (defmacro pv-binding1 ((pv calls pv-table-symbol pv-parameters slot-vars) 
507                            &body body)
508       `(pv-env (,pv ,calls ,pv-table-symbol ,pv-parameters)
509         (let (,@(mapcar #'(lambda (slot-var p) `(,slot-var (get-slots-or-nil ,p)))
510                         slot-vars pv-parameters))
511           ,@(mapcar #'(lambda (slot-var) `(declare (ignorable ,slot-var))) slot-vars)
512           ,@body))))
513
514 ;; see http://thread.gmane.org/gmane.lisp.lispworks.general/681
515 #+lispworks
516 (setf *packages-for-warn-on-redefinition* 
517       (delete "SQL" *packages-for-warn-on-redefinition* :test 'string=))
518
519   #+sbcl
520   (if (find-package 'sb-mop)
521       (setq cl:*features* (delete :clsql-sbcl-mop cl:*features*))
522       (setq cl:*features* (delete :clsql-sbcl-pcl cl:*features*)))
523   
524   #+cmu
525   (if (find-package 'mop)
526       (setq cl:*features* (delete :clsql-cmucl-mop cl:*features*))
527       (setq cl:*features* (delete :clsql-cmucl-pcl cl:*features*)))
528
529 ) ;eval-when                                      
530