【原创】modb 功能设计之“支持部分MySQL客户端协议”-2


      在 《 
modb 功能设计之“支持多消费者单生产者” 》中说到:需要有一个单独的线程来处理 sql 语句。本文就针对“ 支持部分 MySQL 客户端协议”做第二部分讲述。主要是 MySQL 官网文档中关于 Connector/C 的研究。

首先看看有哪些资源:
1. MySQL 官网 【MySQL Connectors】->【Connector/C (libmysqlclient)

Connector/C (libmysqlclient) is a client library for C development.
官网对 MySQL Connector/C 的 完整文档描 述参考 这里 重点内容摘录翻译如下

===


22.5. MySQL Connector/C

      MySQL Connector/C 是一个客户端库,提供了用于客户端/服务器通信的 C API 。其可作为单独组件替代 MySQL Server 发布版本中带有的 MySQL 客户端库。

使用 MySQL Connector/C 的理由:

  • 如果你仅需要使用客户端库提供的功能,MySQL Connector/C 提供了你所需的一切。没有必要源码编译或安装 MySQL Server 包来获取相关功能。
  • MySQL Connector/C 不依赖 MySQL Server 的发布周期。bug 修复和新特特性添加均可独立于 MySQL Server 的发布。


22.5.1. MySQL Connector/C Versions

目前存在如下 MySQL Connector/C 版本:

  • MySQL Connector/C 6.1:基于当前(5.6)MySQL 源码中的 C API 部分生成,并且与 5.6 源码保持同步更新。
  • MySQL Connector/C 6.0:最初从 MySQL 的源码树分支上创建,但目前相较于那条源码树分支上的 C API 内容已经过时。
结论就是,MySQL Connector/C 6.1 当然优于 6.0 。MySQL Connector/C 6.1 已提供了如下 6.0 中不具备的功能特性:
  • 支持可插拔鉴权框架,即可以插件形式支持各种鉴权方法。该框架既可被用作 MySQL 本地鉴权方式,又可用作外部鉴权方式。
  • 支持客户端侧 SHA-256,PAM 和 Windows 本地鉴权插件。老的 Connector/C 6.0 仅能使用本地 MySQL 密码形式的账号信息来进行连接。如果客户端想要使用一种不同的鉴权方式的账户信息来进行连接,则会受到“当前用户访问被拒绝”的错误。
  • 支持 prepared CALL 语句,该功能使得客户端程序,能够在存储过程中处理,产生的多结果集,并获得最终的 OUT 和 INOUT 存储过程参数值。
  • 支持 IPv6 连接。
  • 支持在连接时,将客户端程序与指定 IP 地址进行绑定。
  • 支持在连接时,指定连接属性来告之服务器端。


22.5.2. MySQL Connector/C Supported Platforms

表中给出了 MySQL Connector/C 已经测试过的平台。
Table 22.28. Supported Platforms for MySQL Connector/C 6.1

Platform
Versions
Windows
Windows Vista, Server 2008, Server 2012, 7, 8
Linux
Oracle and RHEL 5, 6; SuSE LES 11; CentOS 5, 6; Fedora 15, 16; OpenSuSE 12.1; Debian 6; Ubuntu 12.04; generic glibc 2.5-based Linux systems
Solaris
10, 11
Mac OS X
10.6, 10.7
FreeBSD
9

Table 22.29. Supported Platforms for MySQL Connector/C 6.0.2
Platform
Versions
Windows
Windows 2000, XP, Vista, Server 2003, Server 2008
Linux
RHEL 4, 5; SuSE LES 9, 10; generic glibc 2-based Linux systems
Solaris
8, 9, 10
Mac OS X
10.4, 10.5
FreeBSD
6, 7
HP-UX
11.11, 11.23, 11.31
IBM AIX    
5.3


22.5.3. MySQL Connector/C Distribution Contents

MySQL Connector/C 6.1 distributions contain the header, library, and utility files necessary to build MySQL client applications that communicate with MySQL Server using the C API.

Distributions are available in binary and source formats. A binary distribution contains the header, library, and utility components discussed following, compiled and ready for use in writing client programs. A source distribution contains the source files required to produce the same headers, libraries, and utilities included in a binary distribution, but you compile them yourself.

MySQL Connector/C 分布包中包含如下组件:

A set of .h header files that C applications include at compile time. These files are located in the include directory.

Static and dynamic libraries that C applications link to at link time. These libraries are located in the lib directory. The library names depend on the library type and platform for which a distribution is built:

Unix(以及 Unix-like)平台上,静态库为 libmysqlclient.a ,动态库为 libmysqlclient.so

Windows 平台上,静态库为 mysqlclient.lib ,动态库为 libmysql.dll 。动态库对应的静态导入库为 libmysql.lib 。相应 debug 版本的库在 lib/debug 目录下可以找到。

一些小实用程序。


【22.8.4.1. Building C API Client Programs】

编译 MS Windows 上的 MySQL 客户端程序

  • 指定头文件和库文件所在位置。
  • 需要额外链接库:ws2_32 和 Secur32 。
  • 需要链接静态库(mysqlclient.lib)或者动态库(libmysql.dll)。

链接静态库时,需要注意:

  • 客户端应用程序必须使用,与库编译时相同的 VS 版本进行编译。
  • 客户端应用程序应该使用编译选项 /MT 来静态链接 C 运行时库。

      如果客户端应用程序以 debug 模式构建,并且使用了静态 debug C 运行时库(编译选项为 /MTd ),其可以链接到静态库 mysqlclient.lib ,当且仅当库是采用同样的编译选项编译时。如果客户端应用程序使用动态 C 运行时库(编译选项为 /MD 或者 debug 模式的 /MDd),则必须链接到 libmysql.dll 动态库上,此时不可链接到静态库上。

===


Changes in MySQL Connector/C 6.0】 
Changes in MySQL Connector/C 6.1】 

Changes in MySQL Connector/C 6.1.2 (2013-09-30)

添加或者改变的功能:

      专门针对 Windows XP 和 Windows Server 2003 的条件变量实现已从源码中移除,因为 MySQL 5.6 决定不在提供上述平台的支持。

注意:上述该表应该做如下理解:Connector/C 6.1 尽管在之前没有被官方声明支持 Windows XP 或 Windows Server 2003,但是确实在上述平台是可用的。但从 6.1.2 版本开始已经不行了。

MySQL 现已支持协议跟踪插件的使用。

      通过 VS2008、VS2010、VS2012 生成的静态库现已作为 Windows 平台 Connector/C 包的一部分一同发布。在 lib 目录下的 vs9、vs10 和 vs11 分别包含了使用 VS2008、VS2010、VS2012 构建的静态库和相应的 pdb 文件。


=== 未完待续 ===

转载于:https://my.oschina.net/moooofly/blog/186234

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值