Re: [patch] with-database bug
Chaitanya Gupta <[email protected]> Thu, 31 May 2007 12:41:40 +0530
| Newsgroups | gmane.lisp.clsql.devel |
|---|---|
| Message-ID | <[email protected]> |
Kevin Rosenberg wrote: > Chaitanya Gupta wrote: >> This patch is for the bug reported in >> http://lists.b9.com/pipermail/clsql-help/2007-May/000823.html > > Thinking more about the report, and rereading the CLSQL documentation, > I don't think the reported behaviour is a bug since the report is > using 'nil' as the "A variable which is bound to the specified > database". > The problem is not just with using NIL as the variable to be bound. Even if you use *DEFAULT-DATABASE*, the problem still remains. CL-USER> (use-package :clsql) T CL-USER> (setf *default-database* nil) NIL CL-USER> (with-database (*default-database* *db-credentials* :database-type :postgresql-socket :if-exists :new) (format t "Outer WITH-DATABASE - ~S ~A~%" (database-type *default-database*) (slot-value *default-database* 'clsql-sys::state)) (with-database (*default-database* *db-credentials* :database-type :postgresql :if-exists :new) (format t "Inner WITH-DATABASE - ~S ~A~%" (database-type *default-database*) (slot-value *default-database* 'clsql-sys::state))) (format t "Outer WITH-DATABASE - ~S ~A~%" (database-type *default-database*) (slot-value *default-database* 'clsql-sys::state))) Outer WITH-DATABASE - :POSTGRESQL-SOCKET OPEN Inner WITH-DATABASE - :POSTGRESQL OPEN Outer WITH-DATABASE - :POSTGRESQL CLOSED NIL Note how the value of *DEFAULT-DATABASE* in the outer WITH-DATABASE changes before and after calling the inner WITH-DATABASE. I think that's certainly a bug. Plus this has another unintended side-effect: CL-USER> *default-database* #<CLSQL-POSTGRESQL-SOCKET:POSTGRESQL-SOCKET-DATABASE localhost/shared/chaitanya CLOSED @ #x10c6b4e2> *DEFAULT-DATABASE* at the toplevel is now bound to the outer WITH-DATABASE connection whereas it was previously NIL. Chaitanya