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