r1670: updated mysql to handle :longlong field translation
[clsql.git] / interfaces / mysql / mysql-sql.cl
index 79bf774ea6a327928eed1357901d43646df8b1c6..9d14dc888b6c4dd3df4186cbc359281f6b4439e0 100644 (file)
@@ -8,7 +8,7 @@
 ;;;;                Original code by Pierre R. Mai 
 ;;;; Date Started:  Feb 2002
 ;;;;
-;;;; $Id: mysql-sql.cl,v 1.12 2002/03/27 04:33:19 kevin Exp $
+;;;; $Id: mysql-sql.cl,v 1.13 2002/03/27 05:37:35 kevin Exp $
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
@@ -73,6 +73,8 @@
               #.mysql-field-types#int24
               #.mysql-field-types#long)
              :int)
+            (#.mysql-field-types#longlong
+             :longlong)
             ((#.mysql-field-types#double
               #.mysql-field-types#float
               #.mysql-field-types#decimal)
     ((str (* :unsigned-char)))
   :returning :long)
 
+(uffi:def-function "atol64"
+    ((str (* :unsigned-char))
+     (high32 (* :int)))
+  :returning :int)
+
 (uffi:def-function "atof"
     ((str (* :unsigned-char)))
   :returning :double)
        (atol char-ptr))
       (:double
        (atof char-ptr))
+      (:longlong
+       (uffi:with-foreign-object (high32-ptr :int)
+        (let ((low32 (atol64 char-ptr high32-ptr))
+              (high32 (uffi:deref-pointer high32-ptr :int)))
+          (if (zerop high32)
+              low32
+              (mysql:make-64-bit-integer high32 low32)))))
       (otherwise
        (uffi:convert-from-foreign-string char-ptr)))))