mysql - "mysql_set_character_set"是否将字节传输到MySQL服务器?

标签 mysql c driver libmysql

引用 MySQL 文档 - mysql_set_character_set() :

This function works like the SET NAMES statement, but also sets the value of mysql->charset, and thus affects the character set used by mysql_real_escape_string()

当它说“works like the SET NAMES statements”时,是否意味着实际 MySQL查询SET NAMES将被发送到服务器?

或者这是否意味着mysql_set_character_set的功能模仿查询SET NAMES但不会从网络发送实际的消息或数据服务器到数据库服务器?

最佳答案

来自the manual (我的重点):

SET NAMES 'charset_name' [COLLATE 'collation_name']

SET NAMES indicates what character set the client will use to send SQL statements to the server. Thus, SET NAMES 'cp1251' tells the server, “future incoming messages from this client are in character set cp1251.” It also specifies the character set that the server should use for sending results back to the client. (For example, it indicates what character set to use for column values if you use a SELECT statement.)

如果SET NAMES命令影响从服务器到客户端的通信中使用的字符集,则必须以某种方式将该字符集信息传输到服务器。

所以,是的。此函数调用将导致数据传输到服务器。

关于mysql - "mysql_set_character_set"是否将字节传输到MySQL服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26453967/

相关文章:

mysql - 如何添加引用同一个表的主键的外键约束(自引用)

c - 未定义的函数引用

c - 用户空间代码以什么顺序执行?

jdbc - Sqoop导入驱动程序问题:无法加载驱动程序

php - 我如何为 mysql 数据库中的每一行创建一个唯一的 php 页面

mysql存储过程-死锁会导致性能吗?

c - 使用 'memcpy' 函数

c - 浮点异常(核心转储)-c 程序

java - com.mongodb.DBPortPool 得到错误警告 : emptying DBPortPool to/IP:27017 b/c of error using spring MongoTemplate

php - MySQL查询只完成了80%的查询,为什么它漏掉了20%呢?