[ 
https://issues.apache.org/jira/browse/DERBY-4031?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12667836#action_12667836
 ] 

Knut Anders Hatlen commented on DERBY-4031:
-------------------------------------------

Matching IDENTITY_VAL_LOCAL() means that we always return a ResultSet with one 
column, but it is possible to have multiple generated key columns, so I'm not 
sure if matching the signature of IDENTITY_VAL_LOCAL() makes more sense than 
having 0 columns. Derby doesn't support multiple identity columns yet, but 
there is an API to support it.

I think I would have preferred that an exception was thrown, though. The 
justification for the empty ResultSet appears to be this sentence in the 
javadoc:

> If this Statement object did not generate any keys, an empty ResultSet object 
> is returned.

But in the case we're discussing, it's not necessarily the case that no keys 
were generated by the Statement object, it's just that we said that we didn't 
want the auto-generated keys to be returned.

The way I understand the javadoc, it is acceptable to throw an exception in 
this case. In particular, it says:

> Throws:
>    SQLException - if a database access error occurs or this method is called 
> on a closed Statement

So I think we could throw an SQLException because we failed to get the 
generated keys from the database because we had specified that we didn't want 
the generated keys.

> If NO_GENERATED_KEYS is specified, Statement.getGeneratedKeys should return 
> an empty ResultSet, not null 
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-4031
>                 URL: https://issues.apache.org/jira/browse/DERBY-4031
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.3.0, 10.4.2.0, 10.5.0.0
>            Reporter: Kathey Marsden
>             Fix For: 10.5.0.0
>
>
> Currently Derby returns null from Statement.getGeneratedKeys() if  the 
> statement is prepared or executed with Statement.NO_GENERATED_KEYS. The 
> javadoc says:
> If this Statement object did not generate any keys, an empty ResultSet object 
> is returned.
> so we should return an empty ResultSet for this case.  It is not entirely 
> clear what the structure of the ResultSet and ResultSetMetaData should be.  I 
> tend to think the following:
> getConcurrency() - inherit from the parent statement
> getStatement() - null
> ResultSetMetaData
> getColumnCount - 0
> an alternative would be to have the ResultSetMetaData match the signature of 
> Identity_Val_local() but I think to return 0 columns makes more sense.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to