Issue Details (XML | Word | Printable)

Key: JDBC-566
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Mark Rotteveel
Reporter: Mark Rotteveel
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Jaybird JCA/JDBC Driver

UPDATE OR INSERT with existing RETURNING clause handled incorrectly for generated keys

Created: 30/Nov/18 02:39 PM   Updated: 25/May/19 10:03 AM
Component/s: JDBC driver
Affects Version/s: Jaybird 3.0.0, Jaybird 3.0.1, Jaybird 3.0.2, Jaybird 3.0.3, Jaybird 3.0.4, Jaybird 3.0.5
Fix Version/s: Jaybird 3.0.6, Jaybird 4


 Description  « Hide
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

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
There are no subversion log entries for this issue yet.