From: Kevin M. Rosenberg Date: Sun, 24 Mar 2002 04:01:26 +0000 (+0000) Subject: r1648: *** empty log message *** X-Git-Tag: v3.8.6~1226 X-Git-Url: http://git.kpe.io/?p=clsql.git;a=commitdiff_plain;h=9a78eef71c902d3b272fb7c777bff6dd0acd8a2b r1648: *** empty log message *** --- diff --git a/ChangeLog b/ChangeLog index 7c405bd..d5f5b23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,13 @@ 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. + + diff --git a/VERSION b/VERSION index 8ea2ddf..aa34b8b 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -0.5.0 +0.5.1 diff --git a/clsql-mysql.system b/clsql-mysql.system index 795d8d9..7672575 100644 --- a/clsql-mysql.system +++ b/clsql-mysql.system @@ -7,7 +7,7 @@ ;;;; 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 ;;;; @@ -32,7 +32,7 @@ (: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*))) diff --git a/clsql-postgresql.system b/clsql-postgresql.system index ae3a9a7..d96a0f5 100644 --- a/clsql-postgresql.system +++ b/clsql-postgresql.system @@ -7,7 +7,7 @@ ;;;; 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 ;;;; @@ -28,4 +28,9 @@ (: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*))) + diff --git a/doc/ref.sgml b/doc/ref.sgml index e7c17ec..0c860c1 100644 --- a/doc/ref.sgml +++ b/doc/ref.sgml @@ -1985,8 +1985,9 @@ (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)) diff --git a/interfaces/aodbc/aodbc-sql.cl b/interfaces/aodbc/aodbc-sql.cl index c1a74c9..4fb4f47 100644 --- a/interfaces/aodbc/aodbc-sql.cl +++ b/interfaces/aodbc/aodbc-sql.cl @@ -7,7 +7,7 @@ ;;;; 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 ;;;; @@ -20,6 +20,11 @@ (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) diff --git a/interfaces/mysql/mysql-loader.cl b/interfaces/mysql/mysql-loader.cl index df0bd64..ce8b7ce 100644 --- a/interfaces/mysql/mysql-loader.cl +++ b/interfaces/mysql/mysql-loader.cl @@ -7,7 +7,7 @@ ;;;; 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 ;;;; @@ -51,17 +51,24 @@ 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) diff --git a/interfaces/mysql/mysql-package.cl b/interfaces/mysql/mysql-package.cl index 450efc2..0dd231a 100644 --- a/interfaces/mysql/mysql-package.cl +++ b/interfaces/mysql/mysql-package.cl @@ -7,7 +7,7 @@ ;;;; 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 ;;;; @@ -20,8 +20,10 @@ (in-package :cl-user) (defpackage :mysql - (:use :common-lisp) + (:use :common-lisp :clsql-sys) (:export + #:database-library-loaded + #:mysql-socket #:mysql-book #:mysql-byte diff --git a/interfaces/mysql/mysql-sql.cl b/interfaces/mysql/mysql-sql.cl index 37b88eb..878033c 100644 --- a/interfaces/mysql/mysql-sql.cl +++ b/interfaces/mysql/mysql-sql.cl @@ -8,7 +8,7 @@ ;;;; 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 @@ -31,6 +31,7 @@ (defpackage :clsql-mysql (:use :common-lisp :clsql-sys :mysql) + (:export #:mysql-database) (:documentation "This is the CLSQL interface to MySQL.")) (in-package :clsql-mysql) diff --git a/interfaces/postgresql-socket/postgresql-socket-api.cl b/interfaces/postgresql-socket/postgresql-socket-api.cl index c97eda1..3d58496 100644 --- a/interfaces/postgresql-socket/postgresql-socket-api.cl +++ b/interfaces/postgresql-socket/postgresql-socket-api.cl @@ -9,7 +9,7 @@ ;;;; ;;;; 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 @@ -25,11 +25,19 @@ ;;;; - 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) diff --git a/interfaces/postgresql/postgresql-loader.cl b/interfaces/postgresql/postgresql-loader.cl index 4db5fd4..a2b7988 100644 --- a/interfaces/postgresql/postgresql-loader.cl +++ b/interfaces/postgresql/postgresql-loader.cl @@ -7,7 +7,7 @@ ;;;; 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 ;;;; @@ -39,10 +39,18 @@ 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) diff --git a/interfaces/postgresql/postgresql-package.cl b/interfaces/postgresql/postgresql-package.cl index 48d8d5e..2957cee 100644 --- a/interfaces/postgresql/postgresql-package.cl +++ b/interfaces/postgresql/postgresql-package.cl @@ -7,7 +7,7 @@ ;;;; 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 ;;;; @@ -21,7 +21,7 @@ (defpackage :postgresql (:nicknames :pgsql) - (:use :common-lisp) + (:use :common-lisp :clsql-sys) (:export #:pgsql-oid #:pgsql-conn-status-type diff --git a/sql/package.cl b/sql/package.cl index 48c5da9..75e6834 100644 --- a/sql/package.cl +++ b/sql/package.cl @@ -8,7 +8,7 @@ ;;;; 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 @@ -32,6 +32,7 @@ ;; "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 diff --git a/sql/sql.cl b/sql/sql.cl index 6969974..ce3cc56 100644 --- a/sql/sql.cl +++ b/sql/sql.cl @@ -8,7 +8,7 @@ ;;;; 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 @@ -148,6 +148,10 @@ although there is an existing connection (~A)." (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*)) @@ -158,6 +162,13 @@ although there is an existing connection (~A)." (: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.") diff --git a/test-clsql.cl b/test-clsql.cl index 7d46988..2f1d960 100644 --- a/test-clsql.cl +++ b/test-clsql.cl @@ -7,7 +7,7 @@ ;;;; 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 ;;;; @@ -19,6 +19,7 @@ (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 "~&==========~%") @@ -28,16 +29,16 @@ (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) @@ -51,6 +52,8 @@ (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 @@ -85,7 +88,7 @@ (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)