[elephant-cvs] CVS elephant/src/db-clsql

ieslick ieslick at common-lisp.net
Sun Feb 4 04:34:56 UTC 2007


Update of /project/elephant/cvsroot/elephant/src/db-clsql
In directory clnet:/tmp/cvs-serv16382/src/db-clsql

Modified Files:
	sql-controller.lisp 
Log Message:
char to unsigned char fix in BDB; cleaned up modular serializer initialization in BDB and SQL backends and main protocol

--- /project/elephant/cvsroot/elephant/src/db-clsql/sql-controller.lisp	2007/02/02 23:51:58	1.14
+++ /project/elephant/cvsroot/elephant/src/db-clsql/sql-controller.lisp	2007/02/04 04:34:56	1.15
@@ -238,7 +238,7 @@
   ;; ALL OF THIS needs to be inside a transaction.
   (clsql::create-table [version]
 		       '(
-			 ([serializerversion] text :not-null)
+			 ([dbversion] text :not-null)
 			 ) :database con
 		       )
   )
@@ -313,34 +313,34 @@
    controller that is independant of the serializer as the
    serializer is dispatched based on the code version which is a
    list of the form '(0 6 0)"
-  (let* ((con (controller-db sc))
-	 (version (elephant::controller-version-cached sc)))
-    (if version version
-	(let ((tuples
-	       (clsql::select [serializerversion] 
-			      :from [version]
-			      :database con)))
-	  ;; The table should exists, but there may or may not be a record there...
-	  (setf (elephant::controller-version-cached sc)
-		(if tuples 
-		    (read-from-string (caar tuples))
-		    (clsql::insert-records :into [version]
-					   :attributes '(serializerversion)
-					   :values (list (format nil "~A" *elephant-code-version*))
-					   :database con)
-		    )
-		)))))
+  (let* ((con (controller-db sc)))
+    (let ((tuples
+	   (clsql::select [dbversion] 
+			  :from [version]
+			  :database con)))
+      ;; The table should exists, but there may or may not be a record there...
+      (if tuples 
+	  (read-from-string (caar tuples))
+	  nil))))
+
+(defun set-database-version (sc)
+  (let ((con (controller-db sc)))
+    (clsql::insert-records :into [version]
+			   :attributes '(dbversion)
+			   :values (list (format nil "~A" *elephant-code-version*))
+			   :database con)))
 
 
 (defmethod open-controller ((sc sql-store-controller)
 			    ;; At present these three have no meaning
 			    &key 
 			    (recover nil)
-			    (recover-fatal nil) 
+			    (recover-fatal nil)
 			    (thread t))
   (declare (ignore recover recover-fatal thread))
   (the sql-store-controller
     (let* ((dbtype (car (second (controller-spec sc))))
+	   (new-p (not (probe-file (cadr (second (controller-spec sc))))))
 	   (con (clsql:connect (cdr (second (controller-spec sc)))
 			       :database-type dbtype
 			       :if-exists :old)))
@@ -353,7 +353,9 @@
       (unless (version-table-exists con)
 	(with-transaction (:store-controller sc)
 	  (create-version-table con)))
-      (elephant::initialize-serializer sc)
+      ;; Set elephant version if new
+      (when new-p (set-database-version sc))
+      (initialize-serializer sc)
       ;; These should get oid 0 and 1 respectively 
       (setf (slot-value sc 'root) (make-instance 'sql-btree :sc sc :from-oid 0))
       (setf (slot-value sc 'class-root) (make-instance 'sql-btree :sc sc :from-oid 1))




More information about the Elephant-cvs mailing list