You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Gregory Hart (Jira)" <ji...@apache.org> on 2022/12/20 23:08:00 UTC

[jira] [Updated] (CALCITE-5443) Reset update count when checking for more results

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

Gregory Hart updated CALCITE-5443:
----------------------------------
    Description: 
After {{java.sql.Statement.getMoreResults()}} has returned false, {{Statement.getUpdateCount()}} should return {{{}-1{}}}. This indicates to the client that there are no additional result sets available. Calcite currently supports at most one result set per SQL statement.

*Background*

Some databases, such as Oracle Database, allow stored procedures to return multiple result sets. The JDBC API provides {{Statement.getMoreResults()}} for users to check if the statement has more than one result set and to retrieve the next result set. Calcite does not support this feature and only returns zero or one result set. The problem is that Calcite sometimes returns the wrong value for {{Statement.getUpdateCount()}} and indicates that additional results are available.

The JavaDoc for {{java.sql.Statement#getMoreResults(int)}} says there are no more results when the following is true:
{code:java}
// stmt is a Statement object
((stmt.getMoreResults(current) == false) && (stmt.getUpdateCount() == -1)) {code}
In {{{}AvaticaStatement{}}}, {{getMoreResults(int)}} always returns {{false}} but does not reset the {{{}updateCount{}}}. This could indicate to the client that there are additional results (which is not true), and could result in an infinite loop in the JDBC client as it tries to read the additional results.

*Steps to reproduce:*
 # Execute an INSERT query by calling Statement#execute(String). Verify that the return value is false indicating it is an update count.
 # Call Statement#getMoreResults(). Verify that the return value is false indicating it is an update count or there are no more results.
 # Call Statement#getUpdateCount().

*Expected results:*

The call to getUpdateCount() returns -1 indicating there are no more results.

*Actual results:*

The call to getUpdateCount() returns the update count for the INSERT query, which should only have one result.

  was:
The JavaDoc for {{java.sql.Statement#getMoreResults(int)}} says there are no more results when the following is true:

 
{code:java}
// stmt is a Statement object  ((stmt.getMoreResults(current) == false) && (stmt.getUpdateCount() == -1)) {code}
In {{{}AvaticaStatement{}}}, {{getMoreResults(int)}} always returns {{false}} but does not reset the {{{}updateCount{}}}. This could result in an infinite loop in the JDBC client because the return value is indicating there are additional results when there are actually none.

 

*Steps to reproduce:*
 # Execute an INSERT query by calling Statement#execute(String). Verify that the return value is false indicating it is an update count.
 # Call Statement#getMoreResults(). Verify that the return value is false indicating it is an update count or there are no more results.
 # Call Statement#getUpdateCount().

*Expected results:*

The call to getUpdateCount() returns -1 indicating there are no more results.

*Actual results:*

The call to getUpdateCount() returns the update count for the INSERT query, which should only have one result.


> Reset update count when checking for more results
> -------------------------------------------------
>
>                 Key: CALCITE-5443
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5443
>             Project: Calcite
>          Issue Type: Bug
>          Components: avatica
>            Reporter: Gregory Hart
>            Assignee: Gregory Hart
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> After {{java.sql.Statement.getMoreResults()}} has returned false, {{Statement.getUpdateCount()}} should return {{{}-1{}}}. This indicates to the client that there are no additional result sets available. Calcite currently supports at most one result set per SQL statement.
> *Background*
> Some databases, such as Oracle Database, allow stored procedures to return multiple result sets. The JDBC API provides {{Statement.getMoreResults()}} for users to check if the statement has more than one result set and to retrieve the next result set. Calcite does not support this feature and only returns zero or one result set. The problem is that Calcite sometimes returns the wrong value for {{Statement.getUpdateCount()}} and indicates that additional results are available.
> The JavaDoc for {{java.sql.Statement#getMoreResults(int)}} says there are no more results when the following is true:
> {code:java}
> // stmt is a Statement object
> ((stmt.getMoreResults(current) == false) && (stmt.getUpdateCount() == -1)) {code}
> In {{{}AvaticaStatement{}}}, {{getMoreResults(int)}} always returns {{false}} but does not reset the {{{}updateCount{}}}. This could indicate to the client that there are additional results (which is not true), and could result in an infinite loop in the JDBC client as it tries to read the additional results.
> *Steps to reproduce:*
>  # Execute an INSERT query by calling Statement#execute(String). Verify that the return value is false indicating it is an update count.
>  # Call Statement#getMoreResults(). Verify that the return value is false indicating it is an update count or there are no more results.
>  # Call Statement#getUpdateCount().
> *Expected results:*
> The call to getUpdateCount() returns -1 indicating there are no more results.
> *Actual results:*
> The call to getUpdateCount() returns the update count for the INSERT query, which should only have one result.



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