Fixed problem with Postgres 9.1 Writeable CTE's #31

merged 1 commit into from May 10, 2012
Commits on May 10, 2012
  1. @jwkoelewijn

    Fixed problem with Postgres 9.1 Writeable CTE's

    jwkoelewijn committed May 10, 2012
    Problem solved by rewriting code that checked whether the
    query should be executed using PreparedStatement#executeQuery() or
    using PreparedStatement#executeUpdate().
    Original code checked for the existence of the word 'RETURNING',
    where this is perfectly possible in Postgres 9.1, where a writable
    CTE can be created with the word RETURNING in it, while not actually
    returning any values (i.e. #executeQuery() should have been called)
    Fix is to use the PreparedStatement#execute(), which returns a
    boolean that indicates whether a result was returned, or that
    existing rows were affected. Based on the value of this boolean
    either a ResultSet is requested or the number of affected rows
    is retrieved.