diff --git a/TODO b/TODO index f32c267ddcbe3afe4a067bd375a8340859ba29d2..f17c4ffa198fbdcf9dfe44c699abea5cbdca51c5 100644 --- a/TODO +++ b/TODO @@ -9,9 +9,13 @@ Cleanup: • Replace ASSERT with conditions. • Drop “mysql-” prefix from everything: this is a MySQL driver, so it's redundant. +• Replace qtest by 5am or stefil, etc. -Convenience +Convenience: • Convenience functions for toggling bits in status and capability. -Query Results +Query Results: • Row at a time result processing + +Good Citizenship: +• export AF_LOCAL functionality to usocket diff --git a/qmynd.asd b/qmynd.asd index b00f9b40608fdde76ffe137eec51f79248c6b302..a457f1159be3d937eb34f672c0adab36183252da 100644 --- a/qmynd.asd +++ b/qmynd.asd @@ -8,9 +8,7 @@ ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(in-package "CL-USER") - -(asdf:defsystem :qmynd +(defsystem :qmynd :name "MySQL Native Driver" :author "Alejandro Sedeño" :version "1.0" @@ -23,7 +21,8 @@ :ironclad :list-of :trivial-gray-streams - :usocket) + :usocket + #-asdf3 :uiop) :weakly-depends-on (:cl+ssl :chipz :salza2) :around-compile "asdf-finalizers:check-finalizers-around-compile" :serial nil @@ -87,6 +86,6 @@ (:file "prepared-statement" :depends-on ("binary-protocol-encoding")))))) (:file "api" - :depends-on ("mysql-protocol")))))) - -(pushnew :qmynd *features*) + :depends-on ("mysql-protocol"))))) + :in-order-to ((test-op (load-op :qmynd-test))) + :perform (test-op :after (o c) (funcall (read-from-string "qmynd-test::run-all-tests")))) diff --git a/src/api.lisp b/src/api.lisp index a8eda2c8c66e5d089f0ce10f4c29c5fc6e02d3a1..94896551d18f5472c16816b00ee837cb0cc42b62 100644 --- a/src/api.lisp +++ b/src/api.lisp @@ -11,7 +11,7 @@ (in-package :qmynd-impl) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Conncetion entry-point +;;; Connection entry-point (defun mysql-connect (&key (host "localhost") (port 3306) (username "") (password "") database (ssl :unspecified) ssl-verify) "Connect to a MySQL over a network (AF_INET) socket and begin the MySQL Handshake. Returns a QMYND:MYSQL-CONNECTION object or signals a QMYND:MYSQL-ERROR. diff --git a/src/common/date-time.lisp b/src/common/date-time.lisp index 5a455196970f6d21c0060018ca8df301538e6296..23a5718155db7632a1e799fd2a2201b175ac8a60 100644 --- a/src/common/date-time.lisp +++ b/src/common/date-time.lisp @@ -187,7 +187,7 @@ (defun parse-time-interval-string (str) "Parses the MySQL Text Protocol represetation of a time interval. /(-)?(h+):(mm):(ss).(µµµµµµ)/" - (let ((negativep (starts-with str "-"))) + (let ((negativep (string-prefix-p "-" str))) (multiple-value-bind (hours end) (parse-integer str :start (if negativep 1 0) :junk-allowed t) (multiple-value-bind (days hours) diff --git a/src/common/utilities.lisp b/src/common/utilities.lisp index a7875252f3890b4e391be077c0b485898624ffb8..c65b42bafaf4ed83b0eea9e36bfb563dfc962f7d 100644 --- a/src/common/utilities.lisp +++ b/src/common/utilities.lisp @@ -73,26 +73,6 @@ `(the fixnum (ldb ,bytespec (the fixnum ,value)))) -;;; String utilities - -(defun starts-with (string prefix &key (start 0)) - "Returns true if 'string' starts with the prefix 'prefix' (case insensitive)." - (and (i>= (length string) (i+ start (length prefix))) - (string-equal string prefix :start1 start :end1 (i+ start (length prefix))) - prefix)) - -(defun ends-with (string suffix &key (end (length string))) - "Returns true if 'string' ends with the prefix 'prefix' (case insensitive)." - (and (i>= end (length suffix)) - (string-equal string suffix :start1 (i- end (length suffix)) :end1 end) - suffix)) - -(defun strcat (&rest strings) - "Concatenate a bunch of strings." - (declare (dynamic-extent strings)) - (apply #'concatenate 'string strings)) - - ;;; Managing symbols (defmacro with-gensyms ((&rest bindings) &body body) @@ -130,36 +110,7 @@ (t nil))) -;;; Collectors, etc - -(defmacro with-collectors ((&rest collection-descriptions) &body body) - "'collection-descriptions' is a list of clauses of the form (coll function). - The body can call each 'function' to add a value to 'coll'. 'function' - runs in constant time, regardless of the length of the list." - (let ((let-bindings ()) - (flet-bindings ()) - (dynamic-extents ()) - (vobj '#:OBJECT)) - (dolist (description collection-descriptions) - (destructuring-bind (place name) description - (let ((vtail (make-symbol (format nil "~A-TAIL" place)))) - (setq dynamic-extents - (nconc dynamic-extents `(#',name))) - (setq let-bindings - (nconc let-bindings - `((,place ()) - (,vtail nil)))) - (setq flet-bindings - (nconc flet-bindings - `((,name (,vobj) - (setq ,vtail (if ,vtail - (setf (cdr ,vtail) (list ,vobj)) - (setf ,place (list ,vobj))))))))))) - `(let (,@let-bindings) - (flet (,@flet-bindings) - ,@(and dynamic-extents - `((declare (dynamic-extent ,@dynamic-extents)))) - ,@body)))) +;;; with-prefixed-accessors (defmacro with-prefixed-accessors (names (prefix object) &body body) `(with-accessors (,@(loop for name in names @@ -204,7 +155,7 @@ (let ((start 0) (sign 1) found-decimal) - (when (starts-with str "-") + (when (string-prefix-p "-" str) (setq start 1 sign -1)) (loop diff --git a/src/mysql-protocol/define-packet.lisp b/src/mysql-protocol/define-packet.lisp index 67e62cdf58fd8e44e81bacfc55c76c1f8479f996..10d9907705efbaeaf0989f26f7905a8a6d5866a2 100644 --- a/src/mysql-protocol/define-packet.lisp +++ b/src/mysql-protocol/define-packet.lisp @@ -250,9 +250,9 @@ Order of Operations: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Entry point macro (defmacro define-packet (name slots) - (let ((parser-name (fintern "PARSE-~A" name)) - (struct-name (fintern "~A-PACKET" name)) - (struct-constructor (fintern "MAKE-~A-PACKET" name)) + (let ((parser-name (fintern "~A-~A" 'parse name)) + (struct-name (fintern "~A-~A" name 'packet)) + (struct-constructor (fintern "~A-~A-~A" 'make name 'packet)) (slot-descriptors (mapcar #'parse-slot slots))) `(progn ;; Define a struct to hold non-transient data @@ -261,6 +261,6 @@ Order of Operations: ;; Define a parser to parse a payload of this form and populate the struct ,(emit-packet-parser parser-name struct-constructor slot-descriptors) ;; Define a writer to generate a packet payload of this type from the struct - #| Implement writer here |# + #| Implement writer here (only needed for servers, not for mere clients) |# ;; ',name))) diff --git a/src/mysql-protocol/handshake.lisp b/src/mysql-protocol/handshake.lisp index eb69a180fb4149390bcd2f1085a6399d174bc68c..84a3aa83e3777be748b1c17b783a1079d0be118b 100644 --- a/src/mysql-protocol/handshake.lisp +++ b/src/mysql-protocol/handshake.lisp @@ -110,7 +110,7 @@ stream)) (setf (mysql-connection-stream *mysql-connection*) stream))) -;; We don't actually receive a Handshake Response packet as a client, but it looks like this. +;; We won't receive a Handshake Response packet (being a client only, not a server), but it looks like this. ;; (define-packet handshake-response-v41 ;; ((capability-flags :mysql-type (integer 4)) diff --git a/src/pkgdcl.lisp b/src/pkgdcl.lisp index 0851e39cb323083fa93b9647a62b5acf02ef248b..1d74e38dd6d5ef9194263915b6ed1e4f5e015b6c 100644 --- a/src/pkgdcl.lisp +++ b/src/pkgdcl.lisp @@ -87,6 +87,9 @@ (defpackage qmynd-impl (:use :common-lisp :list-of :qmynd) + (:import-from :uiop + #:strcat + #:string-prefix-p) (:export ;; Dynamic Variables @@ -149,8 +152,7 @@ ;; Auth Stuff #:generate-auth-response - #+mysql-insecure-password-hash - #:mysql-weak-hash-password + #+mysql-insecure-password-hash #:mysql-weak-hash-password #:mysql-native-password-auth-response #:mysql-clear-password-auth-response diff --git a/tests/qmynd-test.asd b/tests/qmynd-test.asd index f21d1e263e56f031bb5b0e65111e951d4bc11c37..4637bc039febfa6baa945e69b78b7095ed5e16c7 100644 --- a/tests/qmynd-test.asd +++ b/tests/qmynd-test.asd @@ -8,9 +8,6 @@ ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(in-package "CL-USER") - - (asdf:defsystem :qmynd-test :name "MySQL Native Driver - Test Suite" :author "Alejandro Sedeño" @@ -30,7 +27,7 @@ :serial nil :pathname #p"" :depends-on ("packages") - :components ((:file "qtest"))) + :components (#-test-tools (:file "qtest"))) (:module "parsing" :serial nil :pathname #p"" @@ -42,5 +39,3 @@ :pathname #p"" :depends-on ("common") :components ((:file "binary-encoding"))))) - -(pushnew :cl-qmynd *features*)