projects
/
clsql.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r1901: updated with-database and connect/disconnect functions to work better with...
[clsql.git]
/
sql
/
sql.cl
diff --git
a/sql/sql.cl
b/sql/sql.cl
index f5eebd730768fe4ee6e75670b1a4fd2d0daa365c..310001eb221defd1860adb513c293d640fd3ff81 100644
(file)
--- a/
sql/sql.cl
+++ b/
sql/sql.cl
@@
-8,7
+8,7
@@
;;;; Original code by Pierre R. Mai
;;;; Date Started: Feb 2002
;;;;
;;;; Original code by Pierre R. Mai
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: sql.cl,v 1.1
3 2002/04/27 20:58:11 kevin
Exp $
+;;;; $Id: sql.cl,v 1.1
5 2002/05/03 20:50:18 marc.battyani
Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
@@
-76,8
+76,6
@@
initialized, as indicated by `*initialized-database-types*'."
(defvar *default-database* nil
"Specifies the default database to be used.")
(defvar *default-database* nil
"Specifies the default database to be used.")
-
-
(defun find-database (database &optional (errorp t))
(etypecase database
(database
(defun find-database (database &optional (errorp t))
(etypecase database
(database
@@
-98,17
+96,20
@@
initialized, as indicated by `*initialized-database-types*'."
(database-type *default-database-type*)
(pool nil))
"Connects to a database of the given database-type, using the type-specific
(database-type *default-database-type*)
(pool nil))
"Connects to a database of the given database-type, using the type-specific
-connection-spec. if-exists is currently ignored."
+connection-spec. if-exists is currently ignored.
+If pool is t the the connection will be taken from the general pool,
+if pool is a conn-pool object the connection will be taken from this pool.
+"
(let* ((db-name (database-name-from-spec connection-spec database-type))
(let* ((db-name (database-name-from-spec connection-spec database-type))
- (old-db (
find-database db-name nil
))
+ (old-db (
unless (eq if-exists :new) (find-database db-name nil)
))
(result nil))
(if pool
(result nil))
(if pool
- (setq result (acquire-from-pool connection-spec database-type))
+ (setq result (acquire-from-pool connection-spec database-type
pool
))
(if old-db
(case if-exists
(if old-db
(case if-exists
-
(:new
-
(setq result
-
(database-connect connection-spec database-type)))
+
;
(:new
+
;
(setq result
+
;
(database-connect connection-spec database-type)))
(:warn-new
(setq result
(database-connect connection-spec database-type))
(:warn-new
(setq result
(database-connect connection-spec database-type))
@@
-136,11
+137,11
@@
connection-spec. if-exists is currently ignored."
result)))
result)))
-(defun disconnect (&key (database *default-database*)
- (pool nil))
+(defun disconnect (&key (database *default-database*))
"Closes the connection to database. Resets *default-database* if that
"Closes the connection to database. Resets *default-database* if that
-database was disconnected and only one other connection exists."
- (if pool
+database was disconnected and only one other connection exists.
+if the database is from a pool it will be released to this pool."
+ (if (conn-pool database)
(release-to-pool database)
(when (database-disconnect database)
(setq *connected-databases* (delete database *connected-databases*))
(release-to-pool database)
(when (database-disconnect database)
(setq *connected-databases* (delete database *connected-databases*))