Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,6 @@ private void handleQueryStmt() throws Exception {

coord.exec();

// if python's MysqlDb get error after sendfields, it can't catch the exception
// so We need to send fields after first batch arrived

// send result
// 1. If this is a query with OUTFILE clause, eg: select * from tbl1 into outfile xxx,
// We will not send real query result to client. Instead, we only send OK to client with
Expand All @@ -622,13 +619,17 @@ private void handleQueryStmt() throws Exception {
RowBatch batch;
MysqlChannel channel = context.getMysqlChannel();
boolean isOutfileQuery = queryStmt.hasOutFileClause();
if (!isOutfileQuery) {
sendFields(queryStmt.getColLabels(), queryStmt.getResultExprs());
}
boolean isSendFields = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the reason is that the fields has been sent but no data is sent following?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fields has been sent, but query may fail because of timeout. In this case, client will get a fields packet, and error packet, but some language mysql driver cannot recognize the error, and returns a success and no rows result.

while (true) {
batch = coord.getNext();
// for outfile query, there will be only one empty batch send back with eos flag
if (batch.getBatch() != null && !isOutfileQuery) {
// For some language driver, getting error packet after fields packet will be recognized as a success result
// so We need to send fields after first batch arrived
if (!isSendFields) {
sendFields(queryStmt.getColLabels(), queryStmt.getResultExprs());
isSendFields = true;
}
for (ByteBuffer row : batch.getBatch().getRows()) {
channel.sendOnePacket(row);
}
Expand All @@ -638,6 +639,9 @@ private void handleQueryStmt() throws Exception {
break;
}
}
if (!isSendFields && !isOutfileQuery) {
sendFields(queryStmt.getColLabels(), queryStmt.getResultExprs());
}

statisticsForAuditLog = batch.getQueryStatistics();
if (!isOutfileQuery) {
Expand Down