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
17 <application>CommonSQL</application>
23 <title>History</title>
25 &clsql; is written by Kevin M. Rosenberg in 2001 and was based
26 substantially on Pierre R. Mai's excellent &maisql; package. In
27 April 2004, Marcus Pearce ported the UncommonSQL to &clsql;
28 which provides a CommonSQL-compatible API for &clsql;. The main
29 changes from &maisql; are:
32 <para>port from the &cmucl; FFI to &uffi;.</para>
35 <para>Optimized loading of integer and floating-point fields.</para>
38 <para>new &acl; ODBC interface back-end.</para>
41 <para>compatibility layer for &cmucl; specific code.</para>
44 <para>much improved robustness for the &mysql; back-end
45 along with version 4 client library support.</para>
48 <para>improved system loading.</para>
51 <para>improved packages and symbol export.</para>
54 <para>transaction support.</para>
57 <para>UncommonSQL support.</para>
63 <sect1 id="prerequisites">
64 <title>Prerequisites</title>
69 &clsql; uses &asdf; to compile and load its components.
70 &asdf; is included in the <ulink
71 url="http://cclan.sourceforge.net"><citetitle>&cclan;</citetitle></ulink>
80 url="http://uffi.b9.com/"><citetitle>&uffi;</citetitle></ulink>
81 as a <emphasis>Foreign Function Interface</emphasis>
82 (<glossterm linkend="gloss-ffi">FFI</glossterm>) to support
83 multiple &cl; implementations.
89 <para>&clsql;'s postgresql-socket interface uses Pierre Mai's
90 <ulink url="ftp://clsql.b9.com/">md5</ulink>
95 <title>Supported Common Lisp Implementation</title>
97 The implementations that support &clsql; is governed by the supported
98 implementations of &uffi;. The following implementations are supported:
100 <itemizedlist mark="opencircle">
101 <listitem><para>&acl; v6.2 on Debian Linux, FreeBSD 4.5, and Microsoft Windows XP.</para></listitem>
102 <listitem><para>&lw; v4.3 on Debian Linux and Microsoft Windows XP.</para></listitem>
103 <listitem><para>&cmucl; 18e on Debian Linux, FreeBSD 4.5, and Solaris 2.8.</para></listitem>
104 <listitem><para>&sbcl; 0.8.5 on Debian Linux.</para></listitem>
105 <listitem><para>&scl; 1.1.1 on Debian Linux.</para></listitem>
106 <listitem><para>&openmcl; 0.14 on Debian Linux PowerPC.</para></listitem>
111 <title>Supported &sql; Implementation</title>
113 Currently, &clsql; supports the following databases:
115 <itemizedlist mark="opencircle">
116 <listitem><para>&mysql; v3.23.51 and v4.0.15.</para></listitem>
117 <listitem><para>&postgresql; v7.2 with both direct API and TCP
118 socket connections.</para></listitem>
119 <listitem><para>&sqlite;.</para></listitem>
120 <listitem><para>Allegro's ODBC interface (&aodbc;) using iODBC
121 ODBC manager.</para></listitem>
127 <sect1 id="installation">
128 <title>Installation</title>
131 <title>Ensure &asdf; is loaded</title>
133 Simply load the file <filename>asdf.lisp</filename>.
141 <title>Build &c; helper libraries</title>
142 <para>&clsql; uses functions that require 64-bit integer
143 parameters and return values. The &ffi; in most &clsql;
144 implementations do not support 64-bit integers. Thus, C helper
145 libraries are required to break these 64-bit integers into two compatible
146 32-bit integers. The helper libraries reside in the directories
147 <filename>uffi</filename> and <filename>db-mysql</filename>.
151 <title>&mswindows;</title>
153 Files named <filename>Makefile.msvc</filename> are supplied
154 for building the libraries under Microsoft Windows. Since
155 &mswindows; does not come with that compiler, compiled
156 <type>DLL</type> and <type>LIB</type> library files are
157 supplied with &clsql;.
162 <title>&unix;</title>
164 Files named <filename>Makefile</filename> are supplied for
165 building the libraries under &unix;. Loading the
166 <filename>.asd</filename> files automatically invokes
167 <application>make</application> when necessary. So, manual
168 building of the helper libraries is not necessary on most
169 &unix; systems. However, the location of the &mysql; library
170 files and include files may need to adjusted in
171 <filename>db-mysql/Makefile</filename> on non-Debian
179 <title>Load &uffi;</title>
181 Unzip or untar the &uffi; distribution which creates a directory
182 for the &uffi; files. Add that directory to &asdf;'s <varname>asdf:*central-registry*</varname>.
183 You can do that by pushing the pathname of the directory onto this variable.
184 The following example code assumes the &uffi; files reside in the
185 <filename>/usr/share/lisp/uffi/</filename>
188 (push #P"/usr/share/lisp/uffi/" asdf:*central-registry*)
189 (asdf:operate 'asdf:load-op :uffi)
194 <title>Load &md5; module</title>
196 If you plan to use the clsql-postgresql-socket interface, you
197 must load the md5 module. Unzip or untar the cl-md5
198 distribution, which creates a directory for the cl-md5 files.
199 Add that directory to &asdf;'s
200 <varname>asdf:*central-registry*</varname>. You can do that by
201 pushing the pathname of the directory onto this variable. The
202 following example code assumes the cl-md5 files reside in the
203 <filename>/usr/share/lisp/cl-md5/</filename> directory.
205 (push #P"/usr/share/lisp/cl-md5/" asdf:*central-registry*)
206 (asdf:operate 'asdf:load-op :md5)
212 <title>Load &clsql; modules</title>
214 Unzip or untar the &clsql; distribution which creates a
215 directory for the &clsql; files. Add that directory to &asdf;'s
216 <varname>asdf:*central-registry*</varname>. You can do that by
217 pushing the pathname of the directory onto this variable. The
218 following example code assumes the &clsql; files reside in the
219 <filename>/usr/share/lisp/clsql/</filename> directory. You need
220 to load, at a minimum, the main <symbol>clsql</symbol> system
221 and at least one interface system. The below example show loading
225 (push #P"/usr/share/lisp/clsql/" asdf:*central-registry*)
226 (asdf:operate 'asdf:load-op 'clsql-base) ; base CLSQL package
227 (asdf:operate 'asdf:load-op 'clsql-mysql) ; MySQL interface
228 (asdf:operate 'asdf:load-op 'clsql-postgresql) ; PostgreSQL interface
229 (asdf:operate 'asdf:load-op 'clsql-postgresql-socket) ; Socket PGSQL interface
230 (asdf:operate 'asdf:load-op 'clsql-aodbc) ; Allegro ODBC interface
231 (asdf:operate 'asdf:load-op 'clsql) ; main CLSQL package
237 <title>Run test suite</title>
239 After loading &clsql;, you can execute the test suite. A
240 configuration file named
241 <filename>.clsql-test.config</filename> must be created in
242 your home directory. There are instructures on the format of
243 that file in the <filename>tests/tests.lisp</filename> file in
244 the &clsql; source directory. After creating that file, you
245 can run the test suite with &asdf;:
247 (asdf:operate 'asdf:test-op 'clsql)