From: Kevin M. Rosenberg Date: Mon, 27 May 2002 17:19:45 +0000 (+0000) Subject: r2078: Changes to finish separating clsql-base form clsql X-Git-Tag: v3.8.6~1048 X-Git-Url: http://git.kpe.io/?a=commitdiff_plain;ds=sidebyside;h=9f3761f57371f7d347e25d635735dcbf536e652c;p=clsql.git r2078: Changes to finish separating clsql-base form clsql --- diff --git a/base/classes.cl b/base/classes.cl index 0a91a16..e23993e 100644 --- a/base/classes.cl +++ b/base/classes.cl @@ -8,7 +8,7 @@ ;;;; original code by Pierre R. Mai ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: classes.cl,v 1.1 2002/05/13 16:22:08 kevin Exp $ +;;;; $Id: classes.cl,v 1.2 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai @@ -19,7 +19,7 @@ ;;;; ************************************************************************* (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0))) -(in-package :clsql-sys) +(in-package :clsql-base-sys) (defclass database () diff --git a/base/conditions.cl b/base/conditions.cl index 5785653..e902ab0 100644 --- a/base/conditions.cl +++ b/base/conditions.cl @@ -8,7 +8,7 @@ ;;;; Original code by Pierre R. Mai ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: conditions.cl,v 1.1 2002/05/13 16:22:08 kevin Exp $ +;;;; $Id: conditions.cl,v 1.2 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai @@ -19,7 +19,7 @@ ;;;; ************************************************************************* (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0))) -(in-package :clsql-sys) +(in-package :clsql-base-sys) ;;; Conditions (define-condition clsql-condition () diff --git a/base/db-interface.cl b/base/db-interface.cl index f779159..d90d566 100644 --- a/base/db-interface.cl +++ b/base/db-interface.cl @@ -9,7 +9,7 @@ ;;;; onShoreD to support UncommonSQL front-end ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: db-interface.cl,v 1.1 2002/05/13 16:22:08 kevin Exp $ +;;;; $Id: db-interface.cl,v 1.2 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai, and onShoreD @@ -20,7 +20,7 @@ ;;;; ************************************************************************* (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0))) -(in-package :clsql-sys) +(in-package :clsql-base-sys) (defgeneric database-type-load-foreign (database-type) (:documentation @@ -31,11 +31,10 @@ "The internal generic implementation for checking if database type library loaded successfully.")) -(defgeneric database-type (database-type) +(defgeneric database-type (database) (:documentation "Returns database type") - (:method (database-type) - (declare (ignore database-type)) + (:method (database) (signal-nodb-error database))) diff --git a/base/initialize.cl b/base/initialize.cl index 067dfa7..e522d02 100644 --- a/base/initialize.cl +++ b/base/initialize.cl @@ -7,7 +7,7 @@ ;;;; Programmers: Kevin M. Rosenberg ;;;; Date Started: May 2002 ;;;; -;;;; $Id: initialize.cl,v 1.1 2002/05/14 16:23:37 kevin Exp $ +;;;; $Id: initialize.cl,v 1.2 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai @@ -18,7 +18,7 @@ ;;;; ************************************************************************* (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0))) -(in-package :clsql-sys) +(in-package :clsql-base-sys) (defvar *loaded-database-types* nil "Contains a list of database types which have been defined/loaded.") diff --git a/base/package.cl b/base/package.cl index 326e196..62199ce 100644 --- a/base/package.cl +++ b/base/package.cl @@ -8,7 +8,7 @@ ;;;; Original code by Pierre R. Mai ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: package.cl,v 1.5 2002/05/20 17:46:34 kevin Exp $ +;;;; $Id: package.cl,v 1.6 2002/05/27 17:19:30 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,7 +25,7 @@ ;;;; core packages. (eval-when (:compile-toplevel :load-toplevel :execute) -(defpackage :clsql-sys +(defpackage :clsql-base-sys (:use :common-lisp) (:export ;; "Private" exports for use by interface packages @@ -59,8 +59,7 @@ #:database-read-large-object #:database-delete-large-object - ;; Shared exports for re-export by CLSQL - + ;; Shared exports for re-export by CLSQL-BASE . #1=(#:clsql-condition #:clsql-error @@ -91,6 +90,7 @@ #:clsql-exists-error #:clsql-closed-error #:clsql-closed-error-database + #:*loaded-database-types* #:reload-database-types #:*default-database-type* @@ -104,58 +104,25 @@ #:closed-database #:find-database #:database-name-from-spec - #:connect - #:disconnect - #:query - #:execute-command - #:map-query - #:do-query - ;; functional.cl - #:insert-records - #:delete-records - #:update-records - #:with-database + ;; accessors for database class + #:name + #:connection-spec + #:transaction + #:transaction-level + #:conn-pool ;; utils.cl #:number-to-sql-string #:float-to-sql-string #:sql-escape-quotes - - ;; For UncommonSQL support - #:sql-ident - #:list-tables - #:list-attributes - #:attribute-type - #:create-sequence - #:drop-sequence - #:sequence-next - - ;; Pooled connections - #:disconnect-pooled - #:find-or-create-connection-pool - - ;; Transactions - #:with-transaction - #:commit-transaction - #:rollback-transaction - #:add-transaction-commit-hook - #:add-transaction-rollback-hook - - ;; Large objects (Marc B) - #:create-large-object - #:write-large-object - #:read-large-object - #:delete-large-object )) - (:documentation "This is the INTERNAL SQL-Interface package of CLSQL.")) + (:documentation "This is the INTERNAL SQL-Interface package of CLSQL-BASE.")) -(defpackage #:clsql - (:import-from #:clsql-sys . #1#) +(defpackage #:clsql-base + (:import-from :clsql-base-sys . #1#) (:export . #1#) - (:documentation "This is the SQL-Interface package of CLSQL.")) + (:documentation "This is the SQL-Interface package of CLSQL-BASE.")) );eval-when -(defpackage #:clsql-user - (:use #:common-lisp #:clsql) - (:documentation "This is the user package for experimenting with CLSQL.")) + diff --git a/base/utils.cl b/base/utils.cl index de028aa..99df86c 100644 --- a/base/utils.cl +++ b/base/utils.cl @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Mar 2002 ;;;; -;;;; $Id: utils.cl,v 1.3 2002/05/19 16:05:22 kevin Exp $ +;;;; $Id: utils.cl,v 1.4 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -17,7 +17,7 @@ ;;;; ************************************************************************* (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0))) -(in-package :clsql-sys) +(in-package :clsql-base-sys) (defun number-to-sql-string (num) (etypecase num diff --git a/clsql-aodbc.system b/clsql-aodbc.system index d80acf7..4cb2fe6 100644 --- a/clsql-aodbc.system +++ b/clsql-aodbc.system @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: clsql-aodbc.system,v 1.5 2002/05/18 17:37:48 kevin Exp $ +;;;; $Id: clsql-aodbc.system,v 1.6 2002/05/27 17:19:29 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -25,6 +25,6 @@ :binary-pathname "CL-LIBRARY:clsql;interfaces;aodbc;bin;" :components ((:file "aodbc-package") (:file "aodbc-sql" :depends-on ("aodbc-package"))) - :depends-on (:clsql)) + :depends-on (:clsql-base)) diff --git a/clsql.system b/clsql.system index aa1356e..9efc2ad 100644 --- a/clsql.system +++ b/clsql.system @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: clsql.system,v 1.14 2002/05/15 17:19:42 kevin Exp $ +;;;; $Id: clsql.system,v 1.15 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -31,7 +31,8 @@ :source-pathname "CL-LIBRARY:clsql;sql;" :source-extension "cl" :binary-pathname "CL-LIBRARY:clsql;sql;bin;" - :components ((:file "pool") + :components ((:file "package") + (:file "pool" :depends-on ("package")) (:file "loop-extension") (:file "sql" :depends-on ("pool")) (:file "transactions" :depends-on ("sql")) diff --git a/interfaces/aodbc/aodbc-package.cl b/interfaces/aodbc/aodbc-package.cl index 3bfaee8..14f0995 100644 --- a/interfaces/aodbc/aodbc-package.cl +++ b/interfaces/aodbc/aodbc-package.cl @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: aodbc-package.cl,v 1.1 2002/03/23 14:04:52 kevin Exp $ +;;;; $Id: aodbc-package.cl,v 1.2 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -26,6 +26,6 @@ (defpackage :clsql-aodbc (:nicknames :aodbc) - (:use :common-lisp :clsql-sys) + (:use :common-lisp :clsql-base-sys) (:export #:aodbc-database) (:documentation "This is the CLSQL interface to Allegro's AODBC")) diff --git a/interfaces/aodbc/aodbc-sql.cl b/interfaces/aodbc/aodbc-sql.cl index e493918..5eaa960 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.10 2002/05/13 22:05:21 kevin Exp $ +;;;; $Id: aodbc-sql.cl,v 1.11 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -26,11 +26,11 @@ (when (find-package :dbi) ;; finds Allegro's DBI (AODBC) package t)) -(defmethod clsql-sys:database-type-load-foreign ((databae-type (eql :aodbc))) +(defmethod clsql-base-sys:database-type-load-foreign ((databae-type (eql :aodbc))) t) (when (find-package :dbi) - (clsql-sys:database-type-load-foreign :aodbc)) + (clsql-base-sys:database-type-load-foreign :aodbc)) (defmethod database-initialize-database-type ((database-type (eql :aodbc))) t) @@ -146,5 +146,5 @@ list)))) -(when (clsql-sys:database-type-library-loaded :aodbc) - (clsql-sys:initialize-database-type :database-type :aodbc)) +(when (clsql-base-sys:database-type-library-loaded :aodbc) + (clsql-base-sys:initialize-database-type :database-type :aodbc)) diff --git a/interfaces/mysql/mysql-loader.cl b/interfaces/mysql/mysql-loader.cl index a241d2d..75dd094 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.17 2002/05/18 17:37:48 kevin Exp $ +;;;; $Id: mysql-loader.cl,v 1.18 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -65,10 +65,10 @@ 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 clsql-sys:database-type-library-loaded ((database-type (eql :mysql))) +(defmethod clsql-base-sys:database-type-library-loaded ((database-type (eql :mysql))) *mysql-library-loaded*) -(defmethod clsql-sys:database-type-load-foreign ((database-type (eql :mysql))) +(defmethod clsql-base-sys:database-type-load-foreign ((database-type (eql :mysql))) (let ((mysql-path (uffi:find-foreign-library *mysql-library-candidate-names* *mysql-library-candidate-directories* @@ -92,5 +92,5 @@ set to the right path before compiling or loading the system.") mysql-path *clsql-mysql-library-filename*)))) -(clsql-sys:database-type-load-foreign :mysql) +(clsql-base-sys:database-type-load-foreign :mysql) diff --git a/interfaces/mysql/mysql-sql.cl b/interfaces/mysql/mysql-sql.cl index d608d8b..652fb33 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.21 2002/05/25 15:57:28 kevin Exp $ +;;;; $Id: mysql-sql.cl,v 1.22 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai @@ -33,7 +33,7 @@ ;;;; Added field types (defpackage :clsql-mysql - (:use :common-lisp :clsql-sys :mysql :clsql-uffi) + (:use :common-lisp :clsql-base-sys :mysql :clsql-uffi) (:export #:mysql-database) (:documentation "This is the CLSQL interface to MySQL.")) @@ -255,7 +255,6 @@ list))) -(when (clsql-sys:database-type-library-loaded :mysql) - (clsql-sys:initialize-database-type :database-type :mysql) - (setq clsql:*default-database-type* :mysql) +(when (clsql-base-sys:database-type-library-loaded :mysql) + (clsql-base-sys:initialize-database-type :database-type :mysql) (pushnew :mysql cl:*features*)) diff --git a/interfaces/mysql/mysql-usql.cl b/interfaces/mysql/mysql-usql.cl index 59a23b4..311bf67 100644 --- a/interfaces/mysql/mysql-usql.cl +++ b/interfaces/mysql/mysql-usql.cl @@ -7,7 +7,7 @@ ;;;; Programmers: Kevin M. Rosenberg and onShore Development Inc ;;;; Date Started: Mar 2002 ;;;; -;;;; $Id: mysql-usql.cl,v 1.5 2002/04/27 21:48:08 kevin Exp $ +;;;; $Id: mysql-usql.cl,v 1.6 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; and by onShore Development Inc. @@ -80,6 +80,7 @@ ;; Misc USQL functions +#| #+ignore (defmethod database-output-sql ((expr clsql-sys::sql-typecast-exp) (database mysql-database)) @@ -101,3 +102,4 @@ (make-instance 'clsql-sys::sql-typecast-exp :modifier 'int8 :components val))) +|# diff --git a/interfaces/postgresql-socket/postgresql-socket-sql.cl b/interfaces/postgresql-socket/postgresql-socket-sql.cl index 6c517f1..f1a6ca4 100644 --- a/interfaces/postgresql-socket/postgresql-socket-sql.cl +++ b/interfaces/postgresql-socket/postgresql-socket-sql.cl @@ -8,7 +8,7 @@ ;;;; Original code by Pierre R. Mai ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: postgresql-socket-sql.cl,v 1.12 2002/05/13 22:05:21 kevin Exp $ +;;;; $Id: postgresql-socket-sql.cl,v 1.13 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai @@ -22,7 +22,7 @@ (in-package :cl-user) (defpackage :clsql-postgresql-socket - (:use :common-lisp :clsql-sys :postgresql-socket) + (:use :common-lisp :clsql-base-sys :postgresql-socket) (:export #:postgresql-socket-database) (:documentation "This is the CLSQL socket interface to PostgreSQL.")) @@ -33,10 +33,10 @@ (defmethod database-type-library-loaded ((database-type (eql :postgresql-socket))) t) -(defmethod clsql-sys:database-type-load-foreign ((database-type (eql :postgresql-socket))) +(defmethod clsql-base-sys:database-type-load-foreign ((database-type (eql :postgresql-socket))) t) -(clsql-sys:database-type-load-foreign :postgresql-socket) +(clsql-base-sys:database-type-load-foreign :postgresql-socket) ;; Field type conversion @@ -305,5 +305,5 @@ doesn't depend on UFFI." (setf (postgresql-socket-result-set-done result-set) t) (wait-for-query-results (database-connection database))))))) -(when (clsql-sys:database-type-library-loaded :postgresql-socket) - (clsql-sys:initialize-database-type :database-type :postgresql-socket)) +(when (clsql-base-sys:database-type-library-loaded :postgresql-socket) + (clsql-base-sys:initialize-database-type :database-type :postgresql-socket)) diff --git a/interfaces/postgresql/postgresql-loader.cl b/interfaces/postgresql/postgresql-loader.cl index ff95f08..bfdf60d 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.11 2002/05/18 17:37:49 kevin Exp $ +;;;; $Id: postgresql-loader.cl,v 1.12 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -28,11 +28,11 @@ 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 clsql-sys:database-type-library-loaded ((database-type +(defmethod clsql-base-sys:database-type-library-loaded ((database-type (eql :postgresql))) *postgresql-library-loaded*) -(defmethod clsql-sys:database-type-load-foreign ((database-type +(defmethod clsql-base-sys:database-type-load-foreign ((database-type (eql :postgresql))) (let ((libpath (uffi:find-foreign-library "libpq" @@ -48,5 +48,5 @@ set to the right path before compiling or loading the system.") (setq *postgresql-library-loaded* t) (warn "Can't load PostgreSQL client library ~A" libpath)))) -(clsql-sys:database-type-load-foreign :postgresql) +(clsql-base-sys:database-type-load-foreign :postgresql) diff --git a/interfaces/postgresql/postgresql-sql.cl b/interfaces/postgresql/postgresql-sql.cl index 41b43bf..cb02f60 100644 --- a/interfaces/postgresql/postgresql-sql.cl +++ b/interfaces/postgresql/postgresql-sql.cl @@ -8,7 +8,7 @@ ;;;; Original code by Pierre R. Mai ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: postgresql-sql.cl,v 1.17 2002/05/14 16:29:53 kevin Exp $ +;;;; $Id: postgresql-sql.cl,v 1.18 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai @@ -22,7 +22,7 @@ (in-package :cl-user) (defpackage :clsql-postgresql - (:use :common-lisp :clsql-sys :postgresql :clsql-uffi) + (:use :common-lisp :clsql-base-sys :postgresql :clsql-uffi) (:export #:postgresql-database) (:documentation "This is the CLSQL interface to PostgreSQL.")) @@ -285,6 +285,8 @@ (lo-create (database-conn-ptr database) (logior postgresql::+INV_WRITE+ postgresql::+INV_READ+))) + +#+mb-original (defmethod database-write-large-object (object-id (data string) (database postgresql-database)) (let ((ptr (database-conn-ptr database)) (length (length data)) @@ -303,7 +305,26 @@ ))) result)) +(defmethod database-write-large-object (object-id (data string) (database postgresql-database)) + (let ((ptr (database-conn-ptr database)) + (length (length data)) + (result nil) + (fd nil)) + (database-execute-command "begin" database) + (unwind-protect + (progn + (setf fd (lo-open ptr object-id postgresql::+INV_WRITE+)) + (when (>= fd 0) + (when (= (lo-write ptr fd data length) length) + (setf result t)))) + (progn + (when (and fd (>= fd 0)) + (lo-close ptr fd)) + (database-execute-command (if result "commit" "rollback") database))) + result)) + ;; (MB) the begin/commit/rollback stuff will be removed when with-transaction wil be implemented +;; (KMR) Can't use with-transaction since that function is in high-level code (defmethod database-read-large-object (object-id (database postgresql-database)) (let ((ptr (database-conn-ptr database)) (buffer nil) @@ -332,6 +353,6 @@ (defmethod database-delete-large-object (object-id (database postgresql-database)) (lo-unlink (database-conn-ptr database) object-id)) -(when (clsql-sys:database-type-library-loaded :postgresql) - (clsql-sys:initialize-database-type :database-type :postgresql) +(when (clsql-base-sys:database-type-library-loaded :postgresql) + (clsql-base-sys:initialize-database-type :database-type :postgresql) (pushnew :postgresql cl:*features*)) diff --git a/sql/package.cl b/sql/package.cl new file mode 100644 index 0000000..01cbe61 --- /dev/null +++ b/sql/package.cl @@ -0,0 +1,127 @@ +;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- +;;;; ************************************************************************* +;;;; FILE IDENTIFICATION +;;;; +;;;; Name: package.cl +;;;; Purpose: Package definition for CLSQL (high-level) interface +;;;; Programmers: Kevin M. Rosenberg based on +;;;; Original code by Pierre R. Mai +;;;; Date Started: Feb 2002 +;;;; +;;;; $Id: package.cl,v 1.16 2002/05/27 17:19:45 kevin Exp $ +;;;; +;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg +;;;; and Copyright (c) 1999-2001 by Pierre R. Mai +;;;; +;;;; CLSQL users are granted the rights to distribute and use this software +;;;; as governed by the terms of the Lisp Lesser GNU Public License +;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. +;;;; ************************************************************************* + +(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0))) +(in-package :cl-user) + + +(eval-when (:compile-toplevel :load-toplevel :execute) + (defpackage :clsql-sys + (:nicknames :clsql) + (:use :common-lisp :clsql-base-sys) + (:import-from + :clsql-base + . + #1=( + #:clsql-condition + #:clsql-error + #:clsql-simple-error + #:clsql-warning + #:clsql-simple-warning + #:clsql-invalid-spec-error + #:clsql-invalid-spec-error-connection-spec + #:clsql-invalid-spec-error-database-type + #:clsql-invalid-spec-error-template + #:clsql-connect-error + #:clsql-connect-error-database-type + #:clsql-connect-error-connection-spec + #:clsql-connect-error-errno + #:clsql-connect-error-error + #:clsql-sql-error + #:clsql-sql-error-database + #:clsql-sql-error-expression + #:clsql-sql-error-errno + #:clsql-sql-error-error + #:clsql-database-warning + #:clsql-database-warning-database + #:clsql-database-warning-message + #:clsql-exists-condition + #:clsql-exists-condition-new-db + #:clsql-exists-condition-old-db + #:clsql-exists-warning + #:clsql-exists-error + #:clsql-closed-error + #:clsql-closed-error-database + + #:*loaded-database-types* + #:reload-database-types + #:*default-database-type* + #:*initialized-database-types* + #:initialize-database-type + + #:database + #:database-name + #:closed-database + #:database-name-from-spec)) + (:export + ;; sql.cl + #:*connect-if-exists* + #:connected-databases + #:*default-database* + #:find-database + #:connect + #:disconnect + #:query + #:execute-command + #:map-query + #:do-query + + ;; functional.cl + #:insert-records + #:delete-records + #:update-records + #:with-database + + ;; For High-level UncommonSQL compatibility + #:sql-ident + #:list-tables + #:list-attributes + #:attribute-type + #:create-sequence + #:drop-sequence + #:sequence-next + + ;; Pooled connections + #:disconnect-pooled + #:find-or-create-connection-pool + + ;; Transactions + #:with-transaction + #:commit-transaction + #:rollback-transaction + #:add-transaction-commit-hook + #:add-transaction-rollback-hook + + ;; Large objects (Marc B) + #:create-large-object + #:write-large-object + #:read-large-object + #:delete-large-object + + . + #1# + ) + (:documentation "This is the INTERNAL SQL-Interface package of CLSQL.")) + + ) ;eval-when + +(defpackage #:clsql-user + (:use #:common-lisp #:clsql) + (:documentation "This is the user package for experimenting with CLSQL.")) diff --git a/sql/transactions.cl b/sql/transactions.cl index 693e7a5..c45d021 100644 --- a/sql/transactions.cl +++ b/sql/transactions.cl @@ -7,7 +7,7 @@ ;;;; Programmers: Marc Battyani ;;;; Date Started: Apr 2002 ;;;; -;;;; $Id: transactions.cl,v 1.4 2002/05/13 16:55:07 marc.battyani Exp $ +;;;; $Id: transactions.cl,v 1.5 2002/05/27 17:19:30 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -27,7 +27,7 @@ (status :initform nil :accessor status))) ;can be nil :rolled-back or :commited (defmethod database-start-transaction ((database closed-database)) - (signal-closed-database-error database)) + (error 'clsql-closed-database-error database)) (defmethod database-start-transaction (database) (unless (transaction database) @@ -40,7 +40,7 @@ (execute-command "BEGIN" :database database)))) (defmethod database-end-transaction ((database closed-database)) - (signal-closed-database-error database)) + (error 'clsql-closed-database-error database)) (defmethod database-end-transaction (database) (if (> (transaction-level database) 0) @@ -66,9 +66,9 @@ (when (and (transaction database)(not (status (transaction database)))) (setf (status (transaction database)) :commited))) -(defun add-transaction-commit-hook (database abort-hook) +(defun add-transaction-commit-hook (database commit-hook) (when (transaction database) - (push abort-hook (abort-hooks (transaction database))))) + (push commit-hook (commit-hooks (transaction database))))) (defun add-transaction-rollback-hook (database rollback-hook) (when (transaction database) diff --git a/sql/usql.cl b/sql/usql.cl index 432a803..2951dbc 100644 --- a/sql/usql.cl +++ b/sql/usql.cl @@ -8,7 +8,7 @@ ;;;; Programmers: Kevin M. Rosenberg and onShore Development Inc ;;;; Date Started: Mar 2002 ;;;; -;;;; $Id: usql.cl,v 1.8 2002/05/19 16:26:06 kevin Exp $ +;;;; $Id: usql.cl,v 1.9 2002/05/27 17:19:31 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; and onShore Development Inc @@ -45,35 +45,6 @@ keyword argument :database specifies the database to query, defaulting to *default-database*." (database-attribute-type attribute table database)) -(defun add-attribute (table attribute &key (database *default-database*)) - "Add the ATTRIBUTE to TABLE. The ATTRIBUTE sepcification must -include a type argument. The optional keyword argument :database -specifies the database to operation on, defaulting to -*default-database*." - (database-add-attribute table attribute database)) - -(defun rename-attribute (table oldatt newname - &key (database *default-database*)) - (error "(rename-attribute ~a ~a ~a ~a) is not implemented" table oldatt newname database)) - - -(defclass %sql-expression () - ()) - -;; For SQL Identifiers of generic type -(defclass sql-ident (%sql-expression) - ((name - :initarg :name - :initform "NULL")) - (:documentation "An SQL identifer.")) - -(defmethod make-load-form ((sql sql-ident) &optional environment) - (declare (ignore environment)) - (with-slots (name) - sql - `(make-instance 'sql-ident :name ',name))) - - (defun create-sequence (name &key (database *default-database*)) (database-create-sequence name database)) @@ -83,51 +54,4 @@ specifies the database to operation on, defaulting to (defun sequence-next (name &key (database *default-database*)) (database-sequence-next name database)) -(defclass sql-value-exp (%sql-expression) - ((modifier - :initarg :modifier - :initform nil) - (components - :initarg :components - :initform nil)) - (:documentation - "An SQL value expression.") - ) - -(defclass sql-typecast-exp (sql-value-exp) - () - (:documentation - "An SQL typecast expression.") - ) -(defvar +null-string+ "NULL") - -(defvar *sql-stream* nil - "stream which accumulates SQL output") - -(defmethod output-sql ((expr %sql-expression) &optional - (database *default-database*)) - (declare (ignore database)) - (write-string +null-string+ *sql-stream*)) - -(defmethod sql-output ((expr t)) - (declare (ignore expr)) - "") - -(defmethod print-object ((self %sql-expression) stream) - (print-unreadable-object - (self stream :type t) - (write-string (sql-output self) stream))) - - -;; Methods for translating high-level table classes to low-level functions - -(defmethod database-list-attributes ((table sql-ident) database) - (database-list-attributes (string-downcase - (symbol-name (slot-value table 'name))) - database) - ) -(defmethod database-attribute-type (attribute (table sql-ident) database) - (database-attribute-type attribute (string-downcase - (symbol-name (slot-value table 'name))) - database))