r10147: 09 Nov 2004 Kevin Rosenberg <kevin@rosenberg.net>
authorKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 9 Nov 2004 18:04:31 +0000 (18:04 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 9 Nov 2004 18:04:31 +0000 (18:04 +0000)
        * Version 3.1.0 released: New SQLite3 backend by Aurelio Bignoli
        * doc/appendix.xml: Document SQLITE3 backend, patch by Aurelio Bignoli

ChangeLog
db-sqlite3/init-func-sample/Makefile [deleted file]
db-sqlite3/init-func-sample/example.lisp [deleted file]
db-sqlite3/init-func-sample/iso-8859-15-coll.c [deleted file]
debian/changelog
doc/appendix.xml
doc/entities.inc
doc/intro.xml
examples/sqlite3/init-func/Makefile [new file with mode: 0644]
examples/sqlite3/init-func/example.lisp [new file with mode: 0644]
examples/sqlite3/init-func/iso-8859-15-coll.c [new file with mode: 0644]

index edf6b8a21077ea7f9cb8a6fddb6b5ffa2388c894..bc897d25fe8eb0e560f92ce84305d910ad044a28 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,10 @@
 09 Nov 2004 Kevin Rosenberg <kevin@rosenberg.net>
-       * sql/operations.lisp: Add lower and upper SQL
-       functions from Daniel Lowe.
+       * Version 3.1.0 released: New SQLite3 backend by Aurelio Bignoli
+       * doc/appendix.xml: Document SQLITE3 backend, patch by Aurelio Bignoli
+       * sql/operations.lisp: Add lower and upper SQL functions [Daniel Lowe].
        
 08 Nov 2004 Kevin Rosenberg <kevin@rosenberg.net>
-       * sql/expressions.lisp: Fix slot name [thanks to
-       Daniel Lowe]
+       * sql/expressions.lisp: Fix slot name [thanks to Daniel Lowe]
 
 31 Oct 2004 Kevin Rosenberg <kevin@rosenberg.net>
        * clsql-sqlite3, db-sqlite3/*: NEW BACKEND
diff --git a/db-sqlite3/init-func-sample/Makefile b/db-sqlite3/init-func-sample/Makefile
deleted file mode 100644 (file)
index de1cf29..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-# FILE IDENTIFICATION
-#
-#  Name:         Makefile
-#  Purpose:      Makefile for SQLite 3 init function example.
-#  Programer:    Aurelio Bignoli
-#  Date Started: Oct 2004
-#
-#  CVS Id:   $Id$
-#
-# This file, part of CLSQL, is Copyright (c) 2004 by Aurelio Bignoli
-#
-# CLSQL users are granted the rights to distribute and use this software
-# as governed by the terms of the Lisp Lesser GNU Public License
-# (http://opensource.franz.com/preamble.html), also known as the LLGPL.
-
-sqlite3-utils.so:      iso-8859-15-coll.c Makefile
-       gcc -c -fPIC iso-8859-15-coll.c -o iso-8859-15-coll.o
-       gcc -shared iso-8859-15-coll.o -o sqlite3-utils.so -l sqlite3
-
diff --git a/db-sqlite3/init-func-sample/example.lisp b/db-sqlite3/init-func-sample/example.lisp
deleted file mode 100644 (file)
index 1a81645..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
-;;;; *************************************************************************
-;;;; FILE IDENTIFICATION
-;;;;
-;;;; Name:     example.lisp
-;;;; Purpose:  Sample code for SQLite 3 initialization functions
-;;;; Authors:  Aurelio Bignoli
-;;;; Created:  Oct 2004
-;;;;
-;;;; $Id$
-;;;;
-;;;; This file, part of CLSQL, is Copyright (c) 2004 by Aurelio Bignoli
-;;;;
-;;;; CLSQL users are granted the rights to distribute and use this software
-;;;; as governed by the terms of the Lisp Lesser GNU Public License
-;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
-;;;; *************************************************************************
-
-;;;; Load CLSQL.
-(asdf:oos 'asdf:load-op :clsql-sqlite3)
-
-;;;; Load sqlite3-utils.so library. See Makefile for library creation.
-(unless (uffi:load-foreign-library "/usr/lib/clsql/sqlite3-utils.so"
-                                  :module "sqlite3-utils"
-                                  :supporting-libraries '("c"))
-  (error "Unable to load foreign library"))
-
-;;;; Define the foreign function to be used as init function.
-(uffi:def-function 
-    ("create_iso_8859_15_ci_collation" create-coll)
-    ((db sqlite3:sqlite3-db))
-  :returning :int
-  :module "sqlite3-utils")
-
-;;;; Create the DB using create-coll as init function.
-(defparameter db-name "init-func-test.db")
-(clsql:destroy-database (list db-name) :database-type :sqlite3)
-(clsql:connect (list db-name #'create-coll) :database-type :sqlite3)
-
-;;;; Create a table. Field f2 uses the newly defined collating
-;;;; sequence.
-(clsql:execute-command 
- "CREATE TABLE t1 (f1 CHAR(1), f2 CHAR(1) COLLATE ISO_8859_15_CI)")
-
-;;;; Populate the table.
-(clsql:execute-command "INSERT INTO t1 VALUES ('à', 'à')")
-(clsql:execute-command "INSERT INTO t1 VALUES ('a', 'a')")
-(clsql:execute-command "INSERT INTO t1 VALUES ('A', 'A')")
-(clsql:execute-command "INSERT INTO t1 VALUES ('é', 'é')")
-(clsql:execute-command "INSERT INTO t1 VALUES ('e', 'e')")
-(clsql:execute-command "INSERT INTO t1 VALUES ('E', 'E')")
-(clsql:execute-command "INSERT INTO t1 VALUES ('ì', 'ì')")
-(clsql:execute-command "INSERT INTO t1 VALUES ('i', 'i')")
-(clsql:execute-command "INSERT INTO t1 VALUES ('I', 'I')")
-(clsql:execute-command "INSERT INTO t1 VALUES ('ò', 'ò')")
-(clsql:execute-command "INSERT INTO t1 VALUES ('o', 'o')")
-(clsql:execute-command "INSERT INTO t1 VALUES ('O', 'O')")
-(clsql:execute-command "INSERT INTO t1 VALUES ('ù', 'ù')")
-(clsql:execute-command "INSERT INTO t1 VALUES ('u', 'u')")
-(clsql:execute-command "INSERT INTO t1 VALUES ('U', 'U')")
-
-;;;; Perform some SELECTs.
-(format t "~&SELECT * FROM t1 ==> ~A~%"(clsql:query "SELECT * FROM t1"))
-(format t "~&SELECT * FROM t1 ORDER BY f1 ==> ~A~%" 
-       (clsql:query "SELECT * FROM t1 ORDER BY f1"))
-(format t "~&SELECT * FROM t1 ORDER BY f2 ==> ~A~%" 
-       (clsql:query "SELECT * FROM t1 ORDER BY f2"))
-
-;;;; Disconnect from database.
-(clsql:disconnect)
\ No newline at end of file
diff --git a/db-sqlite3/init-func-sample/iso-8859-15-coll.c b/db-sqlite3/init-func-sample/iso-8859-15-coll.c
deleted file mode 100644 (file)
index 0e7fea1..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
- * FILE IDENTIFICATION
- *
- *   Name:          iso-8859-15-coll.c
- *   Purpose:       SQLite 3 initialization function for  
- *                  ISO-8859-15 collating sequence.
- *   Programmer:    Aurelio Bignoli
- *   Date Started:  Oct 2004
- *
- * $Id$
- *
- * This file, part of CLSQL, is Copyright (c) 2004 by Aurelio Bignoli
- *
- * CLSQL users are granted the rights to distribute and use this software
- * as governed by the terms of the Lisp Lesser GNU Public License
- * (http://opensource.franz.com/preamble.html), also known as the LLGPL.
- ***************************************************************************/
-
-
-/* Collating sequence name. CI = Case Insensitive */
-#define ISO_8859_15_CI_NAME "ISO_8859_15_CI"
-
-/* Conversion table. */
-const unsigned char iso_8859_15_ci [] = {
-  /* 0 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 
-  /* 1 */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 
-  /* 2 */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 
-  /* 3 */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 
-  /* 4 */ 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 
-  /* 5 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 
-  /* 6 */ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 
-  /* 7 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 
-  /* 8 */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x73, 0x8B, 0x6F, 0x8D, 0x7A, 0x79, 
-  /* 9 */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x73, 0x9B, 0x6F, 0x9D, 0x7A, 0x79, 
-  /* A */ 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0x73, 0xA7, 0x73, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 
-  /* B */ 0xB0, 0xB1, 0xB2, 0xB3, 0x7A, 0xB5, 0xB6, 0xB7, 0x7A, 0xB9, 0xBA, 0xBB, 0x6F, 0xBD, 0x79, 0xBF, 
-  /* C */ 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x65, 0x63, 0x65, 0x65, 0x65, 0x65, 0x69, 0x69, 0x69, 0x69, 
-  /* D */ 0x64, 0x6E, 0x6F, 0x6F, 0x6F, 0x6F, 0x6F, 0xD7, 0x6F, 0x75, 0x75, 0x75, 0x75, 0x79, 0xDE, 0x73, 
-  /* E */ 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x65, 0x63, 0x65, 0x65, 0x65, 0x65, 0x69, 0x69, 0x69, 0x69,
-  /* F */ 0x64, 0x6E, 0x6F, 0x6F, 0x6F, 0x6F, 0x6F, 0xF7, 0x6F, 0x75, 0x75, 0x75, 0x75, 0x79, 0xFE, 0x73
-};
-
-/*
- * A modified version of sqlite3StrNICmp in sqlite/src/util.c
- */
-int iso_8859_15_ci_StrCmp(const char *zLeft, const char *zRight, int N){
-  register unsigned char *a, *b;
-  a = (unsigned char *)zLeft;
-  b = (unsigned char *)zRight;
-  while( N-- > 0 && *a!=0 && iso_8859_15_ci[*a]==iso_8859_15_ci[*b]){ a++; b++; }
-  return N<0 ? 0 : iso_8859_15_ci[*a] - iso_8859_15_ci[*b];
-}
-
-/*
- * A modified version of nocaseCollatinFunc in sqlite/src/main.c.
- */
-int iso_8859_15_ci_CollatingFunc(
-  void *NotUsed,
-  int nKey1, const void *pKey1,
-  int nKey2, const void *pKey2
-){
-  int r = iso_8859_15_ci_StrCmp(
-      (const char *)pKey1, (const char *)pKey2, (nKey1<nKey2)?nKey1:nKey2);
-  if( 0==r ){
-    r = nKey1-nKey2;
-  }
-  return r;
-}
-/* 
- * Set the ISO_8859_15_CI collating sequence for a db.
- */
-#include "sqlite3.h"
-
-int create_iso_8859_15_ci_collation (sqlite3 *db)
-{
-  return sqlite3_create_collation (db, ISO_8859_15_CI_NAME, SQLITE_UTF8, 0,
-                                  iso_8859_15_ci_CollatingFunc);
-}
index 30b11d569265e27900e0b82d43c63fccda0b352e..e4cc865083d8db160739f450ac5f15856c9a2c36 100644 (file)
@@ -1,3 +1,9 @@
+cl-sql (3.1.0-1) unstable; urgency=low
+
+  * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Tue,  9 Nov 2004 11:04:04 -0700
+
 cl-sql (3.0.11-1) unstable; urgency=low
 
   * New usptream
index d6a50d9cf8aa5b4164e0aef5243564a5ea7899c5..a37c582a9459f1f2e012c45df0ac0f2d07a39f0f 100644 (file)
       </sect2>
     </sect1>
 
+    <sect1 id="sqlite3">
+      <title>&sqlite3;</title>
+      <sect2>
+       <title>Libraries</title> <para>The &sqlite3; back-end requires
+       the &sqlite3; shared library file. Its default file name is
+       <filename>/usr/lib/libsqlite3.so</filename>.</para>
+      </sect2>
+      <sect2>
+       <title>Initialization</title>
+       <para>
+         Use 
+         <screen>
+(asdf:operate 'asdf:load-op 'clsql-sqlite3)
+         </screen>
+         to load the &sqlite3; back-end.  The database type for the &sqlite3;
+         back-end is <symbol>:sqlite3</symbol>.
+       </para>
+      </sect2>
+      <sect2>
+       <title>Connection Specification</title>
+       <sect3>
+         <title>Syntax of connection-spec</title>
+         <synopsis>(<replaceable>filename</replaceable> &amp;optional <replaceable>init-function</replaceable>)</synopsis>
+       </sect3>
+       <sect3>
+         <title>Description of connection-spec</title>
+         <variablelist>
+           <varlistentry>
+             <term><parameter>filename</parameter></term>
+             <listitem>
+               <para>String representing the filename of the &sqlite3;
+               database file.</para>
+             </listitem>
+           </varlistentry>
+           <varlistentry>
+             <term><parameter>init-function</parameter></term>
+             <listitem>
+               <para>
+                A function designator.
+                <replaceable>init-function</replaceable> takes a
+                single argument of type
+                <type>sqlite3:sqlite3-db</type>, a foreign pointer to
+                the C descriptor of the newly opened database.
+                <replaceable>init-function</replaceable> is called by
+                the back-end immediately after &sqlite3;
+                <function>sqlite3_open</function> library function,
+                and can be used to perform optional database
+                initializations by calling foreign functions in the
+                &sqlite3; library.
+               </para>
+               <para>
+                An example of an initialization function which
+                defines a new collating sequence for text columns is
+                provided in
+                <filename>./examples/sqlite3/init-func/</filename>.
+               </para>
+             </listitem>
+           </varlistentry>
+         </variablelist>
+       </sect3>
+      </sect2>
+      <sect2><title>Notes</title>
+      <sect3><title>Connection</title> 
+      <itemizedlist mark='opencircle'>
+        <listitem>
+          <para>
+            Passing <parameter>filename</parameter> a value of
+            <filename>:memory:</filename> will create a database in
+            physical memory instead of using a file on disk.
+          </para>
+        </listitem>        
+        <listitem>
+          <para>
+            Some operations will be many times faster if database
+            integrity checking is disabled by setting the SYNCHRONOUS
+            flag to OFF (see the SQLITE manual for details).
+          </para>
+        </listitem>
+      </itemizedlist>
+      </sect3>
+      <sect3><title>FDDL</title> 
+      <itemizedlist mark='opencircle'>
+        <listitem>
+          <para>
+            The <symbol>:owner</symbol> keyword argument to the FDDL functions 
+            for listing and testing for database objects is ignored. 
+          </para>
+        </listitem>        
+        <listitem>
+          <para>
+            The <symbol>:column-list</symbol> keyword argument to
+            <link
+            linkend="create-view"><function>create-view</function></link>
+            is not supported by &sqlite3;. 
+          </para>
+        </listitem>
+      </itemizedlist>
+      </sect3>
+      <sect3><title>Symbolic SQL Syntax</title>
+      <itemizedlist mark='opencircle'>
+        <listitem>
+          <para>
+            &sqlite3; does not support the <function>all</function>,
+            <function>some</function>, <function>any</function> and
+            <function>exists</function> subquery operations. 
+          </para>
+        </listitem>
+      </itemizedlist>
+      </sect3>
+      </sect2>
+    </sect1>
+
   <sect1 id="oracle">
     <title>Oracle</title>
     <sect2>
index 496d95617368fbb0b370b1a3ff25aaac0cca1069..25ef73ecdec4a33980fa728d7f9701f97e9695a5 100644 (file)
@@ -10,7 +10,8 @@
 <!ENTITY commonsql "<application>CommonSQL</application>">
 <!ENTITY mysql "<application>MySQL</application>">
 <!ENTITY postgresql "<application>PostgreSQL</application>">
-<!ENTITY sqlite "<application>SQLite</application>">
+<!ENTITY sqlite "<application>SQLite version 2</application>">
+<!ENTITY sqlite3 "<application>SQLite version 3</application>">
 <!ENTITY oracle "<application>Oracle</application>">
 <!ENTITY odbc "<application>ODBC</application>">
 <!ENTITY aodbc "<application>AODBC</application>">
index ea59c4b6f4091e9903eb114a30bc095af56625b9..5f1ff000ff3d139bf75707438b6785a517b598c6 100644 (file)
@@ -42,7 +42,8 @@
          <para>Optimized loading of integer and floating-point fields.</para>
        </listitem>
        <listitem>
-         <para>Additional database backends: &odbc;, &aodbc;, and &sqlite;.</para>
+         <para>Additional database backends: &odbc;, &aodbc;, &sqlite;
+         and &sqlite3;.</para>
        </listitem>
        <listitem>
          <para>A compatibility layer for &cmucl; specific code.</para>
        <listitem><para>&postgresql; v7.4 with both direct API and TCP
        socket connections.</para></listitem>
        <listitem><para>&sqlite;.</para></listitem>
+       <listitem><para>&sqlite3;.</para></listitem>
        <listitem><para>Direct &odbc; interface.</para></listitem>
         <listitem><para>&oracle; OCI.</para></listitem>
        <listitem><para>Allegro's DB interface (&aodbc;).</para></listitem>
diff --git a/examples/sqlite3/init-func/Makefile b/examples/sqlite3/init-func/Makefile
new file mode 100644 (file)
index 0000000..de1cf29
--- /dev/null
@@ -0,0 +1,19 @@
+# FILE IDENTIFICATION
+#
+#  Name:         Makefile
+#  Purpose:      Makefile for SQLite 3 init function example.
+#  Programer:    Aurelio Bignoli
+#  Date Started: Oct 2004
+#
+#  CVS Id:   $Id$
+#
+# This file, part of CLSQL, is Copyright (c) 2004 by Aurelio Bignoli
+#
+# CLSQL users are granted the rights to distribute and use this software
+# as governed by the terms of the Lisp Lesser GNU Public License
+# (http://opensource.franz.com/preamble.html), also known as the LLGPL.
+
+sqlite3-utils.so:      iso-8859-15-coll.c Makefile
+       gcc -c -fPIC iso-8859-15-coll.c -o iso-8859-15-coll.o
+       gcc -shared iso-8859-15-coll.o -o sqlite3-utils.so -l sqlite3
+
diff --git a/examples/sqlite3/init-func/example.lisp b/examples/sqlite3/init-func/example.lisp
new file mode 100644 (file)
index 0000000..1a81645
--- /dev/null
@@ -0,0 +1,70 @@
+;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name:     example.lisp
+;;;; Purpose:  Sample code for SQLite 3 initialization functions
+;;;; Authors:  Aurelio Bignoli
+;;;; Created:  Oct 2004
+;;;;
+;;;; $Id$
+;;;;
+;;;; This file, part of CLSQL, is Copyright (c) 2004 by Aurelio Bignoli
+;;;;
+;;;; CLSQL users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the Lisp Lesser GNU Public License
+;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
+;;;; *************************************************************************
+
+;;;; Load CLSQL.
+(asdf:oos 'asdf:load-op :clsql-sqlite3)
+
+;;;; Load sqlite3-utils.so library. See Makefile for library creation.
+(unless (uffi:load-foreign-library "/usr/lib/clsql/sqlite3-utils.so"
+                                  :module "sqlite3-utils"
+                                  :supporting-libraries '("c"))
+  (error "Unable to load foreign library"))
+
+;;;; Define the foreign function to be used as init function.
+(uffi:def-function 
+    ("create_iso_8859_15_ci_collation" create-coll)
+    ((db sqlite3:sqlite3-db))
+  :returning :int
+  :module "sqlite3-utils")
+
+;;;; Create the DB using create-coll as init function.
+(defparameter db-name "init-func-test.db")
+(clsql:destroy-database (list db-name) :database-type :sqlite3)
+(clsql:connect (list db-name #'create-coll) :database-type :sqlite3)
+
+;;;; Create a table. Field f2 uses the newly defined collating
+;;;; sequence.
+(clsql:execute-command 
+ "CREATE TABLE t1 (f1 CHAR(1), f2 CHAR(1) COLLATE ISO_8859_15_CI)")
+
+;;;; Populate the table.
+(clsql:execute-command "INSERT INTO t1 VALUES ('à', 'à')")
+(clsql:execute-command "INSERT INTO t1 VALUES ('a', 'a')")
+(clsql:execute-command "INSERT INTO t1 VALUES ('A', 'A')")
+(clsql:execute-command "INSERT INTO t1 VALUES ('é', 'é')")
+(clsql:execute-command "INSERT INTO t1 VALUES ('e', 'e')")
+(clsql:execute-command "INSERT INTO t1 VALUES ('E', 'E')")
+(clsql:execute-command "INSERT INTO t1 VALUES ('ì', 'ì')")
+(clsql:execute-command "INSERT INTO t1 VALUES ('i', 'i')")
+(clsql:execute-command "INSERT INTO t1 VALUES ('I', 'I')")
+(clsql:execute-command "INSERT INTO t1 VALUES ('ò', 'ò')")
+(clsql:execute-command "INSERT INTO t1 VALUES ('o', 'o')")
+(clsql:execute-command "INSERT INTO t1 VALUES ('O', 'O')")
+(clsql:execute-command "INSERT INTO t1 VALUES ('ù', 'ù')")
+(clsql:execute-command "INSERT INTO t1 VALUES ('u', 'u')")
+(clsql:execute-command "INSERT INTO t1 VALUES ('U', 'U')")
+
+;;;; Perform some SELECTs.
+(format t "~&SELECT * FROM t1 ==> ~A~%"(clsql:query "SELECT * FROM t1"))
+(format t "~&SELECT * FROM t1 ORDER BY f1 ==> ~A~%" 
+       (clsql:query "SELECT * FROM t1 ORDER BY f1"))
+(format t "~&SELECT * FROM t1 ORDER BY f2 ==> ~A~%" 
+       (clsql:query "SELECT * FROM t1 ORDER BY f2"))
+
+;;;; Disconnect from database.
+(clsql:disconnect)
\ No newline at end of file
diff --git a/examples/sqlite3/init-func/iso-8859-15-coll.c b/examples/sqlite3/init-func/iso-8859-15-coll.c
new file mode 100644 (file)
index 0000000..0e7fea1
--- /dev/null
@@ -0,0 +1,79 @@
+/****************************************************************************
+ * FILE IDENTIFICATION
+ *
+ *   Name:          iso-8859-15-coll.c
+ *   Purpose:       SQLite 3 initialization function for  
+ *                  ISO-8859-15 collating sequence.
+ *   Programmer:    Aurelio Bignoli
+ *   Date Started:  Oct 2004
+ *
+ * $Id$
+ *
+ * This file, part of CLSQL, is Copyright (c) 2004 by Aurelio Bignoli
+ *
+ * CLSQL users are granted the rights to distribute and use this software
+ * as governed by the terms of the Lisp Lesser GNU Public License
+ * (http://opensource.franz.com/preamble.html), also known as the LLGPL.
+ ***************************************************************************/
+
+
+/* Collating sequence name. CI = Case Insensitive */
+#define ISO_8859_15_CI_NAME "ISO_8859_15_CI"
+
+/* Conversion table. */
+const unsigned char iso_8859_15_ci [] = {
+  /* 0 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 
+  /* 1 */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 
+  /* 2 */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 
+  /* 3 */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 
+  /* 4 */ 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 
+  /* 5 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 
+  /* 6 */ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 
+  /* 7 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 
+  /* 8 */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x73, 0x8B, 0x6F, 0x8D, 0x7A, 0x79, 
+  /* 9 */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x73, 0x9B, 0x6F, 0x9D, 0x7A, 0x79, 
+  /* A */ 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0x73, 0xA7, 0x73, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 
+  /* B */ 0xB0, 0xB1, 0xB2, 0xB3, 0x7A, 0xB5, 0xB6, 0xB7, 0x7A, 0xB9, 0xBA, 0xBB, 0x6F, 0xBD, 0x79, 0xBF, 
+  /* C */ 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x65, 0x63, 0x65, 0x65, 0x65, 0x65, 0x69, 0x69, 0x69, 0x69, 
+  /* D */ 0x64, 0x6E, 0x6F, 0x6F, 0x6F, 0x6F, 0x6F, 0xD7, 0x6F, 0x75, 0x75, 0x75, 0x75, 0x79, 0xDE, 0x73, 
+  /* E */ 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x65, 0x63, 0x65, 0x65, 0x65, 0x65, 0x69, 0x69, 0x69, 0x69,
+  /* F */ 0x64, 0x6E, 0x6F, 0x6F, 0x6F, 0x6F, 0x6F, 0xF7, 0x6F, 0x75, 0x75, 0x75, 0x75, 0x79, 0xFE, 0x73
+};
+
+/*
+ * A modified version of sqlite3StrNICmp in sqlite/src/util.c
+ */
+int iso_8859_15_ci_StrCmp(const char *zLeft, const char *zRight, int N){
+  register unsigned char *a, *b;
+  a = (unsigned char *)zLeft;
+  b = (unsigned char *)zRight;
+  while( N-- > 0 && *a!=0 && iso_8859_15_ci[*a]==iso_8859_15_ci[*b]){ a++; b++; }
+  return N<0 ? 0 : iso_8859_15_ci[*a] - iso_8859_15_ci[*b];
+}
+
+/*
+ * A modified version of nocaseCollatinFunc in sqlite/src/main.c.
+ */
+int iso_8859_15_ci_CollatingFunc(
+  void *NotUsed,
+  int nKey1, const void *pKey1,
+  int nKey2, const void *pKey2
+){
+  int r = iso_8859_15_ci_StrCmp(
+      (const char *)pKey1, (const char *)pKey2, (nKey1<nKey2)?nKey1:nKey2);
+  if( 0==r ){
+    r = nKey1-nKey2;
+  }
+  return r;
+}
+/* 
+ * Set the ISO_8859_15_CI collating sequence for a db.
+ */
+#include "sqlite3.h"
+
+int create_iso_8859_15_ci_collation (sqlite3 *db)
+{
+  return sqlite3_create_collation (db, ISO_8859_15_CI_NAME, SQLITE_UTF8, 0,
+                                  iso_8859_15_ci_CollatingFunc);
+}