Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getGeneratedKeys execute methods should disallow empty or null arrays [JDBC567] #599

Closed
firebird-automations opened this issue Dec 8, 2018 · 4 comments

Comments

@firebird-automations
Copy link

Submitted by: @mrotteveel

Although inconsistently documented, JDBC requires that the columnIndexes and columnNames array are non-null and non-empty for statements that are capable of generating keys. For example Statement.executeUpdate(String sql, int[] columnIndexes) in Java 11 specifies:

"""
[..]
The driver will ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
[..]

Throws:
SQLException - if [..] the second argument supplied to this method is not an int array whose elements are valid column indexes
"""

Jaybird currently allows this for generated keys statement and executes as if it is a non-generated keys method if the array is null or empty, or ignores the invalid column index if there are other columns present. Instead an exception should be thrown.

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Fix Version: Jaybird 4 [ 10441 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

description: Although inconsistently documented, JDBC requires that the columnIndexes and columnNames array are non-null and non-empty for statements that are capable of generating keys. For example Statement.executeUpdate(String sql, int[] columnIndexes) in Java 11 specifies:

"""
Throws:
SQLException - if [..] the second argument supplied to this method is not an int array whose elements are valid column indexes
"""

Jaybird currently allows this and executes as if it is a non-generated keys method if the array is null or empty, or ignores the invalid column index if there are other columns present. Instead an exception should be thrown.

=>

Although inconsistently documented, JDBC requires that the columnIndexes and columnNames array are non-null and non-empty for statements that are capable of generating keys. For example Statement.executeUpdate(String sql, int[] columnIndexes) in Java 11 specifies:

"""
[..]
The driver will ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
[..]

Throws:
SQLException - if [..] the second argument supplied to this method is not an int array whose elements are valid column indexes
"""

Jaybird currently allows this for generated keys statement and executes as if it is a non-generated keys method if the array is null or empty, or ignores the invalid column index if there are other columns present. Instead an exception should be thrown.

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment