[ 
https://issues.apache.org/jira/browse/CALCITE-6781?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17913103#comment-17913103
 ] 

Francis Chuang commented on CALCITE-6781:
-----------------------------------------

[~caicancai] I think you can add the test here: 
[https://github.com/apache/calcite-avatica/tree/main/core/src/test/java/org/apache/calcite/avatica]
 

Perhaps you can find an existing test that is testing a similiar concept and 
adapt it to reproduce this issue.

> The isUpdateCapable method of calcite.avatica will incorrectly traverse the 
> returned result value
> -------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-6781
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6781
>             Project: Calcite
>          Issue Type: Bug
>          Components: avatica
>    Affects Versions: avatica-1.25.0
>            Reporter: Caican Cai
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: avatica-1.26.0
>
>
> When the delete statement is executed, statement.openResultSet.next will 
> return false, and we do not need to perform subsequent operations.
> {code:java}
>   private void isUpdateCapable(final AvaticaStatement statement)
>       throws SQLException {
>     Meta.Signature signature = statement.getSignature();
>     if (signature == null || signature.statementType == null) {
>       return;
>     }
>     if (signature.statementType.canUpdate() && statement.updateCount == -1) {
>       statement.openResultSet.next();
>       Object obj = statement.openResultSet.getObject(ROWCOUNT_COLUMN_NAME);
>       if (obj instanceof Number) {
>         statement.updateCount = ((Number) obj).intValue();
>       } else if (obj instanceof List) {
>         @SuppressWarnings("unchecked")
>         final List<Number> numbers = (List<Number>) obj;
>         statement.updateCount = numbers.get(0).intValue();
>       } else {
>         throw HELPER.createException("Not a valid return result.");
>       }
>       statement.openResultSet = null;
>     }
>   }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to