Skip to content

update UseContext example to handle rows.Err() correct#1726

Merged
kavirajk merged 3 commits intoClickHouse:mainfrom
ehsansouri23:patch-1
Dec 16, 2025
Merged

update UseContext example to handle rows.Err() correct#1726
kavirajk merged 3 commits intoClickHouse:mainfrom
ehsansouri23:patch-1

Conversation

@ehsansouri23
Copy link
Copy Markdown
Contributor

Check rows Error

Check rows.Err() after rows.Next(). related to this PR: #804

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Dec 3, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

@kavirajk kavirajk left a comment

Choose a reason for hiding this comment

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

thanks @ehsansouri23

@kavirajk
Copy link
Copy Markdown
Contributor

@ehsansouri23 thanks for the PR.

I think it's nice to have that error check on that example. But looks like that exposed some problem with TestStdContext. Can you fix it?

@ehsansouri23
Copy link
Copy Markdown
Contributor Author

@kavirajk Tests have been fixed

}
}
// query is cancelled using Context, so rows.Err() will return context canceled error
if err := rows.Err(); err == nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this is correct. What's the rationale for ignoring the rows.Err() here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if col2 == 3 the context is canceled, after that the rows will return context cancel error.
I didn't ignore the error. I assume that error should not be nil. we should have an error, because context is canceled before.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

True. But we should only ignore the context.Cancelled error not any other errors (that could be legit bug).

I pushed a commit to fix it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for the PR :)

Copy link
Copy Markdown
Contributor

@kavirajk kavirajk left a comment

Choose a reason for hiding this comment

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

We shouldn't ignore the err

@kavirajk kavirajk changed the title Update context.go update UseContext example to handle rows.Err() correct Dec 16, 2025
@kavirajk kavirajk merged commit 82be98e into ClickHouse:main Dec 16, 2025
13 checks passed
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