mysql5.lsp
Posted: Thu May 01, 2008 9:21 pm
Here is a diff for mysql5.lsp to run on amd64/Debian
I think it should go in other 64 bit systems. There is a two places in original file, where sizeof(int)=4 was assumed. They are changed to 8.
Enjoy ;-)
I think it should go in other 64 bit systems. There is a two places in original file, where sizeof(int)=4 was assumed. They are changed to 8.
Enjoy ;-)
Code: Select all
--- /usr/share/newlisp/modules/mysql5.lsp 2008-03-23 02:37:50.000000000 +0300
+++ mysql5-64.lsp 2008-05-02 01:16:28.000000000 +0400
@@ -122,11 +122,12 @@
; check endianess of the host CPU
(set 'big-endian (= (pack ">ld" 1) (pack "ld" 1)))
+(constant 'INT_SIZE 8) ; 4 for 32 bit, 8 for 64 bit
(constant 'NUM_ROWS_OFFSET (if big-endian 4 0))
-(constant 'NUM_FIELDS_OFFSET 60)
-(constant 'ERROR_OFFSET 85)
-(constant 'INSERT_ID_OFFSET (if big-endian 708 704))
-(constant 'AFFECTED_ROWS_OFFSET (if big-endian 700 696))
+(constant 'NUM_FIELDS_OFFSET 96)
+(constant 'ERROR_OFFSET 141)
+(constant 'INSERT_ID_OFFSET (if big-endian 708 832))
+(constant 'AFFECTED_ROWS_OFFSET (if big-endian 700 824))
;; @syntax (MySQL:init)
;; @return 'true' on success, 'nil' on failure.
@@ -185,7 +186,7 @@
; The field type is the 20th field of the MySQL_FIELD structure
; since fields 1-19 are all 4 byte fields we get the enum value
; like so
- (set 'data (get-int (int (+ type_ptr (* 19 4)))))
+ (set 'data (get-int (int (+ type_ptr (* 19 INT_SIZE)))))
; Consult 'enum_field_types' in mysql_com.h for values
(if (= data 1) ;; boolean
(get-string field_addr)
@@ -215,7 +216,7 @@
(begin
(set 'row '())
(dotimes (field (num-fields))
- (set 'field_addr (get-int (int (+ rdata (* field 4)))))
+ (set 'field_addr (get-int (int (+ rdata (* field INT_SIZE)))))
(if (= field_addr 0)
(push nil row -1) ;; what to do when the field contains NULL
(push (keep-type MYSQL_RES field_addr field) row -1)))