From: Nathan Bird Date: Thu, 11 Feb 2010 19:26:04 +0000 (-0500) Subject: Merge branch 'development' X-Git-Tag: v5.0.3~3 X-Git-Url: http://git.kpe.io/?p=clsql.git;a=commitdiff_plain;h=0ad64f85ff6cd99a78cc9ae6716ebbdb5627eaef;hp=ec1872df0ec2761b4ab6811dc12f960f6f455819 Merge branch 'development' --- diff --git a/ChangeLog b/ChangeLog index 0c26481..4d8ede9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2010-02-20 Kevin Rosenberg + * 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 + * 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 + * 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 * Version 5.0.0: First release of CLSQL to formally and consistently support non-ASCII strings with encoding of external diff --git a/Makefile.common b/Makefile.common index dd73322..30be60e 100644 --- a/Makefile.common +++ b/Makefile.common @@ -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.*') diff --git a/db-mysql/Makefile b/db-mysql/Makefile index f85ecb0..9e2e291 100644 --- a/db-mysql/Makefile +++ b/db-mysql/Makefile @@ -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 diff --git a/db-mysql/mysql-sql.lisp b/db-mysql/mysql-sql.lisp index 3e30222..db98e63 100644 --- a/db-mysql/mysql-sql.lisp +++ b/db-mysql/mysql-sql.lisp @@ -159,7 +159,8 @@ :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.") @@ -177,7 +178,8 @@ (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 @@ -509,7 +511,8 @@ :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) diff --git a/debian/changelog b/debian/changelog index 758f2ca..846ec32 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +cl-sql (5.0.2-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Mon, 08 Feb 2010 16:18:52 -0700 + +cl-sql (5.0.1-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Sun, 07 Feb 2010 22:34:13 -0700 + cl-sql (5.0.0-1) unstable; urgency=low * New upstream diff --git a/sql/base-classes.lisp b/sql/base-classes.lisp index 6519f10..344e11c 100644 --- a/sql/base-classes.lisp +++ b/sql/base-classes.lisp @@ -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 @@ -23,9 +23,11 @@ ((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) diff --git a/sql/database.lisp b/sql/database.lisp index 41009f5..382f552 100644 --- a/sql/database.lisp +++ b/sql/database.lisp @@ -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)) - diff --git a/sql/generic-odbc.lisp b/sql/generic-odbc.lisp index e4c3752..7666060 100644 --- a/sql/generic-odbc.lisp +++ b/sql/generic-odbc.lisp @@ -76,10 +76,6 @@ (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))) diff --git a/sql/generics.lisp b/sql/generics.lisp index 860771e..f022ff9 100644 --- a/sql/generics.lisp +++ b/sql/generics.lisp @@ -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 diff --git a/sql/package.lisp b/sql/package.lisp index e2e3b70..e8294f7 100644 --- a/sql/package.lisp +++ b/sql/package.lisp @@ -189,6 +189,7 @@ #:database-state #:attribute-cache #:database-autocommit + #:encoding ;; utils.lisp #:without-interrupts diff --git a/tests/test-ooddl.lisp b/tests/test-ooddl.lisp index a5db79f..b131071 100644 --- a/tests/test-ooddl.lisp +++ b/tests/test-ooddl.lisp @@ -107,10 +107,10 @@ ;; 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) diff --git a/uffi/Makefile b/uffi/Makefile index 3602885..b24f376 100644 --- a/uffi/Makefile +++ b/uffi/Makefile @@ -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