Automated commit for debian release 6.7.2-1
[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           #+clisp #:clos
40           #+ecl #:mop
41           #+lispworks #:clos
42           #+scl #:clos
43           #+openmcl #:openmcl-mop)
44
45     #+allegro
46     (:shadowing-import-from
47      #:excl)
48     #+clisp
49     (:shadowing-import-from
50      #:clos)
51     #+lispworks
52     (:shadowing-import-from
53      #:clos)
54     #+clsql-sbcl-mop
55     (:shadowing-import-from
56      #:sb-pcl
57      #:generic-function-lambda-list)
58     #+clsql-sbcl-pcl
59     (:shadowing-import-from
60      #:sb-pcl
61      #:name
62      #:class-direct-slots
63      #:class-of #:class-name #:class-slots #:find-class
64      #:slot-boundp
65      #:standard-class
66      #:slot-definition-name #:finalize-inheritance
67      #:standard-direct-slot-definition
68      #:standard-effective-slot-definition #:validate-superclass
69      #:direct-slot-definition-class #:compute-effective-slot-definition
70      #:effective-slot-definition-class
71      #:slot-value-using-class
72      #:class-prototype #:generic-function-method-class #:intern-eql-specializer
73      #:make-method-lambda #:generic-function-lambda-list
74      #:class-precedence-list #:slot-definition-type
75      #:class-direct-superclasses
76      #:compute-class-precedence-list)
77     #+clsql-cmucl-mop
78     (:shadowing-import-from
79      #:pcl
80      #:generic-function-lambda-list)
81     #+clsql-cmucl-pcl
82     (:shadowing-import-from
83      #:pcl
84      #:class-direct-slots
85      #:name
86      #:class-of  #:class-name #:class-slots #:find-class #:standard-class
87      #:slot-boundp
88      #:slot-definition-name #:finalize-inheritance
89      #:standard-direct-slot-definition #:standard-effective-slot-definition
90      #:validate-superclass #:direct-slot-definition-class
91      #:effective-slot-definition-class
92      #:compute-effective-slot-definition
93      #:slot-value-using-class
94      #:class-prototype #:generic-function-method-class #:intern-eql-specializer
95      #:make-method-lambda #:generic-function-lambda-list
96      #:class-precedence-list #:slot-definition-type
97      #:class-direct-superclasses
98      #:compute-class-precedence-list)
99     #+scl
100     (:shadowing-import-from
101      #:clos
102      #:class-prototype  ;; note: make-method-lambda is not fbound
103      )
104
105     (:export
106      ;; "Private" exports for use by interface packages
107      #:check-connection-spec
108      #:database-initialize-database-type
109      #:database-type-load-foreign
110      #:database-connect
111      #:database-disconnect
112      #:database-reconnect
113      #:database-query
114      #:database-execute-command
115      #:database-create-sequence
116      #:database-drop-sequence
117      #:database-sequence-next
118      #:database-set-sequence-position
119      #:database-query-result-set
120      #:database-dump-result-set
121      #:database-store-next-row
122      #:database-list-tables
123      #:database-list-tables-and-sequences
124      #:database-table-exists-p
125      #:database-list-views
126      #:database-view-exists-p
127      #:database-list-indexes
128      #:database-list-table-indexes
129      #:database-index-exists-p
130      #:database-list-sequences
131      #:database-sequence-last
132      #:database-sequence-exists-p
133      #:database-last-auto-increment-id
134      #:database-list-attributes
135      #:database-attribute-type
136      #:database-type-library-loaded
137      #:database-create
138      #:database-destroy
139      #:database-probe
140      #:database-list
141      #:database-acquire-from-conn-pool
142      #:database-release-to-conn-pool
143
144      #:db-backend-has-create/destroy-db?
145      #:db-type-has-views?
146      #:db-type-has-bigint?
147      #:db-type-has-union?
148      #:db-type-has-prepared-stmt?
149      #:db-type-has-subqueries?
150      #:db-type-has-boolean-where?
151      #:db-type-transaction-capable?
152      #:db-type-has-fancy-math?
153      #:db-type-default-case
154      #:db-type-use-column-on-drop-index?
155      #:db-type-use-fully-qualified-column-on-drop-index?
156      #:db-type-has-intersect?
157      #:db-type-has-except?
158      #:db-type-has-auto-increment?
159      #:database-underlying-type
160      #:database-get-type-specifier
161      #:read-sql-value
162      #:database-output-sql-as-type
163      #:*loaded-database-types*
164      #:reload-database-types
165      #:is-database-open
166      #:*db-pool-max-free-connections*
167
168      ;; Large objects
169      #:database-create-large-object
170      #:database-write-large-object
171      #:database-read-large-object
172      #:database-delete-large-object
173      #:create-large-object
174      #:write-large-object
175      #:read-large-object
176      #:delete-large-object
177
178      ;; Prepared statments
179      #:database-prepare
180      #:database-run-prepared
181      #:database-bind-parameter
182      #:database-free-prepared
183
184      ;; accessors for database class
185      #:name
186      #:connection-spec
187      #:transaction
188      #:transaction-level
189      #:conn-pool
190      #:command-recording-stream
191      #:result-recording-stream
192      #:record-caches
193      #:view-classes
194      #:database-state
195      #:attribute-cache
196      #:database-autocommit
197      #:encoding
198
199      ;; utils.lisp
200      #:without-interrupts
201      #:make-process-lock
202      #:with-process-lock
203      #:command-output
204      #:symbol-name-default-case
205      #:convert-to-db-default-case
206      #:ensure-keyword
207      #:getenv
208      #:number-to-sql-string
209      #:float-to-sql-string
210      #:sql-escape-quotes
211      #:sql-escape
212      #:in
213
214      ;; Command-object.lisp
215      #:expression
216      #:parameters
217      #:prepare-sql-parameter
218      #:prepared-name
219      #:has-been-prepared
220      #:command-object
221      #:reset-command-object
222
223      ;; Generic backends
224      #:generic-postgresql-database
225      #:generic-odbc-database
226
227          ;; Subclasses of sql-expresssion (expressions.lisp)
228          #:sql-function-exp
229          #:sql-value-exp
230          #:sql-set-exp
231          #:sql-query-modifier-exp
232          #:sql-relational-exp
233          #:sql-upcase-like
234          #:sql-assignment-exp
235          #:sql-typecast-exp
236          #:sql-between-exp
237          #:sql-ident
238          #:sql-ident-attribute
239          #:sql-ident-table
240
241      .
242
243      ;; Shared exports for re-export by CLSQL package.
244      #1=(
245
246          ;; foreign library loading
247          #:*foreign-library-search-paths*
248          #:push-library-path
249
250          ;; Condition system (conditions.lisp)
251          #:sql-user-error
252          #:sql-database-error
253          #:sql-database-data-error
254          #:sql-connection-error
255          #:sql-temporary-error
256          #:sql-timeout-error
257          #:sql-fatal-error
258          #:sql-error-error-id
259          #:sql-error-secondary-error-id
260          #:sql-error-database-message
261          ;; CLSQL Extensions
262          #:sql-condition
263          #:sql-error
264          #:sql-warning
265          #:sql-database-warning
266          #:sql-error-database
267          #:sql-error-database-type
268          #:sql-error-connection-spec
269          #:sql-error-expression
270          #:sql-warning-database
271          #:sql-user-error-message
272          #:*backend-warning-behavior*
273
274          ;; Connection/initialisation (base-classes.lisp, database.lisp,
275          ;;   initialize.lisp)
276          #:*default-database-type*
277          #:*default-database*
278          #:*initialized-database-types*
279          #:initialize-database-type
280          #:connect
281          #:disconnect
282          #:*connect-if-exists*
283          #:connected-databases
284          #:database
285          #:database-name
286          #:reconnect
287          #:find-database
288          #:status
289          ;; CLSQL Extensions
290          #:database-name-from-spec
291          #:database-type
292          #:with-database
293          #:with-default-database
294          #:disconnect-pooled
295          #:list-databases
296          #:create-database
297          #:destroy-database
298          #:probe-database
299
300          ;; I/O Recording (recording.lisp)
301          #:add-sql-stream
302          #:delete-sql-stream
303          #:list-sql-streams
304          #:sql-recording-p
305          #:sql-stream
306          #:start-sql-recording
307          #:stop-sql-recording
308
309          ;; FDDL (fddl.lisp)
310          #:create-table
311          #:drop-table
312          #:list-tables
313          #:table-exists-p
314          #:list-attributes
315          #:attribute-type
316          #:list-attribute-types
317          #:create-view
318          #:drop-view
319          #:create-index
320          #:drop-index
321          ;; CLSQL Extensions
322          #:truncate-database
323          #:list-views
324          #:view-exists-p
325          #:list-indexes
326          #:index-exists-p
327          #:create-sequence
328          #:drop-sequence
329          #:list-sequences
330          #:sequence-exists-p
331          #:sequence-next
332          #:sequence-last
333          #:set-sequence-position
334          #:*old-sequence-names*
335
336          ;; FDML (fdml.lisp)
337          #:select
338          #:cache-table-queries
339          #:*cache-table-queries-default*
340          #:delete-records
341          #:insert-records
342          #:update-records
343          #:execute-command
344          #:query
345          #:print-query
346          #:do-query
347          #:map-query
348          #:loop
349          ;; CLSQL Extensions
350          #:prepare-sql
351          #:bind-parameter
352          #:run-prepared-sql
353          #:free-prepared-sql
354
355          ;; Transaction handling (transaction.lisp)
356          #:with-transaction
357          #:commit
358          #:rollback
359          ;; CLSQL Extensions
360          #:add-transaction-commit-hook
361          #:add-transaction-rollback-hook
362          #:start-transaction
363          #:in-transaction-p
364          #:set-autocommit
365
366          ;; OODDL (ooddl.lisp)
367          #:standard-db-object
368          #:def-view-class
369          #:create-view-from-class
370          #:drop-view-from-class
371          #:list-classes
372          #:universal-time
373          ;; CLSQL Extensions
374          #:view-table
375          #:bigint
376          #:varchar
377          #:longchar
378          #:text
379          #:generalized-boolean
380          #:mediumint
381          #:smallint
382          #:tinyint
383          #:*default-string-length*
384
385          ;; OODML (oodml.lisp)
386          #:select-list
387          #:filter-select-list
388          #:slot-list
389          #:joins
390          #:join-slots
391          #:instance-refreshed
392          #:update-objects-joins
393          #:*default-update-objects-max-len*
394          #:*default-caching*
395          #:update-slot-from-record
396          #:update-instance-from-records
397          #:update-records-from-instance
398          #:update-record-from-slot
399          #:update-record-from-slots
400          #:delete-instance-records
401          ;; CLSQL Extensions
402          #:*db-auto-sync*
403          #:write-instance-to-stream
404          #:read-instance-from-stream
405
406          ;; Symbolic SQL Syntax (syntax.lisp)
407          #:sql
408          #:sql-expression
409          #:sql-operation
410          #:sql-operator
411          #:disable-sql-reader-syntax
412          #:enable-sql-reader-syntax
413          #:locally-disable-sql-reader-syntax
414          #:locally-enable-sql-reader-syntax
415          #:restore-sql-reader-syntax-state
416          #:file-enable-sql-reader-syntax
417
418          ;; SQL operations (operations.lisp)
419          #:sql-query
420          #:sql-object-query
421          #:sql-any
422          #:sql-some
423          #:sql-all
424          #:sql-not
425          #:sql-union
426          #:sql-intersect
427          #:sql-minus
428          #:sql-except
429          #:sql-order-by
430          #:sql-null
431          #:sql-*
432          #:sql-+
433          #:sql-/
434          #:sql--
435          #:sql-like
436          #:sql-and
437          #:sql-or
438          #:sql-in
439          #:sql-substr
440          #:sql-concat-op
441          #:sql-=
442          #:sql-<
443          #:sql->
444          #:sql->=
445          #:sql-<=
446          #:sql-<>
447          #:sql-count
448          #:sql-max
449          #:sql-min
450          #:sql-avg
451          #:sql-sum
452          #:sql-function
453          #:sql-between
454          #:sql-distinct
455          #:sql-nvl
456          #:sql-slot-value
457          #:sql-userenv
458          ;; CLSQL Extensions
459          #:sql-concat
460          #:sql-substring
461          #:sql-limit
462          #:sql-group-by
463          #:sql-having
464          #:sql-not-null
465          #:sql-exists
466          #:sql-uplike
467          #:sql-is
468          #:sql-==
469          #:sql-the
470          #:sql-coalesce
471          #:sql-view-class
472
473          ;; Time handling (time.lisp)
474          #:bad-component
475          #:current-day
476          #:current-month
477          #:current-year
478          #:day-duration
479          #:db-timestring
480          #:db-datestring
481          #:decode-duration
482          #:decode-time
483          #:decode-date
484          #:duration
485          #:duration+
486          #:duration<
487          #:duration<=
488          #:duration=
489          #:duration>
490          #:duration>=
491          #:duration-day
492          #:duration-hour
493          #:duration-minute
494          #:duration-month
495          #:duration-second
496          #:duration-year
497          #:duration-reduce
498          #:duration-timestring
499          #:extract-roman
500          #:format-duration
501          #:format-time
502          #:format-date
503          #:get-time
504          #:get-date
505          #:utime->time
506          #:interval-clear
507          #:interval-contained
508          #:interval-data
509          #:interval-edit
510          #:interval-end
511          #:interval-match
512          #:interval-push
513          #:interval-relation
514          #:interval-start
515          #:interval-type
516          #:make-duration
517          #:make-interval
518          #:make-time
519          #:make-date
520          #:merged-time
521          #:midnight
522          #:month-name
523          #:parse-date-time
524          #:parse-timestring
525          #:parse-datestring
526          #:parse-yearstring
527          #:print-date
528          #:roll
529          #:roll-to
530          #:time
531          #:time+
532          #:time-
533          #:time-by-adding-duration
534          #:time-compare
535          #:time-difference
536          #:time-dow
537          #:time-element
538          #:time-max
539          #:time-min
540          #:time-mjd
541          #:time-msec
542          #:time-p
543          #:time-sec
544          #:time-well-formed
545          #:time-ymd
546          #:time<
547          #:time<=
548          #:time=
549          #:time>
550          #:time>=
551          #:date
552          #:date+
553          #:date-
554          #:date-difference
555          #:date-compare
556          #:date-dow
557          #:date-element
558          #:date-max
559          #:date-min
560          #:date-mjd
561          #:date-p
562          #:date-ymd
563          #:date<
564          #:date<=
565          #:date=
566          #:date>
567          #:date>=
568          #:timezone
569          #:universal-time
570          #:wall-time
571          #:wall-timestring
572          #:week-containing
573          #:gregorian-to-mjd
574          #:mjd-to-gregorian
575          #:iso-timestring
576          ))
577     (:documentation "This is the INTERNAL SQL-Interface package of CLSQL."))
578
579
580 (defpackage #:clsql
581   (:use #:common-lisp)
582   (:import-from #:clsql-sys . #1#)
583   (:export . #1#)
584   (:documentation "This is the user package with CLSQL symbols."))
585
586 (defpackage #:clsql-user
587   (:use #:common-lisp)
588   (:import-from #:clsql-sys . #1#)
589   (:export . #1#)
590   (:documentation "This is the user package with CLSQL symbols."))
591
592   ;; This is from USQL's pcl-patch
593   #+(or clsql-sbcl-pcl clsql-cmucl-pcl)
594   (progn
595     ;; Note that this will no longer required for cmucl as of version 19a.
596     (in-package #+cmu :pcl #+sbcl :sb-pcl)
597     (defmacro pv-binding1 ((pv calls pv-table-symbol pv-parameters slot-vars)
598                            &body body)
599       `(pv-env (,pv ,calls ,pv-table-symbol ,pv-parameters)
600         (let (,@(mapcar #'(lambda (slot-var p) `(,slot-var (get-slots-or-nil ,p)))
601                         slot-vars pv-parameters))
602           ,@(mapcar #'(lambda (slot-var) `(declare (ignorable ,slot-var))) slot-vars)
603           ,@body))))
604
605 ;; see http://thread.gmane.org/gmane.lisp.lispworks.general/681
606 #+lispworks
607 (setf *packages-for-warn-on-redefinition*
608       (delete "SQL" *packages-for-warn-on-redefinition* :test 'string=))
609
610   #+sbcl
611   (if (find-package 'sb-mop)
612       (setq cl:*features* (delete :clsql-sbcl-mop cl:*features*))
613       (setq cl:*features* (delete :clsql-sbcl-pcl cl:*features*)))
614
615   #+cmu
616   (if (find-package 'mop)
617       (setq cl:*features* (delete :clsql-cmucl-mop cl:*features*))
618       (setq cl:*features* (delete :clsql-cmucl-pcl cl:*features*)))
619
620 ) ;eval-when
621