{"record":{"id":"d2c04d822a4f1aad","repo":"apache/shardingsphere","slug":"6","errorCode":"6","errorMessage":"Missing required privilege(s) `%s`","messagePattern":"Missing required privilege\\(s\\) `(.+?)`","errorType":"exception","errorClass":"MissingRequiredPrivilegeException","httpStatus":null,"severity":"error","filePath":"database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/checker/MySQLDatabasePrivilegeChecker.java","lineNumber":84,"sourceCode":"        } catch (final SQLException ex) {\n            throw new CheckDatabaseEnvironmentFailedException(ex);\n        }\n    }\n    \n    private void checkPrivilege(final Connection connection, final PrivilegeCheckType privilegeCheckType) {\n        try (\n                PreparedStatement preparedStatement = connection.prepareStatement(SHOW_GRANTS_SQL);\n                ResultSet resultSet = preparedStatement.executeQuery()) {\n            while (resultSet.next()) {\n                String privilege = resultSet.getString(1).toUpperCase();\n                if (matchPrivileges(privilege, getRequiredPrivileges(connection, privilegeCheckType))) {\n                    return;\n                }\n            }\n        } catch (final SQLException ex) {\n            throw new CheckDatabaseEnvironmentFailedException(ex);\n        }\n        throw new MissingRequiredPrivilegeException(REQUIRED_PRIVILEGES_FOR_MESSAGE.get(privilegeCheckType));\n    }\n    \n    private String[][] getRequiredPrivileges(final Connection connection, final PrivilegeCheckType privilegeCheckType) throws SQLException {\n        switch (privilegeCheckType) {\n            case PIPELINE:\n                return PIPELINE_REQUIRED_PRIVILEGES;\n            case SELECT:\n                return getSelectRequiredPrivilege(connection);\n            case XA:\n                return XA_REQUIRED_PRIVILEGES;\n            default:\n                return new String[0][0];\n        }\n    }\n    \n    private String[][] getSelectRequiredPrivilege(final Connection connection) throws SQLException {\n        String onCatalog = String.format(\"ON `%s`.*\", connection.getCatalog().toUpperCase());\n        return new String[][]{{\"ALL PRIVILEGES\", \"ON *.*\"}, {\"SELECT\", \"ON *.*\"}, {\"ALL PRIVILEGES\", onCatalog}, {\"SELECT\", onCatalog}};","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/checker/MySQLDatabasePrivilegeChecker.java#L66-L102","documentation":"MySQL error 1105 (ER_UNKNOWN_ERROR) thrown by MySQLServerPreparedStatement.getLongDataIndexes() when a parameter accumulated via COM_STMT_SEND_LONG_DATA exceeded the connection's max_allowed_packet size. During accumulation the flag longDataTooLarge is set instead of failing immediately; the error surfaces later, when the prepared statement is next executed or described and the long-data indexes are requested as a SQLException with XOpenSQLState.GENERAL_ERROR.","triggerScenarios":"Calling mysql_send_long_data() (COM_STMT_SEND_LONG_DATA) with a cumulative byte count for one parameter that exceeds max_allowed_packet, then executing or describing the statement — getLongDataIndexes() throws because longDataTooLarge is true.","commonSituations":"Uploading large BLOBs/CLOBs through the binary protocol via send_long_data (common with MySQL Connector/C and some C/ODBC paths) while the proxy's max_allowed_packet is at its default; increasing max_allowed_packet on the backend server but not on the proxy rule; chunked long-data sends that individually pass but cumulatively exceed the limit.","solutions":["Raise max_allowed_packet in the proxy's server configuration (and on backend MySQL) to exceed the largest parameter sent via mysql_send_long_data.","Split the payload: send long data for a parameter in smaller statements, or stream the BLOB through a side channel and reference it (e.g. LOAD_FILE / staging table).","If you do not need binary-protocol long data, switch the driver path to standard COM_QUERY execution with the full parameter inline (within max_allowed_packet).","Verify the setting took effect on the proxy side (the check uses the proxy's configured value, not the backend's)."],"exampleFix":"# before (server.yaml / rule)\nmaxAllowedPacket: 4194304  # 4MB, BLOB is 32MB\n\n# after\nmaxAllowedPacket: 67108864  # 64MB, covers the largest long-data parameter","handlingStrategy":"validation","validationCode":"// Client-side: check payload size before sending long data\nlong maxPacket = fetchMaxAllowedPacketFromProxy(); // e.g. SELECT @@max_allowed_packet via proxy\nif (blobBytes.length > maxPacket) {\n    throw new IllegalArgumentException(\"Parameter of \" + blobBytes.length + \" bytes exceeds max_allowed_packet=\" + maxPacket);\n}\nstmt.sendLongData(paramIndex, blobBytes);","typeGuard":null,"tryCatchPattern":"// SQLException with SQLState 'HY000' and vendor code 1105 at execute time (deferred)\ntry {\n    stmt.execute();\n} catch (SQLException e) {\n    if (e.getErrorCode() == 1105 && e.getMessage().contains(\"max_allowed_packet\")) {\n        throw new IllegalStateException(\"Long-data parameter too large; raise max_allowed_packet on the proxy or chunk the upload\", e);\n    }\n    throw e;\n}","preventionTips":["Size max_allowed_packet (proxy + backend) above your largest BLOB parameter.","Fail fast client-side on oversized payloads instead of relying on the deferred execute-time error.","Remember the limit applies to the cumulative bytes per parameter across chunked send_long_data calls."],"tags":["mysql","prepared-statement","blob","max-allowed-packet","protocol"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}