+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
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.*')
object=$(base).o
shared_lib=$(base).so
shared64_lib=$(base)64.so
-
+dylib=$(base).dylib
.PHONY: all
all: $(shared_lib)
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)
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
: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)
+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
;;;; *************************************************************************
;;;; 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)
&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,
(setf (slot-value result 'state) :open)
(pushnew result *connected-databases*)
(when make-default (setq *default-database* result))
+ (setf (encoding result) encoding)
result))))
(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
: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))
`(progv '(*default-database*)
(list ,database)
,@body))
-
(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)))
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
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
#:database-state
#:attribute-cache
#:database-autocommit
+ #:encoding
;; utils.lisp
#:without-interrupts
;; 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)
object=$(base).o
shared_lib=$(base).so
shared64_lib=$(base)64.so
+dylib=$(base).dylib
.PHONY: all
all: $(shared_lib)
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