Issue Details (XML | Word | Printable)

Key: JDBC-391
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
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

SELECT statements are processed for getGeneratedKeys by appending RETURNING (+ all columnnames)

Created: 20/Apr/15 06:20 PM   Updated: 31/May/15 02:37 PM
Component/s: JDBC driver
Affects Version/s: Jaybird 2.2, Jaybird 2.2.1, Jaybird 2.2.2, Jaybird 2.2.3, Jaybird 2.2.4, Jaybird 2.2.5, Jaybird 2.2.6, Jaybird 2.2.7
Fix Version/s: Jaybird 2.2.8, Jaybird 3.0.0


 Description  « Hide
The generated keys implementation assumes that the parser throws an exception on SELECT queries, and would then proceed executing the query normally. Unfortunately the parser doesn't throw an exception on a SELECT, and instead it processes the query by appending `RETURNING` + all columns in the database (which seems to be another bug in and of itself).

There are currently no tests that check the assumption that SELECT is treated unmodified.

See http://stackoverflow.com/questions/29752184/query-error-using-firebird-rdbms-with-coldfusion-11

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Mark Rotteveel added a comment - 20/Apr/15 07:19 PM
Added initial test that demonstrates this is broken.

Mark Rotteveel added a comment - 27/Apr/15 02:08 PM
Errors during parsing are now checked, and if there have been parser errors, or if no table name was found, then the query is executed as if it isn't a generated keys query. This fixes this problem (and some related issues).

Commits:
master: https://github.com/FirebirdSQL/jaybird/commit/91e001366ace1ad507f789916f258dd80fd45a55
Branch_2_2: https://github.com/FirebirdSQL/jaybird/commit/9573cae3355c86a8723714c09655dab4997af1e3

Mark Rotteveel added a comment - 27/Apr/15 02:34 PM
On further examination the parser intentionally ignores parser errors so it only has to process the first part of the query, and doesn't need to process the full statement.

Mark Rotteveel added a comment - 27/Apr/15 02:57 PM
Removed check for parser errors, the grammar is incomplete, for example DELETE and UPDATE are only implemented sufficiently to obtain the table name. Now only absence of table name in the statement model is considered for treating it as invalid.

Commits:
master: https://github.com/FirebirdSQL/jaybird/commit/047825ddb952a5401a1297be45250e7316bd49b8
Branch_2_2: https://github.com/FirebirdSQL/jaybird/commit/845ea7bcd0a8ffd61a4bf92e992e37e85a02acd6

More tests need to be added.