r5073: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 8 Jun 2003 12:48:55 +0000 (12:48 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 8 Jun 2003 12:48:55 +0000 (12:48 +0000)
db-mysql/mysql-api.lisp
db-mysql/mysql-sql.lisp
uffi/clsql-uffi.lisp

index 85631ea3d1d7c5b7a43cd5235f9a3f86aff5a30a..c14cb7d0f2c5afe321d30370fc723b5de46bdd7c 100644 (file)
@@ -8,7 +8,7 @@
 ;;;;                Original code by Pierre R. Mai 
 ;;;; Date Started:  Feb 2002
 ;;;;
-;;;; $Id: mysql-api.lisp,v 1.2 2003/05/17 07:27:15 kevin Exp $
+;;;; $Id: mysql-api.lisp,v 1.3 2003/06/08 12:48:55 kevin Exp $
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
 ;;;; *************************************************************************
 
-(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
+(eval-when (:compile-toplevel)
+  (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0))))
 
-(in-package :mysql)
+(in-package #:mysql)
 
 ;;;; Modifications from original code
 ;;;;  - Updated C-structures to conform to structures in MySQL 3.23.46
index 5f834ea7c23fb8df733cce70fe231fe6b431a6e9..fee81b5c7822272ce81115ae8b147b13abb604df 100644 (file)
@@ -8,7 +8,7 @@
 ;;;;                Original code by Pierre R. Mai 
 ;;;; Date Started:  Feb 2002
 ;;;;
-;;;; $Id: mysql-sql.lisp,v 1.4 2003/04/16 21:50:01 kevin Exp $
+;;;; $Id: mysql-sql.lisp,v 1.5 2003/06/08 12:48:55 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,8 @@
 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
 ;;;; *************************************************************************
 
-(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
+(eval-when (:compile-toplevel)
+  (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0))))
 
 ;;;; Modified by Kevin Rosenberg, Feb 20002
 ;;;; -- Added support for Allegro CL and Lispworks using UFFI layer
 ;;;; Mar 2002
 ;;;; Added field types
 
-(defpackage :clsql-mysql
+(defpackage #:clsql-mysql
     (:use #:common-lisp #:clsql-base-sys #:mysql #:clsql-uffi)
     (:export #:mysql-database)
     (:documentation "This is the CLSQL interface to MySQL."))
 
-(in-package :clsql-mysql)
+(in-package #:clsql-mysql)
 
 ;;; Field conversion functions
 
 
 (defmethod database-query (query-expression (database mysql-database) 
                           types)
-  (with-slots (mysql-ptr) database
+  (declare (optimize (speed 3) (safety 0) (debug 0) (space 0)))
+  (let ((mysql-ptr (database-mysql-ptr database)))
     (uffi:with-cstring (query-native query-expression)
-       (if (zerop (mysql-query mysql-ptr query-native))
-          (let ((res-ptr (mysql-use-result mysql-ptr)))
-            (if res-ptr
-                (unwind-protect
-                     (let ((num-fields (mysql-num-fields res-ptr)))
-                       (setq types (canonicalize-types 
-                                    types num-fields
-                                    res-ptr))
-                       (loop for row = (mysql-fetch-row res-ptr)
-                             until (uffi:null-pointer-p row)
-                             collect
-                             (loop for i from 0 below num-fields
-                                   collect
-                                   (convert-raw-field
-                                    (uffi:deref-array row '(:array (* :unsigned-char)) i)
-                                    types i))))
-                  (mysql-free-result res-ptr))
-              (error 'clsql-sql-error
-                     :database database
-                     :expression query-expression
-                     :errno (mysql-errno mysql-ptr)
-                     :error (mysql-error-string mysql-ptr))))
-        (error 'clsql-sql-error
-               :database database
-               :expression query-expression
-               :errno (mysql-errno mysql-ptr)
-               :error (mysql-error-string mysql-ptr))))))
+      (if (zerop (mysql-query mysql-ptr query-native))
+         (let ((res-ptr (mysql-use-result mysql-ptr)))
+           (if res-ptr
+               (unwind-protect
+                    (let ((num-fields (mysql-num-fields res-ptr)))
+                      (declare (fixnum num-fields))
+                      (setq types (canonicalize-types 
+                                   types num-fields
+                                   res-ptr))
+                      (loop for row = (mysql-fetch-row res-ptr)
+                            until (uffi:null-pointer-p row)
+                            collect
+                            (loop for i fixnum from 0 below num-fields
+                                  collect
+                                  (convert-raw-field
+                                   (uffi:deref-array row '(:array
+                                                           (* :unsigned-char))
+                                                     i)
+                                   types i))))
+                 (mysql-free-result res-ptr))
+               (error 'clsql-sql-error
+                      :database database
+                      :expression query-expression
+                      :errno (mysql-errno mysql-ptr)
+                      :error (mysql-error-string mysql-ptr))))
+         (error 'clsql-sql-error
+                :database database
+                :expression query-expression
+                :errno (mysql-errno mysql-ptr)
+                :error (mysql-error-string mysql-ptr))))))
 
 (defmethod database-execute-command (sql-expression (database mysql-database))
   (uffi:with-cstring (sql-native sql-expression)
index 41d38b0a88ba98c3bbd9b211e22f6e255b76b818..aa62e6c993c27b3181c47f89effa75847acddedc 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmers:   Kevin M. Rosenberg
 ;;;; Date Started:  Mar 2002
 ;;;;
-;;;; $Id: clsql-uffi.lisp,v 1.29 2003/06/06 21:59:09 kevin Exp $
+;;;; $Id: clsql-uffi.lisp,v 1.30 2003/06/08 12:48:55 kevin Exp $
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
 
 (defun canonicalize-type-list (types auto-list)
   "Ensure a field type list meets expectations"
-  (let ((length-types (length types))
-       (new-types '()))
-    (loop for i from 0 below (length auto-list)
-         do
-         (if (>= i length-types)
-             (push t new-types) ;; types is shorted than num-fields
-             (push
-              (case (nth i types)
-                (:int
-                 (case (nth i auto-list)
-                   (:int32
-                    :int32)
-                   (:int64
-                    :int64)
-                   (t
-                    t)))
-                (:double
-                 (case (nth i auto-list)
-                   (:double
-                    :double)
-                   (t
-                    t)))
-                (:int32
-                 (if (eq :int32 (nth i auto-list))
-                     :int32
-                   t))
-                (:int64
-                 (if (eq :int64 (nth i auto-list))
-                     :int64
-                   t))
-                (t
-                 t))
-              new-types)))
-    (nreverse new-types)))
+  (declaim (optimize (speed 3) (safety 0)))
+  (do ((i 0 (1+ i))
+       (new-types '())
+       (length-types (length types))
+       (length-auto-list (length auto-list)))
+      ((= i length-auto-list)
+       (nreverse new-types))
+    (declaim (fixnum length-types length-auto-list i))
+    (if (>= i length-types)
+       (push t new-types) ;; types is shorted than num-fields
+       (push
+        (case (nth i types)
+          (:int
+           (case (nth i auto-list)
+             (:int32
+              :int32)
+             (:int64
+              :int64)
+             (t
+              t)))
+          (:double
+           (case (nth i auto-list)
+             (:double
+              :double)
+             (t
+              t)))
+          (:int32
+           (if (eq :int32 (nth i auto-list))
+               :int32
+               t))
+          (:int64
+           (if (eq :int64 (nth i auto-list))
+               :int64
+               t))
+          (t
+           t))
+        new-types))))
 
 (uffi:def-function "atoi"
     ((str (* :unsigned-char)))
@@ -77,7 +80,7 @@
 (uffi:def-constant +2^32-1+ (1- +2^32+))
 
 (defmacro make-64-bit-integer (high32 low32)
-  `(+ ,low32 (* ,high32 +2^32+)))
+  `(+ ,low32 (ash ,high32 32)))
 
 (defmacro split-64-bit-integer (int64)
   `(values (ash ,int64 -32) (logand ,int64 +2^32-1+)))
@@ -93,6 +96,7 @@
                   (uffi:deref-pointer char-ptr :char))))
     
 (defun convert-raw-field (char-ptr types index)
+  (declare (optimize (speed 3) (safety 0) (space 0)))
   (let ((type (if (listp types)
                  (nth index types)
                  types)))