X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=db-mysql%2Fmysql-api.lisp;h=1f747f93c4e870d92522578e71925a96e63f702a;hp=75ca09bb090c08982a9dfd6a3f9e0f0bc4136465;hb=eaea8232bda93fd38410e46dd22ec954b2fc4a18;hpb=9d560e5f0e74cc14db164dacf2033934d0be9a5b diff --git a/db-mysql/mysql-api.lisp b/db-mysql/mysql-api.lisp index 75ca09b..1f747f9 100644 --- a/db-mysql/mysql-api.lisp +++ b/db-mysql/mysql-api.lisp @@ -4,13 +4,11 @@ ;;;; ;;;; Name: mysql-api.lisp ;;;; Purpose: Low-level MySQL interface using UFFI -;;;; Programmers: Kevin M. Rosenberg based on -;;;; Original code by Pierre R. Mai +;;;; Programmers: Kevin M. Rosenberg based on +;;;; Original code by Pierre R. Mai ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id$ -;;;; -;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg +;;;; This file, part of CLSQL, is Copyright (c) 2002-2009 by Kevin M. Rosenberg ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software @@ -27,7 +25,7 @@ ;;;; that are used in a few routines. ;;;; - Removed all references to interiors of C-structions, this will ;;;; increase robustness when MySQL's internal structures change. - + ;;;; Type definitions ;;; Basic Types @@ -132,10 +130,10 @@ (decimals :unsigned-int) (type mysql-field-types)) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-struct mysql-field (name (* :char)) - (org_table (* :char)) + (org_name (* :char)) (table (* :char)) (org_table (* :char)) (db (* :char)) @@ -155,6 +153,7 @@ (charsetnr :unsigned-int) (type mysql-field-types)) + (uffi:def-struct mysql-time (year :unsigned-int) (month :unsigned-int) @@ -219,7 +218,7 @@ :read-default-group)) (uffi:def-enum mysql-status - (:ready + (:ready :get-result :use-result)) @@ -275,13 +274,13 @@ (handle (:struct-pointer mysql-mysql)) (eof mysql-bool)) -#+mysql-client-4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-enum mysql-field-types - (:ready + (:ready :get-result :use-result)) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-struct mysql-bind (length (* :unsigned-long)) (is-null (* mysql-bool)) @@ -305,17 +304,6 @@ (declaim (inline mysql-init)) (uffi:def-function "mysql_init" ((mysql (* mysql-mysql))) - :module "mysql" - :returning (* mysql-mysql)) - -#-mysql-client-v4 -(declaim (inline mysql-connect)) -#-mysql-client-v4 -(uffi:def-function "mysql_connect" - ((mysql (* mysql-mysql)) - (host :cstring) - (user :cstring) - (passwd :cstring)) :module "mysql" :returning (* mysql-mysql)) @@ -365,24 +353,6 @@ :module "mysql" :returning :int) -#-mysql-client-v4 -(declaim (inline mysql-create-db)) -#-mysql-client-v4 -(uffi:def-function "mysql_create_db" - ((mysql (* mysql-mysql)) - (db :cstring)) - :module "mysql" - :returning :int) - -#-mysql-client-v4 -(declaim (inline mysql-drop-db)) -#-mysql-client-v4 -(uffi:def-function "mysql_drop_db" - ((mysql (* mysql-mysql)) - (db :cstring)) - :module "mysql" - :returning :int) - (declaim (inline mysql-shutdown)) (uffi:def-function "mysql_shutdown" ((mysql (* mysql-mysql))) @@ -559,16 +529,16 @@ :module "clsql-mysql" :returning :unsigned-int) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-foreign-type mysql-stmt-ptr :pointer-void) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-function "mysql_stmt_init" ((res (* mysql-mysql-res))) :module "clsql-mysql" :returning mysql-stmt-ptr) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-function "mysql_stmt_prepare" ((stmt mysql-stmt-ptr) (query :cstring) @@ -576,70 +546,70 @@ :module "clsql-mysql" :returning :int) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-function "mysql_stmt_param_count" ((stmt mysql-stmt-ptr)) :module "clsql-mysql" :returning :unsigned-int) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-function "mysql_stmt_bind_param" ((stmt mysql-stmt-ptr) (bind (* mysql-bind))) :module "clsql-mysql" :returning :short) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-function "mysql_stmt_bind_result" ((stmt mysql-stmt-ptr) (bind (* mysql-bind))) :module "clsql-mysql" :returning :short) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-function "mysql_stmt_result_metadata" ((stmt mysql-stmt-ptr)) :module "clsql-mysql" :returning (* mysql-mysql-res)) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-function "mysql_stmt_execute" ((stmt mysql-stmt-ptr)) :module "clsql-mysql" :returning :int) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-function "mysql_stmt_store_result" ((stmt mysql-stmt-ptr)) :module "clsql-mysql" :returning :int) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-function "mysql_stmt_fetch" ((stmt mysql-stmt-ptr)) :module "clsql-mysql" :returning :int) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-function "mysql_stmt_free_result" ((stmt mysql-stmt-ptr)) :module "clsql-mysql" :returning :short) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-function "mysql_stmt_close" ((stmt mysql-stmt-ptr)) :module "clsql-mysql" :returning :short) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-function "mysql_stmt_errno" ((stmt mysql-stmt-ptr)) :module "clsql-mysql" :returning :unsigned-int) -#+mysql-client-v4.1 +#+(or mysql-client-v4.1 mysql-client-v5) (uffi:def-function "mysql_stmt_error" ((stmt mysql-stmt-ptr)) :module "clsql-mysql" @@ -654,10 +624,10 @@ (defun mysql-num-rows (res) (uffi:with-foreign-object (p-high32 :unsigned-int) (let ((low32 (clsql-mysql-num-rows res p-high32)) - (high32 (uffi:deref-pointer p-high32 :unsigned-int))) + (high32 (uffi:deref-pointer p-high32 :unsigned-int))) (if (zerop high32) - low32 - (make-64-bit-integer high32 low32))))) + low32 + (make-64-bit-integer high32 low32))))) (uffi:def-function "clsql_mysql_affected_rows" ((mysql (* mysql-mysql)) @@ -668,10 +638,10 @@ (defun mysql-affected-rows (mysql) (uffi:with-foreign-object (p-high32 :unsigned-int) (let ((low32 (clsql-mysql-affected-rows mysql p-high32)) - (high32 (uffi:deref-pointer p-high32 :unsigned-int))) + (high32 (uffi:deref-pointer p-high32 :unsigned-int))) (if (zerop high32) - low32 - (make-64-bit-integer high32 low32))))) + low32 + (make-64-bit-integer high32 low32))))) (uffi:def-function "clsql_mysql_insert_id" ((res (* mysql-mysql)) @@ -682,18 +652,18 @@ (defun mysql-insert-id (mysql) (uffi:with-foreign-object (p-high32 :unsigned-int) (let ((low32 (clsql-mysql-insert-id mysql p-high32)) - (high32 (uffi:deref-pointer p-high32 :unsigned-int))) + (high32 (uffi:deref-pointer p-high32 :unsigned-int))) (if (zerop high32) - low32 + low32 (make-64-bit-integer high32 low32))))) (declaim (inline mysql-num-fields)) -(uffi:def-function "mysql_num_fields" +(uffi:def-function "mysql_num_fields" ((res (* mysql-mysql-res))) :returning :unsigned-int :module "mysql") - + (declaim (inline clsql-mysql-eof)) (uffi:def-function ("mysql_eof" clsql-mysql-eof) ((res (* mysql-mysql-res)))