Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3555, carry PR#5178 to dev-4.x #5731

Merged
merged 1 commit into from
May 21, 2020
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.shardingsphere.shardingproxy.frontend.mysql.command.query.binary.execute;

import lombok.Getter;
import org.apache.shardingsphere.database.protocol.error.CommonErrorCode;
import org.apache.shardingsphere.database.protocol.mysql.constant.MySQLColumnType;
import org.apache.shardingsphere.database.protocol.mysql.packet.MySQLPacket;
Expand Down Expand Up @@ -57,6 +58,10 @@ public final class MySQLComStmtExecuteExecutor implements QueryCommandExecutor {

private volatile boolean isQuery;

@Getter
private volatile boolean isUpdateResponse;

@Getter
private volatile boolean isErrorResponse;

private int currentSequenceId;
Expand All @@ -77,6 +82,7 @@ public Collection<DatabasePacket> execute() {
return Collections.singletonList(createErrorPacket(((ErrorResponse) backendResponse).getCause()));
}
if (backendResponse instanceof UpdateResponse) {
isUpdateResponse = true;
return Collections.singletonList(createUpdatePacket((UpdateResponse) backendResponse));
}
isQuery = true;
Expand Down Expand Up @@ -108,11 +114,6 @@ public boolean isQuery() {
return isQuery;
}

@Override
public boolean isErrorResponse() {
return isErrorResponse;
}

@Override
public boolean next() throws SQLException {
return databaseCommunicationEngine.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.shardingsphere.shardingproxy.frontend.mysql.command.query.text.query;

import lombok.Getter;
import org.apache.shardingsphere.database.protocol.error.CommonErrorCode;
import org.apache.shardingsphere.database.protocol.mysql.constant.MySQLColumnType;
import org.apache.shardingsphere.database.protocol.mysql.packet.MySQLPacket;
Expand Down Expand Up @@ -57,6 +58,10 @@ public final class MySQLComQueryPacketExecutor implements QueryCommandExecutor {

private volatile boolean isQuery;

@Getter
private volatile boolean isUpdateResponse;

@Getter
private volatile boolean isErrorResponse;

private int currentSequenceId;
Expand All @@ -76,6 +81,7 @@ public Collection<DatabasePacket> execute() {
return Collections.singletonList(createErrorPacket(((ErrorResponse) backendResponse).getCause()));
}
if (backendResponse instanceof UpdateResponse) {
isUpdateResponse = true;
return Collections.singletonList(createUpdatePacket((UpdateResponse) backendResponse));
}
isQuery = true;
Expand Down Expand Up @@ -124,11 +130,6 @@ public boolean isQuery() {
return isQuery;
}

@Override
public boolean isErrorResponse() {
return isErrorResponse;
}

@Override
public boolean next() throws SQLException {
return textProtocolBackendHandler.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void writeQueryData(final ChannelHandlerContext context,
context.write(new PostgreSQLReadyForQueryPacket());
return;
}
if (queryCommandExecutor.isErrorResponse()) {
if (queryCommandExecutor.isErrorResponse() || queryCommandExecutor.isUpdateResponse()) {
context.write(new PostgreSQLReadyForQueryPacket());
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.shardingsphere.shardingproxy.frontend.postgresql.command.query.binary.bind;

import lombok.Getter;
import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
import org.apache.shardingsphere.database.protocol.postgresql.constant.PostgreSQLColumnType;
import org.apache.shardingsphere.database.protocol.postgresql.packet.PostgreSQLPacket;
Expand Down Expand Up @@ -60,6 +61,10 @@ public final class PostgreSQLComBindExecutor implements QueryCommandExecutor {

private volatile boolean isQuery;

@Getter
private volatile boolean isUpdateResponse;

@Getter
private volatile boolean isErrorResponse;

public PostgreSQLComBindExecutor(final PostgreSQLComBindPacket packet, final BackendConnection backendConnection) {
Expand All @@ -84,6 +89,7 @@ public Collection<DatabasePacket> execute() {
result.add(createErrorPacket((ErrorResponse) backendResponse));
}
if (backendResponse instanceof UpdateResponse) {
isUpdateResponse = true;
result.add(createUpdatePacket((UpdateResponse) backendResponse));
}
if (backendResponse instanceof QueryResponse) {
Expand Down Expand Up @@ -123,11 +129,6 @@ public boolean isQuery() {
return isQuery;
}

@Override
public boolean isErrorResponse() {
return isErrorResponse;
}

@Override
public boolean next() throws SQLException {
return null != databaseCommunicationEngine && databaseCommunicationEngine.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.shardingsphere.shardingproxy.frontend.postgresql.command.query.text;

import lombok.Getter;
import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
import org.apache.shardingsphere.database.protocol.postgresql.packet.PostgreSQLPacket;
import org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLColumnDescription;
Expand Down Expand Up @@ -54,6 +55,10 @@ public final class PostgreSQLComQueryExecutor implements QueryCommandExecutor {

private volatile boolean isQuery;

@Getter
private volatile boolean isUpdateResponse;

@Getter
private volatile boolean isErrorResponse;

public PostgreSQLComQueryExecutor(final PostgreSQLComQueryPacket comQueryPacket, final BackendConnection backendConnection) {
Expand All @@ -71,6 +76,7 @@ public Collection<DatabasePacket> execute() {
return Collections.singletonList(createErrorPacket((ErrorResponse) backendResponse));
}
if (backendResponse instanceof UpdateResponse) {
isUpdateResponse = true;
return Collections.singletonList(createUpdatePacket((UpdateResponse) backendResponse));
}
Optional<PostgreSQLRowDescriptionPacket> result = createQueryPacket((QueryResponse) backendResponse);
Expand Down Expand Up @@ -108,11 +114,6 @@ public boolean isQuery() {
return isQuery;
}

@Override
public boolean isErrorResponse() {
return isErrorResponse;
}

@Override
public boolean next() throws SQLException {
return textProtocolBackendHandler.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
*/
public interface QueryCommandExecutor extends CommandExecutor {

/**
* Judge is update response.
*
* @return is update response or not
*/
boolean isUpdateResponse();

/**
* Judge is error response.
*
Expand Down