Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
3.4.0
-
None
Description
Try this code:
try (Statement s = connection.createStatement()) {
|
s.executeUpdate("create table t (i int primary key)");
|
 |
try (ResultSet rs = s.executeQuery("""
|
delete from t
|
where false
|
returning i
|
""")) {
|
while (rs.next())
|
System.out.println(rs.getInt(1));
|
}
|
finally {
|
s.executeUpdate("drop table t");
|
}
|
}
|
It should work out of the box, which it did with driver versions 3.3.x. With 3.4.0, it throws this error:
0
|
Statement.executeQuery() command does NOT return a result-set as expected. Either use Statement.execute(), Statement.executeUpdate(), or correct command
|
null
|
java.sql.SQLException: Statement.executeQuery() command does NOT return a result-set as expected. Either use Statement.execute(), Statement.executeUpdate(), or correct command
|
at org.mariadb.jdbc.Statement.executeQuery(Statement.java:171)
|
at org.jooq.testscripts.JDBC.main(JDBC.java:42)
|
The difference can be seen in the implementations:
- https://github.com/mariadb-corporation/mariadb-connector-j/blob/3.3.3/src/main/java/org/mariadb/jdbc/Statement.java#L169
- https://github.com/mariadb-corporation/mariadb-connector-j/blob/3.4.0/src/main/java/org/mariadb/jdbc/Statement.java#L171
The relevant change is this one:
Due to CONJ-1125.
Both static and prepared statements have this regression.
I didn't check for empty UPDATE .. RETURNING or INSERT .. RETURNING statements, but I'd guess they'll also expose this regression.
Attachments
Issue Links
- is caused by
-
MDEV-34585 DELETE .. RETURNING sometimes returns OK packet instead of result set
- Open