[ 
https://issues.apache.org/jira/browse/CALCITE-6781?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Caican Cai updated CALCITE-6781:
--------------------------------
    Description: 
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}




  was:
When the delete statement is executed, statement.openResultSet.next will return 
false, and we do not need to perform subsequent operations.




> 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: 1.35.0, 1.38.0
>            Reporter: Caican Cai
>            Priority: Major
>             Fix For: 1.39.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