Added filter-select-list (for clsql-helper:recency-mixin) as an
[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          #:longchar
377          #:text
378          #:generalized-boolean
379          #:mediumint
380          #:smallint
381          #:tinyint
382          #:*default-string-length*
383
384          ;; OODML (oodml.lisp)
385          #:select-list
386          #:filter-select-list
387          #:slot-list
388          #:joins
389          #:join-slots
390          #:instance-refreshed
391          #:update-objects-joins
392          #:*default-update-objects-max-len*
393          #:*default-caching*
394          #:update-slot-from-record
395          #:update-instance-from-records
396          #:update-records-from-instance
397          #:update-record-from-slot
398          #:update-record-from-slots
399          #:delete-instance-records
400          ;; CLSQL Extensions
401          #:*db-auto-sync*
402          #:write-instance-to-stream
403          #:read-instance-from-stream
404
405          ;; Symbolic SQL Syntax (syntax.lisp)
406          #:sql
407          #:sql-expression
408          #:sql-operation
409          #:sql-operator
410          #:disable-sql-reader-syntax
411          #:enable-sql-reader-syntax
412          #:locally-disable-sql-reader-syntax
413          #:locally-enable-sql-reader-syntax
414          #:restore-sql-reader-syntax-state
415          #:file-enable-sql-reader-syntax
416
417          ;; SQL operations (operations.lisp)
418          #:sql-query
419          #:sql-object-query
420          #:sql-any
421          #:sql-some
422          #:sql-all
423          #:sql-not
424          #:sql-union
425          #:sql-intersect
426          #:sql-minus
427          #:sql-except
428          #:sql-order-by
429          #:sql-null
430          #:sql-*
431          #:sql-+
432          #:sql-/
433          #:sql--
434          #:sql-like
435          #:sql-and
436          #:sql-or
437          #:sql-in
438          #:sql-substr
439          #:sql-concat-op
440          #:sql-=
441          #:sql-<
442          #:sql->
443          #:sql->=
444          #:sql-<=
445          #:sql-<>
446          #:sql-count
447          #:sql-max
448          #:sql-min
449          #:sql-avg
450          #:sql-sum
451          #:sql-function
452          #:sql-between
453          #:sql-distinct
454          #:sql-nvl
455          #:sql-slot-value
456          #:sql-userenv
457          ;; CLSQL Extensions
458          #:sql-concat
459          #:sql-substring
460          #:sql-limit
461          #:sql-group-by
462          #:sql-having
463          #:sql-not-null
464          #:sql-exists
465          #:sql-uplike
466          #:sql-is
467          #:sql-==
468          #:sql-the
469          #:sql-coalesce
470          #:sql-view-class
471
472          ;; Time handling (time.lisp)
473          #:bad-component
474          #:current-day
475          #:current-month
476          #:current-year
477          #:day-duration
478          #:db-timestring
479          #:db-datestring
480          #:decode-duration
481          #:decode-time
482          #:decode-date
483          #:duration
484          #:duration+
485          #:duration<
486          #:duration<=
487          #:duration=
488          #:duration>
489          #:duration>=
490          #:duration-day
491          #:duration-hour
492          #:duration-minute
493          #:duration-month
494          #:duration-second
495          #:duration-year
496          #:duration-reduce
497          #:duration-timestring
498          #:extract-roman
499          #:format-duration
500          #:format-time
501          #:format-date
502          #:get-time
503          #:get-date
504          #:utime->time
505          #:interval-clear
506          #:interval-contained
507          #:interval-data
508          #:interval-edit
509          #:interval-end
510          #:interval-match
511          #:interval-push
512          #:interval-relation
513          #:interval-start
514          #:interval-type
515          #:make-duration
516          #:make-interval
517          #:make-time
518          #:make-date
519          #:merged-time
520          #:midnight
521          #:month-name
522          #:parse-date-time
523          #:parse-timestring
524          #:parse-datestring
525          #:parse-yearstring
526          #:print-date
527          #:roll
528          #:roll-to
529          #:time
530          #:time+
531          #:time-
532          #:time-by-adding-duration
533          #:time-compare
534          #:time-difference
535          #:time-dow
536          #:time-element
537          #:time-max
538          #:time-min
539          #:time-mjd
540          #:time-msec
541          #:time-p
542          #:time-sec
543          #:time-well-formed
544          #:time-ymd
545          #:time<
546          #:time<=
547          #:time=
548          #:time>
549          #:time>=
550          #:date
551          #:date+
552          #:date-
553          #:date-difference
554          #:date-compare
555          #:date-dow
556          #:date-element
557          #:date-max
558          #:date-min
559          #:date-mjd
560          #:date-p
561          #:date-ymd
562          #:date<
563          #:date<=
564          #:date=
565          #:date>
566          #:date>=
567          #:timezone
568          #:universal-time
569          #:wall-time
570          #:wall-timestring
571          #:week-containing
572          #:gregorian-to-mjd
573          #:mjd-to-gregorian
574          #:iso-timestring
575          ))
576     (:documentation "This is the INTERNAL SQL-Interface package of CLSQL."))
577
578
579 (defpackage #:clsql
580   (:use #:common-lisp)
581   (:import-from #:clsql-sys . #1#)
582   (:export . #1#)
583   (:documentation "This is the user package with CLSQL symbols."))
584
585 (defpackage #:clsql-user
586   (:use #:common-lisp)
587   (:import-from #:clsql-sys . #1#)
588   (:export . #1#)
589   (:documentation "This is the user package with CLSQL symbols."))
590
591   ;; This is from USQL's pcl-patch
592   #+(or clsql-sbcl-pcl clsql-cmucl-pcl)
593   (progn
594     ;; Note that this will no longer required for cmucl as of version 19a.
595     (in-package #+cmu :pcl #+sbcl :sb-pcl)
596     (defmacro pv-binding1 ((pv calls pv-table-symbol pv-parameters slot-vars)
597                            &body body)
598       `(pv-env (,pv ,calls ,pv-table-symbol ,pv-parameters)
599         (let (,@(mapcar #'(lambda (slot-var p) `(,slot-var (get-slots-or-nil ,p)))
600                         slot-vars pv-parameters))
601           ,@(mapcar #'(lambda (slot-var) `(declare (ignorable ,slot-var))) slot-vars)
602           ,@body))))
603
604 ;; see http://thread.gmane.org/gmane.lisp.lispworks.general/681
605 #+lispworks
606 (setf *packages-for-warn-on-redefinition*
607       (delete "SQL" *packages-for-warn-on-redefinition* :test 'string=))
608
609   #+sbcl
610   (if (find-package 'sb-mop)
611       (setq cl:*features* (delete :clsql-sbcl-mop cl:*features*))
612       (setq cl:*features* (delete :clsql-sbcl-pcl cl:*features*)))
613
614   #+cmu
615   (if (find-package 'mop)
616       (setq cl:*features* (delete :clsql-cmucl-mop cl:*features*))
617       (setq cl:*features* (delete :clsql-cmucl-pcl cl:*features*)))
618
619 ) ;eval-when
620