-
-
Notifications
You must be signed in to change notification settings - Fork 25
Closed
Description
Submitted by: @mrotteveel
The grammar for UPDATE OR INSERT has a minor bug (expecting MATCHING columnlist instead of MATCHING (columnlist)), which causes an existing RETURNING clause to not be properly identified. This results in Jaybird adding yet another RETURNING clause.
Simple reproduction:
public static void main(String[] args) throws SQLException {
try (Connection connection = DefaultDb.createDefaultConnection();
Statement stmt = connection.createStatement()) {
stmt.execute("update or insert into person (id, name) values (3, 'henk') "
+ "matching (id) "
+ "returning id", Statement.RETURN_GENERATED_KEYS);
try (ResultSet keys = stmt\.getGeneratedKeys()) {
while (keys.next()) {
System.out.println(keys.getInt(1));
}
}
}
}
This results in error:
java.sql.SQLSyntaxErrorException: Dynamic SQL Error; SQL error code = -104; Token unknown - line 2, column 11; "ID" [SQLState:42000, ISC error code:335544634]
This bug in the grammar is also present in Jaybird 2.2, but difference between ANTLR 3.4 and 4.7 apparently cause ANTLR 3.4 to still correctly identify the RETURNING clause.
See also: https://groups.yahoo.com/neo/groups/Firebird-Java/conversations/messages/11490 (archive)