File: mysql-client-info.lisp

package info (click to toggle)
cl-sql 6.7.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 3,552 kB
  • sloc: lisp: 24,508; xml: 17,898; makefile: 487; ansic: 201; sh: 39; cpp: 9
file content (50 lines) | stat: -rw-r--r-- 2,033 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
;;;; Name:          mysql-client-info.lisp
;;;; Purpose:       Check mysql client version
;;;; Programmer:    Kevin M. Rosenberg
;;;; Date Started:  April 2004
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
;;;;
;;;; CLSQL users are granted the rights to distribute and use this software
;;;; as governed by the terms of the Lisp Lesser GNU Public License
;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
;;;; *************************************************************************

(in-package #:mysql)

(declaim (inline mysql-get-client-info))

(defvar *mysql-client-info* nil)

(eval-when (:compile-toplevel :load-toplevel :execute)
  (uffi:def-function ("mysql_get_client_info" mysql-get-client-info)
      ()
    :module "mysql"
    :returning :cstring)

  (setf *mysql-client-info* (uffi:convert-from-cstring (mysql-get-client-info)))


  (when (and (stringp *mysql-client-info*)
             (plusp (length *mysql-client-info*)))
    (cond
      ((eql (schar *mysql-client-info* 0) #\3)
       (pushnew :mysql-client-v3 cl:*features*))
      ((eql (schar *mysql-client-info* 0) #\4)
       (pushnew :mysql-client-v4 cl:*features*)
       (when (and (>= (length *mysql-client-info*) 3)
                  (string-equal "4.1" *mysql-client-info* :end2 3))
         (pushnew :mysql-client-v4.1 cl:*features*)))
      ((eql (schar *mysql-client-info* 0) #\5)
       (pushnew :mysql-client-v5 cl:*features*)
       (when (and (>= (length *mysql-client-info*) 3)
                  (string-equal "5.1" *mysql-client-info* :end2 3))
         (pushnew :mysql-client-v5.1 cl:*features*)))
      ((eql (schar *mysql-client-info* 0) #\6)
       (pushnew :mysql-client-v6 cl:*features*))
      (t
       (format t "Warning: Unknown mysql client version '~A', verify proper operation." *mysql-client-info*)))))