Included is a fix for fetch-all being affected by previous results and affecting previous results, as well as a couple of functions that map the field names to the field values of result sets, i.e. a row will look like '((field-name field-value) (... ...) (... ...) ...).
Just add the following to your mysql5.lsp file:
(define (fetch-all , all)
"Redefined fetch-all that is not affected by previous results, nor does it
affect future results."
(dotimes (x (num-rows)) (push (fetch-row) all))
(reverse all))
(import libmysqlclient "mysql_num_fields")
(define (num-fields)
"Evaluates the total number of fields for the current result."
(mysql_num_fields MYSQL_RES))
(import libmysqlclient "mysql_fetch_field")
(define (result-fields)
"Generates a list of strings reflecting the names of the fields in the
current result."
(let ((fields '()))
(dotimes (i (num-fields))
(push (get-string (get-int (mysql_fetch_field MYSQL_RES)))
fields -1)) fields))
(define (fetch-table)
"Creates a table associating field names with field values for the current
result. This will not work if the result has already been pulled another
way."
(letn ((rows (fetch-all)) (fields (result-fields))
(pair (lambda (row) (map list fields row))))
(map pair rows)))
Also, if you replace the (set 'libmysqlclient...) expression at the top with this:
(let ((lib-paths '("/usr/lib/libmysqlclient.so"
"/usr/local/mysql/lib/libmysqlclient.dylib"
"C:\mysql\lib\mysqlclient.dll")))
(dolist (lib lib-paths)
(if (file? lib) (set 'libmysqlclient lib))))
...the script will look in each of the lib-paths in turn to find the correct lib for your distro/os.