* interfaces/mysql/mysql-sql.cl
Fixed type specifiers in ato* calls
+
+ * interfaces/mysql/clsql-mysql.c
+ * interfaces/mysql/mysql-sql.cl
+ Added atol64 function, :longlong translations
25 Mar 2002 Kevin Rosenberg (kevin@rosenberg.net)
* Programmer: Kevin M. Rosenberg
* Date Started: Mar 2002
*
- * $Id: clsql-mysql.c,v 1.1 2002/03/23 14:04:52 kevin Exp $
+ * $Id: clsql-mysql.c,v 1.2 2002/03/27 05:37:35 kevin Exp $
*
* This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
*
#define lower_32bits(int64) ((unsigned int) int64 & bitmask_32bits)
#define upper_32bits(int64) ((unsigned int) (int64 >> 32))
-DLLEXPORT
-unsigned int
-clsql_mysql_num_rows (MYSQL_RES* res, unsigned int* pHigh32)
-{
- my_ulonglong nRows = mysql_num_rows (res);
- *pHigh32 = upper_32bits(nRows);
- return lower_32bits(nRows);
-}
-
DLLEXPORT
unsigned int
clsql_mysql_affected_rows (MYSQL* res, unsigned int* pHigh32)
}
+/* Reads a 64-bit integer string, returns result as two 32-bit integers */
+
+DLLEXPORT
+unsigned int
+atol64 (const unsigned char* str, int* pHigh32)
+{
+ long long result = 0;
+ int minus = 0;
+
+ while (*str) {
+ int i = *str - '0';
+ if (i < 0 || i > 9) /* Non-numeric character -- quit */
+ break;
+ result = i + (10 * result);
+ str++;
+ }
+
+ *pHigh32 = upper_32bits(result);
+ return lower_32bits(result);
+}
+
;;;; Programmers: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: mysql-package.cl,v 1.5 2002/03/25 14:26:23 kevin Exp $
+;;;; $Id: mysql-package.cl,v 1.6 2002/03/27 05:37:35 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
#:mysql-info
#:mysql-info-string
#:mysql-data-seek
+
+ #:make-64-bit-integer
)
(:documentation "This is the low-level interface MySQL."))
;;;; 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
#.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)))))