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 and based substantially
26 on Pierre R. Mai's excellent &maisql; package. Recently, the UncommonSQL
27 package has been ported and integrated with &clsql;. The main changes
31 <para>port from the &cmucl; FFI to &uffi;.</para>
34 <para>Optimized loading of integer and floating-point fields.</para>
37 <para>new &acl; ODBC interface back-end.</para>
40 <para>compatibility layer for &cmucl; specific code.</para>
43 <para>much improved robustness for the &mysql; back-end
44 along with version 4 client library support.</para>
47 <para>improved system loading.</para>
50 <para>improved packages and symbol export.</para>
53 <para>transaction support.</para>
56 <para>UncommonSQL support.</para>
62 <sect1 id="prerequisites">
63 <title>Prerequisites</title>
68 &clsql; uses &asdf; to compile and load its components.
69 &asdf; is included in the <ulink
70 url="http://cclan.sourceforge.net"><citetitle>&cclan;</citetitle></ulink>
79 url="http://uffi.b9.com/"><citetitle>&uffi;</citetitle></ulink>
80 as a <emphasis>Foreign Function Interface</emphasis>
81 (<glossterm linkend="gloss-ffi">FFI</glossterm>) to support
82 multiple &cl; implementations.
88 <para>&clsql;'s postgresql-socket interface uses Pierre Mai's
89 <ulink url="ftp://clsql.b9.com/">md5</ulink>
94 <title>Supported Common Lisp Implementation</title>
96 The implementations that support &clsql; is governed by the supported
97 implementations of &uffi;. The following implementations are supported:
99 <itemizedlist mark="opencircle">
100 <listitem><para>&acl; v6.2 on Debian Linux, FreeBSD 4.5, and Microsoft Windows XP.</para></listitem>
101 <listitem><para>&lw; v4.3 on Debian Linux and Microsoft Windows XP.</para></listitem>
102 <listitem><para>&cmucl; 18e on Debian Linux, FreeBSD 4.5, and Solaris 2.8.</para></listitem>
103 <listitem><para>&sbcl; 0.8.5 on Debian Linux.</para></listitem>
104 <listitem><para>&scl; 1.1.1 on Debian Linux.</para></listitem>
105 <listitem><para>&openmcl; 0.14 on Debian Linux PowerPC.</para></listitem>
110 <title>Supported &sql; Implementation</title>
112 Currently, &clsql; supports the following databases:
114 <itemizedlist mark="opencircle">
115 <listitem><para>&mysql; v3.23.51 and v4.0.15.</para></listitem>
116 <listitem><para>&postgresql; v7.2 with both direct API and TCP
117 socket connections.</para></listitem>
118 <listitem><para>&sqlite;.</para></listitem>
119 <listitem><para>Allegro's ODBC interface (&aodbc;) using iODBC
120 ODBC manager.</para></listitem>
126 <sect1 id="installation">
127 <title>Installation</title>
130 <title>Ensure &asdf; is loaded</title>
132 Simply load the file <filename>asdf.lisp</filename>.
140 <title>Build &c; helper libraries</title>
141 <para>&clsql; uses functions that require 64-bit integer
142 parameters and return values. The &ffi; in most &clsql;
143 implementations do not support 64-bit integers. Thus, C helper
144 libraries are required to break these 64-bit integers into two compatible
145 32-bit integers. The helper libraries reside in the directories
146 <filename>uffi</filename> and <filename>db-mysql</filename>.
150 <title>&mswindows;</title>
152 Files named <filename>Makefile.msvc</filename> are supplied
153 for building the libraries under Microsoft Windows. Since
154 &mswindows; does not come with that compiler, compiled
155 <type>DLL</type> and <type>LIB</type> library files are
156 supplied with &clsql;.
161 <title>&unix;</title>
163 Files named <filename>Makefile</filename> are supplied for
164 building the libraries under &unix;. Loading the
165 <filename>.asd</filename> files automatically invokes
166 <application>make</application> when necessary. So, manual
167 building of the helper libraries is not necessary on most
168 &unix; systems. However, the location of the &mysql; library
169 files and include files may need to adjusted in
170 <filename>db-mysql/Makefile</filename> on non-Debian
178 <title>Load &uffi;</title>
180 Unzip or untar the &uffi; distribution which creates a directory
181 for the &uffi; files. Add that directory to &asdf;'s <varname>asdf:*central-registry*</varname>.
182 You can do that by pushing the pathname of the directory onto this variable.
183 The following example code assumes the &uffi; files reside in the
184 <filename>/usr/share/lisp/uffi/</filename>
187 (push #P"/usr/share/lisp/uffi/" asdf:*central-registry*)
188 (asdf:operate 'asdf:load-op :uffi)
193 <title>Load &md5; module</title>
195 If you plan to use the clsql-postgresql-socket interface, you
196 must load the md5 module. Unzip or untar the cl-md5
197 distribution, which creates a directory for the cl-md5 files.
198 Add that directory to &asdf;'s
199 <varname>asdf:*central-registry*</varname>. You can do that by
200 pushing the pathname of the directory onto this variable. The
201 following example code assumes the cl-md5 files reside in the
202 <filename>/usr/share/lisp/cl-md5/</filename> directory.
204 (push #P"/usr/share/lisp/cl-md5/" asdf:*central-registry*)
205 (asdf:operate 'asdf:load-op :md5)
211 <title>Load &clsql; modules</title>
213 Unzip or untar the &clsql; distribution which creates a
214 directory for the &clsql; files. 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 &clsql; files reside in the
218 <filename>/usr/share/lisp/clsql/</filename> directory. You need
219 to load, at a minimum, the main <symbol>clsql</symbol> system
220 and at least one interface system. The below example show loading
224 (push #P"/usr/share/lisp/clsql/" asdf:*central-registry*)
225 (asdf:operate 'asdf:load-op 'clsql-base) ; base CLSQL package
226 (asdf:operate 'asdf:load-op 'clsql-mysql) ; MySQL interface
227 (asdf:operate 'asdf:load-op 'clsql-postgresql) ; PostgreSQL interface
228 (asdf:operate 'asdf:load-op 'clsql-postgresql-socket) ; Socket PGSQL interface
229 (asdf:operate 'asdf:load-op 'clsql-aodbc) ; Allegro ODBC interface
230 (asdf:operate 'asdf:load-op 'clsql) ; main CLSQL package
236 <title>Run test suite</title>
238 After loading &clsql;, you can execute the test suite. A
239 configuration file named
240 <filename>.clsql-test.config</filename> must be created in
241 your home directory. There are instructures on the format of
242 that file in the <filename>tests/tests.lisp</filename> file in
243 the &clsql; source directory. After creating that file, you
244 can run the test suite with &asdf;:
246 (asdf:operate 'asdf:test-op 'clsql)