{"record":{"id":"7aa99629221b5707","repo":"prestodb/presto","slug":"rows-is-negative","errorCode":null,"errorMessage":"Rows is negative","messagePattern":"Rows is negative","errorType":"validation","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java","lineNumber":719,"sourceCode":"            throw new SQLException(\"Fetch direction must be FETCH_FORWARD\");\n        }\n    }\n\n    @Override\n    public int getFetchDirection()\n            throws SQLException\n    {\n        checkOpen();\n        return FETCH_FORWARD;\n    }\n\n    @Override\n    public void setFetchSize(int rows)\n            throws SQLException\n    {\n        checkOpen();\n        if (rows < 0) {\n            throw new SQLException(\"Rows is negative\");\n        }\n        // fetch size is ignored\n    }\n\n    @Override\n    public int getFetchSize()\n            throws SQLException\n    {\n        checkOpen();\n        // fetch size is ignored\n        return 0;\n    }\n\n    @Override\n    public int getType()\n            throws SQLException\n    {\n        checkOpen();","sourceCodeStart":701,"sourceCodeEnd":737,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java#L701-L737","documentation":"PrestoResultSet.setFetchSize rejects negative values with SQLException(\"Rows is negative\") after checking the result set is open. Non-negative fetch sizes are accepted but otherwise ignored, since Presto streams results in its own pages.","triggerScenarios":"Calling setFetchSize(rows) with rows < 0 on an open PrestoResultSet.","commonSituations":"Config-driven fetch sizes where a negative placeholder value (-1 meaning 'unlimited' in some frameworks) leaks into the JDBC call.","solutions":["Clamp or validate the fetch size to >= 0 before calling setFetchSize","Treat framework sentinel values like -1 as 'do not call setFetchSize'","Note the value is ignored anyway; simply omit the call when tuning Presto fetch behavior"],"exampleFix":"// before\nrs.setFetchSize(config.getFetchSize()); // may be -1\n// after\nint size = config.getFetchSize();\nif (size >= 0) { rs.setFetchSize(size); }","handlingStrategy":"validation","validationCode":"if (rows < 0) {\n    throw new IllegalArgumentException(\"fetchSize must be >= 0\");\n}\nrs.setFetchSize(rows);","typeGuard":null,"tryCatchPattern":"try { rs.setFetchSize(cfg); } catch (SQLException e) { if (e.getMessage().contains(\"Rows is negative\")) { /* fix config value */ } }","preventionTips":["Validate configured fetch sizes are non-negative at startup","Map framework sentinel values like -1 to 'do not set' before calling JDBC","Remember Presto ignores fetch size; avoid setting it unless needed"],"tags":["jdbc","invalid-argument","fetch-size"],"backgroundTag":"jdbc-invalid-fetch-size","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}