23 Mar 2002 Kevin Rosenberg (kevin@rosenberg.net)
- * Initial Release
+ * doc/ref.sgml: Updated MAP-QUERY example to use
+ *read-default-float-format* (John Foderaro)
+
+ * Extensive work to foreign library loaders and .system files to
+ check for successful loading of foreign libraries.
+
+ * Modified test-clsql.cl to allow more modularity and
+ automated testing in future release.
+
+
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: clsql-mysql.system,v 1.2 2002/03/23 17:10:47 kevin Exp $
+;;;; $Id: clsql-mysql.system,v 1.3 2002/03/24 04:01:26 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(:file "mysql-sql" :depends-on ("mysql-api")))
:depends-on (:uffi :clsql)
:finally-do
- (progn
+ (when (clsql-sys:database-type-library-loaded :mysql)
(clsql-sys:initialize-database-type :database-type :mysql)
(setq clsql:*default-database-type* :mysql)
(pushnew :mysql cl:*features*)))
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: clsql-postgresql.system,v 1.2 2002/03/23 17:10:47 kevin Exp $
+;;;; $Id: clsql-postgresql.system,v 1.3 2002/03/24 04:01:26 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(:file "postgresql-loader" :depends-on ("postgresql-package"))
(:file "postgresql-api" :depends-on ("postgresql-loader"))
(:file "postgresql-sql" :depends-on ("postgresql-api")))
- :depends-on (:uffi :clsql))
+ :depends-on (:uffi :clsql)
+ :finally-do
+ (when (clsql-sys:database-type-library-loaded :postgresql)
+ (clsql-sys:initialize-database-type :database-type :postgresql)
+ (pushnew :postgresql cl:*features*)))
+
(map-query '(vector double-float)
#'(lambda (salary name)
(declare (ignorable name))
- (coerce (read-from-string salary) 'double-float))
- "select salary,name from simple where salary > 8000")
+ (let ((*read-default-float-format* 'double-float))
+ (coerce (read-from-string salary) 'double-float))
+ "select salary,name from simple where salary > 8000"))
=> #(10000.0d0 8000.5d0)
(type-of *)
=> (SIMPLE-ARRAY DOUBLE-FLOAT (2))
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: aodbc-sql.cl,v 1.1 2002/03/23 14:04:52 kevin Exp $
+;;;; $Id: aodbc-sql.cl,v 1.2 2002/03/24 04:01:26 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(in-package :clsql-aodbc)
+(defmethod database-type-library-loaded ((database-type (eql :aodbc)))
+ "T if foreign library was able to be loaded successfully. "
+ (when (find-package :dbi) ;; finds Allegro's DBI (AODBC) package
+ t))
+
(defmethod database-initialize-database-type ((database-type (eql :aodbc)))
t)
;;;; Programmers: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: mysql-loader.cl,v 1.1 2002/03/23 14:04:52 kevin Exp $
+;;;; $Id: mysql-loader.cl,v 1.2 2002/03/24 04:01:26 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
load the MySQL client library succesfully. If this differs at your site,
set to the right path before compiling or loading the system.")
+(defvar *mysql-library-loaded* nil
+ "T if foreign library was able to be loaded successfully")
-
+(defmethod database-type-library-loaded ((database-type (eql :mysql)))
+ *mysql-library-loaded*)
+
(defmethod database-type-load-foreign ((database-type (eql :mysql)))
- (uffi:load-foreign-library *mysql-library-filename*
- :module "mysql"
- :supporting-libraries
- *mysql-supporting-libraries*)
- (uffi:load-foreign-library *clsql-mysql-library-filename*
- :module "clsql-mysql"
- :supporting-libraries
- (append *mysql-supporting-libraries*)))
+ (when
+ (and
+ (uffi:load-foreign-library *mysql-library-filename*
+ :module "mysql"
+ :supporting-libraries
+ *mysql-supporting-libraries*)
+ (uffi:load-foreign-library *clsql-mysql-library-filename*
+ :module "clsql-mysql"
+ :supporting-libraries
+ (append *mysql-supporting-libraries*)))
+ (setq *mysql-library-loaded* t)))
(database-type-load-foreign :mysql)
;;;; Programmers: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: mysql-package.cl,v 1.1 2002/03/23 14:04:52 kevin Exp $
+;;;; $Id: mysql-package.cl,v 1.2 2002/03/24 04:01:26 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(in-package :cl-user)
(defpackage :mysql
- (:use :common-lisp)
+ (:use :common-lisp :clsql-sys)
(:export
+ #:database-library-loaded
+
#:mysql-socket
#:mysql-book
#:mysql-byte
;;;; Original code by Pierre R. Mai
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: mysql-sql.cl,v 1.2 2002/03/23 17:07:40 kevin Exp $
+;;;; $Id: mysql-sql.cl,v 1.3 2002/03/24 04:01:26 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
(defpackage :clsql-mysql
(:use :common-lisp :clsql-sys :mysql)
+ (:export #:mysql-database)
(:documentation "This is the CLSQL interface to MySQL."))
(in-package :clsql-mysql)
;;;;
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: postgresql-socket-api.cl,v 1.1 2002/03/23 17:10:48 kevin Exp $
+;;;; $Id: postgresql-socket-api.cl,v 1.2 2002/03/24 04:01:26 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
;;;; - Changed CMUCL FFI to UFFI
;;;; - Added necessary (force-output) for socket streams on
;;;; Allegro and Lispworks
+;;;; - Added initialization variable
(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
(in-package :postgresql-socket)
+(defmethod database-type-library-loaded ((database-type
+ (eql :postgresql-socket)))
+ "T if foreign library was able to be loaded successfully. Always true for
+socket interface"
+ t)
+
+
;;; Message I/O stuff
(defmacro define-message-constants (description &rest clauses)
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: postgresql-loader.cl,v 1.1 2002/03/23 14:04:53 kevin Exp $
+;;;; $Id: postgresql-loader.cl,v 1.2 2002/03/24 04:01:26 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
load the PostgresSQL client library succesfully. If this differs at your site,
set to the right path before compiling or loading the system.")
+(defvar *postgresql-library-loaded* nil
+ "T if foreign library was able to be loaded successfully")
+
+(defmethod database-type-library-loaded ((database-type (eql :postgresql)))
+ *postgresql-library-loaded*)
+
(defmethod database-type-load-foreign ((database-type (eql :postgresql)))
- (uffi:load-foreign-library *postgresql-library-filename*
- :module "postgresql"
- :supporting-libraries
- *postgresql-supporting-libraries*))
+ (when
+ (uffi:load-foreign-library *postgresql-library-filename*
+ :module "postgresql"
+ :supporting-libraries
+ *postgresql-supporting-libraries*)
+ (setq *postgresql-library-loaded* t)))
(database-type-load-foreign :postgresql)
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: postgresql-package.cl,v 1.1 2002/03/23 14:04:53 kevin Exp $
+;;;; $Id: postgresql-package.cl,v 1.2 2002/03/24 04:01:26 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(defpackage :postgresql
(:nicknames :pgsql)
- (:use :common-lisp)
+ (:use :common-lisp :clsql-sys)
(:export
#:pgsql-oid
#:pgsql-conn-status-type
;;;; Original code by Pierre R. Mai
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: package.cl,v 1.1 2002/03/23 14:04:54 kevin Exp $
+;;;; $Id: package.cl,v 1.2 2002/03/24 04:01:26 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
;; "Private" exports for use by interface packages
#:check-connection-spec
#:database-type-load-foreign
+ #:database-type-library-loaded ;; KMR - Tests if foreign library okay
#:database-initialize-database-type
#:database-connect
#:database-disconnect
;;;; Original code by Pierre R. Mai
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: sql.cl,v 1.1 2002/03/23 14:04:54 kevin Exp $
+;;;; $Id: sql.cl,v 1.2 2002/03/24 04:01:26 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
(defvar *loaded-database-types* nil
"Contains a list of database types which have been defined/loaded.")
+(defvar *library-loaded-database-types* nil
+ "Contains a list of database types which have had their
+foreign libraries loaded successfully.")
+
(defun reload-database-types ()
"Reloads any foreign code for the loaded database types after a dump."
(mapc #'database-type-load-foreign *loaded-database-types*))
(:method :after (database-type)
(pushnew database-type *loaded-database-types*)))
+(defgeneric database-type-library-loaded (database-type)
+ (:documentation
+ "The internal generic implementation for checking if
+database type library loaded successfully.")
+ (:method :after (database-type)
+ (pushnew database-type *library-loaded-database-types*)))
+
(defvar *default-database-type* nil
"Specifies the default type of database. Currently only :mysql is
supported.")
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Mar 2002
;;;;
-;;;; $Id: test-clsql.cl,v 1.1 2002/03/23 14:04:49 kevin Exp $
+;;;; $Id: test-clsql.cl,v 1.2 2002/03/24 04:01:26 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
(in-package :cl-user)
+
(defun get-spec-and-type ()
(format t "~&Test CLSQL")
(format t "~&==========~%")
(let ((type-string (read-line)))
(if (zerop (length type-string))
(values nil nil)
- (let* ((type (read-from-string type-string))
- (spec (get-spec type
- (ecase type
- ((:mysql :postgresql :postgresql-socket)
- '("host" "database" "user" "password"))
- (:aodbc
- '("dsn" "user" "password"))))))
- (when (eq type :mysql)
- (test-clsql-mysql spec))
- (values spec type)))))
+ (get-spec-for-type (read-from-string type-string)))))
+
+(defun get-spec-for-type (type)
+ (let ((spec (get-spec type
+ (ecase type
+ ((:mysql :postgresql :postgresql-socket)
+ '("host" "database" "user" "password"))
+ (:aodbc
+ '("dsn" "user" "password"))))))
+ (values spec type)))))
(defun get-spec (type spec-format)
(nreverse spec)))
(defun test-clsql (spec type)
+ (when (eq type :mysql)
+ (test-clsql-mysql spec))
(let ((db (clsql:connect spec :database-type type :if-exists :new)))
(unwind-protect
(progn
(clsql-mysql::database-execute-command "DROP TABLE test_clsql" db)
(clsql-mysql::database-disconnect db)))
-
+#-non-interactive-test
(do ((done nil))
(done)
(multiple-value-bind (spec type) (get-spec-and-type)