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