Merge branch 'development'
authorNathan Bird <nathan@acceleration.net>
Thu, 11 Feb 2010 19:26:04 +0000 (14:26 -0500)
committerNathan Bird <nathan@acceleration.net>
Thu, 11 Feb 2010 19:26:04 +0000 (14:26 -0500)
12 files changed:
ChangeLog
Makefile.common
db-mysql/Makefile
db-mysql/mysql-sql.lisp
debian/changelog
sql/base-classes.lisp
sql/database.lisp
sql/generic-odbc.lisp
sql/generics.lisp
sql/package.lisp
tests/test-ooddl.lisp
uffi/Makefile

index 0c26481df018b09ed0c08a999215838e17ae9b08..4d8ede9d759cff9ac089352b34f52b971dcdb6d4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2010-02-20  Kevin Rosenberg <kevin@rosenberg.net>
+       * Makefile.common, uffi/Makefile, db-mysql/Makefile:
+       Better support OS X Snow Leopard by building universal
+       (x86_64,i386) dylib bundles
+
+2010-02-08  Kevin Rosenberg <kevin@rosenberg.net>
+       * Version 5.0.2
+       * sql/database.lisp: Fix missing slot-accessor 
+       (Thanks to Stelian Ionescu)
+       * sql/generics.lisp: Add missing keyword to defgeneric
+       (Thanks to Stelian Ionescu)
+
+2010-02-07  Kevin Rosenberg <kevin@rosenberg.net>
+       * Version 5.0.1
+       * sql/{base-classes,database}.lisp: Add encoding slot for 
+       non-ASCII strings.
+       * db-mysql/mysql-sql.lisp: Use UFFI:FOREIGN-ENCODED-OCTET-COUNT.
+       Requires UFFI version 1.8.2 or above.
+
 2010-02-06  Kevin Rosenberg <kevin@rosenberg.net>
        * Version 5.0.0: First release of CLSQL to formally and
        consistently support non-ASCII strings with encoding of external
index dd73322efe4695cd4d2e3d69b05109fcf93a215c..30be60ead65f4a9f89626ccd1e2ff1a4ef7a2e80 100644 (file)
@@ -1,9 +1,11 @@
 UNAME=$(shell uname)
 UNAME_A=$(shell uname -a)
+DARWIN_LIBC=$(shell file /usr/lib/libc.dylib)
 
 OS_AIX=$(shell expr "$(UNAME)" : '.*AIX.*')
 OS_SUNOS=$(shell expr "$(UNAME)" : '.*SunOS.*')
 OS_DARWIN=$(shell expr "$(UNAME)" : '.*Darwin.*')
+OS_DARWIN64=$(shell expr "$(DARWIN_LIBC)" : '.*x86_64.*')
 OS_CYGWIN=$(shell expr "$(UNAME)" : '.*CYGWIN.*')
 OS_LINUX=$(shell expr "$(UNAME)" : '.*Linux.*')
 OS_LINUX64=$(shell expr "$(UNAME_A)" : '.*Linux.*x86_64.*')
index f85ecb02c2724b5a7ae00a6a1e00bc5a0182fbc4..9e2e2913cfcd0a78ab0c32670ae0b8a11d8f7fb2 100644 (file)
@@ -21,7 +21,7 @@ source=$(base).c
 object=$(base).o
 shared_lib=$(base).so
 shared64_lib=$(base)64.so
-
+dylib=$(base).dylib
 
 .PHONY: all
 all: $(shared_lib)
@@ -46,10 +46,13 @@ else
        cc $(CFLAGS) -KPIC -c $(source) -o $(object)
        cc -G $(object) $(LDFLAGS) -o $(shared_lib)
   else
+    ifneq ($(OS_DARWIN64),0)
+       cc $(CFLAGS) -arch x86_64 -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress $(source) -o $(dylib)
+       cc -arch x86_64 -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress /usr/lib/libz.dylib -o z.dylib
+    else
     ifneq ($(OS_DARWIN),0)
-       cc $(CFLAGS) -dynamic -c $(source) -o $(object)
-       ld -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress -o $(base).dylib $(object)
-       ld -bundle /usr/lib/bundle1.o $(LDFLAGS) -flat_namespace -undefined suppress /usr/lib/libz.dylib -o z.dylib
+       cc $(CFLAGS)  -arch x86_64 -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress $(source) -o $(dylib)
+       cc -arch x86_64 -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress /usr/lib/libz.dylib -o z.dylib
     else
       ifneq ($(OS_CYGWIN),0)
        gcc $(CFLAGS) -DWIN32 -c $(source) -o $(object)
@@ -69,9 +72,10 @@ else
       endif
     endif
   endif
+endif
 endif
        rm -f $(object)
 
 .PHONY: distclean
 distclean: clean
-       rm -f $(base).dylib $(base).dylib $(base).so $(base).o
+       @rm -f $(dylib) $(shared_lib) $(shared64_lib) $(object) z.dylib
index 3e302227ea6938f82124216edb4a0cfdc2ee7cb1..db98e6361ee79986d450e02bd47a4400f9c19328 100644 (file)
                                            :mysql-ptr mysql-ptr))
                            (cmd "SET SESSION sql_mode='ANSI'"))
                       (uffi:with-cstring (cmd-cs cmd)
-                        (if (zerop (mysql-real-query mysql-ptr cmd-cs (uffi:foreign-encoded-octet-count cmd)))
+                        (if (zerop (mysql-real-query mysql-ptr cmd-cs (uffi:foreign-encoded-octet-count
+                                                                       cmd :encoding (encoding db))))
                             db
                             (progn
                               (warn "Error setting ANSI mode for MySQL.")
     (let ((mysql-ptr (database-mysql-ptr database)))
       (declare (type mysql-mysql-ptr-def mysql-ptr))
       (if (zerop (mysql-real-query mysql-ptr sql-native
-                                   (uffi:foreign-encoded-octet-count sql-expression)))
+                                   (uffi:foreign-encoded-octet-count
+                                    sql-expression :encoding (encoding database))))
           t
         (error 'sql-database-data-error
                :database database
              :message (mysql-error-string mysql-ptr)))
 
     (uffi:with-cstring (native-query sql-stmt)
-      (unless (zerop (mysql-stmt-prepare stmt native-query (uffi:foreign-encoded-octet-count sql-stmt)))
+      (unless (zerop (mysql-stmt-prepare stmt native-query (uffi:foreign-encoded-octet-count
+                                                            sql-stmt :encoding (encoding database))))
         (mysql-stmt-close stmt)
         (error 'sql-database-error
                :error-id (mysql-errno mysql-ptr)
index 758f2ca6e0e197def6eb8980445fb3d17b02f30f..846ec3282b0490985f734310c3ac482ffc53a966 100644 (file)
@@ -1,3 +1,15 @@
+cl-sql (5.0.2-1) unstable; urgency=low
+
+  * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Mon, 08 Feb 2010 16:18:52 -0700
+
+cl-sql (5.0.1-1) unstable; urgency=low
+
+  * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Sun, 07 Feb 2010 22:34:13 -0700
+
 cl-sql (5.0.0-1) unstable; urgency=low
 
   * New upstream
index 6519f10ef7fce704fc44963aa31f53ca21bdb795..344e11ce60683811e1faf1a3bb889f1debd8ee04 100644 (file)
@@ -2,8 +2,8 @@
 ;;;; *************************************************************************
 ;;;; FILE IDENTIFICATION
 ;;;;
-;;;; Name:          classes.lisp
-;;;; Purpose:       Classes for High-level SQL interface
+;;;; Name:          base-classes.lisp
+;;;; Purpose:       Base classes for high-level SQL interface
 ;;;; Programmers:   Kevin M. Rosenberg based on
 ;;;;                 original code by Pierre R. Mai
 ;;;; Date Started:  Feb 2002
   ((name :initform nil :initarg :name :reader database-name)
    (connection-spec :initform nil :initarg :connection-spec
                     :reader connection-spec
-                    :documentation "Require to use connection pool")
+                    :documentation "Required to use connection pool.")
    (database-type :initarg :database-type :initform :unknown
                   :reader database-type)
+   (encoding :initarg :encoding :initform nil
+             :documentation "External format character encoding.")
    (state :initform :closed :reader database-state)
    (autocommit :initform t :accessor database-autocommit)
    (command-recording-stream :accessor command-recording-stream :initform nil)
index 41009f5802605203be240d975660e2f7233b1f78..382f552955219276e2ba935f8e194b3156b9f5ea 100644 (file)
@@ -70,7 +70,8 @@ error is signalled."
                 &key (if-exists *connect-if-exists*)
                 (make-default t)
                 (pool nil)
-                (database-type *default-database-type*))
+                (database-type *default-database-type*)
+                (encoding nil))
   "Connects to a database of the supplied DATABASE-TYPE which
 defaults to *DEFAULT-DATABASE-TYPE*, using the type-specific
 connection specification CONNECTION-SPEC. The value of IF-EXISTS,
@@ -149,6 +150,7 @@ be taken from this pool."
           (setf (slot-value result 'state) :open)
           (pushnew result *connected-databases*)
           (when make-default (setq *default-database* result))
+          (setf (encoding result) encoding)
           result))))
 
 
@@ -307,10 +309,28 @@ system specified by DATABASE-TYPE."
     (setq connection-spec (string-to-list-connection-spec connection-spec)))
   (database-list connection-spec database-type))
 
+(defun encoding (db)
+  (when (typep db 'database)
+    (slot-value db 'encoding)))
+
+(defun (setf encoding) (encoding db)
+  (when (typep db 'database)
+    (setf (slot-value db 'encoding) encoding)
+    (when (eql (slot-value db 'state) :open)
+      (case (database-type db)
+        ;; FIXME: If database object is open then
+        ;; send command to SQL engine specifying the character
+        ;; encoding for the database
+        (:mysql
+         )
+        ((:postgresql :postgresql-socket)
+         )))))
+
 (defmacro with-database ((db-var connection-spec
                                  &key make-default pool
                                  (if-exists *connect-if-exists*)
-                                 (database-type *default-database-type*))
+                                 (database-type *default-database-type*)
+                                 (encoding nil))
                                  &body body)
   "Evaluate the body in an environment, where DB-VAR is bound to the
 database connection given by CONNECTION-SPEC and CONNECT-ARGS.  The
@@ -320,7 +340,8 @@ from the body. MAKE-DEFAULT has a default value of NIL."
                            :database-type ,database-type
                            :if-exists ,if-exists
                            :pool ,pool
-                           :make-default ,make-default)))
+                           :make-default ,make-default
+                           :encoding ,encoding)))
      (unwind-protect
       (let ((,db-var ,db-var))
         (progn ,@body))
@@ -331,4 +352,3 @@ from the body. MAKE-DEFAULT has a default value of NIL."
   `(progv '(*default-database*)
        (list ,database)
      ,@body))
-
index e4c37529f2e07a32778f46fe01b3ffa0d1c0e331..766606035a3c2cc2f64e6e5d3f194becce3ff28e 100644 (file)
                                         (db-type (eql :mssql)))
   (declare (ignore args database))
   "DATETIME")
-(defmethod database-get-type-specifier ((type (eql 'date)) args database
-                                        (db-type (eql :mssql)))
-  (declare (ignore args database))
-  "DATETIME")
 
 (defmethod database-get-type-specifier ((type (eql 'boolean)) args database
                                         (db-type (eql :mssql)))
index 860771e862eda4191a3c1d9feba37ab84536fff3..f022ff92947c6614368b9c61fad0e5295b54b7a3 100644 (file)
@@ -72,7 +72,7 @@ represented by SLOTS are initialised from the values of the
 supplied slots with other attributes having default
 values. Furthermore, OBJECT becomes associated with DATABASE."))
 
-(defgeneric update-records-from-instance (object &key database)
+(defgeneric update-records-from-instance (object &key database this-class)
   (:documentation
    "Using an instance of a View Class, OBJECT, update the table
 that stores its instance data. DATABASE defaults to
@@ -88,7 +88,7 @@ associated with DATABASE."))
 table of the database associated with OBJECT. If OBJECT is not
 yet associated with a database, an error is signalled."))
 
-(defgeneric update-instance-from-records (object &key database)
+(defgeneric update-instance-from-records (object &key database this-class)
   (:documentation
    "Updates the slot values of the View Class instance OBJECT
 using the attribute values of the appropriate table of DATABASE
index e2e3b70397632aaf6de1e284041883ba5049f4b6..e8294f79ea7e715f2de009551a741af8a9d3fef2 100644 (file)
      #:database-state
      #:attribute-cache
      #:database-autocommit
+     #:encoding
 
      ;; utils.lisp
      #:without-interrupts
index a5db79f0f5b2268274724008f6241a7083c2c318..b1310718dfdab812ff4032d8e9725bedf4b344f3 100644 (file)
     ;; and stick a value in there.
     (progn (clsql-sys:create-view-from-class 'big)
           (values
-            (clsql:table-exists-p [big] )
+            (clsql:table-exists-p [big] :owner *test-database-user*)
             (progn
               (clsql:drop-table [big] :if-does-not-exist :ignore)
-              (clsql:table-exists-p [big])))
+              (clsql:table-exists-p [big] :owner *test-database-user*)))
           )
   t nil)
 
index 3602885812ad984f045caeaf8c3b3069efa13228..b24f37603a49f73be9c53a631f37938417192a74 100644 (file)
@@ -21,6 +21,7 @@ source=$(base).c
 object=$(base).o
 shared_lib=$(base).so
 shared64_lib=$(base)64.so
+dylib=$(base).dylib
 
 .PHONY: all
 all: $(shared_lib)
@@ -34,33 +35,37 @@ else
        cc -KPIC -c $(source) -o $(object)
        cc -G $(object) -o $(shared_lib)
   else
-    ifneq ($(OS_DARWIN),0)
-       cc -dynamic -c $(source) -o $(object)
-       ld -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress -o $(base).dylib $(object)
-       ld -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress /usr/lib/libz.dylib -o z.dylib
+    ifneq ($(OS_DARWIN64),0)
+       cc -arch x86_64 -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress $(source) -o $(dylib)
+       cc -arch x86_64 -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress /usr/lib/libz.dylib -o z.dylib
     else
-      ifneq ($(OS_CYGWIN),0)
-       gcc -c $(source) -o $(object)
-       ld -shared -soname=$(base) $(LDFLAGS) $(object) -o $(shared_lib)
+      ifneq ($(OS_DARWIN),0)
+         cc -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress $(source) -o $(dylib)
+         cc -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress /usr/lib/libz.dylib -o z.dylib
       else
-        ifneq ($(OS_LINUX64),0)
-         gcc -fPIC -DPIC -c $(source) -o $(object)
-         ld -shared -soname=$(base) -lc $(object) -o $(shared64_lib)
-         rm -f $(object)
-         @echo "Ensure that you have multiarch i386 build tools if you want to build 32-bit library"
-         -gcc -m32 -fPIC -DPIC -c $(source) -o $(object)
-         -ld -melf_i386 -shared -soname=$(base) -lc $(object) -o $(shared_lib)
+        ifneq ($(OS_CYGWIN),0)
+         gcc -c $(source) -o $(object)
+         ld -shared -soname=$(base) $(LDFLAGS) $(object) -o $(shared_lib)
         else
-         gcc -fPIC -DPIC -c $(source) -o $(object)
-         ld -shared -soname=$(base) -lc $(object) -o $(shared_lib)
+          ifneq ($(OS_LINUX64),0)
+           gcc -fPIC -DPIC -c $(source) -o $(object)
+           ld -shared -soname=$(base) -lc $(object) -o $(shared64_lib)
+           rm -f $(object)
+           @echo "Ensure that you have multiarch i386 build tools if you want to build 32-bit library"
+           -gcc -m32 -fPIC -DPIC -c $(source) -o $(object)
+           -ld -melf_i386 -shared -soname=$(base) -lc $(object) -o $(shared_lib)
+          else
+           gcc -fPIC -DPIC -c $(source) -o $(object)
+           ld -shared -soname=$(base) -lc $(object) -o $(shared_lib)
         endif
       endif
     endif
   endif
+endif
 endif
        rm -f $(object)
 
 
 .PHONY: distclean
 distclean: clean
-       rm -f $(base).dylib $(base).dylib $(base).so $(base).o
+       @rm -f $(dylib) $(shared_lib) $(shared64_lib) $(object) z.dylib