This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 6ac990bdaf2 [fix](protocol) only return multi result when
CLIENT_MULTI_STATEMENTS been set (#36759) (#36924)
6ac990bdaf2 is described below
commit 6ac990bdaf23a7cd39253b807bde167ec3eed356
Author: morrySnow <[email protected]>
AuthorDate: Thu Jun 27 17:10:06 2024 +0800
[fix](protocol) only return multi result when CLIENT_MULTI_STATEMENTS been
set (#36759) (#36924)
pick from master #36759
multi statement support by PR #3050.
But there is a minor issue in implementation.
as MySQL dev doc say in
https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_command_phase_sp.html#sect_protocol_command_phase_sp_multi_statement
server should only process multi statement
when client set CLIENT_MULTI_STATEMENTS.
When client not set CLIENT_MULTI_STATEMENTS, server should treat query
as single statement.
but Doris do slightly different with MySQL server. Doris always treat
query as multi statement, but only return multi result when client set
CLIENT_MULTI_STATEMENTS. When client do not set CLIENT_MULTI_STATEMENTS,
Doris will return the last statement result only.
---------
Co-authored-by: Mingyu Chen <[email protected]>
---
.../src/main/java/org/apache/doris/mysql/MysqlCapability.java | 6 +++++-
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlCapability.java
b/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlCapability.java
index 0701b6ac2f8..b3d4793eeb2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlCapability.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlCapability.java
@@ -161,9 +161,13 @@ public class MysqlCapability {
return (flags & Flag.CLIENT_DEPRECATE_EOF.getFlagBit()) != 0;
}
+ public boolean isClientMultiStatements() {
+ return (flags & Flag.CLIENT_MULTI_STATEMENTS.getFlagBit()) != 0;
+ }
+
@Override
public boolean equals(Object obj) {
- if (obj == null || !(obj instanceof MysqlCapability)) {
+ if (!(obj instanceof MysqlCapability)) {
return false;
}
if (flags != ((MysqlCapability) obj).flags) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
index 7c280566150..e608b68684b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
@@ -430,7 +430,11 @@ public class ConnectProcessor {
executor.execute();
if (i != stmts.size() - 1) {
ctx.getState().serverStatus |=
MysqlServerStatusFlag.SERVER_MORE_RESULTS_EXISTS;
- if (ctx.getState().getStateType() != MysqlStateType.ERR) {
+ // here, doris do different with mysql.
+ // when client not request CLIENT_MULTI_STATEMENTS, mysql
treat all query as
+ // single statement. Doris treat it with multi statement,
but only return
+ // the last statement result.
+ if (ctx.getCapability().isClientMultiStatements()) {
finalizeCommand();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]