prestodb/presto · error · SQLException

SQL is not an update statement:

Error message

SQL is not an update statement: 

What it means

executeLargeUpdate(String) runs execute(sql); if it returns true the statement produced a result set, meaning the SQL was a query rather than an update, so this SQLException is thrown with the offending SQL appended. It fires when DML/DDL-style APIs are pointed at SELECT statements.

Source

Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java:511

    public int executeUpdate(String sql, int[] columnIndexes)
            throws SQLException
    {
        return executeUpdate(sql);
    }

    @Override
    public int executeUpdate(String sql, String[] columnNames)
            throws SQLException
    {
        return executeUpdate(sql);
    }

    @Override
    public long executeLargeUpdate(String sql)
            throws SQLException
    {
        if (execute(sql)) {
            throw new SQLException("SQL is not an update statement: " + sql);
        }
        return currentUpdateCount.get();
    }

    @Override
    public long executeLargeUpdate(String sql, int autoGeneratedKeys)
            throws SQLException
    {
        return executeLargeUpdate(sql);
    }

    @Override
    public long executeLargeUpdate(String sql, int[] columnIndexes)
            throws SQLException
    {
        return executeLargeUpdate(sql);
    }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use executeQuery() for SELECT statements and executeUpdate() only for DML/DDL
  2. Branch on the boolean returned by execute() when the statement type is dynamic
  3. Wrap calls in try-catch when routing user-supplied SQL
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java:511 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/e288b93feed0073a. Report an issue: GitHub.