{"record":{"id":"90bff714fb5e9dc2","repo":"apache/shardingsphere","slug":"1231","errorCode":"1231","errorMessage":"Variable '%s' can't be set to the value of '%s'","messagePattern":"Variable '(.+?)' can't be set to the value of '(.+?)'","errorType":"exception","errorClass":"InvalidParameterValueException","httpStatus":null,"severity":"error","filePath":"proxy/backend/dialect/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetVariableAdminExecutor.java","lineNumber":216,"sourceCode":"                }\n                if (setNamesWithCollationAssignment) {\n                    validateClientCharacterSet(context.getClientCharacterSetName());\n                }\n                return context.withConnectionCollation(collation);\n            default:\n                return context;\n        }\n    }\n    \n    private MySQLCharacterSets parseClientCharacterSet(final String value) {\n        String normalizedValue = formatVariableValue(value).toLowerCase(Locale.ROOT);\n        validateClientCharacterSet(normalizedValue);\n        return parseCharacterSet(value);\n    }\n    \n    private void validateClientCharacterSet(final String characterSet) {\n        if (IMPERMISSIBLE_CLIENT_CHARACTER_SETS.contains(characterSet)) {\n            throw new InvalidParameterValueException(CHARACTER_SET_CLIENT, characterSet);\n        }\n    }\n    \n    private MySQLSessionCharsetContext updateResultCharacterSet(final MySQLSessionCharsetContext context, final String value) {\n        String normalizedValue = formatVariableValue(value).toLowerCase(Locale.ROOT);\n        if (isKeyword(value, \"null\")) {\n            return context.withoutResultConversion();\n        }\n        return \"binary\".equals(normalizedValue) ? context.withBinaryResult() : context.withResultCharacterSet(parseCharacterSet(value));\n    }\n    \n    private MySQLCharacterSets parseCharacterSet(final String value) {\n        String normalizedValue = formatVariableValue(value);\n        return isKeyword(value, \"default\") ? MySQLConstants.DEFAULT_CHARSET : MySQLCharacterSets.findByCharacterSetName(normalizedValue);\n    }\n    \n    private MySQLCharacterSets parseConnectionCharacterSet(final String value) {\n        if (isKeyword(value, \"default\")) {","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/proxy/backend/dialect/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetVariableAdminExecutor.java#L198-L234","documentation":"InvalidParameterValueException (error code 1231, MySQL 'Variable can't be set to value' semantics) thrown by MySQLSetVariableAdminExecutor.validateClientCharacterSet when the value assigned to character_set_client (directly or via SET NAMES) is in IMPERMISSIBLE_CLIENT_CHARACTER_SETS. MySQL rejects certain charsets as client charsets (historically ucs2, utf16, utf16le, utf32) because the wire protocol cannot frame them; the proxy mirrors this restriction.","triggerScenarios":"SET character_set_client = utf16 / ucs2 / utf32 / utf16le, or SET NAMES utf16 (which routes through parseClientCharacterSet -> validateClientCharacterSet); the lowercased normalized value is found in the impermissible set and the exception is thrown with (CHARACTER_SET_CLIENT, value).","commonSituations":"Configs written for storage-side column charsets reused as connection charsets; tools or ORMs probing available charsets by SETting each one; legacy configs using utf16 for 'more unicode' on the connection.","solutions":["Use a client-safe charset such as utf8mb4 for the connection/session variables","Keep column-level utf16/ucs2 definitions in DDL only; never assign them to character_set_client or SET NAMES","If a client library sends these SETs automatically, disable or reconfigure that behavior (e.g. connector charset probes)"],"exampleFix":"-- before\nSET NAMES utf16;\n\n-- after\nSET NAMES utf8mb4;","handlingStrategy":"validation","validationCode":"private static final Set<String> IMPERMISSIBLE = Set.of(\"ucs2\", \"utf16\", \"utf16le\", \"utf32\");\npublic void checkClientCharset(final String value) {\n    String v = value.trim().toLowerCase(Locale.ROOT);\n    if (IMPERMISSIBLE.contains(v)) { throw new IllegalArgumentException(\"Not allowed as client charset: \" + v); }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use utf8mb4 for all connection/session charsets; reserve utf16/ucs2 for column DDL only","Disable charset probing in client tools that issue SET NAMES for every charset they discover"],"tags":["mysql","charset","set-names","validation","connection"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}