r7061: initial property settings
[umlisp.git] / create-sql.lisp
index e81440d1c51be43f40025f82598bdd06c9830ade..f842eb21af84ca166f342766430180db7e7c01fc 100644 (file)
@@ -7,10 +7,10 @@
 ;;;; Author:        Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
-;;;; $Id: create-sql.lisp,v 1.1 2003/05/07 21:57:06 kevin Exp $
+;;;; $Id$
 ;;;;
 ;;;; This file, part of UMLisp, is
-;;;;    Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
+;;;;    Copyright (c) 2000-2003 by Kevin M. Rosenberg, M.D.
 ;;;;
 ;;;; UMLisp users are granted the rights to distribute and use this software
 ;;;; as governed by the terms of the GNU General Public License.
@@ -18,9 +18,6 @@
 
 (in-package #:umlisp)
 
-(eval-when (:compile-toplevel)
-  (declaim (optimize (speed 3) (safety 1) (compilation-speed 0) (debug 3))))
-
 (defun create-table-cmd (file)
   "Return sql command to create a table"
   (let ((col-func 
@@ -49,8 +46,9 @@
   "Return sql insert command for a row of values"  
   (let ((insert-func
         (lambda (col value)
-          (let ((q (quotechar col)))
-            (concatenate 'string q (insert-col-value col value) q)))))
+          (concatenate 'string (quote-str col)
+                       (insert-col-value col value)
+                       (quote-str col)))))
     (format
      nil "INSERT INTO ~a (~{~a~^,~}) VALUES (~A)"
      (table file)
@@ -65,8 +63,9 @@
   (let ((custom-value (funcall (custom-value-fun col) values)))
     (if custom-value
        (if doquote
-           (let ((q (quotechar col)))
-             (concatenate 'string q (escape-backslashes custom-value) q))
+           (concatenate 'string (quote-str col)
+                        (escape-backslashes custom-value)
+                        (quote-str col))
            (escape-backslashes custom-value))
        "")))
 
                 conn)))
 
 (defun sql-create-special-tables (conn)
-  (make-usrl conn))
+  (make-usrl conn)
+  (make-ustats))
 
 (defun create-umls-db-by-insert ()
   "SQL Databases: initializes entire database via SQL insert commands"
-  (ensure-init-umls)
-  (init-hash-table)
+  (ensure-ucols+ufiles)
+  (ensure-preparse)
   (with-sql-connection (conn)
     (sql-drop-tables conn)
     (sql-create-tables conn)
                       (copy-cmd #'mysql-copy-cmd))
   "SQL Databases: initializes entire database via SQL copy commands. 
 This is much faster that using create-umls-db-insert."
-  (ensure-init-umls)
-  (init-hash-table)
+  (ensure-ucols+ufiles)
+  (ensure-preparse)
   (translate-all-files extension)
   (with-sql-connection (conn)
     (sql-drop-tables conn)
@@ -190,7 +190,8 @@ This is much faster that using create-umls-db-insert."
 (defun translate-all-files (&optional (extension ".trans"))
   "Copy translated files and return postgresql copy commands to import"
   (make-noneng-index-file extension)
-  (dolist (f *umls-files*) (translate-umls-file f extension)))
+  (dolist (f (remove "MRXW.NONENG" *umls-files* :test #'string= :key #'fil))
+    (translate-umls-file f extension)))
 
 (defun translate-umls-file (file extension)
   "Translate a umls file into a format suitable for sql copy cmd"
@@ -274,7 +275,7 @@ This is much faster that using create-umls-db-insert."
            (nreverse avoidable) (nreverse unavoidable))))
 
 (defun display-waste ()
-  (ensure-init-umls)
+  (ensure-ucols+ufiles)
   (multiple-value-bind (tw ta tu al ul) (umls-fixed-size-waste)
     (format t "Total waste: ~d~%" tw)
     (format t "Total avoidable: ~d~%" ta)
@@ -290,7 +291,7 @@ This is much faster that using create-umls-db-insert."
 (defun max-umls-field ()
   "Return length of longest field"
   (declare (optimize (speed 3) (space 0)))
-  (ensure-init-umls)
+  (ensure-ucols+ufiles)
   (let ((max 0))
     (declare (fixnum max))
     (dolist (ucol *umls-cols*)
@@ -301,7 +302,7 @@ This is much faster that using create-umls-db-insert."
 (defun max-umls-row ()
   "Return length of longest row"
   (declare (optimize (speed 3) (space 0)))
-  (ensure-init-umls)
+  (ensure-ucols+ufiles)
   (let ((rowsizes '()))
     (dolist (file *umls-files*)
       (let ((row 0))