eb5b0ed46282984b0c64420642daee9f48fbf413
[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      #:prepared-name
217      #:has-been-prepared
218      #:command-object
219      #:reset-command-object
220
221      ;; Generic backends
222      #:generic-postgresql-database
223      #:generic-odbc-database
224
225          ;; Subclasses of sql-expresssion (expressions.lisp)
226          #:sql-function-exp
227          #:sql-value-exp
228          #:sql-set-exp
229          #:sql-query-modifier-exp
230          #:sql-relational-exp
231          #:sql-upcase-like
232          #:sql-assignment-exp
233          #:sql-typecast-exp
234          #:sql-between-exp
235          #:sql-ident
236          #:sql-ident-attribute
237          #:sql-ident-table
238
239      .
240
241      ;; Shared exports for re-export by CLSQL package.
242      #1=(
243
244          ;; foreign library loading
245          #:*foreign-library-search-paths*
246          #:push-library-path
247
248          ;; Condition system (conditions.lisp)
249          #:sql-user-error
250          #:sql-database-error
251          #:sql-database-data-error
252          #:sql-connection-error
253          #:sql-temporary-error
254          #:sql-timeout-error
255          #:sql-fatal-error
256          #:sql-error-error-id
257          #:sql-error-secondary-error-id
258          #:sql-error-database-message
259          ;; CLSQL Extensions
260          #:sql-condition
261          #:sql-error
262          #:sql-warning
263          #:sql-database-warning
264          #:sql-error-database
265          #:sql-error-database-type
266          #:sql-error-connection-spec
267          #:sql-error-expression
268          #:sql-warning-database
269          #:sql-user-error-message
270          #:*backend-warning-behavior*
271
272          ;; Connection/initialisation (base-classes.lisp, database.lisp,
273          ;;   initialize.lisp)
274          #:*default-database-type*
275          #:*default-database*
276          #:*initialized-database-types*
277          #:initialize-database-type
278          #:connect
279          #:disconnect
280          #:*connect-if-exists*
281          #:connected-databases
282          #:database
283          #:database-name
284          #:reconnect
285          #:find-database
286          #:status
287          ;; CLSQL Extensions
288          #:database-name-from-spec
289          #:database-type
290          #:with-database
291          #:with-default-database
292          #:disconnect-pooled
293          #:list-databases
294          #:create-database
295          #:destroy-database
296          #:probe-database
297
298          ;; I/O Recording (recording.lisp)
299          #:add-sql-stream
300          #:delete-sql-stream
301          #:list-sql-streams
302          #:sql-recording-p
303          #:sql-stream
304          #:start-sql-recording
305          #:stop-sql-recording
306
307          ;; FDDL (fddl.lisp)
308          #:create-table
309          #:drop-table
310          #:list-tables
311          #:table-exists-p
312          #:list-attributes
313          #:attribute-type
314          #:list-attribute-types
315          #:create-view
316          #:drop-view
317          #:create-index
318          #:drop-index
319          ;; CLSQL Extensions
320          #:truncate-database
321          #:list-views
322          #:view-exists-p
323          #:list-indexes
324          #:index-exists-p
325          #:create-sequence
326          #:drop-sequence
327          #:list-sequences
328          #:sequence-exists-p
329          #:sequence-next
330          #:sequence-last
331          #:set-sequence-position
332          #:*old-sequence-names*
333
334          ;; FDML (fdml.lisp)
335          #:select
336          #:cache-table-queries
337          #:*cache-table-queries-default*
338          #:delete-records
339          #:insert-records
340          #:update-records
341          #:execute-command
342          #:query
343          #:print-query
344          #:do-query
345          #:map-query
346          #:loop
347          ;; CLSQL Extensions
348          #:prepare-sql
349          #:bind-parameter
350          #:run-prepared-sql
351          #:free-prepared-sql
352
353          ;; Transaction handling (transaction.lisp)
354          #:with-transaction
355          #:commit
356          #:rollback
357          ;; CLSQL Extensions
358          #:add-transaction-commit-hook
359          #:add-transaction-rollback-hook
360          #:start-transaction
361          #:in-transaction-p
362          #:set-autocommit
363
364          ;; OODDL (ooddl.lisp)
365          #:standard-db-object
366          #:def-view-class
367          #:create-view-from-class
368          #:drop-view-from-class
369          #:list-classes
370          #:universal-time
371          ;; CLSQL Extensions
372          #:view-table
373          #:bigint
374          #:varchar
375          #:generalized-boolean
376          #:mediumint
377          #:smallint
378          #:tinyint
379          #:*default-string-length*
380
381          ;; OODML (oodml.lisp)
382          #:instance-refreshed
383          #:update-objects-joins
384          #:*default-update-objects-max-len*
385          #:*default-caching*
386          #:update-slot-from-record
387          #:update-instance-from-records
388          #:update-records-from-instance
389          #:update-record-from-slot
390          #:update-record-from-slots
391          #:delete-instance-records
392          ;; CLSQL Extensions
393          #:*db-auto-sync*
394          #:write-instance-to-stream
395          #:read-instance-from-stream
396
397          ;; Symbolic SQL Syntax (syntax.lisp)
398          #:sql
399          #:sql-expression
400          #:sql-operation
401          #:sql-operator
402          #:disable-sql-reader-syntax
403          #:enable-sql-reader-syntax
404          #:locally-disable-sql-reader-syntax
405          #:locally-enable-sql-reader-syntax
406          #:restore-sql-reader-syntax-state
407          #:file-enable-sql-reader-syntax
408
409          ;; SQL operations (operations.lisp)
410          #:sql-query
411          #:sql-object-query
412          #:sql-any
413          #:sql-some
414          #:sql-all
415          #:sql-not
416          #:sql-union
417          #:sql-intersect
418          #:sql-minus
419          #:sql-except
420          #:sql-order-by
421          #:sql-null
422          #:sql-*
423          #:sql-+
424          #:sql-/
425          #:sql--
426          #:sql-like
427          #:sql-and
428          #:sql-or
429          #:sql-in
430          #:sql-substr
431          #:sql-concat-op
432          #:sql-=
433          #:sql-<
434          #:sql->
435          #:sql->=
436          #:sql-<=
437          #:sql-<>
438          #:sql-count
439          #:sql-max
440          #:sql-min
441          #:sql-avg
442          #:sql-sum
443          #:sql-function
444          #:sql-between
445          #:sql-distinct
446          #:sql-nvl
447          #:sql-slot-value
448          #:sql-userenv
449          ;; CLSQL Extensions
450          #:sql-concat
451          #:sql-substring
452          #:sql-limit
453          #:sql-group-by
454          #:sql-having
455          #:sql-not-null
456          #:sql-exists
457          #:sql-uplike
458          #:sql-is
459          #:sql-==
460          #:sql-the
461          #:sql-coalesce
462          #:sql-view-class
463
464          ;; Time handling (time.lisp)
465          #:bad-component
466          #:current-day
467          #:current-month
468          #:current-year
469          #:day-duration
470          #:db-timestring
471          #:db-datestring
472          #:decode-duration
473          #:decode-time
474          #:decode-date
475          #:duration
476          #:duration+
477          #:duration<
478          #:duration<=
479          #:duration=
480          #:duration>
481          #:duration>=
482          #:duration-day
483          #:duration-hour
484          #:duration-minute
485          #:duration-month
486          #:duration-second
487          #:duration-year
488          #:duration-reduce
489          #:duration-timestring
490          #:extract-roman
491          #:format-duration
492          #:format-time
493          #:format-date
494          #:get-time
495          #:get-date
496          #:utime->time
497          #:interval-clear
498          #:interval-contained
499          #:interval-data
500          #:interval-edit
501          #:interval-end
502          #:interval-match
503          #:interval-push
504          #:interval-relation
505          #:interval-start
506          #:interval-type
507          #:make-duration
508          #:make-interval
509          #:make-time
510          #:make-date
511          #:merged-time
512          #:midnight
513          #:month-name
514          #:parse-date-time
515          #:parse-timestring
516          #:parse-datestring
517          #:parse-yearstring
518          #:print-date
519          #:roll
520          #:roll-to
521          #:time
522          #:time+
523          #:time-
524          #:time-by-adding-duration
525          #:time-compare
526          #:time-difference
527          #:time-dow
528          #:time-element
529          #:time-max
530          #:time-min
531          #:time-mjd
532          #:time-msec
533          #:time-p
534          #:time-sec
535          #:time-well-formed
536          #:time-ymd
537          #:time<
538          #:time<=
539          #:time=
540          #:time>
541          #:time>=
542          #:date
543          #:date+
544          #:date-
545          #:date-difference
546          #:date-compare
547          #:date-dow
548          #:date-element
549          #:date-max
550          #:date-min
551          #:date-mjd
552          #:date-p
553          #:date-ymd
554          #:date<
555          #:date<=
556          #:date=
557          #:date>
558          #:date>=
559          #:timezone
560          #:universal-time
561          #:wall-time
562          #:wall-timestring
563          #:week-containing
564          #:gregorian-to-mjd
565          #:mjd-to-gregorian
566          #:iso-timestring
567          ))
568     (:documentation "This is the INTERNAL SQL-Interface package of CLSQL."))
569
570
571 (defpackage #:clsql
572   (:use #:common-lisp)
573   (:import-from #:clsql-sys . #1#)
574   (:export . #1#)
575   (:documentation "This is the user package with CLSQL symbols."))
576
577 (defpackage #:clsql-user
578   (:use #:common-lisp)
579   (:import-from #:clsql-sys . #1#)
580   (:export . #1#)
581   (:documentation "This is the user package with CLSQL symbols."))
582
583   ;; This is from USQL's pcl-patch
584   #+(or clsql-sbcl-pcl clsql-cmucl-pcl)
585   (progn
586     ;; Note that this will no longer required for cmucl as of version 19a.
587     (in-package #+cmu :pcl #+sbcl :sb-pcl)
588     (defmacro pv-binding1 ((pv calls pv-table-symbol pv-parameters slot-vars)
589                            &body body)
590       `(pv-env (,pv ,calls ,pv-table-symbol ,pv-parameters)
591         (let (,@(mapcar #'(lambda (slot-var p) `(,slot-var (get-slots-or-nil ,p)))
592                         slot-vars pv-parameters))
593           ,@(mapcar #'(lambda (slot-var) `(declare (ignorable ,slot-var))) slot-vars)
594           ,@body))))
595
596 ;; see http://thread.gmane.org/gmane.lisp.lispworks.general/681
597 #+lispworks
598 (setf *packages-for-warn-on-redefinition*
599       (delete "SQL" *packages-for-warn-on-redefinition* :test 'string=))
600
601   #+sbcl
602   (if (find-package 'sb-mop)
603       (setq cl:*features* (delete :clsql-sbcl-mop cl:*features*))
604       (setq cl:*features* (delete :clsql-sbcl-pcl cl:*features*)))
605
606   #+cmu
607   (if (find-package 'mop)
608       (setq cl:*features* (delete :clsql-cmucl-mop cl:*features*))
609       (setq cl:*features* (delete :clsql-cmucl-pcl cl:*features*)))
610
611 ) ;eval-when
612