2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4 <!ENTITY % myents SYSTEM "entities.inc">
8 <chapter id="introduction">
9 <title>Introduction</title>
12 <title>Purpose</title>
13 <para>&clsql; is a Common Lisp interface to <glossterm
14 linkend="gloss-sql">SQL</glossterm> databases. A number of Common
15 Lisp implementations and SQL databases are supported. The general
16 structure of &clsql; is based on the &commonsql; package by
22 <title>History</title>
24 The &clsql; project was started by Kevin M. Rosenberg in 2001 to
25 support SQL access on multiple Common Lisp implementations using
26 the &uffi; library. The initial code was based substantially on
27 Pierre R. Mai's excellent &maisql; package. In late 2003, the
28 &usql; library was orphaned by its author, onShore Development,
29 Inc. In April 2004, Marcus Pearce ported the &usql; library to
30 &clsql;. The &usql; library provides a &commonsql;-compatible
34 <para>The main changes from &maisql; and &usql; are:
37 <para>Port from the &cmucl; FFI to &uffi; which provide
38 compatibility with the major Common Lisp
39 implementations.</para>
42 <para>Optimized loading of integer and floating-point fields.</para>
45 <para>Additional database backends: &odbc;, &aodbc;, &sqlite;
49 <para>A compatibility layer for &cmucl; specific code.</para>
52 <para>Much improved robustness for the &mysql; back-end
53 along with version 4 client library support.</para>
56 <para>Improved library loading and installation documentation.</para>
59 <para>Improved packages and symbol export.</para>
62 <para>Pooled connections.</para>
65 <para>Integrated transaction support for the classic
66 &maisql; iteration macros.</para>
72 <sect1 id="prerequisites">
73 <title>Prerequisites</title>
78 &clsql; uses &asdf; to compile and load its components.
79 &asdf; is included in the <ulink
80 url="http://cclan.sourceforge.net"><citetitle>&cclan;</citetitle></ulink>
89 url="http://uffi.kpe.io/"><citetitle>&uffi;</citetitle></ulink>
90 as a <emphasis>Foreign Function Interface</emphasis>
91 (<glossterm linkend="gloss-ffi">FFI</glossterm>) to support
92 multiple &cl; implementations.
98 <para>&clsql;'s postgresql-socket interface uses Pierre Mai's
99 <ulink url="http://files.kpe.io/md5/">md5</ulink>
104 <title>Supported Common Lisp Implementation</title>
106 The implementations that support &clsql; is governed by the supported
107 implementations of &uffi;. The following implementations are supported:
109 <itemizedlist mark="opencircle">
110 <listitem><para>&acl; v6.2 through 8.0 on Debian Linux x86 &
111 x86_64 & PowerPC, FreeBSD 4.5, and Microsoft Windows
112 XP.</para></listitem>
113 <listitem><para>&lw; v4.3 and v4.4 on Debian Linux and Microsoft
114 Windows XP.</para></listitem>
115 <listitem><para>&cmucl; 18e on Debian Linux, FreeBSD 4.5, and
116 Solaris 2.8. 19c on Debian Linux.</para></listitem>
117 <listitem><para>&sbcl; 0.8.4 through 0.9.16 on Debian
118 Linux.</para></listitem>
119 <listitem><para>&scl; 1.1.1 on Debian Linux.</para></listitem>
120 <listitem><para>&openmcl; 0.14 PowerPC and 1.0pre AMD64 on Debian Linux .</para></listitem>
125 <title>Supported &sql; Implementation</title>
127 &clsql; supports the following databases:
129 <itemizedlist mark="opencircle">
130 <listitem><para>&mysql; (tested v3.23.51, v4.0.18, 5.0.24).</para></listitem>
131 <listitem><para>&postgresql; (tested with v7.4 and 8.0 with both direct API and TCP
132 socket connections.</para></listitem>
133 <listitem><para>&sqlite;.</para></listitem>
134 <listitem><para>&sqlite3;.</para></listitem>
135 <listitem><para>Direct &odbc; interface.</para></listitem>
136 <listitem><para>&oracle; OCI.</para></listitem>
137 <listitem><para>Allegro's DB interface (&aodbc;).</para></listitem>
143 <sect1 id="installation">
144 <title>Installation</title>
147 <title>Ensure &asdf; is loaded</title>
149 Simply load the file <filename>asdf.lisp</filename>.
157 <title>Build &c; helper libraries</title>
158 <para>&clsql; uses functions that require 64-bit integer
159 parameters and return values. The &ffi; in most &clsql;
160 implementations do not support 64-bit integers. Thus, C helper
161 libraries are required to break these 64-bit integers into two compatible
162 32-bit integers. The helper libraries reside in the directories
163 <filename>uffi</filename> and <filename>db-mysql</filename>.
167 <title>&mswindows;</title>
169 Files named <filename>Makefile.msvc</filename> are supplied
170 for building the libraries under Microsoft Windows. Since
171 &mswindows; does not come with that compiler, compiled
172 <type>DLL</type> and <type>LIB</type> library files are
173 supplied with &clsql;.
178 <title>&unix;</title>
180 Files named <filename>Makefile</filename> are supplied for
181 building the libraries under &unix;. Loading the
182 <filename>.asd</filename> files automatically invokes
183 <application>make</application> when necessary. So, manual
184 building of the helper libraries is not necessary on most
185 &unix; systems. However, the location of the &mysql; library
186 files and include files may need to adjusted in
187 <filename>db-mysql/Makefile</filename> on non-Debian
195 <title>Add &uffi; path</title>
197 Unzip or untar the &uffi; distribution which creates a directory
198 for the &uffi; files. Add that directory to &asdf;'s <varname>asdf:*central-registry*</varname>.
199 You can do that by pushing the pathname of the directory onto this variable.
200 The following example code assumes the &uffi; files reside in the
201 <filename>/usr/share/lisp/uffi/</filename>
204 (push #P"/usr/share/lisp/uffi/" asdf:*central-registry*)
209 <title>Add &md5; path</title>
211 If you plan to use the clsql-postgresql-socket interface, you
212 must load the md5 module. Unzip or untar the cl-md5
213 distribution, which creates a directory for the cl-md5 files.
214 Add that directory to &asdf;'s
215 <varname>asdf:*central-registry*</varname>. You can do that by
216 pushing the pathname of the directory onto this variable. The
217 following example code assumes the cl-md5 files reside in the
218 <filename>/usr/share/lisp/cl-md5/</filename> directory.
220 (push #P"/usr/share/lisp/cl-md5/" asdf:*central-registry*)
226 <title>Add &clsql; path and load module</title>
228 Unzip or untar the &clsql; distribution which creates a
229 directory for the &clsql; files. Add that directory to &asdf;'s
230 <varname>asdf:*central-registry*</varname>. You can do that by
231 pushing the pathname of the directory onto this variable. The
232 following example code assumes the &clsql; files reside in the
233 <filename>/usr/share/lisp/clsql/</filename> directory. You need
234 to load the <symbol>clsql</symbol> system.
237 (push #P"/usr/share/lisp/clsql/" asdf:*central-registry*)
238 (asdf:operate 'asdf:load-op 'clsql) ; main CLSQL package
244 <title>Run test suite (optional)</title>
246 The test suite can be executed using the &asdf;
247 <symbol>test-op</symbol> operator. If &clsql; has not been
248 loaded with <symbol>asdf:load-op</symbol>, the
249 <symbol>asdf:test-op</symbol> operator will automatically load
250 &clsql;. A configuration file named
251 <filename>.clsql-test.config</filename> must be created in
252 your home directory. There are instructures on the format of
253 that file in the <filename>tests/README</filename>. After
254 creating <filename>.clsql-test.config</filename>, you can run
255 the test suite with &asdf;:
257 (asdf:operate 'asdf:test-op 'clsql)