This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 4899e29864c Replace ClientEncodingResponseHeader with
UpdateResponseHeader (#18988)
4899e29864c is described below
commit 4899e29864c6ca823f2a01917070fb1c11a619e9
Author: 吴伟杰 <[email protected]>
AuthorDate: Sun Jul 10 15:01:17 2022 +0800
Replace ClientEncodingResponseHeader with UpdateResponseHeader (#18988)
---
.../exception/InvalidParameterValueException.java | 9 ++--
.../update/ClientEncodingResponseHeader.java | 45 --------------------
.../admin/DatabaseAdminBackendHandlerFactory.java | 5 ---
.../admin/executor/DatabaseSetCharsetExecutor.java | 31 --------------
.../mysql/executor/MySQLSetCharsetExecutor.java | 15 ++-----
.../admin/postgresql/PostgreSQLCharacterSets.java | 2 +-
.../executor/PostgreSQLSetCharsetExecutor.java | 24 +++++------
.../encoding/DatabaseSetCharsetBackendHandler.java | 49 ----------------------
.../exception/UnknownCharacterSetException.java | 34 ---------------
.../text/query/MySQLComQueryPacketExecutor.java | 15 +------
.../frontend/mysql/err/MySQLErrPacketFactory.java | 4 +-
.../query/simple/OpenGaussComQueryExecutor.java | 33 ++++++++-------
.../command/query/extended/JDBCPortal.java | 29 +++++--------
.../query/simple/PostgreSQLComQueryExecutor.java | 33 ++++++++-------
.../postgresql/err/PostgreSQLErrPacketFactory.java | 6 ++-
15 files changed, 72 insertions(+), 262 deletions(-)
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/exception/InvalidParameterValueException.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/InvalidParameterValueException.java
similarity index 78%
rename from
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/exception/InvalidParameterValueException.java
rename to
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/InvalidParameterValueException.java
index 0bb2fa75f0e..b95da7fbec6 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/exception/InvalidParameterValueException.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/InvalidParameterValueException.java
@@ -15,20 +15,21 @@
* limitations under the License.
*/
-package
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.exception;
+package org.apache.shardingsphere.proxy.backend.exception;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.frontend.exception.FrontendException;
/**
* Invalid parameter value exception.
*/
@RequiredArgsConstructor
@Getter
-public final class InvalidParameterValueException extends FrontendException {
+public final class InvalidParameterValueException extends BackendException {
private static final long serialVersionUID = -6561119208409452172L;
- private final String message;
+ private final String parameterName;
+
+ private final String parameterValue;
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/header/update/ClientEncodingResponseHeader.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/header/update/ClientEncodingResponseHeader.java
deleted file mode 100644
index 47fdc419344..00000000000
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/header/update/ClientEncodingResponseHeader.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.response.header.update;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-
-import java.util.Optional;
-
-/**
- * Client encoding response header.
- */
-@RequiredArgsConstructor
-public class ClientEncodingResponseHeader implements ResponseHeader {
-
- private final String currentCharsetValue;
-
- @Getter
- private final String inputValue;
-
- /**
- * Get current charset value.
- *
- * @return current charset value
- */
- public Optional<String> getCurrentCharsetValue() {
- return Optional.ofNullable(currentCharsetValue);
- }
-}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminBackendHandlerFactory.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminBackendHandlerFactory.java
index 13a3a8cecfc..2302d1c9673 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminBackendHandlerFactory.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminBackendHandlerFactory.java
@@ -27,8 +27,6 @@ import
org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdmin
import
org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminExecutorCreator;
import
org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminExecutorCreatorFactory;
import
org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminQueryExecutor;
-import
org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseSetCharsetExecutor;
-import
org.apache.shardingsphere.proxy.backend.text.encoding.DatabaseSetCharsetBackendHandler;
import java.util.Optional;
@@ -80,9 +78,6 @@ public final class DatabaseAdminBackendHandlerFactory {
if (executor instanceof DatabaseAdminQueryExecutor) {
return new DatabaseAdminQueryBackendHandler(connectionSession,
(DatabaseAdminQueryExecutor) executor);
}
- if (executor instanceof DatabaseSetCharsetExecutor) {
- return new DatabaseSetCharsetBackendHandler(connectionSession,
(DatabaseSetCharsetExecutor) executor);
- }
return new DatabaseAdminUpdateBackendHandler(connectionSession,
sqlStatementContext.getSqlStatement(), executor);
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/DatabaseSetCharsetExecutor.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/DatabaseSetCharsetExecutor.java
deleted file mode 100644
index 27a030285de..00000000000
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/DatabaseSetCharsetExecutor.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.admin.executor;
-
-/**
- * Database set charset executor.
- */
-public interface DatabaseSetCharsetExecutor extends DatabaseAdminExecutor {
-
- /**
- * Get current charset.
- *
- * @return Current charset name
- */
- String getCurrentCharset();
-}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/MySQLSetCharsetExecutor.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/MySQLSetCharsetExecutor.java
index 2927ff8b426..9144cd4fd4e 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/MySQLSetCharsetExecutor.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/MySQLSetCharsetExecutor.java
@@ -21,7 +21,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.db.protocol.CommonConstants;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLServerInfo;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import
org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseSetCharsetExecutor;
+import
org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminExecutor;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dal.VariableAssignSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.SetStatement;
@@ -35,19 +35,15 @@ import java.util.Locale;
* Set charset executor of MySQL.
*/
@RequiredArgsConstructor
-public final class MySQLSetCharsetExecutor implements
DatabaseSetCharsetExecutor {
+public final class MySQLSetCharsetExecutor implements DatabaseAdminExecutor {
private final SetStatement setStatement;
- private String currentValue;
-
@Override
public void execute(final ConnectionSession connectionSession) throws
SQLException {
VariableAssignSegment segment =
setStatement.getVariableAssigns().iterator().next();
String value = formatValue(segment.getAssignValue().trim());
- Charset charset = parseCharset(value);
- currentValue = value;
-
connectionSession.getAttributeMap().attr(CommonConstants.CHARSET_ATTRIBUTE_KEY).set(charset);
+
connectionSession.getAttributeMap().attr(CommonConstants.CHARSET_ATTRIBUTE_KEY).set(parseCharset(value));
}
private String formatValue(final String value) {
@@ -70,9 +66,4 @@ public final class MySQLSetCharsetExecutor implements
DatabaseSetCharsetExecutor
}
}
}
-
- @Override
- public String getCurrentCharset() {
- return currentValue;
- }
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/PostgreSQLCharacterSets.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/PostgreSQLCharacterSets.java
index 75a8ee207a5..6a4e07e2432 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/PostgreSQLCharacterSets.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/PostgreSQLCharacterSets.java
@@ -36,7 +36,7 @@ public enum PostgreSQLCharacterSets {
EUC_KR(() -> Charset.forName("EUC_KR")),
EUC_TW(() -> Charset.forName("EUC_TW")),
EUC_JIS_2004(() -> Charset.forName("EUC_JIS_2004")),
- UTF8(() -> StandardCharsets.UTF_8, "Unicode"),
+ UTF8(() -> StandardCharsets.UTF_8, "Unicode", "UTF_8"),
MULE_INTERNAL(() -> Charset.forName("MULE_INTERNAL")),
LATIN1(() -> StandardCharsets.ISO_8859_1, "ISO88591"),
LATIN2(() -> Charset.forName("LATIN2"), "ISO88592"),
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/PostgreSQLSetCharsetExecutor.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/PostgreSQLSetCharsetExecutor.java
index 2c34bcda2c6..60d7031cca2 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/PostgreSQLSetCharsetExecutor.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/PostgreSQLSetCharsetExecutor.java
@@ -19,8 +19,9 @@ package
org.apache.shardingsphere.proxy.backend.text.admin.postgresql.executor;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.db.protocol.CommonConstants;
+import
org.apache.shardingsphere.proxy.backend.exception.InvalidParameterValueException;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import
org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseSetCharsetExecutor;
+import
org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminExecutor;
import
org.apache.shardingsphere.proxy.backend.text.admin.postgresql.PostgreSQLCharacterSets;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dal.VariableAssignSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.SetStatement;
@@ -34,19 +35,15 @@ import java.util.Locale;
* Set charset executor of PostgreSQL.
*/
@RequiredArgsConstructor
-public final class PostgreSQLSetCharsetExecutor implements
DatabaseSetCharsetExecutor {
+public final class PostgreSQLSetCharsetExecutor implements
DatabaseAdminExecutor {
private final SetStatement setStatement;
- private String currentValue;
-
@Override
public void execute(final ConnectionSession connectionSession) throws
SQLException {
VariableAssignSegment segment =
setStatement.getVariableAssigns().iterator().next();
String value = formatValue(segment.getAssignValue().trim());
- Charset charset = parseCharset(value);
- currentValue = value;
-
connectionSession.getAttributeMap().attr(CommonConstants.CHARSET_ATTRIBUTE_KEY).set(charset);
+
connectionSession.getAttributeMap().attr(CommonConstants.CHARSET_ATTRIBUTE_KEY).set(parseCharset(value));
}
private String formatValue(final String value) {
@@ -54,12 +51,11 @@ public final class PostgreSQLSetCharsetExecutor implements
DatabaseSetCharsetExe
}
private Charset parseCharset(final String value) {
- String result = value.toLowerCase(Locale.ROOT);
- return "default".equals(result) ? StandardCharsets.UTF_8 :
PostgreSQLCharacterSets.findCharacterSet(result);
- }
-
- @Override
- public String getCurrentCharset() {
- return currentValue;
+ try {
+ String result = value.toLowerCase(Locale.ROOT);
+ return "default".equals(result) ? StandardCharsets.UTF_8 :
PostgreSQLCharacterSets.findCharacterSet(result);
+ } catch (final IllegalArgumentException ignored) {
+ throw new InvalidParameterValueException("client_encoding",
value.toLowerCase(Locale.ROOT));
+ }
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/encoding/DatabaseSetCharsetBackendHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/encoding/DatabaseSetCharsetBackendHandler.java
deleted file mode 100644
index 6a93ba375ac..00000000000
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/encoding/DatabaseSetCharsetBackendHandler.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.encoding;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import
org.apache.shardingsphere.proxy.backend.response.header.update.ClientEncodingResponseHeader;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
-import
org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseSetCharsetExecutor;
-
-import java.nio.charset.UnsupportedCharsetException;
-import java.sql.SQLException;
-
-/**
- * Set charset backend handler of database.
- */
-@RequiredArgsConstructor
-public class DatabaseSetCharsetBackendHandler implements
TextProtocolBackendHandler {
-
- private final ConnectionSession connectionSession;
-
- private final DatabaseSetCharsetExecutor databaseSetCharsetExecutor;
-
- @Override
- public ResponseHeader execute() throws SQLException {
- try {
- databaseSetCharsetExecutor.execute(connectionSession);
- } catch (final UnsupportedCharsetException ignored) {
- return new ClientEncodingResponseHeader(null,
ignored.getCharsetName());
- }
- return new
ClientEncodingResponseHeader(databaseSetCharsetExecutor.getCurrentCharset(),
null);
- }
-}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/exception/UnknownCharacterSetException.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/exception/UnknownCharacterSetException.java
deleted file mode 100644
index b46fce11f6e..00000000000
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/exception/UnknownCharacterSetException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.frontend.mysql.command.query.exception;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.frontend.exception.FrontendException;
-
-/**
- * Unknown character set exception.
- */
-@RequiredArgsConstructor
-@Getter
-public final class UnknownCharacterSetException extends FrontendException {
-
- private static final long serialVersionUID = -1224655358882073372L;
-
- private final String message;
-}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
index 3032b50a06f..ad54ed3e79c 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
@@ -19,13 +19,10 @@ package
org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query;
import lombok.Getter;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConstants;
-import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLServerErrorCode;
import org.apache.shardingsphere.db.protocol.mysql.packet.MySQLPacket;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.admin.MySQLComSetOptionPacket;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.MySQLTextResultSetRowPacket;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.query.MySQLComQueryPacket;
-import
org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLErrPacket;
-import
org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLOKPacket;
import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
@@ -34,7 +31,6 @@ import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-import
org.apache.shardingsphere.proxy.backend.response.header.update.ClientEncodingResponseHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
@@ -51,7 +47,6 @@ import
org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtil;
import java.sql.SQLException;
import java.util.Collection;
-import java.util.Collections;
import java.util.Optional;
/**
@@ -102,7 +97,7 @@ public final class MySQLComQueryPacketExecutor implements
QueryCommandExecutor {
return processQuery((QueryResponseHeader) responseHeader);
}
responseType = ResponseType.UPDATE;
- return responseHeader instanceof UpdateResponseHeader ?
processUpdate((UpdateResponseHeader) responseHeader) :
processClientEncoding((ClientEncodingResponseHeader) responseHeader);
+ return processUpdate((UpdateResponseHeader) responseHeader);
}
private Collection<DatabasePacket<?>> processQuery(final
QueryResponseHeader queryResponseHeader) {
@@ -116,14 +111,6 @@ public final class MySQLComQueryPacketExecutor implements
QueryCommandExecutor {
return
ResponsePacketBuilder.buildUpdateResponsePackets(updateResponseHeader,
ServerStatusFlagCalculator.calculateFor(connectionSession));
}
- private Collection<DatabasePacket<?>> processClientEncoding(final
ClientEncodingResponseHeader clientEncodingResponseHeader) {
- Optional<String> currentCharsetValue =
clientEncodingResponseHeader.getCurrentCharsetValue();
- if (currentCharsetValue.isPresent()) {
- return Collections.singletonList(new MySQLOKPacket(1, 0, 0,
ServerStatusFlagCalculator.calculateFor(connectionSession)));
- }
- return Collections.singletonList(new MySQLErrPacket(1,
MySQLServerErrorCode.ER_UNKNOWN_CHARACTER_SET,
clientEncodingResponseHeader.getInputValue()));
- }
-
@Override
public boolean next() throws SQLException {
return textProtocolBackendHandler.next();
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
index 220e8859454..c9080eb6efe 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
@@ -42,11 +42,11 @@ import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.exception
import
org.apache.shardingsphere.proxy.frontend.exception.FrontendTooManyConnectionsException;
import
org.apache.shardingsphere.proxy.frontend.exception.UnsupportedCommandException;
import
org.apache.shardingsphere.proxy.frontend.exception.UnsupportedPreparedStatementException;
-import
org.apache.shardingsphere.proxy.frontend.mysql.command.query.exception.UnknownCharacterSetException;
import
org.apache.shardingsphere.sharding.route.engine.exception.NoSuchTableException;
import
org.apache.shardingsphere.sharding.route.engine.exception.TableExistsException;
import org.apache.shardingsphere.sql.parser.exception.SQLParsingException;
+import java.nio.charset.UnsupportedCharsetException;
import java.sql.SQLException;
/**
@@ -132,7 +132,7 @@ public final class MySQLErrPacketFactory {
if (cause instanceof FrontendTooManyConnectionsException) {
return new MySQLErrPacket(0,
MySQLServerErrorCode.ER_CON_COUNT_ERROR,
MySQLServerErrorCode.ER_CON_COUNT_ERROR.getErrorMessage());
}
- if (cause instanceof UnknownCharacterSetException) {
+ if (cause instanceof UnsupportedCharsetException) {
return new MySQLErrPacket(1,
MySQLServerErrorCode.ER_UNKNOWN_CHARACTER_SET, cause.getMessage());
}
if (cause instanceof RuntimeException) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/simple/OpenGaussComQueryExecutor.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/simple/OpenGaussComQueryExecutor.java
index 5cf6104eae7..f4ea3cfef93 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/simple/OpenGaussComQueryExecutor.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/simple/OpenGaussComQueryExecutor.java
@@ -31,7 +31,6 @@ import
org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-import
org.apache.shardingsphere.proxy.backend.response.header.update.ClientEncodingResponseHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
@@ -40,16 +39,20 @@ import
org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExe
import org.apache.shardingsphere.proxy.frontend.command.executor.ResponseType;
import
org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLConnectionContext;
import
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.PostgreSQLCommand;
-import
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.exception.InvalidParameterValueException;
+import
org.apache.shardingsphere.sql.parser.sql.common.segment.dal.VariableAssignSegment;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+import
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.SetStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.CommitStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.RollbackStatement;
+import
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
+import java.util.List;
import java.util.Optional;
/**
@@ -78,8 +81,7 @@ public final class OpenGaussComQueryExecutor implements
QueryCommandExecutor {
return
Collections.singleton(createRowDescriptionPacket((QueryResponseHeader)
responseHeader));
}
responseType = ResponseType.UPDATE;
- return responseHeader instanceof UpdateResponseHeader ?
Collections.singleton(createUpdatePacket((UpdateResponseHeader) responseHeader))
- : createClientEncodingPackets((ClientEncodingResponseHeader)
responseHeader);
+ return createUpdatePacket((UpdateResponseHeader) responseHeader);
}
private PostgreSQLRowDescriptionPacket createRowDescriptionPacket(final
QueryResponseHeader queryResponseHeader) {
@@ -97,24 +99,25 @@ public final class OpenGaussComQueryExecutor implements
QueryCommandExecutor {
return result;
}
- private PostgreSQLPacket createUpdatePacket(final UpdateResponseHeader
updateResponseHeader) {
+ private List<DatabasePacket<?>> createUpdatePacket(final
UpdateResponseHeader updateResponseHeader) {
SQLStatement sqlStatement = updateResponseHeader.getSqlStatement();
if (sqlStatement instanceof CommitStatement || sqlStatement instanceof
RollbackStatement) {
connectionContext.closeAllPortals();
}
- return sqlStatement instanceof EmptyStatement ? new
PostgreSQLEmptyQueryResponsePacket()
- : new
PostgreSQLCommandCompletePacket(PostgreSQLCommand.valueOf(sqlStatement.getClass()).map(PostgreSQLCommand::getTag).orElse(""),
updateResponseHeader.getUpdateCount());
+ if (sqlStatement instanceof SetStatement) {
+ return createParameterStatusResponse((SetStatement) sqlStatement);
+ }
+ return Collections.singletonList(sqlStatement instanceof
EmptyStatement ? new PostgreSQLEmptyQueryResponsePacket()
+ : new
PostgreSQLCommandCompletePacket(PostgreSQLCommand.valueOf(sqlStatement.getClass()).map(PostgreSQLCommand::getTag).orElse(""),
updateResponseHeader.getUpdateCount()));
}
- private Collection<DatabasePacket<?>> createClientEncodingPackets(final
ClientEncodingResponseHeader clientEncodingResponseHeader) {
- Collection<DatabasePacket<?>> result = new LinkedList<>();
- Optional<String> currentCharsetValue =
clientEncodingResponseHeader.getCurrentCharsetValue();
- if (currentCharsetValue.isPresent()) {
- result.add(new PostgreSQLCommandCompletePacket("SET", 0));
- result.add(new PostgreSQLParameterStatusPacket("client_encoding",
currentCharsetValue.get()));
- return result;
+ private List<DatabasePacket<?>> createParameterStatusResponse(final
SetStatement sqlStatement) {
+ List<DatabasePacket<?>> result = new ArrayList<>(2);
+ result.add(new PostgreSQLCommandCompletePacket("SET", 0));
+ for (VariableAssignSegment each : sqlStatement.getVariableAssigns()) {
+ result.add(new
PostgreSQLParameterStatusPacket(each.getVariable().getVariable(),
IdentifierValue.getQuotedContent(each.getAssignValue())));
}
- throw new InvalidParameterValueException(String.format("invalid value
for parameter \"clientEncoding\": \"%s\"",
clientEncodingResponseHeader.getInputValue()));
+ return result;
}
@Override
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortal.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortal.java
index c7e0456022d..178c9c4ae51 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortal.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortal.java
@@ -20,8 +20,6 @@ package
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extend
import lombok.Getter;
import lombok.SneakyThrows;
import org.apache.shardingsphere.db.protocol.binary.BinaryCell;
-import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLErrorCode;
-import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLMessageSeverityLevel;
import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLValueFormat;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.PostgreSQLPacket;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLColumnDescription;
@@ -32,7 +30,6 @@ import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.Pos
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.execute.PostgreSQLPortalSuspendedPacket;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLCommandCompletePacket;
-import
org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLErrorResponsePacket;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.handshake.PostgreSQLParameterStatusPacket;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.identifier.PostgreSQLIdentifierPacket;
import org.apache.shardingsphere.distsql.parser.statement.DistSQLStatement;
@@ -46,20 +43,21 @@ import
org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicati
import
org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
import
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
+import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-import
org.apache.shardingsphere.proxy.backend.response.header.update.ClientEncodingResponseHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import
org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandlerFactory;
import
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.PostgreSQLCommand;
+import
org.apache.shardingsphere.sql.parser.sql.common.segment.dal.VariableAssignSegment;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.SetStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.TCLStatement;
+import
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -139,9 +137,6 @@ public final class JDBCPortal implements Portal<Void> {
if (responseHeader instanceof UpdateResponseHeader) {
return PostgreSQLNoDataPacket.getInstance();
}
- if (responseHeader instanceof ClientEncodingResponseHeader) {
- return PostgreSQLNoDataPacket.getInstance();
- }
throw new IllegalStateException("Cannot describe portal [" + name + "]
before bind");
}
@@ -167,24 +162,20 @@ public final class JDBCPortal implements Portal<Void> {
for (int i = 0; i < fetchSize && hasNext(); i++) {
result.add(nextPacket());
}
- if (responseHeader instanceof ClientEncodingResponseHeader) {
-
result.addAll(handleSetClientEncoding((ClientEncodingResponseHeader)
responseHeader));
+ if (responseHeader instanceof UpdateResponseHeader && sqlStatement
instanceof SetStatement) {
+ result.addAll(createParameterStatusResponse((SetStatement)
sqlStatement));
return result;
}
result.add(createExecutionCompletedPacket(maxRows > 0 && maxRows ==
result.size(), result.size()));
return result;
}
- private Collection<PostgreSQLPacket> handleSetClientEncoding(final
ClientEncodingResponseHeader clientEncodingResponseHeader) {
- Collection<PostgreSQLPacket> result = new LinkedList<>();
- Optional<String> currentCharsetValue =
clientEncodingResponseHeader.getCurrentCharsetValue();
- if (currentCharsetValue.isPresent()) {
- result.add(new PostgreSQLCommandCompletePacket("SET", 0));
- result.add(new PostgreSQLParameterStatusPacket("client_encoding",
currentCharsetValue.get()));
- return result;
+ private List<PostgreSQLPacket> createParameterStatusResponse(final
SetStatement sqlStatement) {
+ List<PostgreSQLPacket> result = new ArrayList<>(2);
+ result.add(new PostgreSQLCommandCompletePacket("SET", 0));
+ for (VariableAssignSegment each : sqlStatement.getVariableAssigns()) {
+ result.add(new
PostgreSQLParameterStatusPacket(each.getVariable().getVariable(),
IdentifierValue.getQuotedContent(each.getAssignValue())));
}
-
result.add(PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.ERROR,
PostgreSQLErrorCode.INVALID_PARAMETER_VALUE,
- String.format("invalid value for parameter \"clientEncoding\":
\"%s\"", clientEncodingResponseHeader.getInputValue())).build());
return result;
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java
index eb71c555c0f..20a14b263a0 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java
@@ -31,7 +31,6 @@ import
org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-import
org.apache.shardingsphere.proxy.backend.response.header.update.ClientEncodingResponseHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
@@ -40,16 +39,20 @@ import
org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExe
import org.apache.shardingsphere.proxy.frontend.command.executor.ResponseType;
import
org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLConnectionContext;
import
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.PostgreSQLCommand;
-import
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.exception.InvalidParameterValueException;
+import
org.apache.shardingsphere.sql.parser.sql.common.segment.dal.VariableAssignSegment;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+import
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.SetStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.CommitStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.RollbackStatement;
+import
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
+import java.util.List;
import java.util.Optional;
/**
@@ -78,8 +81,7 @@ public final class PostgreSQLComQueryExecutor implements
QueryCommandExecutor {
return
Collections.singleton(createRowDescriptionPacket((QueryResponseHeader)
responseHeader));
}
responseType = ResponseType.UPDATE;
- return responseHeader instanceof UpdateResponseHeader ?
Collections.singleton(createUpdatePacket((UpdateResponseHeader) responseHeader))
- : createClientEncodingPackets((ClientEncodingResponseHeader)
responseHeader);
+ return createUpdatePacket((UpdateResponseHeader) responseHeader);
}
private PostgreSQLRowDescriptionPacket createRowDescriptionPacket(final
QueryResponseHeader queryResponseHeader) {
@@ -97,24 +99,25 @@ public final class PostgreSQLComQueryExecutor implements
QueryCommandExecutor {
return result;
}
- private PostgreSQLPacket createUpdatePacket(final UpdateResponseHeader
updateResponseHeader) {
+ private List<DatabasePacket<?>> createUpdatePacket(final
UpdateResponseHeader updateResponseHeader) {
SQLStatement sqlStatement = updateResponseHeader.getSqlStatement();
if (sqlStatement instanceof CommitStatement || sqlStatement instanceof
RollbackStatement) {
connectionContext.closeAllPortals();
}
- return sqlStatement instanceof EmptyStatement ? new
PostgreSQLEmptyQueryResponsePacket()
- : new
PostgreSQLCommandCompletePacket(PostgreSQLCommand.valueOf(sqlStatement.getClass()).map(PostgreSQLCommand::getTag).orElse(""),
updateResponseHeader.getUpdateCount());
+ if (sqlStatement instanceof SetStatement) {
+ return createParameterStatusResponse((SetStatement) sqlStatement);
+ }
+ return Collections.singletonList(sqlStatement instanceof
EmptyStatement ? new PostgreSQLEmptyQueryResponsePacket()
+ : new
PostgreSQLCommandCompletePacket(PostgreSQLCommand.valueOf(sqlStatement.getClass()).map(PostgreSQLCommand::getTag).orElse(""),
updateResponseHeader.getUpdateCount()));
}
- private Collection<DatabasePacket<?>> createClientEncodingPackets(final
ClientEncodingResponseHeader clientEncodingResponseHeader) {
- Collection<DatabasePacket<?>> result = new LinkedList<>();
- Optional<String> currentCharsetValue =
clientEncodingResponseHeader.getCurrentCharsetValue();
- if (currentCharsetValue.isPresent()) {
- result.add(new PostgreSQLCommandCompletePacket("SET", 0));
- result.add(new PostgreSQLParameterStatusPacket("client_encoding",
currentCharsetValue.get()));
- return result;
+ private List<DatabasePacket<?>> createParameterStatusResponse(final
SetStatement sqlStatement) {
+ List<DatabasePacket<?>> result = new ArrayList<>(2);
+ result.add(new PostgreSQLCommandCompletePacket("SET", 0));
+ for (VariableAssignSegment each : sqlStatement.getVariableAssigns()) {
+ result.add(new
PostgreSQLParameterStatusPacket(each.getVariable().getVariable(),
IdentifierValue.getQuotedContent(each.getAssignValue())));
}
- throw new InvalidParameterValueException(String.format("invalid value
for parameter \"clientEncoding\": \"%s\"",
clientEncodingResponseHeader.getInputValue()));
+ return result;
}
@Override
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/err/PostgreSQLErrPacketFactory.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/err/PostgreSQLErrPacketFactory.java
index 0b949049d34..a31720a3e34 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/err/PostgreSQLErrPacketFactory.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/err/PostgreSQLErrPacketFactory.java
@@ -29,7 +29,7 @@ import
org.apache.shardingsphere.proxy.backend.exception.DatabaseLockedException
import
org.apache.shardingsphere.proxy.frontend.postgresql.authentication.exception.InvalidAuthorizationSpecificationException;
import
org.apache.shardingsphere.proxy.frontend.postgresql.authentication.exception.PostgreSQLAuthenticationException;
import
org.apache.shardingsphere.proxy.frontend.postgresql.authentication.exception.PostgreSQLProtocolViolationException;
-import
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.exception.InvalidParameterValueException;
+import
org.apache.shardingsphere.proxy.backend.exception.InvalidParameterValueException;
import org.postgresql.util.PSQLException;
import org.postgresql.util.ServerErrorMessage;
@@ -70,7 +70,9 @@ public final class PostgreSQLErrPacketFactory {
return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.FATAL,
((PostgreSQLAuthenticationException) cause).getErrorCode(),
cause.getMessage()).build();
}
if (cause instanceof InvalidParameterValueException) {
- return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.ERROR,
PostgreSQLErrorCode.INVALID_PARAMETER_VALUE, cause.getMessage()).build();
+ InvalidParameterValueException ex =
(InvalidParameterValueException) cause;
+ String message = String.format("invalid value for parameter
\"%s\": \"%s\"", ex.getParameterName(), ex.getParameterValue());
+ return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.ERROR,
PostgreSQLErrorCode.INVALID_PARAMETER_VALUE, message).build();
}
if (cause instanceof DBCreateExistsException) {
return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.ERROR,
PostgreSQLErrorCode.DUPLICATE_DATABASE,