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

[CALCITE-6781] The isUpdateCapable method of calcite.avatica will incorrectly traverse the returned result value #267

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

caicancai
Copy link
Member

@caicancai caicancai commented Jan 12, 2025

https://issues.apache.org/jira/browse/CALCITE-6781

Recently I am adapting the delete statement of es, but when I support delete * from where condition and similar statements, an error will be reported in the isUpdateCapable method, as follows
java.util.NoSuchElementException: Expecting cursor position to be Position.OK, actual is Position.AFTER_END

The reason is that the openResultSet.next() of the delete statement is false. In the current isUpdateCapable method, whether openResultSet.next() is true or false, it will perform subsequent operations.
But when openResultSet.next() is false,

statement.openResultSet.getObject(ROWCOUNT_COLUMN_NAME)
will throw the exception I encountered above

So when openResultSet.next() is false, it should return null directly.

I am not very familiar with the avatica module, and I am not sure where to add the test

I also have a second solution signature.statementType.canUpdate() returns false which can also solve this problem

} else {
throw HELPER.createException("Not a valid return result.");
if (statement.openResultSet.next()) {
statement.openResultSet.next();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this cannot be right, you are advancing the cursor twice

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, remove

@caicancai caicancai requested a review from mihaibudiu January 13, 2025 02:40
Copy link
Member

@zabetak zabetak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in the JIRA, without a test case or a clear problem statement/description it will not be easy to merge a fix.

@caicancai caicancai requested a review from zabetak January 13, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants