X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-mysql%2Fmysql-api.lisp;h=31828ca296dd99449ddf35ab19371e36bda7edbb;hb=31507a81fff1da3460625fbc07107de931907a8e;hp=b3220b7bc99a44b72041cdc3bebe6e5191f3ebca;hpb=adbb571cf319c49f1cad47f22c83982b5253d4b5;p=clsql.git diff --git a/db-mysql/mysql-api.lisp b/db-mysql/mysql-api.lisp index b3220b7..31828ca 100644 --- a/db-mysql/mysql-api.lisp +++ b/db-mysql/mysql-api.lisp @@ -33,7 +33,7 @@ ;;; Basic Types (uffi:def-foreign-type mysql-socket :int) -(uffi:def-foreign-type mysql-bool :char) +(uffi:def-foreign-type mysql-bool :byte) (uffi:def-foreign-type mysql-byte :unsigned-char) (uffi:def-enum mysql-net-type @@ -104,13 +104,10 @@ (:long-blob 251) (:blob 252) (:var-string 253) - (:string 254))) + (:string 254) + (:geometry 255))) -#-(or :mysql-client-v3 :mysql-client-v4) -(eval-when (:compile-toplevel :load-toplevel :execute) - (pushnew :mysql-client-v3 cl:*features*)) - -#+:mysql-client-v3 +#+mysql-client-v3 (uffi:def-struct mysql-field (name (* :char)) (table (* :char)) @@ -122,17 +119,40 @@ (decimals :unsigned-int)) ;; structure changed in mysql 4 client -#+:mysql-client-v4 +#+(and mysql-client-v4 (not mysql-client-v4.1)) (uffi:def-struct mysql-field (name (* :char)) (table (* :char)) (org_table (* :char)) (db (* :char)) (def (* :char)) - (length :unsigned-int) - (max-length :unsigned-int) + (length :unsigned-long) + (max-length :unsigned-long) + (flags :unsigned-int) + (decimals :unsigned-int) + (type mysql-field-types)) + +#+mysql-client-v4.1 +(uffi:def-struct mysql-field + (name (* :char)) + (org_table (* :char)) + (table (* :char)) + (org_table (* :char)) + (db (* :char)) + (catalog_db (* :char)) + (def (* :char)) + (length :unsigned-long) + (max-length :unsigned-long) + (name-length :unsigned-int) + (org-name-length :unsigned-int) + (table-length :unsigned-int) + (org-table-length :unsigned-int) + (db-length :unsigned-int) + (catalog-length :unsigned-int) + (def-length :unsigned-int) (flags :unsigned-int) (decimals :unsigned-int) + (charsetnr :unsigned-int) (type mysql-field-types)) ;;; MYSQL-ROWS @@ -244,6 +264,32 @@ (handle (:struct-pointer mysql-mysql)) (eof mysql-bool)) +#+mysql-client-4.1 +(uffi:def-enum mysql-field-types + (:ready + :get-result + :use-result)) + +#+mysql-client-v4.1 +(uffi:def-struct mysql-bind + (length (* :unsigned-long)) + (is-null (* mysql-bool)) + (buffer :pointer-void) + (buffer-type :int) + (buffer-length :unsigned-long) + ;; internal use + (inter_buffer (* :unsigned-char)) + (offset :unsigned-long) + (internal-length :unsigned-long) + (param-number :unsigned-int) + (pack-length :unsigned-int) + (is-signed mysql-bool) + (long-data-used mysql-bool) + (internal-is-null mysql-bool) + (store-param-func :pointer-void) + (fetch-result :pointer-void) + (skip-result :pointer-void)) + ;;;; The Foreign C routines (declaim (inline mysql-init)) (uffi:def-function "mysql_init" @@ -264,7 +310,7 @@ ;; Need to comment this out for LW 4.2.6 ;; ? bug in LW version -;;(declaim (inline mysql-real-connect)) +#-lispworks (declaim (inline mysql-real-connect)) (uffi:def-function "mysql_real_connect" ((mysql (* mysql-mysql)) (host :cstring) @@ -273,7 +319,7 @@ (db :cstring) (port :unsigned-int) (unix-socket :cstring) - (clientflag :unsigned-int)) + (clientflag :unsigned-long)) :module "mysql" :returning (* mysql-mysql)) @@ -370,12 +416,6 @@ :module "mysql" :returning :cstring) -(declaim (inline mysql-get-client-info)) -(uffi:def-function "mysql_get_client_info" - () - :module "mysql" - :returning :cstring) - (declaim (inline mysql-get-host-info)) (uffi:def-function "mysql_get_host_info" ((mysql (* mysql-mysql))) @@ -508,6 +548,86 @@ :module "clsql-mysql" :returning :unsigned-int) +#+mysql-client-v4.1 +(uffi:def-foreign-type mysql-stmt-ptr :pointer-void) + +#+mysql-client-v4.1 +(uffi:def-function "mysql_stmt_init" + ((res (* mysql-mysql-res))) + :module "clsql-mysql" + :returning mysql-stmt-ptr) + +#+mysql-client-v4.1 +(uffi:def-function "mysql_stmt_prepare" + ((stmt mysql-stmt-ptr) + (query :cstring) + (length :unsigned-long)) + :module "clsql-mysql" + :returning :int) + +#+mysql-client-v4.1 +(uffi:def-function "mysql_stmt_param_count" + ((stmt mysql-stmt-ptr)) + :module "clsql-mysql" + :returning :unsigned-int) + +#+mysql-client-v4.1 +(uffi:def-function "mysql_stmt_bind_param" + ((stmt mysql-stmt-ptr) + (bind (* mysql-bind))) + :module "clsql-mysql" + :returning :short) + +#+mysql-client-v4.1 +(uffi:def-function "mysql_stmt_bind_result" + ((stmt mysql-stmt-ptr) + (bind (* mysql-bind))) + :module "clsql-mysql" + :returning :short) + +#+mysql-client-v4.1 +(uffi:def-function "mysql_stmt_result_metadata" + ((stmt mysql-stmt-ptr)) + :module "clsql-mysql" + :returning (* mysql-mysql-res)) + + +#+mysql-client-v4.1 +(uffi:def-function "mysql_stmt_execute" + ((stmt mysql-stmt-ptr)) + :module "clsql-mysql" + :returning :int) + +#+mysql-client-v4.1 +(uffi:def-function "mysql_stmt_fetch" + ((stmt mysql-stmt-ptr)) + :module "clsql-mysql" + :returning :int) + +#+mysql-client-v4.1 +(uffi:def-function "mysql_stmt_free_result" + ((stmt mysql-stmt-ptr)) + :module "clsql-mysql" + :returning :short) + +#+mysql-client-v4.1 +(uffi:def-function "mysql_stmt_close" + ((stmt mysql-stmt-ptr)) + :module "clsql-mysql" + :returning :short) + +#+mysql-client-v4.1 +(uffi:def-function "mysql_stmt_errno" + ((stmt mysql-stmt-ptr)) + :module "clsql-mysql" + :returning :unsigned-int) + +#+mysql-client-v4.1 +(uffi:def-function "mysql_stmt_error" + ((stmt mysql-stmt-ptr)) + :module "clsql-mysql" + :returning :cstring) + ;;;; Equivalents of C Macro definitions for accessing various fields ;;;; in the internal MySQL Datastructures @@ -603,7 +723,6 @@ :module "clsql-mysql" :returning :void) - (defun mysql-data-seek (res offset) (multiple-value-bind (high32 low32) (split-64-bit-integer offset) (clsql-mysql-data-seek res high32 low32)))