{"record":{"id":"3383e5475f3d97eb","repo":"prestodb/presto","slug":"invalid-fetch-direction","errorCode":null,"errorMessage":"Invalid fetch direction","messagePattern":"Invalid fetch direction","errorType":"validation","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java","lineNumber":371,"sourceCode":"    {\n        checkOpen();\n        return currentUpdateCount.get();\n    }\n\n    @Override\n    public boolean getMoreResults()\n            throws SQLException\n    {\n        return getMoreResults(CLOSE_CURRENT_RESULT);\n    }\n\n    @Override\n    public void setFetchDirection(int direction)\n            throws SQLException\n    {\n        checkOpen();\n        if (!validFetchDirection(direction)) {\n            throw new SQLException(\"Invalid fetch direction\");\n        }\n        // ignore: fetch direction is always forward\n    }\n\n    @Override\n    public int getFetchDirection()\n            throws SQLException\n    {\n        checkOpen();\n        return ResultSet.FETCH_FORWARD;\n    }\n\n    @Override\n    public void setFetchSize(int rows)\n            throws SQLException\n    {\n        checkOpen();\n        if (rows < 0) {","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java#L353-L389","documentation":"setFetchDirection in PrestoStatement validates the direction argument via validFetchDirection(direction); only FETCH_FORWARD (and unknown/ignored values it accepts) are permitted since Presto fetches rows forward-only, so an invalid direction constant throws this SQLException.","triggerScenarios":"Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java:371 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use ResultSet.FETCH_FORWARD (the only supported direction)","Remove setFetchDirection calls that request scrollable/ reverse cursors","Catch SQLException in generic JDBC code that may set arbitrary directions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}