Skip to content

Incorrect update count (0.3.2-patch9) #947

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

Closed
Veirisa opened this issue May 29, 2022 · 2 comments
Closed

Incorrect update count (0.3.2-patch9) #947

Veirisa opened this issue May 29, 2022 · 2 comments
Labels
Milestone

Comments

@Veirisa
Copy link

Veirisa commented May 29, 2022

Hi!

In com.clickhouse.jdbc.internal.ClickHouseStatementImpl#updateResult:

...
// FIXME apparently this is not always true
if (currentUpdateCount <= 0L) {
    currentUpdateCount = 1L;
}
...

Yes, this isn’t always true :)

Examples:

Statement statement = connection.createStatement();
statement.execute(sql);
int updateCount = statement.getUpdateCount();
  1. String sql = “CREATE TABLE new_table(x INT) engine = Memory;”
    Expected updateCount: 0
    Actual updateCount: 1

  2. String sql = "INSERT INTO new_table VALUES (1), (2), (3);"
    Expected updateCount: 3
    Actual updateCount: 1

@zhicwu zhicwu added the bug label May 29, 2022
@zhicwu
Copy link
Contributor

zhicwu commented May 29, 2022

You got me :p

Have you tried send_progress_in_http_headers option like used here? With that, I think case 2 will be fixed but case 1 stays the same. Let me think how to tackle this without much parsing efforts.

Update: returning actual update count in http without additional setting is possible in 22.6+ - see ClickHouse/ClickHouse#36884

@zhicwu
Copy link
Contributor

zhicwu commented Jul 28, 2022

Now the update count depends on two things: 1) SQL parser(a bit outdated); and 2) summary returned from server. Above two cases work as expected on 22.6+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants