Обсуждение: BUG #2514: (jdbc driver) Multiple inlined statements with mixed updates and queries return wrong results

Поиск
Список
Период
Сортировка
The following bug has been logged online:

Bug reference:      2514
Logged by:          Gilles
Email address:      gilles.rayrat@continuent.com
PostgreSQL version: 8.0.7
Operating system:   linux
Description:        (jdbc driver) Multiple inlined statements with mixed
updates and queries return wrong results
Details:

jdbc driver: 8.1.405

When issuing this:
statement.execute("SELECT 2;UPDATE foo SET d='babar' where i=1; SELECT 3");
The 2 result returned is wrong. This seems to be a ResultSet containing the
same values as the first RS (it should be an update count)

Here is code to reproduce:

      stmt.executeUpdate("CREATE TABLE foo(i integer, d varchar(5))");
      stmt.executeUpdate("INSERT INTO foo values(1,'bar')");
      boolean isRS = stmt.execute("SELECT 2;UPDATE foo SET d='babar' where
i=1; SELECT 3");
      assertTrue(isRS);
      ResultSet rs = stmt.getResultSet();
      assertTrue(rs.next());
      assertEquals(rs.getInt(1), 2);
      rs.close();
      assertFalse(stmt.getMoreResults());  // <= This fails !
      assertEquals(stmt.getUpdateCount(), 1);
      assertTrue(stmt.getMoreResults());
      rs = stmt.getResultSet();
      assertTrue(rs.next());
      assertEquals(rs.getInt(1), 3);
      rs.close();
      stmt.close();

Re: BUG #2514: (jdbc driver) Multiple inlined statements with

От
Kris Jurka
Дата:
On Wed, 5 Jul 2006, Gilles wrote:

> Bug reference:      2514
> Description:        (jdbc driver) Multiple inlined statements with mixed
> updates and queries return wrong results
> Details:
>
> When issuing this:
> statement.execute("SELECT 2;UPDATE foo SET d='babar' where i=1; SELECT 3");
> The 2 result returned is wrong. This seems to be a ResultSet containing the
> same values as the first RS (it should be an update count)
>

Fixed in CVS for 8.0, 8.1 and 8.2dev.  It was mistakenly retaining some
state from the first SELECT when issuing the update.  I've put up a
temporary jar file here if you need a fix before the next official
releases.  http://www.ejurka.com/pgsql/jars/gr/

Kris Jurka