Skip to content

executor, sqlexec: add a function to let DrainRecordSet also close the RecordSet #61448

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

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

Whitea029
Copy link
Contributor

What problem does this PR solve?

This PR addresses the enhancement suggestion regarding repetitive patterns when using DrainRecordSet. Previously, callers needed to manually defer the closing of the RecordSet after execution, which introduced boilerplate and risked forgetting to close the resource.

Issue Number: close #61408

Problem Summary:

What changed and how does it work?

This change introduces a new utility function DrainRecordSetAndClose, which automatically drains and closes the RecordSet, simplifying the common usage pattern and improving code readability and safety. Existing code that follows the defer Close() pattern can now be replaced with a single call to this new function.

Check List

Tests

  • Unit test
  • Integration test

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Add DrainRecordSetAndClose to simplify draining and closing RecordSet, reducing boilerplate and preventing resource leaks.

@ti-chi-bot ti-chi-bot bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 1, 2025
@sre-bot
Copy link
Contributor

sre-bot commented Jun 1, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

ti-chi-bot bot commented Jun 1, 2025

Welcome @Whitea029!

It looks like this is your first PR to pingcap/tidb 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to pingcap/tidb. 😃

Copy link

ti-chi-bot bot commented Jun 1, 2025

Hi @Whitea029. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot added needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 1, 2025
Copy link

tiprow bot commented Jun 1, 2025

Hi @Whitea029. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@lance6716
Copy link
Contributor

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Jun 1, 2025
@lance6716

This comment was marked as resolved.

Copy link

codecov bot commented Jun 1, 2025

Codecov Report

Attention: Patch coverage is 70.58824% with 5 lines in your changes missing coverage. Please review.

Project coverage is 73.5759%. Comparing base (e7b038b) to head (63f8476).
Report is 4 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #61448        +/-   ##
================================================
+ Coverage   73.1839%   73.5759%   +0.3919%     
================================================
  Files          1727       1729         +2     
  Lines        479899     482284      +2385     
================================================
+ Hits         351209     354845      +3636     
+ Misses       107194     105969      -1225     
+ Partials      21496      21470        -26     
Flag Coverage Δ
integration 42.3318% <70.5882%> (?)
unit 72.4473% <47.0588%> (+0.0176%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.7804% <ø> (ø)
parser ∅ <ø> (∅)
br 47.3136% <ø> (-0.1594%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Whitea029 Whitea029 force-pushed the opt-func-drainrecordset branch from 2bddf07 to 63f8476 Compare June 1, 2025 08:57
@Whitea029
Copy link
Contributor Author

/retest

@ti-chi-bot ti-chi-bot bot added the approved label Jun 1, 2025
@lance6716
Copy link
Contributor

/cc @YangKeao

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 1, 2025
@ti-chi-bot ti-chi-bot bot requested a review from YangKeao June 1, 2025 11:29
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 2, 2025
Copy link

ti-chi-bot bot commented Jun 2, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-06-01 11:29:37.829102595 +0000 UTC m=+182064.031447893: ☑️ agreed by lance6716.
  • 2025-06-02 03:15:33.327956166 +0000 UTC m=+238819.530301431: ☑️ agreed by hawkingrei.

@hawkingrei
Copy link
Member

/hold

@YangKeao PTAL

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 2, 2025
Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented Jun 3, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei, lance6716, YangKeao

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [YangKeao,hawkingrei,lance6716]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@lance6716
Copy link
Contributor

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 3, 2025
@hawkingrei
Copy link
Member

/retest

@Whitea029
Copy link
Contributor Author

/test check-dev

Copy link

tiprow bot commented Jun 3, 2025

@Whitea029: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test check-dev

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@Whitea029
Copy link
Contributor Author

/retest

1 similar comment
@lance6716
Copy link
Contributor

/retest

@ti-chi-bot ti-chi-bot bot merged commit 609805c into pingcap:master Jun 3, 2025
24 checks passed
@Whitea029 Whitea029 deleted the opt-func-drainrecordset branch June 3, 2025 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Let DrainRecordSet also close the RecordSet
5 participants