mysql-net / MySqlConnector

MySQL Connector for .NET
https://mysqlconnector.net
MIT License
1.39k stars 334 forks source link

Composite commands are not supported #774

Closed ich-wangxf closed 4 years ago

ich-wangxf commented 4 years ago

Sorry for my misunderstanding, DRDS(Distributed Relational Database Service) supports "transaction isolation level", but the following two commands need to be executed separately. Could you please help solve this problem?

Composite commands are not supported,need to separate "set transaction" from "start transaction"

using (var cmd = new MySqlCommand("set transaction isolation level " + isolationLevelValue + "; start transaction;", this))

@bgrainger

bgrainger commented 4 years ago

Executing those as separate commands would increase latency (and decrease performance) for databases that do support it, so I'd like it be opt in.

What does DRDS return from MySqlConnection.ServerVersion (after you've connected to it)?

ich-wangxf commented 4 years ago

Executing those as separate commands would increase latency (and decrease performance) for databases that do support it, so I'd like it be opt in.

What does DRDS return from MySqlConnection.ServerVersion (after you've connected to it)?

DRDS is a database middleware similar to MyCat, Has nothing to do with the specific MySQL database version.

When I use MySqlConnection to start a transaction, it returns "[ERR_PARSER] statement com.alibaba.fastsql.sql.ast.statement.SQLStartTransactionStatement not supported", So hope to executing those as separate commands through configuration @bgrainger

bgrainger commented 4 years ago

If DRDS is accepting the initial MySQL connection, then it will return some kind of server version string in the initial handshake packet it sends; this will be made available through MySqlConnection.ServerVersion.

ich-wangxf commented 4 years ago

If DRDS is accepting the initial MySQL connection, then it will return some kind of server version string in the initial handshake packet it sends; this will be made available through MySqlConnection.ServerVersion.

In fact, what I want to express is that DRDS is not a database product, it is a database middleware service product, so the final database server version may be MySQL 5.6.x or 5.7.x or ApsaraDB for PolarDB 8.0.X, ApsaraDB for PolarDB is a next-generation relational database service developed by Alibaba Cloud. It is compatible with MySQL

@bgrainger

ich-wangxf commented 4 years ago

If DRDS is accepting the initial MySQL connection, then it will return some kind of server version string in the initial handshake packet it sends; this will be made available through MySqlConnection.ServerVersion.

Can you set the transaction isolation level when creating a new connection, so that there will be no performance degradation, then this setting is set by options, default is false, such as in Server.Session ConnectAsync

@bgrainger

bgrainger commented 4 years ago

Per https://github.com/sysown/proxysql/issues/1728#issuecomment-427881636 this code should probably respect the CLIENT_MULTI_STATEMENTS flag (which ProxySQL may be clearing).

bgrainger commented 4 years ago

See https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/1043#issuecomment-600934232

ProxySQL doesn't clear the CLIENT_MULTI_STATEMENTS flag.

I don't know if DRDS or ApsaraDB for PolarDB do either.

bgrainger commented 4 years ago

@ich-wangxf Do you know if DRDS clears the CLIENT_MULTI_STATEMENTS flag in its initial handshake with a client? A Wireshark packet capture of a client connection to the server would show if it does or not (if you're able to capture and provide that).

bgrainger commented 4 years ago

Fixed in 0.64.0.

ich-wangxf commented 4 years ago

Oh thank you so much! @bgrainger