Use :verbose nil for asdf:operate invocation
[clsql/s11.git] / sql / initialize.lisp
blobfd06c3e004607e9ee4051f2246f5f2aa6acb852f
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name: initialize.lisp
6 ;;;; Purpose: Initializion routines for backend
7 ;;;; Programmers: Kevin M. Rosenberg
8 ;;;; Date Started: May 2002
9 ;;;;
10 ;;;; $Id$
11 ;;;;
12 ;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg
13 ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
14 ;;;;
15 ;;;; CLSQL users are granted the rights to distribute and use this software
16 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
17 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
18 ;;;; *************************************************************************
20 (in-package #:clsql-sys)
22 (defvar *loaded-database-types* nil
23 "Contains a list of database types which have been defined/loaded.")
25 (defmethod database-type-load-foreign (x)
26 (error "No generic function defined for database-type-load-foreign with parameters of ~S" x))
28 (defmethod database-type-load-foreign :after (database-type)
29 (when (database-type-library-loaded database-type)
30 (pushnew database-type *loaded-database-types*)))
32 (defun reload-database-types ()
33 "Reloads any foreign code for the loaded database types after a dump."
34 (mapc #'database-type-load-foreign *loaded-database-types*))
36 (defvar *default-database-type* nil
37 "Designates the default database type which is initialised by
38 the function INITIALISE-DATABASE-TYPE.")
40 (defvar *initialized-database-types* nil
41 "A list of database types which have currently been initialised
42 by calling INITIALIZE-DATABASE-TYPE.")
44 (defun initialize-database-type (&key (database-type *default-database-type*))
45 "Initializes the supplied DATABASE-TYPE, if it is not already
46 initialized, as indicated by *INITIALIZED-DATABASE-TYPES* and
47 returns DATABASE-TYPE. *DEFAULT-DATABASE-TYPE* is set to
48 DATABASE-TYPE and, if DATABASE-TYPE has not been initialised, it
49 is added to *INITIALIZED-DATABASE-TYPES*. "
50 (when (member database-type *initialized-database-types*)
51 (return-from initialize-database-type database-type))
53 (let ((system (intern (concatenate 'string
54 (symbol-name '#:clsql-)
55 (symbol-name database-type)))))
56 (when (not (find-package system))
57 (asdf:operate 'asdf:load-op system)))
59 (when (database-initialize-database-type database-type)
60 (push database-type *initialized-database-types*)
61 (setf *default-database-type* database-type)
62 database-type))