diff --git a/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/statement/ClickHouseStatement.java b/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/statement/ClickHouseStatement.java index 2be870d4..5e4d9e65 100644 --- a/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/statement/ClickHouseStatement.java +++ b/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/statement/ClickHouseStatement.java @@ -76,8 +76,12 @@ public boolean execute(String query) throws SQLException { public int executeUpdate(String query) throws SQLException { return ExceptionUtil.rethrowSQLException(() -> { - cfg.settings().put(SettingKey.max_result_rows, maxRows); - cfg.settings().put(SettingKey.result_overflow_mode, "break"); + // 仅在明确设置了 maxRows > 0 时才配置 settings + // 这样 readonly=1 用户可以正常使用(只要不调用 setMaxRows()) + if (maxRows > 0) { + cfg.settings().put(SettingKey.max_result_rows, maxRows); + cfg.settings().put(SettingKey.result_overflow_mode, "break"); + } extractDBAndTableName(query); Matcher matcher = VALUES_REGEX.matcher(query);